Works on paypal module
New: add trigger for fee treatment
This commit is contained in:
parent
0b1248bffa
commit
be26c52243
@ -36,12 +36,15 @@ $langs->load('companies');
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
|
||||
$facid=isset($_GET['facid'])?$_GET['facid']:$_POST['facid'];
|
||||
$socname=isset($_GET['socname'])?$_GET['socname']:$_POST['socname'];
|
||||
$action = GETPOST('action');
|
||||
$confirm = GETPOST('confirm');
|
||||
|
||||
$sortfield = isset($_GET['sortfield'])?$_GET['sortfield']:$_POST['sortfield'];
|
||||
$sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder'];
|
||||
$page=isset($_GET['page'])?$_GET['page']:$_POST['page'];
|
||||
$facid = GETPOST('facid');
|
||||
$socname = GETPOST('socname');
|
||||
|
||||
$sortfield = GETPOST('sortfield');
|
||||
$sortorder = GETPOST('sortorder');
|
||||
$page = GETPOST('page');
|
||||
|
||||
$amounts=array();
|
||||
$amountsresttopay=array();
|
||||
@ -59,7 +62,7 @@ if ($user->societe_id > 0)
|
||||
/*
|
||||
* Action add_paiement et confirm_paiement
|
||||
*/
|
||||
if ($_POST['action'] == 'add_paiement' || ($_POST['action'] == 'confirm_paiement' && $_POST['confirm']=='yes'))
|
||||
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
@ -124,12 +127,11 @@ if ($_POST['action'] == 'add_paiement' || ($_POST['action'] == 'confirm_paiement
|
||||
/*
|
||||
* Action add_paiement
|
||||
*/
|
||||
if ($_POST['action'] == 'add_paiement')
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
if ($error)
|
||||
{
|
||||
$_POST['action']='';
|
||||
$_GET['action'] = 'create';
|
||||
$action = 'create';
|
||||
}
|
||||
// Le reste propre a cette action s'affiche en bas de page.
|
||||
}
|
||||
@ -137,7 +139,7 @@ if ($_POST['action'] == 'add_paiement')
|
||||
/*
|
||||
* Action confirm_paiement
|
||||
*/
|
||||
if ($_POST['action'] == 'confirm_paiement' && $_POST['confirm'] == 'yes')
|
||||
if ($action == 'confirm_paiement' && $confirm == 'yes')
|
||||
{
|
||||
$error=0;
|
||||
|
||||
@ -209,7 +211,7 @@ llxHeader();
|
||||
$html=new Form($db);
|
||||
|
||||
|
||||
if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_POST['action'] == 'add_paiement')
|
||||
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
|
||||
{
|
||||
$facture = new Facture($db);
|
||||
$result=$facture->fetch($facid);
|
||||
@ -234,7 +236,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P
|
||||
}
|
||||
|
||||
// Initialize data for confirmation (this is used because data can be change during confirmation)
|
||||
if ($_POST["action"] == 'add_paiement')
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
$i=0;
|
||||
|
||||
@ -311,7 +313,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P
|
||||
{
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans('AmountPayment').'</span></td>';
|
||||
print '<td>';
|
||||
if ($_POST["action"] == 'add_paiement')
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
print '<input id="amountpayment" name="amountpaymenthidden" size="8" type="text" value="'.(empty($_POST['amountpayment'])?'':$_POST['amountpayment']).'" disabled="true">';
|
||||
print '<input name="amountpayment" type="hidden" value="'.(empty($_POST['amountpayment'])?'':$_POST['amountpayment']).'">';
|
||||
@ -554,7 +556,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P
|
||||
$namef = 'amount_'.$objp->facid;
|
||||
|
||||
$namef = 'amount_'.$objp->facid;
|
||||
if ($_POST["action"] != 'add_paiement')
|
||||
if ($action != 'add_paiement')
|
||||
{
|
||||
if (! empty($conf->global->MAIN_JS_ON_PAYMENT))
|
||||
{
|
||||
@ -619,7 +621,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P
|
||||
|
||||
|
||||
// Bouton Enregistrer
|
||||
if ($_POST["action"] != 'add_paiement')
|
||||
if ($action != 'add_paiement')
|
||||
{
|
||||
// print '<tr><td colspan="3" align="center">';
|
||||
print '<center><br><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically");
|
||||
@ -636,7 +638,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P
|
||||
}
|
||||
|
||||
// Form to confirm payment
|
||||
if ($_POST["action"] == 'add_paiement')
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
$preselectedchoice=$addwarning?'no':'yes';
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ class Paiement extends CommonObject
|
||||
var $num_paiement; // Numero du CHQ, VIR, etc...
|
||||
var $bank_account; // Id compte bancaire du paiement
|
||||
var $bank_line; // Id de la ligne d'ecriture bancaire
|
||||
var $fk_account; // Id of bank account
|
||||
var $note;
|
||||
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
|
||||
// fk_paiement dans llx_paiement_facture est le rowid du paiement
|
||||
@ -334,21 +335,22 @@ class Paiement extends CommonObject
|
||||
* @param emetteur_banque Name of bank
|
||||
* @return int <0 if KO, bank_line_id if OK
|
||||
*/
|
||||
function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque)
|
||||
function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque,$notrigger=0)
|
||||
{
|
||||
global $conf;
|
||||
global $conf,$langs,$user;
|
||||
|
||||
$error=0;
|
||||
$bank_line_id=0;
|
||||
$this->fk_account=$accountid;
|
||||
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
|
||||
|
||||
dol_syslog("$user->id,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque");
|
||||
dol_syslog("$user->id,$mode,$label,$this->fk_account,$emetteur_nom,$emetteur_banque");
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$acc->fetch($accountid);
|
||||
$acc->fetch($this->fk_account);
|
||||
|
||||
$totalamount=$this->amount;
|
||||
if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility
|
||||
@ -428,6 +430,16 @@ class Paiement extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('PAYMENT_ADD_TO_BANK',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -360,6 +360,10 @@ class InterfaceDemo
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
elseif ($action == 'PAYMENT_SUPPLIER_CREATE')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
elseif ($action == 'PAYMENT_ADD_TO_BANK')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
|
||||
@ -97,8 +97,17 @@ class InterfacePaypalWorkflow
|
||||
{
|
||||
// Mettre ici le code a executer en reaction de l'action
|
||||
// Les donnees de l'action sont stockees dans $object
|
||||
|
||||
|
||||
|
||||
// Add Paypal fee
|
||||
if ($action == 'PAYMENT_ADD_TO_BANK')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->rowid);
|
||||
|
||||
//var_dump($object);
|
||||
// use num_paiement and fk_account
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user