Ajout téléchargement consommation
This commit is contained in:
parent
df3d83d121
commit
e9a4c35d7c
@ -48,11 +48,9 @@ class UserController extends Zend_Controller_Action
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headLink()
|
||||
->appendStylesheet('/themes/default/styles/form.css', 'all');
|
||||
$this->view->headLink()->appendStylesheet('/themes/default/styles/form.css', 'all');
|
||||
|
||||
$this->view->headScript()
|
||||
->appendFile('/themes/default/scripts/user.js', 'text/javascript');
|
||||
$this->view->headScript()->appendFile('/themes/default/scripts/user.js', 'text/javascript');
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
@ -162,6 +160,11 @@ class UserController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
|
||||
public function consoAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/themes/default/scripts/conso.js', 'text/javascript');
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
|
||||
|
27
application/views/default/scripts/user/conso.phtml
Normal file
27
application/views/default/scripts/user/conso.phtml
Normal file
@ -0,0 +1,27 @@
|
||||
<div class="infoTitle StyleInfoLib">Relevé de consommation</div>
|
||||
<div class="infoData">
|
||||
<?php if ($this->profil == 'SuperAdministrateur'){ ?>
|
||||
<label title="Renvoi les logs de tous les clients. Avec le détail le téléchargement peut être long.">
|
||||
Tous les clients</label>
|
||||
<input type="checkbox" name="ConsoAll" value="1" class="noborder"/>
|
||||
<?php }?>
|
||||
|
||||
<label>Détails</label>
|
||||
<input type="checkbox" name="ConsoDetails" value="1" class="noborder"/>
|
||||
|
||||
<select name="ConsoMois">
|
||||
<option value="-">Mois/Année</option>
|
||||
<?php
|
||||
for ($i = 0; $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')));
|
||||
echo '<option value="'.$date.'">'.$date.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<a href="<?=$this->url(array(
|
||||
'controller' => 'telechargement',
|
||||
'action' => 'consommation',
|
||||
))?>" id="dl">Ok</a>
|
||||
</div>
|
||||
<div id="dlMsg" class="infoData last"></div>
|
@ -78,6 +78,13 @@ if ($this->action=='new') {
|
||||
<input type="hidden" name="frmOptions[changepwd]" value="<?php echo $changePassword?>"/>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
//Consomation
|
||||
if (in_array($this->options->profil, array('Administrateur', 'SuperAdministrateur'))){
|
||||
echo $this->action('conso', 'user');
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<h2>Moteur de recherche</h2>
|
||||
|
51
public/themes/default/scripts/conso.js
Normal file
51
public/themes/default/scripts/conso.js
Normal file
@ -0,0 +1,51 @@
|
||||
$(document).ready(function(){
|
||||
var holdTheInterval;
|
||||
var nbEssai = 25;
|
||||
var essai = 0;
|
||||
var url = '';
|
||||
var postUrl = '';
|
||||
var ConsoAll = 0;
|
||||
var ConsoDetails = 0;
|
||||
var ConsoMois;
|
||||
|
||||
$('#dl').click(function(e) {
|
||||
e.preventDefault();
|
||||
if ($('select[name=ConsoMois]').val() == '-') {
|
||||
$('#dlMsg').html('Vous devez sélectionner une période.');
|
||||
return;
|
||||
}
|
||||
postUrl = $(this).attr('href');
|
||||
ConsoAll = $('input[name=ConsoAll]').attr('checked') ? 1 : 0;
|
||||
ConsoDetails = $('input[name=ConsoAll]').attr('checked') ? 1 : 0;
|
||||
ConsoMois = $('select[name=ConsoMois]').val();
|
||||
checkFile();
|
||||
holdTheInterval = setInterval(checkFile, 4000);
|
||||
});
|
||||
|
||||
function checkFile() {
|
||||
essai++;
|
||||
if (essai > nbEssai) {
|
||||
essai = 0;
|
||||
updateInfo('Le temps maximum d\'attente a été atteint. Merci de réessayez.');
|
||||
} else {
|
||||
$('#dlMsg').text('Patientez pendant la construction du fichier ('+ essai +')...');
|
||||
$.post(postUrl, {start: essai, mois: ConsoMois, detail: ConsoDetails, all: ConsoAll, url: url },
|
||||
function (data, textStatus) {
|
||||
if (data != '' && data != 'FALSE') {
|
||||
if (essai == 1) {
|
||||
url = data;
|
||||
if (url == '') { updateInfo('Erreur'); }
|
||||
} else {
|
||||
updateInfo(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateInfo(data) {
|
||||
$('#dlMsg').html(data);
|
||||
clearInterval(holdTheInterval);
|
||||
essai = 0;
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user