@@ -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