62 global $user, $langs, $conf;
66 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
67 $ficheinterstatic =
new Fichinter($this->db);
68 $thirdpartystatic =
new Societe($this->db);
70 $this->info_box_head = array(
71 'text' => $langs->trans(
"BoxTitleLastFicheInter", $max).
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/fichinter/list.php?sortfield=f.tms&sortorder=DESC"><span class="badge">...</span></a>'
74 if ($user->hasRight(
'ficheinter',
'lire')) {
75 $sql =
"SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
77 $sql .=
", f.date_valid as datev";
78 $sql .=
", f.tms as datem";
79 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
80 $sql .=
", s.code_client, s.code_compta, s.client";
81 $sql .=
", s.logo, s.email, s.entity";
82 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
83 if (!$user->hasRight(
'societe',
'client',
'voir')) {
84 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
86 $sql .=
", ".MAIN_DB_PREFIX.
"fichinter as f";
87 $sql .=
" WHERE f.fk_soc = s.rowid ";
88 $sql .=
" AND f.entity = ".$conf->entity;
89 if (!$user->hasRight(
'societe',
'client',
'voir')) {
90 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
93 $sql .=
" AND s.rowid = ".((int) $user->socid);
95 $sql .=
" ORDER BY f.tms DESC";
96 $sql .= $this->db->plimit($max, 0);
98 dol_syslog(get_class($this).
'::loadBox', LOG_DEBUG);
99 $resql = $this->db->query($sql);
101 $num = $this->db->num_rows($resql);
107 $objp = $this->db->fetch_object($resql);
108 $datec = $this->db->jdate($objp->datec);
109 $datem = $this->db->jdate($objp->datem);
111 $ficheinterstatic->statut = $objp->status;
112 $ficheinterstatic->status = $objp->status;
113 $ficheinterstatic->id = $objp->rowid;
114 $ficheinterstatic->ref = $objp->ref;
116 $thirdpartystatic->id = $objp->socid;
117 $thirdpartystatic->name = $objp->name;
119 $thirdpartystatic->code_client = $objp->code_client;
120 $thirdpartystatic->code_compta = $objp->code_compta;
121 $thirdpartystatic->client = $objp->client;
122 $thirdpartystatic->logo = $objp->logo;
123 $thirdpartystatic->email = $objp->email;
124 $thirdpartystatic->entity = $objp->entity;
126 $this->info_box_contents[$i][] = array(
127 'td' =>
'class="nowraponall"',
128 'text' => $ficheinterstatic->getNomUrl(1),
132 $this->info_box_contents[$i][] = array(
133 'td' =>
'class="tdoverflowmax150"',
134 'text' => $thirdpartystatic->getNomUrl(1),
138 $this->info_box_contents[$i][] = array(
143 $this->info_box_contents[$i][] = array(
144 'td' =>
'class="nowrap right"',
145 'text' => $ficheinterstatic->getLibStatut(3),
153 $this->info_box_contents[$i][0] = array(
154 'td' =>
'class="center"',
155 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedInterventions").
'</span>'
159 $this->db->free($resql);
161 $this->info_box_contents[0][0] = array(
164 'text' => ($this->db->error().
' sql='.$sql),
168 $this->info_box_contents[0][0] = array(
169 'td' =>
'class="nohover left"',
170 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'