finish vehicle

This commit is contained in:
Tiavina 2025-02-21 13:57:37 +03:00
parent d95643ee24
commit 8c8956b843
43 changed files with 390 additions and 35 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

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
*/

View File

@ -40,7 +40,23 @@ class VehicleRepository {
}
public function getVehicles(){
$sql = "SELECT * FROM ".$this->gestionTablePrefix."vehicle";
$sql = "SELECT
vehicle.id,
vehicle.brand,
vehicle.model,
vehicle.immatriculation,
vehicle.purchase_date,
vehicle.fk_vehicle_purchase_type_key,
vehicle.fk_thanato_id,
vehicle_purchase_type.type_label as purchase_type_label,
thanato.nom as thanato_name,
thanato.prenom as thanato_last_name
FROM ".$this->gestionTablePrefix."vehicle as vehicle
LEFT JOIN ".$this->gestionTablePrefix."vehicle_purchase_type as vehicle_purchase_type
ON vehicle.fk_vehicle_purchase_type_key = vehicle_purchase_type.type_key
LEFT JOIN ".$this->gestionTablePrefix."thanato as thanato
ON vehicle.fk_thanato_id = thanato.id
";
return $this->execSQL($sql, []);
}

View File

@ -15,6 +15,6 @@ CREATE TABLE IF NOT EXISTS oc_gestion_vehicle(
model VARCHAR(200) DEFAULT '',
immatriculation VARCHAR(200) DEFAULT '',
purchase_date DATE,
fk_vehicule_purchase_type_key VARCHAR(200) DEFAULT 'LOA',
fk_vehicle_purchase_type_key VARCHAR(200) DEFAULT 'LOA',
fk_thanato_id INT
);

View File

