63 global $user, $langs, $conf;
67 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
68 $ficheinterstatic =
new Fichinter($this->db);
69 $thirdpartystatic =
new Societe($this->db);
71 $this->info_box_head = array(
72 '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>'
75 if ($user->hasRight(
'ficheinter',
'lire')) {
76 $sql =
"SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
78 $sql .=
", f.date_valid as datev";
79 $sql .=
", f.tms as datem";
80 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
81 $sql .=
", s.code_client, s.code_compta, s.client";
82 $sql .=
", s.logo, s.email, s.entity";
83 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
84 if (!$user->hasRight(
'societe',
'client',
'voir')) {
85 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
87 $sql .=
", ".MAIN_DB_PREFIX.
"fichinter as f";
88 $sql .=
" WHERE f.fk_soc = s.rowid ";
89 $sql .=
" AND f.entity = ".$conf->entity;
90 if (!$user->hasRight(
'societe',
'client',
'voir')) {
91 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
94 $sql .=
" AND s.rowid = ".((int) $user->socid);
96 $sql .=
" ORDER BY f.tms DESC";
97 $sql .= $this->db->plimit($max, 0);
99 dol_syslog(get_class($this).
'::loadBox', LOG_DEBUG);
100 $resql = $this->db->query($sql);
102 $num = $this->db->num_rows($resql);
108 $objp = $this->db->fetch_object($resql);
109 $datec = $this->db->jdate($objp->datec);
110 $datem = $this->db->jdate($objp->datem);
112 $ficheinterstatic->statut = $objp->status;
113 $ficheinterstatic->status = $objp->status;
114 $ficheinterstatic->id = $objp->rowid;
115 $ficheinterstatic->ref = $objp->ref;
117 $thirdpartystatic->id = $objp->socid;
118 $thirdpartystatic->name = $objp->name;
120 $thirdpartystatic->code_client = $objp->code_client;
121 $thirdpartystatic->code_compta = $objp->code_compta;
122 $thirdpartystatic->code_compta_client = $objp->code_compta;
123 $thirdpartystatic->client = $objp->client;
124 $thirdpartystatic->logo = $objp->logo;
125 $thirdpartystatic->email = $objp->email;
126 $thirdpartystatic->entity = $objp->entity;
128 $this->info_box_contents[$i][] = array(
129 'td' =>
'class="nowraponall"',
130 'text' => $ficheinterstatic->getNomUrl(1),
134 $this->info_box_contents[$i][] = array(
135 'td' =>
'class="tdoverflowmax150"',
136 'text' => $thirdpartystatic->getNomUrl(1),
140 $this->info_box_contents[$i][] = array(
145 $this->info_box_contents[$i][] = array(
146 'td' =>
'class="nowrap right"',
147 'text' => $ficheinterstatic->getLibStatut(3),
155 $this->info_box_contents[$i][0] = array(
156 'td' =>
'class="center"',
157 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedInterventions").
'</span>'
161 $this->db->free($resql);
163 $this->info_box_contents[0][0] = array(
166 'text' => ($this->db->error().
' sql='.$sql),
170 $this->info_box_contents[0][0] = array(
171 'td' =>
'class="nohover left"',
172 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'