66 global $user, $langs, $conf, $hookmanager;
68 $langs->load(
"boxes");
72 $contactstatic =
new Contact($this->db);
73 $societestatic =
new Societe($this->db);
75 $this->info_box_head = array(
76 'text' => $langs->trans(
"BoxTitleLastModifiedContacts", $max).
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/contact/list.php?sortfield=p.tms&sortorder=DESC"><span class="badge">...</span></a>'
79 if ($user->hasRight(
'societe',
'lire') && $user->hasRight(
'societe',
'contact',
'lire')) {
80 $sql =
"SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
82 $sql .=
", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
83 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
84 $sql .=
", s.code_client, s.client";
85 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
87 $sql .=
", spe.accountancy_code_customer as code_compta";
88 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
90 $sql .=
", s.code_compta";
91 $sql .=
", s.code_compta_fournisseur";
93 $sql .=
", s.logo, s.email, s.entity";
94 $sql .=
", co.label as country, co.code as country_code";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON sp.fk_pays = co.rowid";
97 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON sp.fk_soc = s.rowid";
99 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
101 if (!$user->hasRight(
'societe',
'client',
'voir')) {
102 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
104 $sql .=
" WHERE sp.entity IN (".getEntity(
'contact').
")";
105 if (!$user->hasRight(
'societe',
'client',
'voir')) {
106 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
109 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
110 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $contactstatic);
111 if (empty($reshook)) {
112 if ($user->socid > 0) {
113 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
116 $sql .= $hookmanager->resPrint;
117 $sql .=
" ORDER BY sp.tms DESC";
118 $sql .= $this->db->plimit($max, 0);
120 $result = $this->db->query($sql);
122 $num = $this->db->num_rows($result);
125 while ($line < $num) {
126 $objp = $this->db->fetch_object($result);
127 $datec = $this->db->jdate($objp->datec);
128 $datem = $this->db->jdate($objp->tms);
130 $contactstatic->id = $objp->id;
131 $contactstatic->lastname = $objp->lastname;
132 $contactstatic->firstname = $objp->firstname;
133 $contactstatic->civility_id = $objp->civility_id;
134 $contactstatic->statut = $objp->status;
135 $contactstatic->phone_pro = $objp->phone;
136 $contactstatic->phone_perso = $objp->phone_perso;
137 $contactstatic->phone_mobile = $objp->phone_mobile;
138 $contactstatic->email = $objp->spemail;
139 $contactstatic->address = $objp->address;
140 $contactstatic->zip = $objp->zip;
141 $contactstatic->town = $objp->town;
142 $contactstatic->country = $objp->country;
143 $contactstatic->country_code = $objp->country_code;
145 $societestatic->id = $objp->socid;
146 $societestatic->name = $objp->name;
148 $societestatic->code_client = $objp->code_client;
149 $societestatic->code_compta = $objp->code_compta;
150 $societestatic->client = $objp->client;
151 $societestatic->code_fournisseur = $objp->code_fournisseur;
152 $societestatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
153 $societestatic->fournisseur = $objp->fournisseur;
154 $societestatic->logo = $objp->logo;
155 $societestatic->email = $objp->email;
156 $societestatic->entity = $objp->entity;
158 $this->info_box_contents[$line][] = array(
159 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
160 'text' => $contactstatic->getNomUrl(1),
164 $this->info_box_contents[$line][] = array(
165 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
166 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
170 $this->info_box_contents[$line][] = array(
175 $this->info_box_contents[$line][] = array(
176 'td' =>
'class="nowrap right" width="18"',
177 'text' => $contactstatic->getLibStatut(3),
185 $this->info_box_contents[$line][0] = array(
186 'td' =>
'class="center"',
187 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedContacts").
'</span>',
192 $this->db->free($result);
194 $this->info_box_contents[0][0] = array(
197 'text' => ($this->db->error().
' sql='.$sql),
201 $this->info_box_contents[0][0] = array(
202 'td' =>
'class="nohover left"',
203 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'