Uniformize code for error reporting after a hook.

This commit is contained in:
Laurent Destailleur 2014-09-28 03:41:32 +02:00
parent 4244979f4f
commit ec95aacd52
39 changed files with 108 additions and 75 deletions

View File

@ -114,8 +114,8 @@ if ($action == 'add')
} }
{ {
// Creation KO // Creation KO
if (! empty($object->errors)) setEventMessage($object->errors, 'errors'); if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessage($object->error, 'errors'); else setEventMessages($object->error, null, 'errors');
$action='create'; $action='create';
} }
} }
@ -139,7 +139,7 @@ if ($action == 'update' && ! GETPOST('cancel'))
if (empty($object->ref)) if (empty($object->ref))
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors'); setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors');
} }
if (! $error) if (! $error)
@ -152,8 +152,8 @@ if ($action == 'update' && ! GETPOST('cancel'))
else else
{ {
// Creation KO // Creation KO
if (! empty($object->errors)) setEventMessage($object->errors, 'errors'); if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessage($object->error, 'errors'); else setEventMessages($object->error, null, 'errors');
$action='edit'; $action='edit';
} }
} }
@ -170,14 +170,14 @@ if ($action == 'confirm_delete')
if ($result > 0) if ($result > 0)
{ {
// Delete OK // Delete OK
setEventMessage($langs->trans("RecordDeleted")); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
header("Location: ".dol_buildpath('/buildingmanagement/list.php',1)); header("Location: ".dol_buildpath('/buildingmanagement/list.php',1));
exit; exit;
} }
else else
{ {
if (! empty($object->errors)) setEventMessage($object->errors,'errors'); if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors');
else setEventMessage($object->error,'errors'); else setEventMessages($object->error,null,'errors');
} }
} }
@ -327,6 +327,8 @@ if ($id && (empty($action) || $action == 'view'))
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
if ($user->rights->mymodule->write) if ($user->rights->mymodule->write)

View File

@ -117,6 +117,7 @@ $hookmanager->initHooks(array('membercard'));
$parameters=array('rowid'=>$rowid, '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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
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))
{ {

View File

@ -102,7 +102,7 @@ $hookmanager->initHooks(array('categorycard'));
$parameters=array('id'=>$socid); $parameters=array('id'=>$socid);
$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
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {

View File

@ -78,6 +78,7 @@ $object = new Societe($db);
$parameters = array('socid' => $id); $parameters = array('socid' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'setcustomeraccountancycode') if ($action == 'setcustomeraccountancycode')

View File

@ -73,6 +73,7 @@ $hookmanager->initHooks(array('customerlist'));
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Do we click on purge search criteria ? // Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x")) if (GETPOST("button_removefilter_x"))
@ -269,7 +270,7 @@ if ($result)
print '<td align="center">'.$thirdpartystatic->getLibStatut(3); print '<td align="center">'.$thirdpartystatic->getLibStatut(3);
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
$parameters=array('obj' => $obj); $parameters=array('obj' => $obj);
$formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook

View File

@ -101,6 +101,7 @@ $object->substitutionarrayfortest=array(
$parameters=array(); $parameters=array();
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')

View File

@ -105,8 +105,8 @@ $permissionnote = $user->rights->propale->creer; // Used by the include of actio
*/ */
$parameters = array('socid' => $socid); $parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once

View File

@ -91,6 +91,7 @@ $hookmanager->initHooks(array('propallist'));
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Do we click on purge search criteria ? // Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x")) if (GETPOST("button_removefilter_x"))

View File

@ -161,6 +161,7 @@ $hookmanager->initHooks(array('prospectlist'));
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'cstc') if ($action == 'cstc')
{ {

View File

@ -100,6 +100,7 @@ $permissionnote = $user->rights->commande->creer; // Used by the include of acti
$parameters = array('socid' => $socid); $parameters = array('socid' => $socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once

View File

@ -78,6 +78,7 @@ $hookmanager->initHooks(array('orderlist'));
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Do we click on purge search criteria ? // Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x")) if (GETPOST("button_removefilter_x"))
@ -423,7 +424,7 @@ if ($resql)
print '</form>'."\n"; print '</form>'."\n";
print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>'; print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>';
$db->free($resql); $db->free($resql);
} }
else else

View File

@ -111,6 +111,7 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio
$parameters = array('socid' => $socid); $parameters = array('socid' => $socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once

View File

@ -108,6 +108,7 @@ $now=dol_now();
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Do we click on purge search criteria ? // Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x")) if (GETPOST("button_removefilter_x"))

View File

@ -71,10 +71,13 @@ $hookmanager->initHooks(array('paiementcard'));
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/* /*
* Actions * Actions
*/ */
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
{ {
$error = 0; $error = 0;

View File

@ -83,7 +83,7 @@ $hookmanager->initHooks(array('contactcard'));
$parameters=array('id'=>$id, 'objcanvas'=>$objcanvas); $parameters=array('id'=>$id, '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
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
@ -142,10 +142,10 @@ if (empty($reshook))
{ {
setEventMessage($object->error,'errors'); setEventMessage($object->error,'errors');
} }
else else
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
exit; exit;
} }
} }
@ -157,11 +157,11 @@ if (empty($reshook))
{ {
setEventMessage($object->error,'errors'); setEventMessage($object->error,'errors');
} }
else else
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
exit; exit;
} }
} }
// Add contact // Add contact
@ -380,7 +380,7 @@ else
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
dol_fiche_head($head, 'card', $title, 0, 'contact'); dol_fiche_head($head, 'card', $title, 0, 'contact');
dol_htmloutput_events(); dol_htmloutput_events();
} }

