dolibarr  7.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@capnetworks.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 <http://www.gnu.org/licenses/>.
21  */
22 
31 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
32 
33 
38 {
39 
45  function __construct($db)
46  {
47  global $conf;
48 
49  $this->db = $db;
50  $this->numero = 1120;
51 
52  $this->family = "srm";
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->special = 0;
60  $this->picto='supplier_proposal';
61 
62  $this->dirs = array();
63 
64  // Dependancies
65  $this->depends = array('modFournisseur');
66  $this->requiredby = array();
67  $this->config_page_url = array("supplier_proposal.php");
68  $this->langfiles = array("supplier_proposal");
69 
70  // Constants
71  $this->const = array();
72  $r=0;
73 
74  $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF";
75  $this->const[$r][1] = "chaine";
76  $this->const[$r][2] = "aurore";
77  $this->const[$r][3] = 'Name of submodule to generate PDF for supplier quotation request';
78  $this->const[$r][4] = 0;
79  $r++;
80 
81  $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON";
82  $this->const[$r][1] = "chaine";
83  $this->const[$r][2] = "mod_supplier_proposal_marbre";
84  $this->const[$r][3] = 'Name of submodule to number supplier quotation request';
85  $this->const[$r][4] = 0;
86  $r++;
87 
88  $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH";
89  $this->const[$r][1] = "chaine";
90  $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposal";
91  $this->const[$r][3] = "";
92  $this->const[$r][4] = 0;
93 
94  // Boxes
95  $this->boxes = array();
96 
97  // Permissions
98  $this->rights = array();
99  $this->rights_class = 'supplier_proposal';
100  $r=0;
101 
102  $r++;
103  $this->rights[$r][0] = $this->numero + $r; // id de la permission
104  $this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
105  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
106  $this->rights[$r][4] = 'lire';
107 
108  $r++;
109  $this->rights[$r][0] = $this->numero + $r; // id de la permission
110  $this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
111  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
112  $this->rights[$r][4] = 'creer';
113 
114  $r++;
115  $this->rights[$r][0] = $this->numero + $r; // id de la permission
116  $this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
117  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
118  $this->rights[$r][4] = 'validate_advance';
119 
120  $r++;
121  $this->rights[$r][0] = $this->numero + $r; // id de la permission
122  $this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
123  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
124  $this->rights[$r][4] = 'send_advance';
125 
126  $r++;
127  $this->rights[$r][0] = $this->numero + $r; // id de la permission
128  $this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
129  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
130  $this->rights[$r][4] = 'supprimer';
131 
132  $r++;
133  $this->rights[$r][0] = $this->numero + $r; // id de la permission
134  $this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
135  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
136  $this->rights[$r][4] = 'cloturer';
137 
138  // Main menu entries
139  $this->menu = array(); // List of menus to add
140  $r=0;
141  $this->menu[$r]=array(
142  'fk_menu'=>'fk_mainmenu=commercial', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
143  'type'=>'left', // This is a Left menu entry
144  'titre'=>'SupplierProposalsShort',
145  'leftmenu'=>'supplier_proposalsubmenu',
146  'url'=>'/supplier_proposal/index.php',
147  'langs'=>'supplier_proposal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
148  'enabled'=>'$conf->supplier_proposal->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
149  'perms'=>'$user->rights->supplier_proposal->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
150  'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
151  'position'=>300
152  );
153  $r++;
154 
155  $this->menu[$r]=array(
156  'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
157  'type'=>'left',
158  'titre'=>'SupplierProposalNew',
159  'url'=>'/supplier_proposal/card.php?action=create&amp;leftmenu=supplier_proposals',
160  'langs'=>'supplier_proposal',
161  'enabled'=>'$conf->supplier_proposal->enabled',
162  'perms'=>'$user->rights->supplier_proposal->creer',
163  'user'=>2,
164  'position'=>301
165  );
166  $r++;
167 
168  $this->menu[$r]=array(
169  'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
170  'type'=>'left',
171  'titre'=>'List',
172  'url'=>'/supplier_proposal/list.php?leftmenu=supplier_proposals',
173  'langs'=>'supplier_proposal',
174  'enabled'=>'$conf->supplier_proposal->enabled',
175  'perms'=>'$user->rights->supplier_proposal->lire',
176  'user'=>2,
177  'position'=>302
178  );
179  $r++;
180 
181  $this->menu[$r]=array(
182  'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
183  'type'=>'left',
184  'titre'=>'Statistics',
185  'url'=>'/comm/propal/stats/index.php?leftmenu=supplier_proposals&amp;mode=supplier',
186  'langs'=>'supplier_proposal',
187  'enabled'=>'$conf->supplier_proposal->enabled',
188  'perms'=>'$user->rights->supplier_proposal->lire',
189  'user'=>2,
190  'position'=>303
191  );
192  $r++;
193  }
194 
195 
204  function init($options='')
205  {
206  global $conf,$langs;
207 
208  // Remove permissions and default values
209  $this->remove($options);
210 
211  //ODT template
212  $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt';
213  $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposal';
214  $dest=$dirodt.'/template_supplier_proposal.odt';
215 
216  if (file_exists($src) && ! file_exists($dest))
217  {
218  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
219  dol_mkdir($dirodt);
220  $result=dol_copy($src,$dest,0,0);
221  if ($result < 0)
222  {
223  $langs->load("errors");
224  $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
225  return 0;
226  }
227  }
228 
229  $sql = array(
230  "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'supplier_proposal' AND entity = ".$conf->entity,
231  "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".$conf->entity.")",
232  );
233 
234  return $this->_init($sql, $options);
235  }
236 
237 
238 
247  public function remove($options = '')
248  {
249  $sql = array(
250  "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"
251  );
252 
253  return $this->_remove($sql, $options);
254  }
255 
256 }
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
Definition: files.lib.php:631
Class DolibarrModules.
_remove($array_sql, $options='')
Disable function.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
init($options='')
Function called when module is enabled.
Class to describe and enable module AskPriceSupllier.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
_init($array_sql, $options='')
Enables a module.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)