';
$rightpart .= '';
}
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 8441dd530ee..c510bad66c4 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -913,6 +913,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'noteditable' says if field is not editable (1 or 0)
+ * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
* 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
@@ -933,7 +934,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
- 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'),
+ 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'alwayseditable'=>'1'),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirdparty'),
'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60),
@@ -1386,14 +1387,19 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
if (!$error) {
// Edit the class file to write properties
$object = rebuildObjectClass($destdir, $module, $objectname, $newmask);
- if (is_numeric($object) && $object < 0) {
+
+ if (is_numeric($object) && $object <= 0) {
+ $pathoffiletoeditsrc = $destdir.'/class/'.strtolower($objectname).'.class.php';
+ setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors');
$error++;
}
}
if (!$error) {
// Edit sql with new properties
$result = rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object);
- if ($result < 0) {
+
+ if ($result <= 0) {
+ setEventMessages($langs->trans('ErrorFailToCreateFile', '.sql'), null);
$error++;
}
}
@@ -1503,6 +1509,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
'csslist'=>GETPOST('propcsslist', 'alpha'),
'default'=>GETPOST('propdefault', 'restricthtml'),
'noteditable'=>intval(GETPOST('propnoteditable', 'int')),
+ 'alwayseditable'=>intval(GETPOST('propalwayseditable', 'int')),
'validate' => GETPOST('propvalidate', 'int')
);
@@ -1528,6 +1535,8 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
$object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry, $moduletype);
if (is_numeric($object) && $object <= 0) {
+ $pathoffiletoeditsrc = $destdir.'/class/'.strtolower($objectname).'.class.php';
+ setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors');
$error++;
}
}
@@ -1537,6 +1546,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
$result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
if ($result <= 0) {
+ setEventMessages($langs->trans('ErrorFailToCreateFile', '.sql'), null, 'errors');
$error++;
}
}
@@ -1568,7 +1578,10 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) {
// Edit the class file to write properties
if (!$error) {
$object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey);
+
if (is_numeric($object) && $object <= 0) {
+ $pathoffiletoeditsrc = $destdir.'/class/'.strtolower($objectname).'.class.php';
+ setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors');
$error++;
}
}
@@ -1576,7 +1589,9 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) {
// Edit sql with new properties
if (!$error) {
$result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
+
if ($result <= 0) {
+ setEventMessages($langs->trans('ErrorFailToCreateFile', '.sql'), null, 'errors');
$error++;
}
}
@@ -2911,6 +2926,7 @@ if ($module == 'initmodule') {
print '
';
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 8265bbadaf8..430f004eecb 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -89,6 +89,7 @@ class MyObject extends CommonObject
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'noteditable' says if field is not editable (1 or 0)
+ * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
* 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php
index b58c7169f25..8624713c689 100644
--- a/htdocs/mrp/class/mo.class.php
+++ b/htdocs/mrp/class/mo.class.php
@@ -105,7 +105,7 @@ class Mo extends CommonObject
'mrptype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>34, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth150', 'csslist'=>'minwidth150 center'),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'$conf->product->enabled', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1),
- 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'2', 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200'),
+ 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'2', 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200', 'alwayseditable'=>1),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'css'=>'maxwidth400', 'csslist'=>'tdoverflowmax150'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>51, 'notnull'=>-1, 'index'=>1, 'css'=>'minwidth200 maxwidth400', 'csslist'=>'tdoverflowmax100'),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'picto'=>'stock', 'enabled'=>'$conf->stock->enabled', 'visible'=>1, 'position'=>52, 'css'=>'maxwidth400', 'csslist'=>'tdoverflowmax200'),
@@ -116,8 +116,8 @@ class Mo extends CommonObject
'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>502,),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax100'),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1, 'csslist'=>'tdoverflowmax100'),
- 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'),
- 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,),
+ 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap', 'alwayseditable'=>1),
+ 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1, 'alwayseditable'=>1),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>1010),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '9'=>'Canceled')),
@@ -613,11 +613,9 @@ class Mo extends CommonObject
}
if (!$error) {
- setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
$this->db->commit();
return 1;
} else {
- setEventMessages($this->error, $this->errors, 'errors');
$this->db->rollback();
return -1;
}
@@ -636,8 +634,9 @@ class Mo extends CommonObject
$role = "";
if ($this->status != self::STATUS_DRAFT) {
- $this->error = 'BadStatus';
- return -1;
+ //$this->error = 'BadStatusForUpdateProduction';
+ //return -1;
+ return 1;
}
$this->db->begin();
diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php
index 373dd7b6410..fde5811547a 100644
--- a/htdocs/mrp/mo_card.php
+++ b/htdocs/mrp/mo_card.php
@@ -136,7 +136,7 @@ if (empty($reshook)) {
}
$triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record
- //Create MO with Childs
+ // Create MO with Childs
if ($action == 'add' && empty($id) && !empty($TBomLineId)) {
$noback = 1;
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@@ -165,7 +165,7 @@ if (empty($reshook)) {
$res = $object->add_object_linked('mo', $mo_parent->id);
}
- header("Location: ".dol_buildpath('/mrp/mo_card.php?id='.$moline->fk_mo, 1));
+ header("Location: ".dol_buildpath('/mrp/mo_card.php?id='.((int) $moline->fk_mo), 1));
exit;
}