Works on paypal module

This commit is contained in:
Regis Houssin 2011-05-17 19:15:38 +00:00
parent ed5c09a6ed
commit 12bf78b7d6
2 changed files with 43 additions and 1 deletions

View File

@ -32,6 +32,7 @@ if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
require('../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php');
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
@ -57,7 +58,7 @@ top_httphead();
dol_syslog(join(',',$_GET));
if (isset($_GET['action']) && ! empty($_GET['action']) && ( (isset($_GET['element']) && ! empty($_GET['element'])) || (isset($_GET['transaction_id']) && ! empty($_GET['transaction_id'])) ) )
if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transaction_id']) && ! empty($_GET['transaction_id']) )
{
if ($_GET['action'] == 'create')
{
@ -128,6 +129,45 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && ( (isset($_GET['elemen
echo $langs->trans($soc->error);
}
}
if ($soc->id > 0 && isset($_GET['element']) && ! empty($_GET['element']))
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $_GET['element'];
if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') { $element = $subelement = 'commande'; }
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$object = new $classname($db);
$object->socid=$soc->id;
$object->fetch_thirdparty();
$db->begin();
$object->date_commande = dol_now();
$object->ref_ext = $_SESSION[$_GET['transaction_id']]['SHIPTOCITY'];
$object->contactid = $contact->id;
$i=0;
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
{
$product = new Product($db);
$product->fetch('',$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]);
//$_SESSION[$_GET['transaction_id']]["L_QTY".$i];
echo 'ref='.$product->ref.' label='.$product->libelle.'<br>';
$i++;
}
}
echo 'socid='.$soc->id;

View File

@ -174,6 +174,8 @@ dol_htmloutput_errors('',$errors);
print_fiche_titre(' - '.$langs->trans('PaypalTransaction'), '', 'paypal_logo@paypal');
print '<br />';
// Search parameters
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';