Fix pb in ecm

This commit is contained in:
Laurent Destailleur 2017-08-01 18:32:21 +02:00
parent 747719b3e8
commit 71d49f1c6f
10 changed files with 104 additions and 52 deletions

View File

@ -202,7 +202,7 @@ if ($type == 'directory')
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
// If $section defined with value 0 // If $section defined with value 0
if ($section === '0') if ($section === '0' || empty($section))
{ {
$filearray=array(); $filearray=array();
} }

View File

@ -5890,6 +5890,9 @@ class Form
$object->next_prev_filter.=$hookmanager->resPrint; $object->next_prev_filter.=$hookmanager->resPrint;
} }
$previous_ref = $next_ref = '';
if ($shownav)
{
//print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix);
@ -5897,11 +5900,12 @@ class Form
// Special case for project/task page // Special case for project/task page
if ($paramid == 'project_ref') if ($paramid == 'project_ref')
{ {
$navurl = preg_replace('/\/tasks\/(task|contact|time|note|document).php/','/tasks.php',$navurl); $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/','/tasks.php',$navurl);
$paramid='ref'; $paramid='ref';
} }
$previous_ref = $object->ref_previous?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>':'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>'; $previous_ref = $object->ref_previous?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>':'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
$next_ref = $object->ref_next?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>':'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>'; $next_ref = $object->ref_next?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>':'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
}
//print "xx".$previous_ref."x".$next_ref; //print "xx".$previous_ref."x".$next_ref;
$ret.='<!-- Start banner content --><div style="vertical-align: middle">'; $ret.='<!-- Start banner content --><div style="vertical-align: middle">';
@ -5955,6 +5959,10 @@ class Form
{ {
$ret.=$object->label; $ret.=$object->label;
} }
else if ($object->element == 'ecm_directories')
{
$ret.='';
}
else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref); else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref);

View File

@ -1007,9 +1007,9 @@ class FormFile
print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborder':'liste').'">'."\n"; print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborder':'liste').'">'."\n";
print '<tr class="liste_titre nodrag nodrop">'; print '<tr class="liste_titre nodrag nodrop">';
print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$url,"date","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder);
if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"'); if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"');
print_liste_field_titre(''); print_liste_field_titre('');
if (! $disablemove) print_liste_field_titre(''); if (! $disablemove) print_liste_field_titre('');

View File

