From ee9c21f89f8e79603447c4ad9aaaa96086ced4b1 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Tue, 7 Jan 2025 10:30:59 +0300 Subject: [PATCH] create clientgroupdiscount table features from controller --- gestion/appinfo/routes.php | 3 ++- gestion/lib/Controller/PageController.php | 15 ++++++++++++++ gestion/lib/Db/Bdd.php | 25 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/gestion/appinfo/routes.php b/gestion/appinfo/routes.php index 18b417b..fe46303 100644 --- a/gestion/appinfo/routes.php +++ b/gestion/appinfo/routes.php @@ -126,7 +126,8 @@ return [ //SQL ['name' => 'page#addDevisNumberColumn', 'url' => '/addDevisNumberColumn', 'verb' => 'POST'], ['name' => 'page#addFactureNumberColumn', 'url' => '/addFactureNumberColumn', 'verb' => 'POST'], - + ['name' => 'page#addClientGroupDiscountFeatureTables', 'url' => '/addClientGroupDiscountFeatureTables', 'verb' => 'POST'], + //clients discount ['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'], ['name' => 'page#getClientGroups', 'url' => '/getClientGroups', 'verb' => 'PROPFIND'], diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index bc958eb..8c723b0 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -2878,4 +2878,19 @@ class PageController extends Controller { public function createDefaultClientGroupDiscount(){ return $this->myDb->createDefaultClientGroupDiscount(); } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * + */ + + public function addClientGroupDiscountFeatureTables(){ + try{ + $this->myDb->addClientGroupDiscountFeatureTables(); + return true; + } + catch(\OCP\Files\NotFoundException $e) { } + + } } diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index 5293831..52ad1fe 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -2647,6 +2647,31 @@ class Bdd { $sql = "SELECT count(*) as c from ".$this->tableprefix."client_group_discount;"; return $this->execSQL($sql, array()); } + + public function addClientGroupDiscountFeatureTables(){ + $createTableClientGroupSQL = "CREATE TABLE oc_gestion_client_group ( + id INT PRIMARY KEY AUTO_INCREMENT, + client_group_name VARCHAR(255) DEFAULT '' + );"; + + $this->execSQLNoData($createTableClientGroupSQL,[]); + + $addColumnFkClientGroupIdIntoClientTableSQL= "ALTER TABLE oc_gestion_client + ADD fk_client_group_id INT NULL;"; + + $this->execSQLNoData($addColumnFkClientGroupIdIntoClientTableSQL,[]); + + $createTableClientGroupDiscountSQL = "CREATE TABLE oc_gestion_client_group_discount ( + id INT PRIMARY KEY AUTO_INCREMENT, + fk_client_group_id INT NOT NULL, + fk_produit_id INT NOT NULL, + ht_amount FLOAT NOT NULL + );"; + + $this->execSQLNoData($createTableClientGroupDiscountSQL,[]); + + return true; + } } \ No newline at end of file