Commit 565194a1 authored by Théo GUILLON's avatar Théo GUILLON

Modification : factorisation de la génération de l'url avec les id des traitements sélectionnés

Correction : format de la date dans le nom de l'archive et du fichier dans l'export CSV
parent e9ab755f
...@@ -2085,7 +2085,7 @@ class FichesController extends AppController ...@@ -2085,7 +2085,7 @@ class FichesController extends AppController
// On verifie si le dossier file existe. Si c'est pas le cas on le cree // On verifie si le dossier file existe. Si c'est pas le cas on le cree
create_arborescence_files(); create_arborescence_files();
$date = date("Y-m-d_H:i:s"); $date = date("Y-m-d_H-i-s");
if (!file_exists(CHEMIN_EXPORTS . $date)) { if (!file_exists(CHEMIN_EXPORTS . $date)) {
mkdir(CHEMIN_EXPORTS . $date, 0777, true); mkdir(CHEMIN_EXPORTS . $date, 0777, true);
} }
......
...@@ -478,7 +478,7 @@ ...@@ -478,7 +478,7 @@
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
var currentTraitementId = 0; let currentTraitementId = 0;
$(document).ready(function () { $(document).ready(function () {
...@@ -536,7 +536,7 @@ ...@@ -536,7 +536,7 @@
return; return;
} }
var action = element.selected; let action = element.selected;
// $('.extraitRegistreCheckbox') // $('.extraitRegistreCheckbox')
// .attr('disabled', true) // .attr('disabled', true)
...@@ -591,13 +591,14 @@ ...@@ -591,13 +591,14 @@
* @param {int} numSelected * @param {int} numSelected
* @returns {Array|createOption.optionPosition} * @returns {Array|createOption.optionPosition}
*/ */
function createOption(nbTraitement, numSelected){ function createOption(nbTraitement, numSelected)
var optionPosition = []; {
let optionPosition = [];
for(var i = 1; i< nbTraitement + 1; i++){ for (let i = 1; i< nbTraitement + 1; i++) {
if(i === numSelected){ if (i === numSelected) {
optionPosition.push('<option value="'+i+'" selected="selected">'+i+'<\/option>'); optionPosition.push('<option value="'+i+'" selected="selected">'+i+'<\/option>');
}else{ } else {
optionPosition.push('<option value="'+i+'">'+i+'<\/option>'); optionPosition.push('<option value="'+i+'">'+i+'<\/option>');
} }
} }
...@@ -634,11 +635,11 @@ ...@@ -634,11 +635,11 @@
}); });
$('#modalChangerPosition').on('shown.bs.modal', function () { $('#modalChangerPosition').on('shown.bs.modal', function () {
var selectedList = []; let selectedList = [],
var traitement = []; traitement = [],
var nbTraitement = 0; nbTraitement = 0,
var oldPosition = 0; oldPosition = 0,
var fichesValid = <?php echo json_encode($fichesValid); ?>; fichesValid = <?php echo json_encode($fichesValid); ?>;
$("#render > tbody > tr").remove(); $("#render > tbody > tr").remove();
...@@ -650,16 +651,16 @@ ...@@ -650,16 +651,16 @@
nbTraitement = selectedList.length; nbTraitement = selectedList.length;
for (var key = 0; key < fichesValid.length; key++) { for (let key = 0; key < fichesValid.length; key++) {
for (var selectkey = 0; selectkey < nbTraitement; selectkey++) { for (let selectkey = 0; selectkey < nbTraitement; selectkey++) {
if (parseInt(fichesValid[key]['Fiche']['id'], 10) === parseInt(selectedList[selectkey], 10)) { if (parseInt(fichesValid[key]['Fiche']['id'], 10) === parseInt(selectedList[selectkey], 10)) {
traitement.push(fichesValid[key]); traitement.push(fichesValid[key]);
} }
} }
} }
for (var key = 0; key < nbTraitement; key++) { for (let key = 0; key < nbTraitement; key++) {
var tr = $('<tr id="'+selectedList[key]+'"><\/tr>') let tr = $('<tr id="'+selectedList[key]+'"><\/tr>')
.append('<td class="col-md-1"><select class="form-control optionSelected" required="required">' + createOption(nbTraitement, key+1) + '<\/select><\/td>') .append('<td class="col-md-1"><select class="form-control optionSelected" required="required">' + createOption(nbTraitement, key+1) + '<\/select><\/td>')
.append('<td class="col-md-1 tdleft">'+traitement[key]['Fiche']['numero']+'<\/td>') .append('<td class="col-md-1 tdleft">'+traitement[key]['Fiche']['numero']+'<\/td>')
.append('<td class="col-md-3 tdleft">'+traitement[key]['Fiche']['Valeur']['outilnom']+'<\/td>') .append('<td class="col-md-3 tdleft">'+traitement[key]['Fiche']['Valeur']['outilnom']+'<\/td>')
...@@ -672,10 +673,10 @@ ...@@ -672,10 +673,10 @@
}); });
$(".optionSelected").change(function () { $(".optionSelected").change(function () {
var newPosition = parseInt($(this).val(), 10); let newPosition = parseInt($(this).val(), 10),
var row = $(this).closest("tr"); row = $(this).closest("tr"),
var table = $('#render > tbody'); table = $('#render > tbody'),
var nRow = table.children('tr').eq(newPosition-1); nRow = table.children('tr').eq(newPosition-1);
if (oldPosition !== newPosition){ if (oldPosition !== newPosition){
if (oldPosition > newPosition) { if (oldPosition > newPosition) {
...@@ -690,89 +691,55 @@ ...@@ -690,89 +691,55 @@
}); });
function reordonnerPosition(){ function reordonnerPosition()
var table = $('#render > tbody'); {
var nbRow = table.children('tr').length; let table = $('#render > tbody'),
nbRow = table.children('tr').length;
for (var i = 0; i < nbRow; i++) { for (let i = 0; i < nbRow; i++) {
var newValue = i + 1; let newValue = i + 1,
var nRow = table.children('tr').eq(i); nRow = table.children('tr').eq(i),
var row = nRow.children('td').children('select'); row = nRow.children('td').children('select');
row.val(newValue).attr('selected', true); row.val(newValue).attr('selected', true);
} }
} }
function sendDataExtrait() { function sendDataExtrait()
var url = "<?php echo Router::url(['controller' => 'fiches', 'action' => 'genereExtraitRegistre']); ?>"; {
var selectedList = []; window.location.href = send("<?php echo Router::url(['controller' => 'fiches', 'action' => 'genereExtraitRegistre']); ?>");
var table = $('#render > tbody');
var nbRow = table.children('tr').length;
for (var i = 0; i < nbRow; i++) {
var nRow = table.children('tr').eq(i);
var idRow = nRow.attr('id');
selectedList.push(idRow);
}
url = url + '/' + JSON.stringify(selectedList);
window.location.href = url;
} }
function sendData() { function sendData()
var url = "<?php echo Router::url(['controller' => 'registres', 'action' => 'imprimer']); ?>"; {
var selectedList = []; window.location.href = send("<?php echo Router::url(['controller' => 'registres', 'action' => 'imprimer']); ?>");
var table = $('#render > tbody');
var nbRow = table.children('tr').length;
for (var i = 0; i < nbRow; i++) {
var nRow = table.children('tr').eq(i);
var idRow = nRow.attr('id');
selectedList.push(idRow);
}
url = url + '/' + JSON.stringify(selectedList);
window.location.href = url;
} }
function sendDataDeclaration() { function sendDataDeclaration()
var url = "<?php echo Router::url(['controller' => 'fiches', 'action' => 'genereTraitementNonVerrouiller']); ?>"; {
var selectedList = []; window.location.href = send("<?php echo Router::url(['controller' => 'fiches', 'action' => 'genereTraitementNonVerrouiller']); ?>");
var table = $('#render > tbody');
var nbRow = table.children('tr').length;
for (var i = 0; i < nbRow; i++) {
var nRow = table.children('tr').eq(i);
var idRow = nRow.attr('id');
selectedList.push(idRow);
}
url = url + '/' + JSON.stringify(selectedList);
window.location.href = url;
} }
function sendDataExport() { function sendDataExport()
var url = "<?php echo Router::url(['controller' => 'fiches', 'action' => 'export']); ?>"; {
var selectedList = []; window.location.href = send("<?php echo Router::url(['controller' => 'fiches', 'action' => 'export']); ?>");
}
function send (url)
{
let selectedList = [],
table = $('#render > tbody'),
nbRow = table.children('tr').length;
for (let i = 0; i < nbRow; i++) {
let nRow = table.children('tr').eq(i),
idRow = nRow.attr('id');
var table = $('#render > tbody');
var nbRow = table.children('tr').length;
for (var i = 0; i < nbRow; i++) {
var nRow = table.children('tr').eq(i);
var idRow = nRow.attr('id');
selectedList.push(idRow); selectedList.push(idRow);
} }
url = url + '/' + JSON.stringify(selectedList); return (url + '/' + JSON.stringify(selectedList));
window.location.href = url;
} }
//]]> //]]>
</script> </script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment