69 global $conf, $user, $langs;
73 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
75 $text = $langs->trans(
"BoxLastTicketDescription", $max);
76 $this->info_box_head = array(
81 $this->info_box_contents[0][0] = array(
82 'td' =>
'class="left"',
83 'text' => $langs->trans(
"BoxLastTicketContent"),
86 if ($user->hasRight(
'ticket',
'read')) {
87 $sql =
"SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut as status, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email,";
88 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label,";
89 $sql .=
" s.nom as company_name, s.email as socemail, s.client, s.fournisseur";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
91 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
92 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
93 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
94 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid=t.fk_soc";
95 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
99 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
104 $sql .=
" ORDER BY t.datec DESC, t.rowid DESC ";
105 $sql .= $this->db->plimit($max, 0);
107 $resql = $this->db->query($sql);
109 $num = $this->db->num_rows($resql);
114 $objp = $this->db->fetch_object($resql);
116 $datec = $this->db->jdate($objp->datec);
121 $ticket =
new Ticket($this->db);
122 $ticket->id = $objp->id;
123 $ticket->track_id = $objp->track_id;
124 $ticket->ref = $objp->ref;
125 $ticket->fk_statut = $objp->status;
126 $ticket->status = $objp->status;
127 $ticket->subject = $objp->subject;
128 if ($objp->fk_soc > 0) {
129 $thirdparty =
new Societe($this->db);
130 $thirdparty->id = $objp->fk_soc;
131 $thirdparty->email = $objp->socemail;
132 $thirdparty->client = $objp->client;
133 $thirdparty->fournisseur = $objp->fournisseur;
134 $thirdparty->name = $objp->company_name;
135 $link = $thirdparty->getNomUrl(1);
137 $link =
'<span title="'.$objp->origin_email.
'">'.
dol_print_email($objp->origin_email).
'</span>';
143 $this->info_box_contents[$i][$r] = array(
144 'td' =>
'class="nowraponall"',
145 'text' => $ticket->getNomUrl(1),
151 $this->info_box_contents[$i][$r] = array(
152 'td' =>
'class="tdoverflowmax200"',
154 'url' => DOL_URL_ROOT.
"/ticket/card.php?track_id=".urlencode($objp->track_id),
159 $this->info_box_contents[$i][$r] = array(
160 'td' =>
'class="tdoverflowmax100"',
167 $this->info_box_contents[$i][$r] = array(
174 $this->info_box_contents[$i][$r] = array(
175 'td' =>
'class="right nowraponall"',
176 'text' => $ticket->getLibStatut(3),
184 $this->info_box_contents[$i][0] = array(
'td' =>
'',
'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxLastTicketNoRecordedTickets").
'</span>');
190 $this->info_box_contents[0][0] = array(
'td' =>
'',
191 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>');