From 8ec50fce23543f6a86d7eca38d6fef44d1294f04 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2013 14:26:42 +0100 Subject: [PATCH] Move warning at correct place. Fix: Reset of amount was not working --- htdocs/comm/fiche.php | 8 ++-- htdocs/compta/facture.php | 57 ++++++++++---------------- htdocs/core/class/html.form.class.php | 6 +-- htdocs/langs/en_US/companies.lang | 1 + htdocs/langs/fr_FR/companies.lang | 1 + htdocs/societe/class/societe.class.php | 17 ++++---- 6 files changed, 41 insertions(+), 49 deletions(-) diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 7467aee23b3..1e084406ae0 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2013 Alexandre Spangaro + * Copyright (C) 2013 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -198,7 +198,7 @@ if ($id > 0) print '
'; - + print ''; print ''; } - + // Assujeti a TVA ou pas print ''; print ''; print ''; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c54d6242fce..7e1eb0d7445 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2083,6 +2083,16 @@ if ($action == 'create') print ''; } else @@ -2312,23 +2322,6 @@ if ($action == 'create') print ''; } - // TODO This is nt a roperty of invoice so should not appears here but as a warning on thirdparty - /* - if ($soc->outstanding_limit) - { - $outstandigBills=$soc->get_OutstandingBill(); - // Outstanding Bill - print ''; - print ''; - } - */ - // Other attributes $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -2877,7 +2870,18 @@ else if ($id > 0 || ! empty($ref)) else { print '  '.$soc->getNomUrl(1,'compta'); - print '   ('.$langs->trans('OtherBills').')'; + print '   '; + print '('.$langs->trans('OtherBills').''; + // Outstanding Bill + $outstandigBills=$soc->get_OutstandingBill(); + print ' - '.$langs->trans('CurrentOutstandingBill').': '; + print price($outstandigBills,'',$langs,0,0,-1,$conf->currency); + if ($soc->outstanding_limit != '') + { + if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); + print ' / '.price($soc->outstanding_limit); + } + print ')'; } print ''; @@ -3317,23 +3321,6 @@ else if ($id > 0 || ! empty($ref)) } print ''; - // TODO This is nt a roperty of invoice so should not appears here but as a warning on thirdparty - /* - if ($soc->outstandingbill) - { - $outstandingBills=$soc->get_OutstandingBill(); - // Outstanding Bill - print ''; - print ''; - } - */ - // Amount print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 36c1f838810..f89142fe274 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -136,7 +136,7 @@ class Form // Check parameters if (empty($typeofdata)) return 'ErrorBadParameter'; - + // When option to edit inline is activated if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;|datehourpicker/',$typeofdata)) // FIXME add jquery timepicker { @@ -194,9 +194,9 @@ class Form $ret.=''."\n"; } else - { + { if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); - elseif ($typeofdata == 'amount') $ret.=price($value,'',$langs); + elseif ($typeofdata == 'amount') $ret.=($value != '' ? price($value,'',$langs) : ''); elseif (preg_match('/^text/',$typeofdata) || preg_match('/^note/',$typeofdata)) $ret.=dol_htmlentitiesbr($value); elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); elseif ($typeofdata == 'datehourpicker') $ret.=dol_print_date($value,'dayhour'); diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index f20a3fe01dc..cdf9c3e5770 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -398,6 +398,7 @@ InActivity=Open ActivityCeased=Closed ActivityStateFilter=Activity status ProductsIntoElements=List of products into +CurrentOutstandingBill=Current outstanding bill OutstandingBill=Max. for outstanding bill OutstandingBillReached=Reached max. for outstanding bill # Monkey diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 41840c7b4ad..a25784951d2 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -398,6 +398,7 @@ InActivity=En activité ActivityCeased=Clos ActivityStateFilter=Statut d'activité ProductsIntoElements=Liste des produits dans les %s +CurrentOutstandingBill=Montant encours OutstandingBill=Montant max. en attente OutstandingBillReached=Montant max. endetté # Monkey diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 556bbe97041..66d40e480ba 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2821,24 +2821,27 @@ class Societe extends CommonObject $now=dol_now(); + // Clean parameters $outstanding = price2num($this->outstanding_limit); - // Positionne l'encours de facturaiton + // Set outstanding amount $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " outstanding_limit=".$outstanding; + $sql.= " outstanding_limit= ".($outstanding!=''?$outstanding:'null'); $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_outstanding sql=".$sql); $resql=$this->db->query($sql); - if (! $resql) + if ($resql) + { + $this->db->commit(); + return 1; + } + else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } - - $this->db->commit(); - return 1; } }
'.$langs->trans("ThirdPartyName").''; @@ -272,7 +272,7 @@ if ($id > 0) { print ''.$langs->trans('Skype').''.dol_print_skype($object->skype,0,$object->id,'AC_SKYPE').'
'.$langs->trans('VATIsUsed').''; @@ -389,7 +389,7 @@ if ($id > 0) print ''; print $form->editfieldkey("OutstandingBill",'OutstandingBill',$object->outstanding_limit,$object,$user->rights->societe->creer); print ''; - print $form->editfieldval("OutstandingBill",'OutstandingBill',$object->outstanding_limit,$object,$user->rights->societe->creer,'amount',price($object->outstanding_limit)); + print $form->editfieldval("OutstandingBill",'OutstandingBill',$object->outstanding_limit,$object,$user->rights->societe->creer,'amount',($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); print '
'; print $soc->getNomUrl(1); print ''; + // Outstanding Bill + $outstandigBills=$soc->get_OutstandingBill(); + print ' ('.$langs->trans('CurrentOutstandingBill').': '; + print price($outstandigBills,'',$langs,0,0,-1,$conf->currency); + if ($soc->outstanding_limit != '') + { + if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); + print ' / '.price($soc->outstanding_limit); + } + print ')'; print '
'; - print $langs->trans('OutstandingBill'); - print ''; - print price($outstandigBills); - if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); - print ' / '.price($soc->outstanding_limit); - print '
'; - print $langs->trans('OutstandingBill'); - print ''; - print price($outstandingBills); - if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); - print ' / '.price($soc->outstandingbill); - print '
'.$langs->trans('AmountHT').''.price($object->total_ht,1,'',1,-1,-1,$conf->currency).'