Skip to content

Commit

Permalink
Merge pull request #1822 from Devensys/Devlop-PayTotalButton
Browse files Browse the repository at this point in the history
Add button to fill amount paiement
  • Loading branch information
eldy committed Aug 13, 2014
2 parents 52630dc + 49d1983 commit d6c4993
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 40 deletions.
33 changes: 33 additions & 0 deletions htdocs/admin/facture.php
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
* 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
Expand Down Expand Up @@ -261,6 +262,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
Expand Down Expand Up @@ -765,6 +784,20 @@
print "</td></tr>\n";
print '</form>';

// Add js auto fill amount on paiement form
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FAC_AUTO_FILLJS" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';

print '</table>';


Expand Down
46 changes: 11 additions & 35 deletions htdocs/compta/paiement.php
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* 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
Expand Down Expand Up @@ -374,19 +375,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")).trigger("change");
});';
print ' });'."\n";
}
print ' </script>'."\n";
}

Expand All @@ -412,7 +409,6 @@ function callForResult(imgId)
print '<td>'.$langs->trans('Comments').'</td></tr>';

$rowspan=5;
if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) $rowspan++;

// Payment mode
print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
Expand All @@ -438,24 +434,6 @@ function callForResult(imgId)
}
print "</tr>\n";

// Payment amount
if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT))
{
print '<tr><td><span class="fieldrequired">'.$langs->trans('AmountPayment').'</span></td>';
print '<td>';
if ($action == 'add_paiement')
{
print '<input id="amountpayment" name="amountpaymenthidden" size="8" type="text" value="'.(empty($_POST['amountpayment'])?'':$_POST['amountpayment']).'" disabled="disabled">';
print '<input name="amountpayment" type="hidden" value="'.(empty($_POST['amountpayment'])?'':$_POST['amountpayment']).'">';
}
else
{
print '<input id="amountpayment" name="amountpayment" size="8" type="text" value="'.(empty($_POST['amountpayment'])?'':$_POST['amountpayment']).'">';
}
print '</td>';
print '</tr>';
}

// Cheque number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
Expand Down Expand Up @@ -578,10 +556,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 '<input type=hidden name="'.$nameRemain.'" value="'.$remaintopay.'">';
print '<input type="text" size="8" name="'.$namef.'" value="'.$_POST[$namef].'">';
}
Expand Down
19 changes: 16 additions & 3 deletions htdocs/fourn/facture/paiement.php
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* 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
Expand Down Expand Up @@ -328,9 +329,19 @@
{
$i = 0;
print '<br>';

print $langs->trans('Invoices').'<br>';
print '<table class="noborder" width="100%">';

if(!empty($conf->global->FAC_AUTO_FILLJS)){
//Add js for AutoFill
print "\n".'<script type="text/javascript" language="javascript">';
print ' $(document).ready(function () {';
print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
$("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
});';
print ' });'."\n";
print ' </script>'."\n";
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('RefSupplier').'</td>';
Expand Down Expand Up @@ -370,8 +381,10 @@
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
print '<td align="center">';
$namef = 'amount_'.$objp->facid;
if(!empty($conf->global->FAC_AUTO_FILLJS))
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->total_ttc - $objp->am)."'");
print '<input type="text" size="8" name="'.$namef.'" value="'.GETPOST($namef).'">';
print "</td></tr>\n";
print "</td></tr>\n";
$total+=$objp->total_ht;
$total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am;
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/fr_FR/admin.lang
Expand Up @@ -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 ?
Expand Down
3 changes: 1 addition & 2 deletions htdocs/master.inc.php
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* 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
Expand Down Expand Up @@ -244,8 +245,6 @@

if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');

// We force feature to help debug
//$conf->global->MAIN_JS_ON_PAYMENT=0;

// We force FPDF
if (! empty($dolibarr_pdf_force_fpdf)) $conf->global->MAIN_USE_FPDF=$dolibarr_pdf_force_fpdf;
Expand Down

0 comments on commit d6c4993

Please sign in to comment.