Fix: more compatibility with multicompany
This commit is contained in:
parent
1726720d16
commit
b9b2dbe9b1
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2011-2012 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
|
||||
@ -102,35 +102,48 @@ class InterfacePaypalWorkflow
|
||||
if ($action == 'PAYPAL_PAYMENT_OK')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object->source." ref=".$object->ref);
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $path = $filename = $object->source;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
|
||||
{
|
||||
$element = $path = $regs[1];
|
||||
$filename = $regs[2];
|
||||
}
|
||||
// For compatibility
|
||||
if ($element == 'order') { $path = $filename = 'commande'; }
|
||||
if ($element == 'invoice') { $path = 'compta/facture'; $filename = 'facture'; }
|
||||
|
||||
dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
|
||||
|
||||
$classname = ucfirst($filename);
|
||||
$obj = new $classname($this->db);
|
||||
|
||||
$ret = $obj->fetch('',$object->ref);
|
||||
if ($ret < 0) return -1;
|
||||
|
||||
// Add payer id
|
||||
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
|
||||
|
||||
// Add transaction id
|
||||
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
|
||||
|
||||
if ($object->source == 'membersubscription')
|
||||
{
|
||||
//require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherents.class.php");
|
||||
|
||||
// TODO add subscription treatment
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $path = $filename = $object->source;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
|
||||
{
|
||||
$element = $path = $regs[1];
|
||||
$filename = $regs[2];
|
||||
}
|
||||
// For compatibility
|
||||
if ($element == 'order') {
|
||||
$path = $filename = 'commande';
|
||||
}
|
||||
if ($element == 'invoice') {
|
||||
$path = 'compta/facture'; $filename = 'facture';
|
||||
}
|
||||
|
||||
dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
|
||||
|
||||
$classname = ucfirst($filename);
|
||||
$obj = new $classname($this->db);
|
||||
|
||||
$ret = $obj->fetch('',$object->ref);
|
||||
if ($ret < 0) return -1;
|
||||
|
||||
// Add payer id
|
||||
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
|
||||
|
||||
// Add transaction id
|
||||
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -274,12 +274,18 @@ if ($action == 'add')
|
||||
$urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref;
|
||||
if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount'));
|
||||
if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email'));
|
||||
if (! empty($entity)) $urlback.='&entity='.$entity;
|
||||
}
|
||||
else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal')
|
||||
{
|
||||
$urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref;
|
||||
if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount'));
|
||||
if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email'));
|
||||
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
|
||||
{
|
||||
$urlback.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2);
|
||||
}
|
||||
if (! empty($entity)) $urlback.='&entity='.$entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -368,7 +374,7 @@ jQuery(document).ready(function () {
|
||||
// Print form
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" / >';
|
||||
print '<input type="hidden" name="entity" value"'.$entity.'" />';
|
||||
print '<input type="hidden" name="entity" value="'.$entity.'" />';
|
||||
print '<input type="hidden" name="action" value="add" />';
|
||||
|
||||
print '<div id="divsubscribe">';
|
||||
|
||||
@ -27,6 +27,13 @@
|
||||
define("NOLOGIN",1); // This means this output page does not require to be logged.
|
||||
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
||||
|
||||
// For MultiCompany module
|
||||
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
|
||||
if (is_int($entity))
|
||||
{
|
||||
define("DOLENTITY", $entity);
|
||||
}
|
||||
|
||||
require("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
|
||||
@ -113,6 +120,11 @@ if (! empty($SECUREKEY))
|
||||
$urlok.='securekey='.urlencode($SECUREKEY).'&';
|
||||
$urlko.='securekey='.urlencode($SECUREKEY).'&';
|
||||
}
|
||||
if (! empty($entity))
|
||||
{
|
||||
$urlok.='entity='.urlencode($entity).'&';
|
||||
$urlko.='entity='.urlencode($entity).'&';
|
||||
}
|
||||
$urlok=preg_replace('/&$/','',$urlok); // Remove last &
|
||||
$urlko=preg_replace('/&$/','',$urlko); // Remove last &
|
||||
|
||||
@ -255,6 +267,7 @@ print '<input type="hidden" name="action" value="dopayment">'."\n";
|
||||
print '<input type="hidden" name="tag" value="'.GETPOST("tag",'alpha').'">'."\n";
|
||||
print '<input type="hidden" name="suffix" value="'.GETPOST("suffix",'alpha').'">'."\n";
|
||||
print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
|
||||
print '<input type="hidden" name="entity" value="'.$entity.'" />';
|
||||
print "\n";
|
||||
print '<!-- Form to send a Paypal payment -->'."\n";
|
||||
print '<!-- PAYPAL_API_SANDBOX = '.$conf->global->PAYPAL_API_SANDBOX.' -->'."\n";
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 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
|
||||
@ -28,6 +29,13 @@
|
||||
define("NOLOGIN",1); // This means this output page does not require to be logged.
|
||||
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
||||
|
||||
// For MultiCompany module
|
||||
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
|
||||
if (is_int($entity))
|
||||
{
|
||||
define("DOLENTITY", $entity);
|
||||
}
|
||||
|
||||
require("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 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
|
||||
@ -28,6 +29,13 @@
|
||||
define("NOLOGIN",1); // This means this output page does not require to be logged.
|
||||
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
||||
|
||||
// For MultiCompany module
|
||||
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
|
||||
if (is_int($entity))
|
||||
{
|
||||
define("DOLENTITY", $entity);
|
||||
}
|
||||
|
||||
require("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user