Qual: Mutualize code for actions of editing notes

New: Add button 'cancel' to cancel edition of a note (private or public)
This commit is contained in:
Laurent Destailleur 2014-01-11 13:33:30 +01:00
parent 171e74ae7e
commit 23eb0f3770
22 changed files with 176 additions and 305 deletions

View File

@ -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 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('propalcard')); $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); $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
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') 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']); $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 // Create proposal
else if ($action == 'add' && $user->rights->propal->creer) else if ($action == 'add' && $user->rights->propal->creer)
{ {

View File

@ -44,23 +44,15 @@ $result = restrictedArea($user, 'propale', $id, 'propal');
$object = new Propal($db); $object = new Propal($db);
/******************************************************************************/ /******************************************************************************/
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
if ($action == 'setnote_public' && $user->rights->propale->creer) $permission=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php
{
$object->fetch($id); include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
$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->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);
}
/******************************************************************************/ /******************************************************************************/

View File

@ -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 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordercard')); $hookmanager->initHooks(array('ordercard'));
$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php
/******************************************************************************/
/* 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
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) 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')); $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 // Add a new line
else if ($action == 'addline' && $user->rights->commande->creer) else if ($action == 'addline' && $user->rights->commande->creer)
{ {

View File

@ -50,24 +50,15 @@ if (! $object->fetch($id, $ref) > 0)
dol_print_error($db); dol_print_error($db);
} }
$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
if ($action == 'setnote_public' && $user->rights->commande->creer) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
{
$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->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 * View

View File

@ -51,10 +51,15 @@ $object = new Deplacement($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('tripsandexpensescard')); $hookmanager->initHooks(array('tripsandexpensescard'));
$permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
if ($action == 'validate' && $user->rights->deplacement->creer) if ($action == 'validate' && $user->rights->deplacement->creer)
{ {
$object->fetch($id); $object->fetch($id);
@ -231,23 +236,11 @@ else if ($action == 'setkm' && $user->rights->deplacement->creer)
$result=$object->setValueFrom('km',GETPOST('km','int')); $result=$object->setValueFrom('km',GETPOST('km','int'));
if ($result < 0) dol_print_error($db, $object->error); 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 * View
*/ */
llxHeader(); llxHeader();

View File

@ -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 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('invoicecard')); $hookmanager->initHooks(array('invoicecard'));
$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
@ -108,6 +110,8 @@ $hookmanager->initHooks(array('invoicecard'));
$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
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) 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']); $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 // Classify to validated
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider)
{ {

View File

@ -45,29 +45,20 @@ $result=restrictedArea($user,'facture',$id,'');
$object = new Facture($db); $object = new Facture($db);
$object->fetch($id); $object->fetch($id);
$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
/******************************************************************************/
/* 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);
}
/******************************************************************************/ /*
/* Affichage fiche */ * Actions
/******************************************************************************/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
/*
* View
*/
llxHeader(); llxHeader();

View File

@ -41,26 +41,15 @@ $result = restrictedArea($user, 'societe', $id, '&societe');
$object = new Contact($db); $object = new Contact($db);
if ($id > 0) $object->fetch($id); if ($id > 0) $object->fetch($id);
$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
/******************************************************************************/ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
/* 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');
}
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 * View

View File

@ -66,11 +66,15 @@ $hookmanager->initHooks(array('contractcard'));
$object = new Contrat($db); $object = new Contrat($db);
$permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * 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) if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer)
{ {
$object->fetch($id); $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 (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer)
{ {
if ($action == 'addcontact') if ($action == 'addcontact')

View File

@ -43,28 +43,20 @@ $result=restrictedArea($user,'contrat',$id);
$object = new Contrat($db); $object = new Contrat($db);
$object->fetch($id,$ref); $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) /*
{ * Actions
$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);
}
else if ($action == 'setnote_private' && $user->rights->contrat->creer) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
{
$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);
}
/******************************************************************************/ /*
/* Affichage fiche */ * View
/******************************************************************************/ */
llxHeader(); llxHeader();

View File

@ -0,0 +1,47 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
* 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');
}
?>

View File

@ -191,10 +191,9 @@ class Form
$ret.='</td>'; $ret.='</td>';
if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker') if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker')
{ {
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">'; $ret.='<td align="left"><input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'">';
// TODO Add a button Cancel $ret.='<br><br>'."\n";
//$ret.='<br><br>'."\n"; $ret.='<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
//$ret.='<input type="submit" class="button" value="'.$langs->trans("Cancel").'">';
$ret.='</td>'; $ret.='</td>';
} }
$ret.='</tr></table>'."\n"; $ret.='</tr></table>'."\n";

