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