Skip to content

Commit ac7651d

Browse files
Merge pull request #334 from Evarisk/develop
21.0.0
2 parents 10b512a + 57d2a5d commit ac7651d

15 files changed

+733
-919
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
## Informations
44

55
- Numéro du module : 436380
6-
- Dernière mise à jour : 27/09/2023
6+
- Dernière mise à jour : 20/05/2025
77
- Éditeur : [Evarisk](https://evarisk.com)
88
- Thème : Eldy Menu
99
- Licence : GPLv3
1010
- Disponible sur : Windows - MacOS - Linux
1111

1212
### Version
1313

14-
- Version : 1.2.0
14+
- Version : 21.0.0
1515
- PHP : 7.4.33
16-
- Compatibilité : Dolibarr 19.0.0 - 20.0.0
17-
- Saturne Framework : 1.6.1
16+
- Compatibilité : Dolibarr 20.0.0 - 21.0.1
17+
- Saturne Framework : 21.0.0
1818

1919
## Liens
2020

class/actions_dolicar.class.php

Lines changed: 228 additions & 69 deletions
Large diffs are not rendered by default.

class/dolicardashboard.class.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/* Copyright (C) 2021-2025 EVARISK <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
/**
19+
* \file class/dolicardashboard.class.php
20+
* \ingroup digiquali
21+
* \brief Class file for manage DolicarDashboard
22+
*/
23+
24+
/**
25+
* Class for DolicarDashboard
26+
*/
27+
class DolicarDashboard
28+
{
29+
/**
30+
* @var DoliDB Database handler
31+
*/
32+
public DoliDB $db;
33+
34+
/**
35+
* Constructor
36+
*
37+
* @param DoliDB $db Database handler
38+
*/
39+
public function __construct(DoliDB $db)
40+
{
41+
$this->db = $db;
42+
}
43+
44+
/**
45+
* Load dashboard info
46+
*
47+
* @return array
48+
* @throws Exception
49+
*/
50+
public function load_dashboard(): array
51+
{
52+
global $langs;
53+
54+
$array = ['dolicar' => ['widgets' => [], 'graphs' => []]];
55+
56+
$regestrationCertifatesFr = saturne_fetch_all_object_type('registrationcertificatefr', '', '', 0, 0, [], 'AND', true, true, false, '');
57+
$numberOfRegestrationCertifatesFr = count($regestrationCertifatesFr);
58+
59+
$array['dolicar']['graphs'][] = RegistrationCertificateFr::load_dashboard($regestrationCertifatesFr);
60+
61+
$array['dolicar']['widgets']['informations'] = [
62+
'title' => $langs->transnoentities('Informations'),
63+
'picto' => 'fas fa-car',
64+
'label' => [$langs->transnoentities('DashboardNumberOfRegestrationCertifatesFr'), $langs->transnoentities('DashboardRemainingRequestsRequest')],
65+
'content' => [$numberOfRegestrationCertifatesFr, getDolGlobalInt('DOLICAR_API_REMAINING_REQUESTS_COUNTER')],
66+
'widgetName' => 'informations'
67+
];
68+
69+
return $array;
70+
}
71+
}

class/registrationcertificatefr.class.php

Lines changed: 136 additions & 57 deletions
Large diffs are not rendered by default.

core/modules/modDoliCar.class.php

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct($db)
7878
$this->editor_url = 'https://www.evarisk.com';
7979

8080
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
81-
$this->version = '1.2.0';
81+
$this->version = '21.0.0';
8282

8383
// Url to the file with your last numberversion of this module
8484
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
@@ -126,11 +126,12 @@ public function __construct($db)
126126
'productlotcard',
127127
'registrationcertificatefrcard',
128128
'dolicar_quickcreation',
129-
'get_sheet_linkable_objects',
129+
'saturnegetobjectsmetadata',
130130
'propallist',
131131
'orderlist',
132132
'invoicelist',
133-
'main'
133+
'main',
134+
'publiccontrol'
134135
]
135136
],
136137
// Set this to 1 if features of module are opened to external users
@@ -158,7 +159,7 @@ public function __construct($db)
158159

159160
// Prerequisites
160161
$this->phpmin = [7, 4]; // Minimum version of PHP required by module
161-
$this->need_dolibarr_version = [19, 0]; // Minimum version of Dolibarr required by module
162+
$this->need_dolibarr_version = [20, 0]; // Minimum version of Dolibarr required by module
162163

