Fix: add template for view/edit notes in object card and add possibility

to show/hide this bloc
This commit is contained in:
Regis Houssin 2012-03-16 09:39:32 +01:00
parent 245edb8596
commit dae20441d0
5 changed files with 132 additions and 59 deletions

View File

@ -1483,32 +1483,14 @@ if ($id > 0 || ! empty($ref))
// Statut
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans('Notes').'</td></tr>';
// Public note
print '<tr><td valign="top">';
print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea');
print '</td><td colspan="3">';
print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea');
print "</td></tr>";
// Private note
if (! $user->societe_id)
{
print '<tr><td valign="top">';
print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea');
print '</td><td colspan="3">';
print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea');
print "</td></tr>";
}
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
}
print '</table><br>';
/*
* Lines
*/

View File

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

View File

@ -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') : '&nbsp;';
}
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
print dol_htmlcleanlastbr($object->note_public);
print '</td>';
print '</tr>';
// Terms of payment
print '<tr><td height="10">';
@ -1937,9 +1947,14 @@ else
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$object->getLibStatut(4).'</td>';
print '</tr>';
print '</table><br>';
print '</table><br>';
print "\n";
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
}
/*
* Lines

View File

@ -0,0 +1,72 @@
<?php
/* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
$module = $object->element;
if ($module == 'propal') $module = 'propale';
?>
<!-- BEGIN PHP TEMPLATE -->
<script type="text/javascript">
$(document).ready(function() {
$("#hide-notes").click(function(){
setShowHide(1);
$(".notes_line").hide().removeClass("nohideobject");
$(this).hide();
$("#show-notes").show();
});
$("#show-notes").click(function(){
setShowHide(0);
$(".notes_line").show().addClass("nohideobject");
$(this).hide();
$("#hide-notes").show();
});
function setShowHide(status) {
var id = <?php echo $object->id; ?>;
var element = '<?php echo $object->element; ?>';
//$.get("<?php echo dol_buildpath('/core/ajax/showhide.php', 1); ?>?id="+id+"&element="+element+"&status="+status);
}
});
</script>
<table class="border" width="100%">
<tr class="liste_titre">
<td colspan="2">
<div style="float:right;" id="hide-notes" class="linkobject<?php echo ($hide ? ' hideobject' : ''); ?>"><?php echo img_picto('', '1uparrow.png'); ?></div>
<div style="float:right;" id="show-notes" class="linkobject<?php echo ($hide ? '' : ' hideobject'); ?>"><?php echo img_picto('', '1downarrow.png'); ?></div>
<?php echo $langs->trans('Notes'); ?>
</td>
</tr>
<tr id="note_public_line" class="notes_line <?php echo ($hide ? 'hideobject' : 'nohideobject'); ?>">
<td width="25%" valign="top"><?php echo $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->$module->creer,'textarea'); ?></td>
<td><?php echo $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->$module->creer,'textarea'); ?></td>
</tr>
<?php if (! $user->societe_id) { ?>
<tr id="note_private_line" class="notes_line <?php echo ($hide ? 'hideobject' : 'nohideobject'); ?>">
<td width="25%" valign="top"><?php echo $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$user->rights->$module->creer,'textarea'); ?></td>
<td><?php echo $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$user->rights->$module->creer,'textarea'); ?></td>
</tr>
<?php } ?>
</table><br>
<!-- END PHP TEMPLATE -->

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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 @@
<!-- BEGIN PHP TEMPLATE -->
<table class="noborder" style="width: 100%">
<table class="noborder">
<tr class="liste_titre">
<td colspan="2"><?php echo $langs->trans("File"); ?></td>
<td align="center"><?php echo $langs->trans("Version"); ?></td>