diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index bd2730edda0..0a0239f0bf2 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -49,6 +49,21 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; +$object = new Societe($db); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('thirdpartymargins','globalcard')); + + +/* + * Actions + */ + +$parameters=array('id'=>$socid); +$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 diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 2855e82b076..ea0baec1a02 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -56,65 +56,78 @@ if (! $sortfield) $sortfield="c.lastname"; $now=dol_now(); +$object = new Societe($db); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('thirdpartynotification','globalcard')); + + /* * Actions */ -// Add a notification -if ($action == 'add') +$parameters=array('id'=>$socid); +$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 (empty($reshook)) { - $error=0; - - if (empty($contactid)) + // Add a notification + if ($action == 'add') { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Contact")), 'errors'); - $error++; - } - if ($actionid <= 0) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), 'errors'); - $error++; - } - - if (! $error) - { - $db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; - $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid; - if ($db->query($sql)) + $error=0; + + if (empty($contactid)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; - $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")"; - - if (! $db->query($sql)) - { - $error++; - dol_print_error($db); - } + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Contact")), 'errors'); + $error++; } - else + if ($actionid <= 0) { - dol_print_error($db); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), 'errors'); + $error++; } - + if (! $error) { - $db->commit(); - } - else - { - $db->rollback(); + $db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; + $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid; + if ($db->query($sql)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; + $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")"; + + if (! $db->query($sql)) + { + $error++; + dol_print_error($db); + } + } + else + { + dol_print_error($db); + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } } } -} - -// Remove a notification -if ($action == 'delete') -{ - $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"]; - $db->query($sql); + + // Remove a notification + if ($action == 'delete') + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"]; + $db->query($sql); + } } @@ -150,7 +163,7 @@ if ($result > 0) print ''; // Alias names (commercial, trademark or alias names) - print ''.$langs->trans('AliasNames').''; + print ''.$langs->trans('AliasNames').''; print $object->name_alias; print ""; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 7898f543507..82adbd96607 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -49,69 +49,82 @@ if ($user->societe_id) $socid = $user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); +$object = new Societe($db); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('thirdpartycustomerprice','globalcard')); + + /* * Actions */ -if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { +$parameters=array('id'=>$socid); +$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'); - $update_child_soc = GETPOST('updatechildprice'); - - // add price by customer - $prodcustprice->fk_soc = $socid; - $prodcustprice->fk_product = GETPOST('prodid', 'int'); - $prodcustprice->price = price2num(GETPOST("price"), 'MU'); - $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); - $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); - $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); - - $result = $prodcustprice->create($user, 0, $update_child_soc); - - if ($result < 0) { - setEventMessage($prodcustprice->error, 'errors'); - } else { - setEventMessage($langs->trans('Save'), 'mesgs'); - } - - $action = ''; -} - -if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) { - // Delete price by customer - $prodcustprice->id = GETPOST('lineid'); - $result = $prodcustprice->delete($user); - - if ($result < 0) { - setEventMessage($prodcustprice->error, 'mesgs'); - } else { - setEventMessage($langs->trans('Delete'), 'errors'); - } - $action = ''; -} - -if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { - - $prodcustprice->fetch(GETPOST('lineid', 'int')); - - $update_child_soc = GETPOST('updatechildprice'); - - // update price by customer - $prodcustprice->price = price2num(GETPOST("price"), 'MU'); - $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); - $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); - $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); - - $result = $prodcustprice->update($user, 0, $update_child_soc); - if ($result < 0) { - setEventMessage($prodcustprice->error, 'errors'); - } else { - setEventMessage($langs->trans('Save'), 'mesgs'); - } - - $action = ''; +if (empty($reshook)) +{ + if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { + + $update_child_soc = GETPOST('updatechildprice'); + + // add price by customer + $prodcustprice->fk_soc = $socid; + $prodcustprice->fk_product = GETPOST('prodid', 'int'); + $prodcustprice->price = price2num(GETPOST("price"), 'MU'); + $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); + $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); + $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); + $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); + + $result = $prodcustprice->create($user, 0, $update_child_soc); + + if ($result < 0) { + setEventMessage($prodcustprice->error, 'errors'); + } else { + setEventMessage($langs->trans('Save'), 'mesgs'); + } + + $action = ''; + } + + if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) { + // Delete price by customer + $prodcustprice->id = GETPOST('lineid'); + $result = $prodcustprice->delete($user); + + if ($result < 0) { + setEventMessage($prodcustprice->error, 'mesgs'); + } else { + setEventMessage($langs->trans('Delete'), 'errors'); + } + $action = ''; + } + + if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { + + $prodcustprice->fetch(GETPOST('lineid', 'int')); + + $update_child_soc = GETPOST('updatechildprice'); + + // update price by customer + $prodcustprice->price = price2num(GETPOST("price"), 'MU'); + $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); + $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); + $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); + $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); + + $result = $prodcustprice->update($user, 0, $update_child_soc); + if ($result < 0) { + setEventMessage($prodcustprice->error, 'errors'); + } else { + setEventMessage($langs->trans('Save'), 'mesgs'); + } + + $action = ''; + } }