70 global $user, $langs, $conf, $hookmanager;
72 $langs->load(
"boxes");
76 $contactstatic =
new Contact($this->db);
77 $societestatic =
new Societe($this->db);
79 $this->info_box_head = array(
80 '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>'
83 if ($user->hasRight(
'societe',
'lire') && $user->hasRight(
'societe',
'contact',
'lire')) {
84 $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";
86 $sql .=
", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
87 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
88 $sql .=
", s.code_client, s.client";
89 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
91 $sql .=
", spe.accountancy_code_customer as code_compta_client";
92 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
94 $sql .=
", s.code_compta as code_compta_client";
95 $sql .=
", s.code_compta_fournisseur";
97 $sql .=
", s.logo, s.email, s.entity";
98 $sql .=
", co.label as country, co.code as country_code";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON sp.fk_pays = co.rowid";
101 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON sp.fk_soc = s.rowid";
103 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
105 if (!$user->hasRight(
'societe',
'client',
'voir')) {
106 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
108 $sql .=
" WHERE sp.entity IN (".getEntity(
'contact').
")";
109 if (!$user->hasRight(
'societe',
'client',
'voir')) {
110 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
112 $sql .=
" AND ((sp.fk_user_creat = ".((int) $user->id).
" AND sp.priv = 1) OR sp.priv = 0)";
114 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
115 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $contactstatic);
116 if (empty($reshook)) {
117 if ($user->socid > 0) {
118 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
121 $sql .= $hookmanager->resPrint;
122 $sql .=
" ORDER BY sp.tms DESC";
123 $sql .= $this->db->plimit($max, 0);
125 $result = $this->db->query($sql);
127 $num = $this->db->num_rows($result);
130 while ($line < $num) {
131 $objp = $this->db->fetch_object($result);
132 $datec = $this->db->jdate($objp->datec);
133 $datem = $this->db->jdate($objp->tms);
135 $contactstatic->id = $objp->id;
136 $contactstatic->lastname = $objp->lastname;
137 $contactstatic->firstname = $objp->firstname;
138 $contactstatic->civility_id = $objp->civility_id;
139 $contactstatic->statut = $objp->status;
140 $contactstatic->phone_pro = $objp->phone;
141 $contactstatic->phone_perso = $objp->phone_perso;
142 $contactstatic->phone_mobile = $objp->phone_mobile;
143 $contactstatic->email = $objp->spemail;
144 $contactstatic->address = $objp->address;
145 $contactstatic->zip = $objp->zip;
146 $contactstatic->town = $objp->town;
147 $contactstatic->country = $objp->country;
148 $contactstatic->country_code = $objp->country_code;
150 $societestatic->id = $objp->socid;
151 $societestatic->name = $objp->name;
153 $societestatic->code_client = $objp->code_client;
154 $societestatic->code_compta = $objp->code_compta_client;
155 $societestatic->code_compta_client = $objp->code_compta_client;
156 $societestatic->client = $objp->client;
157 $societestatic->code_fournisseur = $objp->code_fournisseur;
158 $societestatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
159 $societestatic->fournisseur = $objp->fournisseur;
160 $societestatic->logo = $objp->logo;
161 $societestatic->email = $objp->email;
162 $societestatic->entity = $objp->entity;
164 $this->info_box_contents[$line][] = array(
165 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
166 'text' => $contactstatic->getNomUrl(1),
170 $this->info_box_contents[$line][] = array(
171 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
172 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
176 $this->info_box_contents[$line][] = array(
181 $this->info_box_contents[$line][] = array(
182 'td' =>
'class="nowrap right" width="18"',
183 'text' => $contactstatic->getLibStatut(3),
198 $this->db->free($result);
200 $this->info_box_contents[0][0] = array(
203 'text' => ($this->db->error().
' sql='.$sql),
207 $this->info_box_contents[0][0] = array(
208 'td' =>
'class="nohover left"',
209 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'