Qual: Better error management.

Qual: Uniformize code for canvas
This commit is contained in:
Laurent Destailleur 2013-04-09 23:56:52 +02:00
parent cf52cbfab5
commit af6f075b5c
5 changed files with 34 additions and 24 deletions

View File

@ -68,7 +68,7 @@ $extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('member'); $extralabels=$extrafields->fetch_name_optionals_label('member');
// Get object canvas (By default, this is not defined, so standard usage of dolibarr) // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($socid); $object->getCanvas($rowid);
$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); $canvas = $object->canvas?$object->canvas:GETPOST("canvas");
$objcanvas=''; $objcanvas='';
if (! empty($canvas)) if (! empty($canvas))
@ -117,7 +117,7 @@ $hookmanager->initHooks(array('membercard'));
* Actions * Actions
*/ */
$parameters=array('socid'=>$socid, 'objcanvas'=>$objcanvas); $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
@ -694,13 +694,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
if (empty($object->error) && $socid) if (empty($object->error) && $rowid)
{ {
$object = new Adherent($db); $object = new Adherent($db);
$object->fetch($socid); $result=$object->fetch($rowid);
if ($result <= 0) dol_print_error('',$object->error);
} }
$objcanvas->assign_values($action, $socid); // Set value for templates $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template $objcanvas->display_canvas($action); // Show template
} }
else else
{ {

View File

@ -300,11 +300,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// ----------------------------------------- // -----------------------------------------
if (empty($object->error) && $id) if (empty($object->error) && $id)
{ {
$object = new Contact($db); $object = new Contact($db);
$object->fetch($id); $result=$object->fetch($id);
if ($result <= 0) dol_print_error('',$object->error);
} }
$objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template $objcanvas->display_canvas($action); // Show template
} }
else else
{ {

View File

@ -244,6 +244,8 @@ ALTER TABLE llx_actioncomm ADD COLUMN transparency integer after fk_user_action;
INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) VALUES (29,'FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',29); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) VALUES (29,'FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',29);
ALTER TABLE llx_adherent ADD COLUMN canvas varchar(32) after fk_user_valid;
ALTER TABLE llx_expedition CHANGE COLUMN note note_private text; ALTER TABLE llx_expedition CHANGE COLUMN note note_private text;
ALTER TABLE llx_expedition ADD COLUMN note_public text after note_private; ALTER TABLE llx_expedition ADD COLUMN note_public text after note_private;
ALTER TABLE llx_livraison CHANGE COLUMN note note_private text; ALTER TABLE llx_livraison CHANGE COLUMN note note_private text;

View File

@ -638,11 +638,17 @@ $formproduct = new FormProduct($db);
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{ {
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS (more simple) // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates if (empty($object->error) && $id)
$objcanvas->display_canvas($action); // Show template {
$object = new Product($db);
$result=$object->fetch($id);
if ($result <= 0) dol_print_error('',$object->error);
}
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template
} }
else else
{ {

View File

@ -531,8 +531,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$result=$object->fetch($socid); $result=$object->fetch($socid);
if ($result <= 0) dol_print_error('',$object->error); if ($result <= 0) dol_print_error('',$object->error);
} }
$objcanvas->assign_values($action, $socid); // Set value for templates $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template $objcanvas->display_canvas($action); // Show template
} }
else else
{ {