48 global
$conf, $user, $mysoc, $langs;
53 $this->family =
"crm";
54 $this->module_position =
'09';
56 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->
description =
"Gestion des sociétés et contacts";
60 $this->version =
'dolibarr';
62 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
63 $this->config_page_url = array(
"societe.php@societe");
65 $this->picto =
'company';
68 $this->dirs = array(
"/societe/temp");
71 $this->hidden =
false;
72 $this->depends = array();
73 $this->requiredby = array(
"modExpedition",
"modFacture",
"modFournisseur",
"modFicheinter",
"modPropale",
"modContrat",
"modCommande");
74 $this->conflictwith = array();
75 $this->phpmin = array(7, 0);
76 $this->langfiles = array(
"companies",
'bills',
"compta",
"admin",
"banks");
79 $this->
const = array();
82 $this->
const[$r][0] =
"SOCIETE_CODECLIENT_ADDON";
83 $this->
const[$r][1] =
"chaine";
84 $this->
const[$r][2] =
"mod_codeclient_monkey";
85 $this->
const[$r][3] =
'Module to control third parties codes';
86 $this->
const[$r][4] = 0;
89 $this->
const[$r][0] =
"SOCIETE_CODECOMPTA_ADDON";
90 $this->
const[$r][1] =
"chaine";
91 $this->
const[$r][2] =
"mod_codecompta_panicum";
92 $this->
const[$r][3] =
'Module to control third parties codes';
93 $this->
const[$r][4] = 0;
96 $this->
const[$r][0] =
"SOCIETE_FISCAL_MONTH_START";
97 $this->
const[$r][1] =
"chaine";
98 $this->
const[$r][2] =
"0";
99 $this->
const[$r][3] =
"Enter the month number of the first month of the fiscal year, e. g. 9 for September";
100 $this->
const[$r][4] = 0;
103 $this->
const[$r][0] =
"COMPANY_ADDON_PDF_ODT_PATH";
104 $this->
const[$r][1] =
"chaine";
105 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/thirdparties";
106 $this->
const[$r][3] =
"";
107 $this->
const[$r][4] = 0;
119 $this->
const[$r][0] =
"SOCIETE_ADD_REF_IN_LIST";
120 $this->
const[$r][1] =
"yesno";
121 $this->
const[$r][2] =
"0";
122 $this->
const[$r][3] =
"Display customer ref into select list";
123 $this->
const[$r][4] = 0;
127 $this->boxes = array(
128 0 => array(
'file' =>
'box_clients.php',
'enabledbydefaulton' =>
'Home'),
129 1 => array(
'file' =>
'box_prospect.php',
'enabledbydefaulton' =>
'Home'),
130 2 => array(
'file' =>
'box_contacts.php',
'enabledbydefaulton' =>
'Home'),
131 3 => array(
'file' =>
'box_activity.php',
'enabledbydefaulton' =>
'Home',
'note' =>
'(WarningUsingThisBoxSlowDown)'),
132 4 => array(
'file' =>
'box_goodcustomers.php',
'enabledbydefaulton' =>
'Home',
'note' =>
'(WarningUsingThisBoxSlowDown)'),
136 $this->rights = array();
137 $this->rights_class =
'societe';
141 $this->rights[$r][0] = 121;
142 $this->rights[$r][1] =
'Read third parties';
143 $this->rights[$r][2] =
'r';
144 $this->rights[$r][3] = 0;
145 $this->rights[$r][4] =
'lire';
165 $this->rights[$r][0] = 122;
166 $this->rights[$r][1] =
'Create and update third parties';
167 $this->rights[$r][2] =
'w';
168 $this->rights[$r][3] = 0;
169 $this->rights[$r][4] =
'creer';
189 $this->rights[$r][0] = 125;
190 $this->rights[$r][1] =
'Delete third parties';
191 $this->rights[$r][2] =
'd';
192 $this->rights[$r][3] = 0;
193 $this->rights[$r][4] =
'supprimer';
196 $this->rights[$r][0] = 126;
197 $this->rights[$r][1] =
'Export third parties';
198 $this->rights[$r][2] =
'r';
199 $this->rights[$r][3] = 0;
200 $this->rights[$r][4] =
'export';
203 $this->rights[$r][0] = 130;
204 $this->rights[$r][1] =
'Modify thirdparty information payment';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'thirdparty_paymentinformation_advance';
207 $this->rights[$r][5] =
'write';
211 $this->rights[$r][0] = 262;
212 $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).';
213 $this->rights[$r][2] =
'r';
214 $this->rights[$r][3] = 0;
215 $this->rights[$r][4] =
'client';
216 $this->rights[$r][5] =
'voir';
229 $this->rights[$r][0] = 281;
230 $this->rights[$r][1] =
'Read contacts';
231 $this->rights[$r][2] =
'r';
232 $this->rights[$r][3] = 0;
233 $this->rights[$r][4] =
'contact';
234 $this->rights[$r][5] =
'lire';
237 $this->rights[$r][0] = 282;
238 $this->rights[$r][1] =
'Create and update contact';
239 $this->rights[$r][2] =
'w';
240 $this->rights[$r][3] = 0;
241 $this->rights[$r][4] =
'contact';
242 $this->rights[$r][5] =
'creer';
245 $this->rights[$r][0] = 283;
246 $this->rights[$r][1] =
'Delete contacts';
247 $this->rights[$r][2] =
'd';
248 $this->rights[$r][3] = 0;
249 $this->rights[$r][4] =
'contact';
250 $this->rights[$r][5] =
'supprimer';
253 $this->rights[$r][0] = 286;
254 $this->rights[$r][1] =
'Export contacts';
255 $this->rights[$r][2] =
'd';
256 $this->rights[$r][3] = 0;
257 $this->rights[$r][4] =
'contact';
258 $this->rights[$r][5] =
'export';
272 $this->export_code[$r] = $this->rights_class.
'_'.$r;
273 $this->export_label[$r] =
'ExportDataset_company_1';
274 $this->export_icon[$r] =
'company';
275 $this->export_permission[$r] = array(array(
"societe",
"export"));
276 $this->export_fields_array[$r] = array(
277 's.rowid' =>
"Id",
's.nom' =>
"Name",
's.name_alias' =>
"AliasNameShort",
'ps.nom' =>
"ParentCompany",
278 's.status' =>
"Status",
's.client' =>
"Customer",
's.fournisseur' =>
"Supplier",
's.datec' =>
"DateCreation",
's.tms' =>
"DateLastModification",
279 's.code_client' =>
"CustomerCode",
's.code_fournisseur' =>
"SupplierCode",
's.code_compta' =>
"AccountancyCode",
's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
280 '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",
281 '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",
282 's.idprof5' =>
"ProfId5",
's.idprof6' =>
"ProfId6",
's.tva_intra' =>
"VATIntraShort",
's.capital' =>
"Capital",
's.note_private' =>
"NotePrivate",
's.note_public' =>
"NotePublic",
283 't.code' =>
"ThirdPartyType",
'ce.code' =>
"DictionaryStaff",
"cfj.libelle" =>
"JuridicalStatus",
's.fk_prospectlevel' =>
'ProspectLevel',
284 'st.code' =>
'ProspectStatus',
'payterm.libelle' =>
'PaymentConditions',
'paymode.libelle' =>
'PaymentMode',
285 's.outstanding_limit' =>
'OutstandingBill',
'pbacc.ref' =>
'PaymentBankAccount',
'incoterm.code' =>
'IncotermLabel'
288 $this->export_fields_array[$r][
's.prefix'] =
'Prefix';
291 $this->export_fields_array[$r][
's.price_level'] =
'PriceLevel';
294 $this->export_fields_array[$r] += array(
's.accountancy_code_sell' =>
'ProductAccountancySellCode',
's.accountancy_code_buy' =>
'ProductAccountancyBuyCode');
298 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
299 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
300 $this->export_fields_array[$r] += array(
's.entity' =>
'Entity');
303 $keyforselect =
'societe';
304 $keyforelement =
'company';
305 $keyforaliasextra =
'extra';
306 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
307 $this->export_fields_array[$r] += array(
'u.login' =>
'SaleRepresentativeLogin',
'u.firstname' =>
'SaleRepresentativeFirstname',
'u.lastname' =>
'SaleRepresentativeLastname');
309 $this->export_TypeFields_array[$r] = array(
310 's.rowid' =>
"Numeric",
's.nom' =>
"Text",
's.name_alias' =>
"Text",
'ps.nom' =>
"Text",
311 's.status' =>
"Numeric",
's.client' =>
"Numeric",
's.fournisseur' =>
"Boolean",
's.datec' =>
"Date",
's.tms' =>
"Date",
312 's.code_client' =>
"Text",
's.code_fournisseur' =>
"Text",
's.code_compta' =>
"Text",
's.code_compta_fournisseur' =>
"Text",
313 's.address' =>
"Text",
's.zip' =>
"Text",
's.town' =>
"Text",
314 'd.nom' =>
'Text',
'r.nom' =>
'Text',
'c.label' =>
'List:c_country:label:label',
'c.code' =>
'Text',
315 's.phone' =>
"Text",
's.fax' =>
"Text",
316 's.url' =>
"Text",
's.email' =>
"Text",
's.default_lang' =>
"Text",
's.canvas' =>
"Text",
317 's.siret' =>
"Text",
's.siren' =>
"Text",
's.ape' =>
"Text",
's.idprof4' =>
"Text",
's.idprof5' =>
"Text",
's.idprof6' =>
"Text",
318 's.tva_intra' =>
"Text",
's.capital' =>
"Numeric",
319 's.note_private' =>
"Text",
's.note_public' =>
"Text",
320 't.code' =>
"List:c_typent:libelle:code",
321 'ce.code' =>
"List:c_effectif:libelle:code",
322 "cfj.libelle" =>
"Text",
323 's.fk_prospectlevel' =>
'List:c_prospectlevel:label:code',
324 'st.code' =>
'List:c_stcomm:libelle:code',
325 'payterm.libelle' =>
'Text',
'paymode.libelle' =>
'Text',
326 's.outstanding_limit' =>
'Numeric',
'pbacc.ref' =>
'Text',
'incoterm.code' =>
'Text',
327 'u.login' =>
'Text',
'u.firstname' =>
'Text',
'u.lastname' =>
'Text',
328 's.entity' =>
'List:entity:label:rowid',
's.price_level' =>
'Numeric',
329 's.accountancy_code_sell' =>
'Text',
's.accountancy_code_buy' =>
'Text'
332 $this->export_entities_array[$r] = array(
334 'u.firstname' =>
'user',
335 'u.lastname' =>
'user');
336 $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)');
337 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
338 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
339 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extra ON s.rowid = extra.fk_object';
340 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON s.parent = ps.rowid';
341 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
342 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid';
343 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_effectif as ce ON s.fk_effectif = ce.id';
344 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
345 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON s.fk_departement = d.rowid';
346 $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';
347 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcomm as st ON s.fk_stcomm = st.id';
348 $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';
349 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
350 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as paymode ON s.mode_reglement = paymode.id';
351 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as pbacc ON s.fk_account = pbacc.rowid';
352 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';
353 $this->export_sql_end[$r] .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
354 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
355 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
357 $subordinatesids = $user->getAllChildIds();
358 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
360 $this->export_sql_end[$r] .=
')';
365 $this->export_code[$r] = $this->rights_class.
'_'.$r;
366 $this->export_label[$r] =
'ExportDataset_company_2';
367 $this->export_icon[$r] =
'contact';
368 $this->export_permission[$r] = array(array(
"societe",
"contact",
"export"));
369 $this->export_fields_array[$r] = array(
370 'c.rowid' =>
"IdContact",
'c.civility' =>
"CivilityCode",
'c.lastname' =>
'Lastname',
'c.firstname' =>
'Firstname',
'c.poste' =>
'PostOrFunction',
371 'c.datec' =>
"DateCreation",
'c.tms' =>
"DateLastModification",
'c.priv' =>
"ContactPrivate",
'c.address' =>
"Address",
'c.zip' =>
"Zip",
'c.town' =>
"Town",
372 '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",
373 'c.note_private' =>
'NotePrivate',
'c.note_public' =>
"NotePublic",
374 'c.statut' =>
"Status",
375 's.rowid' =>
"IdCompany",
's.nom' =>
"CompanyName",
's.status' =>
"Status",
's.code_client' =>
"CustomerCode",
's.code_fournisseur' =>
"SupplierCode",
376 's.code_compta' =>
"AccountancyCode",
's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
377 's.client' =>
'Customer',
's.fournisseur' =>
'Supplier',
378 's.address' =>
'Address',
's.zip' =>
"Zip",
's.town' =>
"Town",
's.phone' =>
'Phone',
's.email' =>
"Email",
379 's.note_private' =>
'NotePrivate',
's.note_public' =>
"NotePublic",
380 't.code' =>
"ThirdPartyType"
384 if (isModEnabled(
'multicompany')) {
385 $nbofallowedentities = count(explode(
',',
getEntity(
'contact')));
386 if ($nbofallowedentities > 1) {
387 $this->export_fields_array[$r][
'c.entity'] =
'Entity';
390 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
391 if ($nbofallowedentities > 1) {
392 $this->export_fields_array[$r][
's.entity'] =
'Entity';
396 $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)');
397 $this->export_TypeFields_array[$r] = array(
398 'c.civility' =>
"List:c_civility:label:code",
'c.lastname' =>
'Text',
'c.firstname' =>
'Text',
'c.poste' =>
'Text',
'c.datec' =>
"Date",
'c.priv' =>
"Boolean",
399 '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",
400 'c.fax' =>
"Text",
'c.email' =>
"Text",
401 'c.statut' =>
"Status",
402 's.rowid' =>
"Numeric",
's.nom' =>
"Text",
's.status' =>
"Status",
's.code_client' =>
"Text",
's.code_fournisseur' =>
"Text",
403 's.code_compta' =>
"Text",
's.code_compta_fournisseur' =>
"Text",
404 's.client' =>
"Numeric",
's.fournisseur' =>
"Numeric",
405 's.address' =>
"Text",
's.zip' =>
"Text",
's.town' =>
"Text",
's.phone' =>
"Text",
's.email' =>
"Text",
406 't.code' =>
"List:c_stcomm:libelle:code",
407 'c.entity' =>
'List:entity:label:rowid',
408 's.entity' =>
'List:entity:label:rowid',
410 $this->export_entities_array[$r] = array(
411 's.rowid' =>
"company",
's.nom' =>
"company",
's.status' =>
'company',
's.code_client' =>
"company",
's.code_fournisseur' =>
"company",
412 's.code_compta' =>
"company",
's.code_compta_fournisseur' =>
"company",
413 's.client' =>
"company",
's.fournisseur' =>
"company",
414 's.address' =>
"company",
's.zip' =>
"company",
's.town' =>
"company",
's.phone' =>
"company",
's.email' =>
"company",
415 's.note_private' =>
'company',
's.note_public' =>
"company",
416 't.code' =>
"company",
417 's.entity' =>
'company',
419 if (!isModEnabled(
"supplier_order") && !isModEnabled(
"supplier_invoice")) {
420 unset($this->export_fields_array[$r][
's.code_fournisseur']);
421 unset($this->export_entities_array[$r][
's.code_fournisseur']);
423 $keyforselect =
'socpeople';
424 $keyforelement =
'contact';
425 $keyforaliasextra =
'extra';
426 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
427 $keyforselect =
'societe';
428 $keyforelement =
'company';
429 $keyforaliasextra =
'extrasoc';
430 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
431 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
432 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'socpeople as c';
433 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON c.fk_soc = s.rowid';
434 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
435 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
436 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
438 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON c.fk_departement = d.rowid';
439 $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';
440 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON c.fk_pays = co.rowid';
441 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
442 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
443 $this->export_sql_end[$r] .=
' WHERE c.entity IN ('.getEntity(
'contact').
')';
444 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
445 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
447 $subordinatesids = $user->getAllChildIds();
448 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
450 $this->export_sql_end[$r] .=
')';
455 $this->export_code[$r] = $this->rights_class.
'_'.$r;
456 $this->export_label[$r] =
'ExportDataset_company_3';
457 $this->export_icon[$r] =
'account';
459 $this->export_permission[$r] = array(array(
"societe",
"export"), array(
"societe",
"thirdparty_paymentinformation_advance",
"write"));
461 $this->export_permission[$r] = array(array(
"societe",
"export"));
463 $this->export_fields_array[$r] = array(
464 'b.rowid' =>
"IdPaymentMode",
465 'b.fk_soc' =>
"ThirdPartyName",
466 'b.label' =>
'Label',
468 'b.code_banque' =>
'Code banque',
469 'b.code_guichet' =>
'Code guichet',
470 'b.number' =>
'Number',
471 'b.cle_rib' =>
'Cle rib',
473 'b.iban_prefix' =>
'Iban prefix',
474 'b.domiciliation' =>
'Domiciliation',
475 'b.proprio' =>
'Proprio',
476 'b.owner_address' =>
'Owner address',
477 'b.default_rib' =>
'Default rib',
479 'b.date_rum' =>
'Date rum',
480 'b.frstrecur' =>
'Frstrecur',
482 'b.status' =>
"status",
483 'b.datec' =>
"DateCreation",
484 'b.tms' =>
"DateLastModification"
488 if (isModEnabled(
'multicompany')) {
489 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
490 if ($nbofallowedentities > 1) {
491 $this->export_fields_array[$r][
's.entity'] =
'Entity';
495 $this->export_examplevalues_array[$r] = array();
496 $this->export_TypeFields_array[$r] = array(
498 's.entity' =>
"List:entity:label:rowid",
499 'b.rowid' =>
"Numeric",
502 'b.code_banque' =>
'Text',
503 'b.code_guichet' =>
'Text',
504 'b.number' =>
'Text',
505 'b.cle_rib' =>
'Text',
507 'b.iban_prefix' =>
'Text',
508 'b.domiciliation' =>
'Text',
509 'b.proprio' =>
'Text',
510 'b.owner_address' =>
'Text',
511 'b.default_rib' =>
'Boolean"',
513 'b.date_rum' =>
'Date',
514 'b.frstrecur' =>
'Text',
516 'b.status' =>
"Status",
520 $this->export_entities_array[$r] = array(
521 's.nom' =>
"company",
522 's.entity' =>
'company'
524 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
525 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe_rib as b';
526 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON b.fk_soc = s.rowid';
527 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
528 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
530 $this->export_sql_end[$r] .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
531 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
532 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.((int) $user->id).
' ';
534 $subordinatesids = $user->getAllChildIds();
535 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.$this->db->sanitize(implode(
',', $subordinatesids)).
')' :
'';
537 $this->export_sql_end[$r] .=
')';
547 $this->import_code[$r] = $this->rights_class.
'_'.$r;
548 $this->import_label[$r] =
'ImportDataset_company_1';
549 $this->import_icon[$r] =
'company';
550 $this->import_entities_array[$r] = array();
551 $this->import_tables_array[$r] = array(
552 's' => MAIN_DB_PREFIX.
'societe',
553 'extra' => MAIN_DB_PREFIX.
'societe_extrafields'
555 $this->import_fields_array[$r] = array(
556 's.nom' =>
"ThirdPartyName*",
557 's.name_alias' =>
"AliasNameShort",
558 's.parent' =>
"ParentCompany",
559 's.status' =>
"Status*",
560 's.code_client' =>
"CustomerCode",
561 's.code_fournisseur' =>
"SupplierCode",
562 's.code_compta' =>
"CustomerAccountancyCode",
563 's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
564 's.address' =>
"Address",
567 's.fk_departement' =>
"StateCode",
568 's.fk_pays' =>
"CountryCode",
569 's.phone' =>
"Phone",
572 's.email' =>
"Email",
573 's.fk_effectif' =>
"Staff",
574 's.fk_typent' =>
"ThirdPartyType",
575 "s.fk_forme_juridique" =>
"JuridicalStatus",
576 's.siren' =>
"ProfId1",
577 's.siret' =>
"ProfId2",
578 's.ape' =>
"ProfId3",
579 's.idprof4' =>
"ProfId4",
580 's.idprof5' =>
"ProfId5",
581 's.idprof6' =>
"ProfId6",
582 's.tva_intra' =>
"VATIntraShort",
583 's.capital' =>
"Capital",
584 's.fk_stcomm' =>
'ProspectStatus',
585 's.note_private' =>
"NotePrivate",
586 's.note_public' =>
"NotePublic",
587 's.client' =>
"Customer*",
588 's.fournisseur' =>
"Supplier*",
589 's.fk_prospectlevel' =>
'ProspectLevel',
590 's.mode_reglement' =>
'PaymentTypeCustomer',
591 's.cond_reglement' =>
"PaymentTermsCustomer",
592 's.mode_reglement_supplier' =>
'PaymentTypeSupplier',
593 's.cond_reglement_supplier' =>
"PaymentTermsSupplier",
594 's.outstanding_limit' =>
'OutstandingBill',
595 's.fk_account' =>
'PaymentBankAccount',
596 's.fk_incoterms' =>
'IncotermLabel',
597 's.tva_assuj' =>
'VATIsUsed',
598 's.barcode' =>
'BarCode',
599 's.default_lang' =>
'DefaultLanguage',
600 's.canvas' =>
"Canvas",
601 's.datec' =>
"DateCreation",
602 's.fk_multicurrency' =>
'MulticurrencyUsed',
603 's.multicurrency_code' =>
'MulticurrencyCurrency'
606 $this->import_fields_array[$r][
's.price_level'] =
'PriceLevel';
609 $this->import_fields_array[$r] += array(
's.accountancy_code_sell' =>
'ProductAccountancySellCode',
's.accountancy_code_buy' =>
'ProductAccountancyBuyCode');
612 if (isModEnabled(
'socialnetworks')) {
613 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
614 $resql = $this->db->query($sql);
616 while ($obj = $this->db->fetch_object($resql)) {
617 $fieldname =
's.socialnetworks_'.$obj->code;
618 $fieldlabel = ucfirst($obj->label);
619 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
624 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".
$conf->entity.
")";
625 $resql = $this->db->query($sql);
627 while ($obj = $this->db->fetch_object($resql)) {
628 $fieldname =
'extra.'.$obj->name;
629 $fieldlabel = ucfirst($obj->label);
630 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
634 $this->import_fieldshidden_array[$r] = array(
635 's.fk_user_creat' =>
'user->id',
636 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'societe'
638 $this->import_convertvalue_array[$r] = array(
639 's.code_client' => array(
'rule' =>
'getcustomercodeifauto'),
640 's.code_fournisseur' => array(
'rule' =>
'getsuppliercodeifauto'),
641 's.code_compta' => array(
'rule' =>
'getcustomeraccountancycodeifauto'),
642 's.code_compta_fournisseur' => array(
'rule' =>
'getsupplieraccountancycodeifauto'),
643 's.fk_departement' => array(
644 'rule' =>
'fetchidfromcodeid',
645 'classfile' =>
'/core/class/cstate.class.php',
648 'dict' =>
'DictionaryStateCode'
650 's.fk_pays' => array(
651 'rule' =>
'fetchidfromcodeid',
652 'classfile' =>
'/core/class/ccountry.class.php',
653 'class' =>
'Ccountry',
655 'dict' =>
'DictionaryCountry'
657 's.fk_typent' => array(
658 'rule' =>
'fetchidfromcodeorlabel',
659 'classfile' =>
'/core/class/ctypent.class.php',
660 'class' =>
'Ctypent',
662 'dict' =>
'DictionaryCompanyType'
664 's.capital' => array(
'rule' =>
'numeric'),
666 'rule' =>
'fetchidfromref',
667 'file' =>
'/societe/class/societe.class.php',
668 'class' =>
'Societe',
670 'element' =>
'ThirdParty'
672 's.outstanding_limit' => array(
'rule' =>
'numeric'),
673 's.fk_account' => array(
674 'rule' =>
'fetchidfromcodeid',
675 'classfile' =>
'/compta/bank/class/account.class.php',
676 'class' =>
'Account',
678 'element' =>
'BankAccount'
680 's.fk_stcomm' => array(
681 'rule' =>
'fetchidfromcodeid',
682 'classfile' =>
'/core/class/cgenericdic.class.php',
683 'class' =>
'CGenericDic',
685 'dict' =>
'DictionaryProspectStatus',
686 'element' =>
'c_stcomm',
687 'table_element' =>
'c_stcomm'
709 $this->import_regex_array[$r] = array(
710 's.status' =>
'^[0|1]',
711 's.fk_typent' =>
'id@'.MAIN_DB_PREFIX.
'c_typent',
712 's.client' =>
'^[0|1|2|3]',
713 's.fournisseur' =>
'^[0|1]',
714 's.mode_reglement' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
715 's.cond_reglement' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
716 's.mode_reglement_supplier' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
717 's.cond_reglement_supplier' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
718 's.fk_incoterms' =>
'rowid@'.MAIN_DB_PREFIX.
'c_incoterms',
719 's.tva_assuj' =>
'^[0|1]',
720 's.fk_multicurrency' =>
'^[0|1]',
721 '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])?$',
722 's.multicurrency_code' =>
'code_iso@'.MAIN_DB_PREFIX.
'c_currencies'
725 $this->import_examplevalues_array[$r] = array(
726 's.nom' =>
"TPBigCompany",
727 's.name_alias' =>
"Alias for TPBigCompany",
728 's.parent' =>
"TPMotherCompany",
729 's.status' =>
"0 (closed) / 1 (active)",
730 's.code_client' =>
'eg. CU01-0001 / empty / "auto"',
731 's.code_fournisseur' =>
'eg. SU01-0001 / empty / "auto"',
732 's.code_compta' =>
"Code or empty to be auto-created",
733 's.code_compta_fournisseur' =>
"Code or empty to be auto-created",
734 's.address' =>
"61 Jump Street",
736 's.town' =>
"Bigtown",
737 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
738 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
739 's.phone' =>
"eg: +34123456789",
740 's.fax' =>
"eg. +34987654321",
741 's.url' =>
"e.g. https://www.mybigcompany.com",
742 's.email' =>
"e.g. test@mybigcompany.com",
743 's.fk_effectif' =>
"1/2/3/5: represents one of the five ranges of employees",
744 's.fk_typent' =>
'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.
'c_typent"',
745 's.fk_forme_juridique' =>
'1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_forme_juridique"',
752 's.tva_intra' =>
'VAT number e.g."FR0123456789"',
753 's.capital' =>
"10000",
754 's.fk_stcomm' =>
'-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.
'c_stcomm"',
755 's.note_private' =>
"Example of a PRIVATE note.",
756 's.note_public' =>
"Example of a PUBLIC note.",
757 's.client' =>
'0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
758 's.fournisseur' =>
'0 (not supplier) / 1 (supplier)',
759 's.fk_prospectlevel' =>
'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.
'c_prospectlevel"',
760 's.mode_reglement' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
761 's.cond_reglement' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
762 's.mode_reglement_supplier' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
763 's.cond_reglement_supplier' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
764 's.outstanding_limit' =>
"5000",
765 's.fk_account' =>
"rowid or ref",
766 's.fk_incoterms' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_incoterms"',
767 's.tva_assuj' =>
'0 (VAT not used) / 1 (VAT used)',
768 's.barcode' =>
'123456789',
769 's.default_lang' =>
'en_US / es_ES etc...matches a language directory in htdocs/langs/',
770 's.canvas' =>
"empty / a custom canvas form layout url e.g. mycanvas@mymodule",
771 's.datec' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
772 's.fk_multicurrency' =>
'0 (use system default currency) / 1 (use local currency)',
773 's.multicurrency_code' =>
'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.
'c_currencies"',
774 's.accountancy_code_sell' =>
'707',
775 's.accountancy_code_buy' =>
'607',
777 $this->import_updatekeys_array[$r] = array(
778 's.nom' =>
'ThirdPartyName',
780 's.email' =>
'Email',
781 's.code_client' =>
'CustomerCode',
782 's.code_fournisseur' =>
'SupplierCode',
783 's.code_compta' =>
'CustomerAccountancyCode',
784 's.code_compta_fournisseur' =>
'SupplierAccountancyCode'
786 if (isModEnabled(
'socialnetworks')) {
787 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
788 $resql = $this->db->query($sql);
790 while ($obj = $this->db->fetch_object($resql)) {
791 $fieldname =
's.socialnetworks_'.$obj->code;
792 $fieldlabel = ucfirst($obj->label);
793 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
798 $langs->load(
"companies");
802 $this->import_updatekeys_array[$r][
's.siren'] =
'ProfId1'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
805 $this->import_updatekeys_array[$r][
's.siret'] =
'ProfId2'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
808 $this->import_updatekeys_array[$r][
's.ape'] =
'ProfId3'.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
812 if ($langs->trans(
'ProfId'.$i.(empty($mysoc->country_code) ?
'' : $mysoc->country_code)) !=
'-') {
813 $this->import_updatekeys_array[$r][
's.idprof'.$i] =
'ProfId'.$i.(empty($mysoc->country_code) ?
'' : $mysoc->country_code);
821 $this->import_code[$r] = $this->rights_class.
'_'.$r;
822 $this->import_label[$r] =
'ImportDataset_company_2';
823 $this->import_icon[$r] =
'contact';
824 $this->import_entities_array[$r] = array(
's.fk_soc' =>
'company');
825 $this->import_tables_array[$r] = array(
826 's' => MAIN_DB_PREFIX.
'socpeople',
827 'extra' => MAIN_DB_PREFIX.
'socpeople_extrafields'
829 $this->import_fields_array[$r] = array(
831 's.datec' =>
"DateCreation",
832 's.fk_soc' =>
'ThirdPartyName',
833 's.civility' =>
'UserTitle',
834 's.lastname' =>
"Lastname*",
835 's.firstname' =>
"Firstname",
836 's.address' =>
"Address",
839 's.fk_departement' =>
"StateCode",
840 's.fk_pays' =>
"CountryCode",
841 's.birthday' =>
"DateOfBirth",
842 's.poste' =>
"PostOrFunction",
843 's.phone' =>
"Phone",
844 's.phone_perso' =>
"PhonePerso",
845 's.phone_mobile' =>
"PhoneMobile",
847 's.email' =>
"Email",
848 's.note_private' =>
"NotePrivate",
849 's.note_public' =>
"NotePublic"
852 if (isModEnabled(
'socialnetworks')) {
853 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
854 $resql = $this->db->query($sql);
856 while ($obj = $this->db->fetch_object($resql)) {
857 $fieldname =
's.socialnetworks_'.$obj->code;
858 $fieldlabel = ucfirst($obj->label);
859 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
864 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".
$conf->entity.
")";
865 $resql = $this->db->query($sql);
867 while ($obj = $this->db->fetch_object($resql)) {
868 $fieldname =
'extra.'.$obj->name;
869 $fieldlabel = ucfirst($obj->label);
870 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
874 $this->import_fieldshidden_array[$r] = array(
875 's.fk_user_creat' =>
'user->id',
876 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'socpeople'
878 $this->import_convertvalue_array[$r] = array(
880 'rule' =>
'fetchidfromref',
881 'file' =>
'/societe/class/societe.class.php',
882 'class' =>
'Societe',
884 'element' =>
'ThirdParty'
886 's.fk_departement' => array(
887 'rule' =>
'fetchidfromcodeid',
888 'classfile' =>
'/core/class/cstate.class.php',
891 'dict' =>
'DictionaryCanton'
893 's.fk_pays' => array(
894 'rule' =>
'fetchidfromcodeid',
895 'classfile' =>
'/core/class/ccountry.class.php',
896 'class' =>
'Ccountry',
898 'dict' =>
'DictionaryCountry'
902 $this->import_regex_array[$r] = array(
903 's.birthday' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
904 '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])?$'
906 $this->import_examplevalues_array[$r] = array(
909 's.fk_soc' =>
'Third Party name eg. TPBigCompany',
910 's.civility' =>
'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_civility"',
911 's.lastname' =>
"lastname or label",
912 's.firstname' =>
'John',
913 's.address' =>
'61 Jump street',
915 's.town' =>
'Bigtown',
916 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
917 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
918 's.birthday' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
919 's.poste' =>
"Director",
920 's.phone' =>
"5551122",
921 's.phone_perso' =>
"5551133",
922 's.phone_mobile' =>
"5551144",
923 's.fax' =>
"5551155",
924 's.email' =>
"johnsmith@email.com",
925 's.note_private' =>
"My private note",
926 's.note_public' =>
"My public note"
928 $this->import_updatekeys_array[$r] = array(
930 's.lastname' =>
"Lastname",
932 if (isModEnabled(
'socialnetworks')) {
933 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_socialnetworks WHERE active = 1";
934 $resql = $this->db->query($sql);
936 while ($obj = $this->db->fetch_object($resql)) {
937 $fieldname =
's.socialnetworks_'.$obj->code;
938 $fieldlabel = ucfirst($obj->label);
939 $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;
946 $this->import_code[$r] = $this->rights_class.
'_'.$r;
947 $this->import_label[$r] =
"ImportDataset_company_3";
948 $this->import_icon[$r] =
'company';
949 $this->import_entities_array[$r] = array();
950 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_rib');
951 $this->import_fields_array[$r] = array(
952 'sr.label' =>
"Label*",
953 'sr.fk_soc' =>
"ThirdPartyName*",
954 'sr.datec' =>
"DateCreation*",
956 'sr.code_banque' =>
"BankCode",
957 'sr.code_guichet' =>
"DeskCode",
958 'sr.number' =>
"BankAccountNumber",
959 'sr.cle_rib' =>
"BankAccountNumberKey",
961 'sr.iban_prefix' =>
"IBAN",
962 'sr.domiciliation' =>
"BankAccountDomiciliation",
963 'sr.proprio' =>
"BankAccountOwner",
964 'sr.owner_address' =>
"BankAccountOwnerAddress",
965 'sr.default_rib' =>
'Default',
967 'sr.frstrecur' =>
"WithdrawMode",
968 'sr.type' =>
"Type ban is default",
971 $this->import_convertvalue_array[$r] = array(
972 'sr.fk_soc' => array(
973 'rule' =>
'fetchidfromref',
974 'classfile' =>
'/societe/class/societe.class.php',
975 'class' =>
'Societe',
977 'element' =>
'ThirdParty'
980 $this->import_examplevalues_array[$r] = array(
981 'sr.label' =>
'eg. "account1"',
982 'sr.fk_soc' =>
'eg. "TPBigCompany"',
983 'sr.datec' =>
'date used for creating direct debit UMR formatted as '.
dol_print_date(
987 'sr.bank' =>
'bank name eg: "ING-Direct"',
988 'sr.code_banque' =>
'account sort code (GB)/Routing number (US) eg. "8456"',
989 'sr.code_guichet' =>
"bank code for office/branch",
990 'sr.number' =>
'account number eg. "3333333333"',
991 'sr.cle_rib' =>
'account checksum/control digits (if used) eg. "22"',
992 'sr.bic' =>
'bank identifier eg. "USHINGMMXXX"',
993 'sr.iban_prefix' =>
'complete account IBAN eg. "GB78CPBK08925068637123"',
994 'sr.domiciliation' =>
'bank branch address eg. "PARIS"',
995 'sr.proprio' =>
'name on the bank account',
996 'sr.owner_address' =>
'address of account holder',
997 'sr.default_rib' =>
'1 (default account) / 0 (not default)',
998 'sr.rum' =>
'RUM code',
999 'sr.frstrecur' =>
'FRST',
1005 $this->import_code[$r] = $this->rights_class.
'_'.$r;
1006 $this->import_label[$r] =
"ImportDataset_company_4";
1007 $this->import_icon[$r] =
'company';
1008 $this->import_entities_array[$r] = array(
'sr.fk_user' =>
'user');
1009 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_commerciaux');
1010 $this->import_fields_array[$r] = array(
'sr.fk_soc' =>
"ThirdPartyName*",
'sr.fk_user' =>
"User*");
1012 $this->import_convertvalue_array[$r] = array(
1013 'sr.fk_soc' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
1014 'sr.fk_user' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/user/class/user.class.php',
'class' =>
'User',
'method' =>
'fetch',
'element' =>
'User')
1016 $this->import_examplevalues_array[$r] = array(
'sr.fk_soc' =>
"MyBigCompany",
'sr.fk_user' =>
"login");