extranet/www/pages/international_enquete.php
2010-04-26 14:46:13 +00:00

413 lines
13 KiB
PHP

<?php
require_once 'graydon/graydon_wsfunctions.php';
if (isset($_GET['speed']) == true && $_GET['speed'] == 'immediate') {
require_once 'dbbootstrap.php';
setDbConn('graydon');
$identifier = $_GET['identifier'];
$pidentifier = $_GET['pidentifier'];
print '<div id="center">';
// Si on a un rapport
$rapports = Doctrine_Query::create()
->from('Report')
->where('identifier = ?', $identifier)
->orderby('id desc')
->execute();
if ($rapports != false && count($rapports) > 0) {
$id = $rapports[0]->order_id;
// Si la commande appartient a cet utilisateur
if (Doctrine_Query::create()
->from('Commandes')
->where('id = ?', $id)
->fetchOne()->user == $_SESSION['tabInfo']['login']) {
$commande_id = $id;
} else {
$commande_id = copieDesRapports($id, $identifier, $pidentifier);
}
} 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>';
exit;
}
$tabInfo = $_SESSION['tabInfo'];
$pays = $_SESSION['graydon']['pays'];
$paysCode = $_SESSION['graydon']['paysCode'];
$mode = $_SESSION['graydon']['mode'];
$message = '';
$firephp->log($pays, 'pays');
if (isset($_POST['submit'])) {
$firephp->log('Soumission formulaire');
// Vérification des informations
$formError = false;
$fields = array();
// Info utilisateur obligatoire :
if ($_POST['InfoUser']['Identite'] == '') {
$fields[] = 'Votre Identite';
$formError = true;
}
if ($_POST['InfoUser']['Tel'] == '') {
$fields[] = 'Votre Téléphone';
$formError = true;}
if ($_POST['InfoUser']['Email'] == '') {
$fields[] = 'Votre Email';
$formError = true;
}
// Info entreprise obligatoire :
if (!isset($_POST['pidentifier'])) {
if ($_POST['InfoEnq']['Name'] == '') {
$fields[] = 'Raison Sociale';
$formError = true;
}
// if ($_POST['InfoEnq']['Telephone'] == '') {
// $fields[] = 'Téléphone';
// $formError = true;
// }
if ($_POST['InfoEnq']['Adresse'] == '') {
$fields[] = 'Adresse';
$formError = true;
}
}
if ($_POST['InfoEnq']['Servicespeed'] == '') {
$fields[] = 'Type d\'enquête';
$formError = true;
}
if ($formError == true){
$message = '<font color="red">';
$message .= 'Veuillez remplir les champs suivants : ';
$message .= join(', ', $fields);
$message .= '</font>';
} else {
$commande_id = setEnquete($pays);
require_once 'mail/mail.php';
sendMail("DEBUG - Commandes de rapport graydon",
"Commandes\n".
"Utilisateur :\n".print_r($_POST['InfoUser'], true)."\n".
"Enquêtes : \n".print_r($_POST['InfoEnq' ], true)."\n",
// From
array('email' => 'contact@scores-decisions.com',
'name' => 'Serveur SD-13408', ),
// To
array(0 => array('email' => EMAIL_SUPPORTDEV,
'name' => 'Support')));
}
}
?>
<style>
#center { background: #ffffff; width:580px; padding:5px; }
#center h1 { margin:5px; padding:5px; background: #606060; color:#ffffff;
font: 600 1.4em arial, verdana, sans-serif; }
#center h2 { margin:5px; padding:5px; background: #00008c; color:#ffffff;
font: bold 1.2em arial, verdana, sans-serif; }
.infoTitle { clear:both; float:left; width:180px; margin-left:30px;
padding:0 10px 0 0; }
.infoData { float:left; width:320px; margin:2px 0; }
form { }
form em { color:#FF0000; }
fieldset { border:0; margin:0; padding:0; }
fieldset legend { padding:0 0 0 10px; }
.fieldgrp { clear:both; width:100%; margin-bottom:.5em; overflow:hidden; }
.fieldgrp:after { content:"."; display:block; clear:both; visibility:hidden;
line-height:0; height:0; }
.fieldgrp label { font-weight:bold; margin-left:30px; width:180px; clear:both;
padding:0 10px 0 0; line-height:22px; _padding-top:3px; float:left;
display:block; font-size:108%; }
.fieldgrp label span { font-weight:normal; }
.fieldgrp label abbr { color:#4B911C; font-size:120%; vertical-align:middle; }
.field { width:320px; float:left; padding:0 10px 0 0; line-height:22px;
_padding-top:3px; }
.field .longfield { width:215px; }
.field .longfield-select { width:220px; }
.field .smallfield { width:95px; }
.field .medfield { width:110px; }
.field input, .field select { font-size:110%; margin:2px 0; }
.field input[type="radio"] { margin:0 5px 0 5px; }
div.submit { margin-left:200px; padding-left:0px; margin-top:1em; }
div.submit p.submit-button { margin-top:0; }
div.submit p.details { font-size:85%; color:#666; margin:0; }
div.submit p.required-note { margin-top:1em; }
div.submit p.required-note span { color:#4B911C; _color:#666; font-size:170%;
vertical-align:top; }
#autreProfil { display:none; }
#autrePrecisions { display:none; }
#fournisseur { display:none; }
#credit { display:none; }
#impayees { display:none; }
#retardpaiement { display:none; }
#litige { display:none; }
</style>
<div id="center">
<h1 class="titre">ENQU&Ecirc;TE INTERNATIONALE</h1>
<?php
if (isset($commande_id) == true) {
if ($commande_id > 0) {
$message = 'Commande enregistrée.';
} else {
$message = '<font color="red">'.
'Erreur lors de la soumission de l\'enqu&ecirc;te.</font>';
}
print '<div id="message">'.$message.'</div>';
print '</div>';
exit;
}
print '<div id="message">'.$message.'</div>';
// --------------------------------------------------------------------------- //
// Formulaire
// --------------------------------------------------------------------------- //
try {
$O = $client->getInfosLogin($tabInfo['login']);
$user = $O['result'];
$firephp->log($user, 'user');
} catch (SoapFault $fault) {
}
print '<form action="./?page=international_enquete" method="post">'.
'<h2>Entreprise concernée : </h2>';
$Companyproducts = getCompanyProducts($_REQUEST['identifier']);
$company = $Companyproducts['Company'];
$products = $Companyproducts['Products'];
if ($company->Name != '') {
$name = $company->Name;
} else {
$name = $_SESSION['graydon']['name'];
}
if (isset($_REQUEST['pidentifier']) == true) {
print '<input type="hidden" name="pidentifier" value="'.
$_REQUEST['pidentifier'].'" />';
}
if (isset($_REQUEST['identifier']) == true) {
print '<input type="hidden" name="identifier" value="'.
$_REQUEST['identifier'].'" />';
}
if (isset($_REQUEST['pidentifier']) == true) {
?>
<div class="fieldgrp">
<label class="StyleInfoLib">Raison Sociale :</label>
<div class="field">
<input type="text" name="InfoEnq[Name]"
value="<?php if (isset($_POST['InfoEnq']['Name'])){ print $_POST['InfoEnq']['Name'];}else{ print $name;} ?>"
readonly="readonly"/></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Adresse :</label>
<div class="field">
<textarea name="InfoEnq[Adresse]" readonly="readonly">
<?php print $company->RegisteredAddress->EntireAddress; ?>
</textarea>
</div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Pays :</label>
<div class="field">
<input type="text" name="InfoEnq[Pays]" value="<?php print $pays;?>"
readonly="readonly"/>
</div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Téléphone</label>
<div class="field">
<input type="text" name="InfoEnq[Telephone]"
<?php
if (isset($company->Telephone) == true) {
print 'value="'.$company->Telephone.'"';
}
?>
readonly="readonly"/>
</div>
</div>
<?php
} else {
?>
<div class="fieldgrp">
<label class="StyleInfoLib">Raison Sociale :</label>
<div class="field"><input type="text" name="InfoEnq[Name]" value="<?php if (isset($_POST['InfoEnq']['Name'])){ print $_POST['InfoEnq']['Name'];}else{ print $name;} ?>"/></div>
</div>
<?php
$identifiers = getCompanyMatchIdentifiers($pays);
$firephp->log($identifiers,'identifiers');
// Affichage des identifiants
// Ne pas afficher l'identifiant Internal
if(is_array($identifiers)){
$firephp->log($identifiers,'identifiers');
$count = 0;
foreach($identifiers as $identifier){
if($identifier->Type != 'Internal'){
?>
<div class="fieldgrp">
<label><?php print $identifier->Description ?></label>
<input type="text" name="InfoEnq[Identifier][<?=$identifier->Type?>]" value="<?php if (isset($_POST['InfoEnq']['Identifier'][$identifier->Type])){ print $_POST['InfoEnq']['Identifier'][$identifier->Type];} ?>" />
</div>
<?php
$count++;
}
}
}else{
?>
<div class="fieldgrp">
<label>&nbsp;</label>
<div class="field">Pas de recherche par identifiant possible pour ce pays.</div>
</div>
<?php
}
?>
<div class="fieldgrp">
<label class="StyleInfoLib">Adresse :</label>
<div class="field"><textarea name="InfoEnq[Adresse]"><?php if(isset($_POST['InfoEnq']['Adresse'])){print $_POST['InfoEnq']['Adresse'];}?></textarea></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Pays :</label>
<div class="field"><input type="text" name="InfoEnq[Pays]" value="<?php print $pays;?>" readonly="readonly"/></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Téléphone</label>
<div class="field"><input type="text" name="InfoEnq[Telephone]" value="<?php if(isset($_POST['InfoEnq']['Telephone'])){print $_POST['InfoEnq']['Telephone'];}?>"/></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Banque</label>
<div class="field">
<input type="text" name="InfoEnq[Bankers]"/>
</div>
</div>
<?php
}
?>
<h2>Demandeur : </h2>
<div class="fieldgrp">
<label class="StyleInfoLib">Votre Identité :</label>
<div class="field"><input type="text" name="InfoUser[Identite]" value="<?php print $user['nom'].' '.$user['prenom']; ?>"/></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Téléphone <font color="Red">*</font>:</label>
<div class="field"><input type="text" name="InfoUser[Tel]" value="<?php if(isset($_POST['InfoUser']['Tel'])){print $_POST['InfoUser']['Tel'];}else{ print $user['tel']; }?>" /></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">E-mail <font color="Red">*</font>:</label>
<div class="field"><input type="text" name="InfoUser[Email]" value="<?php if(isset($_POST['InfoUser']['Email'])){print $_POST['InfoUser']['Email'];}else{ print $user['email']; }?>"/></div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Fax :</label>
<div class="field"><input type="text" name="InfoUser[Fax]" value="<?php if(isset($_POST['InfoUser']['Fax'])){print $_POST['InfoUser']['Fax'];}else{ print $user['fax']; }?>"/></div>
</div>
<h2>Enquête : </h2>
<?php
require_once 'dbbootstrap.php';
setDbConn('graydon');
// Lecture des prix
$results = Doctrine_Query::create()
->from('Price p')
->leftJoin('p.Country c')
->where('c.graydon_country = ?', $pays)
->fetchArray();
// Lecture des délais
$countryavailability = Doctrine_Query::create()
->from('Countryavailability')
->where('country = ?', $pays)
->fetchOne();
if ($countryavailability != false) {
$availability = unserialize($countryavailability->availability);
} else {
$availability = array();
}
?>
<div class="fieldgrp">
<label class="StyleInfoLib">Type d'enquête</label>
<div class="field">
<?php
$serviceActif = array('Normal', 'Superflash');
$serviceNom = array('Normal', 'Rapide');
foreach ($availability as $item) {
if (in_array($item->ServiceSpeed, $serviceActif) == true) {
$key = array_search($item->ServiceSpeed, $serviceActif);
$firephp->log($item->ServiceSpeed, 'ServiceSpeed');
$select = '';
if ((isset($_POST['InfoEnq']['Servicespeed']) &&
$_POST['InfoEnq']['Servicespeed'] == $item->ServiceSpeed) ||
(isset($_GET['speed']) == true &&
ucfirst($_GET['speed']) == $item->ServiceSpeed)) {
$select = 'checked';
}
?>
<input type="radio" name="InfoEnq[Servicespeed]"
value="<?=$item->ServiceSpeed?>" <?=$select?>>
<?php
print $serviceNom[$key];
?>
(Tarif : <?php print $results[0][strtolower($item->ServiceSpeed)]; ?> &euro;,
Délai : <?php
if (isset($item->DaysFrom) == true) {
print $item->DaysFrom.' à ';
}
print $item->DaysTo.' jours';
?>
) <br/>
<?php
}
}
?>
</div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Précisions sur la demande</label>
<div class="field">
<textarea name="InfoEnq[AttentionOf]"><?php if(isset($_POST['InfoEnq']['AttentionOf']) ){print $_POST['InfoEnq']['AttentionOf'];}?></textarea>
</div>
</div>
<div class="fieldgrp">
<label class="StyleInfoLib">Observations ou questions spéciales</label>
<div class="field"><textarea name="InfoEnq[SpecialRemarks]"><?php if(isset($_POST['InfoEnq']['SpecialRemarks']) ){print $_POST['InfoEnq']['SpecialRemarks'];}?></textarea></div>
</div>
<div class="submit"><p class="submit-button"><input type="submit" name="submit" value="Envoyer" /></p></div>
</form>
</div>