26 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
33 public $boxcode =
"lastcustomerbills";
34 public $boximg =
"object_bill";
35 public $boxlabel =
"BoxLastCustomerBills";
36 public $depends = array(
"facture");
45 public $info_box_head = array();
46 public $info_box_contents = array();
61 $this->hidden = empty($user->rights->facture->lire);
72 global $conf, $user, $langs;
76 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
77 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
82 $langs->load(
"bills");
84 $text = $langs->trans(
"BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ?
"" :
"Modified").
"CustomerBills", $max);
85 $this->info_box_head = array(
90 if ($user->rights->facture->lire) {
91 $sql =
"SELECT f.rowid as facid";
92 $sql .=
", f.ref, f.type, f.total_ht";
93 $sql .=
", f.total_tva";
94 $sql .=
", f.total_ttc";
95 $sql .=
", f.datef as date";
96 $sql .=
", f.paye, f.fk_statut as status, f.datec, f.tms";
97 $sql .=
", f.date_lim_reglement as datelimite";
98 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
99 $sql .=
", s.code_client, s.code_compta, s.client";
100 $sql .=
", s.logo, s.email, s.entity";
101 $sql .=
", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
102 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
103 if (empty($user->rights->societe->client->voir) && !$user->socid) {
104 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
107 $sql .=
" WHERE f.fk_soc = s.rowid";
108 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
109 if (empty($user->rights->societe->client->voir) && !$user->socid) {
110 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
113 $sql .=
" AND s.rowid = ".((int) $user->socid);
115 if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
116 $sql .=
" ORDER BY f.datef DESC, f.ref DESC ";
118 $sql .=
" ORDER BY f.tms DESC, f.ref DESC ";
120 $sql .= $this->
db->plimit($max, 0);
122 $result = $this->
db->query($sql);
124 $num = $this->
db->num_rows($result);
128 $l_due_date = $langs->trans(
'Late').
' ('.$langs->trans(
'DateDue').
': %s)';
130 while ($line < $num) {
131 $objp = $this->
db->fetch_object($result);
132 $datelimite = $this->
db->jdate($objp->datelimite);
133 $date = $this->
db->jdate($objp->date);
134 $datem = $this->
db->jdate($objp->tms);
136 $facturestatic->id = $objp->facid;
137 $facturestatic->ref = $objp->ref;
138 $facturestatic->type = $objp->type;
139 $facturestatic->total_ht = $objp->total_ht;
140 $facturestatic->total_tva = $objp->total_tva;
141 $facturestatic->total_ttc = $objp->total_ttc;
142 $facturestatic->statut = $objp->status;
143 $facturestatic->status = $objp->status;
144 $facturestatic->date = $this->
db->jdate($objp->date);
145 $facturestatic->date_lim_reglement = $this->
db->jdate($objp->datelimite);
146 $facturestatic->alreadypaid = $objp->paye;
148 $societestatic->id = $objp->socid;
149 $societestatic->name = $objp->name;
151 $societestatic->code_client = $objp->code_client;
152 $societestatic->code_compta = $objp->code_compta;
153 $societestatic->client = $objp->client;
154 $societestatic->logo = $objp->logo;
155 $societestatic->email = $objp->email;
156 $societestatic->entity = $objp->entity;
157 $societestatic->tva_intra = $objp->tva_intra;
158 $societestatic->idprof1 = $objp->idprof1;
159 $societestatic->idprof2 = $objp->idprof2;
160 $societestatic->idprof3 = $objp->idprof3;
161 $societestatic->idprof4 = $objp->idprof4;
162 $societestatic->idprof5 = $objp->idprof5;
163 $societestatic->idprof6 = $objp->idprof6;
166 if ($facturestatic->hasDelay()) {
170 $this->info_box_contents[$line][] = array(
171 'td' =>
'class="nowraponall"',
172 'text' => $facturestatic->getNomUrl(1),
177 $this->info_box_contents[$line][] = array(
178 'td' =>
'class="tdoverflowmax200"',
179 'text' => $societestatic->getNomUrl(1,
'', 40),
183 $this->info_box_contents[$line][] = array(
184 'td' =>
'class="right nowraponall amount"',
185 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
188 $this->info_box_contents[$line][] = array(
193 $this->info_box_contents[$line][] = array(
194 'td' =>
'class="right" width="18"',
195 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $objp->paye),
202 $this->info_box_contents[$line][0] = array(
203 'td' =>
'class="center"',
204 'text'=>$langs->trans(
"NoRecordedInvoices"),
208 $this->
db->free($result);
210 $this->info_box_contents[0][0] = array(
213 'text' => ($this->
db->error().
' sql='.$sql),
217 $this->info_box_contents[0][0] = array(
218 'td' =>
'class="nohover opacitymedium left"',
219 'text' => $langs->trans(
"ReadPermissionNotAllowed")
232 public function showBox($head = null, $contents = null, $nooutput = 0)
234 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param)
Constructor.
$conf db
API class for accounts.
dol_now($mode= 'auto')
Return date for now.
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...
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 third parties objects (customers, suppliers, prospects...)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
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 last invoices.
Class to manage invoices.