NEW Can add a button "Create" after combo of object with modulebuilder.

This commit is contained in:
Laurent Destailleur 2019-10-21 14:44:39 +02:00
parent 48f5970c7a
commit e261d63295
18 changed files with 110 additions and 69 deletions

View File

@ -79,6 +79,7 @@ $permissionnote=$user->rights->bom->write; // Used by the include of actions_set
$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->bom->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0);
/*
@ -93,11 +94,11 @@ if (empty($reshook))
{
$error=0;
$permissiontoadd = $user->rights->bom->write;
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
if (empty($backtopage)) {
if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist;
if (empty($backtopage) || ($cancel && empty($id))) {
//var_dump($backurlforlist);exit;
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__');
}
$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
@ -218,7 +219,7 @@ if ($action == 'create')
dol_fiche_head(array(), '');
print '<table class="border centpercent">'."\n";
print '<table class="border centpercent tableforfieldcreate">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
@ -252,7 +253,9 @@ if (($id || $ref) && $action == 'edit')
dol_fiche_head();
print '<table class="border centpercent">'."\n";
//$object->fields['keyfield']['disabled'] = 1;
print '<table class="border centpercent tableforfieldedit">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';

View File

@ -91,7 +91,7 @@ class BOM extends CommonObject
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1',),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'),
'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'),
'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
'duration' => array('type'=>'real', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'),

View File

@ -32,6 +32,8 @@
if ($cancel)
{
/*var_dump($cancel);
var_dump($backtopage);exit;*/
if (! empty($backtopage))
{
header("Location: ".$backtopage);
@ -80,7 +82,8 @@ if ($action == 'add' && ! empty($permissiontoadd))
if ($result > 0)
{
// Creation OK
$urltogo=$backtopage?str_replace('__ID__', $result, $backtopage):$backurlforlist;
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: ".$urltogo);
exit;
}

View File

@ -5556,16 +5556,20 @@ abstract class CommonObject
$type='';
$param = array();
$param['options']=array();
$size =$this->fields[$key]['size'];
$reg=array();
$size = $this->fields[$key]['size'];
// Because we work on extrafields
if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){
$param['options']=array($reg[1].':'.$reg[2]=>'N');
$type ='link';
} elseif(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) {
$param['options']=array($reg[1].':'.$reg[2]=>'N');
if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){
$param['options']=array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N');
$type ='link';
} elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)){
$param['options']=array($reg[2].':'.$reg[3].':'.$reg[4] => 'N');
$type ='link';
} elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)){
$param['options']=array($reg[2].':'.$reg[3] => 'N');
$type ='link';
} elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
$param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
$param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N');
$type ='sellist';
} elseif(preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) {
$param['options']=array();
@ -6078,16 +6082,26 @@ abstract class CommonObject
}
elseif ($type == 'link')
{
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]'
$param_list_array = explode(':', $param_list[0]);
$showempty=(($required && $default != '')?0:1);
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', '', '', 0, empty($val['disabled'])?0:1);
if (! empty($param_list_array[2])) // If we set to add a create button
{
list($class,$classfile)=explode(':', $param_list[0]);
if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1);
else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php', 1);
$out.='<a class="butActionNew" href="'.$url_path.'?action=create&backtopage='.$_SERVER['PHP_SELF'].'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
// TODO Add Javascript code to add input fields contents to new elements urls
if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled".
{
list($class,$classfile)=explode(':', $param_list[0]);
if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1);
else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1);
$paramforthenewlink = '';
$paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action','aZ09'):'');
$paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id','int'):'');
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--';
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page
$out.='<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
}
}
}
elseif ($type == 'password')
@ -6167,6 +6181,7 @@ abstract class CommonObject
$label = $val['label'];
$type = $val['type'];
$size = $val['css'];
$reg = array();
// Convert var to be able to share same code than showOutputField of extrafields
if (preg_match('/varchar\((\d+)\)/', $type, $reg))
@ -6182,7 +6197,9 @@ abstract class CommonObject
$computed=$val['computed'];
$unique=$val['unique'];
$required=$val['required'];
$param=$val['param'];
$param=array();
$param['options']=array();
if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
{

View File

@ -234,8 +234,6 @@ class CUnits // extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
$records=array();
$sql = 'SELECT';
$sql.= " t.rowid,";
$sql.= " t.code,";
@ -273,6 +271,7 @@ class CUnits // extends CommonObject
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$resql = $this->db->query($sql);
if ($resql) {
$this->records=array();

View File

@ -5824,10 +5824,11 @@ class Form
* @param string $morecss More CSS
* @param string $moreparams More params provided to ajax call
* @param int $forcecombo Force to load all values and output a standard combobox (with no beautification)
* @param int $disabled 1=Html component is disabled
* @return string Return HTML string
* @see selectForFormsList() select_thirdparty
*/
public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0)
public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0)
{
global $conf, $user;
@ -5868,12 +5869,12 @@ class Form
$out.= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
$out.= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
if ($placeholder) $placeholder=' placeholder="'.$placeholder.'"';
$out.= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$preselectedvalue.'"'.$placeholder.' />';
$out.= '<input type="text" class="'.$morecss.'"'.($disabled?' disabled="disabled"':'').' name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$preselectedvalue.'"'.$placeholder.' />';
}
else
{
// Immediate load of all database
$out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo);
$out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled);
}
return $out;
@ -5893,10 +5894,11 @@ class Form
* @param string $moreparams More params provided to ajax call
* @param int $forcecombo Force to load all values and output a standard combobox (with no beautification)
* @param int $outputmode 0=HTML select string, 1=Array
* @param int $disabled 1=Html component is disabled
* @return string Return HTML string
* @see selectForForms()
*/
public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0)
public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0)
{
global $conf, $langs, $user;
@ -5948,7 +5950,7 @@ class Form
}
// Construct $out and $outarray
$out.= '<select id="'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'"'.($moreparams?' '.$moreparams:'').' name="'.$htmlname.'">'."\n";
$out.= '<select id="'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').($moreparams?' '.$moreparams:'').' name="'.$htmlname.'">'."\n";
// Warning: Do not use textifempty = ' ' or '&nbsp;' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
$textifempty='&nbsp;';

