73 global $user, $langs, $conf;
77 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
78 $ficheinterstatic =
new Fichinter($this->db);
79 $thirdpartystatic =
new Societe($this->db);
81 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastFicheInter", $max));
83 if (!empty($user->rights->ficheinter->lire)) {
84 $sql =
"SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
86 $sql .=
", f.date_valid as datev";
87 $sql .=
", f.tms as datem";
88 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
89 $sql .=
", s.code_client, s.code_compta, s.client";
90 $sql .=
", s.logo, s.email, s.entity";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
92 if (empty($user->rights->societe->client->voir)) {
93 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
95 $sql .=
", ".MAIN_DB_PREFIX.
"fichinter as f";
96 $sql .=
" WHERE f.fk_soc = s.rowid ";
97 $sql .=
" AND f.entity = ".$conf->entity;
98 if (empty($user->rights->societe->client->voir) && !$user->socid) {
99 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
102 $sql .=
" AND s.rowid = ".((int) $user->socid);
104 $sql .=
" ORDER BY f.tms DESC";
105 $sql .= $this->db->plimit($max, 0);
107 dol_syslog(get_class($this).
'::loadBox', LOG_DEBUG);
108 $resql = $this->db->query($sql);
110 $num = $this->db->num_rows($resql);
116 $objp = $this->db->fetch_object($resql);
117 $datec = $this->db->jdate($objp->datec);
118 $datem = $this->db->jdate($objp->datem);
120 $ficheinterstatic->statut = $objp->status;
121 $ficheinterstatic->status = $objp->status;
122 $ficheinterstatic->id = $objp->rowid;
123 $ficheinterstatic->ref = $objp->ref;
125 $thirdpartystatic->id = $objp->socid;
126 $thirdpartystatic->name = $objp->name;
128 $thirdpartystatic->code_client = $objp->code_client;
129 $thirdpartystatic->code_compta = $objp->code_compta;
130 $thirdpartystatic->client = $objp->client;
131 $thirdpartystatic->logo = $objp->logo;
132 $thirdpartystatic->email = $objp->email;
133 $thirdpartystatic->entity = $objp->entity;
135 $this->info_box_contents[$i][] = array(
136 'td' =>
'class="nowraponall"',
137 'text' => $ficheinterstatic->getNomUrl(1),
141 $this->info_box_contents[$i][] = array(
142 'td' =>
'class="tdoverflowmax150"',
143 'text' => $thirdpartystatic->getNomUrl(1),
147 $this->info_box_contents[$i][] = array(
152 $this->info_box_contents[$i][] = array(
153 'td' =>
'class="nowrap right"',
154 'text' => $ficheinterstatic->getLibStatut(3),
162 $this->info_box_contents[$i][0] = array(
163 'td' =>
'class="center opacitymedium"',
164 'text'=>$langs->trans(
"NoRecordedInterventions")
168 $this->db->free($resql);
170 $this->info_box_contents[0][0] = array(
173 'text' => ($this->db->error().
' sql='.$sql),
177 $this->info_box_contents[0][0] = array(
178 'td' =>
'class="nohover opacitymedium left"',
179 'text' => $langs->trans(
"ReadPermissionNotAllowed")