From 23eb0f3770b28a9155f82226e82af9d73668aa8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Jan 2014 13:33:30 +0100 Subject: [PATCH] Qual: Mutualize code for actions of editing notes New: Add button 'cancel' to cancel edition of a note (private or public) --- htdocs/comm/propal.php | 16 +++------ htdocs/comm/propal/note.php | 16 +++------ htdocs/commande/fiche.php | 22 ++++--------- htdocs/commande/note.php | 15 ++------- htdocs/compta/deplacement/fiche.php | 29 +++++++---------- htdocs/compta/facture.php | 18 +++------- htdocs/compta/facture/note.php | 33 +++++++------------ htdocs/contact/note.php | 43 +++++++++--------------- htdocs/contrat/fiche.php | 16 +++------ htdocs/contrat/note.php | 24 +++++--------- htdocs/core/actions_setnotes.inc.php | 47 +++++++++++++++++++++++++++ htdocs/core/class/html.form.class.php | 7 ++-- htdocs/expedition/note.php | 32 +++++++----------- htdocs/fichinter/fiche.php | 31 +++++++----------- htdocs/fichinter/note.php | 13 ++------ htdocs/fourn/commande/fiche.php | 20 ++++-------- htdocs/fourn/commande/note.php | 13 ++------ htdocs/fourn/facture/fiche.php | 15 ++------- htdocs/fourn/facture/note.php | 18 +++------- htdocs/projet/note.php | 21 +++--------- htdocs/projet/tasks/note.php | 13 +------- htdocs/societe/note.php | 19 +++-------- 22 files changed, 176 insertions(+), 305 deletions(-) create mode 100644 htdocs/core/actions_setnotes.inc.php diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index ef37fa534bd..a4767f26ed1 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -96,6 +96,7 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('propalcard')); +$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php /* @@ -105,6 +106,9 @@ $hookmanager->initHooks(array('propalcard')); $parameters=array('socid'=>$socid); $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 + + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -232,18 +236,6 @@ else if ($action == 'set_ref_client' && $user->rights->propal->creer) $object->set_ref_client($user, $_POST['ref_client']); } -else if ($action == 'setnote_public' && $user->rights->propal->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->propal->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - // Create proposal else if ($action == 'add' && $user->rights->propal->creer) { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 2855a296010..7e31518d402 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -44,23 +44,15 @@ $result = restrictedArea($user, 'propale', $id, 'propal'); $object = new Propal($db); + /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} +$permission=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} /******************************************************************************/ diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index d40d8bf5a7c..f326cf33b8f 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -93,14 +93,18 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ordercard')); +$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ + +/* + * Actions + */ $parameters=array('socid'=>$socid); $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 + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) { @@ -552,18 +556,6 @@ else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); } -else if ($action == 'setnote_public' && $user->rights->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - // Add a new line else if ($action == 'addline' && $user->rights->commande->creer) { diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 58023beec33..9d740dc1089 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -50,24 +50,15 @@ if (! $object->fetch($id, $ref) > 0) dol_print_error($db); } +$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ -if ($action == 'setnote_public' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} /* * View diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 808d9163222..6d5f08873e3 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -51,10 +51,15 @@ $object = new Deplacement($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('tripsandexpensescard')); +$permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions -*/ + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + if ($action == 'validate' && $user->rights->deplacement->creer) { $object->fetch($id); @@ -231,23 +236,11 @@ else if ($action == 'setkm' && $user->rights->deplacement->creer) $result=$object->setValueFrom('km',GETPOST('km','int')); if ($result < 0) dol_print_error($db, $object->error); } -else if ($action == 'setnote_public' && $user->rights->deplacement->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db, $object->error); -} -else if ($action == 'setnote_private' && $user->rights->deplacement->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db, $object->error); -} /* * View -*/ + */ llxHeader(); @@ -301,7 +294,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePublic').''; print ''; - + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), 600, 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100); print $doleditor->Create(1); @@ -313,7 +306,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePrivate').''; print ''; - + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), 600, 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100); print $doleditor->Create(1); @@ -400,7 +393,7 @@ else if ($id) $doleditor = new DolEditor('note_public', $object->note_public, 600, 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '100'); print $doleditor->Create(1); - + print ""; // Private note @@ -437,7 +430,7 @@ else if ($id) if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete"); - + } $soc = new Societe($db); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 044cc203cf8..d059e47d555 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -100,6 +100,8 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('invoicecard')); +$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions @@ -108,6 +110,8 @@ $hookmanager->initHooks(array('invoicecard')); $parameters=array('socid'=>$socid); $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 + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) @@ -367,20 +371,6 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer) $object->set_ref_client($_POST['ref_client']); } -else if ($action == 'setnote_public' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - // Classify to validated else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) { diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 6092ba39e85..001473b0568 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -45,29 +45,20 @@ $result=restrictedArea($user,'facture',$id,''); $object = new Facture($db); $object->fetch($id); - -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ - -if ($action == 'setnote_public' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + + +/* + * View + */ llxHeader(); diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 27a56b48825..4adb109b89f 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -41,26 +41,15 @@ $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Contact($db); if ($id > 0) $object->fetch($id); +$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php + + /* * Actions */ -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) setEventMessage($object->error,'errors'); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) setEventMessage($object->error,'errors'); -} /* * View @@ -91,16 +80,16 @@ if ($id > 0) print ''; $linkback = ''.$langs->trans("BackToList").''; - + // Ref print ''; - + // Name print ''; print ''; - + // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { @@ -108,10 +97,10 @@ if ($id > 0) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); - + print ''; } - + else { print ''; } } - + // Civility print ''; - + // Date To Birth print ''; if (! empty($object->birthday)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - + print '"; } print ""; - + print "
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback); print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; @@ -119,20 +108,20 @@ if ($id > 0) print '
'.$langs->trans("UserTitle").''; print $object->getCivilityLabel(); print '
'.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); - + print '   '; //var_dump($birthdatearray); $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; @@ -140,8 +129,8 @@ if ($id > 0) if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - - + + print '   -   '; if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); else print $langs->trans("BirthdayAlertOff"); @@ -152,7 +141,7 @@ if ($id > 0) print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown")."
"; print '
'; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 06b408d4fa2..ca87d798507 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -66,11 +66,15 @@ $hookmanager->initHooks(array('contractcard')); $object = new Contrat($db); +$permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { $object->fetch($id); @@ -669,18 +673,6 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra } } -else if ($action == 'setnote_public' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index e2bac1c6016..05c4608da8a 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -43,28 +43,20 @@ $result=restrictedArea($user,'contrat',$id); $object = new Contrat($db); $object->fetch($id,$ref); +$permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_public')), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} +/* + * Actions + */ -else if ($action == 'setnote_private' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_private')), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * View + */ llxHeader(); diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php new file mode 100644 index 00000000000..3b2bbef75bb --- /dev/null +++ b/htdocs/core/actions_setnotes.inc.php @@ -0,0 +1,47 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_setnotes.inc.php + * \brief Code for actions on setting notes of object page + */ + + +// $action must be defined +// $permission must be defined to permission to edit object +// $object must be defined (object is loaded in this file with fetch) +// $id must be defined (object is loaded in this file with fetch) + +// Set public note +if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel')) +{ + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); + if ($result < 0) setEventMessage($object->error,'errors'); +} +// Set public note +else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel')) +{ + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); + if ($result < 0) setEventMessage($object->error,'errors'); +} + +?> \ No newline at end of file diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d0df5591880..ba76f142534 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -191,10 +191,9 @@ class Form $ret.=''; if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker') { - $ret.=''; - // TODO Add a button Cancel - //$ret.='

