Merge branch 'features/feature-command-provider' into releases/release-h2f

This commit is contained in:
Tiavina 2025-02-13 17:26:58 +03:00
commit 262bdb7676
49 changed files with 747 additions and 47 deletions

View File

@ -175,5 +175,10 @@ return [
//client group facturation
['name' => 'page#getClientGroupFacturations', 'url' => '/client/getClientGroupFacturations', 'verb' => 'PROPFIND'],
['name' => 'page#createDefaultClientGroupFacturation', 'url' => '/client/createDefaultClientGroupFacturation', 'verb' => 'POST'],
//provider
['name' => 'provider#provider', 'url' => '/provider', 'verb' => 'GET'],
['name' => 'provider#getProviders','url' => '/provider/list', 'verb' => 'PROPFIND'],
['name' => 'provider#createDefaultProvider','url' => '/provider/createDefaultProvider', '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

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
namespace OCA\Gestion\Controller;
use Exception;
use OCA\Gestion\Service\MenuStatisticService;
use OCA\Gestion\Service\NavigationService;
use OCA\Gestion\Service\Order\OrderService;
defined("TAB1") or define("TAB1", "\t");
@ -67,6 +68,8 @@ class PageController extends Controller {
/** @var \OCA\Gestion\Service\Order\OrderService */
private $orderService;
private $menuStatisticService;
/**
* Constructor
*/
@ -86,7 +89,8 @@ class PageController extends Controller {
DevisPdfService $devisPdfService,
CertificateService $certificateService,
NavigationService $navigationService,
OrderService $orderService){
OrderService $orderService,
MenuStatisticService $menuStatisticService){
parent::__construct($AppName, $request);
@ -102,6 +106,7 @@ class PageController extends Controller {
$this->certificateService = $certificateService;
$this->navigationService = $navigationService;
$this->orderService = $orderService;
$this->menuStatisticService = $menuStatisticService;
//$this->fpdf = $fpdf;
if ($userSession->isLoggedIn()) {
@ -1968,23 +1973,8 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function getStats(){
$res = array();
$res['client'] = json_decode($this->myDb->numberClient($this->idNextcloud))[0]->c;
$res['defunt'] = json_decode($this->myDb->numberDefunt($this->idNextcloud))[0]->c;
$res['thanato'] = json_decode($this->myDb->numberThanato($this->idNextcloud))[0]->c;
$res['devis'] = json_decode($this->myDb->numberDevis($this->idNextcloud))[0]->c;
$res['lieu'] = json_decode($this->myDb->numberLieu($this->idNextcloud))[0]->c;
$res['trajet'] = json_decode($this->myDb->numberTrajet($this->idNextcloud))[0]->c;
$res['facture'] = json_decode($this->myDb->numberFacture($this->idNextcloud))[0]->c;
$res['produit'] = json_decode($this->myDb->numberProduit($this->idNextcloud))[0]->c;
$res['article'] = json_decode($this->myDb->numberArticle($this->idNextcloud))[0]->c;
$res['bibliotheque'] = json_decode($this->myDb->numberBibliotheque($this->idNextcloud))[0]->c;
$res['order'] = $this->orderService->getOrderCount();
$res['thanatoProductFee'] = $this->orderService->getThanatoProductFeeCount();
$res['clientGroup'] = json_decode($this->myDb->getClientGroupCount())[0]->c;
$res['clientGroupDiscount'] = json_decode($this->myDb->getClientGroupDiscountCount())[0]->c;
$res['clientGroupFacturation'] = json_decode($this->myDb->getClientGroupFacturationCount())[0]->c;
return json_encode($res);
$result = $this->menuStatisticService->getStats($this->idNextcloud);
return json_encode($result);
}
/**

View File

@ -0,0 +1,126 @@
<?php
namespace OCA\Gestion\Controller;
use Exception;
use OCA\Gestion\Service\ConfigurationService;
use OCA\Gestion\Service\NavigationService;
use OCA\Gestion\Service\Order\OrderPdfService;
use OCA\Gestion\Service\Order\OrderService;
use OCA\Gestion\Service\Provider\ProviderService;
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 OCA\Gestion\Db\Bdd;
use OCP\IURLGenerator;
use OCP\IConfig;
date_default_timezone_set('Europe/Paris');
class ProviderController 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 $providerService;
private $logger;
/**
* Constructor
*/
public function __construct($AppName,
IRequest $request,
$UserId,
Bdd $myDb,
IRootFolder $rootFolder,
IURLGenerator $urlGenerator,
IMailer $mailer,
Iconfig $config,
IUserSession $userSession,
IGroupManager $groupManager,
NavigationService $navigationService,
ConfigurationService $configurationService,
LoggerInterface $logger,
ProviderService $providerService
){
parent::__construct($AppName, $request);
$this->idNextcloud = $UserId;
$this->myDb = $myDb;
$this->urlGenerator = $urlGenerator;
$this->mailer = $mailer;
$this->config = $config;
$this->navigationService = $navigationService;
$this->configurationService = $configurationService;
$this->logger = $logger;
$this->providerService = $providerService;
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 provider() {
return new TemplateResponse('gestion', 'provider', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getProviders() {
$providers = $this->providerService->getProvidersAsArray();
return json_encode($providers);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function createDefaultProvider() {
try{
$this->providerService->createDefaultProvider($this->idNextcloud);
return true;
}
catch(Exception $e){
return null;
}
}
}

View File

@ -39,12 +39,13 @@ class Bdd {
"fk_thanato_type_key","thanato_email","fk_user_uuid",
"fk_defunt_id","fk_lieu_id","fk_client_id","fk_thanato_id",
"fk_product_id","ht_price",
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name");
"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");
$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");
"client_group_discount","client_group","provider");
$this->tableprefix = '*PREFIX*' ."gestion_";
$this->pdo = $db;
$this->l = $l;

View File

@ -207,6 +207,7 @@ class OrderBdd {
orders.fk_client_id,
orders.fk_thanato_id,
orders.fk_order_status_key,
orders.fk_provider_id,
thanato.id as thanato_id,
thanato.nom as thanato_nom,
thanato.prenom as thanato_prenom,
@ -219,13 +220,17 @@ class OrderBdd {
lieu.id as lieu_id,
lieu.adresse as lieu_adresse,
lieu.nom as lieu_nom,
order_status.status_label as order_status_label
order_status.status_label as order_status_label,
provider.provider_name as provider_name,
provider.provider_last_name as provider_last_name,
provider.provider_company_name as provider_company_name
FROM "
.$this->orderTablePrefix."orders as orders
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on orders.fk_thanato_id = thanato.id
LEFT JOIN ".$this->orderTablePrefix."client as client on orders.fk_client_id = client.id
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on orders.fk_defunt_id = defunt.id
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on orders.fk_lieu_id = lieu.id
LEFT JOIN ".$this->orderTablePrefix."provider as provider on orders.fk_provider_id = provider.id
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
ORDER BY orders.id DESC;
"

View File

@ -0,0 +1,74 @@
<?php
namespace OCA\Gestion\Db;
use OCA\Gestion\Constants\OrderStatusConstant;
use OCA\Gestion\Constants\ThanatoTypeConstant;
use OCA\Gestion\Helpers\OrderHelpers;
use OCP\IDBConnection;
use \Datetime;
use OCA\Gestion\Constants\BddConstant;
use Ramsey\Uuid\Uuid;
class ProviderRepository {
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 getProvidersList(){
$sql = "SELECT * FROM ".$this->gestionTablePrefix."provider as provider";
return $this->execSQLNoJsonReturn($sql,[]);
}
public function createDefaultProvider($idNextCloud){
$sql = "INSERT INTO `".$this->gestionTablePrefix."provider` (
`id_nextcloud`
)
VALUES (?);";
$this->execSQLNoData($sql, array(
$idNextCloud
)
);
}
public function getProviderCount(){
$count = 0;
$sql = "SELECT COUNT(provider.id) as provider_count
FROM ".$this->gestionTablePrefix."provider as provider;";
$result = $this->execSQLNoJsonReturn($sql,[]);
if(!empty($result)){
$count = $result[0]["provider_count"];
}
return $count;
}
}

View File

@ -0,0 +1,78 @@
<?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;
use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Db\Bdd;
use OCA\Gestion\Db\OrderBdd;
use OCA\Gestion\Db\ProviderRepository;
use OCA\Gestion\Service\Order\OrderService;
use OCP\IURLGenerator;
use Psr\Log\LoggerInterface;
class MenuStatisticService {
private $gestionBdd;
private $orderBdd;
private $providerRepository;
public function __construct(
Bdd $gestionBdd,
OrderBdd $orderBdd,
ProviderRepository $providerRepository
) {
$this->gestionBdd = $gestionBdd;
$this->orderBdd = $orderBdd;
$this->providerRepository = $providerRepository;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getStats($idNextCloud){
$res = array();
$res['client'] = json_decode($this->gestionBdd->numberClient($idNextCloud))[0]->c;
$res['defunt'] = json_decode($this->gestionBdd->numberDefunt($idNextCloud))[0]->c;
$res['thanato'] = json_decode($this->gestionBdd->numberThanato($idNextCloud))[0]->c;
$res['devis'] = json_decode($this->gestionBdd->numberDevis($idNextCloud))[0]->c;
$res['lieu'] = json_decode($this->gestionBdd->numberLieu($idNextCloud))[0]->c;
$res['trajet'] = json_decode($this->gestionBdd->numberTrajet($idNextCloud))[0]->c;
$res['facture'] = json_decode($this->gestionBdd->numberFacture($idNextCloud))[0]->c;
$res['produit'] = json_decode($this->gestionBdd->numberProduit($idNextCloud))[0]->c;
$res['article'] = json_decode($this->gestionBdd->numberArticle($idNextCloud))[0]->c;
$res['bibliotheque'] = json_decode($this->gestionBdd->numberBibliotheque($idNextCloud))[0]->c;
$res['order'] = $this->orderBdd->getOrderCount();
$res['provider'] = $this->providerRepository->getProviderCount();
$res['thanatoProductFee'] = $this->orderBdd->getThanatoProductFeeCount();
$res['clientGroup'] = json_decode($this->gestionBdd->getClientGroupCount())[0]->c;
$res['clientGroupDiscount'] = json_decode($this->gestionBdd->getClientGroupDiscountCount())[0]->c;
$res['clientGroupFacturation'] = json_decode($this->gestionBdd->getClientGroupFacturationCount())[0]->c;
return $res;
}
}

View File

@ -58,6 +58,7 @@ class NavigationService {
"clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"),
"clientGroupDiscount" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupDiscount"),
"clientGroupFacturation" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupFacturation"),
"provider" => $this->urlGenerator->linkToRouteAbsolute("gestion.provider.provider"),
);
}

View File

@ -0,0 +1,54 @@
<?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\Provider;
use OCA\Gestion\Db\OrderBdd;
use OCA\Gestion\Db\ProviderRepository;
use OCA\Gestion\Helpers\FileExportHelpers;
use Psr\Log\LoggerInterface;
class ProviderService {
private $providerRepository;
/** @var LoggerInterface */
private $logger;
public function __construct(
ProviderRepository $providerRepository,
LoggerInterface $logger) {
$this->logger = $logger;
$this->providerRepository = $providerRepository;
}
public function getProvidersAsArray(){
return $this->providerRepository->getProvidersList();
}
public function createDefaultProvider($idNextCloud){
$this->providerRepository->createDefaultProvider($idNextCloud);
}
}

View File

@ -0,0 +1,15 @@
create table oc_gestion_provider (
id INT PRIMARY KEY AUTO_INCREMENT,
provider_name VARCHAR(255) DEFAULT '',
provider_last_name VARCHAR(255) DEFAULT '',
provider_company_name VARCHAR(255) DEFAULT '',
provider_siret_number VARCHAR(255) DEFAULT '',
provider_phone VARCHAR(255) DEFAULT '',
provider_email VARCHAR(255) DEFAULT '',
provider_address VARCHAR(255) DEFAULT '',
provider_city VARCHAR(255) DEFAULT '',
id_nextcloud VARCHAR(255) DEFAULT ''
);
alter table oc_gestion_orders
add column fk_provider_id INT DEFAULT NULL;

View File

@ -20,6 +20,7 @@ import { ThanatoProductFee } from "../objects/thanatoProductFee.mjs";
import { ClientGroup } from '../objects/clientGroup.mjs';
import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
import { ClientGroupFacturation } from "../objects/clientGroupFacturation.mjs";
import { Provider } from "../objects/provider.mjs";
var choose_folder = t('gestion', 'Choose work folder');
$('body').on('click', '#theFolder', function () {
@ -258,6 +259,7 @@ $('body').on('click', '.deleteItem', function () {
if (modifier === "clientGroup") { ClientGroup.loadClientGroupDatatable(dt); }
if (modifier === "clientGroupDiscount") { ClientGroupDiscount.loadClientGroupDiscountDatatable(dt); }
if (modifier === "clientGroupFacturation") { ClientGroupFacturation.loadClientGroupFacturationDatatable(dt); }
if (modifier === "provider") { Provider.loadProviderDatatable(dt); }
});
$('body').on('change', '.listClient,.listDevis', function () {

View File

@ -0,0 +1,15 @@
import DataTable from "datatables.net";
import { Provider } from "../objects/provider.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("selectProviders")){
Provider.loadProvidersIntoSelect(e);
return;
}
if("createDefaultProvider"=== e.target.id){
Provider.createDefaultProvider(new DataTable('.tabledt'));
return;
}
});

View File

@ -84,6 +84,7 @@ export function getStats() {
$("#clientGroupStat").text(res.clientGroup);
$("#clientGroupDiscountStat").text(res.clientGroupDiscount);
$("#clientGroupFacturationStat").text(res.clientGroupFacturation);
$("#providerStat").text(res.provider);
}).fail(function (response, code) {
showError(response);
});

View File

@ -24,6 +24,8 @@ export class Order {
this.statusKey = ((myresp.fk_order_status_key == null || myresp.fk_order_status_key.length === 0) ? '-' : myresp.fk_order_status_key);
this.productReferences = ((myresp.product_references == null || myresp.product_references.length === 0) ? '-' : myresp.product_references);
this.orderDetailsUrl = generateUrl(`/apps/gestion/order/${this.id}/details`);
this.fkProviderId = myresp.fk_provider_id;
this.providerName = ((myresp.provider_name == null || myresp.provider_name.length === 0) ? '-' : myresp.provider_name);
}
static getClientFullname(myresp){
@ -90,6 +92,7 @@ export class Order {
'<div class="getThanatosSubcontractor" data-table="orders" data-column="fk_thanato_id" data-id="' + this.id + '" data-current="' + this.thanatoId + '">'+ this.thanatoFullName + '</div>',
'<div class="loadSelect_listlieu" data-table="orders" data-column="fk_lieu_id" data-id="' + this.id + '" data-current="' + this.locationId + '">'+ this.locationName + '</div>',
'<div>' + this.productReferences + '</div>',
'<div class="selectProviders" data-table="orders" data-column="fk_provider_id" data-id="' + this.id + '" data-current="' + this.fkProviderId + '">'+ this.providerName + '</div>',
'<div style="'+ Order.getComandStatusCssSytle(this.statusKey) +'">' + this.statusLabel + '</div>',
'<div style="display:inline-block;margin-right:0px;width:80%;"><a href="' + this.orderDetailsUrl + '"><button>' + t('gestion', 'Open') + '</button></a>'+'<div data-modifier="orders" data-id=' + this.id + ' data-table="orders" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
];
@ -137,4 +140,5 @@ export class Order {
};
oReq.send();
}
}

View File

@ -0,0 +1,201 @@
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 Provider {
/**
*
* @param myresp instantiate client object
*/
constructor(myresp) {
this.id = myresp.id;
this.providerName =
myresp.provider_name.length === 0 ? "-" : myresp.provider_name;
this.providerLastName =
myresp.provider_last_name.length === 0 ? "-" : myresp.provider_last_name;
this.providerCompanyName =
myresp.provider_company_name.length === 0
? "-"
: myresp.provider_company_name;
this.providerSiretNumber =
myresp.provider_siret_number.length === 0
? "-"
: myresp.provider_siret_number;
this.providerPhone =
myresp.provider_phone.length === 0 ? "-" : myresp.provider_phone;
this.providerEmail =
myresp.provider_email.length === 0 ? "-" : myresp.provider_email;
this.providerAddress =
myresp.provider_address.length === 0 ? "-" : myresp.provider_address;
this.providerCity =
myresp.provider_city.length === 0 ? "-" : myresp.provider_city;
}
/**
* Get datatable row for a client
*/
getDTRow() {
let myrow = [
"<div>" + this.id + "</div>",
'<div class="editable" data-table="provider" data-column="provider_name" data-id="' +
this.id +
'">' +
this.providerName +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_last_name" data-id="' +
this.id +
'">' +
this.providerLastName +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_company_name" data-id="' +
this.id +
'">' +
this.providerCompanyName +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_siret_number" data-id="' +
this.id +
'">' +
this.providerSiretNumber +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_phone" data-id="' +
this.id +
'">' +
this.providerPhone +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_email" data-id="' +
this.id +
'">' +
this.providerEmail +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_address" data-id="' +
this.id +
'">' +
this.providerAddress +
"</div>",
'<div class="editable" data-table="provider" data-column="provider_city" data-id="' +
this.id +
'">' +
this.providerCity +
"</div>",
'<center><div data-modifier="provider" data-id=' +
this.id +
' data-table="provider" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center>',
];
return myrow;
}
/**
*
* @param {*} providerDatatable
*/
static loadProviderDatatable(providerDatatable) {
var oReq = new XMLHttpRequest();
oReq.open("PROPFIND", baseUrl + "/provider/list", true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function (e) {
if (this.status == 200) {
LoadDT(providerDatatable, JSON.parse(this.response), Provider);
} else {
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} dt
*/
static createDefaultProvider(dt) {
var oReq = new XMLHttpRequest();
showLoader();
oReq.open("POST", baseUrl + "/provider/createDefaultProvider", true);
oReq.onload = function (e) {
if (this.status == 200) {
if (this.response != null) {
showDone();
Provider.loadProviderDatatable(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 getProviders(callback) {
var oReq = new XMLHttpRequest();
oReq.open("PROPFIND", baseUrl + "/provider/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 loadProvidersIntoSelect(e) {
Provider.getProviders((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.provider_name;
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

@ -6,6 +6,7 @@ import DataTable from "datatables.net";
import { globalConfiguration, optionDatatable } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import "./listener/orderListener";
import "./listener/providerListener";
import { Order } from "./objects/order.mjs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();

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/providerListener";
import { Provider } from "./objects/provider.mjs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
Provider.loadProviderDatatable(new DataTable(".tabledt",optionDatatable));
});

View File

@ -23,6 +23,7 @@
<th><?php p($l->t('Thanatopracteur'));?></th>
<th><?php p($l->t('Lieu'));?></th>
<th><?php p($l->t('Type de soins'));?></th>
<th><?php p($l->t('Fournisseur'));?></th>
<th><?php p($l->t('Etat'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>

View File

@ -0,0 +1,32 @@
<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>Fournisseur</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="createDefaultProvider">Ajouter un fournisseur</button>
</div>
</div>
<table id="tableProviderList" class="display tabledt">
<thead>
<tr>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Nom'));?></th>
<th><?php p($l->t('Prénom'));?></th>
<th><?php p($l->t('Entreprise'));?></th>
<th><?php p($l->t('Siret'));?></th>
<th><?php p($l->t('Téléphone'));?></th>
<th><?php p($l->t('Email'));?></th>
<th><?php p($l->t('Adresse'));?></th>
<th><?php p($l->t('Ville'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

@ -159,6 +159,19 @@
<span class="navmarg icon-contacts-dark"></span>
<a class="a-entry">Achats</a>
<ul class="app-navigation-submenu">
<li class="app-navigation-entry-submenu">
<span class="navmarg icon-category-integration"></span>
<a class="a-entry-submenu" href="<?php echo($_['url']['provider']); ?>">
<?php p($l->t('Fournisseur'));?>
</a>
<div class="app-navigation-entry-utils-submenu">
<ul>
<li class="app-navigation-entry-utils-counter">
<span id="providerStat"><div class="loader"></div></span>
</li>
</ul>
</div>
</li>
<li class="app-navigation-entry-submenu">
<span class="navmarg icon-category-integration"></span>
<a class="a-entry-submenu" href="<?php echo($_['url']['index']); ?>">

View File

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

View File

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