163164
// Messages at activation
164165
$this->warnings_activation = []; // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...)
@@ -310,7 +311,7 @@ public function __construct($db)
310311
$this->menu[$r++] = [
311312
'fk_menu' => 'fk_mainmenu=dolicar',
312313
'type' => 'left',
313-
'titre' => $langs->transnoentities('ListRegistrationcertificatefr'),
314+
'titre' => $langs->transnoentities('Registrationcertificatefrs'),
314315
'prefix' => '<i class="fas fa-car pictofixedwidth"></i>',
315316
'mainmenu' => 'dolicar',
316317
'leftmenu' => 'registrationcertificatefr',
@@ -479,40 +480,38 @@ public function init($options = ''): int
479480
dolibarr_set_const($this->db, 'DOLICAR_DB_VERSION', $this->version, 'chaine', 0, '', $conf->entity);
480481

481482
// Create extrafields during init
482-
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
483-
$extraFields = new ExtraFields($this->db);
483+
$commonExtraFieldsValue = ['entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"];
484484

485485
$extraFieldsArrays = [
486-
'registrationcertificatefr' => ['Label' => 'RegistrationCertificateFr', 'type' => 'link', 'length' => '', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 10, 'params' => 'a:1:{s:7:"options";a:1:{s:75:"RegistrationCertificateFr:dolicar/class/registrationcertificatefr.class.php";N;}}', 'alwayseditable' => 1, 'list' => 1, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
487-
'vehicle_model' => ['Label' => 'VehicleModel', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 20, 'params' => '', 'list' => 5, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
488-
'mileage' => ['Label' => 'Mileage', 'type' => 'int', 'length' => '', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 30, 'params' => '', 'alwayseditable' => 1, 'list' => 1, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
489-
'registration_number' => ['Label' => 'RegistrationNumber', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 40, 'params' => '', 'list' => 5, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
490-
'linked_product' => ['Label' => 'LinkedProduct', 'type' => 'link', 'length' => '', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 50, 'params' => 'a:1:{s:7:"options";a:1:{s:93:"Product:product/class/product.class.php:0:(t.entity:=:__ENTITY__) AND (t.fk_product_type:=:0)";N;}}', 'list' => 5, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
491-
'linked_lot' => ['Label' => 'LinkedProductBatch', 'type' => 'link', 'length' => '', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 60, 'params' => 'a:1:{s:7:"options";a:1:{s:75:"ProductLot:product/stock/class/productlot.class.php:(t.entity = __ENTITY__)";N;}}', 'list' => 5, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
492-
'first_registration_date' => ['Label' => 'FirstRegistrationDate', 'type' => 'date', 'length' => '', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 70, 'params' => '', 'list' => 5, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
493-
'VIN_number' => ['Label' => 'VINNumber', 'type' => 'varchar', 'length' => 128, 'elementtype' => ['propal', 'commande', 'facture'], 'position' => 80, 'params' => '', 'list' => 5, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
494-
'starting_mileage' => ['Label' => 'StartingMileage', 'type' => 'int', 'length' => '', 'elementtype' => ['actioncomm'], 'position' => 10, 'params' => '', 'alwayseditable' => 1, 'list' => 1, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
495-
'arrival_mileage' => ['Label' => 'ArrivalMileage', 'type' => 'int', 'length' => '', 'elementtype' => ['actioncomm'], 'position' => 20, 'params' => '', 'alwayseditable' => 1, 'list' => 1, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"],
496-
'json' => ['Label' => 'JSON', 'type' => 'text', 'length' => '', 'elementtype' => ['actioncomm'], 'position' => 30, 'params' => '', 'alwayseditable' => 1, 'list' => 0, 'help' => '', 'entity' => 0, 'langfile' => 'dolicar@dolicar', 'enabled' => "isModEnabled('dolicar')"]
486+
'registration_number' => ['Label' => 'RegistrationNumber', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 10, 'list' => 5],
487+
'vehicle_model' => ['Label' => 'VehicleModel', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 20, 'list' => 5],
488+
'VIN_number' => ['Label' => 'VINNumber', 'type' => 'varchar', 'length' => 128, 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 30, 'list' => 5],
489+
'first_registration_date' => ['Label' => 'FirstRegistrationDate', 'type' => 'date', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 40, 'list' => 5],
490+
'mileage' => ['Label' => 'Mileage', 'type' => 'int', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 50, 'list' => 1, 'alwayseditable' => 1],
491+
'registrationcertificatefr' => ['Label' => 'RegistrationCertificateFr', 'type' => 'link', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 60, 'list' => 1, 'alwayseditable' => 1, 'params' => ['RegistrationCertificateFr:dolicar/class/registrationcertificatefr.class.php' => NULL]],
492+
'linked_product' => ['Label' => 'LinkedProduct', 'type' => 'link', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 70, 'list' => 5, 'params' => ['Product:product/class/product.class.php:0:(t.entity:=:__ENTITY__) AND (t.fk_product_type:=:0)' => NULL]],
493+
'linked_lot' => ['Label' => 'LinkedProductBatch', 'type' => 'link', 'elementtype' => ['propal', 'commande', 'facture'], 'position' => $this->numero . 80, 'list' => 5, 'params' => ['ProductLot:product/stock/class/productlot.class.php:0:(t.entity:=:__ENTITY__)' => NULL]],
494+
495+
'starting_mileage' => ['Label' => 'StartingMileage', 'type' => 'int', 'elementtype' => ['actioncomm'], 'position' => 10, 'alwayseditable' => 1, 'list' => 1, 'enabled' => "isModEnabled('dolicar') && isModEnabled('agenda')"],
496+
'arrival_mileage' => ['Label' => 'ArrivalMileage', 'type' => 'int', 'elementtype' => ['actioncomm'], 'position' => 20, 'alwayseditable' => 1, 'list' => 1, 'enabled' => "isModEnabled('dolicar') && isModEnabled('agenda')"],
497+
'json' => ['Label' => 'JSON', 'type' => 'text', 'elementtype' => ['actioncomm'], 'position' => 30, 'alwayseditable' => 1, 'list' => 0, 'enabled' => "isModEnabled('dolicar') && isModEnabled('agenda')"]
497498
];
498499

499-
foreach ($extraFieldsArrays as $key => $extraField) {
500-
foreach ($extraField['elementtype'] as $extraFieldElementType) {
501-
$extraFields->update($key, $extraField['Label'], $extraField['type'], $extraField['length'], $extraFieldElementType, 0, 0, $this->numero . $extraField['position'], $extraField['params'], $extraField['alwayseditable'], '', $extraField['list'], ($extraField['help'][$extraFieldElementType] ?? $extraField['help']), '', '', $extraField['entity'], $extraField['langfile'], $extraField['enabled'] . ' && isModEnabled("' . ($extraFieldElementType != 'actioncomm' ? $extraFieldElementType : 'agenda') . '")', 0, 0, $extraField['css']);
502-
$extraFields->addExtraField($key, $extraField['Label'], $extraField['type'], $this->numero . $extraField['position'], $extraField['length'], $extraFieldElementType, 0, 0, '', $extraField['params'], $extraField['alwayseditable'], '', $extraField['list'], $extraField['help'], '', $extraField['entity'], $extraField['langfile'], $extraField['enabled'] . ' && isModEnabled("' . ($extraFieldElementType != 'actioncomm' ? $extraFieldElementType : 'agenda') . '")', 0, 0, $extraField['css']);
503-
}
504-
}
500+
saturne_manage_extrafields($extraFieldsArrays, $commonExtraFieldsValue);
505501

506502
if (getDolGlobalInt('DOLICAR_EXTRAFIELDS_BACKWARD_COMPATIBILITY') == 0) {
503+
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
504+
$extraFields = new ExtraFields($this->db);
505+
507506
$extraFieldsArrays = [
508-
'registrationcertificatefr' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
507+
'registration_number' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
509508
'vehicle_model' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
509+
'VIN_number' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
510+
'first_registration_date' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
510511
'mileage' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
511-
'registration_number' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
512+
'registrationcertificatefr' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
512513
'linked_product' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
513-
'linked_lot' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
514-
'first_registration_date' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']],
515-
'VIN_number' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']]
514+
'linked_lot' => ['elementtype' => ['propaldet', 'commandedet', 'facturedet']]
516515
];
517516

518517
foreach ($extraFieldsArrays as $key => $extraField) {
@@ -603,6 +602,9 @@ public function init($options = ''): int
603602
$product = new Product($this->db);
604603

605604
if (getDolGlobalInt('DOLICAR_DEFAULT_VEHICLE_SET') == 0) {
605+
// In order to avoid product creation error
606+
$conf->global->BARCODE_PRODUCT_ADDON_NUM = 0;
607+
606608
$product->ref = $langs->transnoentities('DefaultVehicle');
607609
$product->label = $langs->transnoentities('DefaultVehicle');
608610
$product->status_batch = 1;
@@ -615,24 +617,11 @@ public function init($options = ''): int
615617
$category->add_type($product, 'product');
616618
$category->fetch(getDolGlobalInt('DOLICAR_CAR_DEFAULT_BRAND_TAG'));
617619
$category->add_type($product, 'product');
620+
621+
dolibarr_set_const($this->db, 'DOLICAR_DEFAULT_VEHICLE_SET', 1, 'integer', 0, '', $conf->entity);
618622
}
619-
dolibarr_set_const($this->db, 'DOLICAR_DEFAULT_VEHICLE_SET', 1, 'integer', 0, '', $conf->entity);
620623
}
621624

622625
return $this->_init($sql, $options);
623626
}
624-
625-
/**
626-
* Function called when module is disabled
627-
* Remove from database constants, boxes and permissions from Dolibarr database
628-
* Data directories are not deleted
629-
*
630-
* @param string $options Options when enabling module ('', 'noboxes')
631-
* @return int 1 if OK, 0 if KO
632-
*/
633-
public function remove($options = ''): int
634-
{
635-
$sql = [];
636-
return $this->_remove($sql, $options);
637-
}
638627
}

0 commit comments

Comments
 (0)