29 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
30 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38 public $boxcode =
"lastcontacts";
39 public $boximg =
"object_contact";
40 public $boxlabel =
"BoxLastContacts";
41 public $depends = array(
"societe");
50 public $info_box_head = array();
51 public $info_box_contents = array();
66 $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire);
77 global $user, $langs, $conf;
78 $langs->load(
"boxes");
82 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedContacts", $max));
84 if ($user->rights->societe->lire && $user->rights->societe->contact->lire)
86 $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";
88 $sql .=
", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
89 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
90 $sql .=
", s.code_client, s.code_compta, s.client";
91 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
92 $sql .=
", s.logo, s.email, s.entity";
93 $sql .=
", co.label as country, co.code as country_code";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
95 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON sp.fk_pays = co.rowid";
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON sp.fk_soc = s.rowid";
97 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
98 $sql .=
" WHERE sp.entity IN (".getEntity(
'socpeople').
")";
99 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
100 if ($user->socid) $sql .=
" AND sp.fk_soc = ".$user->socid;
101 $sql .=
" ORDER BY sp.tms DESC";
102 $sql .= $this->
db->plimit($max, 0);
104 $result = $this->
db->query($sql);
106 $num = $this->
db->num_rows($result);
114 $objp = $this->
db->fetch_object($result);
115 $datec = $this->
db->jdate($objp->datec);
116 $datem = $this->
db->jdate($objp->tms);
118 $contactstatic->id = $objp->id;
119 $contactstatic->lastname = $objp->lastname;
120 $contactstatic->firstname = $objp->firstname;
121 $contactstatic->civility_id = $objp->civility_id;
122 $contactstatic->statut = $objp->status;
123 $contactstatic->phone_pro = $objp->phone;
124 $contactstatic->phone_perso = $objp->phone_perso;
125 $contactstatic->phone_mobile = $objp->phone_mobile;
126 $contactstatic->email = $objp->spemail;
127 $contactstatic->address = $objp->address;
128 $contactstatic->zip = $objp->zip;
129 $contactstatic->town = $objp->town;
130 $contactstatic->country = $objp->country;
131 $contactstatic->country_code = $objp->country_code;
133 $societestatic->id = $objp->socid;
134 $societestatic->name = $objp->name;
136 $societestatic->code_client = $objp->code_client;
137 $societestatic->code_compta = $objp->code_compta;
138 $societestatic->client = $objp->client;
139 $societestatic->code_fournisseur = $objp->code_fournisseur;
140 $societestatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
141 $societestatic->fournisseur = $objp->fournisseur;
142 $societestatic->logo = $objp->logo;
143 $societestatic->email = $objp->email;
144 $societestatic->entity = $objp->entity;
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
148 'text' => $contactstatic->getNomUrl(1),
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
154 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
158 $this->info_box_contents[$line][] = array(
159 'td' =>
'class="right"',
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="nowrap right" width="18"',
165 'text' => $contactstatic->getLibStatut(3),
173 $this->info_box_contents[$line][0] = array(
174 'td' =>
'class="center"',
175 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedContacts").
'</span>',
179 $this->
db->free($result);
181 $this->info_box_contents[0][0] = array(
184 'text' => ($this->
db->error().
' sql='.$sql),
188 $this->info_box_contents[0][0] = array(
189 'td' =>
'class="nohover left"',
190 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
203 public function showBox($head = null, $contents = null, $nooutput = 0)
205 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
$conf db
API class for accounts.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).