54 public $errors = array();
69 if (!empty($id) || !empty($ref)) {
87 global $conf, $langs, $db, $user, $mysoc, $canvas;
88 global
$form, $formadmin, $formcompany;
90 if ($action ==
'add' || $action ==
'update') {
94 if ($_GET[
"type"] ==
'f') {
95 $this->
object->fournisseur = 1;
97 if ($_GET[
"type"] ==
'c') {
98 $this->
object->client = 1;
100 if ($_GET[
"type"] ==
'p') {
101 $this->
object->client = 2;
103 if ($_GET[
"type"] ==
'cp') {
104 $this->
object->client = 3;
106 if ($_REQUEST[
"private"] == 1) {
107 $this->
object->particulier = 1;
110 foreach ($this->
object as $key => $value) {
111 $this->tpl[$key] = $value;
115 if (is_array($GLOBALS[
'errors'])) {
119 if ($action ==
'create') {
120 if ($conf->use_javascript_ajax) {
121 $this->tpl[
'ajax_selecttype'] =
"\n".
'<script type="text/javascript">
122 $(document).ready(function () {
123 $("#radiocompany").click(function() {
124 document.formsoc.action.value="create";
125 document.formsoc.canvas.value="company";
126 document.formsoc.private.value=0;
127 document.formsoc.submit();
129 $("#radioprivate").click(function() {
130 document.formsoc.action.value="create";
131 document.formsoc.canvas.value="individual";
132 document.formsoc.private.value=1;
133 document.formsoc.submit();
140 if ($action ==
'create' || $action ==
'edit') {
141 if ($conf->use_javascript_ajax) {
142 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript">
143 $(document).ready(function () {
144 $("#selectcountry_id").change(function() {
145 document.formsoc.action.value="'.$action.
'";
146 document.formsoc.canvas.value="'.$canvas.
'";
147 document.formsoc.submit();
154 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
155 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
156 $module = substr($module, 0,
dol_strlen($module) - 4);
158 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
159 foreach ($dirsociete as $dirroot) {
165 $modCodeClient =
new $module($db);
166 $this->tpl[
'auto_customercode'] = $modCodeClient->code_auto;
168 if ($modCodeClient->code_auto) {
169 $this->tpl[
'prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
174 0 => $langs->trans(
'NorProspectNorCustomer'),
175 1 => $langs->trans(
'Customer'),
176 2 => $langs->trans(
'Prospect'),
177 3 => $langs->trans(
'ProspectCustomer')
178 ), $this->object->client);
181 $this->tpl[
'customercode'] = $this->
object->code_client;
182 if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
183 $this->tpl[
'customercode'] = $modCodeClient->getNextValue($this->
object, 0);
185 $this->tpl[
'ismodifiable_customercode'] = $this->
object->codeclient_modifiable();
186 $s = $modCodeClient->getToolTip($langs, $this->
object, 0);
187 $this->tpl[
'help_customercode'] =
$form->textwithpicto(
'', $s, 1);
190 $this->tpl[
'supplier_enabled'] = 1;
193 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
194 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
195 $module = substr($module, 0,
dol_strlen($module) - 4);
197 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
198 foreach ($dirsociete as $dirroot) {
204 $modCodeFournisseur =
new $module;
205 $this->tpl[
'auto_suppliercode'] = $modCodeFournisseur->code_auto;
207 if ($modCodeFournisseur->code_auto) {
208 $this->tpl[
'prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
212 $this->tpl[
'yn_supplier'] =
$form->selectyesno(
"fournisseur", $this->object->fournisseur, 1);
213 $this->tpl[
'suppliercode'] = $this->
object->code_fournisseur;
214 if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
215 $this->tpl[
'suppliercode'] = $modCodeFournisseur->getNextValue($this->
object, 1);
217 $this->tpl[
'ismodifiable_suppliercode'] = $this->
object->codefournisseur_modifiable();
218 $s = $modCodeFournisseur->getToolTip($langs, $this->
object, 1);
219 $this->tpl[
'help_suppliercode'] =
$form->textwithpicto(
'', $s, 1);
221 $this->
object->LoadSupplierCateg();
222 $this->tpl[
'suppliercategory'] = $this->
object->SupplierCategories;
226 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
229 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
232 $this->
object->country_id = ($this->
object->country_id ? $this->
object->country_id : $mysoc->country_id);
233 $this->
object->country_code = ($this->
object->country_code ? $this->
object->country_code : $mysoc->country_code);
234 $this->tpl[
'select_country'] =
$form->select_country($this->object->country_id,
'country_id');
235 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
238 $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
242 if ($this->object->country_id) {
243 $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
245 $this->tpl[
'select_state'] = $countrynotdefined;
250 $this->tpl[
'select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT),
'default_lang', 0, 0, 1);
254 $this->tpl[
'yn_assujtva'] =
$form->selectyesno(
'assujtva_value', $this->tpl[
'tva_assuj'], 1);
257 $this->tpl[
'select_users'] =
$form->select_dolusers($this->object->commercial_id,
'commercial_id', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
261 if ($mysoc->country_code ==
'ES') {
262 $this->tpl[
'localtax'] =
'';
264 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
265 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td>';
266 $this->tpl[
'localtax'] .=
$form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
267 $this->tpl[
'localtax'] .=
'</td><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td>';
268 $this->tpl[
'localtax'] .=
$form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
269 $this->tpl[
'localtax'] .=
'</td></tr>';
270 } elseif ($mysoc->localtax1_assuj ==
"1") {
271 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td colspan="3">';
272 $this->tpl[
'localtax'] .=
$form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
273 $this->tpl[
'localtax'] .=
'</td><tr>';
274 } elseif ($mysoc->localtax2_assuj ==
"1") {
275 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td colspan="3">';
276 $this->tpl[
'localtax'] .=
$form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
277 $this->tpl[
'localtax'] .=
'</td><tr>';
286 $this->tpl[
'showrefnav'] =
$form->showrefnav($this->
object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
288 $this->tpl[
'checkcustomercode'] = $this->
object->check_codeclient();
289 $this->tpl[
'checksuppliercode'] = $this->
object->check_codefournisseur();
290 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
293 if ($this->object->isInEEC()) {
294 $this->tpl[
'country'] =
$form->textwithpicto(($img ? $img.
' ' :
'').$this->object->country, $langs->trans(
"CountryIsInEEC"), 1, 0);
296 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
298 $this->tpl[
'phone'] =
dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
299 $this->tpl[
'fax'] =
dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id,
'AC_FAX');
300 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
303 $this->tpl[
'tva_assuj'] =
yn($this->object->tva_assuj);
306 $arr = $formcompany->typent_array(1);
307 $this->tpl[
'typent'] = $arr[$this->
object->typent_code];
310 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
313 $langs->load(
"languages");
314 $this->tpl[
'default_lang'] = ($this->default_lang ? $langs->trans(
'Language_'.$this->object->default_lang) :
'');
317 $this->tpl[
'image_edit'] =
img_edit();
319 $this->tpl[
'display_rib'] = $this->
object->display_rib();
322 $this->tpl[
'sales_representatives'] =
'';
323 $listsalesrepresentatives = $this->
object->getSalesRepresentatives($user);
324 $nbofsalesrepresentative = count($listsalesrepresentatives);
325 if ($nbofsalesrepresentative > 3) {
326 $this->tpl[
'sales_representatives'] .= $nbofsalesrepresentative;
327 } elseif ($nbofsalesrepresentative > 0) {
328 $userstatic =
new User($this->
db);
330 foreach ($listsalesrepresentatives as $val) {
331 $userstatic->id = $val[
'id'];
332 $userstatic->lastname = $val[
'name'];
333 $userstatic->firstname = $val[
'firstname'];
334 $this->tpl[
'sales_representatives'] .= $userstatic->getNomUrl(1);
336 if ($i < $nbofsalesrepresentative) {
337 $this->tpl[
'sales_representatives'] .=
', ';
341 $this->tpl[
'sales_representatives'] .= $langs->trans(
"NoSalesRepresentativeAffected");
346 $langs->load(
"members");
348 $result = $adh->fetch(
'',
'', $this->object->id);
350 $adh->ref = $adh->getFullName($langs);
351 $this->tpl[
'linked_member'] = $adh->getNomUrl(1);
353 $this->tpl[
'linked_member'] = $langs->trans(
"ThirdpartyNotLinkedToMember");
359 if ($mysoc->country_code ==
'ES') {
360 $this->tpl[
'localtax'] =
'';
362 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
363 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
364 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax1_assuj).
'</td>';
365 $this->tpl[
'localtax'] .=
'<td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
366 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax2_assuj).
'</td></tr>';
367 } elseif ($mysoc->localtax1_assuj ==
"1") {
368 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
369 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax1_assuj).
'</td></tr>';
370 } elseif ($mysoc->localtax2_assuj ==
"1") {
371 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
372 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax2_assuj).
'</td></tr>';
388 global $langs, $mysoc;
390 $this->
object->id =
GETPOST(
"socid");
391 $this->
object->name =
GETPOST(
"nom");
392 $this->
object->prefix_comm =
GETPOST(
"prefix_comm");
393 $this->
object->client =
GETPOST(
"client");
394 $this->
object->code_client =
GETPOST(
"code_client");
395 $this->
object->fournisseur =
GETPOST(
"fournisseur");
396 $this->
object->code_fournisseur =
GETPOST(
"code_fournisseur");
397 $this->
object->address =
GETPOST(
"adresse");
398 $this->
object->zip =
GETPOST(
"zipcode");
399 $this->
object->town =
GETPOST(
"town");
400 $this->
object->country_id =
GETPOST(
"country_id") ?
GETPOST(
"country_id") : $mysoc->country_id;
401 $this->
object->state_id =
GETPOST(
"state_id");
402 $this->
object->phone =
GETPOST(
"tel");
403 $this->
object->fax =
GETPOST(
"fax");
404 $this->
object->email =
GETPOST(
"email",
'alphawithlgt');
405 $this->
object->url =
GETPOST(
"url");
406 $this->
object->capital =
GETPOST(
"capital");
407 $this->
object->idprof1 =
GETPOST(
"idprof1");
408 $this->
object->idprof2 =
GETPOST(
"idprof2");
409 $this->
object->idprof3 =
GETPOST(
"idprof3");
410 $this->
object->idprof4 =
GETPOST(
"idprof4");
411 $this->
object->typent_id =
GETPOST(
"typent_id");
412 $this->
object->effectif_id =
GETPOST(
"effectif_id");
413 $this->
object->barcode =
GETPOST(
"barcode");
414 $this->
object->forme_juridique_code =
GETPOST(
"forme_juridique_code");
415 $this->
object->default_lang =
GETPOST(
"default_lang");
416 $this->
object->commercial_id =
GETPOST(
"commercial_id");
418 $this->
object->tva_assuj =
GETPOST(
"assujtva_value") ?
GETPOST(
"assujtva_value") : 1;
419 $this->
object->tva_intra =
GETPOST(
"tva_intra");
422 $this->
object->localtax1_assuj =
GETPOST(
"localtax1assuj_value");
423 $this->
object->localtax2_assuj =
GETPOST(
"localtax2assuj_value");
426 if ($this->object->country_id) {
427 $tmparray =
getCountry($this->object->country_id,
'all', $this->db, $langs, 0);
428 $this->
object->country_code = $tmparray[
'code'];
429 $this->
object->country_label = $tmparray[
'label'];
Classe permettant la gestion des tiers par defaut.
getObject($id, $ref='')
Get object from id or ref and save it into this->object.
assign_values(&$action, $id=0, $ref='')
Assign custom values for canvas (for example into this->tpl to be used by templates)
assign_post($action)
Assign POST values into object.
Class to manage members of a foundation.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formated error messages to output (Used to show messages on html output).
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
get_htmloutput_mesg($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0)
Show Url link.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
$conf db
API class for accounts.