diff --git a/ChangeLog b/ChangeLog
index fd18deeac14..5aff4d6d3ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,7 +12,9 @@ Following changes may create regressions for some external modules, but were nec
'doaction' into 'sendMail'.
* Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and
CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE
-
+* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is
+ a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required.
+
***** ChangeLog for 7.0.0 compared to 6.0.5 *****
For users:
diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index 3e661958931..92d0f9e4499 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -28,27 +28,331 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
/**
* Class to manage categories of an accounting account
*/
-class AccountancyCategory
+class AccountancyCategory // extends CommonObject
{
- private $db;
- public $error;
- public $errors = array ();
- public $element = 'accounting_category';
- public $table_element = 'c_accounting_category';
+ public $db; //!< To store db handler
+ public $error; //!< To return error code (or message)
+ public $errors=array(); //!< To return several error codes (or messages)
+ public $element='c_accounting_category'; //!< Id that identify managed objects
+ public $table_element='c_accounting_category'; //!< Name of table without prefix where object is stored
+
public $id;
+ public $code;
+ public $label;
+ public $range_account;
+ public $sens;
+ public $category_type;
+ public $formula;
+ public $position;
+ public $fk_country;
+ public $active;
+
public $lines_cptbk;
public $lines_display;
public $sdc;
+
+
/**
- * Constructor
+ * Constructor
*
- * @param DoliDB $db Database handler
+ * @param DoliDb $db Database handler
*/
- public function __construct($db) {
+ function __construct($db)
+ {
$this->db = $db;
}
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that create
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ function create($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+ if (isset($this->code)) $this->code=trim($this->code);
+ if (isset($this->label)) $this->label=trim($this->label);
+ if (isset($this->range_account)) $this->range_account=trim($this->range_account);
+ if (isset($this->sens)) $this->sens=trim($this->sens);
+ if (isset($this->category_type)) $this->category_type=trim($this->category_type);
+ if (isset($this->formula)) $this->formula=trim($this->formula);
+ if (isset($this->position)) $this->position=trim($this->position);
+ if (isset($this->fk_country)) $this->fk_country=trim($this->fk_country);
+ if (isset($this->active)) $this->active=trim($this->active);
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category(";
+ if ($this->rowid > 0) $sql.= "rowid,";
+ $sql.= "code,";
+ $sql.= "label,";
+ $sql.= "range_account,";
+ $sql.= "sens,";
+ $sql.= "category_type,";
+ $sql.= "formula,";
+ $sql.= "position,";
+ $sql.= "fk_country,";
+ $sql.= "active";
+ $sql.= ") VALUES (";
+ if ($this->rowid > 0) $sql.= " ".$this->rowid.",";
+ $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
+ $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
+ $sql.= " ".(! isset($this->range_account)?'NULL':"'".$this->db->escape($this->range_account)."'").",";
+ $sql.= " ".(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").",";
+ $sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->db->escape($this->category_type)."'").",";
+ $sql.= " ".(! isset($this->formula)?'NULL':"'".$this->db->escape($this->formula)."'").",";
+ $sql.= " ".(! isset($this->position)?'NULL':$this->db->escape($this->position)).",";
+ $sql.= " ".(! isset($this->fk_country)?'NULL':$this->db->escape($this->fk_country)).",";
+ $sql.= " ".(! isset($this->active)?'NULL':$this->db->escape($this->active));
+ $sql.= ")";
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_accounting_category");
+
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ }
+
+
+ /**
+ * Load object in memory from database
+ *
+ * @param int $id Id object
+ * @param string $code Code
+ * @param string $label Label
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch($id,$code='',$label='')
+ {
+ global $langs;
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+ $sql.= " t.code,";
+ $sql.= " t.label,";
+ $sql.= " t.range_account,";
+ $sql.= " t.sens,";
+ $sql.= " t.category_type,";
+ $sql.= " t.formula,";
+ $sql.= " t.position,";
+ $sql.= " t.fk_country,";
+ $sql.= " t.active";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
+ if ($id) $sql.= " WHERE t.rowid = ".$id;
+ elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
+ elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'";
+
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->code = $obj->code;
+ $this->label = $obj->label;
+ $this->range_account = $obj->range_account;
+ $this->sens = $obj->sens;
+ $this->category_type = $obj->category_type;
+ $this->formula = $obj->formula;
+ $this->position = $obj->position;
+ $this->fk_country = $obj->fk_country;
+ $this->active = $obj->active;
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ return -1;
+ }
+ }
+
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modify
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function update($user=null, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+ if (isset($this->code)) $this->code=trim($this->code);
+ if (isset($this->label)) $this->label=trim($this->label);
+ if (isset($this->range_account)) $this->range_account=trim($this->range_account);
+ if (isset($this->sens)) $this->sens=trim($this->sens);
+ if (isset($this->category_type)) $this->category_type=trim($this->category_type);
+ if (isset($this->formula)) $this->formula=trim($this->formula);
+ if (isset($this->position)) $this->position=trim($this->position);
+ if (isset($this->fk_country)) $this->fk_country=trim($this->fk_country);
+ if (isset($this->active)) $this->active=trim($this->active);
+
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET";
+ $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
+ $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
+ $sql.= " range_account=".(isset($this->range_account)?"'".$this->db->escape($this->range_account)."'":"null").",";
+ $sql.= " sens=".(isset($this->sens)?$this->sens:"null").",";
+ $sql.= " category_type=".(isset($this->category_type)?$this->category_type:"null").",";
+ $sql.= " formula=".(isset($this->formula)?"'".$this->db->escape($this->formula)."'":"null").",";
+ $sql.= " position=".(isset($this->position)?$this->position:"null").",";
+ $sql.= " fk_country=".(isset($this->fk_country)?$this->fk_country:"null").",";
+ $sql.= " active=".(isset($this->active)?$this->active:"null")."";
+ $sql.= " WHERE rowid=".$this->id;
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::update", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that delete
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category";
+ $sql.= " WHERE rowid=".$this->id;
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
/**
* Function to select all accounting accounts from an accounting category
*
@@ -443,65 +747,6 @@ class AccountancyCategory
}
- // calcule
-
- /* I try to replace this with dol_eval()
-
- const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/';
-
- const PARENTHESIS_DEPTH = 10;
-
- public function calculate($input)
- {
- global $langs;
-
- if(strpos($input, '+') != null || strpos($input, '-') != null || strpos($input, '/') != null || strpos($input, '*') != null){
- // Remove white spaces and invalid math chars
- $input = str_replace($langs->trans("ThousandSeparator"), '', $input);
- $input = str_replace(',', '.', $input);
- $input = preg_replace('[^0-9\.\+\-\*\/\(\)]', '', $input);
-
- // Calculate each of the parenthesis from the top
- $i = 0;
- while(strpos($input, '(') || strpos($input, ')')){
- $input = preg_replace_callback('/\(([^\(\)]+)\)/', 'self::callback', $input);
-
- $i++;
- if($i > self::PARENTHESIS_DEPTH){
- break;
- }
- }
-
- // Calculate the result
- if(preg_match(self::PATTERN, $input, $match)){
- return $this->compute($match[0]);
- }
-
- return 0;
- }
-
- return $input;
- }
-
- private function compute($input){
- $compute = create_function('', 'return '.$input.';');
-
- return 0 + $compute();
- }
-
- private function callback($input){
- if(is_numeric($input[1])){
- return $input[1];
- }
- elseif(preg_match(self::PATTERN, $input[1], $match)){
- return $this->compute($match[0]);
- }
-
- return 0;
- }
- */
-
-
/**
* Get all accounting account of a group.
* You must choose between first parameter (personalized group) or the second (free criteria filter)
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index bd0722ae63e..5691cd6687b 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -1156,12 +1156,9 @@ class Adherent extends CommonObject
$this->model_pdf = $obj->model_pdf;
- // Retreive all extrafield for thirdparty
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
// Load other properties
$result=$this->fetch_subscriptions();
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 763e648746d..69d1d8a8cea 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -507,25 +507,21 @@ print ''."\n";
if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
- {
- require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
- $formfile = new FormFile($db);
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
+ $formfile = new FormFile($db);
- // Show list of available documents
- $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource.=str_replace('&','&',$param);
+ $hidegeneratedfilelistifempty=1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
- $filedir=$diroutputmassaction;
- $genallowed=$user->rights->monmodule->read;
- $delallowed=$user->rights->monmodule->create;
+ // Show list of available documents
+ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource.=str_replace('&','&',$param);
- print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
- }
- else
- {
- print '
'.$langs->trans("ShowTempMassFilesArea").'';
- }
+ $filedir=$diroutputmassaction;
+ $genallowed=$user->rights->monmodule->read;
+ $delallowed=$user->rights->monmodule->create;
+
+ print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
}
dol_fiche_end();
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 46063c0f8c4..5b824d8c959 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -236,7 +236,9 @@ class Categorie extends CommonObject
$this->type = $res['type'];
$this->entity = $res['entity'];
- $this->fetch_optionals($this->id,null);
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
$this->db->free($resql);
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 9e0a0d6321d..5f094856e1c 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -465,7 +465,10 @@ class ActionComm extends CommonObject
// Load source object
$objFrom = clone $this;
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
$this->fetch_optionals();
+
// $this->fetch_userassigned();
$this->fetchResources();
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 81443f04d62..506b0c6fa8d 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -195,7 +195,7 @@ if (empty($reshook))
if ($ret < 0) $error++;
if (! $error)
{
- $result = $object->insertExtraFields();
+ $result = $object->insertExtraFields('COMPANY_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 54e3cf36c45..9c72170b880 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1234,7 +1234,7 @@ if (empty($reshook))
if ($ret < 0) $error++;
if (! $error)
{
- $result = $object->insertExtraFields();
+ $result = $object->insertExtraFields('PROPAL_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 5efc1cf9db4..1380b02d339 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1289,11 +1289,6 @@ class Propal extends CommonObject
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$clonedObj,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
-
- // Call trigger
- $result=$clonedObj->call_trigger('PROPAL_CLONE',$user);
- if ($result < 0) { $error++; }
- // End call triggers
}
unset($this->context['createfromclone']);
@@ -1439,12 +1434,9 @@ class Propal extends CommonObject
$this->brouillon = 1;
}
- // Retreive all extrafield for invoice
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
$this->db->free($resql);
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index af67bd8107b..5de43a75b9d 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -892,25 +892,18 @@ if ($resql)
print ''."\n";
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
- {
- /*
- * Show list of available documents
- */
- $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource.=str_replace('&','&',$param);
+ $hidegeneratedfilelistifempty=1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
- $filedir=$diroutputmassaction;
- $genallowed=$user->rights->propal->lire;
- $delallowed=$user->rights->propal->creer;
+ // Show list of available documents
+ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource.=str_replace('&','&',$param);
- print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'','');
- }
- else
- {
- print '
'.$langs->trans("ShowTempMassFilesArea").'';
- }
+ $filedir=$diroutputmassaction;
+ $genallowed=$user->rights->propal->lire;
+ $delallowed=$user->rights->propal->creer;
+ print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
}
else
{
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 6e1d411d55e..54c7db7d6ca 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1281,7 +1281,7 @@ if (empty($reshook))
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks
if (empty($reshook)) {
- $result = $object->insertExtraFields();
+ $result = $object->insertExtraFields('ORDER_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 65b704693fb..f89bcf534a2 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1073,11 +1073,6 @@ class Commande extends CommonOrder
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
-
- // Call trigger
- $result=$this->call_trigger('ORDER_CLONE',$user);
- if ($result < 0) $error++;
- // End call triggers
}
unset($this->context['createfromclone']);
@@ -1673,12 +1668,9 @@ class Commande extends CommonOrder
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
- // Retrieve all extrafields for invoice
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
$this->db->free($result);
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 13225c2c5d3..fe8461c3a41 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -1101,25 +1101,18 @@ if ($resql)
print ''."\n";
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
- {
- /*
- * Show list of available documents
- */
- $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource.=str_replace('&','&',$param);
+ $hidegeneratedfilelistifempty=1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
- $filedir=$diroutputmassaction;
- $genallowed=$user->rights->commande->lire;
- $delallowed=$user->rights->commande->creer;
+ // Show list of available documents
+ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource.=str_replace('&','&',$param);
- print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
- }
- else
- {
- print '
'.$langs->trans("ShowTempMassFilesArea").'';
- }
+ $filedir=$diroutputmassaction;
+ $genallowed=$user->rights->commande->lire;
+ $delallowed=$user->rights->commande->creer;
+ print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
}
else
{
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 1dba4a5b221..719a48c3e3c 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -913,12 +913,9 @@ class Account extends CommonObject
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_update = $this->db->jdate($obj->date_update);
- // Retreive all extrafield for thirdparty
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
return 1;
}
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 277a3bc9697..04217fee7cd 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -2119,7 +2119,7 @@ if (empty($reshook))
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks
if (empty($reshook)) {
- $result = $object->insertExtraFields();
+ $result = $object->insertExtraFields('BILL_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 1636be2aace..84b61817a28 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -381,12 +381,9 @@ class FactureRec extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
- // Retreive all extrafield for thirdparty
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
/*
* Lines
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 91e05827032..557dc38e2cf 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -790,14 +790,17 @@ class Facture extends CommonInvoice
// Charge facture source
$facture=new Facture($this->db);
- $this->fetch_optionals();
- if(!empty($this->array_options)){
- $facture->array_options = $this->array_options;
- }
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
- foreach($this->lines as &$line){
+ if(!empty($this->array_options)){
+ $facture->array_options = $this->array_options;
+ }
+
+ foreach($this->lines as &$line){
$line->fetch_optionals();//fetch extrafields
- }
+ }
$facture->fk_facture_source = $this->fk_facture_source;
$facture->type = $this->type;
@@ -958,11 +961,6 @@ class Facture extends CommonInvoice
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
-
- // Call trigger
- $result=$this->call_trigger('BILL_CLONE',$user);
- if ($result < 0) $error++;
- // End call triggers
}
unset($this->context['createfromclone']);
@@ -1333,16 +1331,13 @@ class Facture extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
- // Retrieve all extrafield for invoice
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
/*
* Lines
- */
+ */
$this->lines = array();
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index af81e797252..f869c01aa53 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -450,7 +450,7 @@ if (empty($reshook))
if ($ret < 0) $error++;
if (! $error) {
- $result = $object->insertExtraFields();
+ $result = $object->insertExtraFields('BILLREC_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index fe26efd490e..5914f2f06e9 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1192,22 +1192,18 @@ if ($resql)
print "\n";
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
- {
- // Show list of available documents
- $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource.=str_replace('&','&',$param);
+ $hidegeneratedfilelistifempty=1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
- $filedir=$diroutputmassaction;
- $genallowed=$user->rights->facture->lire;
- $delallowed=$user->rights->facture->creer;
+ // Show list of available documents
+ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource.=str_replace('&','&',$param);
- print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
- }
- else
- {
- print '
'.$langs->trans("ShowTempMassFilesArea").'';
- }
+ $filedir=$diroutputmassaction;
+ $genallowed=$user->rights->facture->lire;
+ $delallowed=$user->rights->facture->creer;
+
+ print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
}
else
{
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index f616ca728b6..eca1174bb59 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -801,12 +801,9 @@ class Contact extends CommonObject
}
}
- // Retreive all extrafield for contact
- // fetch optionals attributes and labels
- require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
return 1;
}
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 6111be6c7ee..0bbb509b7fa 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -94,6 +94,7 @@ $permissionnote=$user->rights->contrat->creer; // Used by the include of actions
$permissiondellink=$user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php
+
/*
* Actions
*/
@@ -875,13 +876,15 @@ if (empty($reshook))
}
else if ($action == 'update_extras')
{
+ $object->oldcopy = dol_clone($object);
+
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) $error++;
if (! $error) {
- $result = $object->insertExtraFields();
+ $result = $object->insertExtraFields('CONTRACT_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 12e08984411..e7bae75c3ed 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -261,9 +261,10 @@ class Contrat extends CommonObject
*
* @param User $user Object User making action
* @param int|string $date_start Date start (now if empty)
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int <0 if KO, >0 if OK
*/
- function activateAll($user, $date_start='')
+ function activateAll($user, $date_start='', $notrigger=0)
{
if (empty($date_start)) $date_start = dol_now();
@@ -294,7 +295,7 @@ class Contrat extends CommonObject
if (! $error && $this->statut == 0)
{
- $result=$this->validate($user);
+ $result=$this->validate($user, '', $notrigger);
if ($result < 0) $error++;
}
@@ -609,7 +610,7 @@ class Contrat extends CommonObject
$this->mise_en_service = $this->db->jdate($result["datemise"]);
$this->date_contrat = $this->db->jdate($result["datecontrat"]);
- $this->date_creation = $this->db->jdate($result["datecontrat"]);
+ $this->date_creation = $this->db->jdate($result["datecontrat"]);
$this->fin_validite = $this->db->jdate($result["fin_validite"]);
$this->date_cloture = $this->db->jdate($result["date_cloture"]);
@@ -634,16 +635,15 @@ class Contrat extends CommonObject
$this->db->free($resql);
- // Retreive all extrafield for thirdparty
+
+ // Retreive all extrafield
// fetch optionals attributes and labels
- require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
+ $this->fetch_optionals();
+
/*
* Lines
- */
+ */
$this->lines = array();
@@ -2430,17 +2430,6 @@ class Contrat extends CommonObject
}
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $clonedObj->old_copy=$this;
- $result = $clonedObj->call_trigger('CONTRACT_CLONE', $user);
- if ($result < 0) {
- $error ++;
- }
- // End call triggers
- }
-
unset($this->context['createfromclone']);
// End
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index cdafbd6c2fd..babc31f7702 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -775,24 +775,18 @@ if ($resql)
print '';
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
- {
- /*
- * Show list of available documents
- */
- $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource.=str_replace('&','&',$param);
+ $hidegeneratedfilelistifempty=1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
- $filedir=$diroutputmassaction;
- $genallowed=$user->rights->contrat->lire;
- $delallowed=$user->rights->contrat->lire;
+ // Show list of available documents
+ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource.=str_replace('&','&',$param);
- print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
- }
- else
- {
- print '
'.$langs->trans("ShowTempMassFilesArea").'';
- }
+ $filedir=$diroutputmassaction;
+ $genallowed=$user->rights->contrat->lire;
+ $delallowed=$user->rights->contrat->lire;
+
+ print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
}
else
{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8def2194fb3..07993bb1d97 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4481,7 +4481,7 @@ abstract class CommonObject
if (! is_array($optionsArray))
{
// If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page.
- // TODO Use of existing extrafield is not yet ready (must mutualize code that use extrafields in form first)
+ // TODO Use of existing $extrafield is not yet ready (must mutualize code that use extrafields in form first)
// global $extrafields;
//if (! is_object($extrafields))
//{
@@ -4496,6 +4496,10 @@ abstract class CommonObject
}
$optionsArray = $extrafields->attributes[$this->table_element]['label'];
}
+ else
+ {
+ dol_syslog("Warning: fetch_optionals was called with param $optionsArray defined when you should pass null now", LOG_WARNING);
+ }
$table_element = $this->table_element;
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility
@@ -4529,7 +4533,17 @@ abstract class CommonObject
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
{
// we can add this attribute to object
- $this->array_options["options_".$key]=$value;
+ if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime')))
+ {
+ //var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
+ $this->array_options["options_".$key]=$this->db->jdate($value);
+ }
+ else
+ {
+ $this->array_options["options_".$key]=$value;
+ }
+
+ //var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]);
}
}
}
diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php
index 1de616210e4..a5a6ea879ce 100644
--- a/htdocs/core/class/ctyperesource.class.php
+++ b/htdocs/core/class/ctyperesource.class.php
@@ -48,14 +48,14 @@ class Ctyperesource
/**
*/
-
+
public $code;
public $label;
public $active;
/**
*/
-
+
/**
* Constructor
@@ -82,7 +82,7 @@ class Ctyperesource
$error = 0;
// Clean parameters
-
+
if (isset($this->code)) {
$this->code = trim($this->code);
}
@@ -93,26 +93,26 @@ class Ctyperesource
$this->active = trim($this->active);
}
-
+
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
-
+
$sql.= 'code,';
$sql.= 'label';
$sql.= 'active';
-
+
$sql .= ') VALUES (';
-
+
$sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").',';
$sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").',';
$sql .= ' '.(! isset($this->active)?'NULL':$this->active);
-
+
$sql .= ')';
$this->db->begin();
@@ -165,18 +165,18 @@ class Ctyperesource
$sql = 'SELECT';
$sql .= ' t.rowid,';
-
+
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.active";
-
+
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if ($id) $sql.= " WHERE t.id = ".$id;
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'";
-
-
+
+
$resql = $this->db->query($sql);
if ($resql) {
$numrows = $this->db->num_rows($resql);
@@ -184,25 +184,20 @@ class Ctyperesource
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
-
+
$this->code = $obj->code;
$this->label = $obj->label;
$this->active = $obj->active;
-
+
}
-
+
// Retrieve all extrafields for invoice
// fetch optionals attributes and labels
- /*
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields=new ExtraFields($this->db);
- $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
- $this->fetch_optionals($this->id,$extralabels);
- */
-
+ // $this->fetch_optionals();
+
// $this->fetch_lines();
-
+
$this->db->free($resql);
if ($numrows) {
@@ -236,12 +231,12 @@ class Ctyperesource
$sql = 'SELECT';
$sql .= ' t.rowid,';
-
+
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.active";
-
+
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
@@ -251,7 +246,7 @@ class Ctyperesource
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
-
+
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
@@ -270,12 +265,12 @@ class Ctyperesource
$line = new self($this->db);
$line->id = $obj->rowid;
-
+
$line->code = $obj->code;
$line->label = $obj->label;
$line->active = $obj->active;
-
+
}
$this->db->free($resql);
@@ -303,7 +298,7 @@ class Ctyperesource
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
-
+
if (isset($this->code)) {
$this->code = trim($this->code);
}
@@ -319,12 +314,12 @@ class Ctyperesource
// Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
-
+
$sql .= ' code = '.(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").',';
$sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").',';
$sql .= ' active = '.(isset($this->active)?$this->active:"null");
-
+
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
@@ -387,7 +382,7 @@ class Ctyperesource
}
// If you need to delete child tables to, you can insert them here
-
+
if (!$error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
$sql .= ' WHERE rowid=' . $this->id;
@@ -468,7 +463,7 @@ class Ctyperesource
public function initAsSpecimen()
{
$this->id = 0;
-
+
$this->code = '';
$this->label = '';
$this->active = '';
@@ -488,7 +483,7 @@ class CtyperesourceLine
/**
* @var mixed Sample line property 1
*/
-
+
public $code;
public $label;
public $active;
@@ -496,5 +491,5 @@ class CtyperesourceLine
/**
* @var mixed Sample line property 2
*/
-
+
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index a127ce706e9..ee165ac6808 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1404,12 +1404,12 @@ class ExtraFields
if ($type == 'date')
{
$showsize=10;
- $value=dol_print_date($value, 'day', 'tzuser');
+ $value=dol_print_date($value, 'day');
}
elseif ($type == 'datetime')
{
$showsize=19;
- $value=dol_print_date($value, 'dayhour', 'tzuser');
+ $value=dol_print_date($value, 'dayhour');
}
elseif ($type == 'int')
{
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index eded41be053..b139483b610 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -277,17 +277,18 @@ class FormFile
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
* @param string $morepicto Add more HTML content into cell with picto
* @param Object $object Object when method is called from an object card.
+ * @param int $hideifempty Hide section of generated files if there is no file
* @return string Output string with HTML array of documents (might be empty string)
*/
- function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$notused=0,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null)
+ function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$notused=0,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null,$hideifempty=0)
{
// Deprecation warning
- if (0 !== $iconPDF) {
+ if (! empty($iconPDF)) {
dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING);
}
global $langs, $conf, $user, $hookmanager;
- global $form, $bc;
+ global $form;
if (! is_object($form)) $form=new Form($this->db);
@@ -305,9 +306,17 @@ class FormFile
}
$hookmanager->initHooks(array('formfile'));
- $forname='builddoc';
- $out='';
+ // Get list of files
+ $file_list=null;
+ if (! empty($filedir))
+ {
+ $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview.*.*\.png)$','date',SORT_DESC);
+ }
+ if ($hideifempty && empty($file_list)) return '';
+
+ $out='';
+ $forname='builddoc';
$headershown=0;
$showempty=0;
$i=0;
@@ -678,8 +687,6 @@ class FormFile
// Get list of files
if (! empty($filedir))
{
- $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview.*.*\.png)$','date',SORT_DESC);
-
$link_list = array();
if (is_object($object))
{
@@ -949,7 +956,6 @@ class FormFile
function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1,$upload_dir='',$sortfield='',$sortorder='ASC', $disablemove=1, $addfilterfields=0)
{
global $user, $conf, $langs, $hookmanager;
- global $bc,$bcdd;
global $sortfield, $sortorder, $maxheightmini;
global $dolibarr_main_url_root;
@@ -1322,7 +1328,6 @@ class FormFile
function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload=0, $relativepath='', $permtodelete=1, $useinecm=0, $textifempty='', $maxlength=0, $url='', $addfilterfields=0)
{
global $user, $conf, $langs, $form;
- global $bc;
global $sortfield, $sortorder;
global $search_doc_ref;
@@ -1543,7 +1548,7 @@ class FormFile
if (count($filearray) == 0)
{
- print '