finish thanato product fee crud

This commit is contained in:
Tiavina 2025-02-07 16:11:45 +03:00
parent d153ea598e
commit e0f37ee1cc
38 changed files with 422 additions and 94 deletions

View File

@ -15,7 +15,6 @@ return [
['name' => 'page#isConfig', 'url' => '/isconfig', 'verb' => 'GET'],
['name' => 'page#statistique', 'url' => '/statistique', 'verb' => 'GET'],
['name' => 'page#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'],
['name' => 'order#order', 'url' => '/order', 'verb' => 'GET'],
['name' => 'page#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
@ -152,8 +151,12 @@ return [
['name' => 'page#getUsersNotLinkedToThanato','url' => '/user/getUsersNotLinkedToThanato', 'verb' => 'PROPFIND'],
//order
['name' => 'order#order', 'url' => '/order', 'verb' => 'GET'],
['name' => 'order#thanatoProductFee', 'url' => '/thanatoProductFee', 'verb' => 'GET'],
['name' => 'order#getOrdersWithDetails','url' => '/order/list', 'verb' => 'PROPFIND'],
['name' => 'order#createDefaultOrder','url' => '/order/createDefaultOrder', 'verb' => 'POST'],
['name' => 'order#updateOrderDate','url' => '/order/{orderId}/updateDate', 'verb' => 'PUT'],
['name' => 'order#getThanatoProductsFees','url' => '/thanatoProductFees/list', 'verb' => 'PROPFIND'],
['name' => 'order#createDefaultThanatoProductFee','url' => '/thanatoProductFees/createDefaultThanatoProductFee', '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

View File

@ -0,0 +1,46 @@
/*!
* Sizzle CSS Selector Engine v2.3.9
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2022-12-19
*/
/*!
* Toastify js 1.12.0
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/
/*!
* escape-html
* Copyright(c) 2012-2013 TJ Holowaychuk
* Copyright(c) 2015 Andreas Lubbe
* Copyright(c) 2015 Tiancheng "Timothy" Gu
* MIT Licensed
*/
/*!
* jQuery JavaScript Library v3.6.3
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2022-12-20T21:28Z
*/
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
/*! DataTables 1.13.2
* ©2008-2023 SpryMedia Ltd - datatables.net/license
*/

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

@ -135,4 +135,35 @@ class OrderController extends Controller {
return null;
}
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function thanatoProductFee() {
return new TemplateResponse('gestion', 'thanatoProductFee', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getThanatoProductsFees() {
$thanatoProductsFees = $this->orderService->getThanatoProductsFees();
return json_encode($thanatoProductsFees);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function createDefaultThanatoProductFee() {
try{
$this->orderService->createDefaultThanatoProductFee();
return true;
}
catch(Exception $e){
return null;
}
}
}

View File

@ -2,6 +2,7 @@
namespace OCA\Gestion\Controller;
use Exception;
use OCA\Gestion\Service\NavigationService;
defined("TAB1") or define("TAB1", "\t");
use OCP\IGroupManager;
@ -59,6 +60,9 @@ class PageController extends Controller {
/** @var CertificateService */
private $certificateService;
/** @var \OCA\Gestion\Service\NavigationService */
private $navigationService;
/**
* Constructor
*/
@ -76,7 +80,8 @@ class PageController extends Controller {
ExportClientStatisticService $exportClientStatisticService,
InvoicePdfService $invoicePdfService,
DevisPdfService $devisPdfService,
CertificateService $certificateService){
CertificateService $certificateService,
NavigationService $navigationService){
parent::__construct($AppName, $request);
@ -90,6 +95,7 @@ class PageController extends Controller {
$this->invoicePdfService = $invoicePdfService;
$this->devisPdfService = $devisPdfService;
$this->certificateService = $certificateService;
$this->navigationService = $navigationService;
//$this->fpdf = $fpdf;
if ($userSession->isLoggedIn()) {
@ -117,7 +123,7 @@ class PageController extends Controller {
*
*/
public function index() {
return new TemplateResponse('gestion', 'index', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/index.php
return new TemplateResponse('gestion', 'index', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/index.php
}
/**
@ -126,7 +132,7 @@ class PageController extends Controller {
*
*/
public function defunt() {
return new TemplateResponse('gestion', 'defunt', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/thanatopracteur.php
return new TemplateResponse('gestion', 'defunt', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/thanatopracteur.php
}
/**
@ -136,7 +142,7 @@ class PageController extends Controller {
*/
public function thanatopracteur() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'thanatopracteur', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/thanatopracteur.php
return new TemplateResponse('gestion', 'thanatopracteur', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/thanatopracteur.php
}
/**
@ -144,7 +150,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function devis() {
return new TemplateResponse('gestion', 'devis', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/devis.php
return new TemplateResponse('gestion', 'devis', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/devis.php
}
/**
@ -153,7 +159,7 @@ class PageController extends Controller {
*/
public function trajet() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'trajet', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/trajet.php
return new TemplateResponse('gestion', 'trajet', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/trajet.php
}
/**
@ -161,7 +167,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function lieu() {
return new TemplateResponse('gestion', 'lieu', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/lieu.php
return new TemplateResponse('gestion', 'lieu', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/lieu.php
}
/**
@ -170,7 +176,7 @@ class PageController extends Controller {
*/
public function facture() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'facture', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/facture.php
return new TemplateResponse('gestion', 'facture', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/facture.php
}
/**
@ -179,7 +185,7 @@ class PageController extends Controller {
*/
public function article() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'article', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/produit.php
return new TemplateResponse('gestion', 'article', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/produit.php
}
/**
@ -188,7 +194,7 @@ class PageController extends Controller {
*/
public function produit() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'produit', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/produit.php
return new TemplateResponse('gestion', 'produit', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/produit.php
}
/**
@ -197,7 +203,7 @@ class PageController extends Controller {
*/
public function bibliotheque() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'bibliotheque', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/produit.php
return new TemplateResponse('gestion', 'bibliotheque', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/produit.php
}
/**
@ -206,7 +212,7 @@ class PageController extends Controller {
*/
public function statistique() {
$this->denyIfNotAdmin();
return new TemplateResponse('gestion', 'statistique', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/statistique.php
return new TemplateResponse('gestion', 'statistique', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/statistique.php
}
/**
@ -214,7 +220,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function legalnotice($page) {
return new TemplateResponse('gestion', 'legalnotice', array('groups' => $this->groups, 'user' => $this->user, 'page' => 'content/legalnotice', 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/legalnotice.php
return new TemplateResponse('gestion', 'legalnotice', array('groups' => $this->groups, 'user' => $this->user, 'page' => 'content/legalnotice', 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/legalnotice.php
}
/**
@ -222,7 +228,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function france() {
return new TemplateResponse('gestion', 'legalnotice', array('groups' => $this->groups, 'user' => $this->user, 'page' => 'legalnotice/france', 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/legalnotice.php
return new TemplateResponse('gestion', 'legalnotice', array('groups' => $this->groups, 'user' => $this->user, 'page' => 'legalnotice/france', 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/legalnotice.php
}
/**
@ -231,7 +237,7 @@ class PageController extends Controller {
*/
public function config() {
$this->myDb->checkConfig($this->idNextcloud);
return new TemplateResponse('gestion', 'configuration', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/configuration.php
return new TemplateResponse('gestion', 'configuration', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/configuration.php
}
/**
@ -248,7 +254,7 @@ class PageController extends Controller {
'produit'=>json_decode($produits),
'article'=>json_decode($articles),
'path' => $this->idNextcloud,
'url' => $this->getNavigationLink(),
'url' => $this->navigationService->getNavigationLink(),
'logo' => $this->getLogo()
));
}
@ -263,7 +269,7 @@ class PageController extends Controller {
return new TemplateResponse('gestion', 'defuntshow', array( 'groups' => $this->groups, 'user' => $this->user, 'configuration'=> $this->getConfiguration(),
'defunt'=>json_decode($defunt),
'path' => $this->idNextcloud,
'url' => $this->getNavigationLink(),
'url' => $this->navigationService->getNavigationLink(),
'logo' => $this->getLogo()
));
}
@ -279,7 +285,7 @@ class PageController extends Controller {
return new TemplateResponse('gestion', 'trajetdetails', array(
'groups' => $this->groups, 'user' => $this->user,
'path' => $this->idNextcloud,
'url' => $this->getNavigationLink(),
'url' => $this->navigationService->getNavigationLink(),
'trajet' => json_decode($trajet)
));// templates/trajetdetails.php
}
@ -295,7 +301,7 @@ class PageController extends Controller {
return new TemplateResponse('gestion', 'factureshow', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
'configuration'=> $this->getConfiguration(),
'facture'=>json_decode($facture),
'url' => $this->getNavigationLink(),
'url' => $this->navigationService->getNavigationLink(),
'logo' => $this->getLogo()
));
}
@ -316,7 +322,7 @@ class PageController extends Controller {
'configuration'=> $this->getConfiguration(),
'devis'=> $devis,
'clients'=> $clients,
'url' => $this->getNavigationLink(),
'url' => $this->navigationService->getNavigationLink(),
'logo' => $this->getLogo()
));
}
@ -352,7 +358,7 @@ class PageController extends Controller {
'configuration'=> $this->getConfiguration(),
'factures'=> $factures,
'clients'=> $clients,
'url' => $this->getNavigationLink(),
'url' => $this->navigationService->getNavigationLink(),
'logo' => $this->getLogo()
));
}
@ -365,31 +371,6 @@ class PageController extends Controller {
return $this->myDb->isConfig($this->idNextcloud);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getNavigationLink(){
return array(
"index" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.index"),
"defunt" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.defunt"),
"devis" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.devis"),
"thanatopracteur" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.thanatopracteur"),
"trajet" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.trajet"),
"lieu" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.lieu"),
"facture" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.facture"),
"produit" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.produit"),
"article" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.article"),
"bibliotheque" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.bibliotheque"),
"config" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.config"),
"isConfig" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.isConfig"),
"statistique" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.statistique"),
"legalnotice" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.legalnotice"),
"france" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.france"),
"orders" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.order"),
);
}
/**
* @NoAdminRequired
* @NoCSRFRequired

View File

@ -37,11 +37,12 @@ class Bdd {
"rasage", "presentation_cosmetique", "presentation_sur", "hypodermiques", "hypodermiques_sur", "local", "local_sur", "contenu",
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit",
"fk_thanato_type_key","thanato_email","fk_user_uuid",
"fk_defunt_id","fk_lieu_id","fk_client_id","fk_thanato_id");
"fk_defunt_id","fk_lieu_id","fk_client_id","fk_thanato_id",
"fk_product_id","ht_price");
$this->whiteTable = array("client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit",
"configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis",
"bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
"orders");
"orders","thanato_product_discount");
$this->tableprefix = '*PREFIX*' ."gestion_";
$this->pdo = $db;
$this->l = $l;

View File

@ -61,6 +61,26 @@ class OrderBdd {
return true;
}
private function updateOrderNumber($orderId,$datetime){
$lastOrderNumber = $this->getLastOrderNumber();
$currentOrderNumber = $lastOrderNumber + 1;
$currentOrderFullNumber = OrderHelpers::GetFullOrderNumberByDateAndOrderNumber($datetime,$currentOrderNumber);
$sql = "UPDATE ".$this->orderTablePrefix."orders as orders
SET orders.order_number = ?,orders.order_full_number = ?
WHERE orders.id = ?
";
$this->execSQLNoData($sql,[$currentOrderNumber,$currentOrderFullNumber,$orderId]);
}
private function updateOrderDate($orderId,$orderDate){
$sql = "UPDATE ".$this->orderTablePrefix."orders as orders
SET orders.order_date = ?
WHERE orders.id = ?
";
$this->execSQLNoData($sql,[$orderDate,$orderId]);
}
public function getOrderByCalendarUuid($calendarUuid){
$sql = "SELECT * FROM ".$this->orderTablePrefix."orders as orders
WHERE orders.fk_calendar_uuid = ? LIMIT 1";
@ -213,30 +233,34 @@ class OrderBdd {
);
}
private function updateOrderNumber($orderId,$datetime){
$lastOrderNumber = $this->getLastOrderNumber();
$currentOrderNumber = $lastOrderNumber + 1;
$currentOrderFullNumber = OrderHelpers::GetFullOrderNumberByDateAndOrderNumber($datetime,$currentOrderNumber);
$sql = "UPDATE ".$this->orderTablePrefix."orders as orders
SET orders.order_number = ?,orders.order_full_number = ?
WHERE orders.id = ?
";
$this->execSQLNoData($sql,[$currentOrderNumber,$currentOrderFullNumber,$orderId]);
}
private function updateOrderDate($orderId,$orderDate){
$sql = "UPDATE ".$this->orderTablePrefix."orders as orders
SET orders.order_date = ?
WHERE orders.id = ?
";
$this->execSQLNoData($sql,[$orderDate,$orderId]);
}
public function updateOrderDateAndSetNewOrderNumber($orderId,$date){
$this->updateOrderDate($orderId,$date);
$datetime = new Datetime($date);
$this->updateOrderNumber($orderId,$datetime);
}
public function getThanatoProductDiscountList(){
$sql = "SELECT
thanato_product_discount.id,
thanato_product_discount.fk_thanato_id,
thanato_product_discount.fk_product_id,
thanato.nom as thanato_nom,
thanato.prenom as thanato_prenom,
produit.reference as produit_reference,
produit.description as produit_description,
produit.prix_unitaire as produit_ht_price
FROM ".$this->orderTablePrefix."thanato_product_discount as thanato_product_discount
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on thanato_product_discount.fk_thanato_id = thanato.id
LEFT JOIN ".$this->orderTablePrefix."produit as produit on thanato_product_discount.fk_product_id = produit.id
ORDER BY thanato_product_discount.id DESC
";
return $this->execSQLNoJsonReturn($sql,[]);
}
public function createDefaultThanatoProductFee(){
$sql = "INSERT INTO `".$this->orderTablePrefix."thanato_product_discount` (`fk_thanato_id`,`fk_product_id`,`ht_price`) VALUES (0,0,0);";
$this->execSQLNoData($sql, []);
}
}

View File

@ -54,6 +54,7 @@ class NavigationService {
"legalnotice" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.legalnotice"),
"france" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.france"),
"orders" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.order"),
"thanatoProductFees" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.thanatoProductFee"),
);
}

View File

@ -67,4 +67,12 @@ class OrderService {
public function updateOrderDate($orderId,$date){
$this->orderBdd->updateOrderDateAndSetNewOrderNumber($orderId,$date);
}
public function getThanatoProductsFees(){
return $this->orderBdd->getThanatoProductDiscountList();
}
public function createDefaultThanatoProductFee(){
$this->orderBdd->createDefaultThanatoProductFee();
}
}

View File

@ -16,6 +16,7 @@ import { Defunt } from "../objects/defunt.mjs";
import { Bibliotheque } from "../objects/bibliotheque.mjs";
import { Order } from "../objects/order.mjs";
import { ThanatoEmployeeTypeKey,ThanatoSubcontractorTypeKey } from "../constants/thanatoTypeConstant";
import { ThanatoProductFee } from "../objects/thanatoProductFee.mjs";
var choose_folder = t('gestion', 'Choose work folder');
@ -74,6 +75,9 @@ document.body.addEventListener('click', e => {
else if(e.target.className.includes("selectThanatoType")){
Thanatopracteur.loadThanatoTypeIntoSelect(e);
}
else if(e.target.className.includes("selectProductsList")){
Produit.loadProductListToSelect(e);
}
else if(e.target.className.includes("loadSelect_listDelphineDevis")){
// Devis.loadDevisThanatoList_dnum(e);
Devis.loadDevisByDateByLieu(e);
@ -233,6 +237,7 @@ $('body').on('click', '.deleteItem', function () {
if (modifier === "defunt") { Defunt.loadDefuntDT(dt); }
if (modifier === "bibliotheque") { Bibliotheque.loadBibliothequeDT(dt); }
if (modifier === "orders") { Order.loadOrderDatatable(dt); }
if (modifier === "thanatoProductFee") { ThanatoProductFee.loadThanatoProductFeeDatatable(dt);}
});
$('body').on('change', '.listClient,.listDevis', function () {

View File

@ -0,0 +1,9 @@
import DataTable from "datatables.net";
import { ThanatoProductFee } from "../objects/thanatoProductFee.mjs";
document.body.addEventListener('click', e => {
if("createDefaultThanatoProductFee"=== e.target.id){
ThanatoProductFee.createDefaultThanatoProductFee(new DataTable('.tabledt'));
return;
}
});

View File

@ -1,6 +1,6 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, cur, LoadDT, showDone } from "../modules/mainFunction.mjs";
import { baseUrl, cur, LoadDT, showDone,checkSelectPurJs} from "../modules/mainFunction.mjs";
import { updateDB } from "../modules/ajaxRequest.mjs";
export class Produit {
/**
@ -28,6 +28,20 @@ export class Produit {
return myrow;
}
static getProductsList(callback){
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/getProduits', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
if (this.status == 200) {
callback(JSON.parse(this.response));
}else{
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} productDT
@ -63,4 +77,56 @@ export class Produit {
};
oReq.send();
}
/**
*
* @param {*} lid
*/
static loadProductListToSelect(e){
Produit.getProductsList(response => {
var selectElement = document.createElement("select");
selectElement.dataset.current = e.target.dataset.current;
selectElement.dataset.id = e.target.dataset.id;
selectElement.dataset.old = e.target.innerHTML;
selectElement.addEventListener("change", el=>{
if(el.target.value != 0){
updateDB(el.target.parentElement.dataset.table,
el.target.parentElement.dataset.column,
el.target.value,
el.target.parentElement.dataset.id
);
// location.reload();
var parentElement = el.target.parentElement
parentElement.innerHTML = el.target.options[el.target.selectedIndex].text;
parentElement.dataset.current = el.target.value;
}else{
var parentElement = el.target.parentElement
parentElement.innerHTML = el.target.dataset.old
}
});
var option = document.createElement("option");
option.value = 0;
option.text = t('gestion', 'Cancel');
selectElement.appendChild(option);
JSON.parse(response).forEach(myresp => {
var txt = document.createElement("textarea");
txt.innerHTML = myresp.reference;
var option = document.createElement("option");
option.value = myresp.id;
option.text = txt.value;
selectElement.appendChild(option);
});
checkSelectPurJs(selectElement);
e.target.innerHTML = ''
e.target.appendChild(selectElement);
});
}
}

View File

@ -0,0 +1,91 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, cur, LoadDT, showDone } from "../modules/mainFunction.mjs";
export class ThanatoProductFee {
/**
*
* @param myresp instantiate thanato product fee object
*/
constructor(myresp) {
this.id = myresp.id;
this.thanatoFullName = ThanatoProductFee.getThanatoFullname(myresp);
this.productReference = ((myresp.produit_reference == null || myresp.produit_reference.length === 0) ? '-' : myresp.produit_reference);
this.htAmount = myresp.produit_ht_price;
this.thanatoId = myresp.fk_thanato_id;
this.productId = myresp.fk_product_id;
}
static getThanatoFullname(myresp){
let thanatoPrenom = '';
let thanatoNom = '';
let thanatoFullName = '';
if(myresp.thanato_nom != null && myresp.thanato_nom.length != 0){
thanatoNom = myresp.thanato_nom;
thanatoFullName += thanatoNom;
}
if(myresp.thanato_prenom != null && myresp.thanato_prenom.length != 0){
thanatoPrenom = myresp.thanato_prenom;
if(thanatoNom.length > 0 && thanatoPrenom.length > 0){
thanatoFullName += ' '
}
thanatoFullName += thanatoPrenom;
}
return (thanatoFullName.length === 0) ? '-' : thanatoFullName;
}
/**
* Get datatable row for a fee per thanato per product
*/
getDTRow() {
let thanatoProductFeeRow = [
'<div>'+ this.id + '</div>',
'<div class="getThanatosSubcontractor" data-table="thanato_product_discount" data-column="fk_thanato_id" data-id="' + this.id + '" data-current="' + this.thanatoId + '">' + this.thanatoFullName + '</div>',
'<div class="selectProductsList" data-table="thanato_product_discount" data-column="fk_product_id" data-id="' + this.id + '" data-current="' + this.productId + '">' + this.productReference + '</div>',
'<div class="editableNumeric" data-table="thanato_product_discount" data-column="ht_price" data-id="' + this.id + '">' + cur.format(this.htAmount) + '</div>',
'<div data-modifier="thanatoProductFee" data-id=' + this.id + ' data-table="thanato_product_discount" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
];
return thanatoProductFeeRow;
}
/**
*
* @param {*} ThanatoProductFeeDatatable
*/
static loadThanatoProductFeeDatatable(ThanatoProductFeeDatatable) {
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/thanatoProductFees/list', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
if (this.status == 200) {
LoadDT(ThanatoProductFeeDatatable, JSON.parse(this.response), ThanatoProductFee);
}else{
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} dt
*/
static createDefaultThanatoProductFee(dt) {
var oReq = new XMLHttpRequest();
oReq.open('POST', baseUrl + '/thanatoProductFees/createDefaultThanatoProductFee', true);
oReq.onload = function(e){
if (this.status == 200) {
if(this.response != null){
showDone()
ThanatoProductFee.loadThanatoProductFeeDatatable(dt);
}
else{
showError("Erreur dans la création de tarifs par produit par thanato");
}
}else{
showError("Erreur dans la création de tarifs par produit par thanato");
}
};
oReq.send();
}
}

View File

@ -0,0 +1,14 @@
import "@nextcloud/dialogs/dist/index.css";
import "datatables.net-dt/css/jquery.dataTables.css";
import "../css/mycss.css";
import DataTable from "datatables.net";
import { globalConfiguration, optionDatatable } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import "./listener/thanatoProductFeeListener";
import "./listener/orderListener";
import { ThanatoProductFee } from "./objects/thanatoProductFee.mjs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
ThanatoProductFee.loadThanatoProductFeeDatatable(new DataTable(".tabledt",optionDatatable));
});

View File

@ -0,0 +1,27 @@
<div id="contentTable">
<div class="breadcrumb" data-html2canvas-ignore>
<div class="crumb svg crumbhome">
<a href="<?php echo($_['url']['index']); ?>" class="icon-home"></a>
<span style="display: none;"></span>
</div>
<div class="crumb svg crumbhome">
<span>Tarifs thanatos</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="createDefaultThanatoProductFee">Ajouter un tarif</button>
</div>
</div>
<table id="thanatoProductFeeList" class="display tabledt">
<thead>
<tr>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Thanato'));?></th>
<th><?php p($l->t('Articles'));?></th>
<th><?php p($l->t('Unit price without VAT'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

@ -174,8 +174,8 @@
</li>
<li class="app-navigation-entry-submenu">
<span class="navmarg icon-category-integration"></span>
<a class="a-entry-submenu" href="<?php echo($_['url']['index']); ?>">
<?php p($l->t('Groupe articles'));?>
<a class="a-entry-submenu" href="<?php echo($_['url']['thanatoProductFees']); ?>">
<?php p($l->t('Tarifs thanatos'));?>
</a>
<div class="app-navigation-entry-utils-submenu">
<ul>

View File

@ -0,0 +1,18 @@
<?php
style('gestion', array('style'));
script('gestion', array('thanatoProductFee.app', '814.app', '856.app'));
?>
<div id="app">
<div id="app-navigation">
<?php print_unescaped($this->inc('navigation/index')); ?>
<?php print_unescaped($this->inc('settings/index')); ?>
</div>
<div id="app-content">
<div id="app-content-wrapper">
<?php print_unescaped($this->inc('content/changelog')); ?>
<?php print_unescaped($this->inc('content/thanatoProductFee')); ?>
</div>
</div>
</div>

View File

@ -28,7 +28,8 @@ module.exports =
adminSection: './src/js/adminSection.js',
configuration: './src/js/configuration.js',
pdf: './src/js/pdf.js',
order: './src/js/order.js'
order: './src/js/order.js',
thanatoProductFee: './src/js/thanatoProductFee.js'
},
output: {
filename: '../js/[name].app.js',