From 63f2bfed24123dfde67150566a82916c99666330 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Dec 2014 11:19:16 +0100 Subject: [PATCH] Fixed: Maxi debug of withdrawal module. --- htdocs/admin/prelevement.php | 4 +- htdocs/compta/facture/class/facture.class.php | 25 ++++-- htdocs/compta/facture/prelevement.php | 77 ++++++++++++------- .../class/bonprelevement.class.php | 16 ++-- .../class/ligneprelevement.class.php | 6 +- htdocs/compta/prelevement/create.php | 21 +++-- htdocs/compta/prelevement/fiche-stat.php | 3 +- htdocs/compta/prelevement/ligne.php | 2 +- htdocs/compta/prelevement/lignes.php | 8 +- htdocs/compta/prelevement/stats.php | 4 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/withdrawals.lang | 3 +- htdocs/societe/rib.php | 20 +++-- 13 files changed, 124 insertions(+), 67 deletions(-) diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 6094bb7e4f1..3bff5c29118 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * @@ -153,7 +153,7 @@ print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT,'PRELEVEME print ''; // ICS -print ''.$langs->trans("ICS").''; +print ''.$langs->trans("ICS").''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b924b059bfd..cd8ba3b06a1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2837,6 +2837,8 @@ class Facture extends CommonInvoice */ function demande_prelevement($user) { + $error=0; + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); if ($this->statut > 0 && $this->paye == 0) @@ -2882,21 +2884,32 @@ class Facture extends CommonInvoice $sql .= ",'".$bac->cle_rib."')"; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - if ($this->db->query($sql)) + $resql=$this->db->query($sql); + if (! $resql) { - return 1; - } - else - { $this->error=$this->db->lasterror(); dol_syslog(get_class($this).'::demandeprelevement Erreur'); - return -1; + $error++; } + + if (! $error) + { + // Force payment mode of invoice to withdraw + $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement'); + if ($payment_mode_id > 0) + { + $result=$this->setPaymentMethods($payment_mode_id); + } + } + + if ($error) return -1; + return 1; } else { $this->error="A request already exists"; dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); + return 0; } } else diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 48ca10afd2d..1b4f440b461 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -58,6 +58,7 @@ if ($id > 0 || ! empty($ref)) } } + /* * Actions */ @@ -69,14 +70,14 @@ if ($action == "new") $result = $object->demande_prelevement($user); if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; + setEventMessage($langs->trans("RecordSaved")); } else { setEventMessage($object->error, 'errors'); } } + $action=''; } if ($action == "delete") @@ -307,6 +308,31 @@ if ($object->id > 0) print ''; print ''; + // Conditions de reglement + print ''; + print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE) + { + if ($action == 'editconditions') + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); + } + } + else + { + print ' '; + } + print ''; + // Date payment term print ''; print ''; - // Conditions de reglement - print ''; - - // Mode de reglement + // Payment mode print ''; + print ''; print ''; print ''; } @@ -475,10 +481,10 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) } // IBAN - print ''; + print ''; print ''; - print ''; + print ''; print ''; print '
'; @@ -333,32 +359,7 @@ if ($object->id > 0) } print '
'; - print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; - print '
'; - if ($object->type != Facture::TYPE_CREDIT_NOTE) - { - if ($action == 'editconditions') - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); - } - else - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); - } - } - else - { - print ' '; - } - print '
'; print ''; + // Bank Account + print '"; + print ''; + // Montants print ''; print ''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 47ac4d1a390..5da94a28b76 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -56,7 +56,9 @@ class BonPrelevement extends CommonObject var $statut; // 0-Wait, 1-Trans, 2-Done var $labelstatut=array(); + var $invoice_in_error=array(); + /** * Constructor * @@ -835,7 +837,7 @@ class BonPrelevement extends CommonObject else { dol_syslog("Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); - $facture_errors[$fac[0]]="Error on default bank number RIB/IBAN for thirdparty reported by function verif() ".$fact->socid." ".$soc->name; + $this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty (reported by function verif) ".$soc->name; } } else @@ -1814,21 +1816,21 @@ class BonPrelevement extends CommonObject if ($mode == 1) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut0').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut0'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); } if ($mode == 3) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut0'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); } } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 9c4bf96e8b3..581fb3152af 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -138,20 +138,20 @@ class LignePrelevement if ($mode == 1) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); + if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]); if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); + if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1'); if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8'); } if ($mode == 3) { - if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); + if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1'); if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut8'); } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 0326e4922f1..e4cb4b65c30 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -70,6 +70,10 @@ if ($action == 'create') if ($result == 0) { $mesg='
'.$langs->trans("NoInvoiceCouldBeWithdrawed").'
'; + foreach($bprev->invoice_in_error as $key => $val) + { + $mesg.=$val."
\n"; + } } } @@ -179,6 +183,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print ''; print ''; print ''; @@ -190,16 +195,22 @@ if ($resql) { $obj = $db->fetch_object($resql); $var=!$var; - print ''; + print ''; + // Thirdparty print ''; + // RIB + print ''; + // Amount print ''; @@ -211,7 +222,7 @@ if ($resql) $i++; } } - else print ''; + else print ''; print "
'; print $langs->trans('PaymentMode'); @@ -376,6 +377,26 @@ if ($object->id > 0) } print '
'; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print '
'; + if ($action == 'editbankaccount') + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } + else + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print "
'.$langs->trans('AmountHT').''.price($object->total_ht).'
'.$langs->trans("Invoice").''.$langs->trans("ThirdParty").''.$langs->trans("RIB").''.$langs->trans("AmountTTC").''.$langs->trans("DateRequest").'
'; + print '
'; $invoicestatic->id=$obj->rowid; $invoicestatic->ref=$obj->facnumber; print $invoicestatic->getNomUrl(1,'withdraw'); print ''; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - print $thirdpartystatic->getNomUrl(1,'customer'); + $thirdpartystatic->fetch($obj->socid); + print $thirdpartystatic->getNomUrl(1,'card'); print ''; + print $thirdpartystatic->display_rib(); + print ''; print price($obj->total_ttc,0,$langs,0,0,-1,$conf->currency); print '
'.$langs->trans("None").'
'.$langs->trans("None").'
"; print "
\n"; } diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 37b6c708b96..0e9174ef034 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -106,7 +106,6 @@ if ($prev_id) /* * Stats - * */ $ligne=new LignePrelevement($db,$user); @@ -121,6 +120,8 @@ if ($prev_id) $num = $db->num_rows($resql); $i = 0; + print_fiche_titre($langs->trans("StatisticsByLineStatus"),'',''); + print"\n\n"; print ''; print ''; diff --git a/htdocs/compta/prelevement/ligne.php b/htdocs/compta/prelevement/ligne.php index f1617979645..3e7cb5b6bd7 100644 --- a/htdocs/compta/prelevement/ligne.php +++ b/htdocs/compta/prelevement/ligne.php @@ -134,7 +134,7 @@ if ($id) print '
'; print ''; + print $bon->getNomUrl(1).''; print ''; print ''; print ''; diff --git a/htdocs/compta/prelevement/lignes.php b/htdocs/compta/prelevement/lignes.php index 1e96e9276d8..c4724824f36 100644 --- a/htdocs/compta/prelevement/lignes.php +++ b/htdocs/compta/prelevement/lignes.php @@ -124,8 +124,6 @@ $pagenext = $page + 1; /* * Liste des lignes de prelevement - * - * */ $sql = "SELECT pl.rowid, pl.statut, pl.amount"; $sql.= ", s.rowid as socid, s.nom as name"; @@ -175,7 +173,11 @@ if ($result) print substr('000000'.$obj->rowid, -6); print ''; - print '\n"; + $thirdparty=new Societe($db); + $thirdparty->fetch($obj->socid); + print '\n"; print '\n"; diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 2c8607a9a56..c3667f8b69f 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -21,7 +21,7 @@ /** * \file htdocs/compta/prelevement/stats.php * \ingroup prelevement - * \brief Page de stats des prelevements + * \brief Page with statistics on withdrawals */ require('../../main.inc.php'); @@ -96,7 +96,7 @@ if ($resql) print ''; print ''; - $var=True; + $var=false; while ($i < $num) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 29664483d18..e0c1a9152e6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -444,7 +444,7 @@ Module55Desc=Barcode management Module56Name=Telephony Module56Desc=Telephony integration Module57Name=Standing orders -Module57Desc=Standing orders and withdrawal management +Module57Desc=Standing orders and withdrawal management. Also includes generation of SEPA file for european countries. Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index fd4305bbd0b..a0f8078fb18 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -79,10 +79,11 @@ CreditDate=Credit on WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported) ShowWithdraw=Show Withdraw IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one withdrawal payment not yet processed, it won't be set as paid to allow prior withdrawal management. -DoStandingOrdersBeforePayments=This tab allows you to request a standing order. Once it is complete, you can type the payment to close the invoice. +DoStandingOrdersBeforePayments=This tab allows you to request a standing order. Once donee, go into menu Bank->Withdrawal to manage the standing order. When standing order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid" +StatisticsByLineStatus=Statistics by status of lines ### Notifications InfoCreditSubject=Payment of standing order %s by the bank diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 01d82ac0867..ab14d757f6f 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Peter Fontaine * @@ -185,6 +185,7 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') } } + /* * View */ @@ -317,8 +318,13 @@ if ($socid && $action != 'edit' && $action != "create") print '
'.$langs->trans("RIBControlError").'
'; } - print "
"; + print "
"; + + /* + * List of bank accounts + */ + print_titre($langs->trans("AllRIB")); $rib_list = $soc->get_all_rib(); @@ -339,7 +345,7 @@ if ($socid && $action != 'edit' && $action != "create") foreach ($rib_list as $rib) { - print "
"; + print ""; // Label print ''; // Bank name @@ -382,7 +388,7 @@ if ($socid && $action != 'edit' && $action != "create") } if (count($rib_list) == 0) { - print ''; + print ''; } print '
'.$langs->trans("WithdrawalsReceipts").''; - print ''.$lipre->bon_ref.'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($lipre->amount).'
'.$langs->trans("Status").''.$lipre->LibStatut($lipre->statut,1).'
'.$obj->name."'; + print $thirdparty->getNomUrl(1); + print "'.price($obj->amount)."'.$langs->trans("Status").''.$langs->trans("Number").'%'.$langs->trans("Amount").'%
'.$rib->label.'
'.$langs->trans("NoBANRecord").'
'.$langs->trans("NoBANRecord").'
'; @@ -458,7 +464,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) if ($val == 'AccountNumber') { - print '
'.$langs->trans("BankAccountNumber").''.$langs->trans("BankAccountNumber").'
'.$langs->trans("IBAN").'
'.$langs->trans("IBAN").'
'.$langs->trans("BIC").'
'.$langs->trans("BIC").'
'.$langs->trans("BankAccountDomiciliation").'';