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->rights->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".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ?
"" :
"Modified").
"SupplierBills", $max)
87 if ($user->rights->fournisseur->facture->lire)
89 $langs->load(
"bills");
91 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
92 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
93 $sql .=
", s.logo, s.email, s.entity";
94 $sql .=
", f.rowid as facid, f.ref, f.ref_supplier";
95 $sql .=
", f.total_ht";
96 $sql .=
", f.total_tva";
97 $sql .=
", f.total_ttc";
98 $sql .=
", f.paye, f.fk_statut as status";
99 $sql .=
', f.datef as df';
100 $sql .=
', f.datec as datec';
101 $sql .=
', f.date_lim_reglement as datelimite, f.tms, f.type';
102 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
103 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
104 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
105 $sql .=
" WHERE f.fk_soc = s.rowid";
106 $sql .=
" AND f.entity = ".$conf->entity;
107 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
108 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
109 if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .=
" ORDER BY f.datef DESC, f.ref DESC ";
110 else $sql .=
" ORDER BY f.tms DESC, f.ref DESC ";
111 $sql .= $this->
db->plimit($max, 0);
113 $result = $this->
db->query($sql);
116 $num = $this->
db->num_rows($result);
119 $l_due_date = $langs->trans(
'Late').
' ('.$langs->trans(
'DateDue').
': %s)';
121 while ($line < $num) {
122 $objp = $this->
db->fetch_object($result);
124 $datelimite = $this->
db->jdate($objp->datelimite);
125 $date = $this->
db->jdate($objp->df);
126 $datem = $this->
db->jdate($objp->tms);
128 $facturestatic->id = $objp->facid;
129 $facturestatic->ref = $objp->ref;
130 $facturestatic->total_ht = $objp->total_ht;
131 $facturestatic->total_tva = $objp->total_tva;
132 $facturestatic->total_ttc = $objp->total_ttc;
133 $facturestatic->date_echeance = $datelimite;
134 $facturestatic->statut = $objp->status;
135 $facturestatic->status = $objp->status;
136 $facturestatic->ref_supplier = $objp->ref_supplier;
138 $thirdpartystatic->id = $objp->socid;
139 $thirdpartystatic->name = $objp->name;
140 $thirdpartystatic->name_alias = $objp->name_alias;
141 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
142 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
143 $thirdpartystatic->fournisseur = $objp->fournisseur;
144 $thirdpartystatic->logo = $objp->logo;
145 $thirdpartystatic->email = $objp->email;
146 $thirdpartystatic->entity = $objp->entity;
150 if ($facturestatic->hasDelay()) {
154 $this->info_box_contents[$line][] = array(
155 'td' =>
'class="nowraponall"',
156 'text' => $facturestatic->getNomUrl(1),
161 $this->info_box_contents[$line][] = array(
162 'td' =>
'class="tdoverflowmax150"',
163 'text' => $objp->ref_supplier,
164 'tooltip' => $langs->trans(
'SupplierInvoice').
': '.($objp->ref ? $objp->ref : $objp->facid).
'<br>'.$langs->trans(
'RefSupplier').
': '.$objp->ref_supplier,
165 'url' => DOL_URL_ROOT.
"/fourn/facture/card.php?facid=".$objp->facid,
168 $this->info_box_contents[$line][] = array(
169 'td' =>
'class="tdoverflowmax150"',
170 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
174 $this->info_box_contents[$line][] = array(
175 'td' =>
'class="right nowraponall"',
176 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
179 $this->info_box_contents[$line][] = array(
180 'td' =>
'class="right"',
185 $fac->fetch($objp->facid);
186 $alreadypaid = $fac->getSommePaiement();
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'=>$langs->trans(
"NoModifiedSupplierBills"),
201 $this->
db->free($result);
203 $this->info_box_contents[0][0] = array(
206 'text' => ($this->
db->error().
' sql='.$sql),
210 $this->info_box_contents[0][0] = array(
211 'td' =>
'class="nohover opacitymedium left"',
212 'text' => $langs->transnoentities(
"ReadPermissionNotAllowed")
225 public function showBox($head = null, $contents = null, $nooutput = 0)
227 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage suppliers invoices.
$conf db
API class for accounts.
Class to manage suppliers.
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...
Class to manage the box to show last supplier invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.