diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f28a6d76212..f9389bc3d8d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1806,7 +1806,7 @@ abstract class CommonObject } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; - $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) + $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; if (!empty($filter)) @@ -1858,7 +1858,7 @@ abstract class CommonObject elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; - $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) + $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; if (!empty($filter)) @@ -6042,7 +6042,7 @@ abstract class CommonObject // Several field into label (eq table:code|libelle:rowid) $notrans = false; $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) + if (count($fields_label) > 1) { $notrans = true; foreach ($fields_label as $field_toshow) @@ -6204,7 +6204,7 @@ abstract class CommonObject $notrans = false; // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) { + if (count($fields_label) > 1) { $notrans = true; foreach ($fields_label as $field_toshow) { $labeltoshow .= $obj->$field_toshow.' '; @@ -7556,6 +7556,10 @@ abstract class CommonObject { if (is_null($value)) return 'NULL'; elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) return $this->db->escape("$value"); + elseif ($fieldsentry['type'] == 'boolean') { + if ($value) return 'true'; + else return 'false'; + } else return "'".$this->db->escape($value)."'"; } diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index a31cd3eb778..0bf2a60d0fe 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -56,7 +56,8 @@ foreach ($object->fields as $key => $val) if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int'); elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOST($key, 'none'); else $value = GETPOST($key, 'alpha'); - print $object->showInputField($val, $key, $value, '', '', '', 0); + if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0); + else print $object->showInputField($val, $key, $value, '', '', '', 0); print ''; print ''; } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index a608cad1b4a..3367be09296 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -700,7 +700,9 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $fieldname = $obj->Field; // type $type = $obj->Type; - if ($type == 'int(11)') $type = 'integer'; + if ($type == 'int(11)') $type='integer'; + if ($type == 'float') $type='real'; + if (strstr($type, 'tinyint')) $type='integer'; if ($obj->Field == 'fk_soc') $type = 'integer:Societe:societe/class/societe.class.php'; if (preg_match('/^fk_proj/', $obj->Field)) $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; if (preg_match('/^fk_prod/', $obj->Field)) $type = 'integer:Product:product/class/product.class.php:1'; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 3deba218b59..1331ef38fb2 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -299,7 +299,7 @@ class modMyModule extends DolibarrModules $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry - 'titre'=>'List MyObject', + 'titre'=>'List_MyObject', 'mainmenu'=>'mymodule', 'leftmenu'=>'mymodule_myobject_list', 'url'=>'/mymodule/myobject_list.php', @@ -313,7 +313,7 @@ class modMyModule extends DolibarrModules $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry - 'titre'=>'New MyObject', + 'titre'=>'New_MyObject', 'mainmenu'=>'mymodule', 'leftmenu'=>'mymodule_myobject_new', 'url'=>'/mymodule/myobject_card.php?action=create', @@ -325,7 +325,6 @@ class modMyModule extends DolibarrModules 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); END MODULEBUILDER LEFTMENU MYOBJECT */ - // Exports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 6d63d258c9c..c4627bf75f5 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -70,7 +70,9 @@ if ($object->element == 'product') { print ''.$langs->trans("Warehouse").''; print ''; - print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); + $ident = (GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ? GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))); + if (empty($ident) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $ident = $conf->global->MAIN_DEFAULT_WAREHOUSE; + print $formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '