diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 4f59d3912a7..025cfba71a5 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -231,8 +231,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" $nblines=count($contents); $out.= "\n\n"; - //$out.= '
'; // Does not work on home page. TODO Try to fix this. - $out.= '
'."\n"; + + $out.= '
'."\n"; if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']) || $nblines) { @@ -361,7 +361,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && ! $nblines) $out.= "
\n"; $out.= "
\n"; - //$out.= "
\n"; + $out.= "\n\n"; if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $out); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 3c27a8f05fd..492565cebc7 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1042,8 +1042,8 @@ class FormOther // To update list of activated boxes function updateBoxOrder(closing) { - var left_list = cleanSerialize(jQuery("#left").sortable("serialize")); - var right_list = cleanSerialize(jQuery("#right").sortable("serialize")); + var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize")); + var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize")); var boxorder = \'A:\' + left_list + \'-B:\' + right_list; if (boxorder==\'A:A-B:B\' && closing == 1) // There is no more boxes on screen, and we are after a delete of a box so we must hide title { @@ -1067,8 +1067,8 @@ class FormOther jQuery("#boxcombo").change(function() { var boxid=jQuery("#boxcombo").val(); if (boxid > 0) { - var left_list = cleanSerialize(jQuery("#left").sortable("serialize")); - var right_list = cleanSerialize(jQuery("#right").sortable("serialize")); + var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize")); + var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize")); var boxorder = \'A:\' + left_list + \'-B:\' + right_list; jQuery.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\', @@ -1080,13 +1080,12 @@ class FormOther if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();'; $selectboxlist.=' - jQuery("#left, #right").sortable({ - /* placeholder: \'ui-state-highlight\', */ + jQuery("#boxhalfleft, #boxhalfright").sortable({ handle: \'.boxhandle\', revert: \'invalid\', - items: \'.box\', - containment: \'.fiche\', - connectWith: \'.connectedSortable\', + items: \'.boxdraggable\', + containment: \'document\', + connectWith: \'#boxhalfleft, #boxhalfright\', stop: function(event, ui) { updateBoxOrder(1); /* 1 to avoid message after a move */ } @@ -1118,7 +1117,6 @@ class FormOther $emptybox=new ModeleBoxes($db); $boxlista.="\n\n"; - $boxlista.='
'."\n"; // Define $box_max_lines $box_max_lines=5; @@ -1147,11 +1145,9 @@ class FormOther $emptybox->info_box_contents=array(); $boxlista.= $emptybox->outputBox(array(),array()); } - $boxlista.= "
\n"; $boxlista.= "\n"; $boxlistb.= "\n\n"; - $boxlistb.= '\n"; + $boxlistb.= "\n"; } diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index d14a60ab94f..8e2cba43097 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -35,6 +35,7 @@ * @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') * @param string $delfieldentry Id of field to remove * @return int|object <=0 if KO, Object if OK + * @see rebuildObjectSql */ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='') { @@ -202,6 +203,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' * @param string $readdir Directory source (use $destdir when not defined) * @param Object $object If object was already loaded/known, it is pass to avaoid another include and new. * @return int <=0 if KO, >0 if OK + * @see rebuildObjectClass */ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null) { diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index d14a37f3bdb..606cdd7af22 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -46,7 +46,7 @@ class modModuleBuilder extends DolibarrModules $this->family = "technic"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "A tool to help developers to build their own module."; + $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module."; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 5e1f02489f9..4c81e50c65c 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -32,6 +32,8 @@ if (empty($conf) || ! is_object($conf)) fields = dol_sort_array($object->fields, 'position'); + foreach($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index fc51a8e1602..8e936ef6b9b 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -32,6 +32,8 @@ if (empty($conf) || ! is_object($conf)) fields = dol_sort_array($object->fields, 'position'); + foreach($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index c297c00b0a8..57023bb63d2 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -34,6 +34,8 @@ if (empty($conf) || ! is_object($conf)) fields = dol_sort_array($object->fields, 'position'); + foreach($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form diff --git a/htdocs/index.php b/htdocs/index.php index 000d113cad0..280cb48af86 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -124,8 +124,6 @@ if (empty($user->societe_id)) $boxstat.=''; $boxstat.=''; - $var=true; - $object=new stdClass(); $parameters=array(); $action=''; @@ -510,7 +508,6 @@ if ($reshook == 0) { // Calculate total nb of late $totallate=$totaltodo=0; -$var=true; //Remove any invalid response //load_board can return an integer if failed or WorkboardResponse if OK @@ -617,25 +614,27 @@ print '
'; * Show boxes */ -$boxlist.=''; -$boxlist.='"; -$boxlist.= "
'."\n"; +$boxlist.='
'; -$boxlist.='
'; +$boxlist.='
'; -//$boxlist.=$boxinfo; $boxlist.=$boxstat; $boxlist.=$resultboxes['boxlista']; -$boxlist.= '
'; +$boxlist.= '
'; + +$boxlist.= '
'; +$boxlist.= '
'; $boxlist.=$boxwork; $boxlist.=$resultboxes['boxlistb']; -$boxlist.= '
'; +$boxlist.= '
'; +$boxlist.= '
'; $boxlist.= "\n"; -$boxlist.= "
"; +$boxlist.='
'; + print $boxlist; diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 78d6092f006..9e30ee6f1de 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -43,6 +43,8 @@ PathToModulePackage=Path to zip of module/application package PathToModuleDocumentation=Path to file of module/application documentation SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. FileNotYetGenerated=File not yet generated +RegenerateClassAndSql=Erase and regenerate class and sql files +RegenerateMissingFiles=Generate missing files SpecificationFile=File with business rules LanguageFile=File for language ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index a915728903c..3b2e36e21d8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -419,22 +419,53 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) { + $error = 0; + $objectname = $tabobj; $srcdir = $dirread.'/'.strtolower($module); $destdir = $dirins.'/'.strtolower($module); dol_mkdir($destdir); - $addfieldentry = array( - 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), - 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' - 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), - 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), - 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp','alpha')); - - if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) + // We click on add property + if (! GETPOST('regenerateclasssql') && ! GETPOST('regeneratemissing')) { - $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); + if (! GETPOST('propname','aZ09')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name")), null, 'errors'); + } + if (! GETPOST('proplabel','alpha')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + } + if (! GETPOST('proptype','alpha')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); + } + + if (! $error) + { + $addfieldentry = array( + 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), + 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), + 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), + 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp','alpha')); + + if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) + { + $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); + } + } + } + + if (GETPOST('regeneratemissing')) + { + setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); + $error++; } // Edit the class file to write properties @@ -1431,6 +1462,7 @@ elseif (! empty($module)) $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.key.sql'; $pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php'; $pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png'; + $pathtoscript = strtolower($module).'/scripts/'.strtolower($tabobj).'.php'; $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); @@ -1445,6 +1477,7 @@ elseif (! empty($module)) $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); $realpathtolib = dol_buildpath($pathtolib, 0, 1); $realpathtopicto = dol_buildpath($pathtopicto, 0, 1); + $realpathtoscript = dol_buildpath($pathtoscript, 0, 1); print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; @@ -1506,6 +1539,11 @@ elseif (! empty($module)) print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; + print '
'; + print ' '.$langs->trans("ScriptFile").' : '.($realpathtoscript?'':'').$pathtoscript.($realpathtoscript?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print '
'; print '
'; @@ -1539,9 +1577,15 @@ elseif (! empty($module)) //$propstat = $reflector->getStaticProperties(); //var_dump($reflectorpropdefault); + print '
'; + + print ''; + print ''; + print '

'; + + print load_fiche_titre($langs->trans("Properties"), '', ''); - print ''; print ''; print ''; @@ -1581,19 +1625,19 @@ elseif (! empty($module)) { // Line to add a property print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 8a266ba20cf..1d8ba3dace6 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -215,7 +215,7 @@ class modMyModule extends DolibarrModules $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7d0c5a7d26c..fa06a7e7d05 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -124,7 +124,7 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -134,7 +134,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); } } - +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 9d8f568bbd4..c711eb9b683 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2931,6 +2931,10 @@ ul.noborder li:nth-child(even):not(.liste_titre) { * Boxes */ +.box { + overflow-x: auto; + min-height: 40px; +} .ficheaddleft div.boxstats { border: none; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0ba04898f4c..f6cd5909d0e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3005,6 +3005,10 @@ div .tdtop { * Boxes */ +.box { + overflow-x: auto; + min-height: 40px; +} .ficheaddleft div.boxstats { border: none; }