box ficheinter

This commit is contained in:
Frédéric FRANCE 2019-09-23 18:13:26 +02:00
parent 31094936c1
commit 57509f1312
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -70,12 +70,13 @@ class box_ficheinter extends ModeleBoxes
*/ */
public function loadBox($max = 10) public function loadBox($max = 10)
{ {
global $user, $langs, $db, $conf; global $user, $langs, $conf;
$this->max=$max; $this->max=$max;
include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$ficheinterstatic=new Fichinter($db); $ficheinterstatic=new Fichinter($this->db);
$companystatic = new Societe($this->db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max));
@ -85,7 +86,7 @@ class box_ficheinter extends ModeleBoxes
$sql.= " f.datec,"; $sql.= " f.datec,";
$sql.= " f.date_valid as datev,"; $sql.= " f.date_valid as datev,";
$sql.= " f.tms as datem,"; $sql.= " f.tms as datem,";
$sql.= " s.nom as name, s.rowid as socid, s.client"; $sql.= " s.nom as name, s.rowid as socid, s.client, s.email as semail";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
@ -94,42 +95,40 @@ class box_ficheinter extends ModeleBoxes
if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY f.tms DESC"; $sql.= " ORDER BY f.tms DESC";
$sql.= $db->plimit($max, 0); $sql.= $this->db->plimit($max, 0);
dol_syslog(get_class($this).'::loadBox', LOG_DEBUG); dol_syslog(get_class($this).'::loadBox', LOG_DEBUG);
$resql = $db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $this->db->num_rows($resql);
$now=dol_now(); $now=dol_now();
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($resql); $objp = $this->db->fetch_object($resql);
$datec=$db->jdate($objp->datec); $datec = $this->db->jdate($objp->datec);
$ficheinterstatic->statut=$objp->fk_statut; $ficheinterstatic->statut=$objp->fk_statut;
$ficheinterstatic->id=$objp->rowid; $ficheinterstatic->id=$objp->rowid;
$ficheinterstatic->ref=$objp->ref; $ficheinterstatic->ref=$objp->ref;
$companystatic->id = $objp->socid;
$companystatic->name = $objp->name;
$companystatic->email = $objp->semail;
$this->info_box_contents[$i][] = array( $this->info_box_contents[$i][] = array(
'td' => '', 'td' => '',
'text' => $ficheinterstatic->getNomUrl(1), 'text' => $ficheinterstatic->getNomUrl(1),
'asis' => 1, 'asis' => 1,
); );
$this->info_box_contents[$i][] = array(
'td' => 'class="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][] = array( $this->info_box_contents[$i][] = array(
'td' => '', 'td' => '',
'text' => dol_trunc($objp->name, 40), 'text' => $companystatic->getNomUrl(1),
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, 'asis' => 1,
); );
$this->info_box_contents[$i][] = array( $this->info_box_contents[$i][] = array(
@ -148,14 +147,14 @@ class box_ficheinter extends ModeleBoxes
if ($num==0) $this->info_box_contents[$i][] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedInterventions")); if ($num==0) $this->info_box_contents[$i][] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedInterventions"));
$db->free($resql); $this->db->free($resql);
} }
else else
{ {
$this->info_box_contents[0][] = array( $this->info_box_contents[0][] = array(
'td' => '', 'td' => '',
'maxlength'=>500, 'maxlength'=>500,
'text' => ($db->error().' sql='.$sql), 'text' => ($this->db->error().' sql='.$sql),
); );
} }
} }