Merge branch 'develop' of https://github.com/Darkjeff/dolibarr into develop

This commit is contained in:
Darkjeff 2018-01-16 17:51:00 +01:00
commit 69ab7542d0
14 changed files with 106 additions and 48 deletions

View File

@ -231,8 +231,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
$nblines=count($contents);
$out.= "\n<!-- Box ".get_class($this)." start -->\n";
//$out.= '<div class="div-table-responsive-no-min">'; // Does not work on home page. TODO Try to fix this.
$out.= '<div class="box" id="boxto_'.$this->box_id.'">'."\n";
$out.= '<div class="box boxdraggable" id="boxto_'.$this->box_id.'">'."\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.= "<br>\n";
$out.= "</div>\n";
//$out.= "</div>\n";
$out.= "<!-- Box ".get_class($this)." end -->\n\n";
if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
dol_filecache($cachedir, $filename, $out);

View File

@ -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<!-- Box left container -->\n";
$boxlista.='<div id="left" class="connectedSortable">'."\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.= "</div>\n";
$boxlista.= "<!-- End box left container -->\n";
$boxlistb.= "\n<!-- Box right container -->\n";
$boxlistb.= '<div id="right" class="connectedSortable">'."\n";
$ii=0;
foreach ($boxactivated as $key => $box)
@ -1176,7 +1172,7 @@ class FormOther
$emptybox->info_box_contents=array();
$boxlistb.= $emptybox->outputBox(array(),array());
}
$boxlistb.= "</div>\n";
$boxlistb.= "<!-- End box right container -->\n";
}

View File

@ -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)
{

View File

@ -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)

View File

