46 global $conf, $user, $mysoc, $langs;
51 $this->family =
"crm";
52 $this->module_position =
'09';
54 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
55 $this->
description =
"Gestion des sociétés et contacts";
58 $this->version =
'dolibarr';
60 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
61 $this->config_page_url = array(
"societe.php@societe");
63 $this->picto =
'company';
66 $this->dirs = array(
"/societe/temp");
69 $this->hidden =
false;
70 $this->depends = array();
71 $this->requiredby = array(
"modExpedition",
"modFacture",
"modFournisseur",
"modFicheinter",
"modPropale",
"modContrat",
"modCommande");
72 $this->conflictwith = array();
73 $this->phpmin = array(7, 0);
74 $this->langfiles = array(
"companies",
'bills',
"compta",
"admin",
"banks");
77 $this->
const = array();
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;
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;
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;
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;
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;
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)'),
134 $this->rights = array();
135 $this->rights_class =
'societe';
139 $this->rights[$r][0] = 121;
140 $this->rights[$r][1] =
'Read third parties';
141 $this->rights[$r][2] =
'r';
142 $this->rights[$r][3] = 0;
143 $this->rights[$r][4] =
'lire';
163 $this->rights[$r][0] = 122;
164 $this->rights[$r][1] =
'Create and update third parties';
165 $this->rights[$r][2] =
'w';
166 $this->rights[$r][3] = 0;
167 $this->rights[$r][4] =
'creer';
187 $this->rights[$r][0] = 125;
188 $this->rights[$r][1] =
'Delete third parties';
189 $this->rights[$r][2] =
'd';
190 $this->rights[$r][3] = 0;
191 $this->rights[$r][4] =
'supprimer';
194 $this->rights[$r][0] = 126;
195 $this->rights[$r][1] =
'Export third parties';
196 $this->rights[$r][2] =
'r';
197 $this->rights[$r][3] = 0;
198 $this->rights[$r][4] =
'export';
201 $this->rights[$r][0] = 130;
202 $this->rights[$r][1] =
'Modify thirdparty information payment';
203 $this->rights[$r][3] = 0;
204 $this->rights[$r][4] =
'thirdparty_paymentinformation_advance';
205 $this->rights[$r][5] =
'write';
209 $this->rights[$r][0] = 262;
210 $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).';
211 $this->rights[$r][2] =
'r';
212 $this->rights[$r][3] = 0;
213 $this->rights[$r][4] =
'client';
214 $this->rights[$r][5] =
'voir';
227 $this->rights[$r][0] = 281;
228 $this->rights[$r][1] =
'Read contacts';
229 $this->rights[$r][2] =
'r';
230 $this->rights[$r][3] = 0;
231 $this->rights[$r][4] =
'contact';
232 $this->rights[$r][5] =
'lire';
235 $this->rights[$r][0] = 282;
236 $this->rights[$r][1] =
'Create and update contact';
237 $this->rights[$r][2] =
'w';
238 $this->rights[$r][3] = 0;
239 $this->rights[$r][4] =
'contact';
240 $this->rights[$r][5] =
'creer';
243 $this->rights[$r][0] = 283;
244 $this->rights[$r][1] =
'Delete contacts';
245 $this->rights[$r][2] =
'd';
246 $this->rights[$r][3] = 0;
247 $this->rights[$r][4] =
'contact';
248 $this->rights[$r][5] =
'supprimer';
251 $this->rights[$r][0] = 286;
252 $this->rights[$r][1] =
'Export contacts';
253 $this->rights[$r][2] =
'd';
254 $this->rights[$r][3] = 0;
255 $this->rights[$r][4] =
'contact';
256 $this->rights[$r][5] =
'export';
270 $this->export_code[$r] = $this->rights_class.
'_'.$r;
271 $this->export_label[$r] =
'ExportDataset_company_1';
272 $this->export_icon[$r] =
'company';
273 $this->export_permission[$r] = array(array(
"societe",
"export"));
274 $this->export_fields_array[$r] = array(
275 's.rowid'=>
"Id",
's.nom'=>
"Name",
's.name_alias'=>
"AliasNameShort",
'ps.nom'=>
"ParentCompany",
276 's.status'=>
"Status",
's.client'=>
"Customer",
's.fournisseur'=>
"Supplier",
's.datec'=>
"DateCreation",
's.tms'=>
"DateLastModification",
277 's.code_client'=>
"CustomerCode",
's.code_fournisseur'=>
"SupplierCode",
's.code_compta'=>
"AccountancyCode",
's.code_compta_fournisseur'=>
"SupplierAccountancyCode",
278 '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",
279 '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",
280 's.idprof5'=>
"ProfId5",
's.idprof6'=>
"ProfId6",
's.tva_intra'=>
"VATIntraShort",
's.capital'=>
"Capital",
's.note_private'=>
"NotePrivate",
's.note_public'=>
"NotePublic",
281 't.code'=>
"ThirdPartyType",
'ce.code'=>
"DictionaryStaff",
"cfj.libelle"=>
"JuridicalStatus",
's.fk_prospectlevel'=>
'ProspectLevel',
282 'st.code'=>
'ProspectStatus',
'payterm.libelle'=>
'PaymentConditions',
'paymode.libelle'=>
'PaymentMode',
283 's.outstanding_limit'=>
'OutstandingBill',
'pbacc.ref'=>
'PaymentBankAccount',
'incoterm.code'=>
'IncotermLabel'
286 $this->export_fields_array[$r][
's.prefix'] =
'Prefix';
289 $this->export_fields_array[$r][
's.price_level'] =
'PriceLevel';
292 $this->export_fields_array[$r] += array(
's.accountancy_code_sell'=>
'ProductAccountancySellCode',
's.accountancy_code_buy'=>
'ProductAccountancyBuyCode');
296 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
297 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
298 $this->export_fields_array[$r] += array(
's.entity'=>
'Entity');
301 $keyforselect =
'societe';
302 $keyforelement =
'company';
303 $keyforaliasextra =
'extra';
304 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
305 $this->export_fields_array[$r] += array(
'u.login'=>
'SaleRepresentativeLogin',
'u.firstname'=>
'SaleRepresentativeFirstname',
'u.lastname'=>
'SaleRepresentativeLastname');
307 $this->export_TypeFields_array[$r] = array(
308 's.rowid'=>
"Numeric",
's.nom'=>
"Text",
's.name_alias'=>
"Text",
'ps.nom'=>
"Text",
309 's.status'=>
"Numeric",
's.client'=>
"Numeric",
's.fournisseur'=>
"Boolean",
's.datec'=>
"Date",
's.tms'=>
"Date",
310 's.code_client'=>
"Text",
's.code_fournisseur'=>
"Text",
's.code_compta'=>
"Text",
's.code_compta_fournisseur'=>
"Text",
311 's.address'=>
"Text",
's.zip'=>
"Text",
's.town'=>
"Text",
312 'd.nom'=>
'Text',
'r.nom'=>
'Text',
'c.label'=>
'List:c_country:label:label',
'c.code'=>
'Text',
313 's.phone'=>
"Text",
's.fax'=>
"Text",
314 's.url'=>
"Text",
's.email'=>
"Text",
's.default_lang'=>
"Text",
's.canvas' =>
"Text",
315 's.siret'=>
"Text",
's.siren'=>
"Text",
's.ape'=>
"Text",
's.idprof4'=>
"Text",
's.idprof5'=>
"Text",
's.idprof6'=>
"Text",
316 's.tva_intra'=>
"Text",
's.capital'=>
"Numeric",
317 's.note_private'=>
"Text",
's.note_public'=>
"Text",
318 't.code'=>
"List:c_typent:libelle:code",
319 'ce.code'=>
"List:c_effectif:libelle:code",
320 "cfj.libelle"=>
"Text",
321 's.fk_prospectlevel'=>
'List:c_prospectlevel:label:code',
322 'st.code'=>
'List:c_stcomm:libelle:code',
323 'payterm.libelle'=>
'Text',
'paymode.libelle'=>
'Text',
324 's.outstanding_limit'=>
'Numeric',
'pbacc.ref'=>
'Text',
'incoterm.code'=>
'Text',
325 'u.login'=>
'Text',
'u.firstname'=>
'Text',
'u.lastname'=>
'Text',
326 's.entity'=>
'List:entity:label:rowid',
's.price_level'=>
'Numeric',
327 's.accountancy_code_sell'=>
'Text',
's.accountancy_code_buy'=>
'Text'
330 $this->export_entities_array[$r] = array(
332 'u.firstname'=>
'user',
333 'u.lastname'=>
'user');
334 $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)');
335 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
336 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
337 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extra ON s.rowid = extra.fk_object';
338 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON s.parent = ps.rowid';
339 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
340 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid';
341 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_effectif as ce ON s.fk_effectif = ce.id';
342 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
343 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON s.fk_departement = d.rowid';
344 $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';
345 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcomm as st ON s.fk_stcomm = st.id';
346 $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';
347 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
348 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as paymode ON s.mode_reglement = paymode.id';
349 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as pbacc ON s.fk_account = pbacc.rowid';
350 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';
351 $this->export_sql_end[$r] .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
352 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
353 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
355 $subordinatesids = $user->getAllChildIds();
356 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
358 $this->export_sql_end[$r] .=
')';
363 $this->export_code[$r] = $this->rights_class.
'_'.$r;
364 $this->export_label[$r] =
'ExportDataset_company_2';
365 $this->export_icon[$r] =
'contact';
366 $this->export_permission[$r] = array(array(
"societe",
"contact",
"export"));
367 $this->export_fields_array[$r] = array(
368 'c.rowid'=>
"IdContact",
'c.civility'=>
"CivilityCode",
'c.lastname'=>
'Lastname',
'c.firstname'=>
'Firstname',
'c.poste'=>
'PostOrFunction',
369 'c.datec'=>
"DateCreation",
'c.tms'=>
"DateLastModification",
'c.priv'=>
"ContactPrivate",
'c.address'=>
"Address",
'c.zip'=>
"Zip",
'c.town'=>
"Town",
370 '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",
371 'c.note_private'=>
'NotePrivate',
'c.note_public'=>
"NotePublic",
372 'c.statut'=>
"Status",
373 's.rowid'=>
"IdCompany",
's.nom'=>
"CompanyName",
's.status'=>
"Status",
's.code_client'=>
"CustomerCode",
's.code_fournisseur'=>
"SupplierCode",
374 's.code_compta'=>
"AccountancyCode",
's.code_compta_fournisseur'=>
"SupplierAccountancyCode",
375 's.client'=>
'Customer',
's.fournisseur'=>
'Supplier',
376 's.address'=>
'Address',
's.zip'=>
"Zip",
's.town'=>
"Town",
's.phone'=>
'Phone',
's.email'=>
"Email",
377 's.note_private'=>
'NotePrivate',
's.note_public'=>
"NotePublic",
378 't.code'=>
"ThirdPartyType"
382 if (isModEnabled(
'multicompany')) {
383 $nbofallowedentities = count(explode(
',',
getEntity(
'contact')));
384 if ($nbofallowedentities > 1) {
385 $this->export_fields_array[$r][
'c.entity'] =
'Entity';
388 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
389 if ($nbofallowedentities > 1) {
390 $this->export_fields_array[$r][
's.entity'] =
'Entity';
394 $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)');
395 $this->export_TypeFields_array[$r] = array(
396 'c.civility'=>
"List:c_civility:label:code",
'c.lastname'=>
'Text',
'c.firstname'=>
'Text',
'c.poste'=>
'Text',
'c.datec'=>
"Date",
'c.priv'=>
"Boolean",
397 '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",
398 'c.fax'=>
"Text",
'c.email'=>
"Text",
399 'c.statut'=>
"Status",
400 's.rowid'=>
"Numeric",
's.nom'=>
"Text",
's.status'=>
"Status",
's.code_client'=>
"Text",
's.code_fournisseur'=>
"Text",
401 's.code_compta'=>
"Text",
's.code_compta_fournisseur'=>
"Text",
402 's.client'=>
"Numeric",
's.fournisseur'=>
"Numeric",
403 's.address'=>
"Text",
's.zip'=>
"Text",
's.town'=>
"Text",
's.phone'=>
"Text",
's.email'=>
"Text",
404 't.code'=>
"List:c_stcomm:libelle:code",
405 'c.entity'=>
'List:entity:label:rowid',
406 's.entity'=>
'List:entity:label:rowid',
408 $this->export_entities_array[$r] = array(
409 's.rowid'=>
"company",
's.nom'=>
"company",
's.status'=>
'company',
's.code_client'=>
"company",
's.code_fournisseur'=>
"company",
410 's.code_compta'=>
"company",
's.code_compta_fournisseur'=>
"company",
411 's.client'=>
"company",
's.fournisseur'=>
"company",
412 's.address'=>
"company",
's.zip'=>
"company",
's.town'=>
"company",
's.phone'=>
"company",
's.email'=>
"company",
414 's.entity'=>
'company',
416 if (!isModEnabled(
"supplier_order") && !isModEnabled(
"supplier_invoice")) {
417 unset($this->export_fields_array[$r][
's.code_fournisseur']);
418 unset($this->export_entities_array[$r][
's.code_fournisseur']);
420 $keyforselect =
'socpeople';
421 $keyforelement =
'contact';
422 $keyforaliasextra =
'extra';
423 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
424 $keyforselect =
'societe';
425 $keyforelement =
'company';
426 $keyforaliasextra =
'extrasoc';
427 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
428 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
429 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'socpeople as c';
430 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON c.fk_soc = s.rowid';
431 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
432 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
433 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
435 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON c.fk_departement = d.rowid';
436 $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';
437 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON c.fk_pays = co.rowid';
438 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
439 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
440 $this->export_sql_end[$r] .=
' WHERE c.entity IN ('.getEntity(
'contact').
')';
441 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
442 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
444 $subordinatesids = $user->getAllChildIds();
445 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
447 $this->export_sql_end[$r] .=
')';
458 $this->import_code[$r] = $this->rights_class.
'_'.$r;
459 $this->import_label[$r] =
'ImportDataset_company_1';
460 $this->import_icon[$r] =
'company';
461 $this->import_entities_array[$r] = array();
462 $this->import_tables_array[$r] = array(
463 's' => MAIN_DB_PREFIX.
'societe',
464 'extra' => MAIN_DB_PREFIX.
'societe_extrafields'
466 $this->import_fields_array[$r] = array(
467 's.nom' =>
"ThirdPartyName*",
468 's.name_alias' =>
"AliasNameShort",
469 's.parent' =>
"ParentCompany",
470 's.status' =>
"Status*",
471 's.code_client' =>
"CustomerCode",
472 's.code_fournisseur' =>
"SupplierCode",
473 's.code_compta' =>
"CustomerAccountancyCode",
474 's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
475 's.address' =>
"Address",
478 's.fk_departement' =>
"StateCode",
479 's.fk_pays' =>
"CountryCode",
480 's.phone' =>
"Phone",
483 's.email' =>
"Email",
484 's.fk_effectif' =>
"Staff",
485 's.fk_typent' =>
"ThirdPartyType",
486 "s.fk_forme_juridique" =>
"JuridicalStatus",
487 's.siren' =>
"ProfId1",
488 's.siret' =>
"ProfId2",
489 's.ape' =>
"ProfId3",
490 's.idprof4' =>
"ProfId4",
491 's.idprof5' =>
"ProfId5",
492 's.idprof6' =>
"ProfId6",
493 's.tva_intra' =>
"VATIntraShort",
494 's.capital' =>
"Capital",
495 's.fk_stcomm' =>
'ProspectStatus',
496 's.note_private' =>
"NotePrivate",
497 's.note_public' =>
"NotePublic",
498 's.client' =>
"Customer*",
499 's.fournisseur' =>
"Supplier*",
500 's.fk_prospectlevel' =>
'ProspectLevel',
501 's.mode_reglement' =>
'PaymentTypeCustomer',
502 's.cond_reglement' =>
"PaymentTermsCustomer",
503 's.mode_reglement_supplier' =>
'PaymentTypeSupplier',
504 's.cond_reglement_supplier' =>
"PaymentTermsSupplier",
505 's.outstanding_limit'=>
'OutstandingBill',
506 's.fk_account'=>
'PaymentBankAccount',
507 's.fk_incoterms'=>
'IncotermLabel',
508 's.tva_assuj' =>
'VATIsUsed',
509 's.barcode' =>
'BarCode',
510 's.default_lang' =>
'DefaultLanguage',
511 's.canvas' =>
"Canvas",
512 's.datec' =>
"DateCreation",
513 's.fk_multicurrency' =>
'MulticurrencyUsed',
514 's.multicurrency_code' =>
'MulticurrencyCurrency'
517 $this->import_fields_array[$r][
's.price_level'] =
'PriceLevel';
520 $this->import_fields_array[$r] += array(
's.accountancy_code_sell'=>
'ProductAccountancySellCode',
's.accountancy_code_buy'=>
'ProductAccountancyBuyCode');
523 if (isModEnabled(
'socialnetworks')) {
524 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
525 $resql = $this->db->query($sql);
527 while ($obj = $this->db->fetch_object($resql)) {
528 $fieldname =
's.socialnetworks_'.$obj->code;
529 $fieldlabel = ucfirst($obj->label);
530 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
535 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.
")";
536 $resql = $this->db->query($sql);
538 while ($obj = $this->db->fetch_object($resql)) {
539 $fieldname =
'extra.'.$obj->name;
540 $fieldlabel = ucfirst($obj->label);
541 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
545 $this->import_fieldshidden_array[$r] = array(
546 's.fk_user_creat' =>
'user->id',
547 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'societe'
549 $this->import_convertvalue_array[$r] = array(
550 's.code_client' => array(
'rule' =>
'getcustomercodeifauto'),
551 's.code_fournisseur' => array(
'rule' =>
'getsuppliercodeifauto'),
552 's.code_compta' => array(
'rule' =>
'getcustomeraccountancycodeifauto'),
553 's.code_compta_fournisseur' => array(
'rule' =>
'getsupplieraccountancycodeifauto'),
554 's.fk_departement' => array(
555 'rule' =>
'fetchidfromcodeid',
556 'classfile' =>
'/core/class/cstate.class.php',
559 'dict' =>
'DictionaryStateCode'
561 's.fk_pays' => array(
562 'rule' =>
'fetchidfromcodeid',
563 'classfile' =>
'/core/class/ccountry.class.php',
564 'class' =>
'Ccountry',
566 'dict' =>
'DictionaryCountry'
568 's.fk_typent' => array(
569 'rule' =>
'fetchidfromcodeorlabel',
570 'classfile' =>
'/core/class/ctypent.class.php',
571 'class' =>
'Ctypent',
573 'dict' =>
'DictionaryCompanyType'
575 's.capital' => array(
'rule' =>
'numeric'),
577 'rule' =>
'fetchidfromref',
578 'file' =>
'/societe/class/societe.class.php',
579 'class' =>
'Societe',
581 'element' =>
'ThirdParty'
583 's.outstanding_limit' => array(
'rule' =>
'numeric'),
584 's.fk_account' => array(
585 'rule' =>
'fetchidfromcodeid',
586 'classfile' =>
'/compta/bank/class/account.class.php',
587 'class' =>
'Account',
589 'element' =>
'BankAccount'
591 's.fk_stcomm' => array(
592 'rule' =>
'fetchidfromcodeid',
593 'classfile' =>
'/core/class/cgenericdic.class.php',
594 'class' =>
'CGenericDic',
596 'dict' =>
'DictionaryProspectStatus',
597 'element' =>
'c_stcomm',
598 'table_element' =>
'c_stcomm'
620 $this->import_regex_array[$r] = array(
621 's.status' =>
'^[0|1]',
622 's.fk_typent' =>
'id@'.MAIN_DB_PREFIX.
'c_typent',
623 's.client' =>
'^[0|1|2|3]',
624 's.fournisseur' =>
'^[0|1]',
625 's.mode_reglement' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
626 's.cond_reglement' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
627 's.mode_reglement_supplier' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
628 's.cond_reglement_supplier' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
629 's.fk_incoterms' =>
'rowid@'.MAIN_DB_PREFIX.
'c_incoterms',
630 's.tva_assuj' =>
'^[0|1]',
631 's.fk_multicurrency' =>
'^[0|1]',
632 '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])?$',
633 's.multicurrency_code' =>
'code_iso@'.MAIN_DB_PREFIX.
'c_currencies'
636 $this->import_examplevalues_array[$r] = array(
637 's.nom' =>
"TPBigCompany",
638 's.name_alias' =>
"Alias for TPBigCompany",
639 's.parent' =>
"TPMotherCompany",
640 's.status' =>
"0 (closed) / 1 (active)",
641 's.code_client' =>
'eg. CU01-0001 / empty / "auto"',
642 's.code_fournisseur' =>
'eg. SU01-0001 / empty / "auto"',
643 's.code_compta' =>
"Code or empty to be auto-created",
644 's.code_compta_fournisseur' =>
"Code or empty to be auto-created",
645 's.address' =>
"61 Jump Street",
647 's.town' =>
"Bigtown",
648 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
649 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
650 's.phone' =>
"eg: +34123456789",
651 's.fax' =>
"eg. +34987654321",
652 's.url' =>
"e.g. https://www.mybigcompany.com",
653 's.email' =>
"e.g. test@mybigcompany.com",
654 's.fk_effectif' =>
"1/2/3/5: represents one of the five ranges of employees",
655 's.fk_typent' =>
'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.
'c_typent"',
656 's.fk_forme_juridique' =>
'1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_forme_juridique"',
663 's.tva_intra' =>
'VAT number e.g."FR0123456789"',
664 's.capital' =>
"10000",
665 's.fk_stcomm' =>
'-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.
'c_stcomm"',
666 's.note_private' =>
"Example of a PRIVATE note.",
667 's.note_public' =>
"Example of a PUBLIC note.",
668 's.client' =>
'0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
669 's.fournisseur' =>
'0 (not supplier) / 1 (supplier)',
670 's.fk_prospectlevel' =>
'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.
'c_prospectlevel"',
671 's.mode_reglement' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
672 's.cond_reglement' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
673 's.mode_reglement_supplier' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
674 's.cond_reglement_supplier' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
675 's.outstanding_limit' =>
"5000",
676 's.fk_account' =>
"rowid or ref",
677 's.fk_incoterms' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_incoterms"',
678 's.tva_assuj' =>
'0 (VAT not used) / 1 (VAT used)',
679 's.barcode' =>
'123456789',
680 's.default_lang' =>
'en_US / es_ES etc...matches a language directory in htdocs/langs/',
681 's.canvas' =>
"empty / a custom canvas form layout url e.g. mycanvas@mymodule",
682 's.datec' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
683 's.fk_multicurrency' =>
'0 (use system default currency) / 1 (use local currency)',
684 's.multicurrency_code' =>
'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.
'c_currencies"',
685 's.accountancy_code_sell' =>
'707',
686 's.accountancy_code_buy' =>
'607',
688 $this->import_updatekeys_array[$r] = array(
689 's.nom' =>
'ThirdPartyName',
691 's.email' =>
'Email',
692 's.code_client' =>
'CustomerCode',
693 's.code_fournisseur' =>
'SupplierCode',
694 's.code_compta' =>
'CustomerAccountancyCode',
695 's.code_compta_fournisseur' =>
'SupplierAccountancyCode'
697 if (isModEnabled(
'socialnetworks')) {
698 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
699 $resql = $this->db->query($sql);
701 while ($obj = $this->db->fetch_object($resql)) {
702 $fieldname =
's.socialnetworks_'.$obj->code;
703 $fieldlabel = ucfirst($obj->label);
704 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
709 $langs->load(
"companies");
713 $this->import_updatekeys_array[$r][
's.siren'] =
'ProfId1'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
716 $this->import_updatekeys_array[$r][
's.siret'] =
'ProfId2'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
719 $this->import_updatekeys_array[$r][
's.ape'] =
'ProfId3'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
723 if ($langs->trans(
'ProfId'.$i.(empty($mysoc->country_code) ?
'' : $mysoc->country_code)) !=
'-') {
724 $this->import_updatekeys_array[$r][
's.idprof'.$i] =
'ProfId'.$i.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
732 $this->import_code[$r] = $this->rights_class.
'_'.$r;
733 $this->import_label[$r] =
'ImportDataset_company_2';
734 $this->import_icon[$r] =
'contact';
735 $this->import_entities_array[$r] = array(
's.fk_soc' =>
'company');
736 $this->import_tables_array[$r] = array(
737 's' => MAIN_DB_PREFIX.
'socpeople',
738 'extra' => MAIN_DB_PREFIX.
'socpeople_extrafields'
740 $this->import_fields_array[$r] = array(
742 's.datec' =>
"DateCreation",
743 's.fk_soc' =>
'ThirdPartyName',
744 's.civility' =>
'UserTitle',
745 's.lastname' =>
"Lastname*",
746 's.firstname' =>
"Firstname",
747 's.address' =>
"Address",
750 's.fk_departement' =>
"StateCode",
751 's.fk_pays' =>
"CountryCode",
752 's.birthday' =>
"DateOfBirth",
753 's.poste' =>
"PostOrFunction",
754 's.phone' =>
"Phone",
755 's.phone_perso' =>
"PhonePerso",
756 's.phone_mobile' =>
"PhoneMobile",
758 's.email' =>
"Email",
759 's.note_private' =>
"NotePrivate",
760 's.note_public' =>
"NotePublic"
763 if (isModEnabled(
'socialnetworks')) {
764 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
765 $resql = $this->db->query($sql);
767 while ($obj = $this->db->fetch_object($resql)) {
768 $fieldname =
's.socialnetworks_'.$obj->code;
769 $fieldlabel = ucfirst($obj->label);
770 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
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);
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 ?
'*' :
'');
785 $this->import_fieldshidden_array[$r] = array(
786 's.fk_user_creat' =>
'user->id',
787 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'socpeople'
789 $this->import_convertvalue_array[$r] = array(
791 'rule' =>
'fetchidfromref',
792 'file' =>
'/societe/class/societe.class.php',
793 'class' =>
'Societe',
795 'element' =>
'ThirdParty'
797 's.fk_departement' => array(
798 'rule' =>
'fetchidfromcodeid',
799 'classfile' =>
'/core/class/cstate.class.php',
802 'dict' =>
'DictionaryCanton'
804 's.fk_pays' => array(
805 'rule' =>
'fetchidfromcodeid',
806 'classfile' =>
'/core/class/ccountry.class.php',
807 'class' =>
'Ccountry',
809 'dict' =>
'DictionaryCountry'
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])?$'
817 $this->import_examplevalues_array[$r] = array(
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',
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' =>
"johnsmith@email.com",
836 's.note_private' =>
"My private note",
837 's.note_public' =>
"My public note"
839 $this->import_updatekeys_array[$r] = array(
841 's.lastname' =>
"Lastname",
843 if (isModEnabled(
'socialnetworks')) {
844 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
845 $resql = $this->db->query($sql);
847 while ($obj = $this->db->fetch_object($resql)) {
848 $fieldname =
's.socialnetworks_'.$obj->code;
849 $fieldlabel = ucfirst($obj->label);
850 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
857 $this->import_code[$r] = $this->rights_class.
'_'.$r;
858 $this->import_label[$r] =
"ImportDataset_company_3";
859 $this->import_icon[$r] =
'company';
860 $this->import_entities_array[$r] = array();
861 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_rib');
862 $this->import_fields_array[$r] = array(
863 'sr.label' =>
"Label*",
864 'sr.fk_soc' =>
"ThirdPartyName*",
865 'sr.datec' =>
"DateCreation*",
867 'sr.code_banque' =>
"BankCode",
868 'sr.code_guichet' =>
"DeskCode",
869 'sr.number' =>
"BankAccountNumber",
870 'sr.cle_rib' =>
"BankAccountNumberKey",
872 'sr.iban_prefix' =>
"IBAN",
873 'sr.domiciliation' =>
"BankAccountDomiciliation",
874 'sr.proprio' =>
"BankAccountOwner",
875 'sr.owner_address' =>
"BankAccountOwnerAddress",
876 'sr.default_rib' =>
'Default',
878 'sr.frstrecur' =>
"WithdrawMode",
879 'sr.type' =>
"Type ban is defaut",
882 $this->import_convertvalue_array[$r] = array(
883 'sr.fk_soc' => array(
884 'rule' =>
'fetchidfromref',
885 'classfile' =>
'/societe/class/societe.class.php',
886 'class' =>
'Societe',
888 'element' =>
'ThirdParty'
891 $this->import_examplevalues_array[$r] = array(
892 'sr.label' =>
'eg. "account1"',
893 'sr.fk_soc' =>
'eg. "TPBigCompany"',
894 'sr.datec' =>
'date used for creating direct debit UMR formatted as '.
dol_print_date(
898 'sr.bank' =>
'bank name eg: "ING-Direct"',
899 'sr.code_banque' =>
'account sort code (GB)/Routing number (US) eg. "8456"',
900 'sr.code_guichet' =>
"bank code for office/branch",
901 'sr.number' =>
'account number eg. "3333333333"',
902 'sr.cle_rib' =>
'account checksum/control digits (if used) eg. "22"',
903 'sr.bic' =>
'bank identifier eg. "USHINGMMXXX"',
904 'sr.iban_prefix' =>
'complete account IBAN eg. "GB78CPBK08925068637123"',
905 'sr.domiciliation' =>
'bank branch address eg. "PARIS"',
906 'sr.proprio' =>
'name on the bank account',
907 'sr.owner_address' =>
'address of account holder',
908 'sr.default_rib' =>
'1 (default account) / 0 (not default)',
909 'sr.rum' =>
'RUM code',
910 'sr.frstrecur' =>
'FRST',
916 $this->import_code[$r] = $this->rights_class.
'_'.$r;
917 $this->import_label[$r] =
"ImportDataset_company_4";
918 $this->import_icon[$r] =
'company';
919 $this->import_entities_array[$r] = array(
'sr.fk_user'=>
'user');
920 $this->import_tables_array[$r] = array(
'sr'=>MAIN_DB_PREFIX.
'societe_commerciaux');
921 $this->import_fields_array[$r] = array(
'sr.fk_soc'=>
"ThirdPartyName*",
'sr.fk_user'=>
"User*");
923 $this->import_convertvalue_array[$r] = array(
924 'sr.fk_soc'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/societe/class/societe.class.php',
'class'=>
'Societe',
'method'=>
'fetch',
'element'=>
'ThirdParty'),
925 'sr.fk_user'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/user/class/user.class.php',
'class'=>
'User',
'method'=>
'fetch',
'element'=>
'User')
927 $this->import_examplevalues_array[$r] = array(
'sr.fk_soc'=>
"MyBigCompany",
'sr.fk_user'=>
"login");