diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 75d9b560658..3eac57a64b4 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -664,10 +664,12 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
}
// Go back to draft
-if ($action == 'modif' && $user->rights->propal->creer) {
+if ($action == 'modif' && $user->rights->propal->creer)
+{
$object->set_draft($user);
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ {
// Define output language
$outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) {
@@ -2010,26 +2012,34 @@ if ($action == 'create')
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
// by
// hook
- if (empty($reshook) && ! empty($extrafields->attribute_label)) {
- foreach ($extrafields->attribute_label as $key => $label) {
- if ($action == 'edit_extras') {
+ if (empty($reshook) && ! empty($extrafields->attribute_label))
+ {
+ foreach ($extrafields->attribute_label as $key => $label)
+ {
+ if ($action == 'edit_extras')
+ {
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
- } else {
+ }
+ else
+ {
$value = $object->array_options ["options_" . $key];
}
- if ($extrafields->attribute_type [$key] == 'separate') {
+ if ($extrafields->attribute_type [$key] == 'separate')
+ {
print $extrafields->showSeparator($key);
- } else {
+ }
+ else
+ {
print '
| attribute_required [$key]))
- print ' class="fieldrequired"';
+ if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
print '>' . $label . ' | ';
// Convert date into timestamp format
if (in_array($extrafields->attribute_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 ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key) {
+ if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key)
+ {
print '';
- } else {
+ }
+ else
+ {
print $extrafields->showOutputField($key, $value);
if ($object->statut == 0 && $user->rights->propal->creer)
print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index f5d20936052..193443dd64d 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -34,9 +34,9 @@
*/
include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php';
-require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php';
-require_once DOL_DOCUMENT_ROOT .'/societe/class/client.class.php';
-require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
+require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
/**
@@ -3263,11 +3263,10 @@ class Facture extends CommonInvoice
/**
- * \class FactureLigne
- * \brief Classe permettant la gestion des lignes de factures
- * Gere des lignes de la table llx_facturedet
+ * Class to manage invoice lines.
+ * Saved into database table llx_facturedet
*/
-class FactureLigne extends CommonInvoiceLine
+class FactureLigne extends CommonInvoiceLine
{
var $db;
var $error;
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index f44efafbffa..90ad3e196e3 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -358,10 +358,14 @@ abstract class CommonInvoice extends CommonObject
}
}
+
+
+require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
+
/**
* Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...)
*/
-abstract class CommonInvoiceLine extends CommonObject
+abstract class CommonInvoiceLine extends CommonObjectLine
{
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 60e59222c9e..e8dcce57ac4 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2153,327 +2153,6 @@ abstract class CommonObject
}
}
-
- /**
- * Function to get extra fields of a member into $this->array_options
- * This method is in most cases called by method fetch of objects but you can call it separately.
- *
- * @param int $rowid Id of line
- * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()
- * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded
- */
- function fetch_optionals($rowid='',$optionsArray='')
- {
- if (empty($rowid)) $rowid=$this->id;
-
- if (! is_array($optionsArray))
- {
- // optionsArray not already loaded, so we load it
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields = new ExtraFields($this->db);
- $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element);
- }
-
- // Request to get complementary values
- if (count($optionsArray) > 0)
- {
- $sql = "SELECT rowid";
- foreach ($optionsArray as $name => $label)
- {
- $sql.= ", ".$name;
- }
- $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields";
- $sql.= " WHERE fk_object = ".$rowid;
-
- dol_syslog(get_class($this)."::fetch_optionals", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $numrows=$this->db->num_rows($resql);
- if ($numrows)
- {
- $tab = $this->db->fetch_array($resql);
-
- foreach ($tab as $key => $value)
- {
- // Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine)
- if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
- {
- // we can add this attribute to adherent object
- $this->array_options["options_".$key]=$value;
- }
- }
- }
-
- $this->db->free($resql);
-
- if ($numrows) return $numrows;
- else return 0;
- }
- else
- {
- dol_print_error($this->db);
- return -1;
- }
- }
- return 0;
- }
-
- /**
- * Delete all extra fields values for the current object.
- *
- * @return int <0 if KO, >0 if OK
- */
- function deleteExtraFields()
- {
- global $langs;
-
- $error=0;
-
- $this->db->begin();
-
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
- dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG);
- $resql=$this->db->query($sql_del);
- if (! $resql)
- {
- $this->error=$this->db->lasterror();
- $this->db->rollback();
- return -1;
- }
- else
- {
- $this->db->commit();
- return 1;
- }
- }
-
- /**
- * Add/Update all extra fields values for the current object.
- * All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd')
- *
- * @return int -1=error, O=did nothing, 1=OK
- */
- function insertExtraFields()
- {
- global $conf,$langs;
-
- $error=0;
-
- if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used
-
- if (! empty($this->array_options))
- {
- // Check parameters
- $langs->load('admin');
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields = new ExtraFields($this->db);
- $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element);
-
- foreach($this->array_options as $key => $value)
- {
- $attributeKey = substr($key,8); // Remove 'options_' prefix
- $attributeType = $extrafields->attribute_type[$attributeKey];
- $attributeSize = $extrafields->attribute_size[$attributeKey];
- $attributeLabel = $extrafields->attribute_label[$attributeKey];
- switch ($attributeType)
- {
- case 'int':
- if (!is_numeric($value) && $value!='')
- {
- $error++; $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
- return -1;
- }
- elseif ($value=='')
- {
- $this->array_options[$key] = null;
- }
- break;
- case 'price':
- $this->array_options[$key] = price2num($this->array_options[$key]);
- break;
- case 'date':
- $this->array_options[$key]=$this->db->idate($this->array_options[$key]);
- break;
- case 'datetime':
- $this->array_options[$key]=$this->db->idate($this->array_options[$key]);
- break;
- }
- }
- $this->db->begin();
-
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
- dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
- $this->db->query($sql_del);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
- foreach($this->array_options as $key => $value)
- {
- $attributeKey = substr($key,8); // Remove 'options_' prefix
- // Add field of attribut
- if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate
- $sql.=",".$attributeKey;
- }
- $sql .= ") VALUES (".$this->id;
- foreach($this->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)
- {
- if ($this->array_options[$key] != '')
- {
- $sql.=",'".$this->db->escape($this->array_options[$key])."'";
- }
- else
- {
- $sql.=",null";
- }
- }
- }
- $sql.=")";
-
- dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (! $resql)
- {
- $this->error=$this->db->lasterror();
- $this->db->rollback();
- return -1;
- }
- else
- {
- $this->db->commit();
- return 1;
- }
- }
- else return 0;
- }
-
- /**
- * Function to show lines of extrafields with output datas
- *
- * @param object $extrafields Extrafield Object
- * @param string $mode Show output (view) or input (edit) for extrafield
- * @param array $params Optionnal parameters
- * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
- *
- * @return string
- */
- function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='')
- {
- global $_POST, $conf;
-
- $out = '';
-
- if (count($extrafields->attribute_label) > 0)
- {
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
-
- $e = 0;
- foreach($extrafields->attribute_label as $key=>$label)
- {
- if (is_array($params) && count($params)>0) {
- if (array_key_exists('colspan',$params)) {
- $colspan=$params['colspan'];
- }
- }else {
- $colspan='3';
- }
- switch($mode) {
- case "view":
- $value=$this->array_options["options_".$key];
- break;
- case "edit":
- $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
- break;
- }
- if ($extrafields->attribute_type[$key] == 'separate')
- {
- $out .= $extrafields->showSeparator($key);
- }
- else
- {
- $csstyle='';
- if (is_array($params) && count($params)>0) {
- if (array_key_exists('style',$params)) {
- $csstyle=$params['style'];
- }
- }
- if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
- {
- $out .= ' |