mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
QUAL fix hooks on contact.php files - fixes contexts
This commit is contained in:
parent
d27fd80472
commit
045c623536
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2005-2016 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2011-2022 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -67,50 +68,58 @@ $socid = '';
|
|||
if (!empty($user->socid)) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
restrictedArea($user, 'propal', $object->id);
|
||||
$result = restrictedArea($user, 'propal', $object->id);
|
||||
$hookmanager->initHooks(array('proposalcontactcard', 'globalcard'));
|
||||
|
||||
$usercancreate = $user->hasRight("propal", "creer");
|
||||
|
||||
|
||||
/*
|
||||
* Add a new contact
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->hasRight('propal', 'creer')) {
|
||||
if ($object->id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$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");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('propal', 'creer')) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->id > 0) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('propal', 'creer')) {
|
||||
// Deletes a contact
|
||||
$result = $object->delete_contact($lineid);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Add new contact
|
||||
if ($action == 'addcontact' && $user->hasRight('propal', 'creer')) {
|
||||
if ($object->id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$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");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('propal', 'creer')) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->id > 0) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('propal', 'creer')) {
|
||||
// Delete contact
|
||||
$result = $object->delete_contact($lineid);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
|
|
|
|||
|
|
@ -46,57 +46,65 @@ if ($user->socid) {
|
|||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'commande', $id, '');
|
||||
$hookmanager->initHooks(array('ordercontactcard', 'globalcard'));
|
||||
|
||||
$usercancreate = $user->hasRight("commande", "creer");
|
||||
|
||||
$object = new Commande($db);
|
||||
|
||||
|
||||
/*
|
||||
* Ajout d'un nouveau contact
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->hasRight('commande', 'creer')) {
|
||||
$result = $object->fetch($id);
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
// Add new contact
|
||||
if ($action == 'addcontact' && $user->hasRight('commande', 'creer')) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$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");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('commande', 'creer')) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('commande', 'creer')) {
|
||||
// Delete contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('commande', 'creer')) {
|
||||
// bascule du statut d'un contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('commande', 'creer')) {
|
||||
// Efface un contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -57,47 +58,56 @@ if ($id > 0 || !empty($ref)) {
|
|||
}
|
||||
|
||||
$result = restrictedArea($user, 'facture', $object->id);
|
||||
$hookmanager->initHooks(array('invoicecontactcard', 'globalcard'));
|
||||
|
||||
$usercancreate = $user->hasRight("facture", "creer");
|
||||
|
||||
|
||||
/*
|
||||
* Add a new contact
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->hasRight('facture', 'creer')) {
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$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");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('facture', 'creer')) {
|
||||
// Toggle the status of a contact
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('facture', 'creer')) {
|
||||
// Deletes a contact
|
||||
$result = $object->delete_contact($lineid);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Add new contact
|
||||
if ($action == 'addcontact' && $user->hasRight('facture', 'creer')) {
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$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");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('facture', 'creer')) {
|
||||
// Toggle the status of a contact
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('facture', 'creer')) {
|
||||
// Delete contact
|
||||
$result = $object->delete_contact($lineid);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -51,7 +52,7 @@ if ($user->socid) {
|
|||
$object = new Contrat($db);
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('contractcard', 'globalcard'));
|
||||
$hookmanager->initHooks(array('contractcontactcard', 'globalcard'));
|
||||
|
||||
$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
|
||||
|
|
@ -62,51 +63,59 @@ $result = restrictedArea($user, 'contrat', $object->id);
|
|||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->hasRight('contrat', 'creer')) {
|
||||
$result = $object->fetch($id);
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
// Add new contact
|
||||
if ($action == 'addcontact' && $user->hasRight('contrat', 'creer')) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
$msg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
|
||||
} else {
|
||||
$mesg = $object->error;
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
$msg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
|
||||
} else {
|
||||
$mesg = $object->error;
|
||||
}
|
||||
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle the status of a contact
|
||||
if ($action == 'swapstatut' && $user->hasRight('contrat', 'creer')) {
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete contact
|
||||
if ($action == 'deletecontact' && $user->hasRight('contrat', 'creer')) {
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bascule du statut d'un contact
|
||||
if ($action == 'swapstatut' && $user->hasRight('contrat', 'creer')) {
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete contact
|
||||
if ($action == 'deletecontact' && $user->hasRight('contrat', 'creer')) {
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
||||
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -69,47 +70,54 @@ if ($user->socid) {
|
|||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'expedition', $object->id, '');
|
||||
|
||||
$hookmanager->initHooks(array('shipmentcontactcard', 'globalcard'));
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->hasRight('expedition', 'creer')) {
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
|
||||
} else {
|
||||
$mesg = $objectsrc->error;
|
||||
$mesgs = $objectsrc->errors;
|
||||
}
|
||||
setEventMessages($mesg, $mesgs, 'errors');
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('expedition', 'creer')) {
|
||||
// bascule du statut d'un contact
|
||||
$result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('expedition', 'creer')) {
|
||||
// Efface un contact
|
||||
$result = $objectsrc->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'addcontact' && $user->hasRight('expedition', 'creer')) {
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
|
||||
} else {
|
||||
$mesg = $objectsrc->error;
|
||||
$mesgs = $objectsrc->errors;
|
||||
}
|
||||
setEventMessages($mesg, $mesgs, 'errors');
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $user->hasRight('expedition', 'creer')) {
|
||||
// bascule du statut d'un contact
|
||||
$result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} elseif ($action == 'deletecontact' && $user->hasRight('expedition', 'creer')) {
|
||||
// Efface un contact
|
||||
$result = $objectsrc->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -46,60 +47,70 @@ if ($user->socid) {
|
|||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
|
||||
$hookmanager->initHooks(array('ordersuppliercardcontact'));
|
||||
$hookmanager->initHooks(array('ordersuppliercardcontact', 'ordersuppliercontactcard', 'globalcard'));
|
||||
|
||||
$object = new CommandeFournisseur($db);
|
||||
|
||||
$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"));
|
||||
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) {
|
||||
$result = $object->fetch($id);
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
/*
|
||||
* Add a new contact
|
||||
*/
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'addcontact' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('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");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) {
|
||||
// Deleting a contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) {
|
||||
// Deleting a contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -47,55 +48,66 @@ if ($user->socid) {
|
|||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
|
||||
$hookmanager->initHooks(array('invoicesuppliercardcontact'));
|
||||
$hookmanager->initHooks(array('invoicesuppliercardcontact','invoicesuppliercontactcard', 'globalcard'));
|
||||
|
||||
$object = new FactureFournisseur($db);
|
||||
|
||||
$usercancreate = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"));
|
||||
$permissiontoadd = $usercancreate;
|
||||
|
||||
|
||||
/*
|
||||
* Ajout d'un nouveau contact
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
|
||||
$result = $object->fetch($id, $ref);
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
/*
|
||||
* Add a new contact
|
||||
*/
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'addcontact' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
|
||||
$result = $object->fetch($id, $ref);
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
|
||||
// bascule du statut d'un contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
|
||||
// Efface un contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
|
||||
// bascule du statut d'un contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
|
||||
// Efface un contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2005-2018 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -49,55 +50,67 @@ $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', '
|
|||
|
||||
$object = new SupplierProposal($db);
|
||||
|
||||
$permissiontoedit = $user->rights->supplier_proposal->creer;
|
||||
$permissiontoedit = $user->hasRight('supplier_proposal', 'creer');
|
||||
|
||||
$hookmanager->initHooks(array('supplier_proposalcontactcard', 'globalcard'));
|
||||
|
||||
|
||||
/*
|
||||
* Add a new contact
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $permissiontoedit) {
|
||||
$result = $object->fetch($id);
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source"));
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
/*
|
||||
* Add a new contact
|
||||
*/
|
||||
if ($action == 'addcontact' && $permissiontoedit) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source"));
|
||||
}
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $permissiontoedit) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && $permissiontoedit) {
|
||||
// Deleting a contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'swapstatut' && $permissiontoedit) {
|
||||
// Toggle the status of a contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'deletecontact' && $permissiontoedit) {
|
||||
// Deleting a contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST("lineid", 'int'));
|
||||
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user