Merge branch 'hotfixes/hotfix-h2f-facture-and-devis' into releases/release-h2f
This commit is contained in:
commit
ffa2f227c5
@ -140,5 +140,8 @@ return [
|
||||
//certificate
|
||||
['name' => 'page#exportCareCertificate', 'url' => '/defunt/exportCareCertificate', 'verb' => 'POST'],
|
||||
|
||||
//devis facturation
|
||||
['name' => 'page#exportDevisToFacture', 'url' => '/exportDevisToFacture', 'verb' => 'POST'],
|
||||
|
||||
]
|
||||
];
|
||||
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
@ -31,6 +31,7 @@ class PageController extends Controller {
|
||||
// private $src_path = "/var/www/html/apps/gestion/img/";
|
||||
private $src_path = "/var/www/html/custom_apps/gestion/img/";
|
||||
private const H2F_DEFAULT_ADMIN = "Emmanuelle";
|
||||
private const DEFAULT_ADMIN = "admin";
|
||||
private $urlGenerator;
|
||||
private $mailer;
|
||||
private $config;
|
||||
@ -2755,4 +2756,17 @@ class PageController extends Controller {
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @param array $devisToFacture
|
||||
* @param string $paymentDate
|
||||
*/
|
||||
public function exportDevisToFacture($devisToFacture,$paymentDate) {
|
||||
$factureIdsGenerated = $this->myDb->insertFactureForeEachDevisId($this->idNextcloud,$devisToFacture,$paymentDate);
|
||||
$this->invoicePdfService->generateFacturePdfByFactureIds($factureIdsGenerated,$this->idNextcloud);
|
||||
$this->refreshFEC();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2412,4 +2412,86 @@ class Bdd {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getDevisIdListFilteredByMentionAndDevisListId($mentionToNotInclude,$devisListId){
|
||||
if (empty($devisListId)) {
|
||||
return [];
|
||||
}
|
||||
$placeholders = implode(',', array_fill(0, count($devisListId), '?'));
|
||||
$sql = "SELECT devis.id as id,devis.date as devis_date
|
||||
FROM ".$this->tableprefix."devis as devis
|
||||
WHERE devis.id IN ($placeholders) AND mentions != ?";
|
||||
|
||||
$result = $this->execSQLNoJsonReturn($sql,array_merge($devisListId, [$mentionToNotInclude]));
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getFactureIdByDevisId($devisId){
|
||||
$sql = "SELECT
|
||||
facture.id
|
||||
FROM ".$this->tableprefix."facture as facture
|
||||
WHERE facture.id_devis = ?
|
||||
ORDER BY facture.id DESC;";
|
||||
$facture = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$devisId]);
|
||||
if(!empty($facture)){
|
||||
return $facture[0]['id'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert invoice with a devis
|
||||
*/
|
||||
public function insertFactureByDevisId($idNextcloud,$devisId,$devisDate = null,$paymentDate = null){
|
||||
if($paymentDate == null || $paymentDate == ""){
|
||||
$datetimeNow = new Datetime();
|
||||
$paymentDate = DateHelpers::GetLastDayOfTheMonthOfADate($datetimeNow);
|
||||
$paymentDate = $paymentDate->format('Y-m-d');
|
||||
}
|
||||
else{
|
||||
$paymentDate = Datetime::createFromFormat('Y-m-d',$paymentDate);
|
||||
$paymentDate = $paymentDate->format('Y-m-d');
|
||||
}
|
||||
$devisDatetime = new Datetime();
|
||||
if($devisDate != null){
|
||||
$devisDatetime = new Datetime($devisDate);
|
||||
}
|
||||
|
||||
$last = 0;
|
||||
$last = $this->lastNumFacture($idNextcloud);
|
||||
$factureDate = $devisDatetime->format('Y-m-d');
|
||||
$datesplit = explode('-', $factureDate);
|
||||
$fullFactureNumber = "H2F".$datesplit[0]."/".$datesplit[1]."/".$last+1;
|
||||
$sql = "INSERT INTO `".$this->tableprefix."facture` (`date`,`id_nextcloud`,`num`,`date_paiement`,`type_paiement`,`id_devis`,`user_id`, `version`,`facture_number`) VALUES (?,?,?,?,?,?,?,?,?);";
|
||||
$this->execSQLNoData($sql, array(
|
||||
$factureDate,
|
||||
$idNextcloud,
|
||||
$fullFactureNumber,
|
||||
$paymentDate,
|
||||
"Comptant",
|
||||
$devisId,
|
||||
$last+1,
|
||||
"Ajouter un lieu",
|
||||
$last + 1 )
|
||||
);
|
||||
|
||||
$factureId = $this->getFactureIdByDevisId($devisId);
|
||||
//update devis status
|
||||
$this->gestion_update('devis','mentions','facturé',$devisId,$idNextcloud);
|
||||
return $factureId;
|
||||
}
|
||||
|
||||
public function insertFactureForeEachDevisId($idNextCloud,$devisIdArray,$paymentDate = null){
|
||||
$mentionToNotInclude = 'facturé';
|
||||
$devisIdListFiltered = $this->getDevisIdListFilteredByMentionAndDevisListId($mentionToNotInclude,$devisIdArray);
|
||||
$factureIdsGenerated = [];
|
||||
foreach($devisIdListFiltered as $devis){
|
||||
$factureId = $this->insertFactureByDevisId($idNextCloud,$devis['id'],$devis['devis_date'],$paymentDate);
|
||||
$factureIdsGenerated[] = $factureId;
|
||||
}
|
||||
return $factureIdsGenerated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class CareCertificatePdfHandler extends FPDF {
|
||||
function Header()
|
||||
{
|
||||
if($this->logo != "nothing"){
|
||||
$this->Image($this->imagePath."logo.png", 10, 10, 75, 25);
|
||||
$this->Image($this->imagePath."logo.png", 10, 10, 90, 35);
|
||||
}
|
||||
else{
|
||||
$this->Cell(55,30,'');
|
||||
|
||||
@ -6,6 +6,7 @@ import DataTable from "datatables.net";
|
||||
import { globalConfiguration, optionDatatable } from "./modules/mainFunction.mjs";
|
||||
import { Devis } from "./objects/devis.mjs";
|
||||
import "./listener/main_listener";
|
||||
import "./listener/devisListener";
|
||||
// import { Client } from './objects/client.mjs';
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
70
gestion/src/js/listener/devisListener.js
Normal file
70
gestion/src/js/listener/devisListener.js
Normal file
@ -0,0 +1,70 @@
|
||||
import {showError, showSuccess } from "@nextcloud/dialogs";
|
||||
import {baseUrl} from "../modules/mainFunction.mjs";
|
||||
import { Devis } from "../objects/devis.mjs";
|
||||
import DataTable from "datatables.net";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const today = new Date();
|
||||
const lastDayOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
|
||||
const formattedDate = lastDayOfMonth.toISOString().split('T')[0];
|
||||
const dateInput = document.getElementById('facturationDate');
|
||||
dateInput.value = formattedDate;
|
||||
});
|
||||
|
||||
$('body').on('click', '#showDevisFacturationModal', function () {
|
||||
var oTable = $('.tabledt').dataTable();
|
||||
var rowcollection = oTable.$(".devisToFacture:checked", {"page": "all"});
|
||||
let devisToFacture = [];
|
||||
rowcollection.each(function(index,elem){
|
||||
var checkbox_value = $(elem).val();
|
||||
devisToFacture.push(checkbox_value);
|
||||
});
|
||||
|
||||
if(devisToFacture.length == 0){
|
||||
showError(t('gestion', "Veuillez choisir une ligne de devis à facturer"));
|
||||
return;
|
||||
}
|
||||
$('#devisFacturationModal').show();
|
||||
});
|
||||
|
||||
$('body').on('click', '#closeDevisModal', function () {
|
||||
$('#devisFacturationModal').hide();
|
||||
});
|
||||
|
||||
$('body').on('click', '#invoiceQuote', function () {
|
||||
var dateValue = document.getElementById("facturationDate").value;
|
||||
var oTable = $('.tabledt').dataTable();
|
||||
var rowcollection = oTable.$(".devisToFacture:checked", {"page": "all"});
|
||||
let devisToFacture = [];
|
||||
rowcollection.each(function(index,elem){
|
||||
var checkbox_value = $(elem).val();
|
||||
devisToFacture.push(checkbox_value);
|
||||
});
|
||||
|
||||
if(devisToFacture.length == 0){
|
||||
$('#devisFacturationModal').hide();
|
||||
showError(t('gestion', "Veuillez choisir une ligne de devis à facturer"));
|
||||
return;
|
||||
}
|
||||
|
||||
let devisToFacturePayload = {
|
||||
devisToFacture: devisToFacture,
|
||||
paymentDate: dateValue
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/exportDevisToFacture',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(devisToFacturePayload)
|
||||
}).done(function (response) {
|
||||
$('#devisFacturationModal').hide();
|
||||
let datatable = new DataTable('.tabledt');
|
||||
Devis.loadDevisDT(datatable);
|
||||
showSuccess(t('gestion', "Devis facturés avec succès"));
|
||||
}).fail(function (response, code) {
|
||||
$('#devisFacturationModal').hide();
|
||||
showError(t('gestion', "Erreur dans la facturation du devis"));
|
||||
});
|
||||
});
|
||||
@ -466,3 +466,26 @@ $('body').on('click', '#exportClientStat', function () {
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('body').on('click', '#exportFactureToPdf', function () {
|
||||
var factureIdentifier = $('#factureIdentifier').data('id');
|
||||
var exportFacturePayload = {
|
||||
factureId: factureIdentifier
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/facture/exportFactureToPdf',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(exportFacturePayload)
|
||||
}).done(function (response) {
|
||||
var fileNames = JSON.parse(response);
|
||||
fileNames.forEach(fileName => {
|
||||
showSuccess('Sauvegardé dans' + fileName);
|
||||
});
|
||||
}).fail(function (response, code) {
|
||||
showError(t('gestion', "Please create a new hypodermique"));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@ -36,6 +36,7 @@ export class Devis {
|
||||
getDTRow() {
|
||||
let signe_prop = (this.id_nextcloud.toLowerCase() == 'emmanuelle')?'propdevis-emmanuelle':(this.id_nextcloud.toLowerCase() == 'delphine')?'propdevis-delphine':'';
|
||||
let myrow = [
|
||||
'<input class="devisToFacture" data-id= '+ this.id + ' type="checkbox" name="devisToFacture" value="' + this.id + '"/>',
|
||||
'<div><div class="'+signe_prop+'">' + this.user_id + '</div></div>',
|
||||
'<input style="margin:0;padding:0;" class="inputDate" type="date" value=' + this.date + ' data-table="devis" data-column="date" data-id="' + this.id + '"/>',
|
||||
// '<div class="editable" data-table="devis" data-column="num" data-id="' + this.id + '" style="display:inline">' + this.num + '</div>',
|
||||
|
||||
@ -18,7 +18,10 @@
|
||||
<div class="d-flex flex-row align-items-center"><div class="emmanuelle"></div> <div>Emmanuelle</div></div>
|
||||
<div class="d-flex flex-row align-items-center"><div class="delphine"></div> <div>Delphine</div></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button id="showDevisFacturationModal" class="btn btn-secondary" data-toggle="modal" data-target="#devisFacturationModal">
|
||||
Facturer
|
||||
</button>
|
||||
<button class="btn btn-secondary" id="apercusDevis">Voir les aperçus</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -26,6 +29,7 @@
|
||||
<table id="devis" class="display tabledt">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php p($l->t('ID'));?></th>
|
||||
<th><?php p($l->t('Quote date'));?></th>
|
||||
<!-- <th>Nom du défunt</th> -->
|
||||
@ -40,4 +44,20 @@
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="modal" id="devisFacturationModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Choisir la date de facturation souhaitée</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="date" id="facturationDate">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="closeDevisModal" type="button" class="btn btn-secondary">Annuler</button>
|
||||
<button id="invoiceQuote" type="button" class="btn btn-primary">Facturer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<div class="d-flex flex-column w-100">
|
||||
<h2 class="mt-3 mb-3 text-center"><?php p($l->t('Invoice #'));?>
|
||||
<div id="factureid" style="display:inline"><?php echo $_['facture'][0]->num;?></div>
|
||||
<div id="factureIdentifier" data-id="<?php echo $_['facture'][0]->id;?>" class="d-none"></div>
|
||||
</h2>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
@ -98,7 +99,7 @@
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
<button id="pdf" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore data-name=""><?php p($l->t('Save in Nextcloud'));?></button>
|
||||
<button id="exportFactureToPdf" type="button" class="mb-2 btn btn-outline-success"><?php p($l->t('Save in Nextcloud'));?></button>
|
||||
<button id="mailGestion" type="button" class="mb-2 btn btn-outline-success sendmail" data-html2canvas-ignore data-name=""><?php p($l->t('Send by email'));?></button>
|
||||
</div>
|
||||
<div class="mt-0 table-responsive">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user