dolibarr 18.0.6
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
31include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
32
33
38{
44 public function __construct($db)
45 {
46 global $conf;
47
48 $this->db = $db;
49 $this->numero = 1120;
50
51 $this->family = "srm";
52 $this->module_position = '35';
53 $this->name = preg_replace('/^mod/i', '', get_class($this));
54 $this->description = "supplier_proposalDESC";
55
56 $this->version = 'dolibarr';
57
58 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59 $this->picto = 'supplier_proposal';
60
61 // Data directories to create when module is enabled.
62 $this->dirs = array();
63
64 // Config pages. Put here list of php page names stored in admin directory used to setup module.
65 $this->config_page_url = array("supplier_proposal.php");
66
67 // Dependencies
68 $this->hidden = false; // A condition to hide module
69 $this->depends = array('modFournisseur'); // List of module class names as string that must be enabled if this module is enabled
70 $this->requiredby = array(); // List of module ids to disable if this one is disabled
71 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
72 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
73 $this->langfiles = array("supplier_proposal");
74
75 // Constants
76 $this->const = array();
77 $r = 0;
78
79 $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF";
80 $this->const[$r][1] = "chaine";
81 $this->const[$r][2] = "aurore";
82 $this->const[$r][3] = 'Name of submodule to generate PDF for supplier quotation request';
83 $this->const[$r][4] = 0;
84 $r++;
85
86 $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON";
87 $this->const[$r][1] = "chaine";
88 $this->const[$r][2] = "mod_supplier_proposal_marbre";
89 $this->const[$r][3] = 'Name of submodule to number supplier quotation request';
90 $this->const[$r][4] = 0;
91 $r++;
92
93 $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH";
94 $this->const[$r][1] = "chaine";
95 $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposals";
96 $this->const[$r][3] = "";
97 $this->const[$r][4] = 0;
98
99 // Boxes
100 $this->boxes = array();
101
102 // Permissions
103 $this->rights = array();
104 $this->rights_class = 'supplier_proposal';
105 $r = 0;
106
107 $r++;
108 $this->rights[$r][0] = $this->numero + $r; // id de la permission
109 $this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
110 $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
111 $this->rights[$r][4] = 'lire';
112
113 $r++;
114 $this->rights[$r][0] = $this->numero + $r; // id de la permission
115 $this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
116 $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
117 $this->rights[$r][4] = 'creer';
118
119 $r++;
120 $this->rights[$r][0] = $this->numero + $r; // id de la permission
121 $this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
122 $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
123 $this->rights[$r][4] = 'validate_advance';
124
125 $r++;
126 $this->rights[$r][0] = $this->numero + $r; // id de la permission
127 $this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
128 $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
129 $this->rights[$r][4] = 'send_advance';
130
131 $r++;
132 $this->rights[$r][0] = $this->numero + $r; // id de la permission
133 $this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
134 $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
135 $this->rights[$r][4] = 'supprimer';
136
137 $r++;
138 $this->rights[$r][0] = $this->numero + $r; // id de la permission
139 $this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
140 $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
141 $this->rights[$r][4] = 'cloturer';
142
143 // Main menu entries
144 $this->menu = array(); // List of menus to add
145 $r = 0;
146 }
147
148
157 public function init($options = '')
158 {
159 global $conf, $langs;
160
161 // Remove permissions and default values
162 $this->remove($options);
163
164 //ODT template
165 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposals/template_supplier_proposal.odt';
166 $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_proposals';
167 $dest = $dirodt.'/template_supplier_proposal.odt';
168
169 if (file_exists($src) && !file_exists($dest)) {
170 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
171 dol_mkdir($dirodt);
172 $result = dol_copy($src, $dest, 0, 0);
173 if ($result < 0) {
174 $langs->load("errors");
175 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
176 return 0;
177 }
178 }
179
180 $sql = array(
181 "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),
182 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".((int) $conf->entity).")",
183 );
184
185 return $this->_init($sql, $options);
186 }
187
188
189
198 public function remove($options = '')
199 {
200 $sql = array(
201 "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries
202 );
203
204 return $this->_remove($sql, $options);
205 }
206}
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.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
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:123