diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 59b4af40b34..2fb219e44fe 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -328,6 +328,62 @@ class ActionsTicket extends CommonHookActions print ''; print ''; print $arraymsgs['message']; + + //attachment + + $documents = array(); + + $sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id'; + $sql .= ', ecm.filepath, ecm.filename, ecm.share'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; + $sql .= " WHERE ecm.filepath = 'agenda/".$arraymsgs['id']."'"; + $sql .= ' ORDER BY ecm.position ASC'; + + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + while ($obj = $this->db->fetch_object($resql)) { + $documents[$obj->id] = $obj; + } + } + } + if (!empty($documents)) { + $isshared = 0; + $footer = '
'; + foreach ($documents as $doc) { + if (!empty($doc->share)) { + $isshared = 1; + $footer .= 'id.'" '; + $footer .= ' data-path="'.$doc->filepath.'"'; + $footer .= ' data-filename="'.dol_escape_htmltag($doc->filename).'" '; + $footer .= '>'; + + $filePath = DOL_DATA_ROOT.'/'.$doc->filepath.'/'.$doc->filename; + $mime = dol_mimetype($filePath); + $thumb = $arraymsgs['id'].'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename, '.')).'_mini'.substr($doc->filename, strrpos($doc->filename, '.')); + $doclink = DOL_URL_ROOT.'/document.php?hashp='.urlencode($doc->share); + + $mimeAttr = ' mime="'.$mime.'" '; + $class = ''; + if (in_array($mime, array('image/png', 'image/jpeg', 'application/pdf'))) { + $class .= ' documentpreview'; + } + + $footer .= ''; + $footer .= img_mime($filePath).' '.$doc->filename; + $footer .= ''; + + $footer .= ''; + } + } + $footer .= '
'; + if ($isshared == 1) { + print '
'; + print '
'; + print $footer; + } + } print ''; print ''; }