Merge branch 'features/feature-thanato-vehicle' into releases/release-h2f
This commit is contained in:
commit
51823815f0
@ -188,5 +188,13 @@ return [
|
||||
['name' => 'order#orderProduct', 'url' => '/orderProduct', 'verb' => 'GET'],
|
||||
['name' => 'order#getOrderProducts','url' => '/orderProduct/list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'order#createDefaultOrderProduct','url' => '/orderProduct/createDefaultOrderProduct', 'verb' => 'POST'],
|
||||
|
||||
|
||||
//vehicles
|
||||
['name' => 'vehicle#vehicle', 'url' => '/vehicle', 'verb' => 'GET'],
|
||||
['name' => 'vehicle#getVehicles','url' => '/vehicle/list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'vehicle#getAvailableVehicles','url' => '/vehicle/available-list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'vehicle#getVehiclePurchaseTypes','url' => '/vehicle/purchase-type/list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'vehicle#createDefaultVehicle','url' => '/vehicle/createDefaultVehicle', '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
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
2
gestion/js/vehicle.app.js
Normal file
2
gestion/js/vehicle.app.js
Normal file
File diff suppressed because one or more lines are too long
46
gestion/js/vehicle.app.js.LICENSE.txt
Normal file
46
gestion/js/vehicle.app.js.LICENSE.txt
Normal 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
|
||||
*/
|
||||
10
gestion/lib/Constants/VehiclePurchaseTypeConstant.php
Normal file
10
gestion/lib/Constants/VehiclePurchaseTypeConstant.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Gestion\Constants;
|
||||
abstract class VehiclePurchaseTypeConstant
|
||||
{
|
||||
const LOA_TYPE = "LOA";
|
||||
const LLD_TYPE = "LLD";
|
||||
const CREDIT_TYPE = "CREDIT";
|
||||
}
|
||||
149
gestion/lib/Controller/VehicleController.php
Normal file
149
gestion/lib/Controller/VehicleController.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Controller;
|
||||
|
||||
use Exception;
|
||||
use OCA\Gestion\Service\ConfigurationService;
|
||||
use OCA\Gestion\Service\NavigationService;
|
||||
use OCA\Gestion\Service\Vehicle\VehicleService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
defined("TAB1") or define("TAB1", "\t");
|
||||
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Mail\IMailer;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IConfig;
|
||||
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
|
||||
class VehicleController extends Controller {
|
||||
private $idNextcloud;
|
||||
private $urlGenerator;
|
||||
private $mailer;
|
||||
private $config;
|
||||
|
||||
/** @var IRootStorage */
|
||||
private $storage;
|
||||
|
||||
private $user;
|
||||
private $groups = [];
|
||||
|
||||
/** @var \OCA\Gestion\Service\NavigationService */
|
||||
private $navigationService;
|
||||
|
||||
private $vehicleService;
|
||||
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
$UserId,
|
||||
IRootFolder $rootFolder,
|
||||
IURLGenerator $urlGenerator,
|
||||
IMailer $mailer,
|
||||
Iconfig $config,
|
||||
IUserSession $userSession,
|
||||
IGroupManager $groupManager,
|
||||
NavigationService $navigationService,
|
||||
ConfigurationService $configurationService,
|
||||
LoggerInterface $logger,
|
||||
VehicleService $vehicleService
|
||||
){
|
||||
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
$this->idNextcloud = $UserId;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->mailer = $mailer;
|
||||
$this->config = $config;
|
||||
$this->navigationService = $navigationService;
|
||||
$this->configurationService = $configurationService;
|
||||
$this->logger = $logger;
|
||||
$this->vehicleService = $vehicleService;
|
||||
|
||||
if ($userSession->isLoggedIn()) {
|
||||
$this->user = $userSession->getUser();
|
||||
}
|
||||
|
||||
if ($this->user != null) {
|
||||
$groups = $groupManager->getUserGroups($this->user);
|
||||
$this->groups = [];
|
||||
foreach ($groups as $group) {
|
||||
$this->groups[] = $group->getGID();
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
$this->storage = $rootFolder->getUserFolder($this->idNextcloud);
|
||||
}catch(\OC\User\NoUserException $e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function vehicle() {
|
||||
return new TemplateResponse('gestion', 'vehicle', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getVehicles() {
|
||||
$vehicles = $this->vehicleService->getVehicles();
|
||||
return $vehicles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function createDefaultVehicle() {
|
||||
try{
|
||||
$this->vehicleService->createDefaultVehicle();
|
||||
return true;
|
||||
}
|
||||
catch(Exception $e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getVehiclePurchaseTypes() {
|
||||
try{
|
||||
$types = $this->vehicleService->getVehiclePurchaseTypes();
|
||||
return $types;
|
||||
}
|
||||
catch(Exception $e){
|
||||
return json_encode([]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getAvailableVehicles() {
|
||||
try{
|
||||
$vehicles = $this->vehicleService->getAvailableVehicles();
|
||||
return $vehicles;
|
||||
}
|
||||
catch(Exception $e){
|
||||
return json_encode([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,13 +42,14 @@ class Bdd {
|
||||
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name",
|
||||
"provider_name","provider_last_name","provider_company_name","provider_siret_number","provider_phone","provider_email",
|
||||
"provider_address","provider_city","fk_provider_id",
|
||||
"label","fk_order_id","fk_order_item_id","quantity");
|
||||
"label","fk_order_id","fk_order_item_id","quantity",
|
||||
"brand","model","immatriculation","purchase_date","fk_vehicle_purchase_type_key","purchase_date");
|
||||
$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","thanato_product_discount",
|
||||
"client_group_discount","client_group","provider",
|
||||
"order_product","order_item");
|
||||
"order_product","order_item","vehicle");
|
||||
$this->tableprefix = '*PREFIX*' ."gestion_";
|
||||
$this->pdo = $db;
|
||||
$this->l = $l;
|
||||
|
||||
101
gestion/lib/Db/VehicleRepository.php
Normal file
101
gestion/lib/Db/VehicleRepository.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Db;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
use \Datetime;
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
|
||||
class VehicleRepository {
|
||||
private $gestionTablePrefix;
|
||||
|
||||
private $defaultTablePrefix;
|
||||
private IDbConnection $pdo;
|
||||
|
||||
public function __construct(IDbConnection $db) {
|
||||
$this->gestionTablePrefix = BddConstant::DEFAULT_TABLE_PREFIX ."gestion_";
|
||||
$this->defaultTablePrefix = BddConstant::DEFAULT_TABLE_PREFIX;
|
||||
$this->pdo = $db;
|
||||
}
|
||||
|
||||
private function execSQL($sql, $conditions){
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->execute($conditions);
|
||||
$data = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
private function execSQLNoData($sql, $conditions){
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->execute($conditions);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
private function execSQLNoJsonReturn($sql, $conditions){
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->execute($conditions);
|
||||
$data = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getVehicles(){
|
||||
$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, []);
|
||||
}
|
||||
|
||||
public function createDefaultVehicle(){
|
||||
$date = new DateTime();
|
||||
$date = $date->format("Y-m-d");
|
||||
$sql = "INSERT INTO `".$this->gestionTablePrefix."vehicle` (
|
||||
`purchase_date`
|
||||
)
|
||||
VALUES (?);";
|
||||
$this->execSQLNoData($sql, array(
|
||||
$date
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getVehiclePurchaseTypes(){
|
||||
$sql = "SELECT * FROM ".$this->gestionTablePrefix."vehicle_purchase_type";
|
||||
return $this->execSQL($sql, []);
|
||||
}
|
||||
|
||||
public function getVehicleCount(){
|
||||
$count = 0;
|
||||
$sql = "SELECT COUNT(vehicle.id) as vehicle_count
|
||||
FROM ".$this->gestionTablePrefix."vehicle as vehicle;";
|
||||
|
||||
$result = $this->execSQLNoJsonReturn($sql,[]);
|
||||
if(!empty($result)){
|
||||
$count = $result[0]["vehicle_count"];
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function getAvailableVehicles(){
|
||||
$sql = "SELECT * FROM ".$this->gestionTablePrefix."vehicle as vehicle
|
||||
WHERE vechile.fk_thanato_id IS NULL
|
||||
";
|
||||
|
||||
return $this->execSQL($sql, []);
|
||||
}
|
||||
|
||||
}
|
||||
@ -30,6 +30,7 @@ use OCA\Gestion\Constants\BddConstant;
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Db\OrderBdd;
|
||||
use OCA\Gestion\Db\ProviderRepository;
|
||||
use OCA\Gestion\Db\VehicleRepository;
|
||||
use OCA\Gestion\Service\Order\OrderService;
|
||||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -39,15 +40,18 @@ class MenuStatisticService {
|
||||
private $gestionBdd;
|
||||
private $orderBdd;
|
||||
private $providerRepository;
|
||||
private $vehicleRepository;
|
||||
|
||||
public function __construct(
|
||||
Bdd $gestionBdd,
|
||||
OrderBdd $orderBdd,
|
||||
ProviderRepository $providerRepository
|
||||
ProviderRepository $providerRepository,
|
||||
VehicleRepository $vehicleRepository
|
||||
) {
|
||||
$this->gestionBdd = $gestionBdd;
|
||||
$this->orderBdd = $orderBdd;
|
||||
$this->providerRepository = $providerRepository;
|
||||
$this->vehicleRepository = $vehicleRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,6 +77,7 @@ class MenuStatisticService {
|
||||
$res['clientGroupDiscount'] = json_decode($this->gestionBdd->getClientGroupDiscountCount())[0]->c;
|
||||
$res['clientGroupFacturation'] = json_decode($this->gestionBdd->getClientGroupFacturationCount())[0]->c;
|
||||
$res['orderProduct'] = $this->orderBdd->getOrderProductCount();
|
||||
$res['vehicle'] = $this->vehicleRepository->getVehicleCount();
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
@ -60,6 +60,7 @@ class NavigationService {
|
||||
"clientGroupFacturation" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupFacturation"),
|
||||
"provider" => $this->urlGenerator->linkToRouteAbsolute("gestion.provider.provider"),
|
||||
"orderProduct" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.orderProduct"),
|
||||
"vehicle" => $this->urlGenerator->linkToRouteAbsolute("gestion.vehicle.vehicle"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
62
gestion/lib/Service/Vehicle/VehicleService.php
Normal file
62
gestion/lib/Service/Vehicle/VehicleService.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
* @author Richard Steinmetz <richard@steinmetz.cloud>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Gestion\Service\Vehicle;
|
||||
|
||||
use OCA\Gestion\Db\ProviderRepository;
|
||||
use OCA\Gestion\Db\VehicleRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class VehicleService {
|
||||
private $providerRepository;
|
||||
private $vehicleRepository;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(
|
||||
VehicleRepository $vehicleRepository,
|
||||
LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
$this->vehicleRepository = $vehicleRepository;
|
||||
}
|
||||
|
||||
public function getVehicles(){
|
||||
return $this->vehicleRepository->getVehicles();
|
||||
}
|
||||
|
||||
public function createDefaultVehicle(){
|
||||
$this->vehicleRepository->createDefaultVehicle();
|
||||
}
|
||||
|
||||
public function getVehiclePurchaseTypes(){
|
||||
return $this->vehicleRepository->getVehiclePurchaseTypes();
|
||||
}
|
||||
|
||||
public function getAvailableVehicles(){
|
||||
return $this->vehicleRepository->getAvailableVehicles();
|
||||
}
|
||||
}
|
||||
20
gestion/lib/Sql/20250221-THANATO_VEHICLE.sql
Normal file
20
gestion/lib/Sql/20250221-THANATO_VEHICLE.sql
Normal file
@ -0,0 +1,20 @@
|
||||
CREATE TABLE IF NOT EXISTS oc_gestion_vehicle_purchase_type(
|
||||
type_key VARCHAR(200) PRIMARY KEY,
|
||||
type_label VARCHAR(200) DEFAULT ''
|
||||
);
|
||||
|
||||
insert into oc_gestion_vehicle_purchase_type(type_key,type_label) VALUES
|
||||
('LOA','Loa'),
|
||||
('LLD','Lld'),
|
||||
('CREDIT','Crédit');
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS oc_gestion_vehicle(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
brand VARCHAR(200) DEFAULT '',
|
||||
model VARCHAR(200) DEFAULT '',
|
||||
immatriculation VARCHAR(200) DEFAULT '',
|
||||
purchase_date DATE,
|
||||
fk_vehicle_purchase_type_key VARCHAR(200) DEFAULT 'LOA',
|
||||
fk_thanato_id INT
|
||||
);
|
||||
@ -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); }
|
||||
|
||||
});
|
||||
|
||||
|
||||
15
gestion/src/js/listener/vehicleListener.js
Normal file
15
gestion/src/js/listener/vehicleListener.js
Normal 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;
|
||||
}
|
||||
});
|
||||
@ -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);
|
||||
});
|
||||
|
||||
209
gestion/src/js/objects/vehicle.mjs
Normal file
209
gestion/src/js/objects/vehicle.mjs
Normal 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
13
gestion/src/js/vehicle.js
Normal 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));
|
||||
});
|
||||
30
gestion/templates/content/vehicle.php
Normal file
30
gestion/templates/content/vehicle.php
Normal 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>
|
||||
@ -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>
|
||||
|
||||
19
gestion/templates/vehicle.php
Normal file
19
gestion/templates/vehicle.php
Normal 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>
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user