View File

@ -64,7 +64,7 @@ class MyObject extends CommonObject
/**
* 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float')
* 'type' if the field format ('integer', 'integer:Class:pathtoclass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float')
* 'label' the translation key.
* 'enabled' is a condition when the field must be managed.
* '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). Using a negative value means field is not shown by default on list but can be selected for viewing)
@ -81,6 +81,7 @@ class MyObject extends CommonObject
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
*/
// BEGIN MODULEBUILDER PROPERTIES
@ -94,7 +95,7 @@ class MyObject extends CommonObject
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),

View File

@ -105,10 +105,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php
$permissionnote = $user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php
$permissionedit = $user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd = $user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
@ -124,11 +125,11 @@ if (empty($reshook))
{
$error=0;
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
if (empty($backtopage)) {
if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
@ -226,7 +227,7 @@ if (($id || $ref) && $action == 'edit')
dol_fiche_head();
print '<table class="border centpercent tableforfieldcreate">'."\n";
print '<table class="border centpercent tableforfieldedit">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';

View File

@ -96,7 +96,7 @@ class Mo extends CommonObject
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,),
@ -104,11 +104,11 @@ class Mo extends CommonObject
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",),
'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,),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')),
);
public $rowid;

View File

@ -108,7 +108,7 @@ $permissionnote=$user->rights->mrp->write; // Used by the include of actions_set
$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php
$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0);
/*
@ -125,11 +125,12 @@ if (empty($reshook))
{
$error=0;
$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = dol_buildpath('/mrp/mo_list.php', 1);
if (empty($backtopage)) {
if (empty($id)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mrp/mo_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
if (empty($backtopage) || ($cancel && empty($id))) {
//var_dump($backurlforlist);exit;
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__');
}
$triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record
@ -257,7 +258,9 @@ if (($id || $ref) && $action == 'edit')
dol_fiche_head();
print '<table class="border centpercent tableforfield">'."\n";
$object->fields['fk_bom']['disabled'] = 1;
print '<table class="border centpercent tableforfieldedit">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';

View File

@ -332,7 +332,7 @@ class FormProduct
* @param string $name Name of HTML field
* @param string $measuring_style Unit to show: weight, size, surface, volume, time
* @param string $default Preselected value
* @param int $adddefault Add empty unit called "Default"
* @param int|string $adddefault 1=Add empty unit called "Default", ''=Add empty value
* @param int $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power)
* @return string
*/
@ -346,24 +346,26 @@ class FormProduct
// TODO Use a cache
require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php';
$measuringUnits = new CUnits($db);
$filter = array();
$filter['t.active'] = 1;
if ($measuring_style) $filter['t.unit_type'] = $measuring_style;
$result = $measuringUnits->fetchAll(
'',
'',
0,
0,
array(
't.unit_type' => $measuring_style,
't.active' => 1,
)
$filter
);
if ($result < 0) {
dol_print_error($db);
return -1;
} else {
$return .= '<select class="flat" name="' . $name . '">';
if ($adddefault)
if ($adddefault || $adddefault === '')
{
$return .= '<option value="0">' . $langs->trans("Default") . '</option>';
$return .= '<option value="0">' . ($adddefault ? $langs->trans("Default") : ''). '</option>';
}
foreach ($measuringUnits->records as $lines)

View File

@ -102,6 +102,13 @@ if (empty($reshook))
$backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
//var_dump($backurlforlist);exit;
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__');
}
// Actions cancel, add, update, delete or clone
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';

