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

@ -49,8 +49,8 @@ $backtopage=GETPOST('backtopage','alpha');
$confirm=GETPOST('confirm','alpha');
$rowid=GETPOST('rowid','int');
$typeid=GETPOST('typeid','int');
$userid=GETPOST('userid','int');
$socid=GETPOST('socid','int');
$userid=GETPOST('userid','int');
$socid=GETPOST('socid','int');
if (! empty($conf->mailmanspip->enabled))
{
@ -68,7 +68,7 @@ $extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('member');
// 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");
$objcanvas='';
if (! empty($canvas))
@ -117,7 +117,7 @@ $hookmanager->initHooks(array('membercard'));
* 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
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
// -----------------------------------------
if (empty($object->error) && $socid)
if (empty($object->error) && $rowid)
{
$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->display_canvas($action); // Show template
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
else
{

View File

@ -162,7 +162,7 @@ if (empty($reshook))
$object->birthday_alert = $_POST["birthday_alert"];
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if (! $_POST["lastname"])
{
@ -254,7 +254,7 @@ if (empty($reshook))
$object->note_private = GETPOST("note_private");
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$result = $object->update($_POST["contactid"], $user);
@ -300,11 +300,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// -----------------------------------------
if (empty($object->error) && $id)
{
$object = new Contact($db);
$object->fetch($id);
$object = new Contact($db);
$result=$object->fetch($id);
if ($result <= 0) dol_print_error('',$object->error);
}
$objcanvas->assign_values($action, $id); // Set value for templates
$objcanvas->display_canvas($action); // Show template
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
else
{
@ -510,7 +511,7 @@ else
print $doleditor->Create(1);
//print '<textarea name="note" cols="70" rows="'.ROWS_3.'">'.(isset($_POST["note"])?$_POST["note"]:$object->note).'</textarea>';
print '</td></tr>';
// Note Private
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
print '<td colspan="3" valign="top">';
@ -728,7 +729,7 @@ else
// print isset($_POST["note"])?$_POST["note"]:$object->note;
// print '</textarea></td></tr>';
print '</td></tr>';
// Note Private
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">';
$doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
@ -941,7 +942,7 @@ else
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td><td colspan="3">';
print nl2br($object->note_public);
print '</td></tr>';
// Note Private
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">';
print nl2br($object->note_private);

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);
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 ADD COLUMN note_public text after note_private;
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))
{
// -----------------------------------------
// When used with CANVAS (more simple)
// -----------------------------------------
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
if (empty($object->error) && $id)
{
$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
{

View File

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