New: Can use templates only canvas without controllers.
This commit is contained in:
parent
8d66d2da7e
commit
a6784f461e
@ -85,12 +85,9 @@ class Contact extends CommonObject
|
||||
* @param DB Habler d'acces base
|
||||
* @param id Id contact
|
||||
*/
|
||||
function Contact($DB, $id=0)
|
||||
function Contact($DB)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->id = $id;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,7 +434,7 @@ class Contact extends CommonObject
|
||||
/*
|
||||
* \brief Charge l'objet contact
|
||||
* \param id id du contact
|
||||
* \param user Utilisateur abonnes aux alertes si on veut les alertes de ce contact
|
||||
* \param user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
|
||||
* \return int -1 if KO, 0 if OK but not found, 1 if OK
|
||||
*/
|
||||
function fetch($id, $user=0)
|
||||
|
||||
@ -313,16 +313,26 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
}
|
||||
else if ($action == 'edit')
|
||||
{
|
||||
$objcanvas->fetch($id); // Reload object
|
||||
if (! empty($_POST)) {
|
||||
$objcanvas->assign_post(); // Assign POST data
|
||||
$objcanvas->control->object=$objcanvas->getObject($socid); // Load object
|
||||
if (empty($objcanvas->control->object))
|
||||
{
|
||||
$object = new Contact($db);
|
||||
$object->fetch($id,$user);
|
||||
$objcanvas->control->object=$object;
|
||||
}
|
||||
$objcanvas->assign_post(); // Assign POST data
|
||||
$objcanvas->assign_values($action); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$objcanvas->fetch($id); // Reload object
|
||||
$objcanvas->control->object=$objcanvas->getObject($socid); // Load object
|
||||
if (empty($objcanvas->control->object))
|
||||
{
|
||||
$object = new Contact($db);
|
||||
$object->fetch($id,$user);
|
||||
$objcanvas->control->object=$object;
|
||||
}
|
||||
$objcanvas->assign_values('view'); // Assign values
|
||||
$objcanvas->display_canvas('view'); // Show template
|
||||
}
|
||||
@ -350,7 +360,7 @@ else
|
||||
{
|
||||
// Si edition contact deja existant
|
||||
$object = new Contact($db);
|
||||
$return=$object->fetch(GETPOST("id"), $user);
|
||||
$return=$object->fetch($id, $user);
|
||||
if ($return <= 0)
|
||||
{
|
||||
dol_print_error('',$object->error);
|
||||
|
||||
@ -160,12 +160,23 @@ class Canvas
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch object values
|
||||
* @param id Element id
|
||||
* get object
|
||||
* @param param1 Param1
|
||||
* @param param2 Param2
|
||||
* @param param3 Param3
|
||||
* @return object Object loaded
|
||||
*/
|
||||
function fetch($id)
|
||||
function getObject($param1, $param2='', $param2='')
|
||||
{
|
||||
return $this->control->object->fetch($id);
|
||||
if (is_object($this->control->object) && method_exists($this->control->object,'fetch'))
|
||||
{
|
||||
$this->control->object->fetch($param1, $param2, $param3);
|
||||
return $this->control->object;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,6 +205,7 @@ class Canvas
|
||||
*/
|
||||
function assign_post()
|
||||
{
|
||||
if (empty($_POST)) return;
|
||||
if (method_exists($this->control,'assign_post')) $this->control->assign_post();
|
||||
}
|
||||
|
||||
|
||||
@ -398,17 +398,27 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
}
|
||||
elseif ($action == 'edit')
|
||||
{
|
||||
$objcanvas->fetch($socid); // Reload object
|
||||
if (! empty($_POST)) {
|
||||
$objcanvas->assign_post(); // Assign POST data
|
||||
}
|
||||
$objcanvas->control->object=$objcanvas->getObject($socid); // Load object
|
||||
if (empty($objcanvas->control->object))
|
||||
{
|
||||
$object = new Societe($db);
|
||||
$object->fetch($socid);
|
||||
$objcanvas->control->object=$object;
|
||||
}
|
||||
$objcanvas->assign_post(); // Assign POST data
|
||||
$objcanvas->assign_values($action); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$objcanvas->fetch($socid); // Relaod object
|
||||
$objcanvas->assign_values(); // Assign values
|
||||
$objcanvas->control->object=$objcanvas->getObject($socid); // Load object
|
||||
if (empty($objcanvas->control->object))
|
||||
{
|
||||
$object = new Societe($db);
|
||||
$object->fetch($socid);
|
||||
$objcanvas->control->object=$object;
|
||||
}
|
||||
$objcanvas->assign_values(); // Assign values
|
||||
$objcanvas->display_canvas(); // Show template
|
||||
|
||||
// TODO Move this also into template
|
||||
@ -937,7 +947,6 @@ else
|
||||
if (! $_POST["nom"])
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->id = $socid;
|
||||
$soc->fetch($socid);
|
||||
}
|
||||
else
|
||||
@ -1312,7 +1321,6 @@ else
|
||||
* View
|
||||
*/
|
||||
$soc = new Societe($db);
|
||||
$soc->id = $socid;
|
||||
$result=$soc->fetch($socid);
|
||||
if ($result < 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user