mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
FIX status late on purchase orders
This commit is contained in:
parent
eae232da50
commit
e1af57f540
|
|
@ -51,6 +51,7 @@ FIX: Timeout during import
|
|||
FIX: Trigger on expense report was not fired
|
||||
FIX: User creation of expense report not visible
|
||||
FIX: warning when adding a line if $remise_percent is an empty string
|
||||
FIX: status late on purchase orders
|
||||
|
||||
|
||||
***** ChangeLog for 13.0.0 compared to 12.0.0 *****
|
||||
|
|
|
|||
|
|
@ -3069,8 +3069,10 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
/**
|
||||
* Is the supplier order delayed?
|
||||
* We suppose a purchase ordered as late if a the purchase order has been sent and the delivery date is set and before the delay.
|
||||
* If order has not been sent, we use the order date.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool True if object is delayed
|
||||
*/
|
||||
public function hasDelay()
|
||||
{
|
||||
|
|
@ -3078,14 +3080,28 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
if (empty($this->delivery_date) && !empty($this->date_livraison)) $this->delivery_date = $this->date_livraison; // For backward compatibility
|
||||
|
||||
$now = dol_now();
|
||||
$date_to_test = empty($this->delivery_date) ? $this->date_commande : $this->delivery_date;
|
||||
if ($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY) {
|
||||
$now = dol_now();
|
||||
if (!empty($this->delivery_date)) {
|
||||
$date_to_test = $this->delivery_date;
|
||||
return $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
|
||||
} else {
|
||||
//$date_to_test = $this->date_commande;
|
||||
//return $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$now = dol_now();
|
||||
$date_to_test = $this->date_commande;
|
||||
|
||||
return ($this->statut > 0 && $this->statut < 5) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
|
||||
return ($this->statut > 0 && $this->statut < 5) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the customer delayed info
|
||||
* Show the customer delayed info.
|
||||
* We suppose a purchase ordered as late if a the purchase order has been sent and the delivery date is set and before the delay.
|
||||
* If order has not been sent, we use the order date.
|
||||
*
|
||||
* @return string Show delayed information
|
||||
*/
|
||||
|
|
@ -3095,12 +3111,20 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
if (empty($this->delivery_date) && !empty($this->date_livraison)) $this->delivery_date = $this->date_livraison; // For backward compatibility
|
||||
|
||||
if (empty($this->delivery_date)) {
|
||||
$text = $langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
|
||||
$text = '';
|
||||
|
||||
if ($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY) {
|
||||
if (!empty($this->delivery_date)) {
|
||||
$text = $langs->trans("DeliveryDate").' '.dol_print_date($this->delivery_date, 'day');
|
||||
} else {
|
||||
$text = $langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
|
||||
}
|
||||
} else {
|
||||
$text = $langs->trans("DeliveryDate").' '.dol_print_date($this->delivery_date, 'day');
|
||||
$text = $langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
|
||||
}
|
||||
if ($text) {
|
||||
$text .= ' '.($conf->commande->fournisseur->warning_delay > 0 ? '+' : '-').' '.round(abs($conf->commande->fournisseur->warning_delay) / 3600 / 24, 1).' '.$langs->trans("days").' < '.$langs->trans("Today");
|
||||
}
|
||||
$text .= ' '.($conf->commande->fournisseur->warning_delay > 0 ? '+' : '-').' '.round(abs($conf->commande->fournisseur->warning_delay) / 3600 / 24, 1).' '.$langs->trans("days").' < '.$langs->trans("Today");
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2147,6 +2147,12 @@ if ($action == 'create')
|
|||
print '</tr>';
|
||||
}
|
||||
|
||||
// Delivery delay (in days)
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').'</td>';
|
||||
print '<td>'.$object->getMaxDeliveryTimeDay($langs).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Delivery date planed
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding centpercent"><tr><td>';
|
||||
|
|
@ -2175,12 +2181,6 @@ if ($action == 'create')
|
|||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Delivery delay (in days)
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').'</td>';
|
||||
print '<td>'.$object->getMaxDeliveryTimeDay($langs).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Incoterms
|
||||
if (!empty($conf->incoterm->enabled))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ if ($id > 0 || !empty($ref)) {
|
|||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
$sql .= $hookmanager->resPrint;
|
||||
|
||||
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
|
||||
$sql .= " GROUP BY p.ref, p.label, p.tobatch, p.fk_default_warehouse, l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
|
||||
$sql .= " ORDER BY p.ref, p.label";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
|
|
|||
|
|
@ -142,30 +142,30 @@ if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate";
|
|||
|
||||
$checkedtypetiers = 0;
|
||||
$arrayfields = array(
|
||||
'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||
'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplierShort"), 'checked'=>1, 'enabled'=>1),
|
||||
'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1),
|
||||
'u.login'=>array('label'=>$langs->trans("AuthorRequest"), 'checked'=>1),
|
||||
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
|
||||
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
|
||||
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
|
||||
'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
|
||||
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
|
||||
'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
|
||||
'cf.date_commande'=>array('label'=>$langs->trans("OrderDateShort"), 'checked'=>1),
|
||||
'cf.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)),
|
||||
'cf.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
|
||||
'cf.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
|
||||
'cf.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
|
||||
'cf.ref'=>array('label'=>"Ref", 'checked'=>1),
|
||||
'cf.ref_supplier'=>array('label'=>"RefOrderSupplierShort", 'checked'=>1, 'enabled'=>1),
|
||||
'p.project_ref'=>array('label'=>"ProjectRef", 'checked'=>0, 'enabled'=>1),
|
||||
'u.login'=>array('label'=>"AuthorRequest", 'checked'=>1),
|
||||
's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
|
||||
's.town'=>array('label'=>"Town", 'checked'=>1),
|
||||
's.zip'=>array('label'=>"Zip", 'checked'=>1),
|
||||
'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
|
||||
'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
|
||||
'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
|
||||
'cf.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1),
|
||||
'cf.date_livraison'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)),
|
||||
'cf.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
|
||||
'cf.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
|
||||
'cf.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
|
||||
'cf.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
|
||||
'cf.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
|
||||
'cf.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
|
||||
'cf.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
|
||||
'cf.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
|
||||
'cf.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
||||
'cf.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
|
||||
'cf.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||
'cf.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>1)
|
||||
'cf.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
|
||||
'cf.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
|
||||
'cf.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
|
||||
'cf.billed'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>1)
|
||||
);
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
|
@ -525,7 +525,7 @@ if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DI
|
|||
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
|
||||
$sql .= " typent.code as typent_code,";
|
||||
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,";
|
||||
$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,";
|
||||
$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva as multicurrency_total_vat, cf.multicurrency_total_ttc,';
|
||||
$sql .= ' cf.date_creation as date_creation, cf.tms as date_update,';
|
||||
$sql .= ' cf.note_public, cf.note_private,';
|
||||
|
|
@ -874,7 +874,7 @@ if ($resql)
|
|||
print '</td>';
|
||||
}
|
||||
// Date delivery
|
||||
if (!empty($arrayfields['cf.date_delivery']['checked']))
|
||||
if (!empty($arrayfields['cf.date_livraison']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall center">';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">';
|
||||
|
|
@ -993,7 +993,7 @@ if ($resql)
|
|||
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cf.date_livraison']['checked'])) print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
|
|
@ -1043,7 +1043,7 @@ if ($resql)
|
|||
$objectstatic->total_tva = $obj->total_tva;
|
||||
$objectstatic->total_ttc = $obj->total_ttc;
|
||||
$objectstatic->date_commande = $db->jdate($obj->date_commande);
|
||||
$objectstatic->date_delivery = $db->jdate($obj->date_delivery);
|
||||
$objectstatic->delivery_date = $db->jdate($obj->date_livraison);
|
||||
$objectstatic->note_public = $obj->note_public;
|
||||
$objectstatic->note_private = $obj->note_private;
|
||||
$objectstatic->statut = $obj->fk_statut;
|
||||
|
|
@ -1153,19 +1153,23 @@ if ($resql)
|
|||
{
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($obj->date_commande), 'day');
|
||||
if ($objectstatic->hasDelay() && !empty($objectstatic->date_delivery)) {
|
||||
print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
|
||||
if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
|
||||
if ($objectstatic->hasDelay()) {
|
||||
print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Plannned date of delivery
|
||||
if (!empty($arrayfields['cf.date_delivery']['checked']))
|
||||
if (!empty($arrayfields['cf.date_livraison']['checked']))
|
||||
{
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($obj->date_delivery), 'day');
|
||||
if ($objectstatic->hasDelay() && !empty($objectstatic->date_delivery)) {
|
||||
print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
|
||||
print dol_print_date($db->jdate($obj->date_livraison), 'day');
|
||||
if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
|
||||
if ($objectstatic->hasDelay()) {
|
||||
print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user