26 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
34 public $boxcode =
"lastsupplierbills";
35 public $boximg =
"object_bill";
36 public $boxlabel =
"BoxLastSupplierBills";
37 public $depends = array(
"facture",
"fournisseur");
46 public $info_box_head = array();
47 public $info_box_contents = array();
62 $this->hidden = !($user->hasRight(
'fournisseur',
'facture',
'lire'));
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".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ?
"" :
"Modified").
"SupplierBills", $max)
87 if ($user->rights->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 (empty($user->rights->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 (empty($user->rights->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);
114 if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
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'=>$langs->trans(
"NoModifiedSupplierBills"),
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 opacitymedium left"',
222 'text' => $langs->transnoentities(
"ReadPermissionNotAllowed")
235 public function showBox($head =
null, $contents =
null, $nooutput = 0)
237 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 last supplier invoices.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data into info_box_contents array to show array later.
__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.