From dae20441d07210a1cff127fe5d5c9911050c4bc9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Mar 2012 09:39:32 +0100 Subject: [PATCH] Fix: add template for view/edit notes in object card and add possibility to show/hide this bloc --- htdocs/comm/propal.php | 24 +------ htdocs/commande/class/commande.class.php | 8 ++- htdocs/commande/fiche.php | 83 ++++++++++++++---------- htdocs/core/tpl/notes.tpl.php | 72 ++++++++++++++++++++ htdocs/core/tpl/triggers.tpl.php | 4 +- 5 files changed, 132 insertions(+), 59 deletions(-) create mode 100644 htdocs/core/tpl/notes.tpl.php diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index f7c44c9e1fa..55b3c15afab 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1483,32 +1483,14 @@ if ($id > 0 || ! empty($ref)) // Statut print ''.$langs->trans('Status').''.$object->getLibStatut(4).''; - + + print '
'; if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - print ''.$langs->trans('Notes').''; - - // Public note - print ''; - print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea'); - print ''; - print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea'); - print ""; - - // Private note - if (! $user->societe_id) - { - print ''; - print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea'); - print ''; - print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea'); - print ""; - } + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); } - print '
'; - /* * Lines */ diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2a188fa044e..87274fc46fe 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -83,6 +83,9 @@ class Commande extends CommonObject var $rang; var $special_code; var $source; // Origin of order + var $note; // deprecated + var $note_private; + var $note_public; var $origin; var $origin_id; @@ -1221,7 +1224,7 @@ class Commande extends CommonObject $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee'; - $sql.= ', c.note, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison'; + $sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', ca.code as availability_code'; @@ -1266,7 +1269,8 @@ class Commande extends CommonObject $this->remise_absolue = $obj->remise_absolue; $this->source = $obj->source; $this->facturee = $obj->facturee; - $this->note = $obj->note; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->fk_project = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 8217740f008..7da8907fc78 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -104,7 +104,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Reopen a closed order -if ($action == 'reopen' && $user->rights->commande->creer) +else if ($action == 'reopen' && $user->rights->commande->creer) { $object->fetch($id); if ($object->statut == 3) @@ -123,7 +123,7 @@ if ($action == 'reopen' && $user->rights->commande->creer) } // Suppression de la commande -if ($action == 'confirm_delete' && $confirm == 'yes') +else if ($action == 'confirm_delete' && $confirm == 'yes') { if ($user->rights->commande->supprimer) { @@ -142,7 +142,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') } // Remove a product line -if ($action == 'confirm_deleteline' && $confirm == 'yes') +else if ($action == 'confirm_deleteline' && $confirm == 'yes') { if ($user->rights->commande->creer) { @@ -178,14 +178,14 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes') } // Categorisation dans projet -if ($action == 'classin') +else if ($action == 'classin') { $object->fetch($id); $object->setProject($_POST['projectid']); } // Add order -if ($action == 'add' && $user->rights->commande->creer) +else if ($action == 'add' && $user->rights->commande->creer) { $datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']); @@ -378,26 +378,26 @@ if ($action == 'add' && $user->rights->commande->creer) } -if ($action == 'classifybilled') +else if ($action == 'classifybilled') { $object->fetch($id); $object->classer_facturee(); } // Positionne ref commande client -if ($action == 'set_ref_client' && $user->rights->commande->creer) +else if ($action == 'set_ref_client' && $user->rights->commande->creer) { $object->fetch($id); $object->set_ref_client($user, $_POST['ref_client']); } -if ($action == 'setremise' && $user->rights->commande->creer) +else if ($action == 'setremise' && $user->rights->commande->creer) { $object->fetch($id); $object->set_remise($user, $_POST['remise']); } -if ($action == 'setabsolutediscount' && $user->rights->commande->creer) +else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { if ($_POST["remise_id"]) { @@ -413,7 +413,7 @@ if ($action == 'setabsolutediscount' && $user->rights->commande->creer) } } -if ($action == 'setdate' && $user->rights->commande->creer) +else if ($action == 'setdate' && $user->rights->commande->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $date=dol_mktime(0, 0, 0, $_POST['order_month'], $_POST['order_day'], $_POST['order_year']); @@ -426,7 +426,7 @@ if ($action == 'setdate' && $user->rights->commande->creer) } } -if ($action == 'setdate_livraison' && $user->rights->commande->creer) +else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); @@ -439,50 +439,64 @@ if ($action == 'setdate_livraison' && $user->rights->commande->creer) } } -if ($action == 'setmode' && $user->rights->commande->creer) +else if ($action == 'setmode' && $user->rights->commande->creer) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setavailability' && $user->rights->commande->creer) +else if ($action == 'setavailability' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->availability($_POST['availability_id']); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setdemandreason' && $user->rights->commande->creer) +else if ($action == 'setdemandreason' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->demand_reason($_POST['demand_reason_id']); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setconditions' && $user->rights->commande->creer) +else if ($action == 'setconditions' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setremisepercent' && $user->rights->facture->creer) +else if ($action == 'setremisepercent' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); } -if ($action == 'setremiseabsolue' && $user->rights->facture->creer) +else if ($action == 'setremiseabsolue' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } +else if ($action == 'setnote_public') +{ + $object->fetch($id); + $result=$object->update_note_public(GETPOST('note_public','alpha')); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote') +{ + $object->fetch($id); + $result=$object->update_note(GETPOST('note','alpha')); + if ($result < 0) dol_print_error($db,$object->error); +} + /* * Ajout d'une ligne produit dans la commande */ -if ($action == 'addline' && $user->rights->commande->creer) +else if ($action == 'addline' && $user->rights->commande->creer) { $result=0; @@ -667,7 +681,7 @@ if ($action == 'addline' && $user->rights->commande->creer) /* * Mise a jour d'une ligne dans la commande */ -if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save')) +else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save')) { if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -767,13 +781,13 @@ if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] } } -if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) +else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) { Header('Location: fiche.php?id='.$id); // Pour reaffichage de la fiche en cours d'edition exit; } -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { $idwarehouse=GETPOST('idwarehouse'); @@ -812,7 +826,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->command } // Go back to draft status -if ($action == 'confirm_modif' && $user->rights->commande->creer) +else if ($action == 'confirm_modif' && $user->rights->commande->creer) { $idwarehouse=GETPOST('idwarehouse'); @@ -854,7 +868,7 @@ if ($action == 'confirm_modif' && $user->rights->commande->creer) } } -if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer) +else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer) { $object->fetch($id); // Load order and lines @@ -862,7 +876,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande-> if ($result < 0) $mesgs=$object->errors; } -if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) +else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { $idwarehouse=GETPOST('idwarehouse'); @@ -891,7 +905,7 @@ if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande- * Ordonnancement des lignes */ -if ($action == 'up' && $user->rights->commande->creer) +else if ($action == 'up' && $user->rights->commande->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -914,7 +928,7 @@ if ($action == 'up' && $user->rights->commande->creer) exit; } -if ($action == 'down' && $user->rights->commande->creer) +else if ($action == 'down' && $user->rights->commande->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -936,7 +950,7 @@ if ($action == 'down' && $user->rights->commande->creer) exit; } -if ($action == 'builddoc') // In get or post +else if ($action == 'builddoc') // In get or post { /* * Generate order document @@ -976,7 +990,7 @@ if ($action == 'builddoc') // In get or post } // Remove file in doc form -if ($action == 'remove_file') +else if ($action == 'remove_file') { if ($object->fetch($id)) { @@ -1783,10 +1797,6 @@ else print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : ' '; } print ''; - print ''.$langs->trans('NotePublic').' :
'; - print dol_htmlcleanlastbr($object->note_public); - print ''; - print ''; // Terms of payment print ''; @@ -1937,9 +1947,14 @@ else print ''.$langs->trans('Status').''; print ''.$object->getLibStatut(4).''; print ''; - - print '
'; + + print '
'; print "\n"; + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + } /* * Lines diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php new file mode 100644 index 00000000000..7caa1ee1495 --- /dev/null +++ b/htdocs/core/tpl/notes.tpl.php @@ -0,0 +1,72 @@ + + * + * 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 2 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 . + * + */ + +$module = $object->element; +if ($module == 'propal') $module = 'propale'; + +?> + + + + + + + + + + + + + + + + + societe_id) { ?> + + + + + + +
+
+
+ trans('Notes'); ?> +
editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->$module->creer,'textarea'); ?>editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->$module->creer,'textarea'); ?>
editfieldkey("NotePrivate",'note',$object->note_private,$object,$user->rights->$module->creer,'textarea'); ?>editfieldval("NotePrivate",'note',$object->note_private,$object,$user->rights->$module->creer,'textarea'); ?>

+ + \ No newline at end of file diff --git a/htdocs/core/tpl/triggers.tpl.php b/htdocs/core/tpl/triggers.tpl.php index c72b6cdf41d..3faace1bfec 100644 --- a/htdocs/core/tpl/triggers.tpl.php +++ b/htdocs/core/tpl/triggers.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2012 Regis Houssin * * 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 @@ -19,7 +19,7 @@ - +
trans("File"); ?> trans("Version"); ?>