diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index c7fe04d80a2..5b339b9a206 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -48,6 +48,7 @@ $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", " $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; +$optioncss = GETPOST('optioncss', 'alpha'); // Security check $socid = GETPOSTINT('socid'); @@ -69,11 +70,10 @@ $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); -$optioncss = GETPOST('optioncss', 'alpha'); if (empty($page) || $page == -1) { $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 84a0aebc13a..4e621976509 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -51,7 +51,9 @@ $langs->loadLangs(array('companies', 'orders')); $id = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('socid'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; $massaction = GETPOST('massaction', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -88,43 +90,50 @@ $object = new Societe($db); * Actions */ -if ($action == 'addcontact' && $user->hasRight('societe', 'creer')) { - $result = $object->fetch($id); +$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)) { + if ($action == 'addcontact' && $user->hasRight('societe', 'creer')) { + $result = $object->fetch($id); - if ($result > 0 && $id > 0) { - $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - } - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - $mesg = '