From 3548f72d8ab1f33c5a88e465b43df76cdf5e5e6e Mon Sep 17 00:00:00 2001 From: Andrelec1 Date: Mon, 11 Aug 2014 18:14:40 +0200 Subject: [PATCH 1/3] Start implement --- htdocs/admin/facture.php | 32 +++++++++++++++++++++++++++++++ htdocs/fourn/facture/paiement.php | 19 +++++++++++++++--- htdocs/langs/fr_FR/admin.lang | 1 + 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 54bae759647db..e77d10d9ee78b 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -261,6 +261,24 @@ } } +if ($action == 'set_FAC_AUTO_FILLJS') +{ + $freetext = GETPOST('FAC_AUTO_FILLJS'); // No alpha here, we want exact string + + $res = dolibarr_set_const($db, "FAC_AUTO_FILLJS",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + /* * View @@ -765,6 +783,20 @@ print "\n"; print ''; +// Add js auto fill amount on paiement form +$var=! $var; +print '
'; +print ''; +print ''; +print ''; +print $langs->trans("JSOnPaimentBill"); +print ''; +print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1); +print ''; +print ''; +print "\n"; +print '
'; + print ''; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 5e7658d25b0e0..953348dbb4902 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * * 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 @@ -328,9 +329,19 @@ { $i = 0; print '
'; - print $langs->trans('Invoices').'
'; - print ''; + + if(!empty($conf->global->FAC_AUTO_FILLJS)){ + //Addjs for AutoFill + print "\n".''."\n"; + } + print '
'; print ''; print ''; print ''; @@ -370,8 +381,10 @@ print ''; print '\n"; + print "\n"; $total+=$objp->total_ht; $total_ttc+=$objp->total_ttc; $totalrecu+=$objp->am; diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 1624a8222bd8c..31996a4a74c78 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1075,6 +1075,7 @@ NotificationsDesc=La fonction des notifications par emails permet d'envoyer auto ModelModules=Modèle de documents DocumentModelOdt=Génération depuis des modèles OpenDocument (Fichier .ODT ou .ODS OpenOffice, KOffice, TextEdit…) WatermarkOnDraft=Filigrane sur les documents brouillons +JSOnPaimentBill=Ajout surcouche js CompanyIdProfChecker=Règles sur les Identifiants professionnels MustBeUnique=Doit être unique ? MustBeMandatory=Obligatoire pour creer tiers ? From 1ce4996a345e92970c0ab4c74d37856cc9e16c71 Mon Sep 17 00:00:00 2001 From: Andrelec1 Date: Tue, 12 Aug 2014 11:34:53 +0200 Subject: [PATCH 2/3] finish implement remove old code and add new one ... --- htdocs/compta/paiement.php | 45 +++++++------------------------ htdocs/fourn/facture/paiement.php | 4 +-- htdocs/master.inc.php | 2 -- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 008721ef0182e..5a36fc9139012 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -374,19 +374,15 @@ function callForResult(imgId) }); '; - // Add user helper to input amount on invoices - if (! empty($conf->global->MAIN_JS_ON_PAYMENT) && $facture->type != 2) - { - print ' $("#payment_form").find("img").click(function() { - callForResult(jQuery(this).attr("id")); - }); - - $("#amountpayment").change(function() { - callForResult(); - });'; - } - print ' });'."\n"; + if(!empty($conf->global->FAC_AUTO_FILLJS)){ + //Add js for AutoFill + print ' $(document).ready(function () {'; + print ' $(".AutoFillAmout").on(\'click touchstart\', function(){ + $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")); + });'; + print ' });'."\n"; + } print ' '."\n"; } @@ -412,7 +408,6 @@ function callForResult(imgId) print ''; $rowspan=5; - if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) $rowspan++; // Payment mode print '\n"; - // Payment amount - if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) - { - print ''; - print ''; - print ''; - } - // Cheque number print '
'.$langs->trans('Ref').''.$langs->trans('RefSupplier').''.price($objp->total_ttc - $objp->am).''; $namef = 'amount_'.$objp->facid; + if(!empty($conf->global->FAC_AUTO_FILLJS)) + print img_picto("Auto fill",'1rightarrow_selected', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->total_ttc - $objp->am)."'"); // TODO ADD lang print ''; - print "
'.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; @@ -438,24 +433,6 @@ function callForResult(imgId) } print "
'.$langs->trans('AmountPayment').''; - if ($action == 'add_paiement') - { - print ''; - print ''; - } - else - { - print ''; - } - print '
'.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; @@ -578,10 +555,8 @@ function callForResult(imgId) if ($action != 'add_paiement') { - if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) - { - print img_picto($langs->trans('AddRemind'),'rightarrow.png','id="'.$objp->facid.'"'); - } + if(!empty($conf->global->FAC_AUTO_FILLJS)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); print ''; print ''; } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 953348dbb4902..bc208421fce40 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -332,7 +332,7 @@ print $langs->trans('Invoices').'
'; if(!empty($conf->global->FAC_AUTO_FILLJS)){ - //Addjs for AutoFill + //Add js for AutoFill print "\n".'