73 global $conf, $user, $langs;
77 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
78 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
83 $this->info_box_head = array(
84 'text' => $langs->trans(
"BoxTitleLast".(getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"SupplierBills", $max)
87 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
88 $langs->load(
"bills");
90 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
91 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
92 $sql .=
", s.logo, s.email, s.entity";
93 $sql .=
", f.rowid as facid, f.ref, f.ref_supplier";
94 $sql .=
", f.total_ht";
95 $sql .=
", f.total_tva";
96 $sql .=
", f.total_ttc";
97 $sql .=
", f.paye, f.fk_statut as status";
98 $sql .=
', f.datef as date';
99 $sql .=
', f.datec as datec';
100 $sql .=
', f.date_lim_reglement as datelimite, f.tms, f.type';
101 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
102 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
103 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
104 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
106 $sql .=
" WHERE f.fk_soc = s.rowid";
107 $sql .=
" AND f.entity = ".$conf->entity;
108 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
109 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
112 $sql .=
" AND s.rowid = ".((int) $user->socid);
115 $sql .=
" ORDER BY f.datef DESC, f.ref DESC ";
117 $sql .=
" ORDER BY f.tms DESC, f.ref DESC ";
119 $sql .= $this->db->plimit($max, 0);
121 $result = $this->db->query($sql);
123 $num = $this->db->num_rows($result);
126 $l_due_date = $langs->trans(
'Late').
' ('.$langs->trans(
'DateDue').
': %s)';
128 while ($line < $num) {
129 $objp = $this->db->fetch_object($result);
131 $datelimite = $this->db->jdate($objp->datelimite);
132 $date = $this->db->jdate($objp->date);
133 $datem = $this->db->jdate($objp->tms);
135 $facturestatic->id = $objp->facid;
136 $facturestatic->ref = $objp->ref;
137 $facturestatic->total_ht = $objp->total_ht;
138 $facturestatic->total_tva = $objp->total_tva;
139 $facturestatic->total_ttc = $objp->total_ttc;
140 $facturestatic->date = $date;
141 $facturestatic->date_echeance = $datelimite;
142 $facturestatic->statut = $objp->status;
143 $facturestatic->status = $objp->status;
144 $facturestatic->ref_supplier = $objp->ref_supplier;
146 $alreadypaid = $facturestatic->getSommePaiement();
148 $facturestatic->alreadypaid = $alreadypaid ? $alreadypaid : 0;
150 $thirdpartystatic->id = $objp->socid;
151 $thirdpartystatic->name = $objp->name;
152 $thirdpartystatic->name_alias = $objp->name_alias;
153 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
154 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
155 $thirdpartystatic->fournisseur = $objp->fournisseur;
156 $thirdpartystatic->logo = $objp->logo;
157 $thirdpartystatic->email = $objp->email;
158 $thirdpartystatic->entity = $objp->entity;
162 if ($facturestatic->hasDelay()) {
166 $this->info_box_contents[$line][] = array(
167 'td' =>
'class="nowraponall"',
168 'text' => $facturestatic->getNomUrl(1),
173 $this->info_box_contents[$line][] = array(
174 'td' =>
'class="tdoverflowmax150"',
175 'text' => $objp->ref_supplier,
176 'tooltip' => $langs->trans(
'SupplierInvoice').
': '.($objp->ref ? $objp->ref : $objp->facid).
'<br>'.$langs->trans(
'RefSupplier').
': '.$objp->ref_supplier,
177 'url' => DOL_URL_ROOT.
"/fourn/facture/card.php?facid=".$objp->facid,
180 $this->info_box_contents[$line][] = array(
181 'td' =>
'class="tdoverflowmax150"',
182 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
186 $this->info_box_contents[$line][] = array(
187 'td' =>
'class="nowraponall right amount"',
188 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
191 $this->info_box_contents[$line][] = array(
196 $this->info_box_contents[$line][] = array(
197 'td' =>
'class="right" width="18"',
198 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type),
205 $this->info_box_contents[$line][0] = array(
206 'td' =>
'class="center"',
207 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoModifiedSupplierBills").
'</span>',
211 $this->db->free($result);
213 $this->info_box_contents[0][0] = array(
216 'text' => ($this->db->error().
' sql='.$sql),
220 $this->info_box_contents[0][0] = array(
221 'td' =>
'class="nohover left"',
222 'text' =>
'<span class="opacitymedium">'.$langs->transnoentities(
"ReadPermissionNotAllowed").
'</span>'