Fix: use event method

This commit is contained in:
Regis Houssin 2013-01-15 11:00:32 +01:00
parent 3332709ba1
commit 787d3bd6a9

View File

@ -122,9 +122,7 @@ if (empty($reshook))
$object->fetch($id,$ref); $object->fetch($id,$ref);
$result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy')); $result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy'));
if ($result < 0) if ($result < 0)
{ setEventMessage(join(',',$object->errors), 'errors');
$mesg=join(',',$object->errors);
}
$action=""; $action="";
} }
@ -133,9 +131,7 @@ if (empty($reshook))
$object->fetch($id,$ref); $object->fetch($id,$ref);
$result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell')); $result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell'));
if ($result < 0) if ($result < 0)
{ setEventMessage(join(',',$object->errors), 'errors');
$mesg=join(',',$object->errors);
}
$action=""; $action="";
} }
@ -146,13 +142,13 @@ if (empty($reshook))
if (! GETPOST('libelle')) if (! GETPOST('libelle'))
{ {
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'</div>'; setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), 'errors');
$action = "create"; $action = "create";
$error++; $error++;
} }
if (empty($ref)) if (empty($ref))
{ {
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'</div>'; setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), 'errors');
$action = "create"; $action = "create";
$error++; $error++;
} }
@ -230,7 +226,7 @@ if (empty($reshook))
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans($object->error).'</div>'; setEventMessage($langs->trans($object->error), 'errors');
$action = "create"; $action = "create";
} }
} }
@ -289,14 +285,14 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($langs->trans($object->error), 'errors');
$action = 'edit'; $action = 'edit';
$mesg = $object->error;
} }
} }
else else
{ {
setEventMessage($langs->trans("ErrorProductBadRefOrLabel"), 'errors');
$action = 'edit'; $action = 'edit';
$mesg = $langs->trans("ErrorProductBadRefOrLabel");
} }
} }
@ -309,7 +305,7 @@ if (empty($reshook))
{ {
if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) if (! GETPOST('clone_content') && ! GETPOST('clone_prices') )
{ {
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>'; setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
} }
else else
{ {
@ -351,12 +347,13 @@ if (empty($reshook))
$mesg='<div class="error">'.$langs->trans("ErrorProductAlreadyExists",$object->ref); $mesg='<div class="error">'.$langs->trans("ErrorProductAlreadyExists",$object->ref);
$mesg.=' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.'; $mesg.=' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.';
$mesg.='</div>'; $mesg.='</div>';
setEventMessage($mesg, 'errors');
//dol_print_error($object->db); //dol_print_error($object->db);
} }
else else
{ {
$db->rollback(); $db->rollback();
$mesg=$object->error; setEventMessage($langs->trans($object->error), 'errors');
dol_print_error($db,$object->error); dol_print_error($db,$object->error);
} }
} }
@ -389,7 +386,7 @@ if (empty($reshook))
} }
else else
{ {
$mesg=$object->error; setEventMessage($langs->trans($object->error), 'errors');
$reload = 0; $reload = 0;
$action=''; $action='';
} }
@ -474,7 +471,7 @@ if (empty($reshook))
return; return;
} }
$mesg = $langs->trans("ErrorUnknown").": $result"; setEventMessage($langs->trans("ErrorUnknown").": $result", 'errors');
} }
// Add product into order // Add product into order
@ -717,8 +714,6 @@ else
else $title=$langs->trans("NewProduct"); else $title=$langs->trans("NewProduct");
print_fiche_titre($title); print_fiche_titre($title);
dol_htmloutput_mesg($mesg);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
$tmpcode=''; $tmpcode='';
@ -903,8 +898,6 @@ else
if ($object->isservice()) $type = $langs->trans('Service'); if ($object->isservice()) $type = $langs->trans('Service');
print_fiche_titre($langs->trans('Modify').' '.$type.' : '.$object->ref, ""); print_fiche_titre($langs->trans('Modify').' '.$type.' : '.$object->ref, "");
dol_htmloutput_errors($mesg);
// Main official, simple, and not duplicated code // Main official, simple, and not duplicated code
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n"; print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1066,8 +1059,6 @@ else
// Fiche en mode visu // Fiche en mode visu
else else
{ {
dol_htmloutput_mesg($mesg);
$head=product_prepare_head($object, $user); $head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$object->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==1?'service':'product'); $picto=($object->type==1?'service':'product');