@ -22,6 +22,7 @@ import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
import { ClientGroupFacturation } from "../objects/clientGroupFacturation.mjs";
import { Provider } from "../objects/provider.mjs";
import { OrderProduct } from "../objects/orderProduct.mjs";
import { Vehicle } from "../objects/vehicle.mjs";
var choose_folder = t('gestion', 'Choose work folder');
$('body').on('click', '#theFolder', function () {
@ -262,6 +263,7 @@ $('body').on('click', '.deleteItem', function () {
if (modifier === "clientGroupFacturation") { ClientGroupFacturation.loadClientGroupFacturationDatatable(dt); }
if (modifier === "provider") { Provider.loadProviderDatatable(dt); }
if (modifier === "orderProduct") { OrderProduct.loadOrderProductDatatable(dt); }
if (modifier === "vehicle") { Vehicle.loadVehicleDatatable(dt); }
});

View File

@ -0,0 +1,15 @@
import DataTable from "datatables.net";
import { Vehicle } from "../objects/vehicle.mjs";
import { hideLoader, showLoader,baseUrl } from "../modules/mainFunction.mjs";
import { showError, showSuccess } from "@nextcloud/dialogs";
document.body.addEventListener('click', e => {
if(e.target.className.includes("selectVehiclePurchaseType")){
Vehicle.loadVehiclePurchaseTypesIntoSelect(e);
return;
}
if("createDefaultVehicle"=== e.target.id){
Vehicle.createDefaultVehicle(new DataTable('.tabledt'));
return;
}
});

View File

@ -87,6 +87,8 @@ export function getStats() {
$("#clientGroupFacturationStat").text(res.clientGroupFacturation);
$("#providerStat").text(res.provider);
$("#orerProductStat").text(res.orderProduct);
$("#vehicleStat").text(res.vehicle);
}).fail(function (response, code) {
showError(response);
});

View File

@ -0,0 +1,209 @@
import { showError } from "@nextcloud/dialogs";
import { updateDB } from "../modules/ajaxRequest.mjs";
import {
baseUrl,
checkSelectPurJs,
hideLoader,
LoadDT,
removeOptions,
showDone,
showLoader,
} from "../modules/mainFunction.mjs";
export class Vehicle {
/**
*
* @param myresp instantiate client object
*/
constructor(myresp) {
this.id = myresp.id;
this.brand = myresp.brand.length === 0 ? "-" : myresp.brand;
this.model = myresp.model.length === 0 ? "-" : myresp.model;
this.immatriculation =
myresp.immatriculation.length === 0 ? "-" : myresp.immatriculation;
this.purchase_type_label =
myresp.purchase_type_label == null ||
myresp.purchase_type_label.length === 0
? "-"
: myresp.purchase_type_label;
this.thanatoFullName = Vehicle.getThanatoFullname(myresp);
this.purchaseDate = myresp.purchase_date;
this.vehiclePurchaseTypeKey = myresp.fk_vehicle_purchase_type_key;
this.thanatoId = myresp.fk_thanato_id;
}
static getThanatoFullname(myresp) {
let thanatoPrenom = "";
let thanatoNom = "";
let thanatoFullName = "";
if (myresp.thanato_name != null && myresp.thanato_name.length != 0) {
thanatoNom = myresp.thanato_name;
thanatoFullName += thanatoNom;
}
if (
myresp.thanato_last_name != null &&
myresp.thanato_last_name.length != 0
) {
thanatoPrenom = myresp.thanato_last_name;
if (thanatoNom.length > 0 && thanatoPrenom.length > 0) {
thanatoFullName += " ";
}
thanatoFullName += thanatoPrenom;
}
return thanatoFullName.length === 0 ? "-" : thanatoFullName;
}
/**
* Get datatable row for a client
*/
getDTRow() {
let myrow = [
"<div>" + this.id + "</div>",
'<input style="margin:0;padding:0;" class="inputDate" type="date" value=' +
this.purchaseDate +
' data-table="vehicle" data-column="purchase_date" data-id="' +
this.id +
'"/>',
'<div class="editable" data-table="vehicle" data-column="brand" data-id="' +
this.id +
'">' +
this.brand +
"</div>",
'<div class="editable" data-table="vehicle" data-column="model" data-id="' +
this.id +
'">' +
this.model +
"</div>",
'<div class="editable" data-table="vehicle" data-column="immatriculation" data-id="' +
this.id +
'">' +
this.immatriculation +
"</div>",
'<div class="selectVehiclePurchaseType" data-table="vehicle" data-column="fk_vehicle_purchase_type_key" data-id="' +
this.id +
'" data-current="' +
this.vehiclePurchaseTypeKey +
'">' +
this.purchase_type_label +
"</div>",
'<div class="loadSelect_listthanato" data-table="vehicle" data-column="fk_thanato_id" data-id="' +
this.id +
'" data-current="' +
this.thanatoId +
'">' +
this.thanatoFullName +
"</div>",
'<center><div data-modifier="vehicle" data-id=' +
this.id +
' data-table="vehicle" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center>',
];
return myrow;
}
/**
*
* @param {*} vehicleDatatable
*/
static loadVehicleDatatable(vehicleDatatable) {
var oReq = new XMLHttpRequest();
oReq.open("PROPFIND", baseUrl + "/vehicle/list", true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function (e) {
if (this.status == 200) {
LoadDT(vehicleDatatable, JSON.parse(this.response), Vehicle);
} else {
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} dt
*/
static createDefaultVehicle(dt) {
var oReq = new XMLHttpRequest();
showLoader();
oReq.open("POST", baseUrl + "/vehicle/createDefaultVehicle", true);
oReq.onload = function (e) {
if (this.status == 200) {
if (this.response != null) {
showDone();
Vehicle.loadVehicleDatatable(dt);
} else {
showError("Erreur dans la création d'un fournisseur");
}
} else {
showError("Erreur dans la création d'un fournisseur");
}
hideLoader();
};
oReq.send();
}
static getVehiclePurchaseTypes(callback) {
var oReq = new XMLHttpRequest();
oReq.open("PROPFIND", baseUrl + "/vehicle/purchase-type/list", 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 {*} e
*/
static loadVehiclePurchaseTypesIntoSelect(e) {
Vehicle.getVehiclePurchaseTypes((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
);
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.type_label;
var option = document.createElement("option");
option.value = myresp.type_key;
option.text = txt.value;
selectElement.appendChild(option);
});
checkSelectPurJs(selectElement);
e.target.innerHTML = "";
e.target.appendChild(selectElement);
});
}
}

13
gestion/src/js/vehicle.js Normal file
View File

@ -0,0 +1,13 @@
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/vehicleListener";
import { Vehicle } from "./objects/vehicle.mjs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
Vehicle.loadVehicleDatatable(new DataTable(".tabledt",optionDatatable));
});

View File

@ -0,0 +1,30 @@
<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>Véhicule</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="createDefaultVehicle">Ajouter un véhicule</button>
</div>
</div>
<table id="tableVehicleList" class="display tabledt">
<thead>
<tr>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t("Date d'achat"));?></th>
<th><?php p($l->t('Marque'));?></th>
<th><?php p($l->t('Modèle'));?></th>
<th><?php p($l->t('Immatriculation'));?></th>
<th><?php p($l->t("Type d'achat"));?></th>
<th><?php p($l->t('Thanatopracteur'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

@ -290,13 +290,13 @@
</li>
<li class="app-navigation-entry-submenu">
<span class="navmarg icon-toggle-pictures"></span>
<a class="a-entry-submenu" href="<?php echo($_['url']['index']); ?>">
<a class="a-entry-submenu" href="<?php echo($_['url']['vehicle']); ?>">
<?php p($l->t('Véhicules'));?>
</a>
<div class="app-navigation-entry-utils-submenu">
<ul>
<li class="app-navigation-entry-utils-counter">
<span>5</span>
<span id="vehicleStat"><div class="loader"></div></span>
</li>
</ul>
</div>

View File

@ -0,0 +1,19 @@
<?php
style('gestion', array('style'));
script('gestion', array('vehicle.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/vehicle')); ?>
<?php print_unescaped($this->inc('loader')); ?>
</div>
</div>
</div>

View File

@ -35,7 +35,8 @@ module.exports =
clientGroupFacturation : './src/js/clientGroupFacturation.js',
orderDetails : './src/js/orderDetails.js',
provider : './src/js/provider.js',
orderProduct : './src/js/orderProduct.js'
orderProduct : './src/js/orderProduct.js',
vehicle : './src/js/vehicle.js'
},
output: {
filename: '../js/[name].app.js',