New: Can edit payment note

This commit is contained in:
Laurent Destailleur 2011-03-06 17:03:27 +00:00
parent 3da46d4961
commit 8a852ca4d2
4 changed files with 63 additions and 33 deletions

View File

@ -5,6 +5,7 @@ $Id$
***** ChangeLog for 3.1 compared to 3.0 *****
For users:
- New: Can edit note of payment.
- New: Login is not mandatory in member module.
- New: Reduce a step into supplier order workflow to save time (if user
has permission to approve, order is approved when order is validated).

View File

@ -24,12 +24,13 @@
* \brief File of class to manage payments of customers invoices
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
/** \class Paiement
* \brief Classe permettant la gestion des paiements des factures clients
*/
class Paiement
class Paiement extends CommonObject
{
var $db;
var $error;
@ -65,9 +66,9 @@ class Paiement
}
/**
* \brief Recupere l'objet paiement
* \param id id du paiement a recuperer
* \return int <0 si ko, 0 si non trouve, >0 si ok
* Load payment from database
* @param id id of payment to get
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function fetch($id)
{
@ -216,10 +217,10 @@ class Paiement
/**
* \brief Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
* Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
* Si le paiement porte sur au moins une facture a "payee", on refuse
* \return int <0 si ko, >0 si ok
* Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
* Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
* Si le paiement porte sur au moins une facture a "payee", on refuse
* @return int <0 si ko, >0 si ok
*/
function delete()
{

View File

@ -38,8 +38,8 @@ $langs->load('banks');
$langs->load('companies');
// Security check
$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
$id=GETPOST("id");
$action=GETPOST("action");
if ($user->societe_id) $socid=$user->societe_id;
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
@ -51,12 +51,31 @@ $mesg='';
* Actions
*/
if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->paiement)
if ($action == 'setnote' && $user->rights->facture->paiement)
{
$db->begin();
$paiement = new Paiement($db);
$paiement->fetch($id);
$result = $paiement->update_note(GETPOST('note'));
if ($result > 0)
{
$db->commit();
$action='';
}
else
{
$mesg='<div class="error">'.$paiement->error.'</div>';
$db->rollback();
}
}
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->facture->paiement)
{
$db->begin();
$paiement = new Paiement($db);
$paiement->fetch($_GET['id']);
$paiement->fetch($id);
$result = $paiement->delete();
if ($result > 0)
{
@ -71,12 +90,12 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' &&
}
}
if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->paiement)
if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights->facture->paiement)
{
$db->begin();
$paiement = new Paiement($db);
$paiement->id = $_GET['id'];
$paiement->fetch($id);
if ($paiement->valide() > 0)
{
$db->commit();
@ -117,10 +136,10 @@ llxHeader();
$thirdpartystatic=new Societe($db);
$paiement = new Paiement($db);
$result=$paiement->fetch($_GET['id']);
$result=$paiement->fetch($id);
if ($result <= 0)
{
dol_print_error($db,'Payement '.$_GET['id'].' not found in database');
dol_print_error($db,'Payement '.$id.' not found in database');
exit;
}
@ -128,12 +147,12 @@ $html = new Form($db);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$_GET["id"];
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$id;
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"];
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$id;
$head[$h][1] = $langs->trans("Info");
$h++;
@ -143,7 +162,7 @@ dol_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice"), 0, 'p
/*
* Confirmation de la suppression du paiement
*/
if ($_GET['action'] == 'delete')
if ($action == 'delete')
{
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
if ($ret == 'html') print '<br>';
@ -152,7 +171,7 @@ if ($_GET['action'] == 'delete')
/*
* Confirmation de la validation du paiement
*/
if ($_GET['action'] == 'valide')
if ($action == 'valide')
{
$facid = $_GET['facid'];
$ret=$html->form_confirm('fiche.php?id='.$paiement->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
@ -186,7 +205,9 @@ print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.pr
// Note
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
print '<tr><td valign="top">'.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement).'</td><td colspan="3">';
print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement,'text');
print '</td></tr>';
// Bank account
if ($conf->banque->enabled)
@ -305,18 +326,18 @@ if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
{
if ($user->rights->facture->paiement)
{
print '<a class="butAction" href="fiche.php?id='.$_GET['id'].'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
}
}
}
if ($user->societe_id == 0 && $_GET['action'] == '')
if ($user->societe_id == 0 && $action == '')
{
if ($user->rights->facture->paiement)
{
if (! $disable_delete)
{
print '<a class="butActionDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
else
{

View File

@ -85,14 +85,14 @@ class Form
}
/**
* \brief Output val field for an editable field
* \param text Text of label (not used in this function)
* \param htmlname Name of select field
* \param preselected Preselected value for parameter
* \param paramkey Key of parameter (unique if there is several parameter to show)
* \param perm Permission to allow button to edit parameter
* \param typeofdata Type of data (string by default, email, ...)
* \return string HTML edit field
* Output val field for an editable field
* @param text Text of label (not used in this function)
* @param htmlname Name of select field
* @param preselected Preselected value for parameter
* @param paramkey Key of parameter (unique if there is several parameter to show)
* @param perm Permission to allow button to edit parameter
* @param typeofdata Type of data ('string' by default, 'email', 'text', ...)
* @return string HTML edit field
*/
function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string')
{
@ -107,7 +107,14 @@ class Form
$ret.='<input type="hidden" name="'.$paramkey.'" value="'.$paramvalue.'">';
$ret.='<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
$ret.='<tr><td>';
$ret.='<input type="text" name="'.$htmlname.'" value="'.$preselected.'">';
if (in_array($typeofdata,array('string','email')))
{
$ret.='<input type="text" name="'.$htmlname.'" value="'.$preselected.'">';
}
else if ($typeofdata == 'text')
{
$ret.='<textarea name="'.$htmlname.'">'.$preselected.'</textarea>';
}
$ret.='</td>';
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
$ret.='</tr></table>'."\n";