This commit is contained in:
Tiavina 2024-12-25 08:27:32 +03:00
parent fe4de56abb
commit 93216d1a14
29 changed files with 142 additions and 26 deletions

1
gestion/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

View File

@ -61,6 +61,7 @@ return [
['name' => 'page#apercustoutesfactures', 'url' => '/factures/apercus', 'verb' => 'GET'],
['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#getProduits', 'url' => '/getProduits', 'verb' => 'PROPFIND'],
['name' => 'page#getProduitsById', 'url' => '/getProduitsById', 'verb' => 'POST'],

1
gestion/js/673.app.js Normal file

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

@ -1433,9 +1433,13 @@ class PageController extends Controller {
$distance_temp = 0;
$last_point = NULL;
} else {
$currentDistance = 0;
if($trajetdetails[$i]->lid != NULL) $last_point = $trajetdetails[$i];
if($last_point->lid != NULL && $trajetdetails[$i+1]->lid != NULL) $distance_temp += $this->myDb->calcul_distance(floatval($last_point->latitude), floatval($last_point->longitude), floatval($trajetdetails[$i+1]->latitude), floatval($trajetdetails[$i+1]->longitude));
$ik_temp = $ik_temp.utf8_decode(html_entity_decode($trajetdetails[$i]->cprenoms.' '.$trajetdetails[$i]->cnom)).';'.utf8_decode($formatter_ds->format($date_temp)).';'.utf8_decode(html_entity_decode($trajetdetails[$i]->lieu))."\n";
if($last_point->lid != NULL && $trajetdetails[$i+1]->lid != NULL){
$currentDistance = $this->myDb->calcul_distance(floatval($last_point->latitude), floatval($last_point->longitude), floatval($trajetdetails[$i+1]->latitude), floatval($trajetdetails[$i+1]->longitude));
$distance_temp += $currentDistance;
}
$ik_temp = $ik_temp.utf8_decode(html_entity_decode($trajetdetails[$i]->cprenoms.' '.$trajetdetails[$i]->cnom)).';'.utf8_decode($formatter_ds->format($date_temp)).';'.utf8_decode(html_entity_decode($trajetdetails[$i]->lieu)).';'.$currentDistance."\n";
}
}
@ -1624,6 +1628,17 @@ class PageController extends Controller {
return $this->myDb->gestion_update($table, $column, $data, $id, $this->idNextcloud);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
* @param array $devisToFacture
*/
public function exportDevisToFacture($devisToFacture) {
$result = $this->myDb->insertFactureForeEachDevisId($this->idNextcloud,$devisToFacture);
$this->refreshFEC();
return true;
}
/**
* @NoAdminRequired
* @NoCSRFRequired

View File

@ -4,6 +4,7 @@ namespace OCA\Gestion\Db;
use OCP\IDBConnection;
use OCP\IL10N;
use \Datetime;
use Psr\Log\LoggerInterface;
class Bdd {
private String $charset = 'utf8mb4';
@ -13,7 +14,10 @@ class Bdd {
private String $tableprefix;
private $l;
public function __construct(IDbConnection $db, IL10N $l) {
/** @var LoggerInterface */
private $logger;
public function __construct(IDbConnection $db, IL10N $l, LoggerInterface $logger) {
$this->whiteColumn = array("date", "num", "id_client", "id_thanato", "entreprise", "nom", "prenom", "legal_one", "telephone", "mail", "adresse", "produit_id",
"quantite", "date_paiement", "type_paiement", "id_devis", "reference", "description", "prix_unitaire", "legal_two", "path", "tva_default", "coefficient_ik",
"mentions_default", "version", "mentions", "comment", "status_paiement", "devise", "auto_invoice_number", "changelog", "format", "comment", "user_id",
@ -28,6 +32,7 @@ class Bdd {
$this->tableprefix = '*PREFIX*' ."gestion_";
$this->pdo = $db;
$this->l = $l;
$this->logger = $logger;
}
public function getConfiguration($idNextcloud){
@ -892,6 +897,60 @@ class Bdd {
return $last;
}
private function getDevisIdListFilteredByMentionAndDevisListId($mentionToNotInclude,$devisListId){
if (empty($devisListId)) {
return [];
}
$placeholders = implode(',', array_fill(0, count($devisListId), '?'));
$this->logger->debug('Placeholders : ' . $placeholders);
$sql = "SELECT id as id
FROM ".$this->tableprefix."devis
WHERE id IN ($placeholders) AND mentions != ?";
$this->logger->debug('SQL : ' . $sql);
$result = $this->execSQLNoJsonReturn($sql,array_merge($devisListId, [$mentionToNotInclude]));
return $result;
}
public function insertFactureForeEachDevisId($idNextCloud,$devisIdArray){
$devisIdarrayToString = implode(',', $devisIdArray);
$this->logger->debug($devisIdarrayToString);
$mentionToNotInclude = 'facturé';
$devisIdListFiltered = $this->getDevisIdListFilteredByMentionAndDevisListId($mentionToNotInclude,$devisIdArray);
foreach($devisIdListFiltered as $devis){
$this->insertFactureByDevisId($idNextCloud,devisId: $devis['id']);
}
return true;
}
/**
* Insert invoice with a devis
*/
public function insertFactureByDevisId($idNextcloud,$devisId){
$last = 0;
$last = $this->lastNumFacture($idNextcloud);
$pref = $this->execSQLNoJsonReturn("SELECT * FROM ".$this->tableprefix."configuration WHERE id_nextcloud LIKE ?",array($idNextcloud));
$sql = "INSERT INTO `".$this->tableprefix."facture` (`date`,`id_nextcloud`,`num`,`date_paiement`,`type_paiement`,`id_devis`,`user_id`, `version`) VALUES (?,?,?,NOW(),?,?,?,?);";
$date_temp = new DateTime();
$date = $date_temp->format('Y-m-d');
$datesplit = explode('-', $date);
$this->execSQLNoData($sql, array(
$date ,
$idNextcloud,
"ETS".$datesplit[0]."/".$datesplit[1]."/".$last+1,
"Comptant",
$devisId,
$last+1,
"Ajouter un lieu"));
//update devis status
$this->gestion_update('devis','mentions','facturé',$devisId,$idNextcloud);
return $last;
}
public function insertProduit($idNextcloud){
$sql = "INSERT INTO `".$this->tableprefix."produit` (`id_nextcloud`,`reference`,`description`,`prix_unitaire`) VALUES (?,?,?,0);";

View File

@ -1,4 +1,4 @@
import { FilePicker, showError } from "@nextcloud/dialogs";
import { FilePicker, showError, showSuccess } from "@nextcloud/dialogs";
import { updateDB, configuration, updateEditable, deleteDB, getProduitsById, listProduit, getStatArticleAnnuel, getStatSoinsThanatoAnnuel, getStatSoinsThanatoWeekend, getArticlesById, listArticle, getObservationsById, getBijouxById, getHypodermiquesyId } from "../modules/ajaxRequest.mjs";
import { path, baseUrl, updateNumerical } from "../modules/mainFunction.mjs";
import DataTable from 'datatables.net';
@ -382,4 +382,38 @@ $('body').on('click', '#defuntAddHypodermique', function () {
$('body').on('click', '#about', function () {
var modal = document.getElementById("modalConfig");
modal.style.display = "block";
});
$('body').on('click', '#exportDevisToFacture', 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);
console.log("VALUE",checkbox_value);
});
if(devisToFacture.length == 0){
return;
}
let devisToFacturePayload = {
devisToFacture: devisToFacture
}
$.ajax({
url: baseUrl + '/exportDevisToFacture',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(devisToFacturePayload)
}).done(function (response) {
let datatable = new DataTable('.tabledt');
Devis.loadDevisDT(datatable);
showSuccess(t('gestion', "Devis exported to facture"));
}).fail(function (response, code) {
showError(t('gestion', "Please select devis to facture"));
});
});

View File

@ -37,6 +37,7 @@ export class Devis {
// let signe_prop = (this.id_nextcloud.toLowerCase() == 'emmanuelle')?'propdevis-emmanuelle':(this.id_nextcloud.toLowerCase() == 'delphine')?'propdevis-delphine':'';
let myrow = [
// '<div><div class="'+signe_prop+'">' + this.user_id + '</div></div>',
'<input class="devisToFacture" data-id= '+ this.user_id + ' type="checkbox" name="devisToFacture" value="' + this.id + '"/>',
'<div>' + this.user_id + '</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>',

View File

@ -16,6 +16,9 @@
<div class="d-flex jsutify-content-end">
<button class="btn btn-secondary" id="apercusDevis">Voir les aperçus</button>
</div>
<div class="d-flex jsutify-content-end">
<button class="btn btn-secondary" id="exportDevisToFacture">Facturer</button>
</div>
<!-- <div class="d-flex justify-content-between">
<div class="d-flex flex-column">
<div class="d-flex flex-row align-items-center"><div class="emmanuelle"></div>&nbsp; <div>Emmanuelle</div></div>
@ -26,9 +29,10 @@
</div>
</div> -->
<hr>
<table id="devis" class="display tabledt">
<table id="devis" class="display tabledt devisDataTable">
<thead>
<tr>
<th><?php p($l->t('To invoice'));?></th>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Quote date'));?></th>
<th>Défunt</th>