From a8e16910c0f22413d78651dde5d8b1e9495026d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 13:44:20 +0200 Subject: [PATCH] Fix look and feel v6 --- htdocs/comm/action/rapport/index.php | 46 +++++++-- htdocs/core/class/html.formfile.class.php | 116 +++++++++++----------- 2 files changed, 95 insertions(+), 67 deletions(-) diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index f6d01b18ca1..e83506d8206 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -26,6 +26,7 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php'; @@ -71,6 +72,8 @@ if ($action == 'builddoc') * View */ +$formfile=new FormFile($db); + llxHeader(); $sql = "SELECT count(*) as cc,"; @@ -103,7 +106,7 @@ if ($resql) $param=''; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - + print '
'; if ($optioncss != '') print ''; print ''; @@ -112,23 +115,24 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($langs->trans("Actions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit); $moreforfilter=''; - + $i = 0; print '
'; print ''."\n"; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print "\n"; + $var=true; while ($i < min($num,$limit)) { @@ -136,23 +140,47 @@ if ($resql) if ($obj) { - + print ''; + // Date print "\n"; + + // Nb of events print ''; + // Button to build doc print ''; $name = "actions-".$obj->month."-".$obj->year.".pdf"; $relativepath= $name; $file = $conf->agenda->dir_temp."/".$name; + $modulepart = 'actionsreport'; + $documenturl= DOL_URL_ROOT.'/document.php'; + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper if (file_exists($file)) { - print ''; + print ''; print ''; print ''; } @@ -169,7 +197,7 @@ if ($resql) print "
'.$langs->trans("Date").''.$langs->trans("Period").''.$langs->trans("EventsNb").''.$langs->trans("Action").''.$langs->trans("PDF").''.$langs->trans("PDF").''.$langs->trans("Date").''.$langs->trans("Size").'
".$obj->df."'.$obj->cc.''; - print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('GenerateReport'),'filenew').''; + print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').''; print ''.img_pdf().''; + //print ''.img_pdf().''; + + $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file'); + $out=''; + + // Show file name with link to download + $tmp = $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param); + $out.= ($tmp?$tmp.' ':''); + $out.= 'trans("File").': '.$filearray["name"]).' '.$filearray["name"]; + $out.= ''."\n"; + print $out; + + print ''.dol_print_date(dol_filemtime($file),'dayhour').''.dol_print_size(dol_filesize($file)).'
"; print '
'; print '
'; - + $db->free($resql); } else diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e263efeaa57..89cf70951ad 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -35,7 +35,7 @@ class FormFile { private $db; - + public $error; public $numoffiles; public $infofiles; // Used to return informations by function getDocumentsLink @@ -332,11 +332,11 @@ class FormFile jQuery(\'#togglemassfilesarea\').text("('.dol_escape_js($langs->trans("Hide")).')"); } return false; - }); + }); }); '; - } - + } + $titletoshow=$langs->trans("Documents"); if (! empty($title)) $titletoshow=$title; @@ -593,7 +593,7 @@ class FormFile if (empty($noform)) $out.= '
'; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= '
'; $out.= ''; @@ -682,9 +682,9 @@ class FormFile $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - + $out.= ''."\n"; - + // Show title of array if not already shown if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { @@ -706,8 +706,8 @@ class FormFile $out.= ''; $documenturl = DOL_URL_ROOT.'/document.php'; - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper + // Show file name with link to download $out.= ''; @@ -791,7 +791,7 @@ class FormFile } $this->numoffiles++; } - + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { $out.=''; @@ -835,7 +835,7 @@ class FormFile $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); //if (! empty($conf->dol_use_jmobile)) return ''; - + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -876,7 +876,7 @@ class FormFile $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity); if ($tmparray && $tmparray['url']) $tmpout.= '
  • '.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'
  • '; } - + // Download $tmpout.= '
  • initHooks(array('formfile')); @@ -983,7 +983,7 @@ class FormFile if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; } } - if (empty($conf->global->MAIN_UPLOAD_DOC)) + if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoeditline=0; $permonobject=0; @@ -992,7 +992,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - + print ''."\n"; if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline) { @@ -1003,7 +1003,7 @@ class FormFile } print '
    '; print '
  • '; $tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); @@ -774,7 +774,7 @@ class FormFile if (is_array($link_list)) { $colspan=2; - + foreach($link_list as $file) { $out.='
    '.$langs->trans("None").'
    '."\n"; - + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -1017,10 +1017,10 @@ class FormFile if ($relativedir) { $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); - + //var_dump($filearray); //var_dump($filearrayindatabase); - + // Complete filearray with properties found into $filearrayindatabase foreach($filearray as $key => $val) { @@ -1040,7 +1040,7 @@ class FormFile break; } } - + if (! $found) // This happen in transition towerd version 6, or if files were added manually into os dir. { $filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position @@ -1053,13 +1053,13 @@ class FormFile dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it"); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile=new EcmFiles($this->db); - + // Add entry into database $filename = basename($rel_filename); $rel_dir = dirname($rel_filename); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - + $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; $ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file @@ -1083,21 +1083,21 @@ class FormFile } } } - + /*var_dump($filearray); var_dump($sortfield); var_dump($sortorder);*/ - + if ($sortfield && $sortorder) { $filearray=dol_sort_array($filearray, $sortfield, $sortorder); } //var_dump($filearray); } - + $nboffiles=count($filearray); if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - + $var=true; $i=0; $nboflines = 0; $lastrowid=0; foreach($filearray as $key => $file) // filearray must be only files here { @@ -1105,10 +1105,10 @@ class FormFile && $file['name'] != '..' && ! preg_match('/\.meta$/i',$file['name'])) { - - + + if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; - + $editline=0; $nboflines++; print ''."\n"; @@ -1116,11 +1116,11 @@ class FormFile print ''."\n"; print ''; print ''; - + print ''; - + // Preview if (empty($useinecm)) { @@ -1175,7 +1175,7 @@ class FormFile // Delete or view link // ($param must start with &) print '"; if (empty($disablemove)) { - if ($nboffiles > 1 && empty($conf->browser->phone)) { - print ''; } print "\n"; - + $i++; } } @@ -1260,19 +1260,19 @@ class FormFile } print "
    '; - + $filepath=$relativepath.$file['name']; - + if (! $editline) print $this->showPreview($file,$modulepart,$filepath); - + //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; - + print ''.dol_print_size($file['size'],1,1).''.dol_print_date($file['date'],"dayhour","tzuser").''; - if ($useinecm) + if ($useinecm) { print ''.img_view('default', 0, 'class="paddingrightonly"').''; } @@ -1183,10 +1183,10 @@ class FormFile { $newmodulepart=$modulepart; if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; - - $disablecrop=1; + + $disablecrop=1; if (in_array($modulepart, array('product','produit','service','expensereport','holiday','project','user'))) $disablecrop=0; - + if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) @@ -1195,7 +1195,7 @@ class FormFile print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; } } - + if ($permtoeditline) { print ''.img_edit('default',0,'class="paddingrightonly"').''; @@ -1213,15 +1213,15 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - + print ''.img_delete().''; } print "'; + if ($nboffiles > 1 && empty($conf->browser->phone)) { + print ''; if ($i > 0) { print 'id.'">'.img_up('default',0,'imgupforline').''; } @@ -1245,7 +1245,7 @@ class FormFile if (empty($disablemove)) print '
    "; print '
    '; - - if (! $editline && $nboflines > 1) { + + if (! $editline && $nboflines > 1) { if (! empty($conf->use_javascript_ajax) && $permtoeditline) { $table_element_line = 'ecm_files'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } - } - + } + if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline) { print ''; } - + return $nboffiles; } } @@ -1449,19 +1449,19 @@ class FormFile if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files - + print ''."\n"; print ''; print ''; if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1,'document'); else print $langs->trans("ObjectDeleted",($id?$id:$ref)); - + $filename=dol_sanitizeFileName($ref); //$filedir=$conf->$modulepart->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$file['path']; //$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; //print $formfile->getDocumentsLink($modulepart, $filename, $filedir); - + print ''; print ''; //print "XX".$file['name']; //$file['name'] must be utf8 @@ -1471,9 +1471,9 @@ class FormFile print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' '; print dol_trunc($file['name'],$maxlength,'middle'); print '
    '; - + print $this->getDocumentsLink($modulepart, $filename, $filedir); - + print "\n"; print ''.dol_print_size($file['size'],1,1).''; print ''.dol_print_date($file['date'],"dayhour").''; @@ -1668,11 +1668,11 @@ class FormFile return $nboflinks; } - - + + /** * Show detail icon with link for preview - * + * * @param array $file File * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs