├── img ├── marque.png ├── ATM_logo.jpg ├── logo marque.png ├── object_marque.png ├── Dolibarr_Preferred_Partner_logo.png └── object_marque.svg ├── README ├── ChangeLog.md ├── langs ├── en_US │ └── marque.lang ├── it_IT │ └── marque.lang └── fr_FR │ └── marque.lang ├── backport └── v19 │ └── core │ └── class │ └── commonhookactions.class.php ├── lib └── marque.lib.php ├── admin ├── marque_about.php └── marque_setup.php ├── class └── actions_marque.class.php └── core └── modules └── modMarque.class.php /img/marque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_marque/main/img/marque.png -------------------------------------------------------------------------------- /img/ATM_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_marque/main/img/ATM_logo.jpg -------------------------------------------------------------------------------- /img/logo marque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_marque/main/img/logo marque.png -------------------------------------------------------------------------------- /img/object_marque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_marque/main/img/object_marque.png -------------------------------------------------------------------------------- /img/Dolibarr_Preferred_Partner_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_marque/main/img/Dolibarr_Preferred_Partner_logo.png -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 ATM Consulting 3 | * 4 | * This program and files/directory inner it is free software: you can 5 | * redistribute it and/or modify it under the terms of the 6 | * GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Identity switch - Changelog 2 | 3 | ## Unreleased 4 | 5 | 6 | 7 | ## Release 1.2 8 | - FIX : Compat V22 - *02/10/2025* - 1.2.3 9 | - FIX : compat 21 - *12/12/2024* - 1.2.2 10 | - FIX : de la restriction du champ marque utilisé à la création d'un objet si la conf correspondante est renseignée - *03/10/2024* - 1.2.1 11 | 12 | - FIX: Compat v20 13 | Changed Dolibarr compatibility range to 16 min - 20 max - *28/07/2024* - 1.2.0 14 | 15 | ## Release 1.1 16 | 17 | - FIX : Compat V19 - 1.1.0 18 | Change dolibarr compatibility < 12 19 | 20 | ## Release 1.0 21 | - FIX : Compat V16 - 1.0.8 22 | - add langs 23 | - fix new token in setup 24 | - fix module family 25 | - FIX : missing icon - *25/07/2022* - 1.0.7 26 | - FIX : Product multidir output for images - *21/01/2022* - 1.0.6 27 | - No Change Log up to this point - *2021-10-07* - 1.0.0 28 | -------------------------------------------------------------------------------- /langs/en_US/marque.lang: -------------------------------------------------------------------------------- 1 | Module104015Name = Switch Branding 2 | Module104015Desc = Allow switch branding on documents 3 | 4 | ATMAbout = This module has been developed by ATM Consulting
You can find the documentation on our wiki

For any question or feedback, contact us on support@atm-consulting.fr

For any commercial question, contact us on contact@atm-consulting.fr or at +33 9 77 19 50 70

Find our other modules on Dolistore 5 | 6 | MarqueSetup = Marque module setup 7 | MarqueAbout = About Marque 8 | EntityMarque=Marque used 9 | set_MARQUE_ENTITIES_LINKED=Restrict access to this entity to these marques 10 | -------------------------------------------------------------------------------- /langs/it_IT/marque.lang: -------------------------------------------------------------------------------- 1 | Module104015Name = Gestione brand 2 | Module104015Desc = Permette alle proposte / ordini / fatture di essere assegnate al brand desiderato. (modulo Multi-azienda necessario) 3 | 4 | ATMAbout = This module has been developed by ATM Consulting
You can find the documentation on our wiki

For any question or feedback, contact us on support@atm-consulting.fr

For any commercial question, contact us on contact@atm-consulting.fr or at +33 9 77 19 50 70

Find our other modules on Dolistore 5 | 6 | MarqueSetup = Gestione Brand impostazioni modulo 7 | MarqueAbout = A proposito Brand 8 | EntityMarque = Brand / identità 9 | set_MARQUE_ENTITIES_LINKED=Limita l'accesso di questa entità ai seguenti brand -------------------------------------------------------------------------------- /langs/fr_FR/marque.lang: -------------------------------------------------------------------------------- 1 | Module104015Name = MultiMarque 2 | Module104015Desc = Permet de choisir une "marque" parmis les entités pour éditer un document 3 | 4 | ATMAbout = Ce module a été développé par ATM Consulting
Vous pouvez retrouver la documentation sur notre wiki

Pour toute question technique ou retour, contactez-nous sur support@atm-consulting.fr

Pour toute question commerciale, contactez-nous sur contact@atm-consulting.fr ou au +33 9 77 19 50 70

Retrouvez nos autres modules sur Dolistore 5 | 6 | MarqueSetup = Configuration du module Marque 7 | MarqueAbout = A propos du module Marque 8 | EntityMarque=Marque utilisée 9 | set_MARQUE_ENTITIES_LINKED=Restreindre l'accès de cette entité aux marques suivantes 10 | -------------------------------------------------------------------------------- /img/object_marque.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 | 18 | image/svg+xml 19 | 21 | 22 | 23 | 24 | 25 | 27 | 29 | 33 | 37 | 38 | -------------------------------------------------------------------------------- /backport/v19/core/class/commonhookactions.class.php: -------------------------------------------------------------------------------- 1 | 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 . 16 | */ 17 | 18 | /** 19 | * \file htdocs/core/class/commonhookactions.class.php 20 | * \ingroup core 21 | * \brief File of parent class of all other hook actions classes 22 | */ 23 | 24 | namespace marque; 25 | 26 | if(file_exists(DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php')) { 27 | require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php'; 28 | /** 29 | * Parent class of all other hook actions classes 30 | */ 31 | abstract class RetroCompatCommonHookActions extends \CommonHookActions { 32 | 33 | } 34 | } 35 | else { 36 | /** 37 | * Parent class of all other hook actions classes 38 | */ 39 | abstract class RetroCompatCommonHookActions { 40 | /** 41 | * @var string String of results. 42 | */ 43 | public $resprints; 44 | 45 | /** 46 | * @var array Array of results. 47 | */ 48 | public $results = array(); 49 | } 50 | } -------------------------------------------------------------------------------- /lib/marque.lib.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file lib/marque.lib.php 21 | * \ingroup marque 22 | * \brief This file is an example module library 23 | * Put some comments here 24 | */ 25 | 26 | function marqueAdminPrepareHead() 27 | { 28 | global $langs, $conf, $object; 29 | 30 | $langs->load("marque@marque"); 31 | 32 | $h = 0; 33 | $head = array(); 34 | 35 | $head[$h][0] = dol_buildpath("/marque/admin/marque_setup.php", 1); 36 | $head[$h][1] = $langs->trans("Parameters"); 37 | $head[$h][2] = 'settings'; 38 | $h++; 39 | $head[$h][0] = dol_buildpath("/marque/admin/marque_about.php", 1); 40 | $head[$h][1] = $langs->trans("About"); 41 | $head[$h][2] = 'about'; 42 | $h++; 43 | 44 | // Show more tabs from modules 45 | // Entries must be declared in modules descriptor with line 46 | //$this->tabs = array( 47 | // 'entity:+tabname:Title:@marque:/marque/mypage.php?id=__ID__' 48 | //); // to add new tab 49 | //$this->tabs = array( 50 | // 'entity:-tabname:Title:@marque:/marque/mypage.php?id=__ID__' 51 | //); // to remove a tab 52 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'marque'); 53 | 54 | return $head; 55 | } 56 | -------------------------------------------------------------------------------- /admin/marque_about.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file admin/about.php 21 | * \ingroup marque 22 | * \brief This file is an example about page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = @include("../../main.inc.php"); // From htdocs directory 27 | if (! $res) { 28 | $res = @include("../../../main.inc.php"); // From "custom" directory 29 | } 30 | 31 | // Libraries 32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 33 | require_once '../lib/marque.lib.php'; 34 | 35 | // Translations 36 | $langs->load("marque@marque"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | /* 44 | * View 45 | */ 46 | $page_name = "MarqueAbout"; 47 | llxHeader('', $langs->trans($page_name)); 48 | 49 | // Subheader 50 | $linkback = '' 51 | . $langs->trans("BackToModuleList") . ''; 52 | print_fiche_titre($langs->trans($page_name), $linkback); 53 | 54 | // Configuration header 55 | $head = marqueAdminPrepareHead(); 56 | dol_fiche_head( 57 | $head, 58 | 'about', 59 | $langs->trans("Module104015Name"), 60 | 0, 61 | 'marque@marque' 62 | ); 63 | 64 | // About page goes here 65 | print '
'; 66 | print '
'.$langs->trans('ATMAbout').'
'; 67 | 68 | dol_fiche_end(); 69 | 70 | print '
'; 71 | print ''; 72 | print '
'; 73 | 74 | llxFooter(); 75 | 76 | $db->close(); -------------------------------------------------------------------------------- /admin/marque_setup.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file admin/marque.php 21 | * \ingroup marque 22 | * \brief This file is an example module setup page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = @include("../../main.inc.php"); // From htdocs directory 27 | if (! $res) { 28 | $res = @include("../../../main.inc.php"); // From "custom" directory 29 | } 30 | 31 | // Libraries 32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 33 | require_once '../lib/marque.lib.php'; 34 | 35 | // Translations 36 | $langs->load("marque@marque"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | // Parameters 44 | $action = GETPOST('action', 'alpha'); 45 | 46 | /* 47 | * Actions 48 | */ 49 | if (preg_match('/set_(.*)/',$action,$reg)) 50 | { 51 | $code=$reg[1]; 52 | $value = GETPOST($code); 53 | if(is_array($value))$value = implode(',',$value); 54 | 55 | if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) 56 | { 57 | header("Location: ".$_SERVER["PHP_SELF"]); 58 | exit; 59 | } 60 | else 61 | { 62 | dol_print_error($db); 63 | 64 | } 65 | } 66 | 67 | if (preg_match('/del_(.*)/',$action,$reg)) 68 | { 69 | $code=$reg[1]; 70 | if (dolibarr_del_const($db, $code, 0) > 0) 71 | { 72 | Header("Location: ".$_SERVER["PHP_SELF"]); 73 | exit; 74 | } 75 | else 76 | { 77 | dol_print_error($db); 78 | } 79 | } 80 | 81 | /* 82 | * View 83 | */ 84 | $page_name = "MarqueSetup"; 85 | llxHeader('', $langs->trans($page_name)); 86 | 87 | // Subheader 88 | $linkback = '' 89 | . $langs->trans("BackToModuleList") . ''; 90 | print_fiche_titre($langs->trans($page_name), $linkback); 91 | 92 | // Configuration header 93 | $head = marqueAdminPrepareHead(); 94 | dol_fiche_head( 95 | $head, 96 | 'settings', 97 | $langs->trans("Module104015Name"), 98 | 0, 99 | "marque@marque" 100 | ); 101 | 102 | // Setup page goes here 103 | $form=new Form($db); 104 | $var=false; 105 | print ''; 106 | print ''; 107 | print ''."\n"; 108 | print ''; 109 | print ''."\n"; 110 | 111 | 112 | // Example with a yes / no select 113 | $var=!$var; 114 | print ''; 115 | print ''; 116 | print ''; 117 | print ''; 137 | 138 | print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans("set_MARQUE_ENTITIES_LINKED").' '; 118 | print '
'; 119 | $newToken = function_exists('newToken') ? newToken() : $_SESSION['newtoken']; 120 | print ''; 121 | print ''; 122 | 123 | $TEntities=array(); 124 | dol_include_once('/multicompany/class/dao_multicompany.class.php'); 125 | $dao = new DaoMulticompany($db); 126 | $dao->getEntities(); 127 | foreach($dao->entities as &$e) { 128 | 129 | $TEntities[$e->id] = $e->label; 130 | 131 | } 132 | 133 | print $form->multiselectarray('MARQUE_ENTITIES_LINKED_'.$conf->entity, $TEntities, explode(',',getDolGlobalString('MARQUE_ENTITIES_LINKED_'.$conf->entity))); 134 | print ''; 135 | print '
'; 136 | print '
'; 139 | 140 | llxFooter(); 141 | 142 | $db->close(); 143 | -------------------------------------------------------------------------------- /class/actions_marque.class.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file class/actions_marque.class.php 21 | * \ingroup marque 22 | * \brief This file is an example hook overload class file 23 | * Put some comments here 24 | */ 25 | 26 | /** 27 | * Class ActionsMarque 28 | */ 29 | require_once __DIR__.'/../backport/v19/core/class/commonhookactions.class.php'; 30 | 31 | class ActionsMarque extends marque\RetroCompatCommonHookActions 32 | { 33 | /** 34 | * @var array Hook results. Propagated to $hookmanager->resArray for later reuse 35 | */ 36 | public $results = array(); 37 | 38 | /** 39 | * @var string String displayed by executeHook() immediately after return 40 | */ 41 | public $resprints; 42 | 43 | /** 44 | * @var array Errors 45 | */ 46 | public $errors = array(); 47 | 48 | /** 49 | * Constructor 50 | */ 51 | public function __construct() 52 | { 53 | } 54 | 55 | /** 56 | * Overloading the doActions function : replacing the parent's function with the one below 57 | * 58 | * @param array() $parameters Hook metadatas (context, etc...) 59 | * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 60 | * @param string &$action Current action (if set). Generally create or edit or null 61 | * @param HookManager $hookmanager Hook manager propagated to allow calling another hook 62 | * @return int < 0 on error, 0 on success, 1 to replace standard code 63 | */ 64 | function doActions($parameters, &$object, &$action, $hookmanager) 65 | { 66 | $TContext = explode(':', $parameters['context']); 67 | 68 | if (in_array('agefodd', $TContext) && $parameters['location'] == 'document_trainee') 69 | { 70 | global $conf; 71 | 72 | if(( $action=='create' || $action == 'refresh') 73 | && !empty($object->array_options['options_entity_marque']) 74 | && $object->array_options['options_entity_marque'] > 0 75 | && $object->array_options['options_entity_marque'] != $conf->entity) { 76 | $this->setMySocByEntity($object->array_options['options_entity_marque']); 77 | } 78 | } 79 | } 80 | 81 | function beforePDFCreation(&$parameters, &$object, &$action, $hookmanager) { 82 | global $conf; 83 | 84 | if(!empty($object->array_options['options_entity_marque']) 85 | && $object->array_options['options_entity_marque'] > 0 86 | && $object->array_options['options_entity_marque'] != $conf->entity) { 87 | 88 | $this->setMySocByEntity($object->array_options['options_entity_marque']); 89 | } 90 | } 91 | 92 | function afterPDFCreation(&$parameters, &$null, &$action, $hookmanager) { 93 | global $db,$conf,$mysoc,$original_mysoc,$original_conf; 94 | 95 | if(!empty($original_mysoc)) { 96 | $mysoc = unserialize($original_mysoc); // étragement un clone ne change le pointeur mémoire que du premier niveau... 97 | $conf = unserialize($original_conf); 98 | $mysoc->db = $db; 99 | } 100 | } 101 | 102 | /** 103 | * @param int $entity 104 | * @throws Exception 105 | */ 106 | function setMySocByEntity($entity) { 107 | global $db, $conf, $mysoc, $original_conf, $original_mysoc; 108 | 109 | $original_mysoc = serialize($mysoc); 110 | $original_conf = serialize($conf); 111 | $confBackup = unserialize($original_conf); 112 | 113 | $sourcecompany = &$mysoc; 114 | $sourceconf = &$conf; 115 | 116 | $fk_entity_origin = $sourceconf->entity; 117 | $sourceconf->entity = $entity; 118 | foreach ($sourceconf->global as $attr => &$value) 119 | { 120 | // Recherche des globals liées au info de l'entity, car si non renseignées sur l'entity secondaire (non existante dans llx_const) 121 | // alors l'objet conserve les valeurs d'origines (et on ne veut pas de l'email par exemple de l'entité d'origine) 122 | if (substr($attr, 0, 10) == 'MAIN_INFO_') $value = ''; 123 | } 124 | 125 | $sourceconf->setValues($db); 126 | 127 | // RESTORE MULTIDIR OUTPUT FOR PRODUCT 128 | $rootfordata = DOL_DATA_ROOT; 129 | 130 | // If multicompany module is enabled, we redefine the root of data 131 | if (isModEnabled('multicompany') && !empty($conf->entity) && $conf->entity > 1) 132 | { 133 | $rootfordata .= '/'.$conf->entity; 134 | } 135 | // Set standard temporary folder name or global override 136 | $rootfortemp = getDolGlobalString('MAIN_TEMP_DIR', $rootfordata); 137 | 138 | 139 | // Module product/service 140 | $conf->product->multidir_output += $confBackup->product->multidir_output; 141 | $conf->product->multidir_temp += $confBackup->product->multidir_temp; 142 | $conf->service->multidir_output += $confBackup->service->multidir_output; 143 | $conf->service->multidir_temp += $confBackup->service->multidir_temp; 144 | 145 | $sourcecompany->setMysoc($sourceconf); 146 | 147 | $sourceconf->entity = $fk_entity_origin; // Dolibarr <= 7.0 ; un fetchObjectLinked() essaye pour les propals de faire un fetch filtré sur l'entité 148 | } 149 | 150 | function formObjectOptions(&$parameters, &$null, &$action, $hookmanager) 151 | { 152 | global $conf,$user,$langs,$db,$mysoc,$object; 153 | 154 | $TContext = explode(':', $parameters['context']); 155 | if (in_array('globalcard',$TContext)) 156 | { 157 | if(!empty(getDolGlobalString('MARQUE_ENTITIES_LINKED_'.$conf->entity)) && (GETPOST('attribute') === 'entity_marque' || $action=='edit' || $action=='create') ) { 158 | ?> 159 | 173 | 3 | * Copyright (C) 2004-2012 Laurent Destailleur 4 | * Copyright (C) 2005-2012 Regis Houssin 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * \defgroup marque Module Marque 22 | * \brief Example of a module descriptor. 23 | * Such a file must be copied into htdocs/marque/core/modules directory. 24 | * \file htdocs/marque/core/modules/modMarque.class.php 25 | * \ingroup marque 26 | * \brief Description and activation file for module Marque 27 | */ 28 | include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; 29 | 30 | 31 | /** 32 | * Description and activation class for module Marque 33 | */ 34 | class modMarque extends DolibarrModules 35 | { 36 | /** 37 | * Constructor. Define names, constants, directories, boxes, permissions 38 | * 39 | * @param DoliDB $db Database handler 40 | */ 41 | function __construct($db) 42 | { 43 | global $langs,$conf; 44 | 45 | $this->db = $db; 46 | 47 | // Id for module (must be unique). 48 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). 49 | $this->numero = 104015; // 104000 to 104999 for ATM CONSULTING 50 | $this->editor_name = 'ATM Consulting'; 51 | $this->editor_url = 'https://www.atm-consulting.fr'; 52 | // Key text used to identify module (for permissions, menus, etc...) 53 | $this->rights_class = 'marque'; 54 | 55 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' 56 | // It is used to group modules in module setup page 57 | $this->family = "ATM Consulting"; 58 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) 59 | $this->name = preg_replace('/^mod/i','',get_class($this)); 60 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) 61 | $this->description = "Description of module Marque"; 62 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version 63 | $this->version = '1.2.3'; 64 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) 65 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); 66 | // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) 67 | $this->special = 0; 68 | // Name of image file used for this module. 69 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' 70 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' 71 | $this->picto='marque.svg@marque'; 72 | 73 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) 74 | // for default path (eg: /marque/core/xxxxx) (0=disable, 1=enable) 75 | // for specific path of parts (eg: /marque/core/modules/barcode) 76 | // for specific css file (eg: /marque/css/marque.css.php) 77 | //$this->module_parts = array( 78 | // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) 79 | // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) 80 | // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) 81 | // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) 82 | // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) 83 | // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 84 | // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 85 | // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 86 | // 'css' => array('/marque/css/marque.css.php'), // Set this to relative path of css file if module has its own css file 87 | // 'js' => array('/marque/js/marque.js'), // Set this to relative path of js file if module must load a js on all pages 88 | // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module 89 | // 'dir' => array('output' => 'othermodulename'), // To force the default directories names 90 | // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'isModEnabled("module1") && isModEnabled("module2")', 'picto'=>'yourpicto@marque')) // Set here all workflow context managed by module 91 | // ); 92 | $this->module_parts = array( 93 | 'hooks'=>array('globalcard','pdfgeneration','agefodd') 94 | 95 | ); 96 | 97 | // Data directories to create when module is enabled. 98 | // Example: this->dirs = array("/marque/temp"); 99 | $this->dirs = array(); 100 | 101 | // Config pages. Put here list of php page, stored into marque/admin directory, to use to setup module. 102 | $this->config_page_url = array("marque_setup.php@marque"); 103 | 104 | // Dependencies 105 | $this->hidden = false; // A condition to hide module 106 | $this->depends = array(); // List of modules id that must be enabled if this module is enabled 107 | $this->requiredby = array(); // List of modules id to disable if this one is disabled 108 | $this->conflictwith = array(); // List of modules id this module is in conflict with 109 | $this->phpmin = array(7,0); // Minimum version of PHP required by module 110 | $this->need_dolibarr_version = array(16,0); // Minimum version of Dolibarr required by module 111 | $this->langfiles = array("marque@marque"); 112 | 113 | // Constants 114 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 115 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), 116 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) 117 | // ); 118 | $this->const = array(); 119 | 120 | // Array to add new pages in new tabs 121 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@marque:$user->rights->marque->read:/marque/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 122 | // 'objecttype:+tabname2:Title2:mylangfile@marque:$user->rights->othermodule->read:/marque/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 123 | // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname 124 | // where objecttype can be 125 | // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 126 | // 'contact' to add a tab in contact view 127 | // 'contract' to add a tab in contract view 128 | // 'group' to add a tab in group view 129 | // 'intervention' to add a tab in intervention view 130 | // 'invoice' to add a tab in customer invoice view 131 | // 'invoice_supplier' to add a tab in supplier invoice view 132 | // 'member' to add a tab in fundation member view 133 | // 'opensurveypoll' to add a tab in opensurvey poll view 134 | // 'order' to add a tab in customer order view 135 | // 'order_supplier' to add a tab in supplier order view 136 | // 'payment' to add a tab in payment view 137 | // 'payment_supplier' to add a tab in supplier payment view 138 | // 'product' to add a tab in product view 139 | // 'propal' to add a tab in propal view 140 | // 'project' to add a tab in project view 141 | // 'stock' to add a tab in stock view 142 | // 'thirdparty' to add a tab in third party view 143 | // 'user' to add a tab in user view 144 | $this->tabs = array(); 145 | 146 | // Dictionaries 147 | if (!isModEnabled('marque')) 148 | { 149 | $conf->marque=new stdClass(); 150 | $conf->marque->enabled=0; 151 | } 152 | $this->dictionaries=array(); 153 | /* Example: 154 | if (! isModEnabled("marque")) $conf->marque->enabled=0; // This is to avoid warnings 155 | $this->dictionaries=array( 156 | 'langs'=>'mylangfile@marque', 157 | 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor 158 | 'tablib'=>array("Table1","Table2","Table3"), // Label of tables 159 | 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields 160 | 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order 161 | 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) 162 | 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) 163 | 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) 164 | 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') 165 | 'tabcond'=>array(isModEnabled("marque"),isModEnabled("marque"),isModEnabled("marque")) // Condition to show each dictionary 166 | ); 167 | */ 168 | 169 | // Boxes 170 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. 171 | $this->boxes = array(); // List of boxes 172 | // Example: 173 | //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); 174 | 175 | // Permissions 176 | $this->rights = array(); // Permission array used by this module 177 | $r=0; 178 | 179 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. 180 | // Example: 181 | // $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) 182 | // $this->rights[$r][1] = 'Permision label'; // Permission label 183 | // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) 184 | // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->hasRight("permkey", "level1", "level2")) 185 | // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->hasRight("permkey", "level1", "level2")) 186 | // $r++; 187 | 188 | 189 | // Main menu entries 190 | $this->menu = array(); // List of menus to add 191 | $r=0; 192 | 193 | // Add here entries to declare new menus 194 | // 195 | // Example to declare a new Top Menu entry and its Left menu entry: 196 | // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu 197 | // 'type'=>'top', // This is a Top menu entry 198 | // 'titre'=>'Marque top menu', 199 | // 'mainmenu'=>'marque', 200 | // 'leftmenu'=>'marque', 201 | // 'url'=>'/marque/pagetop.php', 202 | // 'langs'=>'mylangfile@marque', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 203 | // 'position'=>100, 204 | // 'enabled'=>'isModEnabled("marque")', // Define condition to show or hide menu entry. Use 'isModEnabled("marque")' if entry must be visible if module is enabled. 205 | // 'perms'=>'1', // Use 'perms'=>'$user->hasRight("marque", "level1", "level2")' if you want your menu with a permission rules 206 | // 'target'=>'', 207 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 208 | // $r++; 209 | // 210 | // Example to declare a Left Menu entry into an existing Top menu entry: 211 | // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 212 | // 'type'=>'left', // This is a Left menu entry 213 | // 'titre'=>'Marque left menu', 214 | // 'mainmenu'=>'xxx', 215 | // 'leftmenu'=>'marque', 216 | // 'url'=>'/marque/pagelevel2.php', 217 | // 'langs'=>'mylangfile@marque', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 218 | // 'position'=>100, 219 | // 'enabled'=>'$conf->marque->enabled', // Define condition to show or hide menu entry. Use '$conf->marque->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 220 | // 'perms'=>'1', // Use 'perms'=>'$user->hasRight("marque", "level1", "level2")' if you want your menu with a permission rules 221 | // 'target'=>'', 222 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 223 | // $r++; 224 | 225 | 226 | // Exports 227 | $r=1; 228 | 229 | // Example: 230 | // $this->export_code[$r]=$this->rights_class.'_'.$r; 231 | // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 232 | // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. 233 | // $this->export_permission[$r]=array(array("facture","facture","export")); 234 | // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); 235 | // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); 236 | // $this->export_sql_start[$r]='SELECT DISTINCT '; 237 | // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; 238 | // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; 239 | // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; 240 | // $this->export_sql_order[$r] .=' ORDER BY s.nom'; 241 | // $r++; 242 | } 243 | 244 | /** 245 | * Function called when module is enabled. 246 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. 247 | * It also creates data directories 248 | * 249 | * @param string $options Options when enabling module ('', 'noboxes') 250 | * @return int 1 if OK, 0 if KO 251 | */ 252 | function init($options='') 253 | { 254 | global $langs; 255 | $sql = array(); 256 | $langs->load("marque@marque"); 257 | 258 | dol_include_once('/core/class/extrafields.class.php'); 259 | $extrafields=new ExtraFields($this->db); 260 | $res = $extrafields->addExtraField('entity_marque', $langs->trans('EntityMarque'), 'sellist', 0, '', 'propal',0,0,'',serialize(array('options'=>array('entity:label:rowid'=>null)))); 261 | 262 | $extrafields=new ExtraFields($this->db); 263 | $res = $extrafields->addExtraField('entity_marque', $langs->trans('EntityMarque'), 'sellist', 0, '', 'commande',0,0,'',serialize(array('options'=>array('entity:label:rowid'=>null)))); 264 | 265 | $extrafields=new ExtraFields($this->db); 266 | $res = $extrafields->addExtraField('entity_marque', $langs->trans('EntityMarque'), 'sellist', 0, '', 'facture',0,0,'',serialize(array('options'=>array('entity:label:rowid'=>null)))); 267 | 268 | $extrafields=new ExtraFields($this->db); 269 | $res = $extrafields->addExtraField('entity_marque', $langs->trans('EntityMarque'), 'sellist', 0, '', 'agefodd_session',0,0,'',serialize(array('options'=>array('entity:label:rowid'=>null)))); 270 | 271 | 272 | $extrafields=new ExtraFields($this->db); 273 | $res = $extrafields->addExtraField('entity_marque', $langs->trans('EntityMarque'), 'sellist', 0, '', 'expedition',0,0,'',serialize(array('options'=>array('entity:label:rowid'=>null)))); 274 | 275 | $result=$this->_load_tables('/marque/sql/'); 276 | 277 | return $this->_init($sql, $options); 278 | } 279 | 280 | /** 281 | * Function called when module is disabled. 282 | * Remove from database constants, boxes and permissions from Dolibarr database. 283 | * Data directories are not deleted 284 | * 285 | * @param string $options Options when enabling module ('', 'noboxes') 286 | * @return int 1 if OK, 0 if KO 287 | */ 288 | function remove($options='') 289 | { 290 | $sql = array(); 291 | 292 | return $this->_remove($sql, $options); 293 | } 294 | 295 | } 296 | --------------------------------------------------------------------------------