dolibarr  13.0.2
modSociete.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2013 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-2013 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2012-2014 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 
30 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
31 
32 
37 {
38 
44  public function __construct($db)
45  {
46  global $conf, $user;
47 
48  $this->db = $db;
49  $this->numero = 1;
50 
51  $this->family = "crm";
52  $this->module_position = '09';
53  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54  $this->name = preg_replace('/^mod/i', '', get_class($this));
55  $this->description = "Gestion des sociétés et contacts";
56 
57  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
58  $this->version = 'dolibarr';
59 
60  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
61  $this->config_page_url = array("societe.php@societe");
62  // Name of image file used for this module.
63  $this->picto = 'company';
64 
65  // Data directories to create when module is enabled
66  $this->dirs = array("/societe/temp");
67 
68  // Dependencies
69  $this->hidden = false; // A condition to hide module
70  $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
71  $this->requiredby = array("modExpedition", "modFacture", "modFournisseur", "modFicheinter", "modPropale", "modContrat", "modCommande"); // List of module ids to disable if this one is disabled
72  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
73  $this->phpmin = array(5, 4); // Minimum version of PHP required by module
74  $this->langfiles = array("companies", 'bills', "compta", "admin", "banks");
75 
76  // Constants
77  $this->const = array();
78  $r = 0;
79 
80  $this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON";
81  $this->const[$r][1] = "chaine";
82  $this->const[$r][2] = "mod_codeclient_monkey";
83  $this->const[$r][3] = 'Module to control third parties codes';
84  $this->const[$r][4] = 0;
85  $r++;
86 
87  $this->const[$r][0] = "SOCIETE_CODECOMPTA_ADDON";
88  $this->const[$r][1] = "chaine";
89  $this->const[$r][2] = "mod_codecompta_panicum";
90  $this->const[$r][3] = 'Module to control third parties codes';
91  $this->const[$r][4] = 0;
92  $r++;
93 
94  $this->const[$r][0] = "SOCIETE_FISCAL_MONTH_START";
95  $this->const[$r][1] = "chaine";
96  $this->const[$r][2] = "0";
97  $this->const[$r][3] = "Enter the month number of the first month of the fiscal year, e. g. 9 for September";
98  $this->const[$r][4] = 0;
99  $r++;
100 
101  $this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH";
102  $this->const[$r][1] = "chaine";
103  $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties";
104  $this->const[$r][3] = "";
105  $this->const[$r][4] = 0;
106  $r++;
107 
108  /*
109  $this->const[$r][0] = "COMPANY_HIDE_INACTIVE_IN_COMBOBOX";
110  $this->const[$r][1] = "chaine";
111  $this->const[$r][2] = "0";
112  $this->const[$r][3] = "hide thirdparty customer inative in combobox";
113  $this->const[$r][4] = 1;
114  $r++;
115  */
116 
117  $this->const[$r][0] = "SOCIETE_ADD_REF_IN_LIST";
118  $this->const[$r][1] = "yesno";
119  $this->const[$r][2] = "0";
120  $this->const[$r][3] = "Display customer ref into select list";
121  $this->const[$r][4] = 0;
122  $r++;
123 
124  // Boxes
125  $this->boxes = array(
126  0=>array('file'=>'box_clients.php', 'enabledbydefaulton'=>'Home'),
127  1=>array('file'=>'box_prospect.php', 'enabledbydefaulton'=>'Home'),
128  2=>array('file'=>'box_contacts.php', 'enabledbydefaulton'=>'Home'),
129  3=>array('file'=>'box_activity.php', 'enabledbydefaulton'=>'Home', 'note'=>'(WarningUsingThisBoxSlowDown)'),
130  4=>array('file'=>'box_goodcustomers.php', 'enabledbydefaulton'=>'Home', 'note'=>'(WarningUsingThisBoxSlowDown)'),
131  );
132 
133  // Permissions
134  $this->rights = array();
135  $this->rights_class = 'societe';
136  $r = 0;
137 
138  $r++;
139  $this->rights[$r][0] = 121; // id de la permission
140  $this->rights[$r][1] = 'Read third parties'; // libelle de la permission
141  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
142  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
143  $this->rights[$r][4] = 'lire';
144 
145  /*$r++;
146  $this->rights[$r][0] = 241;
147  $this->rights[$r][1] = 'Read thirdparties customers';
148  $this->rights[$r][2] = 'r';
149  $this->rights[$r][3] = 0;
150  $this->rights[$r][4] = 'thirparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
151  $this->rights[$r][5] = 'read';
152 
153  $r++;
154  $this->rights[$r][0] = 242;
155  $this->rights[$r][1] = 'Read thirdparties suppliers';
156  $this->rights[$r][2] = 'r';
157  $this->rights[$r][3] = 0;
158  $this->rights[$r][4] = 'thirdparty_supplier_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
159  $this->rights[$r][5] = 'read';
160  */
161 
162  $r++;
163  $this->rights[$r][0] = 122; // id de la permission
164  $this->rights[$r][1] = 'Create and update third parties'; // libelle de la permission
165  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
166  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
167  $this->rights[$r][4] = 'creer';
168 
169  /* $r++;
170  $this->rights[$r][0] = 251;
171  $this->rights[$r][1] = 'Create thirdparties customers';
172  $this->rights[$r][2] = 'r';
173  $this->rights[$r][3] = 0;
174  $this->rights[$r][4] = 'thirparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
175  $this->rights[$r][5] = 'read';
176 
177  $r++;
178  $this->rights[$r][0] = 252;
179  $this->rights[$r][1] = 'Create thirdparties suppliers';
180  $this->rights[$r][2] = 'r';
181  $this->rights[$r][3] = 0;
182  $this->rights[$r][4] = 'thirdparty_supplier_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
183  $this->rights[$r][5] = 'read';
184  */
185 
186  $r++;
187  $this->rights[$r][0] = 125; // id de la permission
188  $this->rights[$r][1] = 'Delete third parties'; // libelle de la permission
189  $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
190  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
191  $this->rights[$r][4] = 'supprimer';
192 
193  $r++;
194  $this->rights[$r][0] = 126; // id de la permission
195  $this->rights[$r][1] = 'Export third parties'; // libelle de la permission
196  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
197  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
198  $this->rights[$r][4] = 'export';
199 
200  // 262 : Resteindre l'acces des commerciaux
201  $r++;
202  $this->rights[$r][0] = 262;
203  $this->rights[$r][1] = 'Read all third parties by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).';
204  $this->rights[$r][2] = 'r';
205  $this->rights[$r][3] = 0;
206  $this->rights[$r][4] = 'client';
207  $this->rights[$r][5] = 'voir';
208 
209  $r++;
210  $this->rights[$r][0] = 281; // id de la permission
211  $this->rights[$r][1] = 'Read contacts'; // libelle de la permission
212  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
213  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
214  $this->rights[$r][4] = 'contact';
215  $this->rights[$r][5] = 'lire';
216 
217  $r++;
218  $this->rights[$r][0] = 282; // id de la permission
219  $this->rights[$r][1] = 'Create and update contact'; // libelle de la permission
220  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
221  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
222  $this->rights[$r][4] = 'contact';
223  $this->rights[$r][5] = 'creer';
224 
225  $r++;
226  $this->rights[$r][0] = 283; // id de la permission
227  $this->rights[$r][1] = 'Delete contacts'; // libelle de la permission
228  $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
229  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
230  $this->rights[$r][4] = 'contact';
231  $this->rights[$r][5] = 'supprimer';
232 
233  $r++;
234  $this->rights[$r][0] = 286; // id de la permission
235  $this->rights[$r][1] = 'Export contacts'; // libelle de la permission
236  $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
237  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
238  $this->rights[$r][4] = 'contact';
239  $this->rights[$r][5] = 'export';
240 
241 
242  // Menus
243  //-------
244  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
245 
246 
247  // Exports
248  //--------
249  $r = 0;
250 
251  // Export list of third parties and attributes
252  $r++;
253  $this->export_code[$r] = $this->rights_class.'_'.$r;
254  $this->export_label[$r] = 'ExportDataset_company_1';
255  $this->export_icon[$r] = 'company';
256  $this->export_permission[$r] = array(array("societe", "export"));
257  $this->export_fields_array[$r] = array(
258  's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 'ps.nom'=>"ParentCompany",
259  's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification",
260  's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
261  's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom'=>'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax",
262  's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.canvas' => "Canvas", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4",
263  's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic",
264  't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel',
265  'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode',
266  's.outstanding_limit'=>'OutstandingBill', 'pbacc.ref'=>'PaymentBankAccount', 'incoterm.code'=>'IncotermLabel'
267  );
268  if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix';
269  if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel';
270  // Add multicompany field
271  if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
272  {
273  $nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
274  if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity');
275  }
276  $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra';
277  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
278  $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname');
279 
280  //$this->export_TypeFields_array[$r]=array(
281  // 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
282  // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",
283  // 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.canvas' => "Canvas",'s.siret'=>"Text",'s.siren'=>"Text",
284  // 's.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text",
285  // 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
286  // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'
287  //);
288  $this->export_TypeFields_array[$r] = array(
289  's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 'ps.nom'=>"Text",
290  's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date",
291  's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",
292  's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text",
293  'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",
294  's.phone'=>"Text", 's.fax'=>"Text",
295  's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.canvas' => "Canvas",
296  's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text",
297  's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text",
298  't.libelle'=>"Text", 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
299  'st.code'=>'List:c_stcomm:libelle:code',
300  'payterm.libelle'=>'Text', 'paymode.libelle'=>'Text',
301  's.outstanding_limit'=>'Numeric', 'pbacc.ref'=>'Text', 'incoterm.code'=>'Text',
302  'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text',
303  's.entity'=>'Numeric', 's.price_level'=>'Numeric'
304  );
305 
306  $this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto
307  $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
308  $this->export_sql_start[$r] = 'SELECT DISTINCT ';
309  $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
310  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';
311  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON s.parent = ps.rowid';
312  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
313  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
314  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id';
315  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
316  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
317  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = s.fk_pays';
318  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';
319  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid';
320  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
321  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id';
322  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as pbacc ON s.fk_account = pbacc.rowid';
323  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';
324  $this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')';
325  if (is_object($user) && empty($user->rights->societe->client->voir)) {
326  $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
327  if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
328  $subordinatesids = $user->getAllChildIds();
329  $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
330  }
331  $this->export_sql_end[$r] .= ')';
332  }
333 
334  // Export list of contacts and attributes
335  $r++;
336  $this->export_code[$r] = $this->rights_class.'_'.$r;
337  $this->export_label[$r] = 'ExportDataset_company_2';
338  $this->export_icon[$r] = 'contact';
339  $this->export_permission[$r] = array(array("societe", "contact", "export"));
340  $this->export_fields_array[$r] = array(
341  'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction',
342  'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town",
343  'd.nom'=>'State', 'r.nom'=>'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail",
344  'c.statut'=>"Status",
345  's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode",
346  's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
347  's.client'=>'Customer', 's.fournisseur'=>'Supplier',
348  's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email",
349  't.libelle'=>"ThirdPartyType"
350  );
351  $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
352  $this->export_TypeFields_array[$r] = array(
353  'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean",
354  'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'r.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text",
355  'c.fax'=>"Text", 'c.email'=>"Text",
356  'c.statut'=>"Status",
357  's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",
358  's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",
359  's.client'=>"Text", 's.fournisseur'=>"Text",
360  's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text",
361  't.libelle'=>"Text"
362  );
363  $this->export_entities_array[$r] = array(
364  's.rowid'=>"company", 's.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company", 's.code_fournisseur'=>"company",
365  's.code_compta'=>"company", 's.code_compta_fournisseur'=>"company",
366  's.client'=>"company", 's.fournisseur'=>"company",
367  's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company",
368  't.libelle'=>"company"
369  ); // We define here only fields that use another picto
370  if (empty($conf->fournisseur->enabled))
371  {
372  unset($this->export_fields_array[$r]['s.code_fournisseur']);
373  unset($this->export_entities_array[$r]['s.code_fournisseur']);
374  }
375  $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra';
376  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
377  $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
378  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
379  $this->export_sql_start[$r] = 'SELECT DISTINCT ';
380  $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c';
381  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
382  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
383  if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
384  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
385  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays';
386  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
387  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
388  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
389  $this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('socpeople').')';
390  if (is_object($user) && empty($user->rights->societe->client->voir)) {
391  $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
392  if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
393  $subordinatesids = $user->getAllChildIds();
394  $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
395  }
396  $this->export_sql_end[$r] .= ')';
397  }
398 
399 
400  // Imports
401  //--------
402  $r = 0;
403 
404  // Import list of third parties and attributes
405 
406  $r++;
407  $this->import_code[$r] = $this->rights_class.'_'.$r;
408  $this->import_label[$r] = 'ImportDataset_company_1';
409  $this->import_icon[$r] = 'company';
410  $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
411  $this->import_tables_array[$r] = array(
412  's' => MAIN_DB_PREFIX.'societe',
413  'extra' => MAIN_DB_PREFIX.'societe_extrafields'
414  ); // List of tables to insert into (insert done in same order)
415  $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe
416  's.nom' => "Name*",
417  's.name_alias' => "AliasNameShort",
418  's.parent' => "ParentCompany",
419  's.status' => "Status",
420  's.code_client' => "CustomerCode",
421  's.code_fournisseur' => "SupplierCode",
422  's.code_compta' => "CustomerAccountancyCode",
423  's.code_compta_fournisseur' => "SupplierAccountancyCode",
424  's.address' => "Address",
425  's.zip' => "Zip",
426  's.town' => "Town",
427  's.fk_departement' => "StateCode",
428  's.fk_pays' => "CountryCode",
429  's.phone' => "Phone",
430  's.fax' => "Fax",
431  's.url' => "Url",
432  's.email' => "Email",
433  's.skype' => "Skype",
434  's.fk_effectif' => "Staff",
435  's.fk_typent' => "ThirdPartyType",
436  "s.fk_forme_juridique" => "JuridicalStatus",
437  's.siren' => "ProfId1",
438  's.siret' => "ProfId2",
439  's.ape' => "ProfId3",
440  's.idprof4' => "ProfId4",
441  's.idprof5' => "ProfId5",
442  's.idprof6' => "ProfId6",
443  's.tva_intra' => "VATIntraShort",
444  's.capital' => "Capital",
445  's.fk_stcomm' => 'ProspectStatus',
446  's.note_private' => "NotePrivate",
447  's.note_public' => "NotePublic",
448  's.client' => "Customer*",
449  's.fournisseur' => "Supplier*",
450  's.fk_prospectlevel' => 'ProspectLevel',
451  's.mode_reglement' => 'PaymentTypeCustomer',
452  's.cond_reglement' => "PaymentTermsCustomer",
453  's.mode_reglement_supplier' => 'PaymentTypeSupplier',
454  's.cond_reglement_supplier' => "PaymentTermsSupplier",
455  's.outstanding_limit'=>'OutstandingBill',
456  's.fk_account'=>'PaymentBankAccount',
457  's.fk_incoterms'=>'IncotermLabel',
458  's.tva_assuj' => 'VATIsUsed',
459  's.barcode' => 'BarCode',
460  's.default_lang' => 'DefaultLanguage',
461  's.canvas' => "Canvas",
462  's.datec' => "DateCreation",
463  's.fk_multicurrency' => 'MulticurrencyUsed',
464  's.multicurrency_code' => 'MulticurrencyCurrency'
465  );
466  if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel';
467  // Add extra fields
468  $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
469  $resql = $this->db->query($sql);
470  if ($resql) // This can fail when class is used on old database (during migration for example)
471  {
472  while ($obj = $this->db->fetch_object($resql)) {
473  $fieldname = 'extra.'.$obj->name;
474  $fieldlabel = ucfirst($obj->label);
475  $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
476  }
477  }
478  // End add extra fields
479  $this->import_fieldshidden_array[$r] = array(
480  's.fk_user_creat' => 'user->id',
481  'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'societe'
482  ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
483  $this->import_convertvalue_array[$r] = array(//field order as per structure of table llx_societe
484  's.code_client' => array('rule' => 'getcustomercodeifauto'),
485  's.code_fournisseur' => array('rule' => 'getsuppliercodeifauto'),
486  's.code_compta' => array('rule' => 'getcustomeraccountancycodeifauto'),
487  's.code_compta_fournisseur' => array('rule' => 'getsupplieraccountancycodeifauto'),
488  's.fk_departement' => array(
489  'rule' => 'fetchidfromcodeid',
490  'classfile' => '/core/class/cstate.class.php',
491  'class' => 'Cstate',
492  'method' => 'fetch',
493  'dict' => 'DictionaryStateCode'
494  ),
495  's.fk_pays' => array(
496  'rule' => 'fetchidfromcodeid',
497  'classfile' => '/core/class/ccountry.class.php',
498  'class' => 'Ccountry',
499  'method' => 'fetch',
500  'dict' => 'DictionaryCountry'
501  ),
502  's.fk_typent' => array(
503  'rule' => 'fetchidfromcodeorlabel',
504  'classfile' => '/core/class/ctypent.class.php',
505  'class' => 'Ctypent',
506  'method' => 'fetch',
507  'dict' => 'DictionaryCompanyType'
508  ),
509  's.capital' => array('rule' => 'numeric'),
510  's.fk_stcomm' => array('rule' => 'zeroifnull'),
511  's.parent' => array(
512  'rule' => 'fetchidfromref',
513  'file' => '/societe/class/societe.class.php',
514  'class' => 'Societe',
515  'method' => 'fetch',
516  'element' => 'ThirdParty'
517  ),
518  's.outstanding_limit' => array('rule' => 'numeric'),
519  's.fk_account' => array(
520  'rule' => 'fetchidfromcodeid',
521  'classfile' => '/compta/bank/class/account.class.php',
522  'class' => 'Account',
523  'method' => 'fetch',
524  'element' => 'BankAccount'
525  // ),
526  // TODO
527  // 's.fk_incoterms' => array(
528  // 'rule' => 'fetchidfromcodeid',
529  // 'classfile' => '/core/class/cincoterm.class.php',
530  // 'class' => 'Cincoterm',
531  // 'method' => 'fetch',
532  // 'dict' => 'IncotermLabel'
533  )
534  );
535  //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
536  $this->import_regex_array[$r] = array(//field order as per structure of table llx_societe
537  's.status' => '^[0|1]',
538  's.fk_typent' => 'id@'.MAIN_DB_PREFIX.'c_typent',
539  's.client' => '^[0|1|2|3]',
540  's.fournisseur' => '^[0|1]',
541  's.mode_reglement' => 'id@'.MAIN_DB_PREFIX.'c_paiement',
542  's.cond_reglement' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term',
543  's.mode_reglement_supplier' => 'id@'.MAIN_DB_PREFIX.'c_paiement',
544  's.cond_reglement_supplier' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term',
545  's.fk_incoterms' => 'rowid@'.MAIN_DB_PREFIX.'c_incoterms',
546  's.tva_assuj' => '^[0|1]',
547  's.fk_multicurrency' => '^[0|1]',
548  's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
549  's.multicurrency_code' => 'code_iso@'.MAIN_DB_PREFIX.'c_currencies'
550  );
551 
552  $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe
553  's.nom' => "TPBigCompany",
554  's.name_alias' => "Alias for TPBigCompany",
555  's.parent' => "TPMotherCompany",
556  's.status' => "0 (closed) / 1 (active)",
557  's.code_client' => 'eg. CU01-0001 / empty / "auto"',
558  's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"',
559  's.code_compta' => "Code or empty to be auto-created",
560  's.code_compta_fournisseur' => "Code or empty to be auto-created",
561  's.address' => "61 Jump Street",
562  's.zip' => "123456",
563  's.town' => "Bigtown",
564  's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',
565  's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',
566  's.phone' => "eg: +34123456789",
567  's.fax' => "eg. +34987654321",
568  's.url' => "e.g. https://www.mybigcompany.com",
569  's.email' => "e.g. test@mybigcompany.com",
570  's.skype' => "Skype name",
571  's.fk_effectif' => "1/2/3/5: represents one of the five ranges of employees",
572  's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.'c_typent"',
573  's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.'c_forme_juridique"',
574  's.siret' => "",
575  's.siren' => "",
576  's.ape' => "",
577  's.idprof4' => "",
578  's.idprof5' => "",
579  's.idprof6' => "",
580  's.tva_intra' => 'VAT number e.g."FR0123456789"',
581  's.capital' => "10000",
582  's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.'c_stcomm"',
583  's.note_private' => "Example of a PRIVATE note.",
584  's.note_public' => "Example of a PUBLIC note.",
585  's.client' => '0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
586  's.fournisseur' => '0 (not supplier) / 1 (supplier)',
587  's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.'c_prospectlevel"',
588  's.mode_reglement' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"',
589  's.cond_reglement' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"',
590  's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"',
591  's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"',
592  's.outstanding_limit' => "5000",
593  's.fk_account' => "rowid or ref",
594  's.fk_incoterms' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_incoterms"',
595  's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)',
596  's.barcode' => '123456789',
597  's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/',
598  's.canvas' => "empty / a custom canvas form layout url e.g. mycanvas@mymodule",
599  's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
600  's.fk_multicurrency' => '0 (use system default currency) / 1 (use local currency)',
601  's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.'c_currencies"'
602  );
603  $this->import_updatekeys_array[$r] = array(
604  's.nom' => 'Name',
605  's.code_client' => 'CustomerCode',
606  's.code_fournisseur' => 'SupplierCode',
607  's.code_compta' => 'CustomerAccountancyCode',
608  's.code_compta_fournisseur' => 'SupplierAccountancyCode'
609  );
610 
611  // Import list of contacts/additional addresses and attributes
612  $r++;
613  $this->import_code[$r] = $this->rights_class.'_'.$r;
614  $this->import_label[$r] = 'ImportDataset_company_2';
615  $this->import_icon[$r] = 'contact';
616  $this->import_entities_array[$r] = array('s.fk_soc' => 'company'); // We define here only fields that use a different icon than the one defined in import_icon
617  $this->import_tables_array[$r] = array(
618  's' => MAIN_DB_PREFIX.'socpeople',
619  'extra' => MAIN_DB_PREFIX.'socpeople_extrafields'
620  ); // List of tables to insert into (insert done in same order)
621  $this->import_fields_array[$r] = array(//field order as per structure of table llx_socpeople
622  's.rowid' => 'Id',
623  's.datec' => "DateCreation",
624  's.fk_soc' => 'ThirdPartyName',
625  's.civility' => 'UserTitle',
626  's.lastname' => "Lastname*",
627  's.firstname' => "Firstname",
628  's.address' => "Address",
629  's.zip' => "Zip",
630  's.town' => "Town",
631  's.fk_departement' => "StateCode",
632  's.fk_pays' => "CountryCode",
633  's.birthday' => "DateOfBirth",
634  's.poste' => "Role",
635  's.phone' => "Phone",
636  's.phone_perso' => "PhonePerso",
637  's.phone_mobile' => "PhoneMobile",
638  's.fax' => "Fax",
639  's.email' => "Email",
640  's.skype' => "Skype",
641  's.note_private' => "NotePrivate",
642  's.note_public' => "NotePublic"
643  );
644  // Add extra fields
645  $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";
646  $resql = $this->db->query($sql);
647  if ($resql) // This can fail when class is used on an old database (during a migration for example)
648  {
649  while ($obj = $this->db->fetch_object($resql)) {
650  $fieldname = 'extra.'.$obj->name;
651  $fieldlabel = ucfirst($obj->label);
652  $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
653  }
654  }
655  // End add extra fields
656  $this->import_fieldshidden_array[$r] = array(
657  's.fk_user_creat' => 'user->id',
658  'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'socpeople'
659  ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
660  $this->import_convertvalue_array[$r] = array(
661  's.fk_soc' => array(
662  'rule' => 'fetchidfromref',
663  'file' => '/societe/class/societe.class.php',
664  'class' => 'Societe',
665  'method' => 'fetch',
666  'element' => 'ThirdParty'
667  ),
668  's.fk_departement' => array(
669  'rule' => 'fetchidfromcodeid',
670  'classfile' => '/core/class/cstate.class.php',
671  'class' => 'Cstate',
672  'method' => 'fetch',
673  'dict' => 'DictionaryStateCode'
674  ),
675  's.fk_pays' => array(
676  'rule' => 'fetchidfromcodeid',
677  'classfile' => '/core/class/ccountry.class.php',
678  'class' => 'Ccountry',
679  'method' => 'fetch',
680  'dict' => 'DictionaryCountry'
681  ),
682  );
683  //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
684  $this->import_regex_array[$r] = array(
685  's.birthday' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
686  's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'
687  );
688  $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_socpeople
689  's.rowid' => '1',
690  's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
691  's.fk_soc' => 'Third Party name eg. TPBigCompany',
692  's.civility' => 'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.'c_civility"',
693  's.lastname' => "lastname or label",
694  's.firstname' => 'John',
695  's.address' => '61 Jump street',
696  's.zip' => '75000',
697  's.town' => 'Bigtown',
698  's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',
699  's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',
700  's.birthday' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
701  's.poste' => "Director",
702  's.phone' => "5551122",
703  's.phone_perso' => "5551133",
704  's.phone_mobile' => "5551144",
705  's.fax' => "5551155",
706  's.email' => "johnsmith@email.com",
707  's.skype' => "skype username",
708  's.note_private' => "My private note",
709  's.note_public' => "My public note"
710  );
711  $this->import_updatekeys_array[$r] = array(
712  's.rowid' => 'Id'
713  );
714 
715  // Import Bank Accounts
716  $r++;
717  $this->import_code[$r] = $this->rights_class.'_'.$r;
718  $this->import_label[$r] = "ImportDataset_company_3"; // Translation key
719  $this->import_icon[$r] = 'company';
720  $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon
721  $this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX.'societe_rib');
722  $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe_rib
723  'sr.label' => "Label*",
724  'sr.fk_soc' => "ThirdPartyName*",
725  'sr.datec' => "DateCreation*",
726  'sr.bank' => "Bank",
727  'sr.code_banque' => "BankCode",
728  'sr.code_guichet' => "DeskCode",
729  'sr.number' => "BankAccountNumber*",
730  'sr.cle_rib' => "BankAccountNumberKey",
731  'sr.bic' => "BIC",
732  'sr.iban_prefix' => "IBAN",
733  'sr.domiciliation' => "BankAccountDomiciliation",
734  'sr.proprio' => "BankAccountOwner",
735  'sr.owner_address' => "BankAccountOwnerAddress",
736  'sr.default_rib' => 'Default',
737  'sr.rum' => 'RUM',
738  'sr.type' => "Type ban is defaut",
739  );
740 
741  $this->import_convertvalue_array[$r] = array(
742  'sr.fk_soc' => array(
743  'rule' => 'fetchidfromref',
744  'classfile' => '/societe/class/societe.class.php',
745  'class' => 'Societe',
746  'method' => 'fetch',
747  'element' => 'ThirdParty'
748  )
749  );
750  $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe_rib
751  'sr.label' => 'eg. "account1"',
752  'sr.fk_soc' => 'eg. "TPBigCompany"',
753  'sr.datec' => 'date used for creating direct debit UMR formatted as '.dol_print_date(dol_now(),
754  '%Y-%m-%d'),
755  'sr.bank' => 'bank name eg: "ING-Direct"',
756  'sr.code_banque' => 'account sort code (GB)/Routing number (US) eg. "8456"',
757  'sr.code_guichet' => "bank code for office/branch",
758  'sr.number' => 'account number eg. "3333333333"',
759  'sr.cle_rib' => 'account checksum/control digits (if used) eg. "22"',
760  'sr.bic' => 'bank identifier eg. "USHINGMMXXX"',
761  'sr.iban_prefix' => 'complete account IBAN eg. "GB78CPBK08925068637123"',
762  'sr.domiciliation' => 'bank branch address eg. "PARIS"',
763  'sr.proprio' => 'name on the bank account',
764  'sr.owner_address' => 'address of account holder',
765  'sr.default_rib' => '1 (default account) / 0 (not default)',
766  'sr.rum' => 'RUM code',
767  'sr.type' => 'ban',
768  );
769 
770  // Import Company Sales representatives
771  $r++;
772  $this->import_code[$r] = $this->rights_class.'_'.$r;
773  $this->import_label[$r] = "ImportDataset_company_4"; // Translation key
774  $this->import_icon[$r] = 'company';
775  $this->import_entities_array[$r] = array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon
776  $this->import_tables_array[$r] = array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux');
777  $this->import_fields_array[$r] = array('sr.fk_soc'=>"ThirdPartyName*", 'sr.fk_user'=>"User*");
778 
779  $this->import_convertvalue_array[$r] = array(
780  'sr.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'),
781  'sr.fk_user'=>array('rule'=>'fetchidfromref', 'classfile'=>'/user/class/user.class.php', 'class'=>'User', 'method'=>'fetch', 'element'=>'User')
782  );
783  $this->import_examplevalues_array[$r] = array('sr.fk_soc'=>"MyBigCompany", 'sr.fk_user'=>"login");
784  }
785 
786 
795  public function init($options = '')
796  {
797  global $conf, $langs;
798 
799  // We disable this to prevent pb of modules not correctly disabled
800  //$this->remove($options);
801 
802  //ODT template
803  $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt';
804  $dirodt = DOL_DATA_ROOT.'/doctemplates/thirdparties';
805  $dest = $dirodt.'/template_thirdparty.odt';
806 
807  if (file_exists($src) && !file_exists($dest))
808  {
809  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
810  dol_mkdir($dirodt);
811  $result = dol_copy($src, $dest, 0, 0);
812  if ($result < 0)
813  {
814  $langs->load("errors");
815  $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
816  return 0;
817  }
818  }
819 
820  $sql = array();
821 
822  return $this->_init($sql, $options);
823  }
824 }
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
Definition: files.lib.php:663
Class DolibarrModules.
init($options= '')
Function called when module is enabled.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</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:750
dol_now($mode= 'auto')
Return date for now.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
$conf db
API class for accounts.
Definition: inc.php:54
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to describe and enable module Societe.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
_init($array_sql, $options= '')
Enables a module.
__construct($db)
Constructor.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)