'."\n"; - //$ret.=''; + $ret.=''; + $ret.='

'."\n"; + $ret.=''; $ret.=''; } $ret.=''."\n"; diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index d0300dad278..0ef603a23f9 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -53,29 +53,19 @@ $result=restrictedArea($user, $origin, $origin_id); $object = new Expedition($db); $object->fetch($id); - -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ - -if ($action == 'setnote_public' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +$permissionnote=$user->rights->expedition->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + +/* + * View + */ llxHeader(); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 36178057338..ba5f4d986c4 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -88,12 +88,15 @@ if ($id > 0 || ! empty($ref)) if ($ret < 0) dol_print_error('',$object->error); } +$permissionnote=$user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) { $result = $object->setValid($user); @@ -399,16 +402,6 @@ else if ($action == 'setdescription' && $user->rights->ficheinter->creer) $result=$object->set_description($user,GETPOST('description')); if ($result < 0) dol_print_error($db,$object->error); } -else if ($action == 'setnote_public' && $user->rights->ficheinter->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} -else if ($action == 'setnote_private' && $user->rights->ficheinter->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} // Add line else if ($action == "addline" && $user->rights->ficheinter->creer) @@ -781,7 +774,7 @@ else if ($action == 'update_extras') $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); if ($ret < 0) $error++; - + if (! $error) { // Actions on extra fields (by external module or standard code) @@ -799,7 +792,7 @@ else if ($action == 'update_extras') } else if ($reshook < 0) $error++; } - + if ($error) $action = 'edit_extras'; } @@ -973,7 +966,7 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) { $formproject=new FormProjets($db); - + $langs->load("project"); print ''.$langs->trans("Project").''; @@ -1103,7 +1096,7 @@ else if ($id > 0 || ! empty($ref)) if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete','',0,1); - + } // Confirmation validation @@ -1127,21 +1120,21 @@ else if ($id > 0 || ! empty($ref)) $text=$langs->trans('ConfirmValidateIntervention',$numref); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate','',0,1); - + } // Confirmation de la validation de la fiche d'intervention if ($action == 'modify') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify','',0,1); - + } // Confirmation de la suppression d'une ligne d'intervention if ($action == 'ask_deleteline') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.GETPOST('line_id','int'), $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1); - + } print ''; @@ -1286,9 +1279,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + print $extrafields->showInputField($key,$value); - + print ''; print ''; } diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 3b7e8b5c960..6eea406fbfc 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -41,22 +41,13 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); $object->fetch($id,$ref); +$permissionnote=$user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ -if ($action == 'setnote_public' && $user->rights->ficheinter->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->ficheinter->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index dba0d7c8acc..214fc41770b 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -98,9 +98,15 @@ else if (! empty($socid) && $socid > 0) if ($ret < 0) dol_print_error($db,$object->error); } +$permissionnote=$user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php + + /* * Actions */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); @@ -137,23 +143,11 @@ else if ($action == 'classin' && $user->rights->fournisseur->commande->creer) $object->setProject($projectid); } -else if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer) +else if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer) { $result = $object->set_remise($user, $_POST['remise_percent']); } -else if ($action == 'setnote_public' && $user->rights->fournisseur->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->fournisseur->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver) { if (in_array($object->statut, array(1, 5, 6, 7, 9))) diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index 9e629414b63..7220f132f9c 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -44,21 +44,14 @@ $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); $object = new CommandeFournisseur($db); $object->fetch($id, $ref); +$permissionnote=$user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ -if ($action == 'setnote_public' && $user->rights->fournisseur->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setnote_private' && $user->rights->fournisseur->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 7402272fe73..6eb94d3ce07 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -82,12 +82,15 @@ if ($id > 0 || ! empty($ref)) $ret=$object->fetch($id, $ref); } +$permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -237,18 +240,6 @@ elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->factur $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); } -elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setnote_private' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} // Delete payment elseif ($action == 'deletepaiement') diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index b4bb99dcefc..942d06daa94 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -43,22 +43,14 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); $object->fetch($id, $ref); +$permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ -if ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setnote_private' && $user->rights->fournisseur->facture->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once // Set label if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index dddab2a5e79..9eb3ca646b3 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -47,25 +47,14 @@ $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); +$permissionnote=$user->rights->projet->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ -if ($action == 'setnote_public' && $user->rights->projet->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -if ($action == 'setnote_private' && $user->rights->projet->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 1b6bebeb9d5..c2e2451263d 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -85,18 +85,7 @@ $permission=($user->rights->projet->creer || $user->rights->projet->all->creer); * Actions */ -if ($action == 'setnote_public' && ! empty($permission)) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && ! empty($permission)) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; /* diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 1928ba914a0..0d87f98854b 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -40,26 +40,15 @@ $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) $object->fetch($id); +$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php + + /* * Actions */ -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) setEventMessage($object->error,'errors'); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) setEventMessage($object->error,'errors'); -} /* * View