Add file display in ticket
This commit is contained in:
parent
f626f249cf
commit
0cff122ccd
@ -819,6 +819,46 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
|
||||
}
|
||||
}
|
||||
|
||||
$documents = getTicketActionCommEcmList($actionstatic) ;
|
||||
if(!empty($documents))
|
||||
{
|
||||
$footer.= '<div class="timeline-documents-container">';
|
||||
foreach ($documents as $doc)
|
||||
{
|
||||
$footer.= '<span id="document_'.$doc->id.'" class="timeline-documents" ';
|
||||
$footer.= ' data-id="'.$doc->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);
|
||||
$file = $actionstatic->id.'/'.$doc->filename;
|
||||
$thumb = $actionstatic->id.'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,'.')).'_mini'.substr($doc->filename, strrpos($doc->filename,'.'));
|
||||
$doclink = dol_buildpath('document.php', 1).'?modulepart=actions&attachment=0&file='.urlencode($file).'&entity='.$conf->entity;
|
||||
$viewlink = dol_buildpath('viewimage.php', 1).'?modulepart=actions&file='.urlencode($thumb).'&entity='.$conf->entity;
|
||||
|
||||
$mimeAttr = ' mime="'.$mime.'" ';
|
||||
$class = '';
|
||||
if(in_array($mime, array('image/png', 'image/jpeg', 'application/pdf'))){
|
||||
$class.= ' documentpreview';
|
||||
}
|
||||
|
||||
$footer.= '<a href="'.$doclink.'" class="btn-file '.$class.'" target="_blank" '.$mimeAttr.' >';
|
||||
$footer.= img_mime($filePath).' '.$doc->filename;
|
||||
$footer.= '</a>';
|
||||
|
||||
$footer.= '</span>';
|
||||
}
|
||||
$footer.= '</div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!empty($footer)){
|
||||
$out.='<div class="timeline-footer">'.$footer.'</div>';
|
||||
}
|
||||
@ -838,3 +878,32 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
|
||||
if ($noprint) return $out;
|
||||
else print $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @var $object ActionComm
|
||||
* @return array
|
||||
*/
|
||||
function getTicketActionCommEcmList($object)
|
||||
{
|
||||
global $conf, $db;
|
||||
|
||||
$documents = array();
|
||||
|
||||
$sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm';
|
||||
$sql.= ' WHERE ecm.filepath = \'agenda/'.$object->id.'\'';
|
||||
//$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type
|
||||
$sql.= ' ORDER BY ecm.position ASC';
|
||||
|
||||
$resql= $db->query($sql);
|
||||
if ($resql) {
|
||||
if ($db->num_rows($resql)) {
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
$documents[$obj->id] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $documents;
|
||||
}
|
||||
|
||||
@ -125,7 +125,12 @@ a.timeline-btn:hover
|
||||
font-weight: normal;
|
||||
line-height: 1.1;
|
||||
}
|
||||
.timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-header {
|
||||
|
||||
.timeline > li > .timeline-item > .timeline-footer {
|
||||
border-top: 1px solid #f4f4f4;
|
||||
}
|
||||
|
||||
.timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-header, .timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-footer {
|
||||
border-color: #ecebda;
|
||||
}
|
||||
|
||||
@ -195,3 +200,25 @@ a.timeline-btn:hover
|
||||
background-color: #0073b7 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.timeline-documents-container{
|
||||
|
||||
}
|
||||
|
||||
.timeline-documents{
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.btn-file{
|
||||
margin-right: 5px;
|
||||
border: 1px solid #ddd;
|
||||
color: #333;
|
||||
padding: 5px 10px;
|
||||
border-radius:1em;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.btn-file:hover{
|
||||
background-color: #ddd;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user