diff --git a/ChangeLog b/ChangeLog index ab698d84eb8..bde4f7417b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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). diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 67446d51795..31342f17436 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -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() { diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 03d266e6d29..68883cb500c 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -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='
'.$paiement->error.'
'; + $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 '
'; @@ -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.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); @@ -186,7 +205,9 @@ print ''.$langs->trans('Amount').''.pr // Note -print ''.$langs->trans('Note').''.nl2br($paiement->note).''; +print ''.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement).''; +print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement,'text'); +print ''; // Bank account if ($conf->banque->enabled) @@ -305,18 +326,18 @@ if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) { if ($user->rights->facture->paiement) { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } } } -if ($user->societe_id == 0 && $_GET['action'] == '') +if ($user->societe_id == 0 && $action == '') { if ($user->rights->facture->paiement) { if (! $disable_delete) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4fe38c99f04..cffc99c96a2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -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.=''; $ret.=''; $ret.=''; $ret.=''; $ret.='
'; - $ret.=''; + if (in_array($typeofdata,array('string','email'))) + { + $ret.=''; + } + else if ($typeofdata == 'text') + { + $ret.=''; + } $ret.='
'."\n";