71 global $user, $langs,
$conf, $hookmanager;
73 $langs->loadLangs(array(
"boxes",
"contracts"));
77 $contactstatic =
new Contact($this->db);
78 $societestatic =
new Societe($this->db);
80 $this->info_box_head = array(
81 '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>'
84 if ($user->hasRight(
'societe',
'lire') && $user->hasRight(
'societe',
'contact',
'lire')) {
85 $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";
87 $sql .=
", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
88 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
89 $sql .=
", s.code_client, s.client";
90 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
92 $sql .=
", spe.accountancy_code_customer as code_compta_client";
93 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
95 $sql .=
", s.code_compta as code_compta_client";
96 $sql .=
", s.code_compta_fournisseur";
98 $sql .=
", s.logo, s.email, s.entity";
99 $sql .=
", co.label as country, co.code as country_code";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
101 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON sp.fk_pays = co.rowid";
102 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON sp.fk_soc = s.rowid";
104 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
106 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
107 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
109 $sql .=
" WHERE sp.entity IN (".getEntity(
'contact').
")";
110 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
111 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
113 $sql .=
" AND ((sp.fk_user_creat = ".((int) $user->id).
" AND sp.priv = 1) OR sp.priv = 0)";
115 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
116 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $contactstatic);
117 if (empty($reshook)) {
118 if ($user->socid > 0) {
119 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
122 $sql .= $hookmanager->resPrint;
123 $sql .=
" ORDER BY sp.tms DESC";
124 $sql .= $this->db->plimit($max, 0);
126 $result = $this->db->query($sql);
128 $num = $this->db->num_rows($result);
131 while ($line < $num) {
132 $objp = $this->db->fetch_object($result);
133 $datec = $this->db->jdate($objp->datec);
134 $datem = $this->db->jdate($objp->tms);
136 $contactstatic->id = $objp->id;
137 $contactstatic->lastname = $objp->lastname;
138 $contactstatic->firstname = $objp->firstname;
139 $contactstatic->civility_id = $objp->civility_id;
140 $contactstatic->status = $objp->status;
141 $contactstatic->statut = $objp->status;
142 $contactstatic->phone_pro = $objp->phone;
143 $contactstatic->phone_perso = $objp->phone_perso;
144 $contactstatic->phone_mobile = $objp->phone_mobile;
145 $contactstatic->email = $objp->spemail;
146 $contactstatic->address = $objp->address;
147 $contactstatic->zip = $objp->zip;
148 $contactstatic->town = $objp->town;
149 $contactstatic->country = $objp->country;
150 $contactstatic->country_code = $objp->country_code;
152 $societestatic->id = $objp->socid;
153 $societestatic->name = $objp->name;
155 $societestatic->code_client = $objp->code_client;
156 $societestatic->code_compta = $objp->code_compta_client;
157 $societestatic->code_compta_client = $objp->code_compta_client;
158 $societestatic->client = $objp->client;
159 $societestatic->code_fournisseur = $objp->code_fournisseur;
160 $societestatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
161 $societestatic->fournisseur = $objp->fournisseur;
162 $societestatic->logo = $objp->logo;
163 $societestatic->email = $objp->email;
164 $societestatic->entity = $objp->entity;
166 $this->info_box_contents[$line][] = array(
167 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
168 'text' => $contactstatic->getNomUrl(1),
172 $this->info_box_contents[$line][] = array(
173 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
174 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
178 $this->info_box_contents[$line][] = array(
183 $this->info_box_contents[$line][] = array(
184 'td' =>
'class="nowrap right" width="18"',
185 'text' => $contactstatic->getLibStatut(3),
200 $this->db->free($result);
202 $this->info_box_contents[0][0] = array(
205 'text' => ($this->db->error().
' sql='.$sql),
209 $this->info_box_contents[0][0] = array(
210 'td' =>
'class="nohover left"',
211 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'