View File

@ -205,9 +205,11 @@ if (empty($reshook))
{
$db->commit();
if ($backtopage)
if (! empty($backtopage))
{
header("Location: ".$backtopage.'&projectid='.$object->id);
$backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
$backtopage = $backtopage.'&projectid='.$object->id; // Old method
header("Location: ".$backtopage);
exit;
}
else
@ -595,7 +597,7 @@ if ($action == 'create' && $user->rights->projet->creer)
print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1);
}
else print $text;
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
if (! GETPOSTISSET('backtopage')) print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
print '</td></tr>';
}

View File

@ -625,15 +625,16 @@ if (empty($reshook))
{
$db->commit();
if (! empty($backtopage))
if (! empty($backtopage))
{
if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id;
$backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; // Old method
header("Location: ".$backtopage);
exit;
}
else
{
$url=$_SERVER["PHP_SELF"]."?socid=".$object->id;
$url=$_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method
if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id;
elseif ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id;

View File

@ -63,6 +63,7 @@ span.butAction, span.butActionDelete {
}
.tableforfieldcreate a.butActionNew>span.fa-plus-circle, .tableforfieldcreate a.butActionNew>span.fa-plus-circle:hover,
.tableforfieldedit a.butActionNew>span.fa-plus-circle, .tableforfieldedit a.butActionNew>span.fa-plus-circle:hover,
span.butActionNew>span.fa-plus-circle, span.butActionNew>span.fa-plus-circle:hover,
a.butActionNewRefused>span.fa-plus-circle, a.butActionNewRefused>span.fa-plus-circle:hover,
span.butActionNewRefused>span.fa-plus-circle, span.butActionNewRefused>span.fa-plus-circle:hover,

View File

@ -273,8 +273,7 @@ input:-webkit-autofill {
}
::-webkit-input-placeholder { color:#ccc; }
input:-moz-placeholder { color:#ccc; }
input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], select[name=incoterm_id] { margin-right: 6px; }
input[name=surface] { margin-right: 4px; }
input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; }
fieldset { border: 1px solid #AAAAAA !important; }
.legendforfieldsetstep { padding-bottom: 10px; }
input#onlinepaymenturl, input#directdownloadlink {

View File

@ -79,6 +79,7 @@ a.butActionNew>span.fa-plus-circle { padding-left: 6px; font-size: 1.5em; }
a.butActionNewRefused>span.fa-plus-circle { padding-left: 6px; font-size: 1.5em; }
.tableforfieldcreate a.butActionNew>span.fa-plus-circle, .tableforfieldcreate a.butActionNew>span.fa-plus-circle:hover,
.tableforfieldedit a.butActionNew>span.fa-plus-circle, .tableforfieldedit a.butActionNew>span.fa-plus-circle:hover,
span.butActionNew>span.fa-plus-circle, span.butActionNew>span.fa-plus-circle:hover,
a.butActionNewRefused>span.fa-plus-circle, a.butActionNewRefused>span.fa-plus-circle:hover,
span.butActionNewRefused>span.fa-plus-circle, span.butActionNewRefused>span.fa-plus-circle:hover,

View File

@ -500,8 +500,7 @@ input:-webkit-autofill {
::-moz-placeholder { color:#bbb; } /* firefox 19+ */
:-ms-input-placeholder { color:#ccc; } /* ie */
input:-moz-placeholder { color:#ccc; }
input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], select[name=incoterm_id] { margin-right: 6px; }
input[name=surface] { margin-right: 4px; }
input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; }
fieldset { border: 1px solid #AAAAAA !important; }
.legendforfieldsetstep { padding-bottom: 10px; }
input#onlinepaymenturl, input#directdownloadlink {