finish export provider stat in frontend , wip create order when choosing thanato subcontractor on devis

This commit is contained in:
Tiavina 2025-02-20 15:11:06 +03:00
parent 0e42ee1dee
commit ff7cf88bca
31 changed files with 139 additions and 29 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -132,7 +132,12 @@ class ProviderController extends Controller {
* @NoCSRFRequired
*/
public function exportProvidersStatistic(array $providerIds,$year){
try{
$filenames = $this->providerStatisticService->exportProvidersStatisticByYear($providerIds,$year,$this->idNextcloud);
return json_encode($filenames);
return $filenames;
}
catch(Exception $e){
return [];
}
}
}

View File

@ -3,6 +3,12 @@ import { Provider } from "../objects/provider.mjs";
import { hideLoader, showLoader,baseUrl } from "../modules/mainFunction.mjs";
import { showError, showSuccess } from "@nextcloud/dialogs";
window.addEventListener("DOMContentLoaded", function () {
const today = new Date();
const currentYear = today.getFullYear();
this.document.getElementById("yearSelect").value = currentYear;
});
document.body.addEventListener('click', e => {
if(e.target.className.includes("selectProviders")){
Provider.loadProvidersIntoSelect(e);
@ -13,3 +19,69 @@ document.body.addEventListener('click', e => {
return;
}
});
$('body').on('click', '#showExportProviderStatModal', function () {
var oTable = $('.tabledt').dataTable();
var rowcollection = oTable.$(".providerToExport:checked", {"page": "all"});
let providerIdsToExport = [];
rowcollection.each(function(index,elem){
var checkbox_value = $(elem).val();
providerIdsToExport.push(checkbox_value);
});
if(providerIdsToExport.length == 0){
showError(t('gestion', "Veuillez choisir au moins une ligne de fournisseur"));
return;
}
$('#exportProviderStatModal').show();
});
$('body').on('click', '#closeProviderStatModal', function () {
$('#exportProviderStatModal').hide();
});
$('body').on('click', '#exportProviderStat', function () {
var oTable = $('.tabledt').dataTable();
var rowcollection = oTable.$(".providerToExport:checked", {"page": "all"});
let providerIdsToExport = [];
rowcollection.each(function(index,elem){
var checkbox_value = $(elem).val();
providerIdsToExport.push(checkbox_value);
});
if(providerIdsToExport.length == 0){
$('#exportProviderStatModal').hide();
showError(t('gestion', "Veuillez choisir au moins une ligne de fournisseur"));
return;
}
var today = new Date();
var yearValue = document.getElementById("yearSelect").value ?? today.getFullYear();
let exportProviderPayload = {
providerIds: providerIdsToExport,
year: yearValue
}
showLoader();
$.ajax({
url: baseUrl + '/provider/exportStat',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(exportProviderPayload)
}).done(function (response) {
if(response.length == 0){
showError(t('gestion', "Erreur lors de l'exportation de statistique"));
}
else{
$('#exportProviderStatModal').hide();
let datatable = new DataTable('.tabledt');
Provider.loadProviderDatatable(datatable);
response.forEach(fileName => {
showSuccess('Sauvegardé dans' + fileName);
});
}
}).always(function () {
hideLoader();
});
});

View File

@ -44,6 +44,7 @@ export class Provider {
*/
getDTRow() {
let myrow = [
'<input class="providerToExport" data-id= '+ this.id + ' type="checkbox" name="providerToExport" value="' + this.id + '"/>',
"<div>" + this.id + "</div>",
'<div class="editable" data-table="provider" data-column="provider_name" data-id="' +
this.id +

View File

@ -10,10 +10,16 @@
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="createDefaultProvider">Ajouter un fournisseur</button>
</div>
</div>
<div class="d-flex justify-content-end">
<button id="showExportProviderStatModal" class="btn btn-secondary" data-toggle="modal" data-target="#exportProviderStatModal">
Export stat
</button>
</div>
<table id="tableProviderList" class="display tabledt">
<thead>
<tr>
<th></th>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Nom'));?></th>
<th><?php p($l->t('Prénom'));?></th>
@ -29,4 +35,30 @@
<tbody>
</tbody>
</table>
<div class="modal" id="exportProviderStatModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Choisir l'année pour l'export</h5>
</div>
<div class="modal-body">
<div class="d-flex align-items-center gap-2">
<select class="form-select w-auto" name="year" id="yearSelect">
<?php
$currentYear = date('Y');
for ($year = $currentYear; $year >= $currentYear - 10; $year--) {
echo '<option value="' . $year . '"';
echo '>' . $year . '</option>';
}
?>
</select>
</div>
</div>
<div class="modal-footer">
<button id="closeProviderStatModal" type="button" class="btn btn-secondary">Annuler</button>
<button id="exportProviderStat" type="button" class="btn btn-primary">Exporter</button>
</div>
</div>
</div>
</div>
</div>