47 global $conf, $user, $mysoc, $langs;
52 $this->family =
"crm";
53 $this->module_position =
'09';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
56 $this->
description =
"Gestion des sociétés et contacts";
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->config_page_url = array(
"societe.php@societe");
64 $this->picto =
'company';
67 $this->dirs = array(
"/societe/temp");
70 $this->hidden =
false;
71 $this->depends = array();
72 $this->requiredby = array(
"modExpedition",
"modFacture",
"modFournisseur",
"modFicheinter",
"modPropale",
"modContrat",
"modCommande");
73 $this->conflictwith = array();
74 $this->phpmin = array(7, 0);
75 $this->langfiles = array(
"companies",
'bills',
"compta",
"admin",
"banks");
78 $this->
const = array();
81 $this->
const[$r][0] =
"SOCIETE_CODECLIENT_ADDON";
82 $this->
const[$r][1] =
"chaine";
83 $this->
const[$r][2] =
"mod_codeclient_monkey";
84 $this->
const[$r][3] =
'Module to control third parties codes';
85 $this->
const[$r][4] = 0;
88 $this->
const[$r][0] =
"SOCIETE_CODECOMPTA_ADDON";
89 $this->
const[$r][1] =
"chaine";
90 $this->
const[$r][2] =
"mod_codecompta_panicum";
91 $this->
const[$r][3] =
'Module to control third parties codes';
92 $this->
const[$r][4] = 0;
95 $this->
const[$r][0] =
"SOCIETE_FISCAL_MONTH_START";
96 $this->
const[$r][1] =
"chaine";
97 $this->
const[$r][2] =
"0";
98 $this->
const[$r][3] =
"Enter the month number of the first month of the fiscal year, e. g. 9 for September";
99 $this->
const[$r][4] = 0;
102 $this->
const[$r][0] =
"COMPANY_ADDON_PDF_ODT_PATH";
103 $this->
const[$r][1] =
"chaine";
104 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/thirdparties";
105 $this->
const[$r][3] =
"";
106 $this->
const[$r][4] = 0;
118 $this->
const[$r][0] =
"SOCIETE_ADD_REF_IN_LIST";
119 $this->
const[$r][1] =
"yesno";
120 $this->
const[$r][2] =
"0";
121 $this->
const[$r][3] =
"Display customer ref into select list";
122 $this->
const[$r][4] = 0;
126 $this->boxes = array(
127 0 => array(
'file' =>
'box_clients.php',
'enabledbydefaulton' =>
'Home'),
128 1 => array(
'file' =>
'box_prospect.php',
'enabledbydefaulton' =>
'Home'),
129 2 => array(
'file' =>
'box_contacts.php',
'enabledbydefaulton' =>
'Home'),
130 3 => array(
'file' =>
'box_activity.php',
'enabledbydefaulton' =>
'Home',
'note' =>
'(WarningUsingThisBoxSlowDown)'),
131 4 => array(
'file' =>
'box_goodcustomers.php',
'enabledbydefaulton' =>
'Home',
'note' =>
'(WarningUsingThisBoxSlowDown)'),
135 $this->rights = array();
136 $this->rights_class =
'societe';
140 $this->rights[$r][0] = 121;
141 $this->rights[$r][1] =
'Read third parties';
142 $this->rights[$r][2] =
'r';
143 $this->rights[$r][3] = 0;
144 $this->rights[$r][4] =
'lire';
164 $this->rights[$r][0] = 122;
165 $this->rights[$r][1] =
'Create and update third parties';
166 $this->rights[$r][2] =
'w';
167 $this->rights[$r][3] = 0;
168 $this->rights[$r][4] =
'creer';
188 $this->rights[$r][0] = 125;
189 $this->rights[$r][1] =
'Delete third parties';
190 $this->rights[$r][2] =
'd';
191 $this->rights[$r][3] = 0;
192 $this->rights[$r][4] =
'supprimer';
195 $this->rights[$r][0] = 126;
196 $this->rights[$r][1] =
'Export third parties';
197 $this->rights[$r][2] =
'r';
198 $this->rights[$r][3] = 0;
199 $this->rights[$r][4] =
'export';
202 $this->rights[$r][0] = 130;
203 $this->rights[$r][1] =
'Modify thirdparty information payment';
204 $this->rights[$r][3] = 0;
205 $this->rights[$r][4] =
'thirdparty_paymentinformation_advance';
206 $this->rights[$r][5] =
'write';
210 $this->rights[$r][0] = 262;
211 $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).';
212 $this->rights[$r][2] =
'r';
213 $this->rights[$r][3] = 0;
214 $this->rights[$r][4] =
'client';
215 $this->rights[$r][5] =
'voir';
228 $this->rights[$r][0] = 281;
229 $this->rights[$r][1] =
'Read contacts';
230 $this->rights[$r][2] =
'r';
231 $this->rights[$r][3] = 0;
232 $this->rights[$r][4] =
'contact';
233 $this->rights[$r][5] =
'lire';
236 $this->rights[$r][0] = 282;
237 $this->rights[$r][1] =
'Create and update contact';
238 $this->rights[$r][2] =
'w';
239 $this->rights[$r][3] = 0;
240 $this->rights[$r][4] =
'contact';
241 $this->rights[$r][5] =
'creer';
244 $this->rights[$r][0] = 283;
245 $this->rights[$r][1] =
'Delete contacts';
246 $this->rights[$r][2] =
'd';
247 $this->rights[$r][3] = 0;
248 $this->rights[$r][4] =
'contact';
249 $this->rights[$r][5] =
'supprimer';
252 $this->rights[$r][0] = 286;
253 $this->rights[$r][1] =
'Export contacts';
254 $this->rights[$r][2] =
'd';
255 $this->rights[$r][3] = 0;
256 $this->rights[$r][4] =
'contact';
257 $this->rights[$r][5] =
'export';
271 $this->export_code[$r] = $this->rights_class.
'_'.$r;
272 $this->export_label[$r] =
'ExportDataset_company_1';
273 $this->export_icon[$r] =
'company';
274 $this->export_permission[$r] = array(array(
"societe",
"export"));
275 $this->export_fields_array[$r] = array(
276 's.rowid' =>
"Id",
's.nom' =>
"Name",
's.name_alias' =>
"AliasNameShort",
'ps.nom' =>
"ParentCompany",
277 's.status' =>
"Status",
's.client' =>
"Customer",
's.fournisseur' =>
"Supplier",
's.datec' =>
"DateCreation",
's.tms' =>
"DateLastModification",
278 's.code_client' =>
"CustomerCode",
's.code_fournisseur' =>
"SupplierCode",
's.code_compta' =>
"AccountancyCode",
's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
279 '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",
280 '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",
281 's.idprof5' =>
"ProfId5",
's.idprof6' =>
"ProfId6",
's.tva_intra' =>
"VATIntraShort",
's.capital' =>
"Capital",
's.note_private' =>
"NotePrivate",
's.note_public' =>
"NotePublic",
282 't.code' =>
"ThirdPartyType",
'ce.code' =>
"DictionaryStaff",
"cfj.libelle" =>
"JuridicalStatus",
's.fk_prospectlevel' =>
'ProspectLevel',
283 'st.code' =>
'ProspectStatus',
'payterm.libelle' =>
'PaymentConditions',
'paymode.libelle' =>
'PaymentMode',
284 's.outstanding_limit' =>
'OutstandingBill',
'pbacc.ref' =>
'PaymentBankAccount',
'incoterm.code' =>
'IncotermLabel'
287 $this->export_fields_array[$r][
's.prefix'] =
'Prefix';
290 $this->export_fields_array[$r][
's.price_level'] =
'PriceLevel';
293 $this->export_fields_array[$r] += array(
's.accountancy_code_sell' =>
'ProductAccountancySellCode',
's.accountancy_code_buy' =>
'ProductAccountancyBuyCode');
297 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
298 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
299 $this->export_fields_array[$r] += array(
's.entity' =>
'Entity');
302 $keyforselect =
'societe';
303 $keyforelement =
'company';
304 $keyforaliasextra =
'extra';
305 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
306 $this->export_fields_array[$r] += array(
'u.login' =>
'SaleRepresentativeLogin',
'u.firstname' =>
'SaleRepresentativeFirstname',
'u.lastname' =>
'SaleRepresentativeLastname');
308 $this->export_TypeFields_array[$r] = array(
309 's.rowid' =>
"Numeric",
's.nom' =>
"Text",
's.name_alias' =>
"Text",
'ps.nom' =>
"Text",
310 's.status' =>
"Numeric",
's.client' =>
"Numeric",
's.fournisseur' =>
"Boolean",
's.datec' =>
"Date",
's.tms' =>
"Date",
311 's.code_client' =>
"Text",
's.code_fournisseur' =>
"Text",
's.code_compta' =>
"Text",
's.code_compta_fournisseur' =>
"Text",
312 's.address' =>
"Text",
's.zip' =>
"Text",
's.town' =>
"Text",
313 'd.nom' =>
'Text',
'r.nom' =>
'Text',
'c.label' =>
'List:c_country:label:label',
'c.code' =>
'Text',
314 's.phone' =>
"Text",
's.fax' =>
"Text",
315 's.url' =>
"Text",
's.email' =>
"Text",
's.default_lang' =>
"Text",
's.canvas' =>
"Text",
316 's.siret' =>
"Text",
's.siren' =>
"Text",
's.ape' =>
"Text",
's.idprof4' =>
"Text",
's.idprof5' =>
"Text",
's.idprof6' =>
"Text",
317 's.tva_intra' =>
"Text",
's.capital' =>
"Numeric",
318 's.note_private' =>
"Text",
's.note_public' =>
"Text",
319 't.code' =>
"List:c_typent:libelle:code",
320 'ce.code' =>
"List:c_effectif:libelle:code",
321 "cfj.libelle" =>
"Text",
322 's.fk_prospectlevel' =>
'List:c_prospectlevel:label:code',
323 'st.code' =>
'List:c_stcomm:libelle:code',
324 'payterm.libelle' =>
'Text',
'paymode.libelle' =>
'Text',
325 's.outstanding_limit' =>
'Numeric',
'pbacc.ref' =>
'Text',
'incoterm.code' =>
'Text',
326 'u.login' =>
'Text',
'u.firstname' =>
'Text',
'u.lastname' =>
'Text',
327 's.entity' =>
'List:entity:label:rowid',
's.price_level' =>
'Numeric',
328 's.accountancy_code_sell' =>
'Text',
's.accountancy_code_buy' =>
'Text'
331 $this->export_entities_array[$r] = array(
333 'u.firstname' =>
'user',
334 'u.lastname' =>
'user');
335 $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)');
336 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
337 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
338 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extra ON s.rowid = extra.fk_object';
339 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON s.parent = ps.rowid';
340 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
341 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid';
342 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_effectif as ce ON s.fk_effectif = ce.id';
343 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
344 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON s.fk_departement = d.rowid';
345 $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';
346 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcomm as st ON s.fk_stcomm = st.id';
347 $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';
348 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
349 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as paymode ON s.mode_reglement = paymode.id';
350 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as pbacc ON s.fk_account = pbacc.rowid';
351 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';
352 $this->export_sql_end[$r] .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
353 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
354 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
356 $subordinatesids = $user->getAllChildIds();
357 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
359 $this->export_sql_end[$r] .=
')';
364 $this->export_code[$r] = $this->rights_class.
'_'.$r;
365 $this->export_label[$r] =
'ExportDataset_company_2';
366 $this->export_icon[$r] =
'contact';
367 $this->export_permission[$r] = array(array(
"societe",
"contact",
"export"));
368 $this->export_fields_array[$r] = array(
369 'c.rowid' =>
"IdContact",
'c.civility' =>
"CivilityCode",
'c.lastname' =>
'Lastname',
'c.firstname' =>
'Firstname',
'c.poste' =>
'PostOrFunction',
370 'c.datec' =>
"DateCreation",
'c.tms' =>
"DateLastModification",
'c.priv' =>
"ContactPrivate",
'c.address' =>
"Address",
'c.zip' =>
"Zip",
'c.town' =>
"Town",
371 '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",
372 'c.note_private' =>
'NotePrivate',
'c.note_public' =>
"NotePublic",
373 'c.statut' =>
"Status",
374 's.rowid' =>
"IdCompany",
's.nom' =>
"CompanyName",
's.status' =>
"Status",
's.code_client' =>
"CustomerCode",
's.code_fournisseur' =>
"SupplierCode",
375 's.code_compta' =>
"AccountancyCode",
's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
376 's.client' =>
'Customer',
's.fournisseur' =>
'Supplier',
377 's.address' =>
'Address',
's.zip' =>
"Zip",
's.town' =>
"Town",
's.phone' =>
'Phone',
's.email' =>
"Email",
378 's.note_private' =>
'NotePrivate',
's.note_public' =>
"NotePublic",
379 't.code' =>
"ThirdPartyType"
383 if (isModEnabled(
'multicompany')) {
384 $nbofallowedentities = count(explode(
',',
getEntity(
'contact')));
385 if ($nbofallowedentities > 1) {
386 $this->export_fields_array[$r][
'c.entity'] =
'Entity';
389 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
390 if ($nbofallowedentities > 1) {
391 $this->export_fields_array[$r][
's.entity'] =
'Entity';
395 $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)');
396 $this->export_TypeFields_array[$r] = array(
397 'c.civility' =>
"List:c_civility:label:code",
'c.lastname' =>
'Text',
'c.firstname' =>
'Text',
'c.poste' =>
'Text',
'c.datec' =>
"Date",
'c.priv' =>
"Boolean",
398 '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",
399 'c.fax' =>
"Text",
'c.email' =>
"Text",
400 'c.statut' =>
"Status",
401 's.rowid' =>
"Numeric",
's.nom' =>
"Text",
's.status' =>
"Status",
's.code_client' =>
"Text",
's.code_fournisseur' =>
"Text",
402 's.code_compta' =>
"Text",
's.code_compta_fournisseur' =>
"Text",
403 's.client' =>
"Numeric",
's.fournisseur' =>
"Numeric",
404 's.address' =>
"Text",
's.zip' =>
"Text",
's.town' =>
"Text",
's.phone' =>
"Text",
's.email' =>
"Text",
405 't.code' =>
"List:c_stcomm:libelle:code",
406 'c.entity' =>
'List:entity:label:rowid',
407 's.entity' =>
'List:entity:label:rowid',
409 $this->export_entities_array[$r] = array(
410 's.rowid' =>
"company",
's.nom' =>
"company",
's.status' =>
'company',
's.code_client' =>
"company",
's.code_fournisseur' =>
"company",
411 's.code_compta' =>
"company",
's.code_compta_fournisseur' =>
"company",
412 's.client' =>
"company",
's.fournisseur' =>
"company",
413 's.address' =>
"company",
's.zip' =>
"company",
's.town' =>
"company",
's.phone' =>
"company",
's.email' =>
"company",
414 's.note_private' =>
'company',
's.note_public' =>
"company",
415 't.code' =>
"company",
416 's.entity' =>
'company',
418 if (!isModEnabled(
"supplier_order") && !isModEnabled(
"supplier_invoice")) {
419 unset($this->export_fields_array[$r][
's.code_fournisseur']);
420 unset($this->export_entities_array[$r][
's.code_fournisseur']);
422 $keyforselect =
'socpeople';
423 $keyforelement =
'contact';
424 $keyforaliasextra =
'extra';
425 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
426 $keyforselect =
'societe';
427 $keyforelement =
'company';
428 $keyforaliasextra =
'extrasoc';
429 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
430 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
431 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'socpeople as c';
432 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON c.fk_soc = s.rowid';
433 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
434 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
435 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
437 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON c.fk_departement = d.rowid';
438 $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';
439 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON c.fk_pays = co.rowid';
440 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
441 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
442 $this->export_sql_end[$r] .=
' WHERE c.entity IN ('.getEntity(
'contact').
')';
443 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
444 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
446 $subordinatesids = $user->getAllChildIds();
447 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
449 $this->export_sql_end[$r] .=
')';
460 $this->import_code[$r] = $this->rights_class.
'_'.$r;
461 $this->import_label[$r] =
'ImportDataset_company_1';
462 $this->import_icon[$r] =
'company';
463 $this->import_entities_array[$r] = array();
464 $this->import_tables_array[$r] = array(
465 's' => MAIN_DB_PREFIX.
'societe',
466 'extra' => MAIN_DB_PREFIX.
'societe_extrafields'
468 $this->import_fields_array[$r] = array(
469 's.nom' =>
"ThirdPartyName*",
470 's.name_alias' =>
"AliasNameShort",
471 's.parent' =>
"ParentCompany",
472 's.status' =>
"Status*",
473 's.code_client' =>
"CustomerCode",
474 's.code_fournisseur' =>
"SupplierCode",
475 's.code_compta' =>
"CustomerAccountancyCode",
476 's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
477 's.address' =>
"Address",
480 's.fk_departement' =>
"StateCode",
481 's.fk_pays' =>
"CountryCode",
482 's.phone' =>
"Phone",
485 's.email' =>
"Email",
486 's.fk_effectif' =>
"Staff",
487 's.fk_typent' =>
"ThirdPartyType",
488 "s.fk_forme_juridique" =>
"JuridicalStatus",
489 's.siren' =>
"ProfId1",
490 's.siret' =>
"ProfId2",
491 's.ape' =>
"ProfId3",
492 's.idprof4' =>
"ProfId4",
493 's.idprof5' =>
"ProfId5",
494 's.idprof6' =>
"ProfId6",
495 's.tva_intra' =>
"VATIntraShort",
496 's.capital' =>
"Capital",
497 's.fk_stcomm' =>
'ProspectStatus',
498 's.note_private' =>
"NotePrivate",
499 's.note_public' =>
"NotePublic",
500 's.client' =>
"Customer*",
501 's.fournisseur' =>
"Supplier*",
502 's.fk_prospectlevel' =>
'ProspectLevel',
503 's.mode_reglement' =>
'PaymentTypeCustomer',
504 's.cond_reglement' =>
"PaymentTermsCustomer",
505 's.mode_reglement_supplier' =>
'PaymentTypeSupplier',
506 's.cond_reglement_supplier' =>
"PaymentTermsSupplier",
507 's.outstanding_limit' =>
'OutstandingBill',
508 's.fk_account' =>
'PaymentBankAccount',
509 's.fk_incoterms' =>
'IncotermLabel',
510 's.tva_assuj' =>
'VATIsUsed',
511 's.barcode' =>
'BarCode',
512 's.default_lang' =>
'DefaultLanguage',
513 's.canvas' =>
"Canvas",
514 's.datec' =>
"DateCreation",
515 's.fk_multicurrency' =>
'MulticurrencyUsed',
516 's.multicurrency_code' =>
'MulticurrencyCurrency'
519 $this->import_fields_array[$r][
's.price_level'] =
'PriceLevel';
522 $this->import_fields_array[$r] += array(
's.accountancy_code_sell' =>
'ProductAccountancySellCode',
's.accountancy_code_buy' =>
'ProductAccountancyBuyCode');
525 if (isModEnabled(
'socialnetworks')) {
526 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
527 $resql = $this->db->query($sql);
529 while ($obj = $this->db->fetch_object($resql)) {
530 $fieldname =
's.socialnetworks_'.$obj->code;
531 $fieldlabel = ucfirst($obj->label);
532 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
537 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.
")";
538 $resql = $this->db->query($sql);
540 while ($obj = $this->db->fetch_object($resql)) {
541 $fieldname =
'extra.'.$obj->name;
542 $fieldlabel = ucfirst($obj->label);
543 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
547 $this->import_fieldshidden_array[$r] = array(
548 's.fk_user_creat' =>
'user->id',
549 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'societe'
551 $this->import_convertvalue_array[$r] = array(
552 's.code_client' => array(
'rule' =>
'getcustomercodeifauto'),
553 's.code_fournisseur' => array(
'rule' =>
'getsuppliercodeifauto'),
554 's.code_compta' => array(
'rule' =>
'getcustomeraccountancycodeifauto'),
555 's.code_compta_fournisseur' => array(
'rule' =>
'getsupplieraccountancycodeifauto'),
556 's.fk_departement' => array(
557 'rule' =>
'fetchidfromcodeid',
558 'classfile' =>
'/core/class/cstate.class.php',
561 'dict' =>
'DictionaryStateCode'
563 's.fk_pays' => array(
564 'rule' =>
'fetchidfromcodeid',
565 'classfile' =>
'/core/class/ccountry.class.php',
566 'class' =>
'Ccountry',
568 'dict' =>
'DictionaryCountry'
570 's.fk_typent' => array(
571 'rule' =>
'fetchidfromcodeorlabel',
572 'classfile' =>
'/core/class/ctypent.class.php',
573 'class' =>
'Ctypent',
575 'dict' =>
'DictionaryCompanyType'
577 's.capital' => array(
'rule' =>
'numeric'),
579 'rule' =>
'fetchidfromref',
580 'file' =>
'/societe/class/societe.class.php',
581 'class' =>
'Societe',
583 'element' =>
'ThirdParty'
585 's.outstanding_limit' => array(
'rule' =>
'numeric'),
586 's.fk_account' => array(
587 'rule' =>
'fetchidfromcodeid',
588 'classfile' =>
'/compta/bank/class/account.class.php',
589 'class' =>
'Account',
591 'element' =>
'BankAccount'
593 's.fk_stcomm' => array(
594 'rule' =>
'fetchidfromcodeid',
595 'classfile' =>
'/core/class/cgenericdic.class.php',
596 'class' =>
'CGenericDic',
598 'dict' =>
'DictionaryProspectStatus',
599 'element' =>
'c_stcomm',
600 'table_element' =>
'c_stcomm'
622 $this->import_regex_array[$r] = array(
623 's.status' =>
'^[0|1]',
624 's.fk_typent' =>
'id@'.MAIN_DB_PREFIX.
'c_typent',
625 's.client' =>
'^[0|1|2|3]',
626 's.fournisseur' =>
'^[0|1]',
627 's.mode_reglement' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
628 's.cond_reglement' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
629 's.mode_reglement_supplier' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
630 's.cond_reglement_supplier' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
631 's.fk_incoterms' =>
'rowid@'.MAIN_DB_PREFIX.
'c_incoterms',
632 's.tva_assuj' =>
'^[0|1]',
633 's.fk_multicurrency' =>
'^[0|1]',
634 '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])?$',
635 's.multicurrency_code' =>
'code_iso@'.MAIN_DB_PREFIX.
'c_currencies'
638 $this->import_examplevalues_array[$r] = array(
639 's.nom' =>
"TPBigCompany",
640 's.name_alias' =>
"Alias for TPBigCompany",
641 's.parent' =>
"TPMotherCompany",
642 's.status' =>
"0 (closed) / 1 (active)",
643 's.code_client' =>
'eg. CU01-0001 / empty / "auto"',
644 's.code_fournisseur' =>
'eg. SU01-0001 / empty / "auto"',
645 's.code_compta' =>
"Code or empty to be auto-created",
646 's.code_compta_fournisseur' =>
"Code or empty to be auto-created",
647 's.address' =>
"61 Jump Street",
649 's.town' =>
"Bigtown",
650 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
651 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
652 's.phone' =>
"eg: +34123456789",
653 's.fax' =>
"eg. +34987654321",
654 's.url' =>
"e.g. https://www.mybigcompany.com",
655 's.email' =>
"e.g. test@mybigcompany.com",
656 's.fk_effectif' =>
"1/2/3/5: represents one of the five ranges of employees",
657 's.fk_typent' =>
'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.
'c_typent"',
658 's.fk_forme_juridique' =>
'1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_forme_juridique"',
665 's.tva_intra' =>
'VAT number e.g."FR0123456789"',
666 's.capital' =>
"10000",
667 's.fk_stcomm' =>
'-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.
'c_stcomm"',
668 's.note_private' =>
"Example of a PRIVATE note.",
669 's.note_public' =>
"Example of a PUBLIC note.",
670 's.client' =>
'0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
671 's.fournisseur' =>
'0 (not supplier) / 1 (supplier)',
672 's.fk_prospectlevel' =>
'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.
'c_prospectlevel"',
673 's.mode_reglement' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
674 's.cond_reglement' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
675 's.mode_reglement_supplier' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
676 's.cond_reglement_supplier' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
677 's.outstanding_limit' =>
"5000",
678 's.fk_account' =>
"rowid or ref",
679 's.fk_incoterms' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_incoterms"',
680 's.tva_assuj' =>
'0 (VAT not used) / 1 (VAT used)',
681 's.barcode' =>
'123456789',
682 's.default_lang' =>
'en_US / es_ES etc...matches a language directory in htdocs/langs/',
683 's.canvas' =>
"empty / a custom canvas form layout url e.g. mycanvas@mymodule",
684 's.datec' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
685 's.fk_multicurrency' =>
'0 (use system default currency) / 1 (use local currency)',
686 's.multicurrency_code' =>
'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.
'c_currencies"',
687 's.accountancy_code_sell' =>
'707',
688 's.accountancy_code_buy' =>
'607',
690 $this->import_updatekeys_array[$r] = array(
691 's.nom' =>
'ThirdPartyName',
693 's.email' =>
'Email',
694 's.code_client' =>
'CustomerCode',
695 's.code_fournisseur' =>
'SupplierCode',
696 's.code_compta' =>
'CustomerAccountancyCode',
697 's.code_compta_fournisseur' =>
'SupplierAccountancyCode'
699 if (isModEnabled(
'socialnetworks')) {
700 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
701 $resql = $this->db->query($sql);
703 while ($obj = $this->db->fetch_object($resql)) {
704 $fieldname =
's.socialnetworks_'.$obj->code;
705 $fieldlabel = ucfirst($obj->label);
706 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
711 $langs->load(
"companies");
715 $this->import_updatekeys_array[$r][
's.siren'] =
'ProfId1'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
718 $this->import_updatekeys_array[$r][
's.siret'] =
'ProfId2'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
721 $this->import_updatekeys_array[$r][
's.ape'] =
'ProfId3'.(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);
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');
738 $this->import_tables_array[$r] = array(
739 's' => MAIN_DB_PREFIX.
'socpeople',
740 'extra' => MAIN_DB_PREFIX.
'socpeople_extrafields'
742 $this->import_fields_array[$r] = array(
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",
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",
760 's.email' =>
"Email",
761 's.note_private' =>
"NotePrivate",
762 's.note_public' =>
"NotePublic"
765 if (isModEnabled(
'socialnetworks')) {
766 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
767 $resql = $this->db->query($sql);
769 while ($obj = $this->db->fetch_object($resql)) {
770 $fieldname =
's.socialnetworks_'.$obj->code;
771 $fieldlabel = ucfirst($obj->label);
772 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
777 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.
")";
778 $resql = $this->db->query($sql);
780 while ($obj = $this->db->fetch_object($resql)) {
781 $fieldname =
'extra.'.$obj->name;
782 $fieldlabel = ucfirst($obj->label);
783 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
787 $this->import_fieldshidden_array[$r] = array(
788 's.fk_user_creat' =>
'user->id',
789 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'socpeople'
791 $this->import_convertvalue_array[$r] = array(
793 'rule' =>
'fetchidfromref',
794 'file' =>
'/societe/class/societe.class.php',
795 'class' =>
'Societe',
797 'element' =>
'ThirdParty'
799 's.fk_departement' => array(
800 'rule' =>
'fetchidfromcodeid',
801 'classfile' =>
'/core/class/cstate.class.php',
804 'dict' =>
'DictionaryCanton'
806 's.fk_pays' => array(
807 'rule' =>
'fetchidfromcodeid',
808 'classfile' =>
'/core/class/ccountry.class.php',
809 'class' =>
'Ccountry',
811 'dict' =>
'DictionaryCountry'
815 $this->import_regex_array[$r] = array(
816 's.birthday' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
817 '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])?$'
819 $this->import_examplevalues_array[$r] = array(
822 's.fk_soc' =>
'Third Party name eg. TPBigCompany',
823 's.civility' =>
'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_civility"',
824 's.lastname' =>
"lastname or label",
825 's.firstname' =>
'John',
826 's.address' =>
'61 Jump street',
828 's.town' =>
'Bigtown',
829 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
830 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
831 's.birthday' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
832 's.poste' =>
"Director",
833 's.phone' =>
"5551122",
834 's.phone_perso' =>
"5551133",
835 's.phone_mobile' =>
"5551144",
836 's.fax' =>
"5551155",
837 's.email' =>
"johnsmith@email.com",
838 's.note_private' =>
"My private note",
839 's.note_public' =>
"My public note"
841 $this->import_updatekeys_array[$r] = array(
843 's.lastname' =>
"Lastname",
845 if (isModEnabled(
'socialnetworks')) {
846 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
847 $resql = $this->db->query($sql);
849 while ($obj = $this->db->fetch_object($resql)) {
850 $fieldname =
's.socialnetworks_'.$obj->code;
851 $fieldlabel = ucfirst($obj->label);
852 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
859 $this->import_code[$r] = $this->rights_class.
'_'.$r;
860 $this->import_label[$r] =
"ImportDataset_company_3";
861 $this->import_icon[$r] =
'company';
862 $this->import_entities_array[$r] = array();
863 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_rib');
864 $this->import_fields_array[$r] = array(
865 'sr.label' =>
"Label*",
866 'sr.fk_soc' =>
"ThirdPartyName*",
867 'sr.datec' =>
"DateCreation*",
869 'sr.code_banque' =>
"BankCode",
870 'sr.code_guichet' =>
"DeskCode",
871 'sr.number' =>
"BankAccountNumber",
872 'sr.cle_rib' =>
"BankAccountNumberKey",
874 'sr.iban_prefix' =>
"IBAN",
875 'sr.domiciliation' =>
"BankAccountDomiciliation",
876 'sr.proprio' =>
"BankAccountOwner",
877 'sr.owner_address' =>
"BankAccountOwnerAddress",
878 'sr.default_rib' =>
'Default',
880 'sr.frstrecur' =>
"WithdrawMode",
881 'sr.type' =>
"Type ban is default",
884 $this->import_convertvalue_array[$r] = array(
885 'sr.fk_soc' => array(
886 'rule' =>
'fetchidfromref',
887 'classfile' =>
'/societe/class/societe.class.php',
888 'class' =>
'Societe',
890 'element' =>
'ThirdParty'
893 $this->import_examplevalues_array[$r] = array(
894 'sr.label' =>
'eg. "account1"',
895 'sr.fk_soc' =>
'eg. "TPBigCompany"',
896 'sr.datec' =>
'date used for creating direct debit UMR formatted as '.
dol_print_date(
900 'sr.bank' =>
'bank name eg: "ING-Direct"',
901 'sr.code_banque' =>
'account sort code (GB)/Routing number (US) eg. "8456"',
902 'sr.code_guichet' =>
"bank code for office/branch",
903 'sr.number' =>
'account number eg. "3333333333"',
904 'sr.cle_rib' =>
'account checksum/control digits (if used) eg. "22"',
905 'sr.bic' =>
'bank identifier eg. "USHINGMMXXX"',
906 'sr.iban_prefix' =>
'complete account IBAN eg. "GB78CPBK08925068637123"',
907 'sr.domiciliation' =>
'bank branch address eg. "PARIS"',
908 'sr.proprio' =>
'name on the bank account',
909 'sr.owner_address' =>
'address of account holder',
910 'sr.default_rib' =>
'1 (default account) / 0 (not default)',
911 'sr.rum' =>
'RUM code',
912 'sr.frstrecur' =>
'FRST',
918 $this->import_code[$r] = $this->rights_class.
'_'.$r;
919 $this->import_label[$r] =
"ImportDataset_company_4";
920 $this->import_icon[$r] =
'company';
921 $this->import_entities_array[$r] = array(
'sr.fk_user' =>
'user');
922 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_commerciaux');
923 $this->import_fields_array[$r] = array(
'sr.fk_soc' =>
"ThirdPartyName*",
'sr.fk_user' =>
"User*");
925 $this->import_convertvalue_array[$r] = array(
926 'sr.fk_soc' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
927 'sr.fk_user' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/user/class/user.class.php',
'class' =>
'User',
'method' =>
'fetch',
'element' =>
'User')
929 $this->import_examplevalues_array[$r] = array(
'sr.fk_soc' =>
"MyBigCompany",
'sr.fk_user' =>
"login");