83 global $user, $langs, $conf;
84 $langs->load(
"boxes");
88 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
89 $thirdpartystatic =
new Societe($this->db);
91 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleGoodCustomers", $max));
93 if ($user->hasRight(
'societe',
'lire')) {
94 $sql =
"SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,";
95 $sql .=
" count(*) as nbfact, sum(".$this->db->ifsql(
'f.paye=1',
'1',
'0').
") as nbfactpaye";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture as f";
97 $sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
98 $sql .=
' AND s.rowid = f.fk_soc';
99 $sql .=
" GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status";
100 $sql .= $this->db->order(
"nbfact",
"DESC");
101 $sql .= $this->db->plimit($max, 0);
103 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
104 $result = $this->db->query($sql);
106 $num = $this->db->num_rows($result);
109 while ($line < $num) {
110 $objp = $this->db->fetch_object($result);
111 $datem = $this->db->jdate($objp->tms);
112 $thirdpartystatic->id = $objp->rowid;
113 $thirdpartystatic->name = $objp->name;
114 $thirdpartystatic->code_client = $objp->code_client;
115 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
116 $thirdpartystatic->client = $objp->client;
117 $thirdpartystatic->fournisseur = $objp->fournisseur;
118 $thirdpartystatic->logo = $objp->logo;
119 $nbfact = $objp->nbfact;
120 $nbimpaye = $objp->nbfact - $objp->nbfactpaye;
122 $this->info_box_contents[$line][] = array(
123 'td' =>
'class="tdoverflowmax150"',
124 'text' => $thirdpartystatic->getNomUrl(1),
128 $this->info_box_contents[$line][] = array(
129 'td' =>
'class="center nowraponall"',
133 $this->info_box_contents[$line][] = array(
134 'td' =>
'class="right"',
135 'text' => $nbfact.($nbimpaye != 0 ?
' ('.$nbimpaye.
')' :
'')
138 $this->info_box_contents[$line][] = array(
139 'td' =>
'class="right" width="18"',
140 'text' => $thirdpartystatic->LibStatut($objp->status, 3)
147 $this->info_box_contents[$line][0] = array(
148 'td' =>
'class="center"',
149 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedCustomers").
'</span>'
153 $this->db->free($result);
155 $this->info_box_contents[0][0] = array(
158 'text' => ($this->db->error().
' sql='.$sql),
162 $this->info_box_contents[0][0] = array(
163 'td' =>
'class="nohover left"',
164 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'