2
0
forked from Wavyzz/dolibarr

Work on the customer payment mode tab

This commit is contained in:
Laurent Destailleur
2018-03-13 20:23:59 +01:00
parent a86da671ba
commit c78e5d23ea
4 changed files with 551 additions and 5 deletions

View File

@@ -181,6 +181,61 @@ if ($dirins && $action == 'addlanguage' && !empty($module))
$result = dolCopyDir($srcfile, $destfile, 0, 0);
}
if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray','alpha'))
{
$tablename = GETPOST('initfromtablename','alpha');
$_results = $db->DDLDescTable($tablename);
if (empty($_results))
{
setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors');
}
else
{
/*public $fields=array(
'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'),
'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'=>'LinkToThirparty'),
'description' =>array('type'=>'text', 'label'=>'Descrption', '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),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
);*/
$string = 'public $fields=array('."\n";
$string.="<br>";
$i=10;
while ($obj = $db->fetch_object($_results))
{
$fieldname = $obj->Field;
$type = $obj->Type;
if ($type == 'int(11)') $type='integer';
$notnull = ($obj->Null == 'YES'?0:1);
$label = preg_replace('/_/', ' ', ucfirst($fieldname));
if ($fieldname == 'rowid') $label='ID';
$string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."', 'enabled'=>1, 'visible'=>-2";
if ($notnull) $string.= ", 'notnull'=>".$notnull;
$string.= ", 'position'=>".$i."),\n";
$string.="<br>";
$i+=5;
}
$string.= ');'."\n";
$string.="<br>";
print $string;
exit;
}
}
if ($dirins && $action == 'initobject' && $module && $objectname)
{
if (preg_match('/[^a-z0-9_]/i', $objectname))
@@ -490,7 +545,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj))
setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null);
clearstatcache(true);
// Make a redirect to reload all data
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname.'&nocache='.time());
@@ -525,7 +580,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey)
setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null);
clearstatcache(true);
// Make a redirect to reload all data
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname);
@@ -1413,7 +1468,20 @@ elseif (! empty($module))
print $langs->trans("EnterNameOfObjectDesc").'<br><br>';
print '<input type="text" name="objectname" value="'.dol_escape_htmltag(GETPOST('objectname','alpha')?GETPOST('objectname','alpha'):$modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">';
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>';
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Generate")).'"'.($dirins?'':' disabled="disabled"').'>';
print '<br>';
print '<br>';
print '<br>';
print $langs->trans("Or");
print '<br>';
print '<br>';
print '<br>';
//print '<input type="checkbox" name="initfromtablecheck"> ';
print $langs->trans("InitStructureFromExistingTable");
print '<input type="text" name="initfromtablename" value="" placeholder="'.$langs->trans("TableName").'">';
print '<input type="submit" class="button" name="createtablearray" value="'.dol_escape_htmltag($langs->trans("Generate")).'"'.($dirins?'':' disabled="disabled"').'>';
print '<br>';
print '</form>';
}
elseif ($tabobj == 'deleteobject')
@@ -1549,7 +1617,7 @@ elseif (! empty($module))
print '<br><br><br>';
if(function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass,true); // remove the include cache hell !
if (empty($forceddirread))
{
$result = dol_include_once($pathtoclass);