30 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
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(5, 4);
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';
202 $this->rights[$r][0] = 262;
203 $this->rights[$r][1] =
'Read all third parties by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).';
204 $this->rights[$r][2] =
'r';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'client';
207 $this->rights[$r][5] =
'voir';
210 $this->rights[$r][0] = 281;
211 $this->rights[$r][1] =
'Read contacts';
212 $this->rights[$r][2] =
'r';
213 $this->rights[$r][3] = 0;
214 $this->rights[$r][4] =
'contact';
215 $this->rights[$r][5] =
'lire';
218 $this->rights[$r][0] = 282;
219 $this->rights[$r][1] =
'Create and update contact';
220 $this->rights[$r][2] =
'w';
221 $this->rights[$r][3] = 0;
222 $this->rights[$r][4] =
'contact';
223 $this->rights[$r][5] =
'creer';
226 $this->rights[$r][0] = 283;
227 $this->rights[$r][1] =
'Delete contacts';
228 $this->rights[$r][2] =
'd';
229 $this->rights[$r][3] = 0;
230 $this->rights[$r][4] =
'contact';
231 $this->rights[$r][5] =
'supprimer';
234 $this->rights[$r][0] = 286;
235 $this->rights[$r][1] =
'Export contacts';
236 $this->rights[$r][2] =
'd';
237 $this->rights[$r][3] = 0;
238 $this->rights[$r][4] =
'contact';
239 $this->rights[$r][5] =
'export';
253 $this->export_code[$r] = $this->rights_class.
'_'.$r;
254 $this->export_label[$r] =
'ExportDataset_company_1';
255 $this->export_icon[$r] =
'company';
256 $this->export_permission[$r] = array(array(
"societe",
"export"));
257 $this->export_fields_array[$r] = array(
258 's.rowid'=>
"Id",
's.nom'=>
"Name",
's.name_alias'=>
"AliasNameShort",
'ps.nom'=>
"ParentCompany",
259 's.status'=>
"Status",
's.client'=>
"Customer",
's.fournisseur'=>
"Supplier",
's.datec'=>
"DateCreation",
's.tms'=>
"DateLastModification",
260 's.code_client'=>
"CustomerCode",
's.code_fournisseur'=>
"SupplierCode",
's.code_compta'=>
"AccountancyCode",
's.code_compta_fournisseur'=>
"SupplierAccountancyCode",
261 '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",
262 '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",
263 's.idprof5'=>
"ProfId5",
's.idprof6'=>
"ProfId6",
's.tva_intra'=>
"VATIntraShort",
's.capital'=>
"Capital",
's.note_private'=>
"NotePrivate",
's.note_public'=>
"NotePublic",
264 't.libelle'=>
"ThirdPartyType",
'ce.code'=>
"Staff",
"cfj.libelle"=>
"JuridicalStatus",
's.fk_prospectlevel'=>
'ProspectLevel',
265 'st.code'=>
'ProspectStatus',
'payterm.libelle'=>
'PaymentConditions',
'paymode.libelle'=>
'PaymentMode',
266 's.outstanding_limit'=>
'OutstandingBill',
'pbacc.ref'=>
'PaymentBankAccount',
'incoterm.code'=>
'IncotermLabel'
268 if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r][
's.prefix'] =
'Prefix';
269 if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r][
's.price_level'] =
'PriceLevel';
271 if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
273 $nbofallowedentities = count(explode(
',',
getEntity(
'societe')));
274 if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array(
's.entity'=>
'Entity');
276 $keyforselect =
'societe'; $keyforelement =
'company'; $keyforaliasextra =
'extra';
277 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
278 $this->export_fields_array[$r] += array(
'u.login'=>
'SaleRepresentativeLogin',
'u.firstname'=>
'SaleRepresentativeFirstname',
'u.lastname'=>
'SaleRepresentativeLastname');
288 $this->export_TypeFields_array[$r] = array(
289 's.rowid'=>
"Numeric",
's.nom'=>
"Text",
's.name_alias'=>
"Text",
'ps.nom'=>
"Text",
290 's.status'=>
"Numeric",
's.client'=>
"Numeric",
's.fournisseur'=>
"Boolean",
's.datec'=>
"Date",
's.tms'=>
"Date",
291 's.code_client'=>
"Text",
's.code_fournisseur'=>
"Text",
's.code_compta'=>
"Text",
's.code_compta_fournisseur'=>
"Text",
292 's.address'=>
"Text",
's.zip'=>
"Text",
's.town'=>
"Text",
293 'd.nom'=>
'Text',
'r.nom'=>
'Text',
'c.label'=>
"List:c_country:label:label",
'c.code'=>
"Text",
294 's.phone'=>
"Text",
's.fax'=>
"Text",
295 's.url'=>
"Text",
's.email'=>
"Text",
's.default_lang'=>
"Text",
's.canvas' =>
"Canvas",
296 's.siret'=>
"Text",
's.siren'=>
"Text",
's.ape'=>
"Text",
's.idprof4'=>
"Text",
's.idprof5'=>
"Text",
's.idprof6'=>
"Text",
297 's.tva_intra'=>
"Text",
's.capital'=>
"Numeric",
's.note_private'=>
"Text",
's.note_public'=>
"Text",
298 't.libelle'=>
"Text",
'ce.code'=>
"List:c_effectif:libelle:code",
"cfj.libelle"=>
"Text",
's.fk_prospectlevel'=>
'List:c_prospectlevel:label:code',
299 'st.code'=>
'List:c_stcomm:libelle:code',
300 'payterm.libelle'=>
'Text',
'paymode.libelle'=>
'Text',
301 's.outstanding_limit'=>
'Numeric',
'pbacc.ref'=>
'Text',
'incoterm.code'=>
'Text',
302 'u.login'=>
'Text',
'u.firstname'=>
'Text',
'u.lastname'=>
'Text',
303 's.entity'=>
'Numeric',
's.price_level'=>
'Numeric'
306 $this->export_entities_array[$r] = array(
'u.login'=>
'user',
'u.firstname'=>
'user',
'u.lastname'=>
'user');
307 $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)');
308 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
309 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
310 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extra ON s.rowid = extra.fk_object';
311 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON s.parent = ps.rowid';
312 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
313 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid';
314 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_effectif as ce ON s.fk_effectif = ce.id';
315 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
316 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON s.fk_departement = d.rowid';
317 $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';
318 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcomm as st ON s.fk_stcomm = st.id';
319 $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';
320 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
321 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as paymode ON s.mode_reglement = paymode.id';
322 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as pbacc ON s.fk_account = pbacc.rowid';
323 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';
324 $this->export_sql_end[$r] .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
325 if (is_object($user) && empty($user->rights->societe->client->voir)) {
326 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.$user->id.
' ';
327 if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
328 $subordinatesids = $user->getAllChildIds();
329 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.implode(
',', $subordinatesids).
')' :
'';
331 $this->export_sql_end[$r] .=
')';
336 $this->export_code[$r] = $this->rights_class.
'_'.$r;
337 $this->export_label[$r] =
'ExportDataset_company_2';
338 $this->export_icon[$r] =
'contact';
339 $this->export_permission[$r] = array(array(
"societe",
"contact",
"export"));
340 $this->export_fields_array[$r] = array(
341 'c.rowid'=>
"IdContact",
'c.civility'=>
"CivilityCode",
'c.lastname'=>
'Lastname',
'c.firstname'=>
'Firstname',
'c.poste'=>
'PostOrFunction',
342 'c.datec'=>
"DateCreation",
'c.tms'=>
"DateLastModification",
'c.priv'=>
"ContactPrivate",
'c.address'=>
"Address",
'c.zip'=>
"Zip",
'c.town'=>
"Town",
343 '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",
344 'c.statut'=>
"Status",
345 's.rowid'=>
"IdCompany",
's.nom'=>
"CompanyName",
's.status'=>
"Status",
's.code_client'=>
"CustomerCode",
's.code_fournisseur'=>
"SupplierCode",
346 's.code_compta'=>
"AccountancyCode",
's.code_compta_fournisseur'=>
"SupplierAccountancyCode",
347 's.client'=>
'Customer',
's.fournisseur'=>
'Supplier',
348 's.address'=>
'Address',
's.zip'=>
"Zip",
's.town'=>
"Town",
's.phone'=>
'Phone',
's.email'=>
"Email",
349 't.libelle'=>
"ThirdPartyType"
351 $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)');
352 $this->export_TypeFields_array[$r] = array(
353 'c.civility'=>
"List:c_civility:label:code",
'c.lastname'=>
'Text',
'c.firstname'=>
'Text',
'c.poste'=>
'Text',
'c.datec'=>
"Date",
'c.priv'=>
"Boolean",
354 '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",
355 'c.fax'=>
"Text",
'c.email'=>
"Text",
356 'c.statut'=>
"Status",
357 's.rowid'=>
"List:societe:nom::thirdparty",
's.nom'=>
"Text",
's.status'=>
"Status",
's.code_client'=>
"Text",
's.code_fournisseur'=>
"Text",
358 's.code_compta'=>
"Text",
's.code_compta_fournisseur'=>
"Text",
359 's.client'=>
"Text",
's.fournisseur'=>
"Text",
360 's.address'=>
"Text",
's.zip'=>
"Text",
's.town'=>
"Text",
's.phone'=>
"Text",
's.email'=>
"Text",
363 $this->export_entities_array[$r] = array(
364 's.rowid'=>
"company",
's.nom'=>
"company",
's.status'=>
'company',
's.code_client'=>
"company",
's.code_fournisseur'=>
"company",
365 's.code_compta'=>
"company",
's.code_compta_fournisseur'=>
"company",
366 's.client'=>
"company",
's.fournisseur'=>
"company",
367 's.address'=>
"company",
's.zip'=>
"company",
's.town'=>
"company",
's.phone'=>
"company",
's.email'=>
"company",
368 't.libelle'=>
"company"
370 if (empty($conf->fournisseur->enabled))
372 unset($this->export_fields_array[$r][
's.code_fournisseur']);
373 unset($this->export_entities_array[$r][
's.code_fournisseur']);
375 $keyforselect =
'socpeople'; $keyforelement =
'contact'; $keyforaliasextra =
'extra';
376 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
377 $keyforselect =
'societe'; $keyforelement =
'company'; $keyforaliasextra =
'extrasoc';
378 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
379 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
380 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'socpeople as c';
381 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON c.fk_soc = s.rowid';
382 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
383 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
384 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON c.fk_departement = d.rowid';
385 $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';
386 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON c.fk_pays = co.rowid';
387 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
388 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
389 $this->export_sql_end[$r] .=
' WHERE c.entity IN ('.getEntity(
'socpeople').
')';
390 if (is_object($user) && empty($user->rights->societe->client->voir)) {
391 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.$user->id.
' ';
392 if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
393 $subordinatesids = $user->getAllChildIds();
394 $this->export_sql_end[$r] .= count($subordinatesids) > 0 ?
' OR (sc.fk_user IN ('.implode(
',', $subordinatesids).
')' :
'';
396 $this->export_sql_end[$r] .=
')';
407 $this->import_code[$r] = $this->rights_class.
'_'.$r;
408 $this->import_label[$r] =
'ImportDataset_company_1';
409 $this->import_icon[$r] =
'company';
410 $this->import_entities_array[$r] = array();
411 $this->import_tables_array[$r] = array(
412 's' => MAIN_DB_PREFIX.
'societe',
413 'extra' => MAIN_DB_PREFIX.
'societe_extrafields'
415 $this->import_fields_array[$r] = array(
417 's.name_alias' =>
"AliasNameShort",
418 's.parent' =>
"ParentCompany",
419 's.status' =>
"Status",
420 's.code_client' =>
"CustomerCode",
421 's.code_fournisseur' =>
"SupplierCode",
422 's.code_compta' =>
"CustomerAccountancyCode",
423 's.code_compta_fournisseur' =>
"SupplierAccountancyCode",
424 's.address' =>
"Address",
427 's.fk_departement' =>
"StateCode",
428 's.fk_pays' =>
"CountryCode",
429 's.phone' =>
"Phone",
432 's.email' =>
"Email",
433 's.skype' =>
"Skype",
434 's.fk_effectif' =>
"Staff",
435 's.fk_typent' =>
"ThirdPartyType",
436 "s.fk_forme_juridique" =>
"JuridicalStatus",
437 's.siren' =>
"ProfId1",
438 's.siret' =>
"ProfId2",
439 's.ape' =>
"ProfId3",
440 's.idprof4' =>
"ProfId4",
441 's.idprof5' =>
"ProfId5",
442 's.idprof6' =>
"ProfId6",
443 's.tva_intra' =>
"VATIntraShort",
444 's.capital' =>
"Capital",
445 's.fk_stcomm' =>
'ProspectStatus',
446 's.note_private' =>
"NotePrivate",
447 's.note_public' =>
"NotePublic",
448 's.client' =>
"Customer*",
449 's.fournisseur' =>
"Supplier*",
450 's.fk_prospectlevel' =>
'ProspectLevel',
451 's.mode_reglement' =>
'PaymentTypeCustomer',
452 's.cond_reglement' =>
"PaymentTermsCustomer",
453 's.mode_reglement_supplier' =>
'PaymentTypeSupplier',
454 's.cond_reglement_supplier' =>
"PaymentTermsSupplier",
455 's.outstanding_limit'=>
'OutstandingBill',
456 's.fk_account'=>
'PaymentBankAccount',
457 's.fk_incoterms'=>
'IncotermLabel',
458 's.tva_assuj' =>
'VATIsUsed',
459 's.barcode' =>
'BarCode',
460 's.default_lang' =>
'DefaultLanguage',
461 's.canvas' =>
"Canvas",
462 's.datec' =>
"DateCreation",
463 's.fk_multicurrency' =>
'MulticurrencyUsed',
464 's.multicurrency_code' =>
'MulticurrencyCurrency'
466 if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r][
's.price_level'] =
'PriceLevel';
468 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.
")";
472 while ($obj = $this->
db->fetch_object(
$resql)) {
473 $fieldname =
'extra.'.$obj->name;
474 $fieldlabel = ucfirst($obj->label);
475 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
479 $this->import_fieldshidden_array[$r] = array(
480 's.fk_user_creat' =>
'user->id',
481 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'societe'
483 $this->import_convertvalue_array[$r] = array(
484 's.code_client' => array(
'rule' =>
'getcustomercodeifauto'),
485 's.code_fournisseur' => array(
'rule' =>
'getsuppliercodeifauto'),
486 's.code_compta' => array(
'rule' =>
'getcustomeraccountancycodeifauto'),
487 's.code_compta_fournisseur' => array(
'rule' =>
'getsupplieraccountancycodeifauto'),
488 's.fk_departement' => array(
489 'rule' =>
'fetchidfromcodeid',
490 'classfile' =>
'/core/class/cstate.class.php',
493 'dict' =>
'DictionaryStateCode'
495 's.fk_pays' => array(
496 'rule' =>
'fetchidfromcodeid',
497 'classfile' =>
'/core/class/ccountry.class.php',
498 'class' =>
'Ccountry',
500 'dict' =>
'DictionaryCountry'
502 's.fk_typent' => array(
503 'rule' =>
'fetchidfromcodeorlabel',
504 'classfile' =>
'/core/class/ctypent.class.php',
505 'class' =>
'Ctypent',
507 'dict' =>
'DictionaryCompanyType'
509 's.capital' => array(
'rule' =>
'numeric'),
510 's.fk_stcomm' => array(
'rule' =>
'zeroifnull'),
512 'rule' =>
'fetchidfromref',
513 'file' =>
'/societe/class/societe.class.php',
514 'class' =>
'Societe',
516 'element' =>
'ThirdParty'
518 's.outstanding_limit' => array(
'rule' =>
'numeric'),
519 's.fk_account' => array(
520 'rule' =>
'fetchidfromcodeid',
521 'classfile' =>
'/compta/bank/class/account.class.php',
522 'class' =>
'Account',
524 'element' =>
'BankAccount'
536 $this->import_regex_array[$r] = array(
537 's.status' =>
'^[0|1]',
538 's.fk_typent' =>
'id@'.MAIN_DB_PREFIX.
'c_typent',
539 's.client' =>
'^[0|1|2|3]',
540 's.fournisseur' =>
'^[0|1]',
541 's.mode_reglement' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
542 's.cond_reglement' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
543 's.mode_reglement_supplier' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement',
544 's.cond_reglement_supplier' =>
'rowid@'.MAIN_DB_PREFIX.
'c_payment_term',
545 's.fk_incoterms' =>
'rowid@'.MAIN_DB_PREFIX.
'c_incoterms',
546 's.tva_assuj' =>
'^[0|1]',
547 's.fk_multicurrency' =>
'^[0|1]',
548 '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])?$',
549 's.multicurrency_code' =>
'code_iso@'.MAIN_DB_PREFIX.
'c_currencies'
552 $this->import_examplevalues_array[$r] = array(
553 's.nom' =>
"TPBigCompany",
554 's.name_alias' =>
"Alias for TPBigCompany",
555 's.parent' =>
"TPMotherCompany",
556 's.status' =>
"0 (closed) / 1 (active)",
557 's.code_client' =>
'eg. CU01-0001 / empty / "auto"',
558 's.code_fournisseur' =>
'eg. SU01-0001 / empty / "auto"',
559 's.code_compta' =>
"Code or empty to be auto-created",
560 's.code_compta_fournisseur' =>
"Code or empty to be auto-created",
561 's.address' =>
"61 Jump Street",
563 's.town' =>
"Bigtown",
564 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
565 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
566 's.phone' =>
"eg: +34123456789",
567 's.fax' =>
"eg. +34987654321",
568 's.url' =>
"e.g. https://www.mybigcompany.com",
569 's.email' =>
"e.g. test@mybigcompany.com",
570 's.skype' =>
"Skype name",
571 's.fk_effectif' =>
"1/2/3/5: represents one of the five ranges of employees",
572 's.fk_typent' =>
'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.
'c_typent"',
573 's.fk_forme_juridique' =>
'1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_forme_juridique"',
580 's.tva_intra' =>
'VAT number e.g."FR0123456789"',
581 's.capital' =>
"10000",
582 's.fk_stcomm' =>
'-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.
'c_stcomm"',
583 's.note_private' =>
"Example of a PRIVATE note.",
584 's.note_public' =>
"Example of a PUBLIC note.",
585 's.client' =>
'0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
586 's.fournisseur' =>
'0 (not supplier) / 1 (supplier)',
587 's.fk_prospectlevel' =>
'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.
'c_prospectlevel"',
588 's.mode_reglement' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
589 's.cond_reglement' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
590 's.mode_reglement_supplier' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
591 's.cond_reglement_supplier' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_payment_term"',
592 's.outstanding_limit' =>
"5000",
593 's.fk_account' =>
"rowid or ref",
594 's.fk_incoterms' =>
'1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.
'c_incoterms"',
595 's.tva_assuj' =>
'0 (VAT not used) / 1 (VAT used)',
596 's.barcode' =>
'123456789',
597 's.default_lang' =>
'en_US / es_ES etc...matches a language directory in htdocs/langs/',
598 's.canvas' =>
"empty / a custom canvas form layout url e.g. mycanvas@mymodule",
599 's.datec' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
600 's.fk_multicurrency' =>
'0 (use system default currency) / 1 (use local currency)',
601 's.multicurrency_code' =>
'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.
'c_currencies"'
603 $this->import_updatekeys_array[$r] = array(
605 's.code_client' =>
'CustomerCode',
606 's.code_fournisseur' =>
'SupplierCode',
607 's.code_compta' =>
'CustomerAccountancyCode',
608 's.code_compta_fournisseur' =>
'SupplierAccountancyCode'
613 $this->import_code[$r] = $this->rights_class.
'_'.$r;
614 $this->import_label[$r] =
'ImportDataset_company_2';
615 $this->import_icon[$r] =
'contact';
616 $this->import_entities_array[$r] = array(
's.fk_soc' =>
'company');
617 $this->import_tables_array[$r] = array(
618 's' => MAIN_DB_PREFIX.
'socpeople',
619 'extra' => MAIN_DB_PREFIX.
'socpeople_extrafields'
621 $this->import_fields_array[$r] = array(
623 's.datec' =>
"DateCreation",
624 's.fk_soc' =>
'ThirdPartyName',
625 's.civility' =>
'UserTitle',
626 's.lastname' =>
"Lastname*",
627 's.firstname' =>
"Firstname",
628 's.address' =>
"Address",
631 's.fk_departement' =>
"StateCode",
632 's.fk_pays' =>
"CountryCode",
633 's.birthday' =>
"DateOfBirth",
635 's.phone' =>
"Phone",
636 's.phone_perso' =>
"PhonePerso",
637 's.phone_mobile' =>
"PhoneMobile",
639 's.email' =>
"Email",
640 's.skype' =>
"Skype",
641 's.note_private' =>
"NotePrivate",
642 's.note_public' =>
"NotePublic"
645 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.
")";
649 while ($obj = $this->
db->fetch_object(
$resql)) {
650 $fieldname =
'extra.'.$obj->name;
651 $fieldlabel = ucfirst($obj->label);
652 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
656 $this->import_fieldshidden_array[$r] = array(
657 's.fk_user_creat' =>
'user->id',
658 'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'socpeople'
660 $this->import_convertvalue_array[$r] = array(
662 'rule' =>
'fetchidfromref',
663 'file' =>
'/societe/class/societe.class.php',
664 'class' =>
'Societe',
666 'element' =>
'ThirdParty'
668 's.fk_departement' => array(
669 'rule' =>
'fetchidfromcodeid',
670 'classfile' =>
'/core/class/cstate.class.php',
673 'dict' =>
'DictionaryStateCode'
675 's.fk_pays' => array(
676 'rule' =>
'fetchidfromcodeid',
677 'classfile' =>
'/core/class/ccountry.class.php',
678 'class' =>
'Ccountry',
680 'dict' =>
'DictionaryCountry'
684 $this->import_regex_array[$r] = array(
685 's.birthday' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
686 '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])?$'
688 $this->import_examplevalues_array[$r] = array(
691 's.fk_soc' =>
'Third Party name eg. TPBigCompany',
692 's.civility' =>
'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.
'c_civility"',
693 's.lastname' =>
"lastname or label",
694 's.firstname' =>
'John',
695 's.address' =>
'61 Jump street',
697 's.town' =>
'Bigtown',
698 's.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
699 's.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
700 's.birthday' =>
'formatted as '.dol_print_date(
dol_now(),
'%Y-%m-%d'),
701 's.poste' =>
"Director",
702 's.phone' =>
"5551122",
703 's.phone_perso' =>
"5551133",
704 's.phone_mobile' =>
"5551144",
705 's.fax' =>
"5551155",
706 's.email' =>
"johnsmith@email.com",
707 's.skype' =>
"skype username",
708 's.note_private' =>
"My private note",
709 's.note_public' =>
"My public note"
711 $this->import_updatekeys_array[$r] = array(
717 $this->import_code[$r] = $this->rights_class.
'_'.$r;
718 $this->import_label[$r] =
"ImportDataset_company_3";
719 $this->import_icon[$r] =
'company';
720 $this->import_entities_array[$r] = array();
721 $this->import_tables_array[$r] = array(
'sr' => MAIN_DB_PREFIX.
'societe_rib');
722 $this->import_fields_array[$r] = array(
723 'sr.label' =>
"Label*",
724 'sr.fk_soc' =>
"ThirdPartyName*",
725 'sr.datec' =>
"DateCreation*",
727 'sr.code_banque' =>
"BankCode",
728 'sr.code_guichet' =>
"DeskCode",
729 'sr.number' =>
"BankAccountNumber*",
730 'sr.cle_rib' =>
"BankAccountNumberKey",
732 'sr.iban_prefix' =>
"IBAN",
733 'sr.domiciliation' =>
"BankAccountDomiciliation",
734 'sr.proprio' =>
"BankAccountOwner",
735 'sr.owner_address' =>
"BankAccountOwnerAddress",
736 'sr.default_rib' =>
'Default',
738 'sr.type' =>
"Type ban is defaut",
741 $this->import_convertvalue_array[$r] = array(
742 'sr.fk_soc' => array(
743 'rule' =>
'fetchidfromref',
744 'classfile' =>
'/societe/class/societe.class.php',
745 'class' =>
'Societe',
747 'element' =>
'ThirdParty'
750 $this->import_examplevalues_array[$r] = array(
751 'sr.label' =>
'eg. "account1"',
752 'sr.fk_soc' =>
'eg. "TPBigCompany"',
755 'sr.bank' =>
'bank name eg: "ING-Direct"',
756 'sr.code_banque' =>
'account sort code (GB)/Routing number (US) eg. "8456"',
757 'sr.code_guichet' =>
"bank code for office/branch",
758 'sr.number' =>
'account number eg. "3333333333"',
759 'sr.cle_rib' =>
'account checksum/control digits (if used) eg. "22"',
760 'sr.bic' =>
'bank identifier eg. "USHINGMMXXX"',
761 'sr.iban_prefix' =>
'complete account IBAN eg. "GB78CPBK08925068637123"',
762 'sr.domiciliation' =>
'bank branch address eg. "PARIS"',
763 'sr.proprio' =>
'name on the bank account',
764 'sr.owner_address' =>
'address of account holder',
765 'sr.default_rib' =>
'1 (default account) / 0 (not default)',
766 'sr.rum' =>
'RUM code',
772 $this->import_code[$r] = $this->rights_class.
'_'.$r;
773 $this->import_label[$r] =
"ImportDataset_company_4";
774 $this->import_icon[$r] =
'company';
775 $this->import_entities_array[$r] = array(
'sr.fk_user'=>
'user');
776 $this->import_tables_array[$r] = array(
'sr'=>MAIN_DB_PREFIX.
'societe_commerciaux');
777 $this->import_fields_array[$r] = array(
'sr.fk_soc'=>
"ThirdPartyName*",
'sr.fk_user'=>
"User*");
779 $this->import_convertvalue_array[$r] = array(
780 'sr.fk_soc'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/societe/class/societe.class.php',
'class'=>
'Societe',
'method'=>
'fetch',
'element'=>
'ThirdParty'),
781 'sr.fk_user'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/user/class/user.class.php',
'class'=>
'User',
'method'=>
'fetch',
'element'=>
'User')
783 $this->import_examplevalues_array[$r] = array(
'sr.fk_soc'=>
"MyBigCompany",
'sr.fk_user'=>
"login");
795 public function init($options =
'')
797 global $conf, $langs;
803 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/thirdparties/template_thirdparty.odt';
804 $dirodt = DOL_DATA_ROOT.
'/doctemplates/thirdparties';
805 $dest = $dirodt.
'/template_thirdparty.odt';
807 if (file_exists($src) && !file_exists($dest))
809 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
811 $result =
dol_copy($src, $dest, 0, 0);
814 $langs->load(
"errors");
815 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
822 return $this->
_init($sql, $options);
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
init($options= '')
Function called when module is enabled.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode= 'auto')
Return date for now.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to describe and enable module Societe.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
_init($array_sql, $options= '')
Enables a module.
__construct($db)
Constructor.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)