27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastsupplierbills";
36 public $boximg =
"object_bill";
37 public $boxlabel =
"BoxLastSupplierBills";
38 public $depends = array(
"facture",
"fournisseur");
52 $this->hidden = !($user->hasRight(
'fournisseur',
'facture',
'lire'));
63 global $conf, $user, $langs;
67 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
68 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
73 $this->info_box_head = array(
74 'text' => $langs->trans(
"BoxTitleLast".(getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"SupplierBills", $max)
77 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
78 $langs->load(
"bills");
80 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
81 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
82 $sql .=
", s.logo, s.email, s.entity";
83 $sql .=
", f.rowid as facid, f.ref, f.ref_supplier";
84 $sql .=
", f.total_ht";
85 $sql .=
", f.total_tva";
86 $sql .=
", f.total_ttc";
87 $sql .=
", f.paye, f.fk_statut as status";
88 $sql .=
', f.datef as date';
89 $sql .=
', f.datec as datec';
90 $sql .=
', f.date_lim_reglement as datelimite, f.tms, f.type';
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
92 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
96 $sql .=
" WHERE f.fk_soc = s.rowid";
97 $sql .=
" AND f.entity = ".$conf->entity;
98 if (!$user->hasRight(
'societe',
'client',
'voir')) {
99 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
102 $sql .=
" AND s.rowid = ".((int) $user->socid);
105 $sql .=
" ORDER BY f.datef DESC, f.ref DESC ";
107 $sql .=
" ORDER BY f.tms DESC, f.ref DESC ";
109 $sql .= $this->db->plimit($max, 0);
111 $result = $this->db->query(
$sql);
113 $num = $this->db->num_rows($result);
116 $l_due_date = $langs->trans(
'Late').
' ('.$langs->trans(
'DateDue').
': %s)';
118 while ($line < $num) {
119 $objp = $this->db->fetch_object($result);
121 $datelimite = $this->db->jdate($objp->datelimite);
122 $date = $this->db->jdate($objp->date);
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 = $date;
131 $facturestatic->date_echeance = $datelimite;
132 $facturestatic->statut = $objp->status;
133 $facturestatic->status = $objp->status;
134 $facturestatic->ref_supplier = $objp->ref_supplier;
136 $alreadypaid = $facturestatic->getSommePaiement();
138 $facturestatic->alreadypaid = $alreadypaid ? $alreadypaid : 0;
140 $thirdpartystatic->id = $objp->socid;
141 $thirdpartystatic->name = $objp->name;
142 $thirdpartystatic->name_alias = $objp->name_alias;
143 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
144 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
145 $thirdpartystatic->fournisseur = $objp->fournisseur;
146 $thirdpartystatic->logo = $objp->logo;
147 $thirdpartystatic->email = $objp->email;
148 $thirdpartystatic->entity = $objp->entity;
152 if ($facturestatic->hasDelay()) {
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="nowraponall"',
159 'text' => $facturestatic->getNomUrl(1),
164 $this->info_box_contents[$line][] = array(
165 'td' =>
'class="tdoverflowmax150"',
166 'text' => $objp->ref_supplier,
167 'tooltip' => $langs->trans(
'SupplierInvoice').
': '.($objp->ref ? $objp->ref : $objp->facid).
'<br>'.$langs->trans(
'RefSupplier').
': '.$objp->ref_supplier,
168 'url' => DOL_URL_ROOT.
"/fourn/facture/card.php?facid=".$objp->facid,
171 $this->info_box_contents[$line][] = array(
172 'td' =>
'class="tdoverflowmax150"',
173 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
177 $this->info_box_contents[$line][] = array(
178 'td' =>
'class="nowraponall right amount"',
179 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
182 $this->info_box_contents[$line][] = array(
187 $this->info_box_contents[$line][] = array(
188 'td' =>
'class="right" width="18"',
189 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type),
196 $this->info_box_contents[$line][0] = array(
197 'td' =>
'class="center"',
198 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoModifiedSupplierBills").
'</span>',
202 $this->db->free($result);
204 $this->info_box_contents[0][0] = array(
207 'text' => ($this->db->error().
' sql='.
$sql),
211 $this->info_box_contents[0][0] = array(
212 'td' =>
'class="nohover left"',
213 'text' =>
'<span class="opacitymedium">'.$langs->transnoentities(
"ReadPermissionNotAllowed").
'</span>'
226 public function showBox($head =
null, $contents =
null, $nooutput = 0)
228 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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...