31 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
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'
286 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
287 $this->export_fields_array[$r][
's.prefix'] =
'Prefix';
289 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
290 $this->export_fields_array[$r][
's.price_level'] =
'PriceLevel';
292 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
293 $this->export_fields_array[$r] += array(
's.accountancy_code_sell'=>
'ProductAccountancySellCode',
's.accountancy_code_buy'=>
'ProductAccountancyBuyCode');
296 if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
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",
'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) && empty($user->rights->societe->client->voir)) {
353 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
354 if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
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.statut'=>
"Status",
372 's.rowid'=>
"IdCompany",
's.nom'=>
"CompanyName",
's.status'=>
"Status",
's.code_client'=>
"CustomerCode",
's.code_fournisseur'=>
"SupplierCode",
373 's.code_compta'=>
"AccountancyCode",
's.code_compta_fournisseur'=>
"SupplierAccountancyCode",
374 's.client'=>
'Customer',
's.fournisseur'=>
'Supplier',
375 's.address'=>
'Address',
's.zip'=>
"Zip",
's.town'=>
"Town",
's.phone'=>
'Phone',
's.email'=>
"Email",
376 't.code'=>
"ThirdPartyType"
379 if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
381 $nbofallowedentities = count(explode(
',',
getEntity(
'contact')));
382 if ($nbofallowedentities > 1) {
383 $this->export_fields_array[$r][
'c.entity'] =
'Entity';
386 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
387 if ($nbofallowedentities > 1) {
388 $this->export_fields_array[$r][
's.entity'] =
'Entity';
392 $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)');
393 $this->export_TypeFields_array[$r] = array(
394 'c.civility'=>
"List:c_civility:label:code",
'c.lastname'=>
'Text',
'c.firstname'=>
'Text',
'c.poste'=>
'Text',
'c.datec'=>
"Date",
'c.priv'=>
"Boolean",
395 '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",
396 'c.fax'=>
"Text",
'c.email'=>
"Text",
397 'c.statut'=>
"Status",
398 's.rowid'=>
"Numeric",
's.nom'=>
"Text",
's.status'=>
"Status",
's.code_client'=>
"Text",
's.code_fournisseur'=>
"Text",
399 's.code_compta'=>
"Text",
's.code_compta_fournisseur'=>
"Text",
400 's.client'=>
"Text",
's.fournisseur'=>
"Text",
401 's.address'=>
"Text",
's.zip'=>
"Text",
's.town'=>
"Text",
's.phone'=>
"Text",
's.email'=>
"Text",
402 't.code'=>
"List:c_stcomm:libelle:code",
403 'c.entity'=>
'List:entity:label:rowid',
404 's.entity'=>
'List:entity:label:rowid',
406 $this->export_entities_array[$r] = array(
407 's.rowid'=>
"company",
's.nom'=>
"company",
's.status'=>
'company',
's.code_client'=>
"company",
's.code_fournisseur'=>
"company",
408 's.code_compta'=>
"company",
's.code_compta_fournisseur'=>
"company",
409 's.client'=>
"company",
's.fournisseur'=>
"company",
410 's.address'=>
"company",
's.zip'=>
"company",
's.town'=>
"company",
's.phone'=>
"company",
's.email'=>
"company",
412 's.entity'=>
'company',
415 unset($this->export_fields_array[$r][
's.code_fournisseur']);
416 unset($this->export_entities_array[$r][
's.code_fournisseur']);
418 $keyforselect =
'socpeople';
419 $keyforelement =
'contact';
420 $keyforaliasextra =
'extra';
421 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
422 $keyforselect =
'societe';
423 $keyforelement =
'company';
424 $keyforaliasextra =
'extrasoc';
425 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
426 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
427 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'socpeople as c';
428 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON c.fk_soc = s.rowid';
429 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
430 if (is_object($user) && empty($user->rights->societe->client->voir)) {
431 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
433 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON c.fk_departement = d.rowid';
434 $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';
435 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON c.fk_pays = co.rowid';
436 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
437 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
438 $this->export_sql_end[$r] .=
' WHERE c.entity IN ('.getEntity(
'contact').
')';
439 if (is_object($user) && empty($user->rights->societe->client->voir)) {
440 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
441 if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
442 $subordinatesids = $user->getAllChildIds();
443 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
445 $this->export_sql_end[$r] .=
')';
456 $this->import_code[$r] = $this->rights_class.
'_'.$r;
457 $this->import_label[$r] =
'ImportDataset_company_1';
458 $this->import_icon[$r] =
'company';
459 $this->import_entities_array[$r] = array();
460 $this->import_tables_array[$r] = array(
461 's' => MAIN_DB_PREFIX.
'societe',
462 'extra' => MAIN_DB_PREFIX.
'societe_extrafields'
464 $this->import_fields_array[$r] = array(
465 's.nom' =>
"ThirdPartyName*",
466 's.name_alias' =>
"AliasNameShort",
467 's.parent' =>
"ParentCompany",
468 's.status' =>
"Status*",
469 's.code_client' =>
"CustomerCode",
470 's.code_fournisseur' =>
"SupplierCode",
471 's.code_compta' =>
"CustomerAccountancyCode",
472 's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
473 's.address' =>
"Address",
476 's.fk_departement' =>
"StateCode",
477 's.fk_pays' =>
"CountryCode",
478 's.phone' =>
"Phone",
481 's.email' =>
"Email",
482 's.fk_effectif' =>
"Staff",
483 's.fk_typent' =>
"ThirdPartyType",
484 "s.fk_forme_juridique" =>
"JuridicalStatus",
485 's.siren' =>
"ProfId1",
486 's.siret' =>
"ProfId2",
487 's.ape' =>
"ProfId3",
488 's.idprof4' =>
"ProfId4",
489 's.idprof5' =>
"ProfId5",
490 's.idprof6' =>
"ProfId6",
491 's.tva_intra' =>
"VATIntraShort",
492 's.capital' =>
"Capital",
493 's.fk_stcomm' =>
'ProspectStatus',
494 's.note_private' =>
"NotePrivate",
495 's.note_public' =>
"NotePublic",
496 's.client' =>
"Customer*",
497 's.fournisseur' =>
"Supplier*",
498 's.fk_prospectlevel' =>
'ProspectLevel',
499 's.mode_reglement' =>
'PaymentTypeCustomer',
500 's.cond_reglement' =>
"PaymentTermsCustomer",
501 's.mode_reglement_supplier' =>
'PaymentTypeSupplier',
502 's.cond_reglement_supplier' =>
"PaymentTermsSupplier",
503 's.outstanding_limit'=>
'OutstandingBill',
504 's.fk_account'=>
'PaymentBankAccount',
505 's.fk_incoterms'=>
'IncotermLabel',
506 's.tva_assuj' =>
'VATIsUsed',
507 's.barcode' =>
'BarCode',
508 's.default_lang' =>
'DefaultLanguage',
509 's.canvas' =>
"Canvas",
510 's.datec' =>
"DateCreation",
511 's.fk_multicurrency' =>
'MulticurrencyUsed',
512 's.multicurrency_code' =>
'MulticurrencyCurrency'
514 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
515 $this->import_fields_array[$r][
's.price_level'] =
'PriceLevel';
517 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
518 $this->import_fields_array[$r] += array(
's.accountancy_code_sell'=>
'ProductAccountancySellCode',
's.accountancy_code_buy'=>
'ProductAccountancyBuyCode');
522 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
523 $resql = $this->db->query(
$sql);
524 while ($obj = $this->db->fetch_object($resql)) {
525 $fieldname =
's.socialnetworks_'.$obj->code;
526 $fieldlabel = ucfirst($obj->label);
527 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
531 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.
")";
532 $resql = $this->db->query(
$sql);
534 while ($obj = $this->db->fetch_object($resql)) {
535 $fieldname =
'extra.'.$obj->name;
536 $fieldlabel = ucfirst($obj->label);
537 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
541 $this->import_fieldshidden_array[$r] = array(
542 's.fk_user_creat' =>
'user->id',
543 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'societe'
545 $this->import_convertvalue_array[$r] = array(
546 's.code_client' => array(
'rule' =>
'getcustomercodeifauto'),
547 's.code_fournisseur' => array(
'rule' =>
'getsuppliercodeifauto'),
548 's.code_compta' => array(
'rule' =>
'getcustomeraccountancycodeifauto'),
549 's.code_compta_fournisseur' => array(
'rule' =>
'getsupplieraccountancycodeifauto'),
550 's.fk_departement' => array(
551 'rule' =>
'fetchidfromcodeid',
552 'classfile' =>
'/core/class/cstate.class.php',
555 'dict' =>
'DictionaryStateCode'
557 's.fk_pays' => array(
558 'rule' =>
'fetchidfromcodeid',
559 'classfile' =>
'/core/class/ccountry.class.php',
560 'class' =>
'Ccountry',
562 'dict' =>
'DictionaryCountry'
564 's.fk_typent' => array(
565 'rule' =>
'fetchidfromcodeorlabel',
566 'classfile' =>
'/core/class/ctypent.class.php',
567 'class' =>
'Ctypent',
569 'dict' =>
'DictionaryCompanyType'
571 's.capital' => array(
'rule' =>
'numeric'),
573 'rule' =>
'fetchidfromref',
574 'file' =>
'/societe/class/societe.class.php',
575 'class' =>
'Societe',
577 'element' =>
'ThirdParty'
579 's.outstanding_limit' => array(
'rule' =>
'numeric'),
580 's.fk_account' => array(
581 'rule' =>
'fetchidfromcodeid',
582 'classfile' =>
'/compta/bank/class/account.class.php',
583 'class' =>
'Account',
585 'element' =>
'BankAccount'
587 's.fk_stcomm' => array(
588 'rule' =>
'fetchidfromcodeid',
589 'classfile' =>
'/core/class/cgenericdic.class.php',
590 'class' =>
'CGenericDic',
592 'dict' =>
'DictionaryProspectStatus',
593 'element' =>
'c_stcomm',
594 'table_element' =>
'c_stcomm'
616 $this->import_regex_array[$r] = array(
617 's.status' =>
'^[0|1]',
618 's.fk_typent' =>
'id@'.MAIN_DB_PREFIX.
'c_typent',
619 's.client' =>
'^[0|1|2|3]',
620 's.fournisseur' =>
'^[0|1]',
621 's.mode_reglement' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
622 's.cond_reglement' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
623 's.mode_reglement_supplier' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
624 's.cond_reglement_supplier' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
625 's.fk_incoterms' =>
'rowid@'.MAIN_DB_PREFIX.
'c_incoterms',
626 's.tva_assuj' =>
'^[0|1]',
627 's.fk_multicurrency' =>
'^[0|1]',
628 '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])?$',
629 's.multicurrency_code' =>
'code_iso@'.MAIN_DB_PREFIX.
'c_currencies'
632 $this->import_examplevalues_array[$r] = array(
633 's.nom' =>
"TPBigCompany",
634 's.name_alias' =>
"Alias for TPBigCompany",
635 's.parent' =>
"TPMotherCompany",
636 's.status' =>
"0 (closed) / 1 (active)",
637 's.code_client' =>
'eg. CU01-0001 / empty / "auto"',
638 's.code_fournisseur' =>
'eg. SU01-0001 / empty / "auto"',
639 's.code_compta' =>
"Code or empty to be auto-created",
640 's.code_compta_fournisseur' =>
"Code or empty to be auto-created",
641 's.address' =>
"61 Jump Street",
643 's.town' =>
"Bigtown",
644 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
645 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
646 's.phone' =>
"eg: +34123456789",
647 's.fax' =>
"eg. +34987654321",
648 's.url' =>
"e.g. https://www.mybigcompany.com",
649 's.email' =>
"e.g. test@mybigcompany.com",
650 's.fk_effectif' =>
"1/2/3/5: represents one of the five ranges of employees",
651 's.fk_typent' =>
'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.
'c_typent"',
652 's.fk_forme_juridique' =>
'1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_forme_juridique"',
659 's.tva_intra' =>
'VAT number e.g."FR0123456789"',
660 's.capital' =>
"10000",
661 's.fk_stcomm' =>
'-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.
'c_stcomm"',
662 's.note_private' =>
"Example of a PRIVATE note.",
663 's.note_public' =>
"Example of a PUBLIC note.",
664 's.client' =>
'0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
665 's.fournisseur' =>
'0 (not supplier) / 1 (supplier)',
666 's.fk_prospectlevel' =>
'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.
'c_prospectlevel"',
667 's.mode_reglement' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
668 's.cond_reglement' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
669 's.mode_reglement_supplier' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
670 's.cond_reglement_supplier' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
671 's.outstanding_limit' =>
"5000",
672 's.fk_account' =>
"rowid or ref",
673 's.fk_incoterms' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_incoterms"',
674 's.tva_assuj' =>
'0 (VAT not used) / 1 (VAT used)',
675 's.barcode' =>
'123456789',
676 's.default_lang' =>
'en_US / es_ES etc...matches a language directory in htdocs/langs/',
677 's.canvas' =>
"empty / a custom canvas form layout url e.g. mycanvas@mymodule",
678 's.datec' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
679 's.fk_multicurrency' =>
'0 (use system default currency) / 1 (use local currency)',
680 's.multicurrency_code' =>
'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.
'c_currencies"',
681 's.accountancy_code_sell' =>
'707',
682 's.accountancy_code_buy' =>
'607',
684 $this->import_updatekeys_array[$r] = array(
685 's.nom' =>
'ThirdPartyName',
687 's.email' =>
'Email',
688 's.code_client' =>
'CustomerCode',
689 's.code_fournisseur' =>
'SupplierCode',
690 's.code_compta' =>
'CustomerAccountancyCode',
691 's.code_compta_fournisseur' =>
'SupplierAccountancyCode'
694 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
695 $resql = $this->db->query(
$sql);
696 while ($obj = $this->db->fetch_object($resql)) {
697 $fieldname =
's.socialnetworks_'.$obj->code;
698 $fieldlabel = ucfirst($obj->label);
699 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
703 $langs->load(
"companies");
707 $this->import_updatekeys_array[$r][
's.siren'] =
'ProfId1'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
710 $this->import_updatekeys_array[$r][
's.siret'] =
'ProfId2'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
713 $this->import_updatekeys_array[$r][
's.ape'] =
'ProfId3'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
717 if ($langs->trans(
'ProfId'.$i.(empty($mysoc->country_code) ?
'' : $mysoc->country_code)) !=
'-') {
718 $this->import_updatekeys_array[$r][
's.idprof'.$i] =
'ProfId'.$i.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
726 $this->import_code[$r] = $this->rights_class.
'_'.$r;
727 $this->import_label[$r] =
'ImportDataset_company_2';
728 $this->import_icon[$r] =
'contact';
729 $this->import_entities_array[$r] = array(
's.fk_soc' =>
'company');
730 $this->import_tables_array[$r] = array(
731 's' => MAIN_DB_PREFIX.
'socpeople',
732 'extra' => MAIN_DB_PREFIX.
'socpeople_extrafields'
734 $this->import_fields_array[$r] = array(
736 's.datec' =>
"DateCreation",
737 's.fk_soc' =>
'ThirdPartyName',
738 's.civility' =>
'UserTitle',
739 's.lastname' =>
"Lastname*",
740 's.firstname' =>
"Firstname",
741 's.address' =>
"Address",
744 's.fk_departement' =>
"StateCode",
745 's.fk_pays' =>
"CountryCode",
746 's.birthday' =>
"DateOfBirth",
747 's.poste' =>
"PostOrFunction",
748 's.phone' =>
"Phone",
749 's.phone_perso' =>
"PhonePerso",
750 's.phone_mobile' =>
"PhoneMobile",
752 's.email' =>
"Email",
753 's.note_private' =>
"NotePrivate",
754 's.note_public' =>
"NotePublic"
758 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
759 $resql = $this->db->query(
$sql);
760 while ($obj = $this->db->fetch_object($resql)) {
761 $fieldname =
's.socialnetworks_'.$obj->code;
762 $fieldlabel = ucfirst($obj->label);
763 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
767 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.
")";
768 $resql = $this->db->query(
$sql);
770 while ($obj = $this->db->fetch_object($resql)) {
771 $fieldname =
'extra.'.$obj->name;
772 $fieldlabel = ucfirst($obj->label);
773 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
777 $this->import_fieldshidden_array[$r] = array(
778 's.fk_user_creat' =>
'user->id',
779 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'socpeople'
781 $this->import_convertvalue_array[$r] = array(
783 'rule' =>
'fetchidfromref',
784 'file' =>
'/societe/class/societe.class.php',
785 'class' =>
'Societe',
787 'element' =>
'ThirdParty'
789 's.fk_departement' => array(
790 'rule' =>
'fetchidfromcodeid',
791 'classfile' =>
'/core/class/cstate.class.php',
794 'dict' =>
'DictionaryCanton'
796 's.fk_pays' => array(
797 'rule' =>
'fetchidfromcodeid',
798 'classfile' =>
'/core/class/ccountry.class.php',
799 'class' =>
'Ccountry',
801 'dict' =>
'DictionaryCountry'
805 $this->import_regex_array[$r] = array(
806 's.birthday' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
807 '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])?$'
809 $this->import_examplevalues_array[$r] = array(
812 's.fk_soc' =>
'Third Party name eg. TPBigCompany',
813 's.civility' =>
'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_civility"',
814 's.lastname' =>
"lastname or label",
815 's.firstname' =>
'John',
816 's.address' =>
'61 Jump street',
818 's.town' =>
'Bigtown',
819 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
820 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
821 's.birthday' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
822 's.poste' =>
"Director",
823 's.phone' =>
"5551122",
824 's.phone_perso' =>
"5551133",
825 's.phone_mobile' =>
"5551144",
826 's.fax' =>
"5551155",
827 's.email' =>
"johnsmith@email.com",
828 's.note_private' =>
"My private note",
829 's.note_public' =>
"My public note"
831 $this->import_updatekeys_array[$r] = array(
833 's.lastname' =>
"Lastname",
836 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
837 $resql = $this->db->query(
$sql);
838 while ($obj = $this->db->fetch_object($resql)) {
839 $fieldname =
's.socialnetworks_'.$obj->code;
840 $fieldlabel = ucfirst($obj->label);
841 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
847 $this->import_code[$r] = $this->rights_class.
'_'.$r;
848 $this->import_label[$r] =
"ImportDataset_company_3";
849 $this->import_icon[$r] =
'company';
850 $this->import_entities_array[$r] = array();
851 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_rib');
852 $this->import_fields_array[$r] = array(
853 'sr.label' =>
"Label*",
854 'sr.fk_soc' =>
"ThirdPartyName*",
855 'sr.datec' =>
"DateCreation*",
857 'sr.code_banque' =>
"BankCode",
858 'sr.code_guichet' =>
"DeskCode",
859 'sr.number' =>
"BankAccountNumber",
860 'sr.cle_rib' =>
"BankAccountNumberKey",
862 'sr.iban_prefix' =>
"IBAN",
863 'sr.domiciliation' =>
"BankAccountDomiciliation",
864 'sr.proprio' =>
"BankAccountOwner",
865 'sr.owner_address' =>
"BankAccountOwnerAddress",
866 'sr.default_rib' =>
'Default',
868 'sr.frstrecur' =>
"WithdrawMode",
869 'sr.type' =>
"Type ban is defaut",
872 $this->import_convertvalue_array[$r] = array(
873 'sr.fk_soc' => array(
874 'rule' =>
'fetchidfromref',
875 'classfile' =>
'/societe/class/societe.class.php',
876 'class' =>
'Societe',
878 'element' =>
'ThirdParty'
881 $this->import_examplevalues_array[$r] = array(
882 'sr.label' =>
'eg. "account1"',
883 'sr.fk_soc' =>
'eg. "TPBigCompany"',
884 'sr.datec' =>
'date used for creating direct debit UMR formatted as '.
dol_print_date(
888 'sr.bank' =>
'bank name eg: "ING-Direct"',
889 'sr.code_banque' =>
'account sort code (GB)/Routing number (US) eg. "8456"',
890 'sr.code_guichet' =>
"bank code for office/branch",
891 'sr.number' =>
'account number eg. "3333333333"',
892 'sr.cle_rib' =>
'account checksum/control digits (if used) eg. "22"',
893 'sr.bic' =>
'bank identifier eg. "USHINGMMXXX"',
894 'sr.iban_prefix' =>
'complete account IBAN eg. "GB78CPBK08925068637123"',
895 'sr.domiciliation' =>
'bank branch address eg. "PARIS"',
896 'sr.proprio' =>
'name on the bank account',
897 'sr.owner_address' =>
'address of account holder',
898 'sr.default_rib' =>
'1 (default account) / 0 (not default)',
899 'sr.rum' =>
'RUM code',
900 'sr.frstrecur' =>
'FRST',
906 $this->import_code[$r] = $this->rights_class.
'_'.$r;
907 $this->import_label[$r] =
"ImportDataset_company_4";
908 $this->import_icon[$r] =
'company';
909 $this->import_entities_array[$r] = array(
'sr.fk_user'=>
'user');
910 $this->import_tables_array[$r] = array(
'sr'=>MAIN_DB_PREFIX.
'societe_commerciaux');
911 $this->import_fields_array[$r] = array(
'sr.fk_soc'=>
"ThirdPartyName*",
'sr.fk_user'=>
"User*");
913 $this->import_convertvalue_array[$r] = array(
914 'sr.fk_soc'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/societe/class/societe.class.php',
'class'=>
'Societe',
'method'=>
'fetch',
'element'=>
'ThirdParty'),
915 'sr.fk_user'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/user/class/user.class.php',
'class'=>
'User',
'method'=>
'fetch',
'element'=>
'User')
917 $this->import_examplevalues_array[$r] = array(
'sr.fk_soc'=>
"MyBigCompany",
'sr.fk_user'=>
"login");
929 public function init($options =
'')
931 global $conf, $langs;
937 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/thirdparties/template_thirdparty.odt';
938 $dirodt = DOL_DATA_ROOT.
'/doctemplates/thirdparties';
939 $dest = $dirodt.
'/template_thirdparty.odt';
941 if (file_exists($src) && !file_exists($dest)) {
942 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
944 $result =
dol_copy($src, $dest, 0, 0);
946 $langs->load(
"errors");
947 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
_init($array_sql, $options='')
Enables a module.
Class to describe and enable module Societe.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.