Created Commande::hasDelay function
This commit is contained in:
parent
6964f80d8f
commit
3fbab48d81
@ -2846,7 +2846,7 @@ class Commande extends CommonOrder
|
|||||||
|
|
||||||
$clause = " WHERE";
|
$clause = " WHERE";
|
||||||
|
|
||||||
$sql = "SELECT c.rowid, c.date_creation as datec, c.date_livraison as delivery_date, c.fk_statut";
|
$sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id)
|
if (!$user->rights->societe->client->voir && !$user->societe_id)
|
||||||
{
|
{
|
||||||
@ -2862,21 +2862,22 @@ class Commande extends CommonOrder
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$now=dol_now();
|
|
||||||
|
|
||||||
$response = new WorkboardResponse();
|
$response = new WorkboardResponse();
|
||||||
$response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
|
$response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
|
||||||
$response->label=$langs->trans("OrdersToProcess");
|
$response->label=$langs->trans("OrdersToProcess");
|
||||||
$response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3';
|
$response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3';
|
||||||
$response->img=img_object($langs->trans("Orders"),"order");
|
$response->img=img_object($langs->trans("Orders"),"order");
|
||||||
|
|
||||||
|
$generic_commande = new Commande($this->db);
|
||||||
|
|
||||||
while ($obj=$this->db->fetch_object($resql))
|
while ($obj=$this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$response->nbtodo++;
|
$response->nbtodo++;
|
||||||
|
|
||||||
$date_to_test = empty($obj->delivery_date) ? $obj->datec : $obj->delivery_date;
|
$generic_commande->statut = $obj->fk_statut;
|
||||||
|
$generic_commande->date_livraison = $obj->delivery_date;
|
||||||
|
|
||||||
if ($obj->fk_statut != 3 && $this->db->jdate($date_to_test) < ($now - $conf->commande->client->warning_delay)) {
|
if ($generic_commande->hasDelay()) {
|
||||||
$response->nbtodolate++;
|
$response->nbtodolate++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3341,6 +3342,24 @@ class Commande extends CommonOrder
|
|||||||
|
|
||||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the customer order delayed?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasDelay()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
if (!($this->statut > Commande::STATUS_DRAFT) && ($this->statut < Commande::STATUS_CLOSED)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
|
||||||
|
return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -357,9 +357,11 @@ if ($resql)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
|
|
||||||
$generic_commande->id=$objp->rowid;
|
$generic_commande->id=$objp->rowid;
|
||||||
$generic_commande->ref=$objp->ref;
|
$generic_commande->ref=$objp->ref;
|
||||||
|
$generic_commande->statut = $objp->fk_statut;
|
||||||
|
$generic_commande->date_commande = $db->jdate($objp->date_commande);
|
||||||
|
$generic_commande->date_livraison = $db->jdate($objp->date_delivery);
|
||||||
$generic_commande->ref_client = $objp->ref_client;
|
$generic_commande->ref_client = $objp->ref_client;
|
||||||
$generic_commande->total_ht = $objp->total_ht;
|
$generic_commande->total_ht = $objp->total_ht;
|
||||||
$generic_commande->total_tva = $objp->total_tva;
|
$generic_commande->total_tva = $objp->total_tva;
|
||||||
@ -444,8 +446,9 @@ if ($resql)
|
|||||||
|
|
||||||
// warning late icon
|
// warning late icon
|
||||||
print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
|
print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
|
||||||
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && max($db->jdate($objp->date_commande),$db->jdate($objp->date_delivery)) < ($now - $conf->commande->client->warning_delay))
|
if ($generic_commande->hasDelay()) {
|
||||||
print img_picto($langs->trans("Late"), "warning");
|
print img_picto($langs->trans("Late"), "warning");
|
||||||
|
}
|
||||||
if(!empty($objp->note_private))
|
if(!empty($objp->note_private))
|
||||||
{
|
{
|
||||||
print ' <span class="note">';
|
print ' <span class="note">';
|
||||||
|
|||||||
@ -633,6 +633,9 @@ if (($action != 'create' && $action != 'add') && !$error)
|
|||||||
|
|
||||||
$generic_commande->id=$objp->rowid;
|
$generic_commande->id=$objp->rowid;
|
||||||
$generic_commande->ref=$objp->ref;
|
$generic_commande->ref=$objp->ref;
|
||||||
|
$generic_commande->statut = $objp->fk_statut;
|
||||||
|
$generic_commande->date_commande = $db->jdate($objp->date_commande);
|
||||||
|
$generic_commande->date_livraison = $db->jdate($objp->date_livraison);
|
||||||
|
|
||||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||||
print '<td class="nobordernopadding nowrap">';
|
print '<td class="nobordernopadding nowrap">';
|
||||||
@ -640,7 +643,9 @@ if (($action != 'create' && $action != 'add') && !$error)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td width="20" class="nobordernopadding nowrap">';
|
print '<td width="20" class="nobordernopadding nowrap">';
|
||||||
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && $db->jdate($objp->date_valid) < ($now - $conf->commande->client->warning_delay)) print img_picto($langs->trans("Late"),"warning");
|
if ($generic_commande->hasDelay()) {
|
||||||
|
print img_picto($langs->trans("Late"),"warning");
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
|
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user