diff --git a/ChangeLog b/ChangeLog index 36fbb4ed8a1..5f807c7d2fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,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 ***** diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f2b508f665e..598f19ee0a0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -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; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4238d0ee041..2ed7ccab8ef 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2153,6 +2153,12 @@ if ($action == 'create') print ''; } + // Delivery delay (in days) + print '
| '; @@ -2181,12 +2187,6 @@ if ($action == 'create') } print ' | |
| '.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').' | '; - print ''.$object->getMaxDeliveryTimeDay($langs).' | '; - print ''; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -1009,7 +1009,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 '); @@ -1059,7 +1059,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; @@ -1169,19 +1169,23 @@ if ($resql) { print ' | '; 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 ' | '; if (!$i) $totalarray['nbfield']++; } // Plannned date of delivery - if (!empty($arrayfields['cf.date_delivery']['checked'])) + if (!empty($arrayfields['cf.date_livraison']['checked'])) { print ''; - 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 ' | '; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 78f08dcd04e..99ab93ca973 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -498,7 +498,6 @@ if ($search_all || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_P if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid'; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b314171c2c0..c91f4802974 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1517,7 +1517,8 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr // To use external ckeditor 4 js lib $pathckeditor = constant('JS_CKEDITOR'); } - print ''."\n"; print ''."\n"; print '