dolibarr 24.0.0-beta
modSupplierProposal.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
32include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33
34
39{
45 public function __construct($db)
46 {
47 global $conf;
48
49 $this->db = $db;
50 $this->numero = 1120;
51
52 $this->family = "srm";
53 $this->module_position = '11';
54 $this->name = preg_replace('/^mod/i', '', get_class($this));
55 $this->description = "supplier_proposalDESC";
56
57 $this->version = 'dolibarr';
58
59 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 $this->picto = 'supplier_proposal';
61
62 // Data directories to create when module is enabled.
63 $this->dirs = [];
64
65 // Config pages. Put here list of php page names stored in admin directory used to setup module.
66 $this->config_page_url = array("supplier_proposal.php@supplier_proposal");
67
68 // Dependencies
69 $this->hidden = false; // A condition to hide module
70 if (getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
71 $this->depends = array('modSupplierOrder'); // List of module class names as string that must be enabled if this module is enabled
72 } else {
73 $this->depends = array('modFournisseur'); // List of module class names as string that must be enabled if this module is enabled
74 }
75 $this->requiredby = []; // List of module ids to disable if this one is disabled
76 $this->conflictwith = []; // List of module class names as string this module is in conflict with
77 $this->langfiles = array("supplier_proposal");
78
79 // Constants
80 $this->const = [
81 [
82 "SUPPLIER_PROPOSAL_ADDON_PDF",
83 "chaine",
84 "aurore",
85 'Name of submodule to generate PDF for supplier quotation request',
86 0,
87 ],
88 [
89 "SUPPLIER_PROPOSAL_ADDON",
90 "chaine",
91 "mod_supplier_proposal_marbre",
92 'Name of submodule to number supplier quotation request',
93 0,
94 ],
95 [
96 "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH",
97 "chaine",
98 "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/supplier_proposals",
99 "",
100 0,
101 ],
102 ];
103 // Boxes
104 $this->boxes = [];
105
106 // Permissions
107 $this->rights = [];
108 $this->rights_class = 'supplier_proposal';
109 $r = 0;
110
111 $r++;
112 $this->rights[$r][0] = $this->numero + $r; // id de la permission
113 $this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
114 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
115 $this->rights[$r][4] = 'lire';
116
117 $r++;
118 $this->rights[$r][0] = $this->numero + $r; // id de la permission
119 $this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
120 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
121 $this->rights[$r][4] = 'creer';
122
123 $r++;
124 $this->rights[$r][0] = $this->numero + $r; // id de la permission
125 $this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
126 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
127 $this->rights[$r][4] = 'validate_advance';
128
129 $r++;
130 $this->rights[$r][0] = $this->numero + $r; // id de la permission
131 $this->rights[$r][1] = 'Send supplier proposals'; // libelle de la permission
132 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
133 $this->rights[$r][4] = 'send_advance';
134
135 $r++;
136 $this->rights[$r][0] = $this->numero + $r; // id de la permission
137 $this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
138 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
139 $this->rights[$r][4] = 'supprimer';
140
141 $r++;
142 $this->rights[$r][0] = $this->numero + $r; // id de la permission
143 $this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
144 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
145 $this->rights[$r][4] = 'cloturer';
146
147 // Main menu entries
148 $this->menu = []; // List of menus to add
149 $r = 0;
150 }
151
152
161 public function init($options = '')
162 {
163 global $conf, $langs;
164
165 // Remove permissions and default values
166 $this->remove($options);
167
168 // ODT template
169 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposals/template_supplier_proposal.odt';
170 $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/supplier_proposals';
171 $dest = $dirodt.'/template_supplier_proposal.odt';
172
173 if (file_exists($src) && !file_exists($dest)) {
174 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
175 dol_mkdir($dirodt);
176 $result = dol_copy($src, $dest, '0', 0);
177 if ($result < 0) {
178 $langs->load("errors");
179 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
180 return 0;
181 }
182 }
183
184 $sql = array(
185 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'supplier_proposal' AND entity = ".((int) $conf->entity),
186 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".((int) $conf->entity).")",
187 );
188
189 return $this->_init($sql, $options);
190 }
191
192
193
202 public function remove($options = '')
203 {
204 $sql = array(
205 "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries
206 );
207
208 return $this->_remove($sql, $options);
209 }
210}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
Class to describe and enable module SupplierProposal.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133