Enhance skeleton
This commit is contained in:
parent
b58f6b36a8
commit
b6ff6527bc
@ -106,7 +106,7 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
//// Call triggers
|
//// Call triggers
|
||||||
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
|
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
|
||||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||||
//// End call triggers
|
//// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,10 +133,11 @@ class Skeleton_Class extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
*
|
*
|
||||||
* @param int $id Id object
|
* @param int $id Id object
|
||||||
|
* @param string $ref Ref
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($id)
|
function fetch($id,$ref='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
@ -145,7 +146,8 @@ class Skeleton_Class extends CommonObject
|
|||||||
$sql.= " t.field2";
|
$sql.= " t.field2";
|
||||||
//...
|
//...
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
|
||||||
$sql.= " WHERE t.rowid = ".$id;
|
if ($ref) $sql.= " WHERE t.ref = '".$ref."'";
|
||||||
|
else $sql.= " WHERE t.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch");
|
dol_syslog(get_class($this)."::fetch");
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -214,7 +216,7 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
//// Call triggers
|
//// Call triggers
|
||||||
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
|
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
|
||||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||||
//// End call triggers
|
//// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,7 +263,7 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
//// Call triggers
|
//// Call triggers
|
||||||
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
|
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
|
||||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||||
//// End call triggers
|
//// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,8 @@ if ($user->societe_id > 0)
|
|||||||
//accessforbidden();
|
//accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($action) && empty($id) && empty($ref)) $action='create';
|
||||||
|
|
||||||
// Load object if id or ref is provided as parameter
|
// Load object if id or ref is provided as parameter
|
||||||
$object=new Skeleton_Class($db);
|
$object=new Skeleton_Class($db);
|
||||||
if (($id > 0 || ! empty($ref)) && $action != 'add')
|
if (($id > 0 || ! empty($ref)) && $action != 'add')
|
||||||
@ -290,7 +292,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
|
|
||||||
// Part to edit record
|
// Part to edit record
|
||||||
if ($id && $action == 'edit')
|
if (($id || $ref) && $action == 'edit')
|
||||||
{
|
{
|
||||||
dol_fiche_head();
|
dol_fiche_head();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user