From 153997432fbabb6bbafe22708099efae5354d5b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Oct 2012 17:00:38 +0200 Subject: [PATCH] Fix: Several fix. New: Also allow to enter a payment with a negative value on an invoice and positive onto other. --- htdocs/comm/fiche.php | 20 +++++++++++-------- htdocs/comm/propal/list.php | 1 + htdocs/commande/liste.php | 9 +++++---- htdocs/compta/facture/list.php | 3 ++- htdocs/compta/paiement.php | 9 ++++++--- .../compta/paiement/class/paiement.class.php | 9 +++++++-- htdocs/compta/resultat/index.php | 4 ++-- htdocs/core/class/html.form.class.php | 8 ++++---- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index b17b15d3ff9..5680cfb676c 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -502,11 +502,11 @@ if ($id > 0) $sql2.= ' AND s.rowid = '.$object->id; // Show orders with status validated, shipping started and delivered (well any order we can bill) $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - + $resql2=$db->query($sql2); $orders2invoice = $db->num_rows($resql2); $db->free($resql2); - + print ''; print ''; @@ -776,14 +776,18 @@ if ($id > 0) { if ($user->rights->facture->creer) { - $langs->load("bills"); - - if($orders2invoice > 0) print ''.$langs->trans("CreateInvoiceForThisCustomer").''; - else print ''.$langs->trans("CreateInvoiceForThisCustomer").''; - + $langs->load("bills"); + $langs->load("orders"); + + if (! empty($conf->commande->enabled)) + { + if($orders2invoice > 0) print ''.$langs->trans("CreateInvoiceForThisCustomer").''; + else print ''.$langs->trans("CreateInvoiceForThisCustomer").''; + } + if ($object->client != 0) print ''.$langs->trans("AddBill").''; else print ''.$langs->trans("AddBill").''; - + } else { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 8603f0a7394..96d8db20da1 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -234,6 +234,7 @@ if ($result) // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { + $langs->load("commercial"); $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); $moreforfilter.='       '; diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 89641178ab4..dd7c7484666 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -250,7 +250,8 @@ if ($resql) // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; + $langs->load("commercial"); + $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); $moreforfilter.='       '; } @@ -329,16 +330,16 @@ if ($resql) print ''; - print '';
'; print $companystatic->getNomUrl(1,'customer'); print ' '; - + // If module invoices enabled and user with invoice creation permissions if (! empty($conf->facture->enabled)) { if ($user->rights->facture->creer) { - + if (($objp->fk_statut > 0 && $objp->fk_statut < 3) || ($objp->fk_statut == 3 && $objp->facturee == 0)) { - + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->nom,'object_bill').''; } } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 9d668723f34..937b37be6c2 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -256,7 +256,8 @@ if ($resql) $moreforfilter=''; if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; + $langs->load("commercial"); + $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); $moreforfilter.='       '; } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 0ebe94d2d8a..4fbc531707f 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -68,6 +68,8 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye $datepaye = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $paiement_id = 0; + $totalpaiement = 0; + $atleastonepaymentnotnull = 0; // Verifie si des paiements sont superieurs au montant facture foreach ($_POST as $key => $value) @@ -77,6 +79,7 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye $cursorfacid = substr($key,7); $amounts[$cursorfacid] = price2num(trim($_POST[$key])); $totalpaiement = $totalpaiement + $amounts[$cursorfacid]; + if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; $tmpfacture=new Facture($db); $tmpfacture->fetch($cursorfacid); $amountsresttopay[$cursorfacid]=price2num($tmpfacture->total_ttc-$tmpfacture->getSommePaiement()); @@ -108,7 +111,7 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye } } - if ($totalpaiement == 0) + if (empty($totalpaiement) && empty($atleastonepaymentnotnull)) { $fiche_erreur_message = '
'.$langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')).'
'; $error++; @@ -154,8 +157,8 @@ if ($action == 'confirm_paiement' && $confirm == 'yes') if (! $error) { - $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); - if ($paiement_id < 0) + $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); + if ($paiement_id < 0) { $errmsg=$paiement->error; $error++; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 3d23f896c0e..e3daaaf119b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -137,17 +137,22 @@ class Paiement extends CommonObject // Clean parameters $totalamount = 0; + $atleastonepaymentnotnull = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch { $newvalue = price2num($value,'MT'); $this->amounts[$key] = $newvalue; $totalamount += $newvalue; + if (! empty($newvalue)) $atleastonepaymentnotnull++; } $totalamount = price2num($totalamount); // Check parameters - if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null - + if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays + { + $this->error='TotalAmountEmpty'; + return -1; + } $this->db->begin(); diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index e423136b7ee..5b3b2fe05d1 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -506,7 +506,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) print '
 '; if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) { - print ''.price(price2num($decaiss_ttc[$case],'MT')).''; + print ''.price(price2num($decaiss_ttc[$case],'MT')).''; if (! isset($totsorties[$annee])) $totsorties[$annee]=0; $totsorties[$annee]+=$decaiss_ttc[$case]; } @@ -515,7 +515,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) print ' '; if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0) { - print ''.price(price2num($encaiss_ttc[$case],'MT')).''; + print ''.price(price2num($encaiss_ttc[$case],'MT')).''; if (! isset($totentrees[$annee])) $totentrees[$annee]=0; $totentrees[$annee]+=$encaiss_ttc[$case]; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fa53b19a2fb..cab56780ed8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2732,12 +2732,12 @@ class Form if ($filter) $newfilter.=' AND ('.$filter.')'; $nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue); print ''; + print ''; if ($nbqualifiedlines > 0) { - print '   '; + print '   '; } if ($more) print $more; print '