Created Facture::hasDelay function
This commit is contained in:
parent
3fbab48d81
commit
3c5159f497
@ -3222,8 +3222,9 @@ else if ($id > 0 || ! empty($ref))
|
||||
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm');
|
||||
} else {
|
||||
print dol_print_date($object->date_lim_reglement, 'daytext');
|
||||
if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am))
|
||||
if ($object->hasDelay()) {
|
||||
print img_warning($langs->trans('Late'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print ' ';
|
||||
|
||||
@ -3236,11 +3236,15 @@ class Facture extends CommonInvoice
|
||||
$response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1';
|
||||
$response->img=img_object($langs->trans("Bills"),"bill");
|
||||
|
||||
$generic_facture = new Facture($this->db);
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin);
|
||||
|
||||
$response->nbtodo++;
|
||||
|
||||
if ($this->db->jdate($obj->datefin) < ($now - $conf->facture->client->warning_delay)) {
|
||||
if ($generic_facture->hasDelay()) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
@ -3697,6 +3701,25 @@ class Facture extends CommonInvoice
|
||||
|
||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the customer invoice delayed?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDelay()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
//Paid invoices have status STATUS_CLOSED
|
||||
if (!$this->statut != Facture::STATUS_VALIDATED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -378,6 +378,8 @@ if ($resql)
|
||||
$facturestatic->id=$objp->facid;
|
||||
$facturestatic->ref=$objp->facnumber;
|
||||
$facturestatic->type=$objp->type;
|
||||
$facturestatic->statut = $objp->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
|
||||
$notetoshow=dol_string_nohtmltag(($user->societe_id>0?$objp->note_public:$objp->note),1);
|
||||
$paiement = $facturestatic->getSommePaiement();
|
||||
|
||||
@ -417,7 +419,7 @@ if ($resql)
|
||||
|
||||
// Date limit
|
||||
print '<td align="center" class="nowrap">'.dol_print_date($datelimit,'day');
|
||||
if ($datelimit < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $paiement)
|
||||
if ($facturestatic->hasDelay())
|
||||
{
|
||||
print img_warning($langs->trans('Late'));
|
||||
}
|
||||
|
||||
@ -734,6 +734,8 @@ if ($resql)
|
||||
$facturestatic->id=$objp->facid;
|
||||
$facturestatic->ref=$objp->facnumber;
|
||||
$facturestatic->type=$objp->type;
|
||||
$facturestatic->statut=$objp->fk_statut;
|
||||
$facturestatic->date_lim_reglement= $db->jdate($objp->datelimite);
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
|
||||
@ -744,7 +746,9 @@ if ($resql)
|
||||
|
||||
// Warning picto
|
||||
print '<td width="20" class="nobordernopadding nowrap">';
|
||||
if ($date_limit < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
|
||||
if ($facturestatic->hasDelay()) {
|
||||
print img_warning($langs->trans("Late"));
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// PDF Picto
|
||||
|
||||
@ -356,7 +356,9 @@ if ($object->id > 0)
|
||||
else
|
||||
{
|
||||
print dol_print_date($object->date_lim_reglement,'daytext');
|
||||
if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == Facture::STATUS_VALIDATED && ! isset($object->am)) print img_warning($langs->trans('Late'));
|
||||
if ($object->hasDelay()) {
|
||||
print img_warning($langs->trans('Late'));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -358,11 +358,15 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->statut = $obj->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
|
||||
$facturestatic->type=$obj->type;
|
||||
print $facturestatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td width="20" class="nobordernopadding nowrap">';
|
||||
if ($obj->fk_statut == 1 && ! $obj->paye && $db->jdate($obj->datelimite) < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
if ($facturestatic->hasDelay()) {
|
||||
print img_warning($langs->trans("Late"));
|
||||
}
|
||||
print '</td>';
|
||||
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
|
||||
$filename=dol_sanitizeFileName($obj->facnumber);
|
||||
@ -800,10 +804,14 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->type=$obj->type;
|
||||
$facturestatic->statut = $obj->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
|
||||
print $facturestatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td width="20" class="nobordernopadding nowrap">';
|
||||
if ($db->jdate($obj->datelimite) < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
if ($facturestatic->hasDelay()) {
|
||||
print img_warning($langs->trans("Late"));
|
||||
}
|
||||
print '</td>';
|
||||
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
|
||||
$filename=dol_sanitizeFileName($obj->facnumber);
|
||||
|
||||
@ -108,12 +108,18 @@ class box_factures extends ModeleBoxes
|
||||
$facturestatic->total_ht = $objp->total_ht;
|
||||
$facturestatic->total_tva = $objp->total_tva;
|
||||
$facturestatic->total_ttc = $objp->total_ttc;
|
||||
$facturestatic->statut = $objp->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
|
||||
|
||||
$societestatic->id = $objp->socid;
|
||||
$societestatic->name = $objp->name;
|
||||
$societestatic->code_client = $objp->code_client;
|
||||
|
||||
|
||||
$late = '';
|
||||
if ($objp->paye == 0 && ($objp->fk_statut != 2 && $objp->fk_statut != 3) && $datelimite < ($now - $conf->facture->client->warning_delay)) { $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));}
|
||||
if ($facturestatic->hasDelay()) {
|
||||
$late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));
|
||||
}
|
||||
|
||||
$this->info_box_contents[$line][] = array(
|
||||
'td' => 'align="left"',
|
||||
|
||||
@ -108,6 +108,8 @@ class box_factures_imp extends ModeleBoxes
|
||||
$facturestatic->total_ht = $objp->total_ht;
|
||||
$facturestatic->total_tva = $objp->total_tva;
|
||||
$facturestatic->total_ttc = $objp->total_ttc;
|
||||
$facturestatic->statut = $objp->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
|
||||
$societestatic->id = $objp->socid;
|
||||
$societestatic->name = $objp->name;
|
||||
$societestatic->client = 1;
|
||||
@ -115,7 +117,9 @@ class box_factures_imp extends ModeleBoxes
|
||||
$societestatic->logo = $objp->logo;
|
||||
|
||||
$late='';
|
||||
if ($datelimite < ($now - $conf->facture->client->warning_delay)) $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));
|
||||
if ($facturestatic->hasDelay()) {
|
||||
$late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));
|
||||
}
|
||||
|
||||
$this->info_box_contents[$line][] = array(
|
||||
'td' => 'align="left"',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user