@ -32,6 +32,8 @@ if (empty($conf) || ! is_object($conf))
<!-- BEGIN PHP TEMPLATE commonfields_add.tpl.php -->
<?php
$object->fields = dol_sort_array($object->fields, 'position');
foreach($object->fields as $key => $val)
{
// Discard if extrafield is a hidden field on form

View File

@ -32,6 +32,8 @@ if (empty($conf) || ! is_object($conf))
<!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
<?php
$object->fields = dol_sort_array($object->fields, 'position');
foreach($object->fields as $key => $val)
{
// Discard if extrafield is a hidden field on form

View File

@ -34,6 +34,8 @@ if (empty($conf) || ! is_object($conf))
<!-- BEGIN PHP TEMPLATE commonfields_view.tpl.php -->
<?php
$object->fields = dol_sort_array($object->fields, 'position');
foreach($object->fields as $key => $val)
{
// Discard if extrafield is a hidden field on form

View File

@ -124,8 +124,6 @@ if (empty($user->societe_id))
$boxstat.='</tr>';
$boxstat.='<tr class="impair"><td class="tdboxstats nohover flexcontainer">';
$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 '<div class="fichecenter fichecenterbis">';
* Show boxes
*/
$boxlist.='<table width="100%" class="notopnoleftnoright">';
$boxlist.='<tr><td class="notopnoleftnoright">'."\n";
$boxlist.='<div class="twocolumns">';
$boxlist.='<div class="fichehalfleft">';
$boxlist.='<div class="fichehalfleft boxhalfleft" id="boxhalfleft">';
//$boxlist.=$boxinfo;
$boxlist.=$boxstat;
$boxlist.=$resultboxes['boxlista'];
$boxlist.= '</div><div class="fichehalfright"><div class="ficheaddleft">';
$boxlist.= '</div>';
$boxlist.= '<div class="fichehalfright boxhalfright" id="boxhalfright">';
$boxlist.= '<div class="ficheaddleft">';
$boxlist.=$boxwork;
$boxlist.=$resultboxes['boxlistb'];
$boxlist.= '</div></div>';
$boxlist.= '</div>';
$boxlist.= '</div>';
$boxlist.= "\n";
$boxlist.= "</td></tr>";
$boxlist.= "</table>";
$boxlist.='</div>';
print $boxlist;

View File

@ -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 <strong>%s</strong> ? This will change code in PHP class but also remove column from table definition of object.

View File

@ -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 '<div class="fichehalfleft">';
print '<span class="fa fa-file-o"></span> '.$langs->trans("ClassFile").' : <strong>'.($realpathtoclass?'':'<strike>').$pathtoclass.($realpathtoclass?'':'</strike>').'</strong>';
@ -1506,6 +1539,11 @@ elseif (! empty($module))
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtonote).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>';
print '<br>';
print '<span class="fa fa-file-o"></span> '.$langs->trans("ScriptFile").' : <strong>'.($realpathtoscript?'':'<strike>').$pathtoscript.($realpathtoscript?'':'</strike>').'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoscript).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>';
print '<br>';
print '</div>';
@ -1539,9 +1577,15 @@ elseif (! empty($module))
//$propstat = $reflector->getStaticProperties();
//var_dump($reflectorpropdefault);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input class="button" type="submit" name="regenerateclasssql" value="'.$langs->trans("RegenerateClassAndSql").'">';
print '<input class="button" type="submit" name="regeneratemissing" value="'.$langs->trans("RegenerateMissingFiles").'">';
print '<br><br>';
print load_fiche_titre($langs->trans("Properties"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addproperty">';
@ -1581,19 +1625,19 @@ elseif (! empty($module))
{
// Line to add a property
print '<tr>';
print '<td><input class="text" name="propname" value="'.dol_escape_htmltag(GETPOST('propname','alpha')).'"></td>';
print '<td><input class="text" name="proplabel" value="'.dol_escape_htmltag(GETPOST('proplabel','alpha')).'"></td>';
print '<td><input class="text" name="proptype" value="'.dol_escape_htmltag(GETPOST('proptype','alpha')).'"></td>';
print '<td><input class="text" name="proparrayofkeyval" value="'.dol_escape_htmltag(GETPOST('proparrayofkeyval','none')).'"></td>';
print '<td><input class="text maxwidth75" name="propname" value="'.dol_escape_htmltag(GETPOST('propname','alpha')).'"></td>';
print '<td><input class="text maxwidth75" name="proplabel" value="'.dol_escape_htmltag(GETPOST('proplabel','alpha')).'"></td>';
print '<td><input class="text maxwidth75" name="proptype" value="'.dol_escape_htmltag(GETPOST('proptype','alpha')).'"></td>';
print '<td><input class="text maxwidth75" name="proparrayofkeyval" value="'.dol_escape_htmltag(GETPOST('proparrayofkeyval','none')).'"></td>';
print '<td class="center"><input class="text" size="2" name="propnotnull" value="'.dol_escape_htmltag(GETPOST('propnotnull','alpha')).'"></td>';
print '<td><input class="text" name="propdefault" value="'.dol_escape_htmltag(GETPOST('propdefault','alpha')).'"></td>';
print '<td><input class="text maxwidth50" name="propdefault" value="'.dol_escape_htmltag(GETPOST('propdefault','alpha')).'"></td>';
print '<td class="center"><input class="text" size="2" name="propindex" value="'.dol_escape_htmltag(GETPOST('propindex','alpha')).'"></td>';
print '<td class="right"><input class="text right" size="2" name="propposition" value="'.dol_escape_htmltag(GETPOST('propposition','alpha')).'"></td>';
print '<td class="center"><input class="text" size="2" name="propenabled" value="'.dol_escape_htmltag(GETPOST('propenabled','alpha')).'"></td>';
print '<td class="center"><input class="text" size="2" name="propvisible" value="'.dol_escape_htmltag(GETPOST('propvisible','alpha')).'"></td>';
print '<td class="center"><input class="text" size="2" name="propisameasure" value="'.dol_escape_htmltag(GETPOST('propisameasure','alpha')).'"></td>';
print '<td class="center"><input class="text" size="2" name="propsearchall" value="'.dol_escape_htmltag(GETPOST('propsearchall','alpha')).'"></td>';
print '<td><input class="text" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment','alpha')).'"></td>';
print '<td><input class="text maxwidth100" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment','alpha')).'"></td>';
print '<td align="center">';
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">';
print '</td></tr>';

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* 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++;

View File

@ -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');

View File

@ -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;
}

View File

@ -3005,6 +3005,10 @@ div .tdtop {
* Boxes
*/
.box {
overflow-x: auto;
min-height: 40px;
}
.ficheaddleft div.boxstats {
border: none;
}