Debug modulebuilder
This commit is contained in:
parent
dcb79e66cc
commit
8303cee676
@ -58,7 +58,7 @@ class MyObject extends CommonObject
|
|||||||
public $picto = 'myobject';
|
public $picto = 'myobject';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed,
|
* '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)
|
* '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
|
* 'notnull' if not null in database
|
||||||
|
|||||||
@ -110,6 +110,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
|||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
|
$error=0;
|
||||||
|
|
||||||
if ($cancel)
|
if ($cancel)
|
||||||
{
|
{
|
||||||
if ($action != 'addlink')
|
if ($action != 'addlink')
|
||||||
@ -125,15 +127,6 @@ if (empty($reshook))
|
|||||||
// Action to add record
|
// Action to add record
|
||||||
if ($action == 'add' && ! empty($user->rights->mymodule->create))
|
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)
|
foreach ($object->fields as $key => $val)
|
||||||
{
|
{
|
||||||
if (in_array($key, array('entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields
|
if (in_array($key, array('entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields
|
||||||
@ -173,20 +166,20 @@ if (empty($reshook))
|
|||||||
// Action to update record
|
// Action to update record
|
||||||
if ($action == 'update' && ! empty($user->rights->mymodule->create))
|
if ($action == 'update' && ! empty($user->rights->mymodule->create))
|
||||||
{
|
{
|
||||||
$error=0;
|
foreach ($object->fields as $key => $val)
|
||||||
|
{
|
||||||
$object->prop1=GETPOST("field1");
|
$object->$key=GETPOST($key,'alpha');
|
||||||
$object->prop2=GETPOST("field2");
|
if (in_array($key, array('entity', 'datec', 'tms'))) continue;
|
||||||
|
if ($val['notnull'] && $object->$key == '')
|
||||||
if (empty($object->ref))
|
{
|
||||||
{
|
$error++;
|
||||||
$error++;
|
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
|
||||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$result=$object->update($user);
|
$result=$object->updateCommon($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$action='view';
|
$action='view';
|
||||||
@ -208,7 +201,7 @@ if (empty($reshook))
|
|||||||
// Action to delete
|
// Action to delete
|
||||||
if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete))
|
if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete))
|
||||||
{
|
{
|
||||||
$result=$object->delete($user);
|
$result=$object->deleteCommon($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Delete OK
|
// Delete OK
|
||||||
|
|||||||
@ -510,11 +510,11 @@ while ($i < min($num, $limit))
|
|||||||
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
if (! empty($val['isameasure']))
|
if (! empty($val['isameasure']))
|
||||||
{
|
{
|
||||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
|
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
|
||||||
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
|
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user