From 0cff122ccd09625ff07d34dab65c045268134c9b Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 30 Oct 2019 17:46:18 +0100 Subject: [PATCH 1/3] Add file display in ticket --- htdocs/core/lib/ticket.lib.php | 69 ++++++++++++++++++++++++++++++ htdocs/theme/eldy/timeline.inc.php | 29 ++++++++++++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 63e9a2fc9ff..7a2a96d074a 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -819,6 +819,46 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } } + $documents = getTicketActionCommEcmList($actionstatic) ; + if(!empty($documents)) + { + $footer.= '
'; + foreach ($documents as $doc) + { + $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); + $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.= ''; + $footer.= img_mime($filePath).' '.$doc->filename; + $footer.= ''; + + $footer.= ''; + } + $footer.= '
'; + } + + + + + + + if(!empty($footer)){ $out.=''; } @@ -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; +} diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index 2cb3461d713..d81ae4b8bed 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -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; +} From 2293048fdb5adadad0c0ba92c970917724022be5 Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 30 Oct 2019 17:48:52 +0100 Subject: [PATCH 2/3] Fix move css style --- htdocs/theme/eldy/btn.inc.php | 21 ++++++++++++++++++++- htdocs/theme/eldy/timeline.inc.php | 13 ------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 51fbfd6a561..91a95d7a4d3 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -260,4 +260,23 @@ div.pagination li:first-child a.btnTitle{ .butActionRefused, .butActionNewRefused, .btnTitle.refused { display: none !important; } - + + +/* + * BTN FILE doc + */ + +.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; +} diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index d81ae4b8bed..76ca244e572 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -209,16 +209,3 @@ a.timeline-btn:hover 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; -} From d0a5e30faade72f78847ae1fc7de53349046295e Mon Sep 17 00:00:00 2001 From: John Botella Date: Thu, 31 Oct 2019 08:44:08 +0100 Subject: [PATCH 3/3] Change btn name --- htdocs/core/lib/ticket.lib.php | 2 +- htdocs/theme/eldy/btn.inc.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 7a2a96d074a..e89e9a79194 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -844,7 +844,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $class.= ' documentpreview'; } - $footer.= ''; + $footer.= ''; $footer.= img_mime($filePath).' '.$doc->filename; $footer.= ''; diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 91a95d7a4d3..59c015b6245 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -264,10 +264,10 @@ div.pagination li:first-child a.btnTitle{ /* - * BTN FILE doc + * BTN LINK */ -.btn-file{ +.btn-link{ margin-right: 5px; border: 1px solid #ddd; color: #333; @@ -276,7 +276,7 @@ div.pagination li:first-child a.btnTitle{ text-decoration: none !important; } -.btn-file:hover{ +.btn-link:hover{ background-color: #ddd; border: 1px solid #ddd; }