From 1747533bc2134cc418957eaed13553467c08f284 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sun, 1 Jun 2008 19:19:00 +0000 Subject: [PATCH] Added payment num and date edition feature / draft payment for payments of provider invoices --- htdocs/fourn/facture/paiementfourn.class.php | 55 ++++++++++ htdocs/fourn/paiement/fiche.php | 103 ++++++++++++++++--- htdocs/langs/en_US/banks.lang | 4 + htdocs/langs/es_ES/banks.lang | 4 + htdocs/langs/fr_FR/banks.lang | 4 + 5 files changed, 158 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index 6d6a63049ac..4c2af51ef7e 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -49,6 +49,7 @@ class PaiementFourn var $bank_account; // Id compte bancaire du paiement var $bank_line; // Id de la ligne d'�criture bancaire var $note; + var $statut; //Status of payment. 0 = unvalidated; 1 = validated // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) // fk_paiement dans llx_paiement_facture est le rowid du paiement @@ -486,5 +487,59 @@ class PaiementFourn if ($withpicto != 2) $result.=$lien.$this->rowid.$lienfin; return $result; } + /** + * \brief Updates the payment number + * \param string New num + * \return int -1 on error, 0 otherwise + */ + function update_num($num) + { + if(!empty($num) && $this->statut!=1) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET num_paiement = \''.$this->db->escape($num).'\' WHERE rowid = '.$this->id; + + dolibarr_syslog("PaiementFourn::update_num sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->numero = $this->db->escape($num); + return 0; + } + else + { + $this->error='PaiementFourn::update_num Error -1 '.$this->db->error(); + dolibarr_syslog('PaiementFourn::update_num error '.$this->error); + return -1; + } + } + return -1; //no num given or already validated + } + /** + * \brief Updates the payment date + * \param string New date + * \return int -1 on error, 0 otherwise + */ + function update_date($date) + { + if(!empty($date) && $this->statut!=1) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET datep = '.$this->db->idate($date).' WHERE rowid = '.$this->id; + dolibarr_syslog("PaiementFourn::update_date sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->datepaye = $date; + $this-> date = $date; + return 0; + } + else + { + $this->error='PaiementFourn::update_date Error -1 '.$this->db->error(); + dolibarr_syslog('PaiementFourn::update_date error '.$this->error); + return -1; + } + } + return -1; //no date given or already validated + } } ?> diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php index a2221a05b8b..6ae1f1a21ab 100644 --- a/htdocs/fourn/paiement/fiche.php +++ b/htdocs/fourn/paiement/fiche.php @@ -115,7 +115,7 @@ dolibarr_fiche_head($head, $hselected, $langs->trans('SupplierPayment')); if ($_GET['action'] == 'delete') { $html->form_confirm('fiche.php?id='.$paiement->id, 'Supprimer le paiement', 'Etes-vous sûr de vouloir supprimer ce paiement ?', 'confirm_delete'); - print '
'; + print '
'; } /* @@ -124,17 +124,40 @@ if ($_GET['action'] == 'delete') if ($_GET['action'] == 'valide') { $html->form_confirm('fiche.php?id='.$paiement->id, 'Valider le paiement', 'Etes-vous sûr de vouloir valider ce paiment, auncune modification n\'est possible une fois le paiement validé ?', 'confirm_valide'); - print '
'; + print '
'; } +if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num'])) +{ + $res = $paiement->update_num($_POST['new_num']); + if ($res === 0) { + $mesg = $langs->trans('PaymentNumberUpdateSucceeded'); + } else { + $mesg = $langs->trans('PaymentNumberUpdateFailed'); + } +} -if ($mesg) print $mesg.'
'; +if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday'])) +{ + $datepaye = dolibarr_mktime(12, 0 , 0, + $_POST['remonth'], + $_POST['reday'], + $_POST['reyear']); + $res = $paiement->update_date($datepaye); + if ($res === 0) { + $mesg = $langs->trans('PaymentDateUpdateSucceeded'); + } else { + $mesg = $langs->trans('PaymentDateUpdateFailed'); + } +} + +if ($mesg) print $mesg.'
'; print ''; print ''; -print ''; +print ''; if ($conf->banque->enabled) { if ($paiement->bank_account) @@ -147,21 +170,77 @@ if ($conf->banque->enabled) $bankline->fetch($paiement->bank_line); print ''; - print ''; + print ''; print ''; print ''; print ''; } } -print ''; -print ''; +//switch through edition options for date (only available when statut is -not 1- (=validated)) +if($paiement->statut == 0) +{ + if(empty($_GET['action']) or $_GET['action']!='edit_date') + { + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } +} +else +{ + print ''; + print ''; +} +print ''; +//switch through edition options for number (only available when statut is -not 1- (=validated)) if ($paiement->numero) { - print ''; + if ($paiement->statut == 0) + { + if(empty($_GET['action']) or $_GET['action'] != 'edit_num') + { + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } + } + else + { + print ''; + print ''; + } } -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print '
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('BankAccount').''.$langs->trans('BankAccount').''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.''.$langs->trans('BankLineConciliated').''.yn($bankline->rappro).'
'.$langs->trans('Date').''.dolibarr_print_date($paiement->date).'
'.$langs->trans('Type').''.$paiement->type_libelle.'
'.$langs->trans('Date').''.img_edit().''.dolibarr_print_date($paiement->date).'
'.$langs->trans('Date').''; + if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear'])) + $sel_date=mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + else + $sel_date=$paiement->date; + $html->select_date($sel_date,'','','','',"addpaiement"); + print ''; + print '
'.$langs->trans('Date').''.dolibarr_print_date($paiement->date).'
'.$langs->trans('Type').''.$paiement->type_libelle.'
'.$langs->trans('Numero').''.$paiement->numero.'
'.$langs->trans('Numero').''.img_edit().''.$paiement->numero.'
'.$langs->trans('Date').''; + if (!empty($_POST['new_num'])) + $num = $this->db->escape($_POST['new_num']); + else + $num = $paiement->numero; + print ''; + print ''; + print '
'.$langs->trans('Numero').''.$paiement->numero.'
'.$langs->trans('Amount').''.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.$paiement->getLibStatut(4).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'.$langs->trans('Amount').''.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.$paiement->getLibStatut(4).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'; @@ -180,7 +259,7 @@ if ($resql) $i = 0; $total = 0; - print '
'.$langs->trans("Invoices").'
'; + print '
'.$langs->trans("Invoices").'
'; print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 02ac98a760d..951c76e2711 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -115,3 +115,7 @@ CashBudget=Cash budget ExportDataset_banque_1=Bank transactions and account statement TransactionOnTheOtherAccount=Transaction on the other account TransactionWithOtherAccount=Account transfert +PaymentNumberUpdateSucceeded=Payment number updated succesfully +PaymentNumberUpdateFailed=Payment number could not be updated +PaymentDateUpdateSucceeded=Payment date update succesfully +PaymentDateUpdateFailed=Payment date could not be updated \ No newline at end of file diff --git a/htdocs/langs/es_ES/banks.lang b/htdocs/langs/es_ES/banks.lang index 19a08667e53..a161dfc1b37 100644 --- a/htdocs/langs/es_ES/banks.lang +++ b/htdocs/langs/es_ES/banks.lang @@ -116,3 +116,7 @@ CashBudget=Presupuesto de tesorer ExportDataset_banque_1=Transacción bancaria y extracto TransactionOnTheOtherAccount=Transacción sobre la otra cuenta TransactionWithOtherAccount=Transferencia de cuenta +PaymentNumberUpdateSucceeded=Numero de pago modificado +PaymentNumberUpdateFailed=Numero de pago no pudo ser modificado +PaymentDateUpdateSucceeded=Fecha de pago modificada +PaymentDateUpdateFailed=Fecha de pago no pudo ser modificada \ No newline at end of file diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 599fc13ad5a..8a570276b8c 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -115,3 +115,7 @@ CashBudget=Budget de tr ExportDataset_banque_1=Transaction bancaire et relevé TransactionOnTheOtherAccount=Transaction sur l'autre compte TransactionWithOtherAccount=Transfert de compte +PaymentNumberUpdateSucceeded=Numéro de paiement mis à jour +PaymentNumberUpdateFailed=Impossible de mettre le numéro de paiement à jour +PaymentDateUpdateSucceeded=Date de paiement mise à jour +PaymentDateUpdateFailed=Impossible de mettre la date de paiement à jour \ No newline at end of file
'.$langs->trans('Ref').'