27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastcustomers";
36 public $boximg =
"object_company";
37 public $boxlabel =
"BoxLastCustomers";
38 public $depends = array(
"societe");
47 public $info_box_head = array();
48 public $info_box_contents = array();
64 if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0;
66 $this->hidden = !($user->rights->societe->lire && empty($user->socid));
77 global $user, $langs, $conf;
78 $langs->load(
"boxes");
82 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
83 $thirdpartystatic =
new Client($this->
db);
85 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedCustomers", $max));
87 if ($user->rights->societe->lire)
89 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
90 $sql .=
", s.code_client, s.code_compta, s.client";
91 $sql .=
", s.logo, s.email, s.entity";
92 $sql .=
", s.datec, s.tms, s.status";
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
94 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
95 $sql .=
" WHERE s.client IN (1, 3)";
96 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
97 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
98 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
99 $sql .=
" ORDER BY s.tms DESC";
100 $sql .= $this->
db->plimit($max, 0);
102 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
103 $result = $this->
db->query($sql);
106 $num = $this->
db->num_rows($result);
111 $objp = $this->
db->fetch_object($result);
112 $datec = $this->
db->jdate($objp->datec);
113 $datem = $this->
db->jdate($objp->tms);
115 $thirdpartystatic->id = $objp->socid;
116 $thirdpartystatic->name = $objp->name;
117 $thirdpartystatic->name_alias = $objp->name_alias;
118 $thirdpartystatic->code_client = $objp->code_client;
119 $thirdpartystatic->code_compta = $objp->code_compta;
120 $thirdpartystatic->client = $objp->client;
121 $thirdpartystatic->logo = $objp->logo;
122 $thirdpartystatic->email = $objp->email;
123 $thirdpartystatic->entity = $objp->entity;
125 $this->info_box_contents[$line][] = array(
127 'text' => $thirdpartystatic->getNomUrl(1),
131 $this->info_box_contents[$line][] = array(
132 'td' =>
'class="right"',
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="right" width="18"',
138 'text' => $thirdpartystatic->LibStatut($objp->status, 3)
144 if ($num == 0) $this->info_box_contents[$line][0] = array(
145 'td' =>
'class="center opacitymedium"',
146 'text'=>$langs->trans(
"NoRecordedCustomers")
149 $this->
db->free($result);
151 $this->info_box_contents[0][0] = array(
154 'text' => ($this->
db->error().
' sql='.$sql)
158 $this->info_box_contents[0][0] = array(
159 'td' =>
'class="nohover opacitymedium left"',
160 'text' => $langs->trans(
"ReadPermissionNotAllowed")
173 public function showBox($head = null, $contents = null, $nooutput = 0)
175 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
__construct($db, $param= '')
Constructor.
Class to manage customers or prospects.
loadBox($max=5)
Load data for box to show them later.
$conf db
API class for accounts.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
Class to manage the box to show last thirdparties.