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
$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)
{

View File

@ -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);
}
/******************************************************************************/

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
$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)
{

View File

@ -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

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
$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 '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">';
$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 '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
$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 "</td></tr>";
// 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);

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
$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)
{

View File

@ -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();

View File

@ -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 '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'id', $linkback);
print '</td></tr>';
// Name
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
// Company
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
{
@ -108,10 +97,10 @@ if ($id > 0)
{
$objsoc = new Societe($db);
$objsoc->fetch($object->socid);
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
}
else
{
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
@ -119,20 +108,20 @@ if ($id > 0)
print '</td></tr>';
}
}
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $object->getCivilityLabel();
print '</td></tr>';
// Date To Birth
print '<tr>';
if (! empty($object->birthday))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.dol_print_date($object->birthday,"day");
print ' &nbsp; ';
//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 ' &nbsp; - &nbsp; ';
if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn");
else print $langs->trans("BirthdayAlertOff");
@ -152,7 +141,7 @@ if ($id > 0)
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.$langs->trans("Unknown")."</td>";
}
print "</tr>";
print "</table>";
print '<br>';

View File

@ -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')

View File

@ -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();

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>';
if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker')
{
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
// TODO Add a button Cancel
//$ret.='<br><br>'."\n";
//$ret.='<input type="submit" class="button" value="'.$langs->trans("Cancel").'">';
$ret.='<td align="left"><input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'">';
$ret.='<br><br>'."\n";
$ret.='<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
$ret.='</td>';
}
$ret.='</tr></table>'."\n";

View File

@ -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();

View File

@ -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 '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
@ -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 '<table class="border" width="100%">';
@ -1286,9 +1279,9 @@ else if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="attribute" value="'.$key.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print $extrafields->showInputField($key,$value);
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}

View File

@ -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
/*

View File

@ -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)))

View File

@ -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
/*

View File

@ -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')

View File

@ -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)

View File

@ -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
/*

View File

@ -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';
/*

View File

@ -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