View File

@ -53,29 +53,19 @@ $result=restrictedArea($user, $origin, $origin_id);
$object = new Expedition($db); $object = new Expedition($db);
$object->fetch($id); $object->fetch($id);
$permissionnote=$user->rights->expedition->creer; // Used by the include of actions_setnotes.inc.php
/******************************************************************************/
/* 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);
}
/******************************************************************************/ /*
/* Affichage fiche */ * Actions
/******************************************************************************/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
/*
* View
*/
llxHeader(); llxHeader();

View File

@ -88,12 +88,15 @@ if ($id > 0 || ! empty($ref))
if ($ret < 0) dol_print_error('',$object->error); if ($ret < 0) dol_print_error('',$object->error);
} }
$permissionnote=$user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * 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) if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer)
{ {
$result = $object->setValid($user); $result = $object->setValid($user);
@ -399,16 +402,6 @@ else if ($action == 'setdescription' && $user->rights->ficheinter->creer)
$result=$object->set_description($user,GETPOST('description')); $result=$object->set_description($user,GETPOST('description'));
if ($result < 0) dol_print_error($db,$object->error); 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 // Add line
else if ($action == "addline" && $user->rights->ficheinter->creer) else if ($action == "addline" && $user->rights->ficheinter->creer)

View File

@ -41,22 +41,13 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db); $object = new Fichinter($db);
$object->fetch($id,$ref); $object->fetch($id,$ref);
$permissionnote=$user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
if ($action == 'setnote_public' && $user->rights->ficheinter->creer) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
{
$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);
}
/* /*

View File

@ -98,9 +98,15 @@ else if (! empty($socid) && $socid > 0)
if ($ret < 0) dol_print_error($db,$object->error); 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 * 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) if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
{ {
$result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha'));
@ -142,18 +148,6 @@ else if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->
$result = $object->set_remise($user, $_POST['remise_percent']); $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) else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver)
{ {
if (in_array($object->statut, array(1, 5, 6, 7, 9))) if (in_array($object->statut, array(1, 5, 6, 7, 9)))

View File

@ -44,21 +44,14 @@ $result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
$object = new CommandeFournisseur($db); $object = new CommandeFournisseur($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
$permissionnote=$user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
if ($action == 'setnote_public' && $user->rights->fournisseur->commande->creer) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
{
$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);
}
/* /*

View File

@ -82,12 +82,15 @@ if ($id > 0 || ! empty($ref))
$ret=$object->fetch($id, $ref); $ret=$object->fetch($id, $ref);
} }
$permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
@ -237,18 +240,6 @@ elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->factur
$result=$object->update($user); $result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error); 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 // Delete payment
elseif ($action == 'deletepaiement') elseif ($action == 'deletepaiement')

View File

@ -43,22 +43,14 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
$object = new FactureFournisseur($db); $object = new FactureFournisseur($db);
$object->fetch($id, $ref); $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) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
{
$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);
}
// Set label // Set label
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)

View File

@ -47,25 +47,14 @@ $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $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) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
{
$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);
}
/* /*

View File

@ -85,18 +85,7 @@ $permission=($user->rights->projet->creer || $user->rights->projet->all->creer);
* Actions * Actions
*/ */
if ($action == 'setnote_public' && ! empty($permission)) include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';
{
$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);
}
/* /*

View File

@ -40,26 +40,15 @@ $result = restrictedArea($user, 'societe', $id, '&societe');
$object = new Societe($db); $object = new Societe($db);
if ($id > 0) $object->fetch($id); if ($id > 0) $object->fetch($id);
$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
/******************************************************************************/ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
/* 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');
}
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 * View