|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <[email protected]> |
|
4
|
|
|
* Copyright (C) 2004-2013 Laurent Destailleur <[email protected]> |
|
5
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <[email protected]> |
|
6
|
|
|
* Copyright (C) 2004 Benoit Mortier <[email protected]> |
|
7
|
|
|
* Copyright (C) 2005-2013 Regis Houssin <[email protected]> |
|
8
|
|
|
* Copyright (C) 2012-2014 Juanjo Menent <[email protected]> |
|
9
|
|
|
* Copyright (C) 2022 Ferran Marcet <[email protected]> |
|
10
|
|
|
* Copyright (C) 2024 MDW <[email protected]> |
|
11
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
|
12
|
|
|
* |
|
13
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
14
|
|
|
* it under the terms of the GNU General Public License as published by |
|
15
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
16
|
|
|
* (at your option) any later version. |
|
17
|
|
|
* |
|
18
|
|
|
* This program is distributed in the hope that it will be useful, |
|
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21
|
|
|
* GNU General Public License for more details. |
|
22
|
|
|
* |
|
23
|
|
|
* You should have received a copy of the GNU General Public License |
|
24
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* \defgroup societe Module societe |
|
29
|
|
|
* \brief Module to manage third parties (customers, prospects) |
|
30
|
|
|
* \file htdocs/core/modules/modSociete.class.php |
|
31
|
|
|
* \ingroup societe |
|
32
|
|
|
* \brief Description and activation file for the module societe (thirdparty) |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
namespace Dolibarr\Modules; |
|
36
|
|
|
|
|
37
|
|
|
use Dolibarr\Core\Base\DolibarrModules; |
|
38
|
|
|
use DoliDB; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Class to describe and enable module Societe |
|
42
|
|
|
*/ |
|
43
|
|
|
class Societe extends DolibarrModules |
|
44
|
|
|
{ |
|
45
|
|
|
/** |
|
46
|
|
|
* Constructor. Define names, constants, directories, boxes, permissions |
|
47
|
|
|
* |
|
48
|
|
|
* @param DoliDB $db Database handler |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct($db) |
|
51
|
|
|
{ |
|
52
|
|
|
global $conf, $user, $mysoc, $langs; |
|
53
|
|
|
|
|
54
|
|
|
$this->db = $db; |
|
55
|
|
|
$this->numero = 1; |
|
56
|
|
|
|
|
57
|
|
|
$this->family = "crm"; |
|
58
|
|
|
$this->module_position = '09'; |
|
59
|
|
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
60
|
|
|
$this->name = preg_replace('/^mod/i', '', get_only_class($this)); |
|
61
|
|
|
$this->description = "Gestion des sociétés et contacts"; |
|
62
|
|
|
|
|
63
|
|
|
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
64
|
|
|
$this->version = 'dolibarr'; |
|
65
|
|
|
|
|
66
|
|
|
$this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name); |
|
67
|
|
|
$this->config_page_url = array("societe.php@societe"); |
|
68
|
|
|
// Name of image file used for this module. |
|
69
|
|
|
$this->picto = 'company'; |
|
70
|
|
|
|
|
71
|
|
|
// Data directories to create when module is enabled |
|
72
|
|
|
$this->dirs = array("/societe/temp"); |
|
73
|
|
|
|
|
74
|
|
|
// Dependencies |
|
75
|
|
|
$this->hidden = false; // A condition to hide module |
|
76
|
|
|
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
77
|
|
|
$this->requiredby = array("modExpedition", "modFacture", "modFournisseur", "modFicheinter", "modPropale", "modContrat", "modCommande"); // List of module ids to disable if this one is disabled |
|
78
|
|
|
$this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
79
|
|
|
$this->phpmin = array(7, 0); // Minimum version of PHP required by module |
|
80
|
|
|
$this->langfiles = array("companies", 'bills', "compta", "admin", "banks"); |
|
81
|
|
|
|
|
82
|
|
|
// Constants |
|
83
|
|
|
$this->const = array(); |
|
84
|
|
|
$r = 0; |
|
85
|
|
|
|
|
86
|
|
|
$this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON"; |
|
87
|
|
|
$this->const[$r][1] = "chaine"; |
|
88
|
|
|
$this->const[$r][2] = "mod_codeclient_monkey"; |
|
89
|
|
|
$this->const[$r][3] = 'Module to control third parties codes'; |
|
90
|
|
|
$this->const[$r][4] = 0; |
|
91
|
|
|
$r++; |
|
92
|
|
|
|
|
93
|
|
|
$this->const[$r][0] = "SOCIETE_CODECOMPTA_ADDON"; |
|
94
|
|
|
$this->const[$r][1] = "chaine"; |
|
95
|
|
|
$this->const[$r][2] = "mod_codecompta_panicum"; |
|
96
|
|
|
$this->const[$r][3] = 'Module to control third parties codes'; |
|
97
|
|
|
$this->const[$r][4] = 0; |
|
98
|
|
|
$r++; |
|
99
|
|
|
|
|
100
|
|
|
$this->const[$r][0] = "SOCIETE_FISCAL_MONTH_START"; |
|
101
|
|
|
$this->const[$r][1] = "chaine"; |
|
102
|
|
|
$this->const[$r][2] = "0"; |
|
103
|
|
|
$this->const[$r][3] = "Enter the month number of the first month of the fiscal year, e. g. 9 for September"; |
|
104
|
|
|
$this->const[$r][4] = 0; |
|
105
|
|
|
$r++; |
|
106
|
|
|
|
|
107
|
|
|
$this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH"; |
|
108
|
|
|
$this->const[$r][1] = "chaine"; |
|
109
|
|
|
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties"; |
|
110
|
|
|
$this->const[$r][3] = ""; |
|
111
|
|
|
$this->const[$r][4] = 0; |
|
112
|
|
|
$r++; |
|
113
|
|
|
|
|
114
|
|
|
/* |
|
115
|
|
|
$this->const[$r][0] = "COMPANY_HIDE_INACTIVE_IN_COMBOBOX"; |
|
116
|
|
|
$this->const[$r][1] = "chaine"; |
|
117
|
|
|
$this->const[$r][2] = "0"; |
|
118
|
|
|
$this->const[$r][3] = "hide thirdparty customer inative in combobox"; |
|
119
|
|
|
$this->const[$r][4] = 1; |
|
120
|
|
|
$r++; |
|
121
|
|
|
*/ |
|
122
|
|
|
|
|
123
|
|
|
$this->const[$r][0] = "SOCIETE_ADD_REF_IN_LIST"; |
|
124
|
|
|
$this->const[$r][1] = "yesno"; |
|
125
|
|
|
$this->const[$r][2] = "0"; |
|
126
|
|
|
$this->const[$r][3] = "Display customer ref into select list"; |
|
127
|
|
|
$this->const[$r][4] = 0; |
|
128
|
|
|
$r++; |
|
129
|
|
|
|
|
130
|
|
|
// Boxes |
|
131
|
|
|
$this->boxes = array( |
|
132
|
|
|
0 => array('file' => 'box_clients.php', 'enabledbydefaulton' => 'Home'), |
|
133
|
|
|
1 => array('file' => 'box_prospect.php', 'enabledbydefaulton' => 'Home'), |
|
134
|
|
|
2 => array('file' => 'box_contacts.php', 'enabledbydefaulton' => 'Home'), |
|
135
|
|
|
3 => array('file' => 'box_activity.php', 'enabledbydefaulton' => 'Home', 'note' => '(WarningUsingThisBoxSlowDown)'), |
|
136
|
|
|
4 => array('file' => 'box_goodcustomers.php', 'enabledbydefaulton' => 'Home', 'note' => '(WarningUsingThisBoxSlowDown)'), |
|
137
|
|
|
); |
|
138
|
|
|
|
|
139
|
|
|
// Permissions |
|
140
|
|
|
$this->rights = array(); |
|
141
|
|
|
$this->rights_class = 'societe'; |
|
142
|
|
|
$r = 0; |
|
143
|
|
|
|
|
144
|
|
|
$r++; |
|
145
|
|
|
$this->rights[$r][0] = 121; // id de la permission |
|
146
|
|
|
$this->rights[$r][1] = 'Read third parties'; // libelle de la permission |
|
147
|
|
|
$this->rights[$r][2] = 'r'; // type de la permission (deprecated) |
|
148
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
149
|
|
|
$this->rights[$r][4] = 'lire'; |
|
150
|
|
|
|
|
151
|
|
|
/*$r++; |
|
152
|
|
|
$this->rights[$r][0] = 241; |
|
153
|
|
|
$this->rights[$r][1] = 'Read thirdparties customers'; |
|
154
|
|
|
$this->rights[$r][2] = 'r'; |
|
155
|
|
|
$this->rights[$r][3] = 0; |
|
156
|
|
|
$this->rights[$r][4] = 'thirdparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
157
|
|
|
$this->rights[$r][5] = 'read'; |
|
158
|
|
|
|
|
159
|
|
|
$r++; |
|
160
|
|
|
$this->rights[$r][0] = 242; |
|
161
|
|
|
$this->rights[$r][1] = 'Read thirdparties suppliers'; |
|
162
|
|
|
$this->rights[$r][2] = 'r'; |
|
163
|
|
|
$this->rights[$r][3] = 0; |
|
164
|
|
|
$this->rights[$r][4] = 'thirdparty_supplier_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
165
|
|
|
$this->rights[$r][5] = 'read'; |
|
166
|
|
|
*/ |
|
167
|
|
|
|
|
168
|
|
|
$r++; |
|
169
|
|
|
$this->rights[$r][0] = 122; // id de la permission |
|
170
|
|
|
$this->rights[$r][1] = 'Create and update third parties'; // libelle de la permission |
|
171
|
|
|
$this->rights[$r][2] = 'w'; // type de la permission (deprecated) |
|
172
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
173
|
|
|
$this->rights[$r][4] = 'creer'; |
|
174
|
|
|
|
|
175
|
|
|
/* $r++; |
|
176
|
|
|
$this->rights[$r][0] = 251; |
|
177
|
|
|
$this->rights[$r][1] = 'Create thirdparties customers'; |
|
178
|
|
|
$this->rights[$r][2] = 'r'; |
|
179
|
|
|
$this->rights[$r][3] = 0; |
|
180
|
|
|
$this->rights[$r][4] = 'thirdparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
181
|
|
|
$this->rights[$r][5] = 'read'; |
|
182
|
|
|
|
|
183
|
|
|
$r++; |
|
184
|
|
|
$this->rights[$r][0] = 252; |
|
185
|
|
|
$this->rights[$r][1] = 'Create thirdparties suppliers'; |
|
186
|
|
|
$this->rights[$r][2] = 'r'; |
|
187
|
|
|
$this->rights[$r][3] = 0; |
|
188
|
|
|
$this->rights[$r][4] = 'thirdparty_supplier_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
189
|
|
|
$this->rights[$r][5] = 'read'; |
|
190
|
|
|
*/ |
|
191
|
|
|
|
|
192
|
|
|
$r++; |
|
193
|
|
|
$this->rights[$r][0] = 125; // id de la permission |
|
194
|
|
|
$this->rights[$r][1] = 'Delete third parties'; // libelle de la permission |
|
195
|
|
|
$this->rights[$r][2] = 'd'; // type de la permission (deprecated) |
|
196
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
197
|
|
|
$this->rights[$r][4] = 'supprimer'; |
|
198
|
|
|
|
|
199
|
|
|
$r++; |
|
200
|
|
|
$this->rights[$r][0] = 126; // id de la permission |
|
201
|
|
|
$this->rights[$r][1] = 'Export third parties'; // libelle de la permission |
|
202
|
|
|
$this->rights[$r][2] = 'r'; // type de la permission (deprecated) |
|
203
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
204
|
|
|
$this->rights[$r][4] = 'export'; |
|
205
|
|
|
|
|
206
|
|
|
$r++; |
|
207
|
|
|
$this->rights[$r][0] = 130; |
|
208
|
|
|
$this->rights[$r][1] = 'Modify thirdparty information payment'; |
|
209
|
|
|
$this->rights[$r][3] = 0; |
|
210
|
|
|
$this->rights[$r][4] = 'thirdparty_paymentinformation_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
211
|
|
|
$this->rights[$r][5] = 'write'; |
|
212
|
|
|
|
|
213
|
|
|
// 262 : Restrict access to sales representative |
|
214
|
|
|
$r++; |
|
215
|
|
|
$this->rights[$r][0] = 262; |
|
216
|
|
|
$this->rights[$r][1] = 'Read all third parties (and their objects) by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).'; |
|
217
|
|
|
$this->rights[$r][2] = 'r'; |
|
218
|
|
|
$this->rights[$r][3] = 0; |
|
219
|
|
|
$this->rights[$r][4] = 'client'; |
|
220
|
|
|
$this->rights[$r][5] = 'voir'; |
|
221
|
|
|
|
|
222
|
|
|
/* |
|
223
|
|
|
$r++; |
|
224
|
|
|
$this->rights[$r][0] = 263; |
|
225
|
|
|
$this->rights[$r][1] = 'Read all third parties (without their objects) by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).'; |
|
226
|
|
|
$this->rights[$r][2] = 'r'; |
|
227
|
|
|
$this->rights[$r][3] = 0; |
|
228
|
|
|
$this->rights[$r][4] = 'client'; |
|
229
|
|
|
$this->rights[$r][5] = 'readallthirdparties_advance'; |
|
230
|
|
|
*/ |
|
231
|
|
|
|
|
232
|
|
|
$r++; |
|
233
|
|
|
$this->rights[$r][0] = 281; // id de la permission |
|
234
|
|
|
$this->rights[$r][1] = 'Read contacts'; // libelle de la permission |
|
235
|
|
|
$this->rights[$r][2] = 'r'; // type de la permission (deprecated) |
|
236
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
237
|
|
|
$this->rights[$r][4] = 'contact'; |
|
238
|
|
|
$this->rights[$r][5] = 'lire'; |
|
239
|
|
|
|
|
240
|
|
|
$r++; |
|
241
|
|
|
$this->rights[$r][0] = 282; // id de la permission |
|
242
|
|
|
$this->rights[$r][1] = 'Create and update contact'; // libelle de la permission |
|
243
|
|
|
$this->rights[$r][2] = 'w'; // type de la permission (deprecated) |
|
244
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
245
|
|
|
$this->rights[$r][4] = 'contact'; |
|
246
|
|
|
$this->rights[$r][5] = 'creer'; |
|
247
|
|
|
|
|
248
|
|
|
$r++; |
|
249
|
|
|
$this->rights[$r][0] = 283; // id de la permission |
|
250
|
|
|
$this->rights[$r][1] = 'Delete contacts'; // libelle de la permission |
|
251
|
|
|
$this->rights[$r][2] = 'd'; // type de la permission (deprecated) |
|
252
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
253
|
|
|
$this->rights[$r][4] = 'contact'; |
|
254
|
|
|
$this->rights[$r][5] = 'supprimer'; |
|
255
|
|
|
|
|
256
|
|
|
$r++; |
|
257
|
|
|
$this->rights[$r][0] = 286; // id de la permission |
|
258
|
|
|
$this->rights[$r][1] = 'Export contacts'; // libelle de la permission |
|
259
|
|
|
$this->rights[$r][2] = 'd'; // type de la permission (deprecated) |
|
260
|
|
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par default |
|
261
|
|
|
$this->rights[$r][4] = 'contact'; |
|
262
|
|
|
$this->rights[$r][5] = 'export'; |
|
263
|
|
|
|
|
264
|
|
|
|
|
265
|
|
|
// Menus |
|
266
|
|
|
//------- |
|
267
|
|
|
$this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
268
|
|
|
|
|
269
|
|
|
|
|
270
|
|
|
// Exports |
|
271
|
|
|
//-------- |
|
272
|
|
|
$r = 0; |
|
273
|
|
|
|
|
274
|
|
|
// Export list of third parties and attributes |
|
275
|
|
|
$r++; |
|
276
|
|
|
$this->export_code[$r] = $this->rights_class . '_' . $r; |
|
277
|
|
|
$this->export_label[$r] = 'ExportDataset_company_1'; |
|
278
|
|
|
$this->export_icon[$r] = 'company'; |
|
279
|
|
|
$this->export_permission[$r] = array(array("societe", "export")); |
|
280
|
|
|
$this->export_fields_array[$r] = array( |
|
281
|
|
|
's.rowid' => "Id", 's.nom' => "Name", 's.name_alias' => "AliasNameShort", 'ps.nom' => "ParentCompany", |
|
282
|
|
|
's.status' => "Status", 's.client' => "Customer", 's.fournisseur' => "Supplier", 's.datec' => "DateCreation", 's.tms' => "DateLastModification", |
|
283
|
|
|
's.code_client' => "CustomerCode", 's.code_fournisseur' => "SupplierCode", 's.code_compta' => "AccountancyCode", 's.code_compta_fournisseur' => "SupplierAccountancyCode", |
|
284
|
|
|
'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", |
|
285
|
|
|
'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", |
|
286
|
|
|
's.idprof5' => "ProfId5", 's.idprof6' => "ProfId6", 's.tva_intra' => "VATIntraShort", 's.capital' => "Capital", 's.note_private' => "NotePrivate", 's.note_public' => "NotePublic", |
|
287
|
|
|
't.code' => "ThirdPartyType", 'ce.code' => "DictionaryStaff", "cfj.libelle" => "JuridicalStatus", 's.fk_prospectlevel' => 'ProspectLevel', |
|
288
|
|
|
'st.code' => 'ProspectStatus', 'payterm.libelle' => 'PaymentConditions', 'paymode.libelle' => 'PaymentMode', |
|
289
|
|
|
's.outstanding_limit' => 'OutstandingBill', 'pbacc.ref' => 'PaymentBankAccount', 'incoterm.code' => 'IncotermLabel' |
|
290
|
|
|
); |
|
291
|
|
|
if (getDolGlobalString('SOCIETE_USEPREFIX')) { |
|
292
|
|
|
$this->export_fields_array[$r]['s.prefix'] = 'Prefix'; |
|
293
|
|
|
} |
|
294
|
|
|
if (getDolGlobalString('PRODUIT_MULTIPRICES')) { |
|
295
|
|
|
$this->export_fields_array[$r]['s.price_level'] = 'PriceLevel'; |
|
296
|
|
|
} |
|
297
|
|
|
if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) { |
|
298
|
|
|
$this->export_fields_array[$r] += array('s.accountancy_code_sell' => 'ProductAccountancySellCode', 's.accountancy_code_buy' => 'ProductAccountancyBuyCode'); |
|
299
|
|
|
} |
|
300
|
|
|
// Add multicompany field |
|
301
|
|
|
if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) { |
|
302
|
|
|
$nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1 |
|
303
|
|
|
if (isModEnabled('multicompany') && $nbofallowedentities > 1) { |
|
304
|
|
|
$this->export_fields_array[$r] += array('s.entity' => 'Entity'); |
|
305
|
|
|
} |
|
306
|
|
|
} |
|
307
|
|
|
$keyforselect = 'societe'; |
|
308
|
|
|
$keyforelement = 'company'; |
|
309
|
|
|
$keyforaliasextra = 'extra'; |
|
310
|
|
|
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
|
311
|
|
|
$this->export_fields_array[$r] += array('u.login' => 'SaleRepresentativeLogin', 'u.firstname' => 'SaleRepresentativeFirstname', 'u.lastname' => 'SaleRepresentativeLastname'); |
|
312
|
|
|
|
|
313
|
|
|
$this->export_TypeFields_array[$r] = array( |
|
314
|
|
|
's.rowid' => "Numeric", 's.nom' => "Text", 's.name_alias' => "Text", 'ps.nom' => "Text", |
|
315
|
|
|
's.status' => "Numeric", 's.client' => "Numeric", 's.fournisseur' => "Boolean", 's.datec' => "Date", 's.tms' => "Date", |
|
316
|
|
|
's.code_client' => "Text", 's.code_fournisseur' => "Text", 's.code_compta' => "Text", 's.code_compta_fournisseur' => "Text", |
|
317
|
|
|
's.address' => "Text", 's.zip' => "Text", 's.town' => "Text", |
|
318
|
|
|
'd.nom' => 'Text', 'r.nom' => 'Text', 'c.label' => 'List:c_country:label:label', 'c.code' => 'Text', |
|
319
|
|
|
's.phone' => "Text", 's.fax' => "Text", |
|
320
|
|
|
's.url' => "Text", 's.email' => "Text", 's.default_lang' => "Text", 's.canvas' => "Text", |
|
321
|
|
|
's.siret' => "Text", 's.siren' => "Text", 's.ape' => "Text", 's.idprof4' => "Text", 's.idprof5' => "Text", 's.idprof6' => "Text", |
|
322
|
|
|
's.tva_intra' => "Text", 's.capital' => "Numeric", |
|
323
|
|
|
's.note_private' => "Text", 's.note_public' => "Text", |
|
324
|
|
|
't.code' => "List:c_typent:libelle:code", |
|
325
|
|
|
'ce.code' => "List:c_effectif:libelle:code", |
|
326
|
|
|
"cfj.libelle" => "Text", |
|
327
|
|
|
's.fk_prospectlevel' => 'List:c_prospectlevel:label:code', |
|
328
|
|
|
'st.code' => 'List:c_stcomm:libelle:code', |
|
329
|
|
|
'payterm.libelle' => 'Text', 'paymode.libelle' => 'Text', |
|
330
|
|
|
's.outstanding_limit' => 'Numeric', 'pbacc.ref' => 'Text', 'incoterm.code' => 'Text', |
|
331
|
|
|
'u.login' => 'Text', 'u.firstname' => 'Text', 'u.lastname' => 'Text', |
|
332
|
|
|
's.entity' => 'List:entity:label:rowid', 's.price_level' => 'Numeric', |
|
333
|
|
|
's.accountancy_code_sell' => 'Text', 's.accountancy_code_buy' => 'Text' |
|
334
|
|
|
); |
|
335
|
|
|
|
|
336
|
|
|
$this->export_entities_array[$r] = array( // We define here only fields that use another picto |
|
337
|
|
|
'u.login' => 'user', |
|
338
|
|
|
'u.firstname' => 'user', |
|
339
|
|
|
'u.lastname' => 'user'); |
|
340
|
|
|
$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)'); |
|
341
|
|
|
$this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
342
|
|
|
$this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
|
343
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_extrafields as extra ON s.rowid = extra.fk_object'; |
|
344
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as ps ON s.parent = ps.rowid'; |
|
345
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_typent as t ON s.fk_typent = t.id'; |
|
346
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid'; |
|
347
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_effectif as ce ON s.fk_effectif = ce.id'; |
|
348
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; |
|
349
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_departements as d ON s.fk_departement = d.rowid'; |
|
350
|
|
|
$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'; |
|
351
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_stcomm as st ON s.fk_stcomm = st.id'; |
|
352
|
|
|
$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'; |
|
353
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; |
|
354
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as paymode ON s.mode_reglement = paymode.id'; |
|
355
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as pbacc ON s.fk_account = pbacc.rowid'; |
|
356
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid'; |
|
357
|
|
|
$this->export_sql_end[$r] .= ' WHERE s.entity IN (' . getEntity('societe') . ')'; |
|
358
|
|
|
if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
|
359
|
|
|
$this->export_sql_end[$r] .= ' AND (sc.fk_user = ' . ((int)$user->id) . ' '; |
|
360
|
|
|
if (getDolGlobalString('SOCIETE_EXPORT_SUBORDINATES_CHILDS')) { |
|
361
|
|
|
$subordinatesids = $user->getAllChildIds(); |
|
362
|
|
|
$this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN (' . $this->db->sanitize(implode(',', $subordinatesids)) . ')' : ''; |
|
363
|
|
|
} |
|
364
|
|
|
$this->export_sql_end[$r] .= ')'; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
// Export list of contacts and attributes |
|
368
|
|
|
$r++; |
|
369
|
|
|
$this->export_code[$r] = $this->rights_class . '_' . $r; |
|
370
|
|
|
$this->export_label[$r] = 'ExportDataset_company_2'; |
|
371
|
|
|
$this->export_icon[$r] = 'contact'; |
|
372
|
|
|
$this->export_permission[$r] = array(array("societe", "contact", "export")); |
|
373
|
|
|
$this->export_fields_array[$r] = array( |
|
374
|
|
|
'c.rowid' => "IdContact", 'c.civility' => "CivilityCode", 'c.lastname' => 'Lastname', 'c.firstname' => 'Firstname', 'c.poste' => 'PostOrFunction', |
|
375
|
|
|
'c.datec' => "DateCreation", 'c.tms' => "DateLastModification", 'c.priv' => "ContactPrivate", 'c.address' => "Address", 'c.zip' => "Zip", 'c.town' => "Town", |
|
376
|
|
|
'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", |
|
377
|
|
|
'c.note_private' => 'NotePrivate', 'c.note_public' => "NotePublic", |
|
378
|
|
|
'c.statut' => "Status", |
|
379
|
|
|
's.rowid' => "IdCompany", 's.nom' => "CompanyName", 's.status' => "Status", 's.code_client' => "CustomerCode", 's.code_fournisseur' => "SupplierCode", |
|
380
|
|
|
's.code_compta' => "AccountancyCode", 's.code_compta_fournisseur' => "SupplierAccountancyCode", |
|
381
|
|
|
's.client' => 'Customer', 's.fournisseur' => 'Supplier', |
|
382
|
|
|
's.address' => 'Address', 's.zip' => "Zip", 's.town' => "Town", 's.phone' => 'Phone', 's.email' => "Email", |
|
383
|
|
|
's.note_private' => 'NotePrivate', 's.note_public' => "NotePublic", |
|
384
|
|
|
't.code' => "ThirdPartyType" |
|
385
|
|
|
); |
|
386
|
|
|
// Add multicompany field |
|
387
|
|
|
if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) { |
|
388
|
|
|
if (isModEnabled('multicompany')) { |
|
389
|
|
|
$nbofallowedentities = count(explode(',', getEntity('contact'))); |
|
390
|
|
|
if ($nbofallowedentities > 1) { |
|
391
|
|
|
$this->export_fields_array[$r]['c.entity'] = 'Entity'; |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
$nbofallowedentities = count(explode(',', getEntity('societe'))); |
|
395
|
|
|
if ($nbofallowedentities > 1) { |
|
396
|
|
|
$this->export_fields_array[$r]['s.entity'] = 'Entity'; |
|
397
|
|
|
} |
|
398
|
|
|
} |
|
399
|
|
|
} |
|
400
|
|
|
$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)'); |
|
401
|
|
|
$this->export_TypeFields_array[$r] = array( |
|
402
|
|
|
'c.civility' => "List:c_civility:label:code", 'c.lastname' => 'Text', 'c.firstname' => 'Text', 'c.poste' => 'Text', 'c.datec' => "Date", 'c.priv' => "Boolean", |
|
403
|
|
|
'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", |
|
404
|
|
|
'c.fax' => "Text", 'c.email' => "Text", |
|
405
|
|
|
'c.statut' => "Status", |
|
406
|
|
|
's.rowid' => "Numeric", 's.nom' => "Text", 's.status' => "Status", 's.code_client' => "Text", 's.code_fournisseur' => "Text", |
|
407
|
|
|
's.code_compta' => "Text", 's.code_compta_fournisseur' => "Text", |
|
408
|
|
|
's.client' => "Numeric", 's.fournisseur' => "Numeric", |
|
409
|
|
|
's.address' => "Text", 's.zip' => "Text", 's.town' => "Text", 's.phone' => "Text", 's.email' => "Text", |
|
410
|
|
|
't.code' => "List:c_stcomm:libelle:code", |
|
411
|
|
|
'c.entity' => 'List:entity:label:rowid', |
|
412
|
|
|
's.entity' => 'List:entity:label:rowid', |
|
413
|
|
|
); |
|
414
|
|
|
$this->export_entities_array[$r] = array( // We define here only fields that use another picto |
|
415
|
|
|
's.rowid' => "company", 's.nom' => "company", 's.status' => 'company', 's.code_client' => "company", 's.code_fournisseur' => "company", |
|
416
|
|
|
's.code_compta' => "company", 's.code_compta_fournisseur' => "company", |
|
417
|
|
|
's.client' => "company", 's.fournisseur' => "company", |
|
418
|
|
|
's.address' => "company", 's.zip' => "company", 's.town' => "company", 's.phone' => "company", 's.email' => "company", |
|
419
|
|
|
't.code' => "company", |
|
420
|
|
|
's.entity' => 'company', |
|
421
|
|
|
); // We define here only fields that use another picto |
|
422
|
|
|
if (!isModEnabled("supplier_order") && !isModEnabled("supplier_invoice")) { |
|
423
|
|
|
unset($this->export_fields_array[$r]['s.code_fournisseur']); |
|
424
|
|
|
unset($this->export_entities_array[$r]['s.code_fournisseur']); |
|
425
|
|
|
} |
|
426
|
|
|
$keyforselect = 'socpeople'; |
|
427
|
|
|
$keyforelement = 'contact'; |
|
428
|
|
|
$keyforaliasextra = 'extra'; |
|
429
|
|
|
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
|
430
|
|
|
$keyforselect = 'societe'; |
|
431
|
|
|
$keyforelement = 'company'; |
|
432
|
|
|
$keyforaliasextra = 'extrasoc'; |
|
433
|
|
|
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
|
434
|
|
|
$this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
435
|
|
|
$this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'socpeople as c'; |
|
436
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON c.fk_soc = s.rowid'; |
|
437
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
|
438
|
|
|
if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
|
439
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
440
|
|
|
} |
|
441
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_departements as d ON c.fk_departement = d.rowid'; |
|
442
|
|
|
$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'; |
|
443
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as co ON c.fk_pays = co.rowid'; |
|
444
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; |
|
445
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_typent as t ON s.fk_typent = t.id'; |
|
446
|
|
|
$this->export_sql_end[$r] .= ' WHERE c.entity IN (' . getEntity('contact') . ')'; |
|
447
|
|
|
if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
|
448
|
|
|
$this->export_sql_end[$r] .= ' AND (sc.fk_user = ' . ((int)$user->id) . ' '; |
|
449
|
|
|
if (getDolGlobalString('SOCIETE_EXPORT_SUBORDINATES_CHILDS')) { |
|
450
|
|
|
$subordinatesids = $user->getAllChildIds(); |
|
451
|
|
|
$this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN (' . $this->db->sanitize(implode(',', $subordinatesids)) . ')' : ''; |
|
452
|
|
|
} |
|
453
|
|
|
$this->export_sql_end[$r] .= ')'; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
|
|
457
|
|
|
// Imports |
|
458
|
|
|
//-------- |
|
459
|
|
|
$r = 0; |
|
460
|
|
|
|
|
461
|
|
|
// Import list of third parties and attributes |
|
462
|
|
|
|
|
463
|
|
|
$r++; |
|
464
|
|
|
$this->import_code[$r] = $this->rights_class . '_' . $r; |
|
465
|
|
|
$this->import_label[$r] = 'ImportDataset_company_1'; |
|
466
|
|
|
$this->import_icon[$r] = 'company'; |
|
467
|
|
|
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon |
|
468
|
|
|
$this->import_tables_array[$r] = array( |
|
469
|
|
|
's' => MAIN_DB_PREFIX . 'societe', |
|
470
|
|
|
'extra' => MAIN_DB_PREFIX . 'societe_extrafields' |
|
471
|
|
|
); // List of tables to insert into (insert done in same order) |
|
472
|
|
|
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe |
|
473
|
|
|
's.nom' => "ThirdPartyName*", |
|
474
|
|
|
's.name_alias' => "AliasNameShort", |
|
475
|
|
|
's.parent' => "ParentCompany", |
|
476
|
|
|
's.status' => "Status*", |
|
477
|
|
|
's.code_client' => "CustomerCode", |
|
478
|
|
|
's.code_fournisseur' => "SupplierCode", |
|
479
|
|
|
's.code_compta' => "CustomerAccountancyCode", |
|
480
|
|
|
's.code_compta_fournisseur' => "SupplierAccountancyCode", |
|
481
|
|
|
's.address' => "Address", |
|
482
|
|
|
's.zip' => "Zip", |
|
483
|
|
|
's.town' => "Town", |
|
484
|
|
|
's.fk_departement' => "StateCode", |
|
485
|
|
|
's.fk_pays' => "CountryCode", |
|
486
|
|
|
's.phone' => "Phone", |
|
487
|
|
|
's.fax' => "Fax", |
|
488
|
|
|
's.url' => "Url", |
|
489
|
|
|
's.email' => "Email", |
|
490
|
|
|
's.fk_effectif' => "Staff", |
|
491
|
|
|
's.fk_typent' => "ThirdPartyType", |
|
492
|
|
|
"s.fk_forme_juridique" => "JuridicalStatus", |
|
493
|
|
|
's.siren' => "ProfId1", |
|
494
|
|
|
's.siret' => "ProfId2", |
|
495
|
|
|
's.ape' => "ProfId3", |
|
496
|
|
|
's.idprof4' => "ProfId4", |
|
497
|
|
|
's.idprof5' => "ProfId5", |
|
498
|
|
|
's.idprof6' => "ProfId6", |
|
499
|
|
|
's.tva_intra' => "VATIntraShort", |
|
500
|
|
|
's.capital' => "Capital", |
|
501
|
|
|
's.fk_stcomm' => 'ProspectStatus', |
|
502
|
|
|
's.note_private' => "NotePrivate", |
|
503
|
|
|
's.note_public' => "NotePublic", |
|
504
|
|
|
's.client' => "Customer*", |
|
505
|
|
|
's.fournisseur' => "Supplier*", |
|
506
|
|
|
's.fk_prospectlevel' => 'ProspectLevel', |
|
507
|
|
|
's.mode_reglement' => 'PaymentTypeCustomer', |
|
508
|
|
|
's.cond_reglement' => "PaymentTermsCustomer", |
|
509
|
|
|
's.mode_reglement_supplier' => 'PaymentTypeSupplier', |
|
510
|
|
|
's.cond_reglement_supplier' => "PaymentTermsSupplier", |
|
511
|
|
|
's.outstanding_limit' => 'OutstandingBill', |
|
512
|
|
|
's.fk_account' => 'PaymentBankAccount', |
|
513
|
|
|
's.fk_incoterms' => 'IncotermLabel', |
|
514
|
|
|
's.tva_assuj' => 'VATIsUsed', |
|
515
|
|
|
's.barcode' => 'BarCode', |
|
516
|
|
|
's.default_lang' => 'DefaultLanguage', |
|
517
|
|
|
's.canvas' => "Canvas", |
|
518
|
|
|
's.datec' => "DateCreation", |
|
519
|
|
|
's.fk_multicurrency' => 'MulticurrencyUsed', |
|
520
|
|
|
's.multicurrency_code' => 'MulticurrencyCurrency' |
|
521
|
|
|
); |
|
522
|
|
|
if (getDolGlobalString('PRODUIT_MULTIPRICES')) { |
|
523
|
|
|
$this->import_fields_array[$r]['s.price_level'] = 'PriceLevel'; |
|
524
|
|
|
} |
|
525
|
|
|
if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) { |
|
526
|
|
|
$this->import_fields_array[$r] += array('s.accountancy_code_sell' => 'ProductAccountancySellCode', 's.accountancy_code_buy' => 'ProductAccountancyBuyCode'); |
|
527
|
|
|
} |
|
528
|
|
|
// Add social networks fields |
|
529
|
|
|
if (isModEnabled('socialnetworks')) { |
|
530
|
|
|
$sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "c_socialnetworks WHERE active = 1"; |
|
531
|
|
|
$resql = $this->db->query($sql); |
|
532
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
533
|
|
|
$fieldname = 's.socialnetworks_' . $obj->code; |
|
534
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
535
|
|
|
$this->import_fields_array[$r][$fieldname] = $fieldlabel; |
|
536
|
|
|
} |
|
537
|
|
|
} |
|
538
|
|
|
// Add extra fields |
|
539
|
|
|
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, " . $conf->entity . ")"; |
|
540
|
|
|
$resql = $this->db->query($sql); |
|
541
|
|
|
if ($resql) { // This can fail when class is used on old database (during migration for example) |
|
542
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
543
|
|
|
$fieldname = 'extra.' . $obj->name; |
|
544
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
545
|
|
|
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
|
546
|
|
|
} |
|
547
|
|
|
} |
|
548
|
|
|
// End add extra fields |
|
549
|
|
|
$this->import_fieldshidden_array[$r] = array( |
|
550
|
|
|
's.fk_user_creat' => 'user->id', |
|
551
|
|
|
'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'societe' |
|
552
|
|
|
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
553
|
|
|
$this->import_convertvalue_array[$r] = array(//field order as per structure of table llx_societe |
|
554
|
|
|
's.code_client' => array('rule' => 'getcustomercodeifauto'), |
|
555
|
|
|
's.code_fournisseur' => array('rule' => 'getsuppliercodeifauto'), |
|
556
|
|
|
's.code_compta' => array('rule' => 'getcustomeraccountancycodeifauto'), |
|
557
|
|
|
's.code_compta_fournisseur' => array('rule' => 'getsupplieraccountancycodeifauto'), |
|
558
|
|
|
's.fk_departement' => array( |
|
559
|
|
|
'rule' => 'fetchidfromcodeid', |
|
560
|
|
|
'classfile' => '/core/class/cstate.class.php', |
|
561
|
|
|
'class' => 'Cstate', |
|
562
|
|
|
'method' => 'fetch', |
|
563
|
|
|
'dict' => 'DictionaryStateCode' |
|
564
|
|
|
), |
|
565
|
|
|
's.fk_pays' => array( |
|
566
|
|
|
'rule' => 'fetchidfromcodeid', |
|
567
|
|
|
'classfile' => '/core/class/ccountry.class.php', |
|
568
|
|
|
'class' => 'Ccountry', |
|
569
|
|
|
'method' => 'fetch', |
|
570
|
|
|
'dict' => 'DictionaryCountry' |
|
571
|
|
|
), |
|
572
|
|
|
's.fk_typent' => array( |
|
573
|
|
|
'rule' => 'fetchidfromcodeorlabel', |
|
574
|
|
|
'classfile' => '/core/class/ctypent.class.php', |
|
575
|
|
|
'class' => 'Ctypent', |
|
576
|
|
|
'method' => 'fetch', |
|
577
|
|
|
'dict' => 'DictionaryCompanyType' |
|
578
|
|
|
), |
|
579
|
|
|
's.capital' => array('rule' => 'numeric'), |
|
580
|
|
|
's.parent' => array( |
|
581
|
|
|
'rule' => 'fetchidfromref', |
|
582
|
|
|
'file' => '/societe/class/societe.class.php', |
|
583
|
|
|
'class' => 'Societe', |
|
584
|
|
|
'method' => 'fetch', |
|
585
|
|
|
'element' => 'ThirdParty' |
|
586
|
|
|
), |
|
587
|
|
|
's.outstanding_limit' => array('rule' => 'numeric'), |
|
588
|
|
|
's.fk_account' => array( |
|
589
|
|
|
'rule' => 'fetchidfromcodeid', |
|
590
|
|
|
'classfile' => '/compta/bank/class/account.class.php', |
|
591
|
|
|
'class' => 'Account', |
|
592
|
|
|
'method' => 'fetch', |
|
593
|
|
|
'element' => 'BankAccount' |
|
594
|
|
|
), |
|
595
|
|
|
's.fk_stcomm' => array( |
|
596
|
|
|
'rule' => 'fetchidfromcodeid', |
|
597
|
|
|
'classfile' => '/core/class/cgenericdic.class.php', |
|
598
|
|
|
'class' => 'CGenericDic', |
|
599
|
|
|
'method' => 'fetch', |
|
600
|
|
|
'dict' => 'DictionaryProspectStatus', |
|
601
|
|
|
'element' => 'c_stcomm', |
|
602
|
|
|
'table_element' => 'c_stcomm' |
|
603
|
|
|
), |
|
604
|
|
|
/* |
|
605
|
|
|
's.fk_prospectlevel' => array( |
|
606
|
|
|
'rule' => 'fetchidfromcodeid', |
|
607
|
|
|
'classfile' => '/core/class/cgenericdic.class.php', |
|
608
|
|
|
'class' => 'CGenericDic', |
|
609
|
|
|
'method' => 'fetch', |
|
610
|
|
|
'dict' => 'DictionaryProspectLevel', |
|
611
|
|
|
'element' => 'c_prospectlevel', |
|
612
|
|
|
'table_element' => 'c_prospectlevel' |
|
613
|
|
|
),*/ |
|
614
|
|
|
// TODO |
|
615
|
|
|
// 's.fk_incoterms' => array( |
|
616
|
|
|
// 'rule' => 'fetchidfromcodeid', |
|
617
|
|
|
// 'classfile' => '/core/class/cincoterm.class.php', |
|
618
|
|
|
// 'class' => 'Cincoterm', |
|
619
|
|
|
// 'method' => 'fetch', |
|
620
|
|
|
// 'dict' => 'IncotermLabel' |
|
621
|
|
|
// ) |
|
622
|
|
|
); |
|
623
|
|
|
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
624
|
|
|
$this->import_regex_array[$r] = array(//field order as per structure of table llx_societe |
|
625
|
|
|
's.status' => '^[0|1]', |
|
626
|
|
|
's.fk_typent' => 'id@' . MAIN_DB_PREFIX . 'c_typent', |
|
627
|
|
|
's.client' => '^[0|1|2|3]', |
|
628
|
|
|
's.fournisseur' => '^[0|1]', |
|
629
|
|
|
's.mode_reglement' => 'id@' . MAIN_DB_PREFIX . 'c_paiement', |
|
630
|
|
|
's.cond_reglement' => 'rowid@' . MAIN_DB_PREFIX . 'c_payment_term', |
|
631
|
|
|
's.mode_reglement_supplier' => 'id@' . MAIN_DB_PREFIX . 'c_paiement', |
|
632
|
|
|
's.cond_reglement_supplier' => 'rowid@' . MAIN_DB_PREFIX . 'c_payment_term', |
|
633
|
|
|
's.fk_incoterms' => 'rowid@' . MAIN_DB_PREFIX . 'c_incoterms', |
|
634
|
|
|
's.tva_assuj' => '^[0|1]', |
|
635
|
|
|
's.fk_multicurrency' => '^[0|1]', |
|
636
|
|
|
'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])?$', |
|
637
|
|
|
's.multicurrency_code' => 'code_iso@' . MAIN_DB_PREFIX . 'c_currencies' |
|
638
|
|
|
); |
|
639
|
|
|
|
|
640
|
|
|
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe |
|
641
|
|
|
's.nom' => "TPBigCompany", |
|
642
|
|
|
's.name_alias' => "Alias for TPBigCompany", |
|
643
|
|
|
's.parent' => "TPMotherCompany", |
|
644
|
|
|
's.status' => "0 (closed) / 1 (active)", |
|
645
|
|
|
's.code_client' => 'eg. CU01-0001 / empty / "auto"', |
|
646
|
|
|
's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"', |
|
647
|
|
|
's.code_compta' => "Code or empty to be auto-created", |
|
648
|
|
|
's.code_compta_fournisseur' => "Code or empty to be auto-created", |
|
649
|
|
|
's.address' => "61 Jump Street", |
|
650
|
|
|
's.zip' => "123456", |
|
651
|
|
|
's.town' => "Bigtown", |
|
652
|
|
|
's.fk_departement' => 'matches field "code_departement" in table "' . MAIN_DB_PREFIX . 'c_departements"', |
|
653
|
|
|
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "' . MAIN_DB_PREFIX . 'c_country"', |
|
654
|
|
|
's.phone' => "eg: +34123456789", |
|
655
|
|
|
's.fax' => "eg. +34987654321", |
|
656
|
|
|
's.url' => "e.g. https://www.mybigcompany.com", |
|
657
|
|
|
's.email' => "e.g. [email protected]", |
|
658
|
|
|
's.fk_effectif' => "1/2/3/5: represents one of the five ranges of employees", |
|
659
|
|
|
's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "' . MAIN_DB_PREFIX . 'c_typent"', |
|
660
|
|
|
's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "' . MAIN_DB_PREFIX . 'c_forme_juridique"', |
|
661
|
|
|
's.siret' => "", |
|
662
|
|
|
's.siren' => "", |
|
663
|
|
|
's.ape' => "", |
|
664
|
|
|
's.idprof4' => "", |
|
665
|
|
|
's.idprof5' => "", |
|
666
|
|
|
's.idprof6' => "", |
|
667
|
|
|
's.tva_intra' => 'VAT number e.g."FR0123456789"', |
|
668
|
|
|
's.capital' => "10000", |
|
669
|
|
|
's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "' . MAIN_DB_PREFIX . 'c_stcomm"', |
|
670
|
|
|
's.note_private' => "Example of a PRIVATE note.", |
|
671
|
|
|
's.note_public' => "Example of a PUBLIC note.", |
|
672
|
|
|
's.client' => '0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)', |
|
673
|
|
|
's.fournisseur' => '0 (not supplier) / 1 (supplier)', |
|
674
|
|
|
's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "' . MAIN_DB_PREFIX . 'c_prospectlevel"', |
|
675
|
|
|
's.mode_reglement' => '1/2/3...matches field "id" in table "' . MAIN_DB_PREFIX . 'c_paiement"', |
|
676
|
|
|
's.cond_reglement' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_payment_term"', |
|
677
|
|
|
's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "' . MAIN_DB_PREFIX . 'c_paiement"', |
|
678
|
|
|
's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_payment_term"', |
|
679
|
|
|
's.outstanding_limit' => "5000", |
|
680
|
|
|
's.fk_account' => "rowid or ref", |
|
681
|
|
|
's.fk_incoterms' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_incoterms"', |
|
682
|
|
|
's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)', |
|
683
|
|
|
's.barcode' => '123456789', |
|
684
|
|
|
's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/', |
|
685
|
|
|
's.canvas' => "empty / a custom canvas form layout url e.g. mycanvas@mymodule", |
|
686
|
|
|
's.datec' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'), |
|
687
|
|
|
's.fk_multicurrency' => '0 (use system default currency) / 1 (use local currency)', |
|
688
|
|
|
's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "' . MAIN_DB_PREFIX . 'c_currencies"', |
|
689
|
|
|
's.accountancy_code_sell' => '707', |
|
690
|
|
|
's.accountancy_code_buy' => '607', |
|
691
|
|
|
); |
|
692
|
|
|
$this->import_updatekeys_array[$r] = array( |
|
693
|
|
|
's.nom' => 'ThirdPartyName', |
|
694
|
|
|
's.zip' => 'Zip', |
|
695
|
|
|
's.email' => 'Email', |
|
696
|
|
|
's.code_client' => 'CustomerCode', |
|
697
|
|
|
's.code_fournisseur' => 'SupplierCode', |
|
698
|
|
|
's.code_compta' => 'CustomerAccountancyCode', |
|
699
|
|
|
's.code_compta_fournisseur' => 'SupplierAccountancyCode' |
|
700
|
|
|
); |
|
701
|
|
|
if (isModEnabled('socialnetworks')) { |
|
702
|
|
|
$sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "c_socialnetworks WHERE active = 1"; |
|
703
|
|
|
$resql = $this->db->query($sql); |
|
704
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
705
|
|
|
$fieldname = 's.socialnetworks_' . $obj->code; |
|
706
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
707
|
|
|
$this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; |
|
708
|
|
|
} |
|
709
|
|
|
} |
|
710
|
|
|
// Add profids as criteria to search duplicates |
|
711
|
|
|
$langs->load("companies"); |
|
712
|
|
|
$i = 1; |
|
713
|
|
|
while ($i <= 6) { |
|
714
|
|
|
if ($i == 1) { |
|
715
|
|
|
$this->import_updatekeys_array[$r]['s.siren'] = 'ProfId1' . (empty($mysoc->country_code) ? '' : $mysoc->country_code); |
|
716
|
|
|
} |
|
717
|
|
|
if ($i == 2) { |
|
718
|
|
|
$this->import_updatekeys_array[$r]['s.siret'] = 'ProfId2' . (empty($mysoc->country_code) ? '' : $mysoc->country_code); |
|
719
|
|
|
} |
|
720
|
|
|
if ($i == 3) { |
|
721
|
|
|
$this->import_updatekeys_array[$r]['s.ape'] = 'ProfId3' . (empty($mysoc->country_code) ? '' : $mysoc->country_code); |
|
722
|
|
|
} |
|
723
|
|
|
if ($i >= 4) { |
|
724
|
|
|
//var_dump($langs->trans('ProfId'.$i.(empty($mysoc->country_code) ? '' : $mysoc->country_code))); |
|
725
|
|
|
if ($langs->trans('ProfId' . $i . (empty($mysoc->country_code) ? '' : $mysoc->country_code)) != '-') { |
|
726
|
|
|
$this->import_updatekeys_array[$r]['s.idprof' . $i] = 'ProfId' . $i . (empty($mysoc->country_code) ? '' : $mysoc->country_code); |
|
727
|
|
|
} |
|
728
|
|
|
} |
|
729
|
|
|
$i++; |
|
730
|
|
|
} |
|
731
|
|
|
|
|
732
|
|
|
// Import list of contacts/addresses of thirparties and attributes |
|
733
|
|
|
$r++; |
|
734
|
|
|
$this->import_code[$r] = $this->rights_class . '_' . $r; |
|
735
|
|
|
$this->import_label[$r] = 'ImportDataset_company_2'; |
|
736
|
|
|
$this->import_icon[$r] = 'contact'; |
|
737
|
|
|
$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 |
|
738
|
|
|
$this->import_tables_array[$r] = array( |
|
739
|
|
|
's' => MAIN_DB_PREFIX . 'socpeople', |
|
740
|
|
|
'extra' => MAIN_DB_PREFIX . 'socpeople_extrafields' |
|
741
|
|
|
); // List of tables to insert into (insert done in same order) |
|
742
|
|
|
$this->import_fields_array[$r] = array(//field order as per structure of table llx_socpeople |
|
743
|
|
|
's.rowid' => 'Id', |
|
744
|
|
|
's.datec' => "DateCreation", |
|
745
|
|
|
's.fk_soc' => 'ThirdPartyName', |
|
746
|
|
|
's.civility' => 'UserTitle', |
|
747
|
|
|
's.lastname' => "Lastname*", |
|
748
|
|
|
's.firstname' => "Firstname", |
|
749
|
|
|
's.address' => "Address", |
|
750
|
|
|
's.zip' => "Zip", |
|
751
|
|
|
's.town' => "Town", |
|
752
|
|
|
's.fk_departement' => "StateCode", |
|
753
|
|
|
's.fk_pays' => "CountryCode", |
|
754
|
|
|
's.birthday' => "DateOfBirth", |
|
755
|
|
|
's.poste' => "PostOrFunction", |
|
756
|
|
|
's.phone' => "Phone", |
|
757
|
|
|
's.phone_perso' => "PhonePerso", |
|
758
|
|
|
's.phone_mobile' => "PhoneMobile", |
|
759
|
|
|
's.fax' => "Fax", |
|
760
|
|
|
's.email' => "Email", |
|
761
|
|
|
's.note_private' => "NotePrivate", |
|
762
|
|
|
's.note_public' => "NotePublic" |
|
763
|
|
|
); |
|
764
|
|
|
// Add social networks fields |
|
765
|
|
|
if (isModEnabled('socialnetworks')) { |
|
766
|
|
|
$sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "c_socialnetworks WHERE active = 1"; |
|
767
|
|
|
$resql = $this->db->query($sql); |
|
768
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
769
|
|
|
$fieldname = 's.socialnetworks_' . $obj->code; |
|
770
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
771
|
|
|
$this->import_fields_array[$r][$fieldname] = $fieldlabel; |
|
772
|
|
|
} |
|
773
|
|
|
} |
|
774
|
|
|
// Add extra fields |
|
775
|
|
|
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'socpeople' AND entity IN (0, " . $conf->entity . ")"; |
|
776
|
|
|
$resql = $this->db->query($sql); |
|
777
|
|
|
if ($resql) { // This can fail when class is used on an old database (during a migration for example) |
|
778
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
779
|
|
|
$fieldname = 'extra.' . $obj->name; |
|
780
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
781
|
|
|
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
|
782
|
|
|
} |
|
783
|
|
|
} |
|
784
|
|
|
// End add extra fields |
|
785
|
|
|
$this->import_fieldshidden_array[$r] = array( |
|
786
|
|
|
's.fk_user_creat' => 'user->id', |
|
787
|
|
|
'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'socpeople' |
|
788
|
|
|
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
789
|
|
|
$this->import_convertvalue_array[$r] = array( |
|
790
|
|
|
's.fk_soc' => array( |
|
791
|
|
|
'rule' => 'fetchidfromref', |
|
792
|
|
|
'file' => '/societe/class/societe.class.php', |
|
793
|
|
|
'class' => 'Societe', |
|
794
|
|
|
'method' => 'fetch', |
|
795
|
|
|
'element' => 'ThirdParty' |
|
796
|
|
|
), |
|
797
|
|
|
's.fk_departement' => array( |
|
798
|
|
|
'rule' => 'fetchidfromcodeid', |
|
799
|
|
|
'classfile' => '/core/class/cstate.class.php', |
|
800
|
|
|
'class' => 'Cstate', |
|
801
|
|
|
'method' => 'fetch', |
|
802
|
|
|
'dict' => 'DictionaryCanton' |
|
803
|
|
|
), |
|
804
|
|
|
's.fk_pays' => array( |
|
805
|
|
|
'rule' => 'fetchidfromcodeid', |
|
806
|
|
|
'classfile' => '/core/class/ccountry.class.php', |
|
807
|
|
|
'class' => 'Ccountry', |
|
808
|
|
|
'method' => 'fetch', |
|
809
|
|
|
'dict' => 'DictionaryCountry' |
|
810
|
|
|
), |
|
811
|
|
|
); |
|
812
|
|
|
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
813
|
|
|
$this->import_regex_array[$r] = array( |
|
814
|
|
|
's.birthday' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', |
|
815
|
|
|
'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])?$' |
|
816
|
|
|
); |
|
817
|
|
|
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_socpeople |
|
818
|
|
|
's.rowid' => '1', |
|
819
|
|
|
's.datec' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'), |
|
820
|
|
|
's.fk_soc' => 'Third Party name eg. TPBigCompany', |
|
821
|
|
|
's.civility' => 'Title of civility eg: MR...matches field "code" in table "' . MAIN_DB_PREFIX . 'c_civility"', |
|
822
|
|
|
's.lastname' => "lastname or label", |
|
823
|
|
|
's.firstname' => 'John', |
|
824
|
|
|
's.address' => '61 Jump street', |
|
825
|
|
|
's.zip' => '75000', |
|
826
|
|
|
's.town' => 'Bigtown', |
|
827
|
|
|
's.fk_departement' => 'matches field "code_departement" in table "' . MAIN_DB_PREFIX . 'c_departements"', |
|
828
|
|
|
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "' . MAIN_DB_PREFIX . 'c_country"', |
|
829
|
|
|
's.birthday' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'), |
|
830
|
|
|
's.poste' => "Director", |
|
831
|
|
|
's.phone' => "5551122", |
|
832
|
|
|
's.phone_perso' => "5551133", |
|
833
|
|
|
's.phone_mobile' => "5551144", |
|
834
|
|
|
's.fax' => "5551155", |
|
835
|
|
|
's.email' => "[email protected]", |
|
836
|
|
|
's.note_private' => "My private note", |
|
837
|
|
|
's.note_public' => "My public note" |
|
838
|
|
|
); |
|
839
|
|
|
$this->import_updatekeys_array[$r] = array( |
|
840
|
|
|
's.rowid' => 'Id', |
|
841
|
|
|
's.lastname' => "Lastname", |
|
842
|
|
|
); |
|
843
|
|
|
if (isModEnabled('socialnetworks')) { |
|
844
|
|
|
$sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "c_socialnetworks WHERE active = 1"; |
|
845
|
|
|
$resql = $this->db->query($sql); |
|
846
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
847
|
|
|
$fieldname = 's.socialnetworks_' . $obj->code; |
|
848
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
849
|
|
|
$this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; |
|
850
|
|
|
} |
|
851
|
|
|
} |
|
852
|
|
|
|
|
853
|
|
|
// Import Bank Accounts |
|
854
|
|
|
$r++; |
|
855
|
|
|
$this->import_code[$r] = $this->rights_class . '_' . $r; |
|
856
|
|
|
$this->import_label[$r] = "ImportDataset_company_3"; // Translation key |
|
857
|
|
|
$this->import_icon[$r] = 'company'; |
|
858
|
|
|
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon |
|
859
|
|
|
$this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX . 'societe_rib'); |
|
860
|
|
|
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe_rib |
|
861
|
|
|
'sr.label' => "Label*", |
|
862
|
|
|
'sr.fk_soc' => "ThirdPartyName*", |
|
863
|
|
|
'sr.datec' => "DateCreation*", |
|
864
|
|
|
'sr.bank' => "Bank", |
|
865
|
|
|
'sr.code_banque' => "BankCode", |
|
866
|
|
|
'sr.code_guichet' => "DeskCode", |
|
867
|
|
|
'sr.number' => "BankAccountNumber", |
|
868
|
|
|
'sr.cle_rib' => "BankAccountNumberKey", |
|
869
|
|
|
'sr.bic' => "BIC", |
|
870
|
|
|
'sr.iban_prefix' => "IBAN", |
|
871
|
|
|
'sr.domiciliation' => "BankAccountDomiciliation", |
|
872
|
|
|
'sr.proprio' => "BankAccountOwner", |
|
873
|
|
|
'sr.owner_address' => "BankAccountOwnerAddress", |
|
874
|
|
|
'sr.default_rib' => 'Default', |
|
875
|
|
|
'sr.rum' => 'RUM', |
|
876
|
|
|
'sr.frstrecur' => "WithdrawMode", |
|
877
|
|
|
'sr.type' => "Type ban is default", |
|
878
|
|
|
); |
|
879
|
|
|
|
|
880
|
|
|
$this->import_convertvalue_array[$r] = array( |
|
881
|
|
|
'sr.fk_soc' => array( |
|
882
|
|
|
'rule' => 'fetchidfromref', |
|
883
|
|
|
'classfile' => '/societe/class/societe.class.php', |
|
884
|
|
|
'class' => 'Societe', |
|
885
|
|
|
'method' => 'fetch', |
|
886
|
|
|
'element' => 'ThirdParty' |
|
887
|
|
|
) |
|
888
|
|
|
); |
|
889
|
|
|
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe_rib |
|
890
|
|
|
'sr.label' => 'eg. "account1"', |
|
891
|
|
|
'sr.fk_soc' => 'eg. "TPBigCompany"', |
|
892
|
|
|
'sr.datec' => 'date used for creating direct debit UMR formatted as ' . dol_print_date( |
|
893
|
|
|
dol_now(), |
|
894
|
|
|
'%Y-%m-%d' |
|
895
|
|
|
), |
|
896
|
|
|
'sr.bank' => 'bank name eg: "ING-Direct"', |
|
897
|
|
|
'sr.code_banque' => 'account sort code (GB)/Routing number (US) eg. "8456"', |
|
898
|
|
|
'sr.code_guichet' => "bank code for office/branch", |
|
899
|
|
|
'sr.number' => 'account number eg. "3333333333"', |
|
900
|
|
|
'sr.cle_rib' => 'account checksum/control digits (if used) eg. "22"', |
|
901
|
|
|
'sr.bic' => 'bank identifier eg. "USHINGMMXXX"', |
|
902
|
|
|
'sr.iban_prefix' => 'complete account IBAN eg. "GB78CPBK08925068637123"', |
|
903
|
|
|
'sr.domiciliation' => 'bank branch address eg. "PARIS"', |
|
904
|
|
|
'sr.proprio' => 'name on the bank account', |
|
905
|
|
|
'sr.owner_address' => 'address of account holder', |
|
906
|
|
|
'sr.default_rib' => '1 (default account) / 0 (not default)', |
|
907
|
|
|
'sr.rum' => 'RUM code', |
|
908
|
|
|
'sr.frstrecur' => 'FRST', |
|
909
|
|
|
'sr.type' => 'ban', |
|
910
|
|
|
); |
|
911
|
|
|
|
|
912
|
|
|
// Import Company Sales representatives |
|
913
|
|
|
$r++; |
|
914
|
|
|
$this->import_code[$r] = $this->rights_class . '_' . $r; |
|
915
|
|
|
$this->import_label[$r] = "ImportDataset_company_4"; // Translation key |
|
916
|
|
|
$this->import_icon[$r] = 'company'; |
|
917
|
|
|
$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 |
|
918
|
|
|
$this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX . 'societe_commerciaux'); |
|
919
|
|
|
$this->import_fields_array[$r] = array('sr.fk_soc' => "ThirdPartyName*", 'sr.fk_user' => "User*"); |
|
920
|
|
|
|
|
921
|
|
|
$this->import_convertvalue_array[$r] = array( |
|
922
|
|
|
'sr.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), |
|
923
|
|
|
'sr.fk_user' => array('rule' => 'fetchidfromref', 'classfile' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'User') |
|
924
|
|
|
); |
|
925
|
|
|
$this->import_examplevalues_array[$r] = array('sr.fk_soc' => "MyBigCompany", 'sr.fk_user' => "login"); |
|
926
|
|
|
} |
|
927
|
|
|
|
|
928
|
|
|
|
|
929
|
|
|
/** |
|
930
|
|
|
* Function called when module is enabled. |
|
931
|
|
|
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
932
|
|
|
* It also creates data directories |
|
933
|
|
|
* |
|
934
|
|
|
* @param string $options Options when enabling module ('', 'noboxes') |
|
935
|
|
|
* @return int 1 if OK, 0 if KO |
|
936
|
|
|
*/ |
|
937
|
|
|
public function init($options = '') |
|
938
|
|
|
{ |
|
939
|
|
|
global $conf, $langs; |
|
940
|
|
|
|
|
941
|
|
|
// We disable this to prevent pb of modules not correctly disabled |
|
942
|
|
|
//$this->remove($options); |
|
943
|
|
|
|
|
944
|
|
|
//ODT template |
|
945
|
|
|
$src = DOL_DOCUMENT_ROOT . '/install/doctemplates/thirdparties/template_thirdparty.odt'; |
|
946
|
|
|
$dirodt = DOL_DATA_ROOT . '/doctemplates/thirdparties'; |
|
947
|
|
|
$dest = $dirodt . '/template_thirdparty.odt'; |
|
948
|
|
|
|
|
949
|
|
|
if (file_exists($src) && !file_exists($dest)) { |
|
950
|
|
|
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/files.lib.php'; |
|
951
|
|
|
dol_mkdir($dirodt); |
|
952
|
|
|
$result = dol_copy($src, $dest, 0, 0); |
|
953
|
|
|
if ($result < 0) { |
|
954
|
|
|
$langs->load("errors"); |
|
955
|
|
|
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); |
|
956
|
|
|
return 0; |
|
957
|
|
|
} |
|
958
|
|
|
} |
|
959
|
|
|
|
|
960
|
|
|
$sql = array(); |
|
961
|
|
|
|
|
962
|
|
|
return $this->_init($sql, $options); |
|
963
|
|
|
} |
|
964
|
|
|
} |
|
965
|
|
|
|