extranet/www/pages/international_identitec.php
2010-03-30 09:27:57 +00:00

90 lines
2.9 KiB
PHP

<?php
if ($_SESSION['connected'] == false) {
die();
}
require_once 'graydon/graydon_wsfunctions.php';
require_once 'dbbootstrap.php';
setDbConn('graydon');
$pays = $_SESSION['graydon']['pays'];
$login = $_SESSION['tabInfo']['login'];
$mode = $_SESSION['graydon']['mode'];
$name = $_SESSION['graydon']['name'];
$identifier = $_GET['identifier'];
$pidentifier = $_GET['pidentifier'];
print '<div id="center">';
// Verifier si on a un rapport
$rapports = Doctrine_Query::create()
->from('Report')
->where('identifier = ?', $identifier)
->execute();
if ($rapports != false && count($rapports) > 0) {
// Nouvelle commande
$commande = new Commandes();
$commande->prix = Doctrine_Query::create()
->select('p.immediate')
->from('Price p')
->leftJoin('p.Country c')
->where('c.graydon_country = ?', $pays)
->fetchOne();
$commande->servicespeed = 'Immediate';
$commande->orderstate = 'Delivered';
$commande->dateordered = date('Y-m-d');
$commande->datecompleted = $commande->dateordered;
$commande->datedue = $commande->dateordered;
$commande->companyproductidentifier = $pidentifier;
list($dummy, $session_id, $transaction_identifier) =
explode(':', $commande->companyproductidentifier);
$commande->sessionid = $session_id;
$commande->transactionidentifier = $transaction_identifier;
$commande->user = $login;
$commande->mode = $mode;
$commande->Country = Doctrine_Query::create()
->from('Country')
->where('graydon_country = ?', $pays)
->fetchOne();
$commande->save();
// Detail de la commande
$commandesDetail = new CommandesDetail();
$commandesDetail->eName = $name;
$commandesDetail->eIdentifiers = $identifier;
$commandesDetail->ePays = $pays;
$commandesDetail->commandes_id = $commande->id;
$commandesDetail->eCreditOpinionCurrency = 'EUR';
$commandesDetail->save();
// Copie des rapports
$i = count($rapports);
$f = array();
while ($i > 0) {
--$i;
// Copie du rapport pour la nouvelle commande
if (isset($f[$rapports[$i]->format]) == true) {
continue;
}
$rapport = new Report();
$rapport->identifier = $rapports[$i]->identifier;
$rapport->name = $rapports[$i]->name;
$rapport->content = $rapports[$i]->content;
$rapport->format = $rapports[$i]->format;
$rapport->order_id = $commande->id;
$rapport->save();
$f[$rapports[$i]->format] = true;
}
$commande_id = $commande->id;
} else {
$commande_id = getIdentite($identifier, $pidentifier);
}
if ($commande_id > 0) {
header('Location: ?page=international_commandes&id='.$commande_id);
print '<a href="?page=international_commandes&id='.$commande_id.
'">Veuillez suivre ce lien</a>';
}
print '</div>';
?>