65 global $user, $langs, $conf;
69 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
70 $ficheinterstatic =
new Fichinter($this->db);
71 $thirdpartystatic =
new Societe($this->db);
73 $this->info_box_head = array(
74 '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>'
77 if ($user->hasRight(
'ficheinter',
'lire')) {
78 $sql =
"SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
80 $sql .=
", f.date_valid as datev";
81 $sql .=
", f.tms as datem";
82 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
83 $sql .=
", s.code_client, s.code_compta, s.client";
84 $sql .=
", s.logo, s.email, s.entity";
85 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
86 if (!$user->hasRight(
'societe',
'client',
'voir')) {
87 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
89 $sql .=
", ".MAIN_DB_PREFIX.
"fichinter as f";
90 $sql .=
" WHERE f.fk_soc = s.rowid ";
91 $sql .=
" AND f.entity = ".$conf->entity;
92 if (!$user->hasRight(
'societe',
'client',
'voir')) {
93 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
96 $sql .=
" AND s.rowid = ".((int) $user->socid);
98 $sql .=
" ORDER BY f.tms DESC";
99 $sql .= $this->db->plimit($max, 0);
101 dol_syslog(get_class($this).
'::loadBox', LOG_DEBUG);
102 $resql = $this->db->query($sql);
104 $num = $this->db->num_rows($resql);
110 $objp = $this->db->fetch_object($resql);
111 $datec = $this->db->jdate($objp->datec);
112 $datem = $this->db->jdate($objp->datem);
114 $ficheinterstatic->statut = $objp->status;
115 $ficheinterstatic->status = $objp->status;
116 $ficheinterstatic->id = $objp->rowid;
117 $ficheinterstatic->ref = $objp->ref;
119 $thirdpartystatic->id = $objp->socid;
120 $thirdpartystatic->name = $objp->name;
122 $thirdpartystatic->code_client = $objp->code_client;
123 $thirdpartystatic->code_compta = $objp->code_compta;
124 $thirdpartystatic->code_compta_client = $objp->code_compta;
125 $thirdpartystatic->client = $objp->client;
126 $thirdpartystatic->logo = $objp->logo;
127 $thirdpartystatic->email = $objp->email;
128 $thirdpartystatic->entity = $objp->entity;
130 $this->info_box_contents[$i][] = array(
131 'td' =>
'class="nowraponall"',
132 'text' => $ficheinterstatic->getNomUrl(1),
136 $this->info_box_contents[$i][] = array(
137 'td' =>
'class="tdoverflowmax150"',
138 'text' => $thirdpartystatic->getNomUrl(1),
142 $this->info_box_contents[$i][] = array(
147 $this->info_box_contents[$i][] = array(
148 'td' =>
'class="nowrap right"',
149 'text' => $ficheinterstatic->getLibStatut(3),
163 $this->db->free($resql);
165 $this->info_box_contents[0][0] = array(
168 'text' => ($this->db->error().
' sql='.$sql),
172 $this->info_box_contents[0][0] = array(
173 'td' =>
'class="nohover left"',
174 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'