25 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
33 public $boxcode =
"oldestunpaidsupplierbills";
34 public $boximg =
"object_bill";
35 public $boxlabel =
"BoxOldestUnpaidSupplierBills";
36 public $depends = array(
"facture",
"fournisseur");
45 public $info_box_head = array();
46 public $info_box_contents = array();
61 $this->hidden = !($user->hasRight(
'fournisseur',
'facture',
'lire'));
72 global $conf, $user, $langs;
76 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
78 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
81 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleOldestUnpaidSupplierBills", $max));
83 if ($user->rights->fournisseur->facture->lire) {
84 $langs->load(
"bills");
86 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
87 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
88 $sql .=
", s.logo, s.email, s.entity";
89 $sql .=
", f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite";
90 $sql .=
", f.datef as df";
91 $sql .=
", f.total_ht as total_ht";
92 $sql .=
", f.tva as total_tva";
93 $sql .=
", f.total_ttc";
94 $sql .=
", f.paye, f.fk_statut as status, f.type";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
97 $sql .=
",".MAIN_DB_PREFIX.
"facture_fourn as f";
98 if (empty($user->rights->societe->client->voir) && !$user->socid) {
99 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
101 $sql .=
" WHERE f.fk_soc = s.rowid";
102 $sql .=
" AND f.entity = ".$conf->entity;
103 $sql .=
" AND f.paye = 0";
104 $sql .=
" AND fk_statut = 1";
105 if (empty($user->rights->societe->client->voir) && !$user->socid) {
106 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
109 $sql .=
" AND s.rowid = ".((int) $user->socid);
111 $sql .=
" ORDER BY datelimite DESC, f.ref_supplier DESC ";
112 $sql .= $this->
db->plimit($max, 0);
114 $result = $this->
db->query($sql);
116 $num = $this->
db->num_rows($result);
119 $l_due_date = $langs->trans(
'Late').
' ('.$langs->trans(
'DateDue').
': %s)';
123 while ($line < $num) {
124 $objp = $this->
db->fetch_object($result);
125 $datelimite = $this->
db->jdate($objp->datelimite);
126 $date = $this->
db->jdate($objp->df);
127 $datem = $this->
db->jdate($objp->tms);
129 $facturestatic->id = $objp->facid;
130 $facturestatic->ref = $objp->ref;
131 $facturestatic->total_ht = $objp->total_ht;
132 $facturestatic->total_tva = $objp->total_tva;
133 $facturestatic->total_ttc = $objp->total_ttc;
134 $facturestatic->date_echeance = $datelimite;
135 $facturestatic->date = $date;
136 $facturestatic->statut = $objp->status;
137 $facturestatic->status = $objp->status;
139 $alreadypaid = $facturestatic->getSommePaiement();
141 $facturestatic->alreadypaid = $alreadypaid ? $alreadypaid : 0;
143 $thirdpartystatic->id = $objp->socid;
144 $thirdpartystatic->name = $objp->name;
145 $thirdpartystatic->name_alias = $objp->name_alias;
146 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
147 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
148 $thirdpartystatic->fournisseur = $objp->fournisseur;
149 $thirdpartystatic->logo = $objp->logo;
150 $thirdpartystatic->email = $objp->email;
151 $thirdpartystatic->entity = $objp->entity;
154 if ($facturestatic->hasDelay()) {
158 $tooltip = $langs->trans(
'SupplierInvoice').
': '.($objp->ref ? $objp->ref : $objp->facid).
'<br>'.$langs->trans(
'RefSupplier').
': '.$objp->ref_supplier;
160 $this->info_box_contents[$line][] = array(
161 'td' =>
'class="nowraponall"',
162 'text' => $facturestatic->getNomUrl(1),
167 $this->info_box_contents[$line][] = array(
168 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
169 'text' => $thirdpartystatic->getNomUrl(1,
'', 40),
173 $this->info_box_contents[$line][] = array(
174 'td' =>
'class="nowraponall right amount"',
175 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
178 $this->info_box_contents[$line][] = array(
183 $this->info_box_contents[$line][] = array(
184 'td' =>
'class="right" width="18"',
185 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type),
192 $this->info_box_contents[$line][0] = array(
193 'td' =>
'class="center"',
194 'text'=>$langs->trans(
"NoUnpaidSupplierBills"),
198 $this->
db->free($result);
200 $this->info_box_contents[0][0] = array(
203 'text' => ($this->
db->error().
' sql='.$sql),
207 $this->info_box_contents[0][0] = array(
208 'td' =>
'class="nohover opacitymedium left"',
209 'text' => $langs->trans(
"ReadPermissionNotAllowed")
222 public function showBox($head =
null, $contents =
null, $nooutput = 0)
224 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage suppliers invoices.
Class to manage suppliers.
Class to manage the box to show not paid suppliers invoices.
loadBox($max=5)
Load data into info_box_contents array to show array later.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param)
Constructor.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
$conf db
API class for accounts.