Works on paypal module

Fix: add function to return linked object
This commit is contained in:
Regis Houssin 2011-05-23 18:53:43 +00:00
parent 8ef26ab887
commit d562249fd2
3 changed files with 34 additions and 26 deletions

View File

@ -272,33 +272,9 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
// Check if already import
$i=0;
$objectArray = array();
if ($conf->commande->enabled) {
$elementArray[$i] = 'order';
$i++;
}
if ($conf->facture->enabled) {
$elementArray[$i] = 'invoice';
}
foreach($elementArray as $element)
{
if ($element == 'order') { $element = $subelement = 'commande'; }
if ($element == 'invoice') { $element = 'compta/facture'; $subelement = 'facture'; }
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$object = new $classname($db);
$res = $object->fetchObjectFromRefExt($object->table_element, $_GET['transaction_id']);
if ($res > 0)
{
$return_arr['element_created'] = true;
$objectArray[$element] = $object;
}
}
$objects = getLinkedObjects($_GET['transaction_id']);
if (! empty($objects)) $return_arr['element_created'] = true;
$soc = new Societe($db);
$ret = $soc->fetchObjectFromRefExt($soc->table_element, $_SESSION[$_GET['transaction_id']]['PAYERID']);

View File

@ -149,6 +149,36 @@ function paypaladmin_prepare_head()
return $head;
}
function getLinkedObjects($transactionID)
{
global $db, $conf;
$objectArray = array();
if ($conf->commande->enabled) {
$elementArray[$i] = 'order';
$i++;
}
if ($conf->facture->enabled) {
$elementArray[$i] = 'invoice';
}
foreach($elementArray as $element)
{
if ($element == 'order') { $path = $subelement = 'commande'; }
if ($element == 'invoice') { $path = 'compta/facture'; $subelement = 'facture'; }
dol_include_once('/'.$path.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$object = new $classname($db);
$res = $object->fetchObjectFromRefExt($object->table_element, $transactionID);
if ($res > 0) $objectArray[$element] = $object;
}
return $objectArray;
}
/**
* Send redirect to paypal to browser

View File

@ -295,6 +295,8 @@ else
while (isset($resArray["L_TRANSACTIONID".$i]))
{
$var=!$var;
$objects = getLinkedObjects($resArray["L_TRANSACTIONID".$i]);
$transactionID = $resArray["L_TRANSACTIONID".$i];
$timeStamp = dol_stringtotime($resArray["L_TIMESTAMP".$i]);