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->rights->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)
85 $langs->load(
"bills");
87 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
88 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
89 $sql .=
", s.logo, s.email, s.entity";
90 $sql .=
", f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite";
91 $sql .=
", f.datef as df";
92 $sql .=
", f.total_ht as total_ht";
93 $sql .=
", f.tva as total_tva";
94 $sql .=
", f.total_ttc";
95 $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 (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
99 $sql .=
" WHERE f.fk_soc = s.rowid";
100 $sql .=
" AND f.entity = ".$conf->entity;
101 $sql .=
" AND f.paye = 0";
102 $sql .=
" AND fk_statut = 1";
103 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
104 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
105 $sql .=
" ORDER BY datelimite DESC, f.ref_supplier DESC ";
106 $sql .= $this->
db->plimit($max, 0);
108 $result = $this->
db->query($sql);
111 $num = $this->
db->num_rows($result);
114 $l_due_date = $langs->trans(
'Late').
' ('.$langs->trans(
'DateDue').
': %s)';
120 $objp = $this->
db->fetch_object($result);
121 $datelimite = $this->
db->jdate($objp->datelimite);
122 $date = $this->
db->jdate($objp->df);
123 $datem = $this->
db->jdate($objp->tms);
125 $facturestatic->id = $objp->facid;
126 $facturestatic->ref = $objp->ref;
127 $facturestatic->total_ht = $objp->total_ht;
128 $facturestatic->total_tva = $objp->total_tva;
129 $facturestatic->total_ttc = $objp->total_ttc;
130 $facturestatic->date_echeance = $datelimite;
131 $facturestatic->statut = $objp->status;
132 $facturestatic->status = $objp->status;
134 $thirdpartystatic->id = $objp->socid;
135 $thirdpartystatic->name = $objp->name;
136 $thirdpartystatic->name_alias = $objp->name_alias;
137 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
138 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
139 $thirdpartystatic->fournisseur = $objp->fournisseur;
140 $thirdpartystatic->logo = $objp->logo;
141 $thirdpartystatic->email = $objp->email;
142 $thirdpartystatic->entity = $objp->entity;
145 if ($facturestatic->hasDelay()) {
149 $tooltip = $langs->trans(
'SupplierInvoice').
': '.($objp->ref ? $objp->ref : $objp->facid).
'<br>'.$langs->trans(
'RefSupplier').
': '.$objp->ref_supplier;
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="nowraponall"',
153 'text' => $facturestatic->getNomUrl(1),
158 $this->info_box_contents[$line][] = array(
159 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
160 'text' => $thirdpartystatic->getNomUrl(1,
'', 40),
164 $this->info_box_contents[$line][] = array(
165 'td' =>
'class="nowraponall right"',
166 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
169 $this->info_box_contents[$line][] = array(
170 'td' =>
'class="right"',
175 $fac->fetch($objp->facid);
176 $alreadypaid = $fac->getSommePaiement();
177 $this->info_box_contents[$line][] = array(
178 'td' =>
'class="right" width="18"',
179 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type),
186 $this->info_box_contents[$line][0] = array(
187 'td' =>
'class="center"',
188 'text'=>$langs->trans(
"NoUnpaidSupplierBills"),
191 $this->
db->free($result);
193 $this->info_box_contents[0][0] = array(
196 'text' => ($this->
db->error().
' sql='.$sql),
200 $this->info_box_contents[0][0] = array(
201 'td' =>
'class="nohover opacitymedium left"',
202 'text' => $langs->trans(
"ReadPermissionNotAllowed")
215 public function showBox($head = null, $contents = null, $nooutput = 0)
217 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
Class to manage suppliers invoices.
$conf db
API class for accounts.
Class to manage suppliers.
__construct($db, $param)
Constructor.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
loadBox($max=5)
Load data into info_box_contents array to show array later.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage the box to show not paid suppliers invoices.