save in nextcloud from backend
This commit is contained in:
parent
219acacce5
commit
ece1356203
@ -31,7 +31,6 @@ return [
|
||||
['name' => 'page#getThanatopracteurs', 'url' => '/getThanatopracteurs', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#insertThanatopracteur', 'url' => '/thanatopracteur/insert', 'verb' => 'POST'],
|
||||
['name' => 'page#exportThanatoStatistic', 'url' => '/thanatopracteur/exportThanatoStatistic', 'verb' => 'POST'],
|
||||
['name' => 'page#generateSamplePdf', 'url' => '/generateSamplePdf', 'verb' => 'POST'],
|
||||
|
||||
['name' => 'page#getDevis', 'url' => '/getDevis', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#getDevisDelphine', 'url' => '/getDevisDelphine/{idtrajetdetails}', 'verb' => 'PROPFIND'],
|
||||
@ -65,6 +64,7 @@ return [
|
||||
['name' => 'page#apercustousdevis', 'url' => '/devis/apercus', 'verb' => 'GET'],
|
||||
['name' => 'page#insertFacture', 'url' => '/facture/insert', 'verb' => 'POST'],
|
||||
['name' => 'page#exportDevisToFacture', 'url' => '/exportDevisToFacture', 'verb' => 'POST'],
|
||||
['name' => 'page#exportFactureToPdf', 'url' => '/facture/exportFactureToPdf', 'verb' => 'POST'],
|
||||
|
||||
['name' => 'page#getProduits', 'url' => '/getProduits', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#getProduitsById', 'url' => '/getProduitsById', '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
@ -2638,37 +2638,10 @@ class PageController extends Controller {
|
||||
*
|
||||
*/
|
||||
|
||||
public function generateSamplePdf($factureId){
|
||||
$factureId = 1;
|
||||
$configs = json_decode($this->myDb->getConfiguration($this->idNextcloud));
|
||||
$currentConfig = $configs[0];
|
||||
$logo = $this->getLogo();
|
||||
$invoicePdfData = $this->myDb->getInvoicePdfData($factureId,$currentConfig);
|
||||
if($invoicePdfData == null){
|
||||
return "";
|
||||
}
|
||||
public function exportFactureToPdf($factureId){
|
||||
try{
|
||||
$clean_folder = html_entity_decode($currentConfig->path).'/';
|
||||
$_clean_folder = $clean_folder.'SAMPLES/';
|
||||
try {
|
||||
$this->storage->newFolder($_clean_folder);
|
||||
}
|
||||
catch(\OCP\Files\NotPermittedException $e) {
|
||||
|
||||
}
|
||||
$pdf = new InvoicePdfHandler();
|
||||
$pdf->InvoicePdfFactory($invoicePdfData,$logo);
|
||||
$pdfContent = $pdf->GetFactureContent();
|
||||
|
||||
$pdf->Output();
|
||||
$ff_pdf = $_clean_folder.Uuid::uuid4()->toString().'.pdf';
|
||||
$this->storage->newFile($ff_pdf);
|
||||
$file_pdf = $this->storage->get($ff_pdf);
|
||||
$file_pdf->putContent($pdfContent);
|
||||
|
||||
$res = array();
|
||||
$res['path'] = $_clean_folder;
|
||||
return json_encode($res);
|
||||
$factureFilenames = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->idNextcloud);
|
||||
return json_encode($factureFilenames);
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
|
||||
|
||||
@ -62,7 +62,8 @@ class InvoicePdfHandler extends FPDF {
|
||||
public function GetFilename(){
|
||||
$factureNum = $this->factureData['num'];
|
||||
$factureNum = str_replace('/','-',$factureNum);
|
||||
return $this->factureData['configuration']->facture_prefixe.'_'.$factureNum.'_'.strtoupper($this->factureData['defunt_nom']);
|
||||
$defuntNom = str_replace(' ',' ',$this->factureData['defunt_nom']);
|
||||
return $this->factureData['configuration']->facture_prefixe.'_'.$factureNum.'_'.strtoupper($defuntNom);
|
||||
}
|
||||
|
||||
public function GetFactureContent(){
|
||||
|
||||
@ -86,15 +86,14 @@ class InvoicePdfService {
|
||||
foreach($factureFolders as $folder){
|
||||
try {
|
||||
$this->storage->newFolder($folder);
|
||||
$ff_pdf = $folder.$pdfFilename.'.pdf';
|
||||
$this->storage->newFile($ff_pdf);
|
||||
$file_pdf = $this->storage->get($ff_pdf);
|
||||
$file_pdf->putContent($pdfContent);
|
||||
$filenames[] = $ff_pdf;
|
||||
}
|
||||
catch(\OCP\Files\NotPermittedException $e) {
|
||||
|
||||
}
|
||||
$ff_pdf = $folder.$pdfFilename.'.pdf';
|
||||
$this->storage->newFile($ff_pdf);
|
||||
$file_pdf = $this->storage->get($ff_pdf);
|
||||
$file_pdf->putContent($pdfContent);
|
||||
$filenames[] = $ff_pdf;
|
||||
}
|
||||
return $filenames;
|
||||
}
|
||||
|
||||
@ -486,4 +486,27 @@ $('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"));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@ -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">
|
||||
@ -104,7 +105,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" data-html2canvas-ignore data-name=""><?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