Created FactureFournisseur::hasDelay function
This commit is contained in:
parent
f1ea19e09b
commit
47e62f2270
@ -93,7 +93,6 @@ class box_factures_fourn extends ModeleBoxes
|
|||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$now=dol_now();
|
|
||||||
|
|
||||||
$line = 0;
|
$line = 0;
|
||||||
$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)';
|
$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)';
|
||||||
@ -108,6 +107,8 @@ class box_factures_fourn extends ModeleBoxes
|
|||||||
$facturestatic->total_ht = $objp->total_ht;
|
$facturestatic->total_ht = $objp->total_ht;
|
||||||
$facturestatic->total_tva = $objp->total_tva;
|
$facturestatic->total_tva = $objp->total_tva;
|
||||||
$facturestatic->total_ttc = $objp->total_ttc;
|
$facturestatic->total_ttc = $objp->total_ttc;
|
||||||
|
$facturestatic->date_echeance = $datelimite;
|
||||||
|
$facturestatic->statut = $objp->fk_statut;
|
||||||
$thirdpartytmp->id = $objp->socid;
|
$thirdpartytmp->id = $objp->socid;
|
||||||
$thirdpartytmp->name = $objp->name;
|
$thirdpartytmp->name = $objp->name;
|
||||||
$thirdpartytmp->fournisseur = 1;
|
$thirdpartytmp->fournisseur = 1;
|
||||||
@ -115,7 +116,10 @@ class box_factures_fourn extends ModeleBoxes
|
|||||||
$thirdpartytmp->logo = $objp->logo;
|
$thirdpartytmp->logo = $objp->logo;
|
||||||
|
|
||||||
$late = '';
|
$late = '';
|
||||||
if ($objp->paye == 0 && $datelimite && $datelimite < ($now - $conf->facture->fournisseur->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(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'align="left"',
|
'td' => 'align="left"',
|
||||||
|
|||||||
@ -86,11 +86,12 @@ class box_factures_fourn_imp extends ModeleBoxes
|
|||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$now=dol_now();
|
|
||||||
|
|
||||||
$line = 0;
|
$line = 0;
|
||||||
$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)';
|
$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)';
|
||||||
|
|
||||||
|
$facturestatic = new FactureFournisseur($db);
|
||||||
|
|
||||||
while ($line < $num)
|
while ($line < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
@ -99,9 +100,13 @@ class box_factures_fourn_imp extends ModeleBoxes
|
|||||||
$thirdpartytmp->name = $objp->name;
|
$thirdpartytmp->name = $objp->name;
|
||||||
$thirdpartytmp->code_client = $objp->code_client;
|
$thirdpartytmp->code_client = $objp->code_client;
|
||||||
$thirdpartytmp->logo = $objp->logo;
|
$thirdpartytmp->logo = $objp->logo;
|
||||||
|
$facturestatic->date_echeance = $datelimite;
|
||||||
|
$facturestatic->statut = $objp->fk_statut;
|
||||||
|
|
||||||
$late='';
|
$late='';
|
||||||
if ($datelimite && $datelimite < ($now - $conf->facture->fournisseur->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')));
|
||||||
|
}
|
||||||
|
|
||||||
$tooltip = $langs->trans('SupplierInvoice') . ': ' . ($objp->ref?$objp->ref:$objp->facid) . '<br>' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier;
|
$tooltip = $langs->trans('SupplierInvoice') . ': ' . ($objp->ref?$objp->ref:$objp->facid) . '<br>' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier;
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
|
|||||||
@ -63,7 +63,12 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
* @see FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_PAID, FactureFournisseur::STATUS_ABANDONED
|
* @see FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_PAID, FactureFournisseur::STATUS_ABANDONED
|
||||||
*/
|
*/
|
||||||
var $statut;
|
var $statut;
|
||||||
//! 1 si facture payee COMPLETEMENT, 0 sinon (ce champ ne devrait plus servir car insuffisant)
|
|
||||||
|
/**
|
||||||
|
* Set to 1 if the invoice is completely paid, otherwise is 0
|
||||||
|
* @var int
|
||||||
|
* @deprecated Use statuses stored in self::statut
|
||||||
|
*/
|
||||||
var $paye;
|
var $paye;
|
||||||
|
|
||||||
var $author;
|
var $author;
|
||||||
@ -1409,7 +1414,7 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
$sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin';
|
$sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff';
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ' WHERE ff.paye=0';
|
$sql.= ' WHERE ff.paye=0';
|
||||||
@ -1430,10 +1435,16 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
$response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0';
|
$response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0';
|
||||||
$response->img=img_object($langs->trans("Bills"),"bill");
|
$response->img=img_object($langs->trans("Bills"),"bill");
|
||||||
|
|
||||||
|
$facturestatic = new FactureFournisseur($this->db);
|
||||||
|
|
||||||
while ($obj=$this->db->fetch_object($resql))
|
while ($obj=$this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$response->nbtodo++;
|
$response->nbtodo++;
|
||||||
if (! empty($obj->datefin) && $this->db->jdate($obj->datefin) < ($now - $conf->facture->fournisseur->warning_delay)) {
|
|
||||||
|
$facturestatic->date_echeance = $this->db->jdate($obj->datefin);
|
||||||
|
$facturestatic->statut = $obj->fk_statut;
|
||||||
|
|
||||||
|
if ($facturestatic->hasDelay()) {
|
||||||
$response->nbtodolate++;
|
$response->nbtodolate++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1822,6 +1833,24 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
|
|
||||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the payment of the supplier invoice having a delay?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasDelay()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
|
||||||
|
if (!$this->date_echeance) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($this->statut == self::STATUS_VALIDATED) && ($this->date_echeance < ($now - $conf->facture->fournisseur->warning_delay));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1905,7 +1905,9 @@ else
|
|||||||
// Due date
|
// Due date
|
||||||
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,$form_permission,'datepicker').'</td><td colspan="3">';
|
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,$form_permission,'datepicker').'</td><td colspan="3">';
|
||||||
print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,$form_permission,'datepicker');
|
print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,$form_permission,'datepicker');
|
||||||
if ($action != 'editdate_lim_reglement' && $object->statut < FactureFournisseur::STATUS_CLOSED && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late'));
|
if ($action != 'editdate_lim_reglement' && $object->hasDelay()) {
|
||||||
|
print img_warning($langs->trans('Late'));
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Conditions de reglement par defaut
|
// Conditions de reglement par defaut
|
||||||
|
|||||||
@ -230,6 +230,9 @@ if ($user->rights->fournisseur->facture->lire)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
$facturestatic->statut = $objp->fk_statut;
|
||||||
|
$facturestatic->date_echeance = $db->jdate($objp->datelimite);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
@ -245,7 +248,9 @@ if ($user->rights->fournisseur->facture->lire)
|
|||||||
|
|
||||||
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($objp->df),'day')."</td>\n";
|
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($objp->df),'day')."</td>\n";
|
||||||
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($objp->datelimite),'day');
|
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($objp->datelimite),'day');
|
||||||
if ($objp->datelimite && $db->jdate($objp->datelimite) < ($now - $conf->facture->fournisseur->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>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
|
|||||||
@ -323,6 +323,10 @@ if ($resql)
|
|||||||
while ($i < min($num,$limit))
|
while ($i < min($num,$limit))
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
$facturestatic->date_echeance = $db->jdate($obj->date_echeance);
|
||||||
|
$facturestatic->statut = $obj->fk_statut;
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
@ -342,7 +346,9 @@ if ($resql)
|
|||||||
|
|
||||||
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datef),'day').'</td>';
|
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datef),'day').'</td>';
|
||||||
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_echeance),'day');
|
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_echeance),'day');
|
||||||
if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
|
if ($facturestatic->hasDelay()) {
|
||||||
|
print img_picto($langs->trans("Late"),"warning");
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>'.dol_trunc($obj->libelle,36).'</td>';
|
print '<td>'.dol_trunc($obj->libelle,36).'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user