54 public $errors = array();
69 if (!empty($id) || !empty($ref))
$object->fetch($id, $ref);
85 global $conf, $langs, $db, $user, $mysoc, $canvas;
86 global $form, $formadmin, $formcompany;
88 if ($action ==
'add' || $action ==
'update') $this->
assign_post($action);
90 if ($_GET[
"type"] ==
'f') { $this->
object->fournisseur = 1; }
91 if ($_GET[
"type"] ==
'c') { $this->
object->client = 1; }
92 if ($_GET[
"type"] ==
'p') { $this->
object->client = 2; }
93 if ($_GET[
"type"] ==
'cp') { $this->
object->client = 3; }
94 if ($_REQUEST[
"private"] == 1) { $this->
object->particulier = 1; }
96 foreach ($this->
object as $key => $value)
98 $this->tpl[$key] = $value;
102 if (is_array($GLOBALS[
'errors'])) $this->tpl[
'error'] =
get_htmloutput_mesg(
'', $GLOBALS[
'errors'],
'error');
104 if ($action ==
'create')
106 if ($conf->use_javascript_ajax)
108 $this->tpl[
'ajax_selecttype'] =
"\n".
'<script type="text/javascript" language="javascript">
109 $(document).ready(function () {
110 $("#radiocompany").click(function() {
111 document.formsoc.action.value="create";
112 document.formsoc.canvas.value="company";
113 document.formsoc.private.value=0;
114 document.formsoc.submit();
116 $("#radioprivate").click(function() {
117 document.formsoc.action.value="create";
118 document.formsoc.canvas.value="individual";
119 document.formsoc.private.value=1;
120 document.formsoc.submit();
127 if ($action ==
'create' || $action ==
'edit')
129 if ($conf->use_javascript_ajax)
131 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript" language="javascript">
132 $(document).ready(function () {
133 $("#selectcountry_id").change(function() {
134 document.formsoc.action.value="'.$action.
'";
135 document.formsoc.canvas.value="'.$canvas.
'";
136 document.formsoc.submit();
143 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
144 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php')
146 $module = substr($module, 0,
dol_strlen($module) - 4);
148 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
149 foreach ($dirsociete as $dirroot)
154 $modCodeClient =
new $module($db);
155 $this->tpl[
'auto_customercode'] = $modCodeClient->code_auto;
157 if ($modCodeClient->code_auto) $this->tpl[
'prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
161 0 => $langs->trans(
'NorProspectNorCustomer'),
162 1 => $langs->trans(
'Customer'),
163 2 => $langs->trans(
'Prospect'),
164 3 => $langs->trans(
'ProspectCustomer')
165 ), $this->object->client);
168 $this->tpl[
'customercode'] = $this->
object->code_client;
169 if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl[
'customercode'] = $modCodeClient->getNextValue($this->
object, 0);
170 $this->tpl[
'ismodifiable_customercode'] = $this->
object->codeclient_modifiable();
171 $s = $modCodeClient->getToolTip($langs, $this->
object, 0);
172 $this->tpl[
'help_customercode'] = $form->textwithpicto(
'', $s, 1);
174 if (!empty($conf->fournisseur->enabled))
176 $this->tpl[
'supplier_enabled'] = 1;
179 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
180 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php')
182 $module = substr($module, 0,
dol_strlen($module) - 4);
184 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
185 foreach ($dirsociete as $dirroot)
190 $modCodeFournisseur =
new $module;
191 $this->tpl[
'auto_suppliercode'] = $modCodeFournisseur->code_auto;
193 if ($modCodeFournisseur->code_auto) $this->tpl[
'prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
196 $this->tpl[
'yn_supplier'] = $form->selectyesno(
"fournisseur", $this->object->fournisseur, 1);
197 $this->tpl[
'suppliercode'] = $this->
object->code_fournisseur;
198 if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl[
'suppliercode'] = $modCodeFournisseur->getNextValue($this->
object, 1);
199 $this->tpl[
'ismodifiable_suppliercode'] = $this->
object->codefournisseur_modifiable();
200 $s = $modCodeFournisseur->getToolTip($langs, $this->
object, 1);
201 $this->tpl[
'help_suppliercode'] = $form->textwithpicto(
'', $s, 1);
203 $this->
object->LoadSupplierCateg();
204 $this->tpl[
'suppliercategory'] = $this->
object->SupplierCategories;
208 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
211 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
214 $this->
object->country_id = ($this->
object->country_id ? $this->
object->country_id : $mysoc->country_id);
215 $this->
object->country_code = ($this->
object->country_code ? $this->
object->country_code : $mysoc->country_code);
216 $this->tpl[
'select_country'] = $form->select_country($this->object->country_id,
'country_id');
217 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
219 if ($user->admin) $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
222 if ($this->object->country_id) $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
223 else $this->tpl[
'select_state'] = $countrynotdefined;
226 if (!empty($conf->global->MAIN_MULTILANGS)) $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);
229 $this->tpl[
'yn_assujtva'] = $form->selectyesno(
'assujtva_value', $this->tpl[
'tva_assuj'], 1);
232 $this->tpl[
'select_users'] = $form->select_dolusers($this->object->commercial_id,
'commercial_id', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
236 if ($mysoc->country_code ==
'ES')
238 $this->tpl[
'localtax'] =
'';
240 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1")
242 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td>';
243 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
244 $this->tpl[
'localtax'] .=
'</td><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td>';
245 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
246 $this->tpl[
'localtax'] .=
'</td></tr>';
247 } elseif ($mysoc->localtax1_assuj ==
"1")
249 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td colspan="3">';
250 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
251 $this->tpl[
'localtax'] .=
'</td><tr>';
252 } elseif ($mysoc->localtax2_assuj ==
"1")
254 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td colspan="3">';
255 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
256 $this->tpl[
'localtax'] .=
'</td><tr>';
265 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
267 $this->tpl[
'checkcustomercode'] = $this->
object->check_codeclient();
268 $this->tpl[
'checksuppliercode'] = $this->
object->check_codefournisseur();
269 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
272 if ($this->object->isInEEC()) $this->tpl[
'country'] = $form->textwithpicto(($img ? $img.
' ' :
'').$this->object->country, $langs->trans(
"CountryIsInEEC"), 1, 0);
273 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
275 $this->tpl[
'phone'] =
dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
276 $this->tpl[
'fax'] =
dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id,
'AC_FAX');
277 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
280 $this->tpl[
'tva_assuj'] =
yn($this->object->tva_assuj);
283 $arr = $formcompany->typent_array(1);
284 $this->tpl[
'typent'] = $arr[$this->
object->typent_code];
286 if (!empty($conf->global->MAIN_MULTILANGS))
288 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
291 $langs->load(
"languages");
292 $this->tpl[
'default_lang'] = ($this->default_lang ? $langs->trans(
'Language_'.$this->object->default_lang) :
'');
295 $this->tpl[
'image_edit'] =
img_edit();
297 $this->tpl[
'display_rib'] = $this->
object->display_rib();
300 $this->tpl[
'sales_representatives'] =
'';
301 $listsalesrepresentatives = $this->
object->getSalesRepresentatives($user);
302 $nbofsalesrepresentative = count($listsalesrepresentatives);
303 if ($nbofsalesrepresentative > 3)
305 $this->tpl[
'sales_representatives'] .= $nbofsalesrepresentative;
306 } elseif ($nbofsalesrepresentative > 0)
308 $userstatic =
new User($this->
db);
310 foreach ($listsalesrepresentatives as $val)
312 $userstatic->id = $val[
'id'];
313 $userstatic->lastname = $val[
'name'];
314 $userstatic->firstname = $val[
'firstname'];
315 $this->tpl[
'sales_representatives'] .= $userstatic->getNomUrl(1);
317 if ($i < $nbofsalesrepresentative) $this->tpl[
'sales_representatives'] .=
', ';
319 }
else $this->tpl[
'sales_representatives'] .= $langs->trans(
"NoSalesRepresentativeAffected");
322 if (!empty($conf->adherent->enabled))
324 $langs->load(
"members");
326 $result = $adh->fetch(
'',
'', $this->object->id);
329 $adh->ref = $adh->getFullName($langs);
330 $this->tpl[
'linked_member'] = $adh->getNomUrl(1);
332 $this->tpl[
'linked_member'] = $langs->trans(
"ThirdpartyNotLinkedToMember");
338 if ($mysoc->country_code ==
'ES')
340 $this->tpl[
'localtax'] =
'';
342 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1")
344 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
345 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax1_assuj).
'</td>';
346 $this->tpl[
'localtax'] .=
'<td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
347 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax2_assuj).
'</td></tr>';
348 } elseif ($mysoc->localtax1_assuj ==
"1")
350 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
351 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax1_assuj).
'</td></tr>';
352 } elseif ($mysoc->localtax2_assuj ==
"1")
354 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
355 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax2_assuj).
'</td></tr>';
371 global $langs, $mysoc;
373 $this->
object->id = $_POST[
"socid"];
374 $this->
object->name = $_POST[
"nom"];
375 $this->
object->prefix_comm = $_POST[
"prefix_comm"];
376 $this->
object->client = $_POST[
"client"];
377 $this->
object->code_client = $_POST[
"code_client"];
378 $this->
object->fournisseur = $_POST[
"fournisseur"];
379 $this->
object->code_fournisseur = $_POST[
"code_fournisseur"];
380 $this->
object->address = $_POST[
"adresse"];
381 $this->
object->zip = $_POST[
"zipcode"];
382 $this->
object->town = $_POST[
"town"];
383 $this->
object->country_id = $_POST[
"country_id"] ? $_POST[
"country_id"] : $mysoc->country_id;
384 $this->
object->state_id = $_POST[
"state_id"];
385 $this->
object->phone = $_POST[
"tel"];
386 $this->
object->fax = $_POST[
"fax"];
387 $this->
object->email = $_POST[
"email"];
388 $this->
object->url = $_POST[
"url"];
389 $this->
object->capital = $_POST[
"capital"];
390 $this->
object->idprof1 = $_POST[
"idprof1"];
391 $this->
object->idprof2 = $_POST[
"idprof2"];
392 $this->
object->idprof3 = $_POST[
"idprof3"];
393 $this->
object->idprof4 = $_POST[
"idprof4"];
394 $this->
object->typent_id = $_POST[
"typent_id"];
395 $this->
object->effectif_id = $_POST[
"effectif_id"];
396 $this->
object->barcode = $_POST[
"barcode"];
397 $this->
object->forme_juridique_code = $_POST[
"forme_juridique_code"];
398 $this->
object->default_lang = $_POST[
"default_lang"];
399 $this->
object->commercial_id = $_POST[
"commercial_id"];
401 $this->
object->tva_assuj = $_POST[
"assujtva_value"] ? $_POST[
"assujtva_value"] : 1;
402 $this->
object->tva_intra = $_POST[
"tva_intra"];
405 $this->
object->localtax1_assuj = $_POST[
"localtax1assuj_value"];
406 $this->
object->localtax2_assuj = $_POST[
"localtax2assuj_value"];
409 if ($this->object->country_id)
411 $tmparray =
getCountry($this->object->country_id,
'all', $this->db, $langs, 0);
412 $this->
object->country_code = $tmparray[
'code'];
413 $this->
object->country_label = $tmparray[
'label'];
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
assign_values(&$action, $id=0, $ref= '')
Assign custom values for canvas (for example into this->tpl to be used by templates) ...
Classe permettant la gestion des tiers par defaut.
Class to manage Dolibarr users.
get_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Get formated error 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.
assign_post($action)
Assign POST values into object.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
$conf db
API class for accounts.
Class to manage third parties objects (customers, suppliers, prospects...)
get_htmloutput_mesg($mesgstring= '', $mesgarray= '', $style= 'ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
Class to manage members of a foundation.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getObject($id, $ref= '')
Get object from id or ref and save it into this->object.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.