mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 19:02:35 +01:00
Fix navigation on card generated by modulebuilder
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
if (($id > 0 || (! empty($ref) && ! in_array($action, array('create','createtask')))) && empty($cancel))
|
||||
{
|
||||
$ret = $object->fetch($id,$ref);
|
||||
$ret = $object->fetch($id, $ref);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
@@ -4905,7 +4905,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @param stdClass $obj Contain data of object from database
|
||||
*/
|
||||
private function set_vars_by_db(&$obj)
|
||||
private function setVarsFromFetchObj(&$obj)
|
||||
{
|
||||
foreach ($this->fields as $field => $info)
|
||||
{
|
||||
@@ -4922,7 +4922,8 @@ abstract class CommonObject
|
||||
}
|
||||
elseif($this->isInt($info))
|
||||
{
|
||||
$this->{$field} = (int) $obj->{$field};
|
||||
if ($field == 'rowid') $this->id = (int) $obj->{$field};
|
||||
else $this->{$field} = (int) $obj->{$field};
|
||||
}
|
||||
elseif($this->isFloat($info))
|
||||
{
|
||||
@@ -4982,6 +4983,7 @@ abstract class CommonObject
|
||||
|
||||
$fieldvalues = $this->set_save_query();
|
||||
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now);
|
||||
if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id;
|
||||
unset($fieldvalues['rowid']); // We suppose the field rowid is reserved field for autoincrement field.
|
||||
|
||||
$keys=array();
|
||||
@@ -5048,8 +5050,10 @@ abstract class CommonObject
|
||||
|
||||
// Load source object
|
||||
$object->fetchCommon($fromid);
|
||||
// Reset object
|
||||
$object->id = 0;
|
||||
// Reset some properties
|
||||
unset($object->id);
|
||||
unset($object->fk_user_creat);
|
||||
unset($object->import_key);
|
||||
|
||||
// Clear fields
|
||||
$object->ref = "copy_of_".$object->ref;
|
||||
@@ -5088,7 +5092,7 @@ abstract class CommonObject
|
||||
{
|
||||
if (empty($id) && empty($ref)) return false;
|
||||
|
||||
$sql = 'SELECT '.$this->get_field_list().', date_creation, tms';
|
||||
$sql = 'SELECT '.$this->get_field_list();
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
|
||||
if(!empty($id)) $sql.= ' WHERE rowid = '.$id;
|
||||
@@ -5101,12 +5105,7 @@ abstract class CommonObject
|
||||
{
|
||||
if ($obj)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->set_vars_by_db($obj);
|
||||
|
||||
$this->date_creation = $this->db->idate($obj->date_creation);
|
||||
$this->tms = $this->db->idate($obj->tms);
|
||||
|
||||
$this->setVarsFromFetchObj($obj);
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -55,7 +55,7 @@ class MyObject extends CommonObject
|
||||
/**
|
||||
* @var string String with name of icon for myobject
|
||||
*/
|
||||
public $picto = 'myobject';
|
||||
public $picto = 'myobject@mymodule';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,6 +61,7 @@ $langs->loadLangs(array("mymodule","other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
@@ -130,7 +131,7 @@ if (empty($reshook))
|
||||
{
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
|
||||
|
||||
$object->$key=GETPOST($key,'alpha');
|
||||
if ($val['notnull'] && $object->$key == '')
|
||||
@@ -170,7 +171,7 @@ if (empty($reshook))
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$object->$key=GETPOST($key,'alpha');
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue;
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
if ($val['notnull'] && $object->$key == '')
|
||||
{
|
||||
$error++;
|
||||
@@ -263,12 +264,14 @@ if ($action == 'create')
|
||||
print '<table class="border centpercent">'."\n";
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue;
|
||||
print '<tr><td';
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr id="field_'.$key.'"><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull']) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td></tr>';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>'."\n";
|
||||
|
||||
@@ -294,8 +297,17 @@ if (($id || $ref) && $action == 'edit')
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border centpercent">'."\n";
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_EDIT
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull']) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@@ -405,9 +417,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">'."\n";
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_VIEW
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull']) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
@@ -419,7 +440,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
|
||||
// ...
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
Reference in New Issue
Block a user