View File

@ -88,6 +88,7 @@ $hookmanager->initHooks(array('expeditioncard'));
*/ */
$parameters=array(); $parameters=array();
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'add') if ($action == 'add')
{ {

View File

@ -97,9 +97,12 @@ $permissionnote=$user->rights->ficheinter->creer; // Used by the include of acti
/* /*
* Actions * Actions
*/ */
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer)
{ {

View File

@ -54,6 +54,7 @@ $object = new Fournisseur($db);
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'setsupplieraccountancycode') if ($action == 'setsupplieraccountancycode')
{ {

View File

@ -110,6 +110,7 @@ $permissionnote=$user->rights->fournisseur->commande->creer; // Used by the incl
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once

View File

@ -88,6 +88,7 @@ $permissionnote=$user->rights->fournisseur->facture->creer; // Used by the inclu
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once

View File

@ -68,10 +68,13 @@ $hookmanager->initHooks(array('paymentsupplier'));
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/* /*
* Actions * Actions
*/ */
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
{ {
$error = 0; $error = 0;

View File

@ -66,6 +66,7 @@ $hookmanager->initHooks(array('supplierlist'));
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/* /*

View File

@ -101,7 +101,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barc
$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $parameters=array('id'=>$id, 'ref'=>$ref, '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
$error=$hookmanager->error; $errors=$hookmanager->errors; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {

View File

@ -75,6 +75,7 @@ $modulepart='produit';
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/* /*
@ -101,7 +102,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $titre, 0, $picto); dol_fiche_head($head, 'documents', $titre, 0, $picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Construit liste des fichiers // Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);

View File

@ -64,10 +64,6 @@ $hookmanager->initHooks(array('pricesuppliercard'));
$product = new ProductFournisseur($db); $product = new ProductFournisseur($db);
$product->fetch($id,$ref); $product->fetch($id,$ref);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
@ -80,8 +76,8 @@ if (! $sortorder) $sortorder="ASC";
*/ */
$parameters=array('socid'=>$socid, 'id_prod'=>$id); $parameters=array('socid'=>$socid, 'id_prod'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'remove_pf') if ($action == 'remove_pf')
{ {

View File

@ -67,10 +67,10 @@ if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($id, $ref); $result = $product->fetch($id, $ref);
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -83,8 +83,9 @@ if ($id > 0 || ! empty($ref))
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto); dol_fiche_head($head, 'referers', $titre, 0, $picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -67,10 +67,10 @@ if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($id, $ref); $result = $product->fetch($id, $ref);
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -80,8 +80,9 @@ if ($id > 0 || ! empty($ref))
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto); dol_fiche_head($head, 'referers', $titre, 0, $picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -147,7 +148,7 @@ if ($id > 0 || ! empty($ref))
print "</tr>\n"; print "</tr>\n";
$commandestatic=new CommandeFournisseur($db); $commandestatic=new CommandeFournisseur($db);
if ($num > 0) if ($num > 0)
{ {
$var=True; $var=True;
@ -155,7 +156,7 @@ if ($id > 0 || ! empty($ref))
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var=!$var; $var=!$var;
$commandestatic->id=$objp->commandeid; $commandestatic->id=$objp->commandeid;
$commandestatic->ref=$objp->ref; $commandestatic->ref=$objp->ref;
$commandestatic->statut=$objp->statut; $commandestatic->statut=$objp->statut;

View File

@ -73,7 +73,7 @@ if ($id > 0 || ! empty($ref))
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -85,6 +85,7 @@ if ($id > 0 || ! empty($ref))
dol_fiche_head($head, 'referers', $titre, 0, $picto); dol_fiche_head($head, 'referers', $titre, 0, $picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -72,9 +72,10 @@ if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($id, $ref); $result = $product->fetch($id, $ref);
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -87,8 +88,9 @@ if ($id > 0 || ! empty($ref))
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto); dol_fiche_head($head, 'referers', $titre, 0, $picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -72,10 +72,10 @@ if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($id, $ref); $result = $product->fetch($id, $ref);
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -88,9 +88,9 @@ if ($id > 0 || ! empty($ref))
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto); dol_fiche_head($head, 'referers', $titre, 0, $picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -66,9 +66,10 @@ if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($id, $ref); $result = $product->fetch($id, $ref);
$parameters=array('id'=>$id); $parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -78,9 +79,9 @@ if ($id > 0 || ! empty($ref))
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'referers', $titre,0,$picto); dol_fiche_head($head, 'referers', $titre,0,$picto);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -74,7 +74,7 @@ $date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendd
$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); $parameters=array('id'=>$socid, '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
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {

View File

@ -60,6 +60,7 @@ $object = new Resource($db);
$hookmanager->initHooks(array('resource_card')); $hookmanager->initHooks(array('resource_card'));
$parameters=array('resource_id'=>$id); $parameters=array('resource_id'=>$id);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/******************************************************************* /*******************************************************************
@ -86,7 +87,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write
$object->ref = $ref; $object->ref = $ref;
$object->description = $description; $object->description = $description;
$object->fk_code_type_resource = $fk_code_type_resource; $object->fk_code_type_resource = $fk_code_type_resource;
$result=$object->update($user); $result=$object->update($user);
if ($result > 0) if ($result > 0)
{ {
@ -98,9 +99,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write
setEventMessage('<div class="error">'.$object->error.'</div>'); setEventMessage('<div class="error">'.$object->error.'</div>');
$action='edit'; $action='edit';
} }
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessage($object->error,'errors');
$action='edit'; $action='edit';
@ -149,13 +150,13 @@ if ( $object->fetch($id) > 0 )
// Ref // Ref
print '<tr><td width="20%">'.$langs->trans("ResourceFormLabel_ref").'</td>'; print '<tr><td width="20%">'.$langs->trans("ResourceFormLabel_ref").'</td>';
print '<td><input size="12" name="ref" value="'.(GETPOST('ref') ? GETPOST('ref') : $object->ref).'"></td></tr>'; print '<td><input size="12" name="ref" value="'.(GETPOST('ref') ? GETPOST('ref') : $object->ref).'"></td></tr>';
// Type // Type
print '<tr><td width="20%">'.$langs->trans("ResourceType").'</td>'; print '<tr><td width="20%">'.$langs->trans("ResourceType").'</td>';
print '<td>'; print '<td>';
$ret = $formresource->select_types_resource($object->fk_code_type_resource,'fk_code_type_resource','',2); $ret = $formresource->select_types_resource($object->fk_code_type_resource,'fk_code_type_resource','',2);
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<td>'; print '<td>';
@ -194,7 +195,7 @@ if ( $object->fetch($id) > 0 )
print $object->type_label; print $object->type_label;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Description // Description
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("ResourceFormLabel_description") . '</td>'; print '<td>' . $langs->trans("ResourceFormLabel_description") . '</td>';
@ -215,8 +216,8 @@ if ( $object->fetch($id) > 0 )
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) if (empty($reshook))
{ {
if ($action != "edit" ) if ($action != "edit" )
{ {
// Edit resource // Edit resource

View File

@ -138,11 +138,12 @@ if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->dele
$parameters=array('resource_id'=>resource_id); $parameters=array('resource_id'=>resource_id);
$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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$parameters=array('resource_id'=>$resource_id); $parameters=array('resource_id'=>$resource_id);
$reshook=$hookmanager->executeHooks('getElementResources',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('getElementResources',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*************************************************** /***************************************************

View File

@ -53,9 +53,6 @@ $object = new Resource($db);
$hookmanager->initHooks(array('resource_list')); $hookmanager->initHooks(array('resource_list'));
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($sortorder)) $sortorder="DESC"; if (empty($sortorder)) $sortorder="DESC";
if (empty($sortfield)) $sortfield="t.rowid"; if (empty($sortfield)) $sortfield="t.rowid";
if (empty($arch)) $arch = 0; if (empty($arch)) $arch = 0;
@ -72,12 +69,20 @@ $pagenext = $page + 1;
if( ! $user->rights->resource->read) if( ! $user->rights->resource->read)
accessforbidden(); accessforbidden();
/***************************************************
* VIEW
*
* Put here all code to build page
****************************************************/
/*
* Action
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*
* View
*/
$pagetitle=$langs->trans('ResourcePageIndex'); $pagetitle=$langs->trans('ResourcePageIndex');
llxHeader('',$pagetitle,''); llxHeader('',$pagetitle,'');
@ -129,7 +134,7 @@ else
print '<td>'; print '<td>';
print $resource->ref; print $resource->ref;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $resource->type_label; print $resource->type_label;
print '</td>'; print '</td>';

View File

@ -47,8 +47,7 @@ $hookmanager->initHooks(array('agendathirdparty'));
$parameters=array('id'=>$socid); $parameters=array('id'=>$socid);
$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
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

View File

@ -57,8 +57,7 @@ if($_GET["socid"] && $_GET["commid"])
$parameters=array('id'=>$_GET["commid"]); $parameters=array('id'=>$_GET["commid"]);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$soc,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$soc,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) $soc->add_commercial($user, $_GET["commid"]); if (empty($reshook)) $soc->add_commercial($user, $_GET["commid"]);
@ -84,8 +83,7 @@ if($_GET["socid"] && $_GET["delcommid"])
$parameters=array('id'=>$_GET["delcommid"]); $parameters=array('id'=>$_GET["delcommid"]);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$soc,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$soc,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) $soc->del_commercial($user, $_GET["delcommid"]); if (empty($reshook)) $soc->del_commercial($user, $_GET["delcommid"]);

View File

@ -48,7 +48,7 @@ $hookmanager->initHooks(array('infothirdparty'));
$parameters=array('id'=>$socid); $parameters=array('id'=>$socid);
$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
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

View File

@ -86,7 +86,7 @@ $hookmanager->initHooks(array('thirdpartycard'));
$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); $parameters=array('id'=>$socid, '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
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {