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/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index ddba2ea6fd9..2e49327ae1d 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -171,6 +171,7 @@ then cp -pr $mydir/../../htdocs/install/doctemplates/* "$documentdir/doctemplates/" mkdir -p "$documentdir/ecm/Administrative documents" mkdir -p "$documentdir/ecm/Images" + rm -f "$documentdir/doctemplates/"*/index.html echo cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" else diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9833a1c01b1..0dcefdcc0ee 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -113,7 +113,7 @@ $tabcond[32]= ! empty($conf->accounting->enabled); // List of help for fields $tabhelp=array(); -$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode")); +$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'category_type'=>$langs->trans("SetToYesIfGroupIsComputationOfOtherGroups"), 'formula'=>$langs->trans("EnterCalculationRuleIfPreviousFieldIsYes")); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); 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/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2d197de8c9f..c4c3d03ee97 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -113,7 +113,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; + $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); @@ -204,7 +204,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("fd.tva_tx", $search_vat); + $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -223,7 +223,7 @@ if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= natural_search("s.tva_intra", $search_tva_intra); + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -245,28 +245,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; - + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '
' . "\n"; print ''; @@ -370,7 +361,7 @@ if ($result) { print ''; print ''; - print '' . $objp->country .''; + print '' . $objp->country .''; print '' . $objp->tva_intra . ''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index df039bf4093..5c7347403d9 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -61,10 +61,10 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; +$offset = $limit * $page; if (! $sortfield) $sortfield = "erd.date, erd.rowid"; if (! $sortorder) { @@ -170,19 +170,19 @@ if (strlen(trim($search_expensereport))) { $sql .= " AND er.ref like '%" . $search_expensereport . "%'"; } if (strlen(trim($search_label))) { - $sql .= " AND f.label like '%" . $search_label . "%'"; + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= " AND er.comments like '%" . $search_desc . "%'"; + $sql .= natural_search("er.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= " AND erd.total_ht like '%" . $search_amount . "%'"; + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= " AND aa.account_number like '%" . $search_account . "%'"; + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; + $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -219,25 +219,18 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_expensereport) - $param .= "&search_expensereport=" . $search_expensereport; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_expensereport) $param .= "&search_expensereport=" . urlencode($search_expensereport); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '' . "\n"; print ''; @@ -297,7 +290,6 @@ if ($result) { $expensereport_static = new ExpenseReport($db); - $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label; @@ -347,7 +339,7 @@ if ($result) { print '
'; } else { - print $db->error(); + print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index b8b1ed9206d..af9d82e5056 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -65,8 +65,8 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) @@ -195,10 +195,10 @@ if (strlen(trim($search_amount))) { $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account, 1); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -214,10 +214,10 @@ else if ($search_year > 0) $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } if (strlen(trim($search_country))) { - $sql .= " AND (co.label like'" . $search_country . "%')"; + $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')"; + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy @@ -241,27 +241,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '
' . "\n"; print ''; @@ -277,7 +269,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 1); print '
'; $moreforfilter = ''; @@ -389,7 +381,7 @@ if ($result) { print '
'; } else { - print $db->error(); + print $db->lasterror(); } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 73f207abe91..65f9c65e641 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1003,7 +1003,7 @@ else if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); if ($res < 0) { dol_print_error($db); exit; } @@ -1272,7 +1272,7 @@ else if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); if ($res < 0) { dol_print_error($db); exit; } 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/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5e9cbb07ca5..c352f5dc944 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -35,6 +35,7 @@ class AdherentType extends CommonObject public $table_element = 'adherent_type'; public $element = 'adherent_type'; public $picto = 'group'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string @@ -307,7 +308,7 @@ class AdherentType extends CommonObject $sql = "SELECT rowid, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity IN (".getEntity('adherent').")"; + $sql.= " WHERE entity IN (".getEntity('member_type').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 26d3d115f75..f2dfba0367a 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; + $sql.= ' WHERE t.entity IN ('.getEntity('member_type').')'; // Add sql filters if ($sqlfilters) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index a04b1df5786..fd418756bd6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -65,7 +65,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " ON t.rowid = d.fk_adherent_type"; $sql.= " AND d.entity IN (".getEntity('adherent').")"; -$sql.= " WHERE t.entity IN (".getEntity('adherent').")"; +$sql.= " WHERE t.entity IN (".getEntity('member_type').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members by type", LOG_DEBUG); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index a01cc379b3c..fc30d6f1ae2 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -574,7 +574,7 @@ if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titr include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index cc9fd872062..48df382181d 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -216,7 +216,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); if ($result) @@ -361,7 +361,7 @@ if ($rowid > 0) { $object = new AdherentType($db); $object->fetch($rowid); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); /* * Confirmation suppression @@ -692,7 +692,7 @@ if ($rowid > 0) { $object = new AdherentType($db); $object->fetch($rowid); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $head = member_type_prepare_head($object); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 438c7cd5227..fbb0b5f38c5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -93,7 +93,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,25,0); // Name of SQL tables of dictionaries $tabname=array(); @@ -121,7 +121,7 @@ $tabname[21]= MAIN_DB_PREFIX."c_availability"; $tabname[22]= MAIN_DB_PREFIX."c_input_reason"; $tabname[23]= MAIN_DB_PREFIX."c_revenuestamp"; $tabname[24]= MAIN_DB_PREFIX."c_type_resource"; -//$tabname[25]= MAIN_DB_PREFIX."c_email_templates"; +$tabname[25]= MAIN_DB_PREFIX."c_type_container"; $tabname[26]= MAIN_DB_PREFIX."c_units"; $tabname[27]= MAIN_DB_PREFIX."c_stcomm"; $tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; @@ -160,7 +160,7 @@ $tablib[21]= "DictionaryAvailability"; $tablib[22]= "DictionarySource"; $tablib[23]= "DictionaryRevenueStamp"; $tablib[24]= "DictionaryResourceType"; -//$tablib[25]= "DictionaryEMailTemplates"; +$tablib[25]= "DictionaryTypeOfContainer"; $tablib[26]= "DictionaryUnits"; $tablib[27]= "DictionaryProspectStatus"; $tablib[28]= "DictionaryHolidayTypes"; @@ -199,7 +199,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; +$tabsql[25]= "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; @@ -237,8 +237,8 @@ $tabsqlsort[20]="code ASC, libelle ASC"; $tabsqlsort[21]="code ASC, label ASC"; $tabsqlsort[22]="code ASC, label ASC"; $tabsqlsort[23]="country ASC, taux ASC"; -$tabsqlsort[24]="code ASC,label ASC"; -//$tabsqlsort[25]="label ASC"; +$tabsqlsort[24]="code ASC, label ASC"; +$tabsqlsort[25]="t.module ASC, t.code ASC, t.label ASC"; $tabsqlsort[26]="code ASC"; $tabsqlsort[27]="code ASC"; $tabsqlsort[28]="country ASC, code ASC"; @@ -277,7 +277,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -//$tabfield[25]= "label,type_template,private,position,topic,content_lines,content"; +$tabfield[25]= "code,label"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; @@ -316,7 +316,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -//$tabfieldvalue[25]= "label,type_template,private,position,topic,content_lines,content"; +$tabfieldvalue[25]= "code,label"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; @@ -355,7 +355,7 @@ $tabfieldinsert[21]= "code,label"; $tabfieldinsert[22]= "code,label"; $tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[24]= "code,label"; -//$tabfieldinsert[25]= "label,type_template,private,position,topic,content_lines,content,entity"; +$tabfieldinsert[25]= "code,label"; $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; @@ -396,7 +396,7 @@ $tabrowid[21]= "rowid"; $tabrowid[22]= "rowid"; $tabrowid[23]= ""; $tabrowid[24]= ""; -//$tabrowid[25]= ""; +$tabrowid[25]= ""; $tabrowid[26]= ""; $tabrowid[27]= "id"; $tabrowid[28]= ""; @@ -435,7 +435,7 @@ $tabcond[21]= ! empty($conf->propal->enabled); $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); $tabcond[23]= true; $tabcond[24]= ! empty($conf->resource->enabled); -//$tabcond[25]= true; // && ! empty($conf->global->MAIN_EMAIL_EDIT_TEMPLATE_FROM_DIC); +$tabcond[25]= ! empty($conf->website->enabled); $tabcond[26]= ! empty($conf->product->enabled); $tabcond[27]= ! empty($conf->societe->enabled); $tabcond[28]= ! empty($conf->holiday->enabled); @@ -474,7 +474,7 @@ $tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent'); $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); -//$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'content_lines'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode')); $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); @@ -513,7 +513,7 @@ $tabfieldcheck[21] = array(); $tabfieldcheck[22] = array(); $tabfieldcheck[23] = array(); $tabfieldcheck[24] = array(); -//$tabfieldcheck[25] = array(); +$tabfieldcheck[25] = array(); $tabfieldcheck[26] = array(); $tabfieldcheck[27] = array(); $tabfieldcheck[28] = array(); @@ -1072,8 +1072,7 @@ if ($id) if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='width100'; } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { - if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - else $valuetoshow=$langs->trans("Label"); + $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); } if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); @@ -1298,12 +1297,7 @@ if ($id) if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field]=='position') { $align='right'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { - //if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - //else $valuetoshow=$langs->trans("Label"); - $valuetoshow=$langs->trans("Label"); - } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='libelle_facture') { //$valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); $valuetoshow=$langs->trans("LabelOnDocuments"); 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/admin/modulehelp.php b/htdocs/admin/modulehelp.php index bc48feb076f..dd90774a05b 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -163,8 +163,6 @@ foreach ($modulesdir as $dir) $modules[$i] = $objMod; $filename[$i]= $modName; - $special = $objMod->special; - // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { if (!is_array($familyinfo)) $familyinfo=array(); @@ -180,13 +178,11 @@ foreach ($modulesdir as $dir) $moduleposition = 800; } - if ($special == 1) $familykey='interface'; - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] - $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown'; + $specialstring = 'unknown'; if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories else $categ[$specialstring]=1; @@ -240,7 +236,6 @@ foreach($orders as $tmpkey => $tmpvalue) $i++; } $value = $orders[$key]; -$special = $objMod->special; $tab=explode('_',$value); $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3]; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ee17e647863..db8251d0562 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -358,8 +358,6 @@ foreach ($modulesdir as $dir) $filename[$i]= $modName; $modules[$modName] = $objMod; - $special = $objMod->special; - // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { $familyinfo = array_merge($familyinfo, $objMod->familyinfo); @@ -374,8 +372,6 @@ foreach ($modulesdir as $dir) $moduleposition = 800; } - if ($special == 1) $familykey='interface'; - // Add list of warnings to show into arrayofwarnings and arrayofwarningsext if (! empty($objMod->warnings_activation)) { @@ -390,7 +386,7 @@ foreach ($modulesdir as $dir) $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] - $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown'; + $specialstring = 'unknown'; if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories else $categ[$specialstring]=1; @@ -531,12 +527,9 @@ if ($mode == 'common') $objMod = $modules[$modName]; $dirofmodule = $dirmod[$key]; - $special = $objMod->special; - - //print $objMod->name." - ".$key." - ".$objMod->special.' - '.$objMod->version."
"; + //print $objMod->name." - ".$key." - ".$objMod->version."
"; //if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev') - if (($special >= 4 && $mode != 'expdev') - || ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental')) continue; // Discard if not for current tab + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab if (! $objMod->getName()) { @@ -741,12 +734,12 @@ if ($mode == 'common') if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs)) { $urltouse=dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1); - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } else { $urltouse=$urlpage; - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } } } @@ -754,11 +747,11 @@ if ($mode == 'common') } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } else { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } } else diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 60c20dfafe7..38cf0b3f0df 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -140,7 +140,7 @@ if (GETPOST('target') == 'remote') if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; - //print "eee".$xmlfile."eee"; + //print "xmlfilestart".$xmlfile."xmlfileend"; $xml = simplexml_load_string($xmlfile); } else diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 27b909c2dad..65ba8f4ff37 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -638,7 +638,7 @@ class Setup extends DolibarrApi if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; - //print "eee".$xmlfile."eee"; + //print "xmlfilestart".$xmlfile."endxmlfile"; $xml = simplexml_load_string($xmlfile); } else diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 1ebd512e772..5e684b4091d 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -143,7 +144,7 @@ if ($action == 'initbarcodeproducts') $nextvalue=$modBarCodeProduct->getNextValue($productstatic,''); //print 'Set value '.$nextvalue.' to product '.$productstatic->id." ".$productstatic->ref." ".$productstatic->type."
\n"; - $result=$productstatic->setValueFrom('barcode', $nextvalue, '', '', 'date', '', $user, 'PRODUCT_MODIFY'); + $result=$productstatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'PRODUCT_MODIFY'); $nbtry++; if ($result > 0) $nbok++; diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 8bfd1d3082c..769a69a23fa 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -233,7 +233,7 @@ class Facturation $this->prix_total_localtax2 = $total_localtax2; $this->montant_tva = $total_ttc - $total_ht; - //print $this->prix_total_ttc.'eeee'; exit; + //print 'total: '.$this->prix_total_ttc; exit; } /** diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 399e2984ea8..431f921a1fb 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -324,7 +324,7 @@ switch ($action) { // We set status to payed $result=$invoice->set_paid($user); - //print 'eeeee';exit; + //print 'set paid';exit; } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 46063c0f8c4..ada86667f44 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); @@ -713,11 +715,12 @@ class Categorie extends CommonObject } } - // Save object we want to link category to into category instance to provide information to trigger - $this->linkto=$obj; + // Call trigger - $result=$this->call_trigger('CATEGORY_LINK',$user); + $this->linkto=$obj; // Deprecated. Save object we want to link category to into category instance to provide information to trigger + $this->context=array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result=$this->call_trigger('CATEGORY_LINK',$user); if ($result < 0) { $error++; } // End call triggers diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 1f7b41df085..f6a0417bbda 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -53,11 +53,12 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); $result=$object->fetch($id, $label); -$object->fetch_optionals($id,$extralabels); -if ($result <= 0) -{ - dol_print_error($db,$object->error); - exit; +if ($result <= 0) { + dol_print_error($db,$object->error); exit; +} +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db,$object->error); exit; } $type=$object->type; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b89263bae01..2f59df43803 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -934,7 +934,7 @@ if ($id > 0) $result2=$object->fetch_projet(); $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); - $result5=$object->fetch_optionals($id,$extralabels); + $result5=$object->fetch_optionals(); if ($listUserAssignedUpdated || $donotclearsession) { 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/action/document.php b/htdocs/comm/action/document.php index 46efeb95a54..1bbe5ddc6fc 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -100,7 +100,7 @@ if ($object->id > 0) $result2=$object->fetch_thirdparty(); $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); - $result5=$object->fetch_optionals($id,$extralabels); + $result5=$object->fetch_optionals(); if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 81443f04d62..aab95264a57 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -189,13 +189,15 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($id); + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); 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 4291b22508d..a09485e0a9a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -201,7 +201,7 @@ if (empty($reshook)) { $result = $object->delete($user); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); + header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1'); exit(); } else { $langs->load("errors"); @@ -505,7 +505,7 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } @@ -1228,13 +1228,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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); 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..850fa969bbb 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1210,7 +1210,7 @@ class Propal extends CommonObject // get extrafields so they will be clone foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); + $line->fetch_optionals(); // Load dest object $clonedObj = clone $this; @@ -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']); @@ -1321,7 +1316,7 @@ class Propal extends CommonObject function fetch($rowid,$ref='') { - $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql.= ", p.datec"; $sql.= ", p.date_valid as datev"; @@ -1367,6 +1362,7 @@ class Propal extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; @@ -1439,12 +1435,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..a47625e100b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -614,7 +614,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -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 6cd21df9c78..dabd44ae448 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -185,7 +185,7 @@ if (empty($reshook)) $result = $object->delete($user); if ($result > 0) { - header('Location: index.php'); + header('Location: list.php?restore_lastsearch_values=1'); exit; } else @@ -1268,9 +1268,11 @@ if (empty($reshook)) 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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) @@ -1281,7 +1283,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'); @@ -1804,7 +1806,7 @@ if ($action == 'create' && $user->rights->commande->creer) $author = new User($db); $author->fetch($object->user_author_id); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = commande_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 65b704693fb..92e04e1672b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1024,7 +1024,7 @@ class Commande extends CommonOrder // get lines so they will be clone foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); + $line->fetch_optionals(); // Load source object $objFrom = clone $this; @@ -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']); @@ -1150,7 +1145,7 @@ class Commande extends CommonOrder $line->marque_tx = $marginInfos[2]; // get extrafields from original line - $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + $object->lines[$i]->fetch_optionals(); foreach($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; @@ -1572,7 +1567,7 @@ class Commande extends CommonOrder // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; + $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.fk_account'; $sql.= ', c.date_commande'; @@ -1602,12 +1597,14 @@ class Commande extends CommonOrder dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - $obj = $this->db->fetch_object($result); - if ($obj) - { - $this->id = $obj->rowid; + if ($result) + { + $obj = $this->db->fetch_object($result); + if ($obj) + { + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; $this->ref_customer = $obj->ref_client; @@ -1673,12 +1670,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..793fb2cf708 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -701,7 +701,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -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 ab75eaa86de..5062bc88f99 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -191,7 +191,7 @@ if (empty($reshook)) $result = $object->delete($user, 0, $idwarehouse); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1'); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -925,6 +925,12 @@ if (empty($reshook)) foreach($facture_source->lines as $line) { + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($line, 'fetch_optionals')) { + // load extrafields + $line->fetch_optionals(); + } + // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; @@ -2106,9 +2112,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { @@ -2119,7 +2127,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'); @@ -3257,7 +3265,7 @@ else if ($id > 0 || ! empty($ref)) // Invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; // Ref customer diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1636be2aace..7a08cc6c97e 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 @@ -504,7 +501,7 @@ class FactureRec extends CommonInvoice $line->price = $objp->price; $line->remise = $objp->remise; - $extralabelsline = $line->fetch_optionals($line->id,$extrafieldsline); + $extralabelsline = $line->fetch_optionals($line->id); // Multicurrency $line->fk_multicurrency = $objp->fk_multicurrency; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7edc3b65b41..c8f5c25e1e8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -557,6 +557,15 @@ class Facture extends CommonInvoice } $newinvoiceline->fk_parent_line=$fk_parent_line; + + if($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except){ + $discount = new DiscountAbsolute($this->db); + $discount->fetch($newinvoiceline->fk_remise_except); + + $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); + $newinvoiceline->fk_remise_except = $discountId; + } + $result=$newinvoiceline->insert(); // Defined the new fk_parent_line @@ -790,14 +799,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 +970,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']); @@ -1033,7 +1040,7 @@ class Facture extends CommonInvoice $line->pa_ht = $marginInfos[0]; // get extrafields from original line - $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + $object->lines[$i]->fetch_optionals(); foreach($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; @@ -1230,7 +1237,7 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; + $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.datef as df, f.date_pointoftax'; @@ -1267,6 +1274,8 @@ class Facture extends CommonInvoice $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->facnumber; $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; @@ -1333,16 +1342,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(); @@ -3836,6 +3842,7 @@ class Facture extends CommonInvoice // Initialize parameters $this->id=0; + $this->entity = 1; $this->ref = 'SPECIMEN'; $this->specimen=1; $this->socid = 1; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index af81e797252..43d28c9abbd 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -444,13 +444,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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); 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..bacaddcffd4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -862,7 +862,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -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/agenda.php b/htdocs/contact/agenda.php index c885f0869de..c513db1b49f 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -190,7 +190,8 @@ else $object = new Contact($db); $res=$object->fetch($id, $user); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); + if ($res < 0) { dol_print_error($db,$object->error); exit; } // Show tabs $head = contact_prepare_head($object); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 9c35714dcd5..7d024e6f096 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -468,7 +468,8 @@ else $object = new Contact($db); $res=$object->fetch($id, $user); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); + if ($res < 0) { dol_print_error($db,$object->error); exit; } // Show tabs $head = contact_prepare_head($object); 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..59688aab1a3 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 */ @@ -841,7 +842,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result >= 0) { - header("Location: index.php"); + header("Location: list.php?restore_lastsearch_values=1"); return; } else @@ -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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1706,7 +1709,7 @@ else if (is_array($extralabelslines) && count($extralabelslines)>0) { print ''; $line = new ContratLigne($db); - $line->fetch_optionals($objp->rowid,$extralabelslines); + $line->fetch_optionals($objp->rowid); print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); print ''; } @@ -1780,7 +1783,7 @@ else if (is_array($extralabelslines) && count($extralabelslines)>0) { print ''; $line = new ContratLigne($db); - $line->fetch_optionals($objp->rowid,$extralabelslines); + $line->fetch_optionals($objp->rowid); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); print ''; } @@ -1892,7 +1895,7 @@ else } if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) { - print ''; + print ''; print img_picto($tmpactiontext, $tmpactionpicto); print ''; } @@ -1993,7 +1996,7 @@ else print ''; print ''; - print ''; + print '
'; // Definie date debut et fin par defaut $dateactstart = $objp->date_debut_reelle; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 190de79aa17..02868eb369c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -261,9 +261,11 @@ 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 + * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function activateAll($user, $date_start='') + function activateAll($user, $date_start='', $notrigger=0, $comment='') { if (empty($date_start)) $date_start = dol_now(); @@ -279,7 +281,9 @@ class Contrat extends CommonObject // Open lines not already open if ($contratline->statut != 4) { - $result = $contratline->active_line($user, $date_start, -1); + $contratline->context = $this->context; + + $result = $contratline->active_line($user, $date_start, -1, $comment); if ($result < 0) { $error++; @@ -292,7 +296,7 @@ class Contrat extends CommonObject if (! $error && $this->statut == 0) { - $result=$this->validate($user); + $result=$this->validate($user, '', $notrigger); if ($result < 0) $error++; } @@ -313,9 +317,10 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function closeAll(User $user, $notrigger=0) + function closeAll(User $user, $notrigger=0, $comment='') { $this->db->begin(); @@ -334,7 +339,7 @@ class Contrat extends CommonObject $contratline->date_cloture=$now; $contratline->fk_user_cloture=$user->id; $contratline->statut='5'; - $result=$contratline->close_line($user, $now); + $result=$contratline->close_line($user, $now, $comment, $notrigger); if ($result < 0) { $error++; @@ -607,7 +612,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"]); @@ -632,16 +637,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(); @@ -793,7 +797,7 @@ class Contrat extends CommonObject // Retreive all extrafield for contract // fetch optionals attributes and labels - $line->fetch_optionals($line->id,$extralabelsline); + $line->fetch_optionals(); $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; @@ -1338,7 +1342,7 @@ class Contrat extends CommonObject // Check parameters if ($fk_product <= 0 && empty($desc)) { - $this->error="DescRequiredForFreeProductLines"; + $this->error="ErrorDescRequiredForFreeProductLines"; return -1; } @@ -1465,49 +1469,39 @@ class Contrat extends CommonObject { $contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX."contratdet"); - $result=$this->update_statut($user); - if ($result > 0) + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { - - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + $contractline = new ContratLigne($this->db); + $contractline->array_options=$array_options; + $contractline->id=$contractlineid; + $result=$contractline->insertExtraFields(); + if ($result < 0) { - $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_options; - $contractline->id=$contractlineid; - $result=$contractline->insertExtraFields(); - if ($result < 0) - { - $this->error[]=$contractline->error; - $error++; - } - } - - if (empty($error)) { - // Call trigger - $result=$this->call_trigger('LINECONTRACT_INSERT',$user); - if ($result < 0) - { - $error++; - } - // End call triggers - } - - if ($error) - { - $this->db->rollback(); - return -1; - } - else - { - $this->db->commit(); - return $contractlineid; + $this->error[]=$contractline->error; + $error++; } } - else + + if (empty($error)) { + // Call trigger + $result=$this->call_trigger('LINECONTRACT_INSERT',$user); + if ($result < 0) + { + $error++; + } + // End call triggers + } + + if ($error) { $this->db->rollback(); return -1; } + else + { + $this->db->commit(); + return $contractlineid; + } } else { @@ -2428,17 +2422,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 @@ -3103,13 +3086,6 @@ class ContratLigne extends CommonObjectLine { global $langs, $conf; - // Update object - $this->date_ouverture = $date; - $this->date_fin_validite = $date_end; - $this->fk_user_ouverture = $user->id; - $this->date_cloture = null; - $this->commentaire = $comment; - $error = 0; $this->db->begin(); @@ -3127,15 +3103,26 @@ class ContratLigne extends CommonObjectLine if ($resql) { // Call trigger $result = $this->call_trigger('LINECONTRACT_ACTIVATE', $user); - if ($result < 0) { - $error++; + if ($result < 0) $error++; + // End call triggers + + if (! $error) + { + $this->statut = 4; + $this->date_ouverture = $date; + $this->date_fin_validite = $date_end; + $this->fk_user_ouverture = $user->id; + $this->date_cloture = null; + $this->commentaire = $comment; + + $this->db->commit(); + return 1; + } + else + { $this->db->rollback(); return -1; } - // End call triggers - - $this->db->commit(); - return 1; } else { $this->error = $this->db->lasterror(); $this->db->rollback(); @@ -3149,9 +3136,10 @@ class ContratLigne extends CommonObjectLine * @param User $user Objet User who close contract * @param int $date_end Date end * @param string $comment A comment typed by user + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function close_line($user, $date_end, $comment = '') + function close_line($user, $date_end, $comment = '', $notrigger=0) { global $langs, $conf; @@ -3173,15 +3161,19 @@ class ContratLigne extends CommonObjectLine $sql .= " WHERE rowid = " . $this->id . " AND statut = 4"; $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); - if ($result < 0) { - $error++; - $this->db->rollback(); - return -1; + if ($resql) + { + if (! $notrigger) + { + // Call trigger + $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } + // End call triggers } - // End call triggers $this->db->commit(); return 1; 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/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b08993acf8a..fae976dec80 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -46,7 +46,7 @@ if (! empty($massaction) && count($toselect) < 1) $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (! $error && count($toselect) > $maxformassaction) +if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); $error++; diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 25fa257d098..e5819f0f14c 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -88,7 +88,7 @@ class box_members extends ModeleBoxes $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql.= " t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.entity = ".$conf->entity; + $sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql.= " AND a.fk_adherent_type = t.rowid"; $sql.= " ORDER BY a.tms DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index aeca3d5a102..f5a16aa540b 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -203,7 +203,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('societe',true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { @@ -274,7 +274,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true); - $object->fetch_optionals($object->id, $extralabels); + $object->fetch_optionals(); foreach($extrafields->attribute_label as $key => $label) { @@ -316,6 +316,14 @@ abstract class CommonDocGenerator 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), ); + + foreach($conf->global as $key => $val) + { + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval = $val; + $array_other['__['.$key.']__'] = $newval; + } + return $array_other; } @@ -345,17 +353,19 @@ abstract class CommonDocGenerator $sumcreditnote = $object->getSumCreditNotesUsed(); } + $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); + $resarray=array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>$object->ref_client, - $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur)?$object->ref_fournisseur:''), + $array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), $array_key.'_source_invoice_ref'=>$invoice_source->ref, // Dates - $array_key.'_hour'=>dol_print_date($object->date,'hour'), - $array_key.'_date'=>dol_print_date($object->date,'day'), - $array_key.'_date_rfc'=>dol_print_date($object->date,'dayrfc'), + $array_key.'_hour'=>dol_print_date($date,'hour'), + $array_key.'_date'=>dol_print_date($date,'day'), + $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), @@ -457,7 +467,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); } @@ -524,7 +534,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $line->fetch_optionals($line->rowid,$extralabels); + $line->fetch_optionals(); $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); @@ -592,7 +602,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('shipment',true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); }*/ diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index c629c6021b4..5b032eb94a3 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -451,7 +451,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); } @@ -469,7 +469,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); return img_picto($langs->trans('BillStatusStarted'),'statut3'); } @@ -487,7 +487,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); } @@ -506,7 +506,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); if ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5abf5e3a0e1..d08d5df3f78 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1231,7 +1231,7 @@ abstract class CommonObject } /** - * Charge le projet d'id $this->fk_project dans this->projet + * Load the project with id $this->fk_project into this->project * * @return int <0 if KO, >=0 if OK */ @@ -1251,7 +1251,25 @@ abstract class CommonObject } /** - * Charge le user d'id userid dans this->user + * Load the product with id $this->fk_product into this->product + * + * @return int <0 if KO, >=0 if OK + */ + function fetch_product() + { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + if (empty($this->fk_product)) return 0; + + $product = new Product($this->db); + $result = $product->fetch($this->fk_product); + + $this->product = $product; + return $result; + } + + /** + * Load the user with id $userid into this->user * * @param int $userid Id du contact * @return int <0 if KO, >0 if OK @@ -3670,8 +3688,7 @@ abstract class CommonObject foreach ($this->lines as $line) { //Line extrafield - $line->fetch_optionals($line->id,$extralabelslines); - + $line->fetch_optionals(); //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) @@ -4123,6 +4140,7 @@ abstract class CommonObject * @param int $hideref 1 to hide product reference. 0 by default * @param null|array $moreparams Array to provide more information * @return int >0 if OK, <0 if KO + * @see addFileIntoDatabaseIndex */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null) { @@ -4361,6 +4379,7 @@ abstract class CommonObject /** * Build thumb + * @TODO Move this into files.lib.php * * @param string $file Path file in UTF8 to original file to create thumbs from. * @return void @@ -4487,7 +4506,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)) //{ @@ -4502,6 +4521,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 @@ -4535,7 +4558,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 (! empty($extrafields) && 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]); } } } @@ -4622,10 +4655,10 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeLabel = $extrafields->attribute_label[$attributeKey]; - $attributeParam = $extrafields->attribute_param[$attributeKey]; - $attributeRequired = $extrafields->attribute_required[$attributeKey]; + $attributeType = $extrafields->attributes[$this->table_element]['type'][$attributeKey]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; if ($attributeRequired) { @@ -4658,7 +4691,43 @@ abstract class CommonObject $this->array_options[$key] = null; } break;*/ - case 'price': + case 'password': + $algo=''; + if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) + { + // If there is an encryption choice, we use it to crypt data before insert + $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); + if ($algo != '') + { + //global $action; // $action may be 'create', 'update', 'update_extras'... + //var_dump($action); + //var_dump($this->oldcopy);exit; + if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value + { + //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); + if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } + else + { + // var_dump($algo); + $newvalue = dol_hash($this->array_options[$key], $algo); + $new_array_options[$key] = $newvalue; + } + } + else + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } + } + } + else // Common usage + { + $new_array_options[$key] = $this->array_options[$key]; + } + break; + case 'price': $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': @@ -4716,7 +4785,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; @@ -4724,8 +4793,8 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + // Add field of attribute + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) { if ($new_array_options[$key] != '') { @@ -4774,7 +4843,7 @@ abstract class CommonObject * Update an exta field value for the current object. * Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * - * @param string $key Key of the extrafield + * @param string $key Key of the extrafield (without starting 'options_') * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK @@ -4799,9 +4868,12 @@ abstract class CommonObject $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); $value=$this->array_options["options_".$key]; - $attributeType = $extrafields->attribute_type[$key]; - $attributeLabel = $extrafields->attribute_label[$key]; - $attributeParam = $extrafields->attribute_param[$key]; + + $attributeType = $extrafields->attributes[$this->table_element]['type'][$key]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$key]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + switch ($attributeType) { case 'int': @@ -4831,7 +4903,7 @@ abstract class CommonObject $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'link': - $param_list=array_keys($attributeParam ['options']); + $param_list=array_keys($attributeParam['options']); // 0 : ObjectName // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); 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..db0e7f4284a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -234,7 +234,7 @@ class ExtraFields $lengthdb='11'; } elseif($type=='password') { $typedb='varchar'; - $lengthdb='50'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; @@ -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.form.class.php b/htdocs/core/class/html.form.class.php index aafe9b81cc1..806446cfdc1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3653,7 +3653,7 @@ class Form $more.=''; $more.=''; @@ -1600,7 +1605,6 @@ class FormFile public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null, $param='') { global $user, $conf, $langs, $user; - global $bc; global $sortfield, $sortorder; $langs->load("link"); @@ -1712,7 +1716,7 @@ class FormFile } if ($nboflinks == 0) { - print ''; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 94ab828ee39..67497b4881b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -982,11 +982,12 @@ class FormMail extends Form * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with position = 0, or 0 for all + * @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position * @param int $active 1=Only active template, 0=Only disabled, -1=All + * @param string $label Label of template * @return array array('topic'=>,'content'=>,..) */ - public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) + public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1, $label='') { $ret=array(); @@ -996,11 +997,13 @@ class FormMail extends Form $sql.= " AND entity IN (".getEntity('c_email_templates').")"; $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; + if ($label) $sql.=" AND label ='".$this->db->escape($label)."'"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; - $sql.= $db->order("position,lang,label","ASC"); - if ($id == -1) $sql.= $db->plimit(1); + if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' + else $sql.= $db->order("position,lang,label","ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined + $sql.= $db->plimit(1); //print $sql; $resql = $db->query($sql); @@ -1185,7 +1188,7 @@ class FormMail extends Form $extralabels = $extrafields->fetch_name_optionals_label('product', true); $product = new Product($this->db); $product->fetch($line->fk_product, '', '', 1); - $product->fetch_optionals($product->id, $extralabels); + $product->fetch_optionals(); foreach ($extrafields->attribute_label as $key => $label) { $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; } diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 5f78fa0e283..cf1b7064a01 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -85,8 +85,6 @@ class FormMargin $product = new ProductFournisseur($db); if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); - if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) - $line->pa_ht += $product->fourn_unitcharges; } // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { @@ -96,7 +94,7 @@ class FormMargin $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); $pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign $pa = $line->qty * $pa_ht; - + // calcul des marges if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index af9bd644caf..3339b2b054e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1184,7 +1184,7 @@ class FormOther /** - * Return a HTML select list of bank accounts + * Return a HTML select list of a dictionary * * @param string $htmlname Name of select zone * @param string $dictionarytable Dictionary table diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index f1d407d3bba..9f03213a16d 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -292,7 +292,7 @@ class FormProjets } /** - * Output a combo list with projects qualified for a third party + * Output a combo list with tasks qualified for a third party * * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) * @param int $selected Id task preselected @@ -304,9 +304,11 @@ class FormProjets * @param int $forcefocus Force focus on field (works with javascript only) * @param int $disabled Disabled * @param string $morecss More css added to the select component + * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. + * @param string $showproject 'all' = Show project info, ''=Hide project info * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500') + function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $projectsListId='', $showproject='all') { global $user,$conf,$langs; @@ -317,11 +319,13 @@ class FormProjets $hideunselectables = false; if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; - $projectsListId = false; - if (empty($user->rights->projet->all->lire)) + if (empty($projectsListId)) { - $projectstatic=new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + if (empty($user->rights->projet->all->lire)) + { + $projectstatic=new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + } } // Search all projects @@ -332,7 +336,7 @@ class FormProjets $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t'; $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND t.fk_projet = p.rowid"; - if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; + if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; $sql.= " ORDER BY p.ref, t.ref ASC"; @@ -378,31 +382,38 @@ class FormProjets continue; } - $labeltoshow=dol_trunc($obj->ref,18); // Project ref - //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; - //else $labeltoshow.=' ('.$langs->trans("Private").')'; - $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); + $labeltoshow = ''; - if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; + if ($showproject == 'all') + { + $labeltoshow.=dol_trunc($obj->ref,18); // Project ref + //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; + //else $labeltoshow.=' ('.$langs->trans("Private").')'; + $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); - $disabled=0; - if ($obj->fk_statut == 0) - { - $disabled=1; - $labeltoshow.=' - '.$langs->trans("Draft"); - } - else if ($obj->fk_statut == 2) - { - if ($discard_closed == 2) $disabled=1; - $labeltoshow.=' - '.$langs->trans("Closed"); - } - else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) - { - $disabled=1; - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); + if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; + + $disabled=0; + if ($obj->fk_statut == 0) + { + $disabled=1; + $labeltoshow.=' - '.$langs->trans("Draft"); + } + else if ($obj->fk_statut == 2) + { + if ($discard_closed == 2) $disabled=1; + $labeltoshow.=' - '.$langs->trans("Closed"); + } + else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) + { + $disabled=1; + $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); + } + $labeltoshow.=' - '; } + // Label for task - $labeltoshow.=' - '.$obj->tref.' '.dol_trunc($obj->tlabel,$maxlength); + $labeltoshow.=$obj->tref.' '.dol_trunc($obj->tlabel,$maxlength); if (!empty($selected) && $selected == $obj->rowid) { diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 6981ecc343f..e7cd6d447a0 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -95,4 +95,112 @@ class FormWebsite return $out; } + + /** + * Return a HTML select list of a dictionary + * + * @param string $htmlname Name of select zone + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function selectTypeOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='') + { + global $langs, $conf, $user; + + $langs->load("admin"); + + $sql = "SELECT rowid, code, label, entity"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; + $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; + $sql.= " ORDER BY label"; + + dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + if ($num) + { + print '"; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + } + else + { + print $langs->trans("NoTypeOfPagePleaseEditDictionary"); + } + } + else { + dol_print_error($this->db); + } + } + + + /** + * Return a HTML select list of a dictionary + * + * @param string $htmlname Name of select zone + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='') + { + global $langs, $conf, $user; + + $langs->load("admin"); + + $arrayofsamples=array('corporatehome'=>'CorporateHomePage', 'empty'=>'EmptyPage'); + + $out = ''; + + $out .= '"; + + return $out; + } + } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 14f017bef55..69fe031459d 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -1027,6 +1027,7 @@ class Translate foreach($this->tab_translate as $code => $label) { $substitutionarray['lang_'.$code] = $label; + $substitutionarray['__('.$code.')__'] = $label; } return $substitutionarray; diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index 20a713ce220..ae7d839919c 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -216,6 +216,21 @@ function updateTotal(days,mode) if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+days).addClass("bold"); else jQuery('.totalDay'+days).removeClass("bold"); jQuery('.totalDay'+days).text(pad(total.getHours())+':'+pad(total.getMinutes())); + + var total = new Date(0); + total.setHours(0); + total.setMinutes(0); + for (var i=0; i<7; i++) + { + var taskTime= new Date(0); + result=parseTime(jQuery('.totalDay'+i).text(),taskTime); + if (result >= 0) + { + total.setHours(total.getHours()+taskTime.getHours()); + total.setMinutes(total.getMinutes()+taskTime.getMinutes()); + } + } + jQuery('.totalDayAll').text(pad(total.getHours())+':'+pad(total.getMinutes())); } else { @@ -260,7 +275,6 @@ function updateTotal(days,mode) else jQuery('.totalDay'+days).removeClass("bold"); jQuery('.totalDay'+days).text(total); } - } \ No newline at end of file diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 65cc2965bea..fcc3098c730 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -870,7 +870,7 @@ function activateModule($value,$withdeps=1) // Test if Dolibarr version ok $verdol=versiondolibarrarray(); $vermin=isset($objMod->need_dolibarr_version)?$objMod->need_dolibarr_version:0; - //print 'eee '.versioncompare($verdol,$vermin).' - '.join(',',$verdol).' - '.join(',',$vermin);exit; + //print 'version: '.versioncompare($verdol,$vermin).' - '.join(',',$verdol).' - '.join(',',$vermin);exit; if (is_array($vermin) && versioncompare($verdol, $vermin) < 0) { $ret['errors'][] = $langs->trans("ErrorModuleRequireDolibarrVersion", versiontostring($vermin)); return $ret; @@ -1290,8 +1290,6 @@ function complete_elementList_with_modules(&$elementList) $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories - else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; if (! empty($objMod->module_parts['contactelement'])) { @@ -1500,7 +1498,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; - //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); + //var_dump($modulename.' - '.$langs->trans('Module'.$module->numero.'Name')); if ($i > 0) $text.=', '; else $text.=' '; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 85d80f646d0..529f58dbbf1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -950,7 +950,7 @@ function dolCheckVirus($src_file) * Note: * - This function can be used only into a HTML page context. Use dol_move if you are outside. * - Test on antivirus is always done (if antivirus set). - * - Database of files is NOT updated. + * - Database of files is NOT updated (this is done by dol_add_file_process() that calls this function). * * @param string $src_file Source full path filename ($_FILES['field']['tmp_name']) * @param string $dest_file Target full path filename ($_FILES['field']['name']) @@ -1554,28 +1554,10 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio // Update table of files if ($donotupdatesession) { - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); - - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', 0); + if ($result < 0) { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // MD5 of file content - $ecmfile->fullpath_orig = $TFile['name'][$i]; - $ecmfile->gen_or_uploaded = 'uploaded'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->create($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } + setEventMessages('FailedToAddFileIntoDatabaseIndex', '', 'warnings'); } } @@ -1679,6 +1661,114 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= } } + +/** + * Add a file into database index. + * Called by dol_add_file_process when uploading a file and on other cases. + * See also commonGenerateDocument that also add/update database index when a file is generated. + * + * @param string $dir Directory name (full real path without ending /) + * @param string $file File name + * @param string $fullpathorig Full path of origin for file (can be '') + * @param string $mode How file was created ('uploaded', 'generated', ...) + * @param int $setsharekey Set also the share key + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ +function addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0) +{ + global $db, $user; + + $result = 0; + + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($file); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($dir.'/'.$file)); // MD5 of file content + $ecmfile->fullpath_orig = $fullpathorig; + $ecmfile->gen_or_uploaded = $mode; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + if ($setsharekey) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + + $result = $ecmfile->create($user); + if ($result < 0) + { + dol_syslog($ecmfile->error); + } + } + + return $result; +} + + +/** + * Delete files into database index using search criterias. + * + * @param string $dir Directory name (full real path without ending /) + * @param string $file File name + * @param string $mode How file was created ('uploaded', 'generated', ...) + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ +function deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded') +{ + global $conf, $db, $user; + + $error = 0; + + if (empty($dir)) + { + dol_syslog("deleteFilesIntoDatabaseIndex: dir parameter can't be empty", LOG_ERR); + return -1; + } + + $db->begin(); + + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + + $filename = basename($file); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + if (! $error) + { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files'; + $sql.= ' WHERE entity = '.$conf->entity; + $sql.= " AND filepath = '" . $db->escape($rel_dir) . "'"; + if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'"; + if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; + + $resql = $db->query($sql); + if (!$resql) + { + $error++; + dol_syslog(__METHOD__ . ' ' . $db->lasterror(), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $db->rollback(); + return - 1 * $error; + } else { + $db->commit(); + return 1; + } +} + + /** * Convert an image file into another format. * This need Imagick php extension. diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0cc2fb0446f..72ff4343d38 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1999,7 +1999,7 @@ function dol_now($mode='gmt') }*/ else if ($mode == 'tzuser') // Time for now with user timezone added { - //print 'eeee'.time().'-'.mktime().'-'.gmmktime(); + //print 'time: '.time().'-'.mktime().'-'.gmmktime(); $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; $ret=(int) dol_now('gmt')+($offsettz+$offsetdst); @@ -5703,6 +5703,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; + $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; if (is_object($object) && $object->element == 'shipping') { @@ -5766,11 +5767,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); } if (is_object($object->projet) && $object->projet->id > 0) @@ -5806,7 +5811,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $extrafieldstmp = new ExtraFields($db); $extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); - $object->fetch_optionals($object->id, $extralabels); + $object->fetch_optionals(); foreach ($extrafieldstmp->attribute_label as $key => $label) { $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; } @@ -5942,7 +5947,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) if (dol_textishtml($text,1)) $msgishtml = 1; $keyfound = $reg[1]; - $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 31fcc519051..43f5aaaf579 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1003,7 +1003,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $freetextheight=0; if ($line) // Free text { - //$line="eee
\nfdsfsdf
\nghfghg
"; + //$line="sample text
\nfdsfsdf
\nghfghg
"; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dda89a7425d..a367579e1cd 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -70,11 +70,11 @@ function dol_decode($chain) /** * Returns a hash of a string. - * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function. - * If constant MAIN_SECURITY_SALT is defined, we use it as a salt. + * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function (recommanded value is 'password_hash') + * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO then md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @getRandomPassword */ @@ -83,8 +83,10 @@ function dol_hash($chain, $type='0') global $conf; // No need to add salt for password_hash - if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) - return password_hash($chain, PASSWORD_DEFAULT); + if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) + { + return password_hash($chain, PASSWORD_DEFAULT); + } // Salt value if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index dbd3acd794a..b4c542edf9c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -184,12 +184,28 @@ function redirectToContainer($containeralias) unset($tmpwebsitepage); if ($result > 0) { - $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $_SERVER["REQUEST_URI"]); + $currenturi = $_SERVER["REQUEST_URI"]; + if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) + { + if ($regtmp[0] == $containeralias) + { + print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containeralias."' in web site '".$website->ref."'"; + exit; + } + else + { + $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $currenturi); + } + } + else + { + $newurl = $currenturi.'&pageref='.urlencode($containeralias); + } } } else // When page called from virtual host server { - $newurl = '/'.$containeralias; + $newurl = '/'.$containeralias.'.php'; } if ($newurl) @@ -199,7 +215,7 @@ function redirectToContainer($containeralias) } else { - print "Error, page contains a reditect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; + print "Error, page contains a redirect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; exit; } } @@ -273,11 +289,14 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $error=0; + dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); + $alreadygrabbed=array(); if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 + // Search X in "img...src=X" preg_match_all('/]*)>/i', $tmp, $regs); foreach ($regs[0] as $key => $val) @@ -372,16 +391,20 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } $linkwithoutdomain = $regs[2][$key]; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + + $dirforimages = '/'.$objectpage->pageurl; + if ($grabimagesinto == 'root') $dirforimages=''; + + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); @@ -499,7 +522,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9ff01c9f5b5..8178af40c37 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -163,7 +163,7 @@ class doc_generic_order_odt extends ModelePDFCommandes } $texte.='
'; } - + $texte.= ''; $texte.= '
'.$input['label'].' '; $more.=' * Copyright (C) 2010-2012 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2018 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -194,9 +194,12 @@ class FormActions $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; - $buttontoaddnewevent = ''; - $buttontoaddnewevent.= $langs->trans("AddEvent"); - $buttontoaddnewevent.= ''; + if (! empty($conf->agenda->enabled)) + { + $buttontoaddnewevent = ''; + $buttontoaddnewevent.= $langs->trans("AddEvent"); + $buttontoaddnewevent.= ''; + } print ''."\n"; print load_fiche_titre($title, $buttontoaddnewevent, '', 0, 0, '', $morehtmlright); 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 '
'; + print '
'; if (empty($textifempty)) print $langs->trans("NoFileFound"); else print $textifempty; print '
'; + print '
'; print $langs->trans("NoLinkFound"); print '
'; @@ -354,21 +354,22 @@ class doc_generic_order_odt extends ModelePDFCommandes { } - // Make substitutions into odt + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_user=$this->get_substitutionarray_user($user,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in order as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in order as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); + // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -392,30 +393,42 @@ class doc_generic_order_odt extends ModelePDFCommandes // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -468,7 +481,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index d99d43396bc..98b644c8cce 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -290,27 +290,40 @@ class doc_generic_contract_odt extends ModelePDFContract { $socobject=$object->thirdparty; } - // Make substitution - $substitutionarray=array( - '__FROM_NAME__' => $this->emetteur->name, - '__FROM_EMAIL__' => $this->emetteur->email, - '__TOTAL_TTC__' => $object->total_ttc, - '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat - ); - complete_substitutions_array($substitutionarray, $langs, $object); + + $object->fetch_optionals(); + + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object + $array_user=$this->get_substitutionarray_user($user,$outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in contract as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + + $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $tmparray = $substitutionarray; + // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks // Line of free text $newfreetext=''; - $paramfreetext='contract_FREE_TEXT'; + $paramfreetext='CONTRACT_FREE_TEXT'; if (! empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); + $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray); } + // Open and load template require_once ODTPHP_PATH.'odf.php'; try { @@ -344,24 +357,6 @@ class doc_generic_contract_odt extends ModelePDFContract { } - // Make substitutions into odt - $array_contract=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user,$outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in contract as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - - $tmparray = array_merge($array_contract,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); - complete_substitutions_array($tmparray, $outputlangs, $object); - $object->fetch_optionals(); - // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks foreach($tmparray as $key=>$value) { try { @@ -379,33 +374,46 @@ class doc_generic_contract_odt extends ModelePDFContract { } } + // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -456,7 +464,7 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 77a5677c003..9c45c135ac3 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -437,30 +437,42 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -511,7 +523,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 15d48694277..c236c9ad017 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -328,7 +328,15 @@ class pdf_standard extends ModeleExpenseReport $nextColumnPosX = $this->posxprojet; } - $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, dol_trunc($outputlangs->transnoentities($object->lines[$i]->type_fees_code), 10), 0, 'C'); + $expensereporttypecode = $object->lines[$i]->type_fees_code; + $expensereporttypecodetoshow = $outputlangs->transnoentities($expensereporttypecode); + if ($expensereporttypecodetoshow == $expensereporttypecode) + { + $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); + } + $expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); // 10 is too much + + $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); // Project if (! empty($conf->projet->enabled)) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 79b848c5773..6d9d5172a7f 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -361,20 +361,22 @@ class doc_generic_invoice_odt extends ModelePDFFactures { } - // Make substitutions into odt + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_user=$this->get_substitutionarray_user($user,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array(); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in invoice as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in invoice as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); + // Call the ODTSubstitution hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -401,30 +403,42 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -475,7 +489,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index a1674d6ab08..f71b6b925f0 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -127,7 +127,7 @@ class mailing_fraise extends MailingTargets $s.='
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index e0b4927bf19..63059964b74 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -91,15 +91,16 @@ $langs->load("modulebuilder"); else if (type == 'int') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'text') { size.removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'varchar') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } + else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").show();} else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} - else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} - else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();jQuery("#helppassword").hide();} + else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} else { // type = string size.val('').prop('disabled', true); unique.removeAttr('disabled'); @@ -166,7 +167,7 @@ if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_ar } } } -elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') ) +elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password')) { $paramlist=array_keys($param['options']); $param_chain = $paramlist[0]; @@ -210,7 +211,7 @@ else trans("Size"); ?> - + trans("Value"); ?> @@ -224,6 +225,7 @@ else textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"),1,0,'', 0, 2, 'helpvalue5')?> diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 27d57d3e48a..aa392489987 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -201,18 +201,12 @@ if ($permission) { if ($tab[$i]['source']=='internal') { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - $userstatic->photo=$tab[$i]['photo']; - $userstatic->login=$tab[$i]['login']; + $userstatic->fetch($tab[$i]['id']); echo $userstatic->getNomUrl(-1); } if ($tab[$i]['source']=='external') { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; + $contactstatic->fetch($tab[$i]['id']); echo $contactstatic->getNomUrl(1); } ?> @@ -223,16 +217,10 @@ if ($permission) { id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; echo $userstatic->LibStatut($tab[$i]['statuscontact'],3); } if ($tab[$i]['source']=='external') { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; echo $contactstatic->LibStatut($tab[$i]['statuscontact'],3); } ?> diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 9d638426bc3..3559df44c9c 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -107,8 +107,16 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ print ''; // Convert date into timestamp format - if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) { - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options['options_' . $key]); + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) + { + $datenotinstring = $object->array_options['options_' . $key]; + // print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x'; + if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility + { + $datenotinstring = $db->jdate($datenotinstring); + } + //print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); + $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring; } //TODO Improve element and rights detection diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 8e540c799fe..8c97bc4e2c8 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -557,7 +557,7 @@ else dol_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron'); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; $morehtmlref.='
'; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index a63982c5b12..1debc47e776 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -805,6 +805,69 @@ class Cronjob extends CommonObject $this->libname = ''; } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("CronJob") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/cron/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowCronJob"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + return $result; + } + + /** * Load object information * @@ -925,7 +988,8 @@ class Cronjob extends CommonObject $ret=dol_include_once($this->classesname); if ($ret===false || (! class_exists($this->objectname))) { - $this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname); + if ($ret===false) $this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname); + else $this->error=$langs->trans('CronCannotLoadObject',$this->classesname,$this->objectname); dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); $this->lastoutput = $this->error; $this->lastresult = -1; diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index d3365abb90b..18bfde73bde 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -50,7 +50,7 @@ $head = cron_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron'); -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; $morehtmlref.='
'; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 3933a30a54b..ca21a40635a 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -38,6 +38,7 @@ if (!$user->rights->cron->read) accessforbidden(); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cronjoblist'; // To manage different context of search $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -50,9 +51,6 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='t.status'; if (! $sortorder) $sortorder='ASC'; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='cronjoblist'; - $status=GETPOST('status','int'); if ($status == '') $status=-2; @@ -151,6 +149,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex */ $form = new Form($db); +$cronjob = new Cronjob($db); $pagetitle=$langs->trans("CronList"); @@ -280,6 +279,9 @@ if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text.=$langs->trans("Warn print info_admin($text); print '
'; +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''; @@ -340,19 +342,22 @@ if ($num > 0) if (empty($obj)) break; if (! verifCond($obj->test)) continue; // Discard line with test = false + $object->id = $obj->rowid; + $object->ref = $obj->rowid; + $object->label = $obj->label; + print ''; print ''; print ''; print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); @@ -1661,7 +1663,7 @@ else if ($id || $ref) $soc = new Societe($db); $soc->fetch($object->socid); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head=shipping_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, 'sending'); @@ -2451,7 +2453,7 @@ else if ($id || $ref) if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan= empty($conf->productbatch->enabled) ? 5 : 6; $line = new ExpeditionLigne($db); - $line->fetch_optionals($lines[$i]->id,$extralabelslines); + $line->fetch_optionals($lines[$i]->id); print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 85408c7e14a..b8eef6b5102 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -547,12 +547,9 @@ class Expedition extends CommonObject */ $result=$this->fetch_thirdparty(); - // Retrieve all extrafields for expedition + // 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/expedition/shipment.php b/htdocs/expedition/shipment.php index 7b0cca64a30..f16ee1eac48 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -180,9 +180,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -193,7 +195,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('SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -247,7 +249,7 @@ if ($id > 0 || ! empty($ref)) $author = new User($db); $author->fetch($object->user_author_id); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = commande_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), -1, 'order'); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 6d989e6efc0..dd5db880bc9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -286,9 +286,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -299,7 +301,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('FICHINTER_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1434,7 +1436,7 @@ else { $result = $object->fetch($id, $ref); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); if ($result > 0) { @@ -1978,7 +1980,8 @@ else $i = 0;$total = 0; print ''; - print ''; + print ''; + //print ''; print ''; if (! empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; @@ -2001,15 +2004,21 @@ else foreach ($object->lines as &$line) { - $piece_comptable = $i + 1; + $numline = $i + 1; if ($action != 'editline' || $line->rowid != GETPOST('rowid')) { print ''; print ''; + + /*print ''; + print ' '.$piece_comptable.''; + print '';*/ + print ''; if (! empty($conf->projet->enabled)) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b1523f3bbf9..5674192906c 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -341,11 +341,6 @@ class ExpenseReport extends CommonObject $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('EXPENSEREPORT_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index caae068461a..097a912b6c1 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -831,22 +831,18 @@ if ($resql) if (empty($id)) { - 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->expensereport->lire; - $delallowed=$user->rights->expensereport->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->expensereport->lire; + $delallowed=$user->rights->expensereport->creer; + + print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } } else diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 81e7fe9ac54..b2533ba553c 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -470,7 +470,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); + header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1'); exit; } @@ -741,9 +741,11 @@ if (empty($reshook)) 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')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -755,7 +757,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('INTERVENTION_MODIFY'); if ($result < 0) { $error++; @@ -1476,7 +1478,7 @@ else if ($id > 0 || ! empty($ref)) $extrafieldsline = new ExtraFields($db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element); - $line->fetch_optionals($line->rowid, $extralabelslines); + $line->fetch_optionals(); print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5)); @@ -1521,7 +1523,7 @@ else if ($id > 0 || ! empty($ref)) $extrafieldsline = new ExtraFields($db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element); - $line->fetch_optionals($line->rowid, $extralabelslines); + $line->fetch_optionals(); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5)); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6ee279d2015..2cbbd1be022 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -383,14 +383,13 @@ class Fichinter extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - 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(); /* * Lines - */ + */ $result=$this->fetch_lines(); if ($result < 0) { @@ -1107,11 +1106,6 @@ class Fichinter extends CommonObject $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('INTERVENTION_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 49cb1837d35..e046209a354 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -563,25 +563,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->ficheinter->lire; - $delallowed=$user->rights->ficheinter->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->ficheinter->lire; + $delallowed=$user->rights->ficheinter->creer; + print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 1929c11a464..a5d5490e660 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -101,7 +101,7 @@ if (empty($reshook)) $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); if ($result < 0) dol_print_error($db,$object->error); } - + // update supplier order min amount if ($action == 'setsupplier_order_min_amount') { @@ -114,14 +114,16 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($id); + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) $error++; } if ($error) $action = 'edit_extras'; @@ -297,7 +299,7 @@ if ($object->id > 0) print ''; print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 38d0e42d36a..cf007659487 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -218,7 +218,7 @@ class CommandeFournisseur extends CommonOrder // Check parameters if (empty($id) && empty($ref)) return -1; - $sql = "SELECT c.rowid, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; + $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; $sql.= " c.localtax1, c.localtax2, "; $sql.= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,"; $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,"; @@ -253,6 +253,8 @@ class CommandeFournisseur extends CommonOrder } $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; $this->ref_supplier = $obj->ref_supplier; $this->socid = $obj->fk_soc; @@ -310,12 +312,9 @@ class CommandeFournisseur extends CommonOrder $this->db->free($resql); - // Retrieve all extrafields + // 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(); if ($this->statut == 0) $this->brouillon = 1; @@ -1368,11 +1367,6 @@ class CommandeFournisseur 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_SUPPLIER_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); @@ -2968,7 +2962,58 @@ class CommandeFournisseur extends CommonOrder } return 4; } - } + }elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) + {//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) + + $close=0; + + if( count($diff_array) > 0 ) + {//there are some difference between the two arrays + + //scan the array of results + foreach($diff_array as $key => $value) + {//if the quantity delivered is greater or equal to wish quantity + if($qtydelivered[$key] >= $qtywished[$key] ) + { + $close++; + } + + } + } + + + if($close == count($diff_array)) + {//all the products are received equal or more than the wished quantity + if ($closeopenorder) + { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 5; + } + else + { + //Diff => received partially + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + + } + else + {//all the products are not received + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + } else { //Diff => received partially @@ -3112,40 +3157,6 @@ class CommandeFournisseurLigne extends CommonOrderLine } } - /** - * Mise a jour de l'objet ligne de commande en base - * - * @return int <0 si ko, >0 si ok - */ - public function updateTotal() - { - $this->db->begin(); - - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseurdet SET"; - $sql.= " total_ht='".price2num($this->total_ht)."'"; - $sql.= ",total_tva='".price2num($this->total_tva)."'"; - $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'"; - $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'"; - $sql.= ",total_ttc='".price2num($this->total_ttc)."'"; - $sql.= " WHERE rowid = ".$this->rowid; - - dol_syslog(get_class($this)."::updateTotal", LOG_DEBUG); - - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - } - /** * Insert line into database * diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7c0159c814f..c486642d856 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -643,10 +643,7 @@ class FactureFournisseur extends CommonInvoice // 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(); if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 74da470c04c..c8c24afc942 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -64,10 +64,6 @@ class ProductFournisseur extends Product var $fourn_unitprice; var $fourn_tva_tx; var $fourn_tva_npr; - /** - * @deprecated - */ - var $fourn_unitcharges; // old version used a buggy system to calculate margin of a charge field on supplier price. Now margin is on pmp, best supplier price or cost price. var $fk_supplier_price_expression; var $supplier_reputation; // reputation of supplier @@ -215,7 +211,6 @@ class ProductFournisseur extends Product $error=0; $unitBuyPrice = price2num($buyprice/$qty,'MU'); - $unitCharges = price2num($charges/$qty,'MU'); $now=dol_now(); @@ -250,7 +245,6 @@ class ProductFournisseur extends Product $sql.= " remise_percent = ".$remise_percent.","; $sql.= " remise = ".$remise.","; $sql.= " unitprice = ".$unitBuyPrice.","; - $sql.= " unitcharges = ".$unitCharges.","; // deprecated $sql.= " fk_availability = ".$availability.","; $sql.= " entity = ".$conf->entity.","; $sql.= " tva_tx = ".price2num($tva_tx).","; @@ -306,7 +300,7 @@ class ProductFournisseur extends Product if ($resql) { // Add price for this quantity to supplier $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; - $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; + $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; $sql .= " values('" . $this->db->idate($now) . "',"; $sql .= " " . $this->id . ","; $sql .= " " . $fourn->id . ","; @@ -319,7 +313,6 @@ class ProductFournisseur extends Product $sql .= " " . $unitBuyPrice . ","; $sql .= " " . $tva_tx . ","; $sql .= " " . $charges . ","; - $sql .= " " . $unitCharges . ","; $sql .= " " . $availability . ","; $sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; $sql .= " " . $newnpr . ","; @@ -393,7 +386,7 @@ class ProductFournisseur extends Product { global $conf; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,"; - $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price + $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price $sql.= " pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$rowid; @@ -418,7 +411,6 @@ class ProductFournisseur extends Product $this->fourn_remise_percent = $obj->remise_percent; $this->fourn_remise = $obj->remise; $this->fourn_unitprice = $obj->unitprice; - $this->fourn_unitcharges = $obj->unitcharges; // deprecated $this->fourn_tva_tx = $obj->tva_tx; // TODO // $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? @@ -478,7 +470,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; @@ -510,7 +502,6 @@ class ProductFournisseur extends Product $prodfourn->fourn_remise = $record["remise"]; $prodfourn->fourn_unitprice = $record["unitprice"]; $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_unitcharges = $record["unitcharges"]; // deprecated $prodfourn->fourn_tva_tx = $record["tva_tx"]; $prodfourn->fourn_id = $record["fourn_id"]; $prodfourn->fourn_name = $record["supplier_name"]; @@ -588,7 +579,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, "; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; $sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE s.entity IN (".getEntity('societe').")"; @@ -623,7 +614,7 @@ class ProductFournisseur extends Product { $fourn_price = $record["price"]; // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) + $record["unitcharges"] - $record["remise"]; + $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; @@ -657,7 +648,6 @@ class ProductFournisseur extends Product $this->fourn_remise = $record["remise"]; $this->fourn_unitprice = $record["unitprice"]; $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_unitcharges = $record["unitcharges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; $this->fourn_id = $record["fourn_id"]; $this->fourn_name = $record["supplier_name"]; @@ -755,14 +745,14 @@ class ProductFournisseur extends Product $out .= ''; $out .= ''; foreach ($productFournList as $productFourn) { - $out.= ''; + $out.= ''; $out.= ''; $out.= ''; $out.= ''; } $out .= '
'; - print ''; - print img_picto('', 'object_cron').' '; - print $obj->rowid; - print ''; + print $object->getNomUrl(1); print ''; if (! empty($obj->label)) { - print ''.$langs->trans($obj->label).''; + $object->ref = $obj->label; + print $object->getNomUrl(0, '', 1); + $object->ref = $obj->rowid; } else { @@ -430,7 +435,7 @@ if ($num > 0) print ''; if ($user->rights->cron->create) { - print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."&backtourl=".urlencode($_SERVER["PHP_SELF"])."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; + print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."&backtourl=".urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:''))."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; } if ($user->rights->cron->delete) { diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 01164c47508..3d0e9e9623a 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -411,7 +411,7 @@ if (! empty($id) && $action == 'edit') if ($result < 0) { dol_print_error($db,$object->error); exit; } - $result=$object->fetch_optionals($object->id,$extralabels); + $result=$object->fetch_optionals(); if ($result < 0) { dol_print_error($db); exit; } @@ -539,7 +539,7 @@ if (! empty($id) && $action != 'edit') if ($result < 0) { dol_print_error($db,$object->error); exit; } - $result=$object->fetch_optionals($object->id,$extralabels); + $result=$object->fetch_optionals(); if ($result < 0) { dol_print_error($db); exit; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index df298831c22..01ae466f132 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -665,12 +665,9 @@ class Don extends CommonObject $this->modelpdf = $obj->model_pdf; $this->commentaire = $obj->note; // deprecated - // Retrieve 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/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 019a749b6ef..a3669f909e9 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -325,11 +325,12 @@ class EcmDirectory // extends CommonObject /** * Delete object on database and/or on disk * - * @param User $user User that delete - * @param string $mode 'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented) - * @return int <0 if KO, >0 if OK + * @param User $user User that delete + * @param string $mode 'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented) + * @param int $deletedirrecursive 1=Agree to delete content recursiveley (otherwise an error will be returned when trying to delete) + * @return int <0 if KO, >0 if OK */ - function delete($user, $mode='all') + function delete($user, $mode='all', $deletedirrecursive=0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -368,7 +369,14 @@ class EcmDirectory // extends CommonObject if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output . "/" . $relativepath; - $result=@dol_delete_dir($file); + if ($deletedirrecursive) + { + $result=@dol_delete_dir_recursive($file, 0, 0); + } + else + { + $result=@dol_delete_dir($file, 0); + } } if ($result || ! @is_dir(dol_osencode($file))) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index ae16ad85eaf..698960974d5 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -337,12 +337,8 @@ class EcmFiles //extends CommonObject // 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); diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index e313787b01f..14f0ee18e8c 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -156,27 +156,41 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') $backtourl = DOL_URL_ROOT."/ecm/index.php"; if ($module == 'medias') $backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1"; + $deletedirrecursive = (GETPOST('deletedirrecursive','alpha') == 'on' ? 1 : 0); + if ($module == 'ecm') { // Fetch was already done - $result=$ecmdir->delete($user); + $result=$ecmdir->delete($user, 'all', $deletedirrecursive); + if ($result <= 0) + { + $langs->load('errors'); + setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors'); + } } else { - $resbool = dol_delete_dir($upload_dir); + if ($deletedirrecursive) + { + $resbool = dol_delete_dir_recursive($upload_dir, 0, 1); + } + else + { + $resbool = dol_delete_dir($upload_dir, 1); + } if ($resbool) $result = 1; - else $result = 0; + else + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors'); + $result = 0; + } } if ($result > 0) { header("Location: ".$backtourl); exit; } - else - { - $langs->load('errors'); - setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors'); - } } // Update dirname or description @@ -281,6 +295,7 @@ if ($module == 'ecm') llxHeader(); // Built the file List +$filearrayall=dol_dir_list($upload_dir,"all",0,'','',$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); $totalsize=0; foreach($filearray as $key => $file) @@ -469,8 +484,8 @@ if ($action != 'edit' && $action != 'delete') print ''.$langs->trans('ECMAddSection').''; } - if (count($filearray) == 0) - { + //if (count($filearrayall) == 0) + //{ if ($permtoadd) { print ''.$langs->trans('Delete').''; @@ -479,11 +494,14 @@ if ($action != 'edit' && $action != 'delete') { print ''.$langs->trans('Delete').''; } - } + /*} else { - print ''.$langs->trans('Delete').''; - } + if (count($filearray) > 0) + print ''.$langs->trans('Delete').''; + else + print ''.$langs->trans('Delete').''; + }*/ print ''; } @@ -497,7 +515,17 @@ if ($action == 'delete') if ($action == 'delete_dir') { $relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath); - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1); + + //Form to close proposal (signed or not) + if (count($filearrayall) > 0) + { + $langs->load("other"); + $formquestion = array( + array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
'.$langs->trans("DeleteAlsoContentRecursively"),'value' => '0') // Field to complete private note (not replace) + ); + } + + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 9f48d27ca00..27b70e1b8cf 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -155,9 +155,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) @@ -168,7 +170,7 @@ if (empty($reshook)) $parameters = array('id' => $object->id); $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('SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1068,7 +1070,7 @@ if ($action == 'create') // copy from order $orderExtrafields = new Extrafields($db); $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); - if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + if ($object->fetch_optionals() > 0) { $expe->array_options = array_merge($expe->array_options, $object->array_options); } print $object->showOptionals($extrafields, 'edit'); @@ -1605,9 +1607,9 @@ if ($action == 'create') $orderLineExtrafields = new Extrafields($db); $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); $srcLine = new OrderLine($db); - $srcLine->fetch_optionals($line->id,$orderLineExtrafieldLabels); // fetch extrafields also available in orderline + $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline $line = new ExpeditionLigne($db); - $line->fetch_optionals($object->id,$extralabelslines); + $line->fetch_optionals($line->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); print '
'.$langs->trans('Piece').''.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('CarCategory').'
'; + print $numline; + print ''; print img_picto($langs->trans("Document"), "object_generic"); - print ' '.$piece_comptable.''.dol_print_date($db->jdate($line->date), 'day').''; $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); - + print '
'.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; } else { - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } return $out; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 88d654a8924..0026bfe8fe7 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -850,7 +850,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result > 0) { - header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php'); + header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'); exit; } else @@ -945,9 +945,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -963,7 +965,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields(); + $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); if ($result < 0) { @@ -1665,7 +1667,7 @@ elseif (! empty($object->id)) $author = new User($db); $author->fetch($object->user_author_id); - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); $head = ordersupplier_prepare_head($object); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 0b45f2d63a0..760c80737f4 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -914,7 +914,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'],$_SERVER["PHP_SELF"],"cf.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -1176,26 +1176,20 @@ if ($resql) print '
'; 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); - - $filedir=$diroutputmassaction; - $genallowed=$user->rights->fournisseur->commande->lire; - $delallowed=$user->rights->fournisseur->commande->creer; - - print $formfile->showdocuments('massfilesarea_supplier_order','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } - $db->free($resql); + + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->fournisseur->commande->lire; + $delallowed=$user->rights->fournisseur->commande->creer; + + print $formfile->showdocuments('massfilesarea_supplier_order','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b1efc5cbfa5..9f2610d093b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -225,7 +225,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result > 0) { - header('Location: list.php'); + header('Location: list.php?restore_lastsearch_values=1'); exit; } else @@ -1450,9 +1450,11 @@ if (empty($reshook)) } if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (!$error) @@ -1469,7 +1471,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields(); + $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); if ($result < 0) { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 75dee1422d2..3a1f3c7e725 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -796,7 +796,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -1141,22 +1141,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/holiday/card.php b/htdocs/holiday/card.php index e626f950a2b..59cb522d7d5 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -282,8 +282,8 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); - // If this is a rough draft - if ($object->statut == 1 || $object->statut == 3) + // If this is a rough draft, approved, canceled or refused + if ($object->statut == 1 || $object->statut == 4 || $object->statut == 5) { // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer if ($canedit) @@ -299,7 +299,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- if (! $error) { $db->commit(); - header('Location: list.php'); + header('Location: list.php?restore_lastsearch_values=1'); exit; } else @@ -1255,7 +1255,7 @@ else { print ''.$langs->trans("Validate").''; } - if ($user->rights->holiday->delete && $object->statut == 1) // If draft + if ($user->rights->holiday->delete && ($object->statut == 1 || $object->statut == 4 || $object->statut == 5)) // If draft or canceled or refused { print ''.$langs->trans("DeleteCP").''; } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index b4440700be7..e4421505b00 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -118,7 +118,7 @@ if (empty($reshook)) $userValue = $_POST['nb_holiday_'.$val['rowid']]; $userValue = $userValue[$userID]; - if (!empty($userValue)) + if (!empty($userValue) || (string) $userValue == '0') { $userValue = price2num($userValue,5); } else { @@ -128,7 +128,7 @@ if (empty($reshook)) //If the user set a comment, we add it to the log comment $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : ''); - //print 'eee'.$val['rowid'].'-'.$userValue; + //print 'holiday: '.$val['rowid'].'-'.$userValue; if ($userValue != '') { // We add the modification to the log (must be before update of sold because we read current value of sold) @@ -174,11 +174,14 @@ $userstatic=new User($db); llxHeader('', $langs->trans('CPTitreMenu')); +$typeleaves=$holiday->getTypes(1,1); + + print '
'; if ($optioncss != '') print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -223,10 +226,8 @@ if (is_numeric($listUsers) && $listUsers < 0) setEventMessages($holiday->error, $holiday->errors, 'errors'); } -$var=true; $i = 0; -$typeleaves=$holiday->getTypes(1,1); if (count($typeleaves) == 0) { @@ -240,8 +241,6 @@ else $canedit=0; if (! empty($user->rights->holiday->define_holiday)) $canedit=1; - print ''; - $moreforfilter=''; print '
'; diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 3a08ae197a2..6180393e1df 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -93,7 +93,7 @@ else if ($action == 'add') $object->fk_user_author = $user->id; $object->datec = dol_now(); - + $id = $object->create($user); @@ -123,7 +123,7 @@ else if ($action == 'add') else if ($action == 'update') { $error = 0; - + if (! $cancel) { $name = GETPOST('name', 'alpha'); @@ -132,7 +132,7 @@ else if ($action == 'update') $error ++; } - if (empty($error)) + if (empty($error)) { $object->name = GETPOST('name', 'alpha'); $object->address = GETPOST('address', 'alpha'); @@ -141,7 +141,7 @@ else if ($action == 'update') $object->country_id = GETPOST('country_id', 'int'); $object->fk_user_mod = $user->id; $object->status = GETPOST('status','int'); - + $result = $object->update($user); if ($result > 0) @@ -201,18 +201,18 @@ if ($action == 'create') print ''; print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array ( 'town', - 'selectcountry_id' + 'selectcountry_id' ), 6); print ''; print ''; - + // Town print ''; print ''.fieldLabel('Town','town',0).''; print ''; print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( 'zipcode', - 'selectcountry_id' + 'selectcountry_id' )); print ''; print ''; @@ -234,7 +234,7 @@ if ($action == 'create') print ''; print ''; - + dol_fiche_end(); print '
'; @@ -286,12 +286,12 @@ if (($id || $ref) && $action == 'edit') print ''.fieldLabel('Zip','zipcode',0).''; print $formcompany->select_ziptown($object->zip, 'zipcode', array ( 'town', - 'selectcountry_id' + 'selectcountry_id' ), 6) . ''; print ''.fieldLabel('Town','town',0).''; print $formcompany->select_ziptown($object->town, 'town', array ( 'zipcode', - 'selectcountry_id' + 'selectcountry_id' )) . ''; // Country @@ -300,7 +300,7 @@ if (($id || $ref) && $action == 'edit') print $form->select_country($object->fk_country,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; - print ''; + print ''; // Status print ''.fieldLabel('Status','status',1).''; @@ -325,11 +325,11 @@ if (($id || $ref) && $action == 'edit') if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); - + $res = $object->fetch_optionals(); + $head = establishment_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building'); - + // Confirmation to delete if ($action == 'delete') { @@ -337,22 +337,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } - + // Object card // ------------------------------------------------------------ - + $linkback = '' . $langs->trans("BackToList") . ''; - + $morehtmlref='
'; $morehtmlref.='
'; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', $morehtmlref); - - + + print '
'; //print '
'; print '
'; - print ''."\n"; + print '
'."\n"; // Name print ''; @@ -393,9 +393,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; - + print '

