";
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