@ -1349,14 +1349,15 @@ function dol_init_file_process($pathtoscan='', $trackid='')
* *
* @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) * @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename)
* @param int $allowoverwrite 1=Allow overwrite existing file * @param int $allowoverwrite 1=Allow overwrite existing file
* @param int $donotupdatesession 1=Do no edit _SESSION variable * @param int $donotupdatesession 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index.
* @param string $varfiles _FILES var name * @param string $varfiles _FILES var name
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param string $link Link to add (to add a link instead of a file) * @param string $link Link to add (to add a link instead of a file)
* @param string $trackid Track id (used to prefix name of session vars to avoid conflict) * @param string $trackid Track id (used to prefix name of session vars to avoid conflict)
* @param int $generatethumbs 1=Generate also thumbs for uploaded image files
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='') function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1)
{ {
global $db,$user,$conf,$langs; global $db,$user,$conf,$langs;
@ -1407,6 +1408,8 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
// Generate thumbs. // Generate thumbs.
if ($generatethumbs)
{
if (image_format_supported($destfull) == 1) if (image_format_supported($destfull) == 1)
{ {
// Create thumbs // Create thumbs
@ -1418,6 +1421,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
// Used on menu or for setup page for example // Used on menu or for setup page for example
$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); $imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
} }
}
// Update session // Update session
if (empty($donotupdatesession)) if (empty($donotupdatesession))

View File

@ -1341,7 +1341,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>';
} }
if ($object->element != 'product' && $object->element != 'bookmark') if ($object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories')
{ {
$morehtmlref.='<div class="refidno">'; $morehtmlref.='<div class="refidno">';
$morehtmlref.=$object->getBannerAddress('refaddress',$object); $morehtmlref.=$object->getBannerAddress('refaddress',$object);

View File

@ -63,7 +63,7 @@ class modECM extends DolibarrModules
$this->picto='dir'; $this->picto='dir';
// Data directories to create when module is enabled // Data directories to create when module is enabled
$this->dirs = array("/ecm/temp"); $this->dirs = array("/ecm/My_First_Directory","/ecm/temp");
// Config pages. Put here list of php page names stored in admmin directory used to setup module // Config pages. Put here list of php page names stored in admmin directory used to setup module
$this->config_page_url = array('ecm.php'); $this->config_page_url = array('ecm.php');

View File

@ -27,8 +27,9 @@
*/ */
class EcmDirectory // extends CommonObject class EcmDirectory // extends CommonObject
{ {
//public $element='ecm_directories'; //!< Id that identify managed objects public $element='ecm_directories'; //!< Id that identify managed objects
//public $table_element='ecm_directories'; //!< Name of table without prefix where object is stored //public $table_element='ecm_directories'; //!< Name of table without prefix where object is stored
var $picto = 'dir';
var $id; var $id;
@ -514,6 +515,31 @@ class EcmDirectory // extends CommonObject
} }
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->status,$mode);
}
/**
* Return the status
*
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
* @return string Label of status
*/
static function LibStatut($status,$mode=0)
{
global $langs;
return '';
}
/** /**
* Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée
* Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec:

View File

@ -78,7 +78,7 @@ if (! $urlfile)
// Load ecm object // Load ecm object
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
$result=$ecmdir->fetch(GETPOST("section")); $result=$ecmdir->fetch(GETPOST("section",'alpha'));
if (! $result > 0) if (! $result > 0)
{ {
dol_print_error($db,$ecmdir->error); dol_print_error($db,$ecmdir->error);
@ -144,7 +144,7 @@ if ($action == 'update')
//print $oldfile.' - '.$newfile; //print $oldfile.' - '.$newfile;
if ($newlabel != $oldlabel) if ($newlabel != $oldlabel)
{ {
$result=dol_move($oldfile,$newfile); $result=dol_move($oldfile, $newfile);
if (! $result) if (! $result)
{ {
$langs->load('errors'); $langs->load('errors');

View File

@ -191,15 +191,15 @@ if ($action == 'update' && ! GETPOST('cancel'))
/******************************************************************* /*******************************************************************
* PAGE * View
*
* Put here all code to do according to value of "action" parameter
********************************************************************/ ********************************************************************/
llxHeader();
$form=new Form($db); $form=new Form($db);
$object=new EcmDirectory($db); // Need to create a new one
$object->fetch($ecmdir->id);
llxHeader();
// Built the file List // Built the file List
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
@ -211,7 +211,8 @@ foreach($filearray as $key => $file)
$head = ecm_prepare_head($ecmdir); $head = ecm_prepare_head($ecmdir);
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), '', 'dir'); dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir');
if ($action == 'edit') if ($action == 'edit')
{ {
@ -221,13 +222,11 @@ if ($action == 'edit')
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
} }
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
$s=''; $s='';
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
$result = 1; $result = 1;
$i=0; $i=0;
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0) while ($tmpecmdir && $result > 0)
{ {
$tmpecmdir->ref=$tmpecmdir->label; $tmpecmdir->ref=$tmpecmdir->label;
@ -248,10 +247,21 @@ while ($tmpecmdir && $result > 0)
$i++; $i++;
} }
$morehtml='';
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
/*print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '; print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
print $s; print $s;
print '</td></tr>'; print '</td></tr>';*/
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
if ($action == 'edit') if ($action == 'edit')
{ {
print '<textarea class="flat" name="description" cols="80">'; print '<textarea class="flat" name="description" cols="80">';
@ -283,20 +293,24 @@ print '</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
print dol_print_size($totalsize); print dol_print_size($totalsize);
print '</td></tr>'; print '</td></tr>';
print '</table>';
if ($action == 'edit') if ($action == 'edit')
{ {
print '<tr><td colspan="2" align="center">'; print '<br><div align="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>'; print '</div>';
} }
print '</table>';
print '</div>';
if ($action == 'edit') if ($action == 'edit')
{ {
print '</form>'; print '</form>';
} }
print '</div>';
dol_fiche_end();

View File

@ -110,7 +110,7 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
if (! $error) if (! $error)
{ {
$res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', '', ''); $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', '', '', 0);
if ($res > 0) if ($res > 0)
{ {
$result=$ecmdir->changeNbOfFiles('+'); $result=$ecmdir->changeNbOfFiles('+');