2010-08-31 13:55:19 +00:00
|
|
|
<?php
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// giant_enquete.php
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
define('VERSION', '1.0');
|
|
|
|
|
2010-10-06 11:47:31 +00:00
|
|
|
$pays = $_GET['pays'];
|
2010-08-31 13:55:19 +00:00
|
|
|
$company = $_GET['company'];
|
|
|
|
$level = $_GET['level'];
|
|
|
|
$type = $_GET['type' ];
|
|
|
|
$lang = $_GET['lang' ];
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-09-21 10:14:44 +00:00
|
|
|
// giantCopieDuRapports
|
2010-08-31 13:55:19 +00:00
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
function giantCopieDuRapport($rapport_a_copier)
|
|
|
|
{
|
|
|
|
$r = new Rapports;
|
|
|
|
$r->CountryCode = $rapport_a_copier->CountryCode;
|
|
|
|
$r->ProviderId = $rapport_a_copier->ProviderId;
|
|
|
|
$r->CompanyId = $rapport_a_copier->CompanyId;
|
|
|
|
$r->ServiceLevelName = 'Immediate';
|
|
|
|
$r->DataSetType = $rapport_a_copier->DataSetType;
|
|
|
|
$r->LanguageCode = $rapport_a_copier->LanguageCode;
|
|
|
|
$r->DataSet = $rapport_a_copier->DataSet;
|
|
|
|
$r->OrderId = $rapport_a_copier->OrderId;
|
|
|
|
$r->User = $_SESSION['tabInfo']['login'];
|
|
|
|
$r->DateTime = date('Y-m-d\ H:i:s');
|
|
|
|
$r->save();
|
|
|
|
|
|
|
|
return $r->ReportId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// giantGetIdentite
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-10-06 11:47:31 +00:00
|
|
|
function giantGetIdentite($pays, $company, $level, $type, $lang)
|
2010-08-31 13:55:19 +00:00
|
|
|
{
|
|
|
|
$c = new Commandes;
|
2010-10-06 11:47:31 +00:00
|
|
|
$c->ProviderId = getProviderId($pays);
|
|
|
|
$c->CountryCode = getCountryCode($pays);
|
2010-08-31 13:55:19 +00:00
|
|
|
$c->CompanyId = $company;
|
|
|
|
//$c->CompanyName = ;
|
|
|
|
$c->ServiceLevelName = 'Immediate';
|
|
|
|
$c->DataSetType = $type;
|
|
|
|
$c->LanguageCode = $lang;
|
|
|
|
$c->OrderStatus = 'Pending';
|
|
|
|
$c->OrderDateTime = date('Y-m-d\TH:i:s');
|
|
|
|
$c->DueDateTime = $c->OrderDateTime;
|
|
|
|
$c->User = $_SESSION['tabInfo']['login'];
|
|
|
|
$c->save();
|
|
|
|
|
2010-10-06 11:47:31 +00:00
|
|
|
$soap_client = getClient($pays, 'credit-data');
|
2010-08-31 13:55:19 +00:00
|
|
|
|
|
|
|
$o = new StdClass;
|
|
|
|
$o->CompanyId = $company;
|
|
|
|
$o->DataSetType = new StdClass;
|
|
|
|
$o->DataSetType->_ = $type;
|
|
|
|
$o->LanguageCode = $lang;
|
|
|
|
$o->DataSetVersion = VERSION;
|
|
|
|
|
|
|
|
try {
|
|
|
|
$O = $soap_client->__call('OrderDataSet', array($o));
|
|
|
|
} catch (SoapFault $f) {
|
|
|
|
print_r($f);
|
|
|
|
print '<br/>';
|
|
|
|
print 'Requete: '.
|
|
|
|
htmlspecialchars($soap_client->__getLastRequest());
|
|
|
|
print '<br/>';
|
|
|
|
print 'Reponse: '.
|
|
|
|
htmlspecialchars($soap_client->__getLastResponse());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($O->Order->OrderStatus != 'Completed') {
|
|
|
|
print 'Service momentanément indisponible';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$o = new StdClass;
|
|
|
|
$o->ProviderOrderId = $O->Order->ProviderOrderId;
|
|
|
|
$o->InternalOrderId = $O->Order->InternalOrderId;
|
|
|
|
|
|
|
|
try {
|
|
|
|
$O = $soap_client->__call('RetrieveDataSet', array($o));
|
|
|
|
} catch (SoapFault $f) {
|
|
|
|
print_r($f);
|
|
|
|
print '<br/>';
|
|
|
|
print 'Requete: '.
|
|
|
|
htmlspecialchars($soap_client->__getLastRequest());
|
|
|
|
print '<br/>';
|
|
|
|
print 'Reponse: '.
|
|
|
|
htmlspecialchars($soap_client->__getLastResponse());
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
print '<pre>';
|
|
|
|
print_r($O);
|
|
|
|
print '</pre>';
|
|
|
|
exit;
|
|
|
|
*/
|
|
|
|
$r = new Rapports;
|
2010-10-06 11:47:31 +00:00
|
|
|
$r->ProviderId = $c->ProviderId;
|
|
|
|
$r->CountryCode = $c->CountryCode;
|
2010-08-31 13:55:19 +00:00
|
|
|
$r->CompanyId = $company;
|
|
|
|
$r->ServiceLevelName = $level;
|
|
|
|
$r->DataSetType = $type;
|
|
|
|
$r->LanguageCode = $lang;
|
|
|
|
$r->DataSet = serialize($O->DataSet);
|
|
|
|
$r->OrderId = $c->OrderId;
|
2010-09-13 13:38:37 +00:00
|
|
|
$r->User = $c->User;
|
2010-08-31 13:55:19 +00:00
|
|
|
$r->save();
|
|
|
|
|
|
|
|
$c->CompanyName = $O->DataSet->Company->CompanyName->_;
|
|
|
|
$c->OrderStatus = 'Completed';
|
|
|
|
$c->DateTimeCompleted = date('Y-m-d\TH:i:s');
|
|
|
|
$c->ReportId = $r->ReportId;
|
|
|
|
$c->save();
|
|
|
|
|
|
|
|
return $c->OrderId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Rapport Immediat
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if ($level == 'Immediate') {
|
|
|
|
require_once 'dbbootstrap.php';
|
|
|
|
setDbConn('giantclient');
|
|
|
|
|
|
|
|
print '<div id="center">';
|
|
|
|
|
|
|
|
// Si on a un rapport
|
2010-10-06 11:47:31 +00:00
|
|
|
require_once 'giant/client.php';
|
2010-08-31 13:55:19 +00:00
|
|
|
$rapports = Doctrine_Query::create()
|
|
|
|
->from('Rapports')
|
2010-10-06 11:47:31 +00:00
|
|
|
->andWhere('ProviderId = ?', getProviderId($pays))
|
|
|
|
->andWhere('CountryCode = ?', getCountryCode($pays))
|
|
|
|
->andwhere('CompanyId = ?', $company)
|
2010-08-31 13:55:19 +00:00
|
|
|
->andWhere('ServiceLevelName = ?', 'Immediate')
|
2010-10-06 11:47:31 +00:00
|
|
|
->andWhere('DataSetType = ?', $type)
|
|
|
|
->andWhere('LanguageCode = ?', $lang)
|
2010-08-31 13:55:19 +00:00
|
|
|
->orderby('ReportId desc')
|
|
|
|
->execute();
|
|
|
|
$commande_id = 0;
|
|
|
|
if ($rapports != false && count($rapports) > 0) {
|
|
|
|
// Si une commande appartient a cet utilisateur
|
|
|
|
foreach ($rapports as $r) {
|
|
|
|
if ($r->User == $_SESSION['tabInfo']['login']) {
|
|
|
|
$commande_id = $r->OrderId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($commande_id == 0) {
|
|
|
|
$commande_id = giantCopieDuRapport($rapports[0]);
|
|
|
|
}
|
|
|
|
} else {
|
2010-10-06 11:47:31 +00:00
|
|
|
$commande_id =
|
|
|
|
giantGetIdentite($pays, $company, $level, $type, $lang);
|
2010-08-31 13:55:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($commande_id > 0) {
|
|
|
|
header('Location: ?page=giant_commandes&OrderId='.$commande_id);
|
|
|
|
print '<a href="?page=giant_commandes&OrderId='.$commande_id.
|
|
|
|
'">Veuillez suivre ce lien</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Commande de rapport
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
print 'TODO';
|
|
|
|
?>
|