extranet/www/pages/moncompte.php
2010-11-03 13:24:58 +00:00

359 lines
13 KiB
PHP

<?php
$tabInfo = $_SESSION['tabInfo'];
$message = '';
if (isset($_REQUEST['login']) && $_REQUEST['login']!='' &&
$_REQUEST['login']!=$_SESSION['tabInfo']['login'] &&
($_SESSION['tabInfo']['profil']=='Administrateur' ||
$_SESSION['tabInfo']['profil']=='SuperAdministrateur') ){
$loginVu=$_REQUEST['login'];
}elseif (isset($tabOptions) && $tabOptions['action']=='new'){
$loginVu=$tabOptions['login'];
}else{
$loginVu=$_SESSION['tabInfo']['login'];
//On affecte la valeur en session de mode edition d'après le résultat du formulaire
if (isset($tabOptions) && !isset($tabOptions['mode_edition']) &&
$tabOptions['action']=='save'){
$_SESSION['tabInfo']['mode_edition']=0;
}
}
if (isset($tabOptions) &&
($tabOptions['action']=='save' || $tabOptions['action']=='new')){
$message = 'Erreur lors de la mise à jour du compte !';
$tabOptions['nom'] = preg_replace('/[^0-9A-Z\'-]/i', ' ', strtoupper(strtr(stripslashes($tabOptions['nom']), 'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜݟ', 'aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUYY')));
$tabOptions['prenom'] = ucwords(strtolower(preg_replace('/[^0-9A-Z\'-]/i', ' ', strtoupper(strtr(stripslashes($tabOptions['prenom']), 'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜݟ', 'aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUYY')))));
$tabOptions['reference'] = preg_replace('/[^0-9A-Z\'-]/i', ' ', strtoupper(strtr(stripslashes($tabOptions['reference']), 'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜݟ', 'aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUYY')));
$firephp->log($loginVu, 'loginVu');
$firephp->log($tabOptions, 'tabOptions');
try {
$O = $client->setInfosLogin($loginVu, $tabOptions);
if ($O['result']==1) $message='Compte mis à jour !';
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
$message = 'Erreur SOAP lors de la mise à jour du compte !';
}
if ($_REQUEST['referer']=='administration') {
?>
<script language="javascript">
$(document).ready(function(){
alert("Le profil <?=$loginVu?> a été mis à jour !");
window.location.href = '/?page=administration&id=<?=$idEntreprise?>&siret=<?=$siret?>';
});
</script>
<?php
}
if ($_REQUEST['frmOptions']['changepwd']==1 &&
$loginVu==$_SESSION['tabInfo']['login'] &&
$tabOptions['action']=='save' ){
?>
<script language="javascript">
$(document).ready(function(){
alert("La modification de votre mot de passe nécessite votre déconnexion !");
window.location.href = '/?page=main&action=logout';
});
</script>
<?php
}
}
/** Utilisation du WS **/
try {
if (!isset($_REQUEST['action']) || $_REQUEST['action']!='new') {
$O = $client->getInfosLogin($loginVu);
$login=$O['result'];
} else {
$O = $client->getNextLogin($loginVu);
$loginNew=$O['result']['racine'];
$idClient=$O['result']['idClient'];
$login=$O['result'];
}
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
die();
}
$admin = false;
if ($_SESSION['tabInfo']['profil']=='Administrateur' ||
$_SESSION['tabInfo']['profil']=='SuperAdministrateur'){
$admin = true;
}
?>
<style type="text/css">
#telechargementjsMsg {margin-left:30px;}
#dialog { display:none; }
#center p {
margin:5px;
padding:5px;
}
</style>
<div id="dialog" title="Modifier le mot de passe">
<form>
<label for="npass1">Nouveau mot de passe</label><br/>
<input type="password" name="npass1" size="15" maxlength="32" /><br/>
<label for="npass2">Répeter le nouveau mot de passe</label><br/>
<input type="password" name="npass2" size="15" maxlength="32"/><br/>
<span id="form-message"></span>
</form>
</div>
<div id="center">
<?php
if ($message!='') {
?>
<div style="margin:5px; padding: 0pt 0.7em;" class="ui-state-highlight ui-corner-all">
<p><span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-info"></span>
<?=$message?></p>
</div>
<?php
}
?>
<h1 class="titre">PROFIL UTILISATEUR</h1>
<form name="form_moncompte" action="./?page=moncompte" method="post" enctype="multipart/form-data">
<?php
if (isset($_REQUEST['action']) && $_REQUEST['action']=='new') {
?>
<input type="hidden" name="frmOptions[action]" value="new"/>
<?php
} else {
?>
<input type="hidden" name="frmOptions[action]" value="save"/>
<?php
}
?>
<input type="hidden" name="siret" value="<?=$siret?>"/>
<input type="hidden" name="id" value="<?=$idEntreprise?>"/>
<input type="hidden" name="login" value="<?=$loginVu?>"/>
<input type="hidden" name="frmOptions[idClient]" value="<?=$idClient?>"/>
<input type="hidden" name="referer" value="<?=$_REQUEST['referer']?>"/>
<div class="infoTitle StyleInfoLib">Identifiant utilisateur</div>
<div class="infoData">
<?php
if (!isset($_REQUEST['action']) || $_REQUEST['action']!='new'){
echo (isset($loginVu) ? $loginVu : '' );
} else {
?>
<input type="text" size="20" maxlength="80" name="frmOptions[login]" value="<?=isset($loginNew) ? $loginNew : '';?>"/>
<?php
}
?>
</div>
<div class="infoTitle StyleInfoLib">Identit&eacute; (NOM/Pr&eacute;nom)</div>
<div class="infoData">
<?php
if ($admin)
{
?>
<input type="text" size="20" maxlength="80" name="frmOptions[nom]" value="<?=(is_array($login) && isset($login['nom']))? $login['nom'] : '';?>"/>
<input type="text" size="20" maxlength="80" name="frmOptions[prenom]" value="<?=(is_array($login) && isset($login['prenom']))? $login['prenom'] : '';?>"/>
<?php
} else { ?> <?=$login['nom'].' '.$login['prenom']?> <? } ?>
</div>
<div class="infoTitle StyleInfoLib">R&eacute;f. facturation (service, etc...)</div>
<div class="infoData">
<?php
if ($admin)
{
?>
<input type="text" size="20" maxlength="80" name="frmOptions[reference]" value="<?=(is_array($login) && isset($login['reference']))? $login['reference'] : '';?>"/>
<? } else { ?> <?=$login['reference']?><? } ?>
</div>
<div class="infoTitle StyleInfoLib">Adresse e-mail</div>
<div class="infoData">
<input type="text" size="30" maxlength="80" name="frmOptions[email]" value="<?=(is_array($login) && isset($login['email']))? $login['email'] : '';?>"/>
</div>
<div class="infoTitle StyleInfoLib">
Num&eacute;ros de t&eacute;l&eacute;phone<br/><i>(Fixe, Fax, Mobile)</i>
</div>
<div class="infoData">
<input type="text" size="10" maxlength="15" name="frmOptions[tel_fix]" value="<?=(is_array($login) && isset($login['tel']))? $login['tel'] : '';?>"/>
<input type="text" size="10" maxlength="15" name="frmOptions[tel_fax]" value="<?=(is_array($login) && isset($login['fax']))? $login['fax'] : '';?>"/>
<input type="text" size="10" maxlength="15" name="frmOptions[tel_mob]" value="<?=(is_array($login) && isset($login['mobile']))? $login['mobile'] : '';?>"/>
<!--<br/><input type="checkbox" name="frmOptions[copie_sms]" value="<?=$_SESSION['tabInfo']['copieParSms']?>"/> Recevoir une copie de mes messages de surveillance par SMS-->
</div>
<br/>
<div class="infoTitle StyleInfoLib">Mot de passe</div>
<div class="infoData last">
<?php
if (isset($_REQUEST['action']) && $_REQUEST['action']=='new') {
$typeChamp = 'password';
} else {
$typeChamp = 'hidden';
?>
<a href="#" id="password">Modifier le mot de passe.</a>
<?php
}
?>
<input type="<?=$typeChamp?>" name="frmOptions[password]" value="oqsrihgwslglm"/>
<input type="hidden" name="frmOptions[changepwd]" value="0"/>
<?php
/*
<input type="password" size="15" maxlength="32" name="frmOptions[password]" value="oqsrihgwslglm" onkeypress="document.form_moncompte.changepwd.checked=1"/>
<input name="frmOptions[changepwd]" id="changepwd" type="checkbox" value="1" class="noborder"/> R&eacute;initialiser le mot de passe
*/
?>
</div>
<?php
// --------------------------------------------------------------------------- //
// Consommation
// --------------------------------------------------------------------------- //
if ($tabInfo['profil'] == 'Administrateur' ||
$tabInfo['profil'] == 'SuperAdministrateur') {
$argv = '';
if (isset($loginVu) == true) {
$argv .= "login,$loginVu,";
}
if (isset($idClient) == true) {
$argv .= "idClient,$idClient";
}
?>
<div class="infoTitle StyleInfoLib">Relevé de consommation</div>
<div class="infoData">
<input type="hidden" name="page" value="<?=$page?>"/>
<input type="hidden" name="argv" value="<?=$argv?>"/>
<label>Détails</label>
<input type="checkbox" name="telechargementjsCase" value="1" class="noborder"/>
<select name="telechargementjsMenu">
<option value="invalide">Mois/Année</option>
<?php
for ($i = 1; $i <= 12; ++$i) {
$date = date('m', mktime(0, 0, 0, date('m') - $i, 1, date('Y'))).'/'.
date('Y', mktime(0, 0, 0, date('m') - $i, 1, date('Y')));
print '<option value="'.$date.'">'.$date.'</option>';
}
?>
</select>
<a href="./?page=telechargement" id="telechargementjs">Ok</a>
</div>
<div id="telechargementjsMsg" class="infoData last"></div>
<?php
}
// --------------------------------------------------------------------------- //
// Moteur de recherche
// --------------------------------------------------------------------------- //
?>
<h2>Moteur de recherche</h2>
<div class="infoTitle StyleInfoLib">R&eacute;sultats par page</div>
<div class="infoData">
<select name="frmOptions[rech_nbrep]">
<?
$opts = array(10, 20, 30, 40, 50, 100, 150, 200);
foreach($opts as $opt)
{
$selected = '';
if($opt == $login['nbReponses']) $selected = 'selected';
?><option value="<?=$opt?>" <?=$selected?>><?=$opt?></option><?php
}
?>
</select>
</div>
<div class="infoTitle StyleInfoLib">Inclure</div>
<div class="infoData last">
<input type="checkbox" name="frmOptions[rech_limites][]" value="assocs" checked disabled class="noborder"/> les associations<br/>
<input type="checkbox" name="frmOptions[rech_limites][]" value="actifs" checked disabled class="noborder"/> les actifs<br/>
<input type="checkbox" name="frmOptions[rech_limites][]" value="radies" checked disabled class="noborder"/> les radi&eacute;s<br/>
<input type="checkbox" name="frmOptions[rech_limites][]" value="sieges" checked disabled class="noborder"/> les &eacute;tablissements secondaires
</div>
<h2>Surveillance</h2>
<div class="infoTitle StyleInfoLib">Supports pour les alertes</div>
<div class="infoData last">
<input type="checkbox" name="frmOptions[alertes][]" value="sms" disabled class="noborder"/> SMS<br/>
<input type="checkbox" name="frmOptions[alertes][]" value="fax" disabled class="noborder"/> Fax<br/>
<input type="checkbox" name="frmOptions[alertes][]" value="mail" checked disabled class="noborder"/> Mail<br/>
</div>
<?php
if ($_SESSION['tabInfo']['login']=='ylenaour')
{
$formatMail=$login['formatMail'];
?>
<div class="infoTitle StyleInfoLib">Format des emails</div>
<div class="infoData last">
<select name="frmOptions[formatMail]">
<optgroup label="Sans pièce jointe">
<option value="txt1" <?if($formatMail=='txt1') echo 'selected';?>>1 annonce/mail en texte</option>
<option value="txt2" <?if($formatMail=='txt2') echo 'selected';?>>1 mail/jour en texte</option>
<!--<option value="htm1" <?if($formatMail=='htm1') echo 'selected';?>>Mail format Html</option>-->
</optgroup>
<optgroup label="Avec pièce jointe">
<!--<option value="pdf" <?if($formatMail=='pdf') echo 'selected';?>>Pdf en pièce jointe</option>-->
<option value="pdf1" <?if($formatMail=='pdf1') echo 'selected';?>>Pdf (1 annonce/page)</option>
<!--<option value="csv" <?if($formatMail=='csv') echo 'selected';?>>Pièce jointe CSV</option>-->
<option value="xls" <?if($formatMail=='xls') echo 'selected';?>>Pièce jointe Excel</option>
</optgroup>
</select>
</div>
<?php
}
?>
<h2>Gestion des droits</h2>
<div class="infoTitle StyleInfoLib">Type de profil</div>
<div class="infoData">
<?=(is_array($login) && isset($login['profil']))?
$login['profil'] : 'Utilisateur';?>
</div>
<div class="infoTitle StyleInfoLib">Droits d&#039;acc&egrave;s</div>
<div class="infoData">
<?php
FB::log($login, 'login');
?>
<?=formElementPerm($login)?>
<?php
if (checkModeEdition($loginVu)) {
if ($_SESSION['tabInfo']['international_giant'] == 1) {
$strMode = 'checked';
} else {
$strMode = '';
}
print '<input type="checkbox" name="frmOptions[international_giant]"'.
' value="1" disabled '.$strMode.
' class="noborder"/>Recherche internationale V2';
}
?>
</div>
<div class="infoTitle StyleInfoLib">Pr&eacute;f&eacute;rences</div>
<div class="infoData last">
<?=formElementPref($login)?>
</div>
<?php
if(checkModeEdition($loginVu))
{
?>
<h2>Edition</h2>
<div class="infoTitle StyleInfoLib">Mode actuel</div>
<div class="infoData last">
<?=formElementModeEdition()?>
</div>
<?php
} else {
?>
<div>&nbsp;</div>
<?php
}
?>
<div class="submit"><p class="submit-button"><input type="submit" value="Sauver"/></p></div>
</form>
</div>