Debug modulebuilder

This commit is contained in:
Laurent Destailleur 2017-07-24 21:03:35 +02:00
parent dcb79e66cc
commit 8303cee676
3 changed files with 23 additions and 30 deletions

View File

@ -58,7 +58,7 @@ class MyObject extends CommonObject
public $picto = 'myobject';
/*
/**
* 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed,
* 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed)
* 'notnull' if not null in database
@ -84,8 +84,8 @@ class MyObject extends CommonObject
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>true, 'position'=>1000, 'nullifempty'=>1),
);
// END MODULEBUILDER PROPERTIES
// If this object has a subtable with lines

View File

@ -110,6 +110,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
$error=0;
if ($cancel)
{
if ($action != 'addlink')
@ -125,19 +127,10 @@ if (empty($reshook))
// Action to add record
if ($action == 'add' && ! empty($user->rights->mymodule->create))
{
if ($cancel)
{
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1);
header("Location: ".$urltogo);
exit;
}
$error=0;
foreach ($object->fields as $key => $val)
{
if (in_array($key, array('entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields
$object->$key=GETPOST($key,'alpha');
if ($val['notnull'] && $object->$key == '')
{
@ -173,20 +166,20 @@ if (empty($reshook))
// Action to update record
if ($action == 'update' && ! empty($user->rights->mymodule->create))
{
$error=0;
$object->prop1=GETPOST("field1");
$object->prop2=GETPOST("field2");
if (empty($object->ref))
{
$error++;
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
}
foreach ($object->fields as $key => $val)
{
$object->$key=GETPOST($key,'alpha');
if (in_array($key, array('entity', 'datec', 'tms'))) continue;
if ($val['notnull'] && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->update($user);
$result=$object->updateCommon($user);
if ($result > 0)
{
$action='view';
@ -208,7 +201,7 @@ if (empty($reshook))
// Action to delete
if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete))
{
$result=$object->delete($user);
$result=$object->deleteCommon($user);
if ($result > 0)
{
// Delete OK

View File

@ -510,11 +510,11 @@ while ($i < min($num, $limit))
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
}
}