'; - + dol_fiche_end(); /* @@ -407,6 +407,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Delete').''; print '
'; } - + llxFooter(); $db->close(); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index b5dbc72fba0..08d3495c33c 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1475,10 +1475,11 @@ if ($step == 5 && $datatoimport) $sourcelinenb=0; $endoffile=0; // Loop on each input file record - while ($sourcelinenb < $nboflines && ! $endoffile) + while (($sourcelinenb < $nboflines) && ! $endoffile) { $sourcelinenb++; // Read line and store it into $arrayrecord + //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb); $arrayrecord=$obj->import_read_record(); if ($arrayrecord === false) { @@ -1487,7 +1488,7 @@ if ($step == 5 && $datatoimport) continue; } if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; // Run import $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); @@ -1857,7 +1858,7 @@ if ($step == 6 && $datatoimport) continue; } if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; // Run import $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); diff --git a/htdocs/install/mysql/data/llx_c_type_container.sql b/htdocs/install/mysql/data/llx_c_type_container.sql new file mode 100644 index 00000000000..1e915412a12 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_type_container.sql @@ -0,0 +1,37 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2003 Jean-Louis Bergamo +-- Copyright (C) 2004-2009 Laurent Destailleur +-- Copyright (C) 2004 Benoit Mortier +-- Copyright (C) 2004 Guillaume Delecourt +-- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2007 Patrick Raguin +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +-- +-- Type of website page/container +-- + +insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); + diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 1e0388cff94..56659ea714c 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -242,7 +242,7 @@ UPDATE llx_bank_account SET accountancy_journal = 'OD' WHERE accountancy_journal ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer; ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); -UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); +UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code AND aj.entity = ba.entity) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 4ffe73ac6ea..190e0dcf05f 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -321,6 +321,8 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik ( active integer DEFAULT 1 )ENGINE=innodb; +ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL; + CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat ( rowid integer AUTO_INCREMENT PRIMARY KEY, label varchar(48) NOT NULL, @@ -684,3 +686,14 @@ ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL; ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); + +create table llx_facture_rec_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + + +ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 4071356c982..e97b0b5851e 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -29,12 +29,28 @@ -- For 8.0 +ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; + ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0; ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit; ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount; + +create table llx_c_type_container +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + label varchar(64) NOT NULL, + module varchar(32) NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); + + ALTER TABLE llx_societe_remise_except ADD COLUMN discount_type integer DEFAULT 0 NOT NULL AFTER fk_soc; ALTER TABLE llx_societe ADD COLUMN remise_supplier real DEFAULT 0 AFTER remise_client; CREATE TABLE llx_societe_remise_supplier @@ -47,5 +63,13 @@ CREATE TABLE llx_societe_remise_supplier fk_user_author integer, -- creation user remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount note text +)ENGINE=innodb; +insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); + + +ALTER TABLE llx_expensereport_det ADD COLUMN docnumber varchar(128) after fk_expensereport; + -)ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_c_type_container.key.sql b/htdocs/install/mysql/tables/llx_c_type_container.key.sql new file mode 100644 index 00000000000..7a81f352f63 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_container.key.sql @@ -0,0 +1,21 @@ +-- ======================================================================== +-- Copyright (C) 2018 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + + +ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); + diff --git a/htdocs/install/mysql/tables/llx_c_type_container.sql b/htdocs/install/mysql/tables/llx_c_type_container.sql new file mode 100644 index 00000000000..33be89a67f4 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_container.sql @@ -0,0 +1,36 @@ +-- ======================================================================== +-- Copyright (C) 2018 Laurent Destailleur +-- +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- Defini les types de contact d'un element sert de reference pour +-- la table llx_element_contact +-- +-- element est le nom de la table utilisant le type de contact. +-- i.e. contact, facture, projet, societe (sans le llx_ devant). +-- Libelle est un texte decrivant le type de contact. +-- active precise si cette valeur est 'active' ou 'archive'. +-- +-- ======================================================================== + +create table llx_c_type_container +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + label varchar(64) NOT NULL, + module varchar(32) NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 5cc7b1b86f5..fc0bd6e697f 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -20,9 +20,10 @@ CREATE TABLE llx_expensereport_det ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_expensereport integer NOT NULL, - fk_c_type_fees integer NOT NULL, + docnumber varchar(128), -- To store a ref of a accounting doc (piece) + fk_c_type_fees integer NOT NULL, -- Type of expense fk_c_exp_tax_cat integer, - fk_projet integer, + fk_projet integer, -- Id of project comments text NOT NULL, product_type integer DEFAULT -1, qty real NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 1c86bfe04f8..14664225a9d 100755 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -29,13 +29,12 @@ create table llx_product_fournisseur_price fk_soc integer, ref_fourn varchar(30), fk_availability integer, - price double(24,8) DEFAULT 0, + price double(24,8) DEFAULT 0, -- price without tax for quantity quantity double, remise_percent double NOT NULL DEFAULT 0, remise double NOT NULL DEFAULT 0, - unitprice double(24,8) DEFAULT 0, + unitprice double(24,8) DEFAULT 0, -- unit price without tax charges double(24,8) DEFAULT 0, -- to store transport cost. Constant PRODUCT_CHARGES must be set to see it. - unitcharges double(24,8) DEFAULT 0, -- deprecated default_vat_code varchar(10), tva_tx double(6,3) NOT NULL, localtax1_tx double(6,3) DEFAULT 0, diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 6b662e4306d..838ef34afa3 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -491,7 +491,7 @@ if (! $error && $db->connected && $action == "set") 'thirdparties' => 'thirdparty', 'usergroups' => 'usergroups', 'users' => 'user', - 'usergroups' => 'usergroups', + 'usergroups' => 'usergroups', ); foreach($docs as $cursordir => $cursorfile) { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d20357dd20c..560bf3d2593 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3977,7 +3977,7 @@ function migrate_reset_blocked_log($db,$langs,$conf) } else { - print ' - '.$langs->trans('AlreadyInV7'); + print ' - '.$langs->trans('AlreadyInV7').'
'; } } else diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 537da9bdb0b..d6bf4d01fe9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -411,6 +411,7 @@ ExtrafieldCheckBoxFromList=Checkboxes from table ExtrafieldLink=Link to an object ComputedFormula=Computed field ComputedFormulaDesc=You can enter here a formula using other properties of object or any PHP coding to get a dynamic computed value. You can use any PHP compatible formulas including the "?" condition operator, and following global object: $db, $conf, $langs, $mysoc, $user, $object.
WARNING: Only some properties of $object may be available. If you need a properties not loaded, just fetch yourself the object into your formula like in the second example.
Using a computed field means you can't enter yourself any value from interface. Also, if there is a syntax error, the formula may return nothing.

Example of formula:
$object->id < 10 ? round($object->id / 2, 2) : ($object->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)

Example to reload object
(($reloadedobj = new Societe($db)) && ($reloadedobj->fetch($obj->id ? $obj->id : ($obj->rowid ? $obj->rowid : $object->id)) > 0)) ? $reloadedobj->array_options['options_extrafieldkey'] * $reloadedobj->capital / 5 : '-1'

Other example of formula to force load of object and its parent object:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetch($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetch($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : 'Parent project not found' +ExtrafieldParamHelpPassword=Keep this field empty means value will be stored without encryption (field must be only hidden with star on screen).
Set here value 'auto' to use the default encryption rule to save password into database (then value read will be the hash only, no way to retreive original value) ExtrafieldParamHelpselect=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
code3,value3
...

In order to have the list depending on another complementary attribute list :
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

In order to have the list depending on another list :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... @@ -885,6 +886,7 @@ DictionaryRevenueStamp=Amount of revenue stamps DictionaryPaymentConditions=Payment terms DictionaryPaymentModes=Payment modes DictionaryTypeContact=Contact/Address types +DictionaryTypeOfContainer=Type of website pages/containers DictionaryEcotaxe=Ecotax (WEEE) DictionaryPaperFormat=Paper formats DictionaryFormatCards=Cards formats @@ -1765,6 +1767,8 @@ MAIN_PDF_MARGIN_LEFT=Left margin on PDF MAIN_PDF_MARGIN_RIGHT=Right margin on PDF MAIN_PDF_MARGIN_TOP=Top margin on PDF MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF +SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups +EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 7f3385bef12..8947fcc47ac 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -74,7 +74,8 @@ CronFrom=From CronType=Job type CronType_method=Call method of a PHP Class CronType_command=Shell command -CronCannotLoadClass=Cannot load class %s or object %s +CronCannotLoadClass=Cannot load class file %s (to use class %s) +CronCannotLoadObject=Class file %s was loaded, but object %s was not found into it UseMenuModuleToolsToAddCronJobs=Go into menu "Home - Admin tools - Scheduled jobs" to see and edit scheduled jobs. JobDisabled=Job disabled MakeLocalDatabaseDumpShort=Local database backup diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index fe5600004ed..588044f18df 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -39,6 +39,7 @@ ShowECMSection=Show directory DeleteSection=Remove directory ConfirmDeleteSection=Can you confirm you want to delete the directory %s? ECMDirectoryForFiles=Relative directory for files +CannotRemoveDirectoryContainsFilesOrDirs=Removed not possible because it contains some files or sub-directories CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files ECMFileManager=File manager ECMSelectASection=Select a directory in the tree... diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index f87a30ecfb2..86460452286 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -207,6 +207,7 @@ ErrorDiscountLargerThanRemainToPaySplitItBefore=The discount you try to apply is ErrorFileNotFoundWithSharedLink=File was not found. May be the share key was modified or file was removed recently. ErrorProductBarCodeAlreadyExists=The product barcode %s already exists on another product reference. ErrorNoteAlsoThatSubProductCantBeFollowedByLot=Note also that using virtual product to have auto increase/decrease of subproducts is not possible when at least one subproduct (or subproduct of subproducts) needs a serial/lot number. +ErrorDescRequiredForFreeProductLines=Description is mandatory for lines with free product # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index cde8a485e59..0fd9fe52b3e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -334,6 +334,7 @@ PriceUHTCurrency=U.P (currency) PriceUTTC=U.P. (inc. tax) Amount=Amount AmountInvoice=Invoice amount +AmountInvoiced=Amount invoiced AmountPayment=Payment amount AmountHTShort=Amount (net) AmountTTCShort=Amount (inc. tax) @@ -854,6 +855,7 @@ FileNotShared=File not shared to exernal public Project=Project Projects=Projects Rights=Permissions +LineNb=Line nb # Week day Monday=Monday Tuesday=Tuesday diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 1585504479e..c4cb693716d 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -22,6 +22,8 @@ JumpToLogin=Disconnected. Go to login page... MessageForm=Message on online payment form MessageOK=Message on validated payment return page MessageKO=Message on canceled payment return page +ContentOfDirectoryIsNotEmpty=Content of this directory is not empty. +DeleteAlsoContentRecursively=Check to delete all content recursiveley YearOfInvoice=Year of invoice date PreviousYearOfInvoice=Previous year of invoice date diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ab044618556..5f71b230537 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -55,6 +55,7 @@ TasksOnOpenedProject=Tasks on open projects WorkloadNotDefined=Workload not defined NewTimeSpent=Time spent MyTimeSpent=My time spent +BillTime=Bill the time spent Tasks=Tasks Task=Task TaskDateStart=Task start date @@ -91,6 +92,7 @@ ListDonationsAssociatedProject=List of donations associated with the project ListVariousPaymentsAssociatedProject=List of miscellaneous payments associated with the project ListActionsAssociatedProject=List of events associated with the project ListTaskTimeUserProject=List of time consumed on tasks of project +ListTaskTimeForTask=List of time consumed on task ActivityOnProjectToday=Activity on project today ActivityOnProjectYesterday=Activity on project yesterday ActivityOnProjectThisWeek=Activity on project this week diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index df799470b6d..a4c7d9e0211 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -4,6 +4,7 @@ WebsiteSetupDesc=Create here as much entry as number of different websites you n DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. WEBSITE_TYPE_CONTAINER=Type of page/container +WEBSITE_PAGE_EXAMPLE=Web page to use as example WEBSITE_PAGENAME=Page name/alias WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS file content (common to all pages) @@ -34,9 +35,12 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on %s
then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server. -PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s -PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. +SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on
%s
then enter here the virtual hostname you have created, so the preview can be done also using this dedicated web server access instead of only using Dolibarr server. +CheckVirtualHostPerms=Check also that virtual host has %s on files into
%s +ReadPerm=Read permission +WritePerm=Write permission +PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s +PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined NoPageYet=No pages yet SyntaxHelp=Help on specific syntax tips @@ -73,4 +77,6 @@ GrabImagesInto=Grab also images found into css and page. ImagesShouldBeSavedInto=Images should be saved into directory WebsiteRootOfImages=Root directory for website images SubdirOfPage=Sub-directory dedicated to page -AliasPageAlreadyExists=Alias page %s already exists \ No newline at end of file +AliasPageAlreadyExists=Alias page %s already exists +CorporateHomePage=Corporate Home page +EmptyPage=Empty page \ No newline at end of file diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index b0de98ae2eb..0e61adcb279 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -165,7 +165,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expeditio { $db->commit(); if (! empty($backtopage)) header("Location: ".$backtopage); - else header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); + else header("Location: ".DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'); exit; } else @@ -193,9 +193,11 @@ elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) // Update extrafields 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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -206,7 +208,7 @@ if ($action == 'update_extras') $parameters = array('id' => $object->id); $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('DELIVERY_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -571,7 +573,7 @@ else // copy from expedition $expeditionExtrafields = new Extrafields($db); $expeditionExtrafieldLabels = $expeditionExtrafields->fetch_name_optionals_label($expedition->table_element); - if ($expedition->fetch_optionals($object->origin_id, $expeditionExtrafieldLabels) > 0) { + if ($expedition->fetch_optionals($object->origin_id) > 0) { $object->array_options = array_merge($object->array_options, $expedition->array_options); } } @@ -674,12 +676,12 @@ else $colspan=2; $mode = ($object->statut == 0) ? 'edit' : 'view'; $line = new LivraisonLigne($db); - $line->fetch_optionals($object->lines[$i]->id,$extralabelslines); + $line->fetch_optionals($object->lines[$i]->id); if ($action = 'create_delivery') { $srcLine = new ExpeditionLigne($db); $expeditionLineExtrafields = new Extrafields($db); $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); - $srcLine->fetch_optionals($expedition->lines[$i]->id,$expeditionLineExtrafieldLabels); + $srcLine->fetch_optionals($expedition->lines[$i]->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); } print ''; diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 837b0af77f5..d0d24d39144 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -301,13 +301,9 @@ class Livraison extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - - // Retrieve all extrafields for delivery + // 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(); /* * Lignes diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index b6584f8d909..c34574791c1 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -42,14 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once '../lib/mymodule.lib.php'; // Translations -$langs->load("errors"); -$langs->load("admin"); -$langs->load("mymodule@mymodule"); +$langs->loadLangs(array("errors","admin","mymodule@mymodule")); // Access control -if (! $user->admin) { - accessforbidden(); -} +if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); @@ -73,7 +69,7 @@ $page_name = "MyModuleAbout"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 19908d33546..58a572a42ac 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -71,7 +71,7 @@ $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index b0265a28e3f..e11925f075f 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -175,7 +175,7 @@ class ActionsMyModule */ function beforePDFCreation($parameters, &$object, &$action) { - global $langs,$conf; + global $conf, $user, $langs; global $hookmanager; $outputlangs=$langs; @@ -204,7 +204,7 @@ class ActionsMyModule */ function afterPDFCreation($parameters, &$pdfhandler, &$action) { - global $langs,$conf; + global $conf, $user, $langs; global $hookmanager; $outputlangs=$langs; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 1d8ba3dace6..eea2a85e656 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -53,7 +53,7 @@ class modMyModule extends DolibarrModules // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'mymodule'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page $this->family = "other"; // Module position in the family on 2 digits ('01', '10', '20', ...) diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index e413c969119..f9984e8fb40 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -151,13 +151,13 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers case 'STOCK_MOVEMENT': //MYECMDIR - case 'MYECMDIR_DELETE': case 'MYECMDIR_CREATE': case 'MYECMDIR_MODIFY': + case 'MYECMDIR_DELETE': // Customer orders case 'ORDER_CREATE': - case 'ORDER_CLONE': + case 'ORDER_MODIFY': case 'ORDER_VALIDATE': case 'ORDER_DELETE': case 'ORDER_CANCEL': @@ -170,7 +170,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Supplier orders case 'ORDER_SUPPLIER_CREATE': - case 'ORDER_SUPPLIER_CLONE': + case 'ORDER_SUPPLIER_MODIFY': case 'ORDER_SUPPLIER_VALIDATE': case 'ORDER_SUPPLIER_DELETE': case 'ORDER_SUPPLIER_APPROVE': @@ -184,7 +184,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Proposals case 'PROPAL_CREATE': - case 'PROPAL_CLONE': case 'PROPAL_MODIFY': case 'PROPAL_VALIDATE': case 'PROPAL_SENTBYMAIL': @@ -197,7 +196,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // SupplierProposal case 'SUPPLIER_PROPOSAL_CREATE': - case 'SUPPLIER_PROPOSAL_CLONE': case 'SUPPLIER_PROPOSAL_MODIFY': case 'SUPPLIER_PROPOSAL_VALIDATE': case 'SUPPLIER_PROPOSAL_SENTBYMAIL': @@ -210,8 +208,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Contracts case 'CONTRACT_CREATE': - case 'CONTRACT_ACTIVATE': case 'CONTRACT_MODIFY': + case 'CONTRACT_ACTIVATE': case 'CONTRACT_CANCEL': case 'CONTRACT_CLOSE': case 'CONTRACT_DELETE': @@ -221,7 +219,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Bills case 'BILL_CREATE': - case 'BILL_CLONE': case 'BILL_MODIFY': case 'BILL_VALIDATE': case 'BILL_UNVALIDATE': diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index bc1e9fc7d51..a82ec237006 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -228,7 +228,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = myobjectPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule'); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 23a748a12dc..2ef8fa97030 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -422,7 +422,7 @@ foreach($object->fields as $key => $val) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; @@ -542,25 +542,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); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 06cfc0e0eac..a51d19f5b97 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -129,7 +129,7 @@ if ($action == 'other') } - $value = GETPOST('activate_sousproduits','alpha'); + $value = GETPOST('PRODUIT_SOUSPRODUITS','alpha'); $res = dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $value,'chaine',0,'',$conf->entity); $value = GETPOST('activate_viewProdDescInForm','alpha'); @@ -580,7 +580,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''.$langs->trans("AssociatedProductsAbility").''; print ''; -print $form->selectyesno("activate_sousproduits",$conf->global->PRODUIT_SOUSPRODUITS,1); +print $form->selectyesno("PRODUIT_SOUSPRODUITS",$conf->global->PRODUIT_SOUSPRODUITS,1); print ''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 73d867e7141..c1f218f15f8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1951,13 +1951,9 @@ class Product extends CommonObject $this->db->free($resql); - - // Retreive all extrafield for current object + // 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(); // multilangs if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); @@ -3396,7 +3392,7 @@ class Product extends CommonObject * @param int $id Id of product to search childs of * @param int $firstlevelonly Return only direct child * @param int $level Level of recursing call (start to 1) - * @return array Prod + * @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=> ...) */ function getChildsArbo($id, $firstlevelonly=0, $level=1) { diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index a6cc3427243..79120aa1191 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -370,7 +370,7 @@ if ($id > 0 || ! empty($ref)) } print ''; - $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index c281816e99b..fc986a9e051 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -156,7 +156,7 @@ class PriceParser //Retrieve all extrafield for product and add it to values $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('product', true); - $product->fetch_optionals($product->id, $extralabels); + $product->fetch_optionals(); foreach ($extrafields->attribute_label as $key=>$label) { $values["extrafield_".$key] = $product->array_options['options_'.$key]; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 5219291e8af..4f266611940 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -638,11 +638,6 @@ if ($id > 0 || $ref) print_liste_field_titre("DiscountQtyMin",$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("NbDaysToDelivery",$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("ReputationForThisProduct",$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); - // Charges ???? - if ($conf->global->PRODUCT_CHARGES) - { - if (! empty($conf->margin->enabled)) print_liste_field_titre("UnitCharges"); - } print_liste_field_titre(''); print "\n"; @@ -708,18 +703,6 @@ if ($id > 0 || $ref) } print''; - // Charges ???? - /* - if ($conf->global->PRODUCT_CHARGES) - { - if (! empty($conf->margin->enabled)) - { - print ''; - print $productfourn->fourn_unitcharges?price($productfourn->fourn_unitcharges) : ($productfourn->fourn_qty?price($productfourn->fourn_charges/$productfourn->fourn_qty):" "); - print ''; - } - }*/ - if (is_object($hookmanager)) { $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index e393721c47d..84db46c879f 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -194,7 +194,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); dol_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'inventory'); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index cb67168b214..f9fef88edce 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -494,25 +494,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); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ebb2c0a421a..662c15507f0 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -654,7 +654,7 @@ else // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -793,7 +793,7 @@ else if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 8ab36de3428..61bd5c3d47f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -117,7 +117,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/list.php'); + header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?resotre_lastsearch_values=1'); exit; } else diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 69be51f11e8..ab2b60f564a 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -576,12 +576,9 @@ class MouvementStock extends CommonObject $this->sellby = $this->db->jdate($obj->sellby); } - // 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->fetch_lines(); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index d7915512b2c..31c28eaa5b3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -233,12 +233,9 @@ class Productlot extends CommonObject $this->fk_user_modif = $obj->fk_user_modif; $this->import_key = $obj->import_key; - // 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($resql); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 048be66461f..cbca4e5854d 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -51,7 +51,7 @@ class ProductStockEntrepot extends CommonObject /** */ - + public $tms = ''; public $fk_product; public $fk_entrepot; @@ -61,7 +61,7 @@ class ProductStockEntrepot extends CommonObject /** */ - + /** * Constructor @@ -88,7 +88,7 @@ class ProductStockEntrepot extends CommonObject $error = 0; // Clean parameters - + if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); @@ -100,23 +100,23 @@ class ProductStockEntrepot extends CommonObject // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - + $sql.= 'fk_product,'; $sql.= 'fk_entrepot,'; $sql.= 'seuil_stock_alerte,'; $sql.= 'desiredstock,'; $sql.= 'import_key'; - + $sql .= ') VALUES ('; - + $sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).','; $sql .= ' '.(! isset($this->fk_entrepot)?'NULL':$this->fk_entrepot).','; $sql .= ' '.(! isset($this->seuil_stock_alerte)?'0':$this->seuil_stock_alerte).','; $sql .= ' '.(! isset($this->desiredstock)?'0':$this->desiredstock).','; $sql .= ' '.(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'"); - + $sql .= ')'; $this->db->begin(); @@ -166,12 +166,12 @@ class ProductStockEntrepot extends CommonObject public function fetch($id, $fk_product, $fk_entrepot) { if(empty($id) && (empty($fk_product) || empty($fk_entrepot))) return -1; - + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; - + $sql .= " t.tms,"; $sql .= " t.fk_product,"; $sql .= " t.fk_entrepot,"; @@ -179,11 +179,11 @@ class ProductStockEntrepot extends CommonObject $sql .= " t.desiredstock,"; $sql .= " t.import_key"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if(!empty($id)) $sql .= ' WHERE t.rowid = ' . $id; else $sql.= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; - + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); @@ -191,7 +191,7 @@ class ProductStockEntrepot extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->tms = $this->db->jdate($obj->tms); $this->fk_product = $obj->fk_product; $this->fk_entrepot = $obj->fk_entrepot; @@ -199,18 +199,15 @@ class ProductStockEntrepot extends CommonObject $this->desiredstock = $obj->desiredstock; $this->import_key = $obj->import_key; - + } - - // 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->fetch_lines(); - + $this->db->free($resql); if ($numrows) { @@ -246,7 +243,7 @@ class ProductStockEntrepot extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; - + $sql .= " t.tms,"; $sql .= " t.fk_product,"; $sql .= " t.fk_entrepot,"; @@ -254,11 +251,11 @@ class ProductStockEntrepot extends CommonObject $sql .= " t.desiredstock,"; $sql .= " t.import_key"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; - + $sql .= ' WHERE 1=1'; - + // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -267,19 +264,19 @@ class ProductStockEntrepot extends CommonObject } } if (count($sqlwhere) > 0) $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); - + if(!empty($fk_product)) $sql .= ' AND fk_product = '.$fk_product; elseif(!empty($fk_entrepot)) $sql .= ' AND fk_entrepot = '.$fk_entrepot; // "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch - + if (!empty($sortfield)) $sql .= $this->db->order($sortfield,$sortorder); if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit, $offset); - + $lines = array(); $resql = $this->db->query($sql); if ($resql) { - + while ($obj = $this->db->fetch_object($resql)) { $lines[$obj->rowid] = array( 'id'=>$obj->rowid @@ -315,20 +312,20 @@ class ProductStockEntrepot extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); if (isset($this->desiredstock)) $this->desiredstock = trim($this->desiredstock); if (isset($this->import_key)) $this->import_key = trim($this->import_key); - + // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - + $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_product = '.(isset($this->fk_product)?$this->fk_product:"null").','; $sql .= ' fk_entrepot = '.(isset($this->fk_entrepot)?$this->fk_entrepot:"null").','; @@ -336,7 +333,7 @@ class ProductStockEntrepot extends CommonObject $sql .= ' desiredstock = '.(isset($this->desiredstock)?$this->desiredstock:"null").','; $sql .= ' import_key = '.(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); - + $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -573,7 +570,7 @@ class ProductStockEntrepot extends CommonObject public function initAsSpecimen() { $this->id = 0; - + $this->tms = ''; $this->fk_product = ''; $this->fk_entrepot = ''; @@ -581,7 +578,7 @@ class ProductStockEntrepot extends CommonObject $this->desiredstock = ''; $this->import_key = ''; - + } } diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 3a8f4cbff4e..f269e260b25 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -122,9 +122,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) @@ -135,7 +137,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('PRODUCT_LOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -305,7 +307,7 @@ if ($action == 'create') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); //print load_fiche_titre($langs->trans("Batch")); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 5934e8dff55..76d70c1ad10 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -537,22 +537,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_orders','',$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_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); */ } else diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 85848eefedc..b61c5aff922 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -595,10 +595,15 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); //if ($timeonothertasks) //{ diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index d64a5fad6cd..a52ea4fd6d8 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -531,8 +531,8 @@ $colspan=7; if ($conf->use_javascript_ajax) { - print ' - '; + print ''; + print ''; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; @@ -547,8 +547,8 @@ if ($conf->use_javascript_ajax) print '
 
'; } - print ' - '; + print '
 
'; + print ''; } @@ -625,7 +625,7 @@ if (count($tasksarray) > 0) $cssweekend='weekend'; } - print ''; + print ''; $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) @@ -658,7 +658,7 @@ if (count($tasksarray) > 0) print '
 
'; } - print ' + print '
 
'; } } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index ddfa1733f8c..c5cfb9b3756 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -161,6 +161,7 @@ if (empty($reshook)) $object->statut = $status; $object->opp_status = $opp_status; $object->opp_percent = $opp_percent; + $object->bill_time = (GETPOST('bill_time','alpha')=='on'?1:0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -261,6 +262,7 @@ if (empty($reshook)) if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount','alpha')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; + $object->bill_time = (GETPOST('bill_time','alpha')=='on'?1:0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -407,7 +409,7 @@ if (empty($reshook)) if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: index.php"); + header("Location: list.php?restore_lastsearch_values=1"); exit; } else @@ -599,6 +601,14 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; + // Bill time + if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''.$langs->trans("BillTime").''; + print ''; + print ''; + } + if ($conf->categorie->enabled) { // Categories print ''.$langs->trans("Categories").''; @@ -660,7 +670,7 @@ elseif ($object->id > 0) * Show or edit */ - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); // To verify role of users $userAccess = $object->restrictedProjectArea($user,'read'); @@ -826,6 +836,14 @@ elseif ($object->id > 0) print ''; print ''; + // Bill time + if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''.$langs->trans("BillTime").''; + print 'bill_time) ? ' checked="checked"' : '').'">'; + print ''; + } + // Tags-Categories if ($conf->categorie->enabled) { @@ -948,6 +966,14 @@ elseif ($object->id > 0) print nl2br($object->description); print ''; + // Bill time + if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''.$langs->trans("BillTime").''; + print ''.yn($object->bill_time).''; + print ''; + } + // Categories if($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e24a444702c..ed25f3ba813 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -64,6 +64,7 @@ class Project extends CommonObject var $user_close_id; var $public; //!< Tell if this is a public or private project var $budget_amount; + var $bill_time; // Is the time spent on project must be invoiced or not var $statuts_short; var $statuts_long; @@ -178,6 +179,7 @@ class Project extends CommonObject $sql.= ", datee"; $sql.= ", opp_amount"; $sql.= ", budget_amount"; + $sql.= ", bill_time"; $sql.= ", entity"; $sql.= ") VALUES ("; $sql.= "'" . $this->db->escape($this->ref) . "'"; @@ -297,6 +299,7 @@ class Project extends CommonObject $sql.= ", opp_amount = " . (strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null"); $sql.= ", budget_amount = " . (strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null"); $sql.= ", fk_user_modif = " . $user->id; + $sql.= ", bill_time = " . ($this->bill_time ? 1 : 0); $sql.= " WHERE rowid = " . $this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -394,7 +397,8 @@ class Project extends CommonObject if (empty($id) && empty($ref)) return -1; $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; - $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; + $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut, fk_opp_status, opp_percent,"; + $sql.= " note_private, note_public, model_pdf, bill_time"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; if (! empty($id)) { @@ -441,10 +445,12 @@ class Project extends CommonObject $this->opp_percent = $obj->opp_percent; $this->budget_amount = $obj->budget_amount; $this->modelpdf = $obj->model_pdf; + $this->bill_time = (int) $obj->bill_time; $this->db->free($resql); - // Retreive all extrafield for thirdparty + // Retreive all extrafield + // fetch optionals attributes and labels $this->fetch_optionals(); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) @@ -583,10 +589,10 @@ class Project extends CommonObject $i++; } $this->db->free($result); - - /* Return array */ - return $elements; } + + /* Return array even if empty*/ + return $elements; } else { @@ -1140,10 +1146,10 @@ class Project extends CommonObject * * @param User $user User object * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts - * @param int $list 0=Return array,1=Return string list + * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party - * @param string $filter additionnal filter on project (statut, ref, ...) - * @return array or string Array of projects id, or string with projects id separated with "," + * @param string $filter additionnal filter on project (statut, ref, ...) + * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 */ function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0, $filter='') { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index e694b3c7bfd..eeacf27aaec 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -266,8 +266,9 @@ class Task extends CommonObject $this->task_parent_position = $obj->task_parent_position; } - // Retreive all extrafield data - $this->fetch_optionals(); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); } $this->db->free($resql); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 47de9ce2b19..4a5bcdab70b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -207,7 +207,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); - $res=$object->fetch_optionals($object->id,$extralabels_projet); + $res=$object->fetch_optionals(); // To verify role of users @@ -455,29 +455,25 @@ else if ($id > 0 || ! empty($ref)) } } + print '
'; - /* - * Actions - */ - print '
'; - + // Link to create task if ($user->rights->projet->all->creer || $user->rights->projet->creer) { if ($object->public || $userWrite > 0) { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } - print '
'; print '
'; @@ -492,8 +488,9 @@ else if ($id > 0 || ! empty($ref)) $title=$langs->trans("ListOfTasks"); $linktotasks=''.$langs->trans("GoToListOfTimeConsumed").''; + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks,'title_generic.png'); + print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'title_generic.png'); // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). @@ -578,7 +575,7 @@ else if ($id > 0 || ! empty($ref)) } else { - if ($nboftaskshown < count($tasksarray)) + if ($nboftaskshown < count($tasksarray) && ! GETPOST('search_user_id','int')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 49072299ac4..fb553a1b837 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 479366ab586..85a6461fbfb 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -125,7 +125,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->s if ($object->delete($user) > 0) { - header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject?'&withproject=1':'')); + header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject?'&withproject=1':'')); exit; } else @@ -207,7 +207,7 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ce2e1c32889..912551012b0 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2006-2018 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; $langs->load('projects'); @@ -38,6 +39,7 @@ $projectid=GETPOST('projectid','int'); $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); +$cancel=GETPOST('cancel','alpha'); $withproject=GETPOST('withproject','int'); $project_ref=GETPOST('project_ref','alpha'); @@ -77,11 +79,7 @@ $projectstatic = new Project($db); $extrafields_project = new ExtraFields($db); $extrafields_task = new ExtraFields($db); -if ($projectid > 0 || ! empty($ref)) -{ - // fetch optionals attributes and labels - $extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); -} +$extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); $extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_element); @@ -89,6 +87,8 @@ $extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_e * Actions */ +if (GETPOST('cancel','alpha')) { $action=''; } + $parameters=array('socid'=>$socid, 'projectid'=>$projectid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -137,10 +137,17 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) if (! $error) { - $object->fetch($id, $ref); + if ($id || $ref) + { + $object->fetch($id, $ref); + } + else + { + $object->fetch(GETPOST('taskid','int')); + } $object->fetch_projet(); - if (empty($object->projet->statut)) + if (empty($object->project->statut)) { setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); $error++; @@ -175,7 +182,8 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } else { - $action=''; + if (empty($id)) $action='createtime'; + else $action='createtime'; } } @@ -229,7 +237,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->lire if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) { - $object->fetchTimeSpent($_GET['lineid']); + $object->fetchTimeSpent(GETPOST('lineid','int')); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) $result = $object->delTimeSpent($user); @@ -240,6 +248,10 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->l $error++; $action=''; } + else + { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + } } // Retreive First Task ID of Project if withprojet is on to allow project prev next to work @@ -262,10 +274,9 @@ if (! empty($project_ref) && ! empty($withproject)) // To show all time lines for project $projectidforalltimes=0; -if (GETPOST('projectid')) +if (GETPOST('projectid','none')) { - $projectidforalltimes=GETPOST('projectid','int'); - + $projectidforalltimes=GETPOST('projectid','int'); } @@ -277,6 +288,7 @@ llxHeader("",$langs->trans("Task")); $form = new Form($db); $formother = new FormOther($db); +$formproject = new FormProjets($db); $userstatic = new User($db); if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) @@ -288,13 +300,13 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { $result=$projectstatic->fetch($projectidforalltimes); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); + $res=$projectstatic->fetch_optionals(); } elseif ($object->fetch($id, $ref) >= 0) { $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); + $res=$projectstatic->fetch_optionals(); $object->project = clone $projectstatic; } @@ -397,37 +409,27 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); + print '
'; - /* - * Actions - */ - - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) - { - print '
'; - + // Link to create time + //if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) + //{ if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - if ($object->public || $userWrite > 0) + if ($projectstatic->public || $userWrite > 0) { - print ''.$langs->trans('AddTask').''; + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetime = ''.$langs->trans('AddTime').''; } } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetime = ''.$langs->trans('AddTime').''; } - - print '
'; - } - else - { - print '
'; - } + //} } } @@ -438,7 +440,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($action == 'deleteline') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid",'int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); } $param=($withproject?'&withproject=1':''); @@ -526,14 +528,20 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); + print ''."\n"; + + $title=$langs->trans("ListTaskTimeForTask"); + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); + print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); + /* - * Form to add time spent + * Form to add time spent on task */ - if ($user->rights->projet->lire) - { - print '
'; + if ($action == 'createtime' && $object->id > 0 && $user->rights->projet->lire) + { + print ''."\n"; print ''; print ''; print ''; @@ -591,7 +599,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; - print ''; + print ''; + print '   '; + print ''; print ''; print ''; @@ -604,7 +614,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { if ($action == 'deleteline') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid','int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array @@ -623,6 +633,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayfields['t.note']=array('label'=>$langs->trans("Note"), 'checked'=>1); $arrayfields['t.task_duration']=array('label'=>$langs->trans("Duration"), 'checked'=>1); $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); + $arrayfields['valuebilled'] =array('label'=>$langs->trans("AmountInvoiced"), 'checked'=>1, 'enabled'=>(empty($conf->global->PROJECT_BILL_TIME_SPENT)?0:1)); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -639,8 +650,11 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; $sql .= " pt.ref, pt.label,"; - $sql .= " u.lastname, u.firstname, u.login, u.photo"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " u.lastname, u.firstname, u.login, u.photo,"; + $sql .= " il.fk_facture as invoice_id, il.total_ht"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; @@ -673,10 +687,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($projectidforalltimes)) { - $title=$langs->trans("ListTaskTimeUserProject"); + print ''."\n"; + + $title=$langs->trans("ListTaskTimeUserProject"); $linktotasks=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks,'title_generic.png'); + print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime, 'title_generic.png'); } $i = 0; @@ -694,21 +710,108 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } + /* + * Form to add time spent + */ + if ($action == 'createtime' && empty($id) && $user->rights->projet->lire) + { + print ''."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + + // Date + print ''; + + // Task + print ''; + + // Contributor + print ''; + + // Note + print ''; + + // Duration - Time spent + print ''; + + // Progress declared + print ''; + + print ''; + + print '
'.$langs->trans("Date").''.$langs->trans("Task").''.$langs->trans("By").''.$langs->trans("Note").''.$langs->trans("NewTimeSpent").''.$langs->trans("ProgressDeclared").'
'; + //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); + $newdate=''; + print $form->select_date($newdate, 'time', ($conf->browser->layout == 'phone'?2:1), 1, 2, "timespent_date", 1, 0, 1); + print ''; + $formproject->selectTasks(-1, GETPOST('taskid','int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + print ''; + print img_object('','user','class="hideonsmartphone"'); + $contactsofproject=$projectstatic->getListContactId('internal'); + if (count($contactsofproject)>0) + { + if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; + else $userid=$contactsofproject[0]; + if ($projectstatic->public) $contactsofproject = array(); + print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); + } + else + { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + print ''; + print ''; + print ''; + print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); + print ''; + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); + print ''; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + + $arrayofselected=is_array($toselect)?$toselect:array(); - $params=''; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_note != '') $params.= '&search_note='.urlencode($search_note); - if ($search_duration != '') $params.= '&search_field2='.urlencode($search_duration); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($search_month > 0) $param.= '&search_month='.urlencode($search_month); + if ($search_year > 0) $param.= '&search_year='.urlencode($search_year); + if ($search_user > 0) $param.= '&search_user='.urlencode($search_user); + if ($search_task_ref != '') $param.= '&search_task_ref='.urlencode($search_task_ref); + if ($search_task_label != '') $param.= '&search_task_label='.urlencode($search_task_label); + if ($search_note != '') $param.= '&search_note='.urlencode($search_note); + if ($search_duration != '') $param.= '&search_field2='.urlencode($search_duration); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); /* // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - if ($id) $params.='&id='.$id; - if ($projectid) $params.='&projectid='.$projectid; - if ($withproject) $params.='&withproject='.$withproject; + if ($id) $param.='&id='.urlencode($id); + if ($projectid) $param.='&projectid='.urlencode($projectid); + if ($withproject) $param.='&withproject='.urlencode($withproject); $arrayofmassactions = array( @@ -776,9 +879,11 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['t.note']['checked'])) print ''; // Duration if (! empty($arrayfields['t.task_duration']['checked'])) print ''; - // Value in currency + // Value in main currency if (! empty($arrayfields['value']['checked'])) print ''; - /* + // Value billed + if (! empty($arrayfields['valuebilled']['checked'])) print ''; + /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; */ @@ -794,16 +899,17 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''."\n"; print ''; - if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { - if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); } - if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$params,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$params,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'],$_SERVER['PHP_SELF'],'il.total_ht','',$param,'align="right"',$sortfield,$sortorder); /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -952,6 +1058,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $totalarray['totalvalue'] += $value; } + // Value billed + if (! empty($arrayfields['valuebilled']['checked'])) + { + print ''; + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; + $totalarray['totalvaluebilled'] += $valuebilled; + } + /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 61685ed8267..61919c54b1a 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -178,8 +178,6 @@ foreach ($modulesdir as $dir) $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories - else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; $j++; $i++; @@ -329,7 +327,7 @@ foreach ($demoprofiles as $profilearray) print '
'; } - print '
'."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -340,7 +338,7 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
'."\n"; + print '
'."\n"; print '
'; diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index 8f28cd12827..f21a4d1a338 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -77,7 +77,7 @@ if ($id > 0) { $res=$object->fetch($id); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); print load_fiche_titre($langs->trans("MemberCard"), '', ''); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index c880f9538c7..7db33a9bfae 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -213,13 +213,9 @@ class Dolresource extends CommonObject $this->note_private = $obj->note_private; $this->type_label = $obj->type_label; - // 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(); } $this->db->free($resql); @@ -570,7 +566,7 @@ class Dolresource extends CommonObject // Retreive all extrafield for thirdparty // fetch optionals attributes and labels - $line->fetch_optionals($line->id,$extralabels); + $line->fetch_optionals(); $this->lines[] = $line; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 94fe7436041..c4a7cd836c5 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -327,14 +327,16 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($socid); + $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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -511,6 +513,8 @@ if (empty($reshook)) { if ($action == 'add') { + $error = 0; + $db->begin(); if (empty($object->client)) $object->code_client=''; @@ -533,11 +537,21 @@ if (empty($reshook)) // Customer categories association $custcats = GETPOST('custcats', 'array'); - $object->setCategories($custcats, 'customer'); + $result = $object->setCategories($custcats, 'customer'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Supplier categories association $suppcats = GETPOST('suppcats', 'array'); - $object->setCategories($suppcats, 'supplier'); + $result = $object->setCategories($suppcats, 'supplier'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Logo/Photo save $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; @@ -566,7 +580,7 @@ if (empty($reshook)) } } else - { + { switch($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini @@ -593,7 +607,7 @@ if (empty($reshook)) $error++; } - if ($result >= 0) + if ($result >= 0 && ! $error) { $db->commit(); @@ -622,6 +636,8 @@ if (empty($reshook)) if ($action == 'update') { + $error = 0; + if (GETPOST('cancel','alpha')) { if (! empty($backtopage)) @@ -647,16 +663,27 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } + // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined) - if (!empty($user->rights->categorie->lire)) + if (! $error && !empty($user->rights->categorie->lire)) { // Customer categories association $categories = GETPOST( 'custcats', 'array' ); - $object->setCategories($categories, 'customer'); + $result = $object->setCategories($categories, 'customer'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Supplier categories association $categories = GETPOST('suppcats', 'array'); - $object->setCategories($categories, 'supplier'); + $result = $object->setCategories($categories, 'supplier'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } // Logo/Photo save @@ -686,13 +713,18 @@ if (empty($reshook)) } else { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + // Create thumbs + $object->addThumbs($newfile); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + // Index file in database + if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) + { + require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir + deleteFilesIntoDatabaseIndex(dirname($newfile), '', '', 'uploaded', 1); + // now we index the uploaded logo file + addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1); + } } } } @@ -764,7 +796,7 @@ if (empty($reshook)) if ($result > 0) { - header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name)); + header("Location: ".DOL_URL_ROOT."/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name)); exit; } else @@ -1145,7 +1177,7 @@ else // Address print ''.fieldLabel('Address','address').''; - print ''; @@ -1418,7 +1450,7 @@ else if ($socid) { - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); @@ -2011,7 +2043,7 @@ else * View */ - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + if (!empty($object->id)) $res=$object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ddf6f5c509a..8e77bbcf147 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -335,7 +335,7 @@ class Societe extends CommonObject */ var $price_level; var $outstanding_limit; - + /** * Min order amounts */ @@ -1122,10 +1122,11 @@ class Societe extends CommonObject * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) - * @param string $email Email (Warning, this can return several records) + * @param string $email Email of third party (Warning, this can return several records) + * @param string $ref_alias Name_alias of third party (Warning, this can return several records) * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='', $ref_alias='') { global $langs; global $conf; @@ -1167,17 +1168,18 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; - if ($rowid) $sql .= ' AND s.rowid = '.$rowid; - if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; - if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; - if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; - if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; - if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; - if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; - if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; - if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; + if ($rowid) $sql .= ' AND s.rowid = '.$rowid; + if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; + if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; + if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; + if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; + if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; + if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; + if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; + if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; + if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; + if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; $resql=$this->db->query($sql); if ($resql) @@ -1317,8 +1319,9 @@ class Societe extends CommonObject $result = 1; - // Retreive all extrafield for thirdparty - $this->fetch_optionals(); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); } else { @@ -3833,6 +3836,8 @@ class Societe extends CommonObject $to_add = $categories; } + $error = 0; + // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { @@ -3840,12 +3845,20 @@ class Societe extends CommonObject } } foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, $type_text); + if ($c->fetch($add) > 0) + { + $result = $c->add_type($this, $type_text); + if ($result < 0) + { + $error++; + $this->error = $c->error; + $this->errors = $c->errors; + break; + } } } - return 1; + return $error ? -1 : 1; } diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index d57f61045c0..32575beb8c7 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -150,7 +150,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) else { - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + if (!empty($object->id)) $res=$object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 47852c71403..9861f4b8d66 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -998,7 +998,7 @@ while ($i < min($num, $limit)) $savalias = $obj->name_alias; if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias=''; print ''; - print $companystatic->getNomUrl(1,'',100); + print $companystatic->getNomUrl(1, '', 100, 0, 1); print "\n"; $companystatic->name_alias = $savalias; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 439586468c4..67a44d87ccf 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -222,7 +222,8 @@ if ($id > 0 || ! empty($ref)) $sql.= " t.libelle as type, t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE d.fk_soc=".$id; + $sql.= " WHERE d.fk_soc = ".$id; + $sql.= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); $resql = $db->query($sql); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index ef990a7e4f0..9e57176250a 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -525,25 +525,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); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 93bf576ef71..75575bf087b 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -358,7 +358,7 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } @@ -927,14 +927,16 @@ 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')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('SUPPLIER_PROPOSAL_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e43404777b6..baa0b424650 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1042,7 +1042,7 @@ class SupplierProposal extends CommonObject // get extrafields so they will be clone foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); + $line->fetch_optionals(); // Load source object $objFrom = clone $this; @@ -1101,11 +1101,6 @@ class SupplierProposal extends CommonObject $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('SUPPLIER_PROPOSAL_CLONE',$user); - if ($result < 0) { $error++; } - // End call triggers } // End @@ -1132,7 +1127,7 @@ class SupplierProposal extends CommonObject { global $conf; - $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql.= ", p.datec"; $sql.= ", p.date_valid as datev"; @@ -1166,6 +1161,7 @@ class SupplierProposal extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->remise = $obj->remise; @@ -1220,12 +1216,9 @@ class SupplierProposal 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); @@ -1316,12 +1309,9 @@ class SupplierProposal extends CommonObject return -1; } - // Retreive all extrafield for askprice + // 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/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index abf9f9cfd2a..685e9531072 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -599,7 +599,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'],$_SERVER["PHP_SELF"],"sp.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -858,26 +858,19 @@ 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; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - $genallowed=$user->rights->supplier_proposal->lire; - $delallowed=$user->rights->supplier_proposal->creer; + $filedir=$diroutputmassaction; - print $formfile->showdocuments('massfilesarea_supplier_proposal','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $genallowed=$user->rights->supplier_proposal->lire; + $delallowed=$user->rights->supplier_proposal->creer; + print $formfile->showdocuments('massfilesarea_supplier_proposal','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 2b150d64a5e..df41d1301ef 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -407,6 +407,9 @@ td.onholidayallday { td.leftborder, td.hide0 { border-left: 1px solid #ccc; } +td.leftborder, td.hide6 { + border-right: 1px solid #ccc; +} td.actionbuttons a { padding-left: 6px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 07c02ba74fa..40b3fefc634 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -411,6 +411,9 @@ td.actionbuttons a { td.leftborder, td.hide0 { border-left: 1px solid #ccc; } +td.leftborder, td.hide6 { + border-right: 1px solid #ccc; +} select.flat, form.flat select { font-weight: normal; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ba327e7c9f1..a11c18daca7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -67,6 +67,9 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); } +if(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $caneditgroup = ($conf->entity == 1) && ! empty($user->admin) && empty($user->entity); +} // Define value to know what current user can do on properties of edited user if ($id) { @@ -154,7 +157,7 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorUserCannotBeDelete"), null, 'errors'); } else { - header("Location: index.php"); + header("Location: index.php?restore_lastsearch_values=1"); exit; } } @@ -1176,7 +1179,7 @@ else { $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); // Check if user has rights $object->getrights(); @@ -1795,7 +1798,7 @@ else } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6a2a1b774e7..3fcdf411a24 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -324,12 +324,9 @@ class User extends CommonObject // in such case, this admin user must be admin for ALL entities. if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; - // 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(); $this->db->free($result); } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 2e0cd0376c6..5104d813a05 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -116,12 +116,9 @@ class UserGroup extends CommonObject $this->members=$this->listUsersForGroup(); - // Retreive all extrafield for group + // Retreive all extrafield // fetch optionals attributes and labels - dol_include_once('/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(); // Sav current LDAP Current DN diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 8f99fa1bb81..52de09d566d 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -91,7 +91,7 @@ if (empty($reshook)) { { $object->fetch($id); $object->delete(); - header("Location: index.php"); + header("Location: index.php?restore_lastsearch_values=1"); exit; } else diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 6f9ac1f638a..b5edbafa89e 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -406,7 +406,7 @@ if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_t // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"u.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 4f0081551ca..a00e014d88a 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -306,7 +306,7 @@ function getActionComm($authentication,$id) $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true); //Get extrafield values - $actioncomm->fetch_optionals($actioncomm->id,$extralabels); + $actioncomm->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index fe4fcc3378f..6791864ba8b 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -311,7 +311,7 @@ function getContact($authentication,$id,$ref_ext) $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('socpeople',true); //Get extrafield values - $contact->fetch_optionals($contact->id,$extralabels); + $contact->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 00dcd2fe4fc..c4c4d40191e 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -425,7 +425,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('product',true); //Get extrafield values - $product->fetch_optionals($product->id,$extralabels); + $product->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { @@ -1096,7 +1096,7 @@ function getProductsForCategory($authentication,$id,$lang='') $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('product',true); //Get extrafield values - $obj->fetch_optionals($obj->id,$extralabels); + $obj->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index 9e10b0212ec..bc26de37601 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -377,7 +377,7 @@ function getProject($authentication,$id='',$ref='') $extralabels=$extrafields->fetch_name_optionals_label('societe',true); //Get extrafield values - $project->fetch_optionals($project->id,$extralabels); + $project->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { $project_result_fields=array_merge($project_result_fields,array('options_'.$key => $project->array_options['options_'.$key])); diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 8e358e21924..c2236368d18 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -357,7 +357,7 @@ function getThirdParty($authentication,$id='',$ref='',$ref_ext='') $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('societe',true); //Get extrafield values - $thirdparty->fetch_optionals($thirdparty->id,$extralabels); + $thirdparty->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 55119ef418d..084ef28c2d0 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; @@ -152,7 +153,7 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault.=''."\n"; /* @@ -287,13 +288,16 @@ if ($action == 'addcontainer') // and $urltograbdirrootwithoutslash is https://www.dolimed.com // Check pageurl is not already used - $tmpwebsitepage = new WebsitePage($db); - $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); - if ($result > 0) + if ($pageurl) { - setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); - $error++; - $action='createcontainer'; + $tmpwebsitepage = new WebsitePage($db); + $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); + if ($result > 0) + { + setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); + $error++; + $action='createcontainer'; + } } if (! $error) @@ -523,6 +527,11 @@ if ($action == 'addcontainer') getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto); + // Normalize links href to Dolibarr internal naming + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2.php"', $tmp); + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2-\3.php"', $tmp); + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2-\3-\4.php"', $tmp); + //print dol_escape_htmltag($tmp);exit; $objectpage->content = $tmp; @@ -543,8 +552,13 @@ if ($action == 'addcontainer') $substitutionarray=array(); $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); + $sample = GETPOST('sample','alpha'); + if (empty($sample)) $sample='empty'; + + $pathtosample = DOL_DOCUMENT_ROOT.'/website/page-sample-'.$sample.'.html'; + // Init content with content into pagetemplate.html, blogposttempltate.html, ... - $objectpage->content = make_substitutions(@file_get_contents(DOL_DOCUMENT_ROOT.'/website/'.$objectpage->type_container.'template.html'), $substitutionarray); + $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); } if (! $error) @@ -1242,6 +1256,7 @@ if (GETPOST('exportsite','alpha')) $form = new Form($db); $formadmin = new FormAdmin($db); $formwebsite = new FormWebsite($db); +$formother = new FormOther($db); $help_url=''; @@ -1408,29 +1423,44 @@ if (count($object->records) > 0) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { - print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/website/index.php?website='.$website; + + $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); + print '
'; + print $form->textwithpicto('', $htmltext, 1, 'preview'); print ''; print '
'; print ''; //print ''; - $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); + $htmltext =$langs->trans("SetHereVirtualHost", $dataroot); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print '
'; - $urlext=$virtualurl; - $urlint=$urlwithroot.'/public/website/index.php?website='.$website; if (empty($object->fk_default_home)) { + $htmltext = ''.$langs->trans("YouMustDefineTheHomePage").'
'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', ''.$langs->trans("YouMustDefineTheHomePage").'
'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '
'; } else { + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print ''; } } @@ -1451,7 +1481,7 @@ if (count($object->records) > 0) { print '
'; // Close current websitebar to open a new one - $array=$objectpage->fetchAll($object->id); + $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); $atleastonepage=(is_array($array) && count($array) > 0); @@ -1580,8 +1610,12 @@ if (count($object->records) > 0) $realpage=$urlwithroot.'/public/website/index.php?website='.$website.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); + $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); + + print '
'; + print $form->textwithpicto('', $htmltext, 1, 'preview'); print ''; // View page in new Tab print '
'; @@ -1592,8 +1626,11 @@ if (count($object->records) > 0) $urlext=$virtualurl.'/'.$pagealias.'.php'; $urlint=$urlwithroot.'/public/website/index.php?website='.$website; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); + + print ''; + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print ''; //print ''; @@ -1879,7 +1916,12 @@ if ($action == 'createsite') print ''; print ''; - print $form->textwithpicto($langs->trans('Virtualhost'), $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref'), 1, 'help', '', 0, 2, 'tooltipvirtual'); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref'); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); + + print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'tooltipvirtual'); print ''; print ''; print ''; @@ -1996,14 +2038,19 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print $langs->trans('WEBSITE_TYPE_CONTAINER'); print ''; - $arrayoftype=array('page'=>$langs->trans("Page"), 'banner'=>$langs->trans("Banner"), 'blogpost'=>$langs->trans("BlogPost"), 'other'=>$langs->trans("Other")); - print $form->selectarray('WEBSITE_TYPE_CONTAINER', $arrayoftype, $type_container); + print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER')?GETPOST('WEBSITE_TYPE_CONTAINER'):'page')); + print ''; + + print ''; + print $langs->trans('WEBSITE_PAGE_EXAMPLE'); + print ''; + print $formwebsite->selectSampleOfContainer('sample', (GETPOST('sample')?GETPOST('sample'):'corporatehomepage')); print ''; print ''; print $langs->trans('WEBSITE_PAGENAME'); print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/website/pagetemplate.html b/htdocs/website/page-sample-corporatehome.html similarity index 100% rename from htdocs/website/pagetemplate.html rename to htdocs/website/page-sample-corporatehome.html diff --git a/htdocs/website/page-sample-empty.html b/htdocs/website/page-sample-empty.html new file mode 100644 index 00000000000..313c398a86e --- /dev/null +++ b/htdocs/website/page-sample-empty.html @@ -0,0 +1,10 @@ +
+

__[MAIN_INFO_SOCIETE_NOM]__


+__(MyContainerTitle)__ +
+
+
+
+
Created by: __WEBSITE_CREATE_BY__
+
+
diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 9918b0b3022..8daab76e38c 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -221,7 +221,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if ($object->fk_soc >0 && empty($socid)) $socid = $object->fk_soc; - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = websiteaccountPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website');