60 global $conf, $user, $langs;
64 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
66 $text = $langs->trans(
"BoxLastTicketDescription", $max);
67 $this->info_box_head = array(
68 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/ticket/list.php?sortfield=t.datec&sortorder=DESC"><span class="badge">...</span></a>',
72 $this->info_box_contents[0][0] = array(
73 'td' =>
'class="left"',
74 'text' => $langs->trans(
"BoxLastTicketContent"),
77 if ($user->hasRight(
'ticket',
'read')) {
78 $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,";
79 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label,";
80 $sql .=
" s.nom as company_name, s.email as socemail, s.client, s.fournisseur";
81 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
82 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
83 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
84 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
85 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid=t.fk_soc";
86 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
90 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
95 $sql .=
" ORDER BY t.datec DESC, t.rowid DESC ";
96 $sql .= $this->db->plimit($max, 0);
98 $resql = $this->db->query($sql);
100 $num = $this->db->num_rows($resql);
105 $objp = $this->db->fetch_object($resql);
107 $datec = $this->db->jdate($objp->datec);
112 $ticket =
new Ticket($this->db);
113 $ticket->id = $objp->id;
114 $ticket->track_id = $objp->track_id;
115 $ticket->ref = $objp->ref;
116 $ticket->fk_statut = $objp->status;
117 $ticket->status = $objp->status;
118 $ticket->subject = $objp->subject;
119 if ($objp->fk_soc > 0) {
120 $thirdparty =
new Societe($this->db);
121 $thirdparty->id = $objp->fk_soc;
122 $thirdparty->email = $objp->socemail;
123 $thirdparty->client = $objp->client;
124 $thirdparty->fournisseur = $objp->fournisseur;
125 $thirdparty->name = $objp->company_name;
126 $link = $thirdparty->getNomUrl(1);
128 $link =
'<span title="'.$objp->origin_email.
'">'.
dol_print_email($objp->origin_email).
'</span>';
134 $this->info_box_contents[$i][$r] = array(
135 'td' =>
'class="nowraponall"',
136 'text' => $ticket->getNomUrl(1),
142 $this->info_box_contents[$i][$r] = array(
143 'td' =>
'class="tdoverflowmax200"',
145 'url' => DOL_URL_ROOT.
"/ticket/card.php?track_id=".urlencode($objp->track_id),
150 $this->info_box_contents[$i][$r] = array(
151 'td' =>
'class="tdoverflowmax100"',
158 $this->info_box_contents[$i][$r] = array(
165 $this->info_box_contents[$i][$r] = array(
166 'td' =>
'class="right nowraponall"',
167 'text' => $ticket->getLibStatut(3),
175 $this->info_box_contents[$i][0] = array(
'td' =>
'',
'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxLastTicketNoRecordedTickets").
'</span>');
181 $this->info_box_contents[0][0] = array(
'td' =>
'',
182 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>');