77 global $user, $langs, $conf, $hookmanager;
79 $langs->load(
"boxes");
83 $contactstatic =
new Contact($this->db);
84 $societestatic =
new Societe($this->db);
86 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedContacts", $max));
88 if ($user->hasRight(
'societe',
'lire') && $user->hasRight(
'societe',
'contact',
'lire')) {
89 $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";
91 $sql .=
", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
92 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
93 $sql .=
", s.code_client, s.client";
94 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
95 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
96 $sql .=
", spe.accountancy_code_customer as code_compta";
97 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
99 $sql .=
", s.code_compta";
100 $sql .=
", s.code_compta_fournisseur";
102 $sql .=
", s.logo, s.email, s.entity";
103 $sql .=
", co.label as country, co.code as country_code";
104 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
105 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON sp.fk_pays = co.rowid";
106 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON sp.fk_soc = s.rowid";
107 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
108 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
110 if (empty($user->rights->societe->client->voir) && !$user->socid) {
111 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
113 $sql .=
" WHERE sp.entity IN (".getEntity(
'contact').
")";
114 if (empty($user->rights->societe->client->voir) && !$user->socid) {
115 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
118 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
119 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $contactstatic);
120 if (empty($reshook)) {
121 if ($user->socid > 0) {
122 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
125 $sql .= $hookmanager->resPrint;
126 $sql .=
" ORDER BY sp.tms DESC";
127 $sql .= $this->db->plimit($max, 0);
129 $result = $this->db->query($sql);
131 $num = $this->db->num_rows($result);
134 while ($line < $num) {
135 $objp = $this->db->fetch_object($result);
136 $datec = $this->db->jdate($objp->datec);
137 $datem = $this->db->jdate($objp->tms);
139 $contactstatic->id = $objp->id;
140 $contactstatic->lastname = $objp->lastname;
141 $contactstatic->firstname = $objp->firstname;
142 $contactstatic->civility_id = $objp->civility_id;
143 $contactstatic->statut = $objp->status;
144 $contactstatic->phone_pro = $objp->phone;
145 $contactstatic->phone_perso = $objp->phone_perso;
146 $contactstatic->phone_mobile = $objp->phone_mobile;
147 $contactstatic->email = $objp->spemail;
148 $contactstatic->address = $objp->address;
149 $contactstatic->zip = $objp->zip;
150 $contactstatic->town = $objp->town;
151 $contactstatic->country = $objp->country;
152 $contactstatic->country_code = $objp->country_code;
154 $societestatic->id = $objp->socid;
155 $societestatic->name = $objp->name;
157 $societestatic->code_client = $objp->code_client;
158 $societestatic->code_compta = $objp->code_compta;
159 $societestatic->client = $objp->client;
160 $societestatic->code_fournisseur = $objp->code_fournisseur;
161 $societestatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
162 $societestatic->fournisseur = $objp->fournisseur;
163 $societestatic->logo = $objp->logo;
164 $societestatic->email = $objp->email;
165 $societestatic->entity = $objp->entity;
167 $this->info_box_contents[$line][] = array(
168 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
169 'text' => $contactstatic->getNomUrl(1),
173 $this->info_box_contents[$line][] = array(
174 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
175 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
179 $this->info_box_contents[$line][] = array(
184 $this->info_box_contents[$line][] = array(
185 'td' =>
'class="nowrap right" width="18"',
186 'text' => $contactstatic->getLibStatut(3),
194 $this->info_box_contents[$line][0] = array(
195 'td' =>
'class="center"',
196 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedContacts").
'</span>',
201 $this->db->free($result);
203 $this->info_box_contents[0][0] = array(
206 'text' => ($this->db->error().
' sql='.$sql),
210 $this->info_box_contents[0][0] = array(
211 'td' =>
'class="nohover left"',
212 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'