diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f391d4bf0e0..cc985378732 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1219,8 +1219,12 @@ class Commande extends CommonOrder $this->fk_delivery_address = $object->fk_delivery_address; $this->contact_id = $object->contactid; $this->ref_client = $object->ref_client; - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + + if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) + { + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; + } $this->origin = $object->element; $this->origin_id = $object->id; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2f8c94a63fa..4e9b21ef2d5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1081,7 +1081,7 @@ class Facture extends CommonInvoice */ public function createFromOrder($object, User $user) { - global $hookmanager; + global $conf, $hookmanager; $error=0; @@ -1142,8 +1142,12 @@ class Facture extends CommonInvoice $this->fk_delivery_address = $object->fk_delivery_address; $this->contact_id = $object->contactid; $this->ref_client = $object->ref_client; - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + + if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) + { + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; + } $this->module_source = $object->module_source; $this->pos_source = $object->pos_source; @@ -4382,10 +4386,6 @@ class FactureLigne extends CommonInvoiceLine public $date_start; public $date_end; - // Ne plus utiliser - //var $price; // P.U. HT apres remise % de ligne (exemple 80) - //var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) - // From llx_product /** * @deprecated diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7b83dce5394..3b9a4771ba0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5169,8 +5169,9 @@ abstract class CommonObject $table_element = $this->table_element; if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG); + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$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.$table_element."_extrafields (fk_object"; @@ -5181,6 +5182,14 @@ abstract class CommonObject if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator $sql.=",".$attributeKey; } + // We must insert a default value for fields for other entities that are mandatory to avoid not null error + if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) + { + foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + $sql.=",".$tmpkey; + } + } $sql .= ") VALUES (".$this->id; foreach($new_array_options as $key => $value) @@ -5199,10 +5208,20 @@ abstract class CommonObject } } } + // We must insert a default value for fields for other entities that are mandatory to avoid not null error + if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) + { + foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (in_array($tmpval, array('int', 'double'))) $sql.=", 0"; + else $sql.=", ''"; + } + } + $sql.=")"; - dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG); $resql = $this->db->query($sql); + if (! $resql) { $this->error=$this->db->lasterror(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ce8916c1871..4795eedc219 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -864,8 +864,8 @@ class ExtraFields $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,totalizable,fielddefault,fieldcomputed,entity,enabled,help"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE entity IN (0,".$conf->entity.")"; - if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element + //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later + if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element $sql.= " ORDER BY pos"; $resql=$this->db->query($sql); @@ -875,6 +875,16 @@ class ExtraFields { while ($tab = $this->db->fetch_object($resql)) { + if ($tab->entity != 0 && $tab->entity != $conf->entity) + { + // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field + if ($tab->fieldrequired && is_null($tab->fielddefault)) + { + $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type; + } + continue; + } + // We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label'] if ($tab->type != 'separate') { diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 1e244df883f..54ad9b2066b 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -868,7 +868,7 @@ class DoliDBMysqli extends DoliDB if ($field_desc['default'] != '') { if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']); - elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields + elseif ($field_desc['type'] != 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields } dol_syslog(get_class($this)."::DDLUpdateField ".$sql, LOG_DEBUG); diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 6e72d9c435a..42d419bd7d1 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1176,7 +1176,7 @@ class DoliDBPgsql extends DoliDB if ($field_desc['default'] != '') { if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']); - elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields + elseif ($field_desc['type'] != 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields } dol_syslog($sql, LOG_DEBUG); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 0738d421c3c..4b753e71838 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1280,9 +1280,6 @@ if ($action == 'edit_price' && $object->getRights()->creer) $parameters=array('colspan' => 2); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $parameters=array('colspan' => 2); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print ''; dol_fiche_end(); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 611ab7fadc2..db0632be486 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -754,6 +754,7 @@ class User extends CommonObject { dol_syslog(get_class($this)."::clearrights reset user->rights"); $this->rights=''; + $this->nb_rights=0; $this->all_permissions_are_loaded=false; $this->_tab_loaded=array(); } @@ -2303,7 +2304,7 @@ class User extends CommonObject if ($infologin > 0) { $label.= '
'; - $label.= '
'.$langs->trans("Connection").''; + $label.= '
'.$langs->trans("Session").''; $label.= '
'.$langs->trans("IPAddress").': '.$_SERVER["REMOTE_ADDR"]; if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $label.= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$this->entity.')'; $label.= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)'); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 32b5ce452f7..e1551310a43 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -96,6 +96,9 @@ if (empty($reshook)) { $user->getrights(); $menumanager->loadMenu(); } + + $object->clearrights(); + $object->getrights(); } if ($action == 'delrights' && $caneditperms) { @@ -109,6 +112,9 @@ if (empty($reshook)) { $user->getrights(); $menumanager->loadMenu(); } + + $object->clearrights(); + $object->getrights(); } } @@ -265,9 +271,9 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad if ($caneditperms) { print ''; - print ''.$langs->trans("All").""; + print ''.$langs->trans("All").""; print '/'; - print ''.$langs->trans("None").""; + print ''.$langs->trans("None").""; print ''; } print ' ';