109 global $form, $formadmin, $formcompany;
111 @phan-var-force Form $form
112 @phan-var-force FormAdmin $formadmin
113 @phan-var-force FormCompany $formcompany
116 if ($action ==
'add' || $action ==
'update') {
121 $this->
object->fournisseur = 1;
124 $this->
object->client = 1;
127 $this->
object->client = 2;
130 $this->
object->client = 3;
133 $this->
object->particulier = 1;
136 foreach ($this->
object as $key => $value) {
137 $this->tpl[$key] = $value;
141 if (is_array($GLOBALS[
'errors'])) {
145 if ($action ==
'create') {
146 if (
$conf->use_javascript_ajax) {
147 $this->tpl[
'ajax_selecttype'] =
"\n".
'<script type="text/javascript">
148 $(document).ready(function () {
149 $("#radiocompany").click(function() {
150 document.formsoc.action.value="create";
151 document.formsoc.canvas.value="company";
152 document.formsoc.private.value=0;
153 document.formsoc.submit();
155 $("#radioprivate").click(function() {
156 document.formsoc.action.value="create";
157 document.formsoc.canvas.value="individual";
158 document.formsoc.private.value=1;
159 document.formsoc.submit();
166 if ($action ==
'create' || $action ==
'edit') {
167 if (
$conf->use_javascript_ajax) {
168 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript">
169 $(document).ready(function () {
170 $("#selectcountry_id").change(function() {
171 document.formsoc.action.value="'.$action.
'";
172 document.formsoc.canvas.value="'.$canvas.
'";
173 document.formsoc.submit();
181 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) {
191 $modCodeClient =
new $module(
$db);
192 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
193 $this->tpl[
'auto_customercode'] = $modCodeClient->code_auto;
195 if ($modCodeClient->code_auto) {
196 $this->tpl[
'prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
201 0 => $langs->trans(
'NorProspectNorCustomer'),
202 1 => $langs->trans(
'Customer'),
203 2 => $langs->trans(
'Prospect'),
204 3 => $langs->trans(
'ProspectCustomer')
205 ), $this->object->client);
208 $this->tpl[
'customercode'] = $this->
object->code_client;
209 if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
210 $this->tpl[
'customercode'] = $modCodeClient->getNextValue($this->
object, 0);
212 $this->tpl[
'ismodifiable_customercode'] = $this->
object->codeclient_modifiable();
213 $s = $modCodeClient->getToolTip($langs, $this->
object, 0);
214 $this->tpl[
'help_customercode'] = $form->textwithpicto(
'', $s, 1);
217 $this->tpl[
'supplier_enabled'] = 1;
221 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
222 $module = substr($module, 0,
dol_strlen($module) - 4);
224 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
225 foreach ($dirsociete as $dirroot) {
231 $modCodeFournisseur =
new $module();
232 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
233 $this->tpl[
'auto_suppliercode'] = $modCodeFournisseur->code_auto;
235 if ($modCodeFournisseur->code_auto) {
236 $this->tpl[
'prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
240 $this->tpl[
'yn_supplier'] = $form->selectyesno(
"fournisseur", $this->object->fournisseur, 1);
241 $this->tpl[
'suppliercode'] = $this->
object->code_fournisseur;
242 if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
243 $this->tpl[
'suppliercode'] = $modCodeFournisseur->getNextValue($this->
object, 1);
245 $this->tpl[
'ismodifiable_suppliercode'] = $this->
object->codefournisseur_modifiable();
246 $s = $modCodeFournisseur->getToolTip($langs, $this->
object, 1);
247 $this->tpl[
'help_suppliercode'] = $form->textwithpicto(
'', $s, 1);
249 $this->
object->LoadSupplierCateg();
250 $this->tpl[
'suppliercategory'] = $this->
object->SupplierCategories;
254 $this->tpl[
'select_zip'] = $formcompany->select_ziptown((
string) $this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
257 $this->tpl[
'select_town'] = $formcompany->select_ziptown((
string) $this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
260 $this->
object->country_id = ($this->
object->country_id ? $this->
object->country_id : $mysoc->country_id);
261 $this->
object->country_code = ($this->
object->country_code ? $this->
object->country_code : $mysoc->country_code);
262 $this->tpl[
'select_country'] = $form->select_country((
string) $this->
object->country_id,
'country_id');
263 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
266 $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
270 if ($this->object->country_id) {
271 $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
273 $this->tpl[
'select_state'] = $countrynotdefined;
278 $this->tpl[
'select_lang'] = $formadmin->select_language((empty($this->object->default_lang) ?
getDolGlobalString(
'MAIN_LANG_DEFAULT') : $this->
object->default_lang),
'default_lang', 0, array(), 1);
282 $this->tpl[
'yn_assujtva'] = $form->selectyesno(
'assujtva_value', $this->tpl[
'tva_assuj'], 1);
285 $this->tpl[
'select_users'] = $form->select_dolusers($this->object->commercial_id,
'commercial_id', 1,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth300');
289 if (
$mysoc->country_code ==
'ES') {
290 $this->tpl[
'localtax'] =
'';
292 if (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj ==
"1") {
293 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td>';
294 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
295 $this->tpl[
'localtax'] .=
'</td><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td>';
296 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
297 $this->tpl[
'localtax'] .=
'</td></tr>';
298 } elseif (
$mysoc->localtax1_assuj ==
"1") {
299 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td colspan="3">';
300 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
301 $this->tpl[
'localtax'] .=
'</td><tr>';
302 } elseif (
$mysoc->localtax2_assuj ==
"1") {
303 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td colspan="3">';
304 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
305 $this->tpl[
'localtax'] .=
'</td><tr>';
314 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'name');
316 $this->tpl[
'checkcustomercode'] = $this->
object->check_codeclient();
317 $this->tpl[
'checksuppliercode'] = $this->
object->check_codefournisseur();
318 $this->tpl[
'address'] =
dol_nl2br((
string) $this->object->address);
321 if ($this->object->isInEEC()) {
322 $this->tpl[
'country'] = $form->textwithpicto(($img ? $img.
' ' :
'').$this->object->country, $langs->trans(
"CountryIsInEEC"), 1,
'info');
324 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
326 $this->tpl[
'phone'] =
dol_print_phone((
string) $this->object->phone, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
327 $this->tpl[
'phone_mobile'] =
dol_print_phone((
string) $this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_MOB');
328 $this->tpl[
'fax'] =
dol_print_phone((
string) $this->object->fax, $this->object->country_code, 0, $this->object->id,
'AC_FAX');
329 $this->tpl[
'email'] =
dol_print_email((
string) $this->object->email, 0, $this->object->id, 1);
330 $this->tpl[
'url'] =
dol_print_url((
string) $this->object->url);
332 $this->tpl[
'tva_assuj'] =
yn($this->object->tva_assuj);
335 $arr = $formcompany->typent_array(1);
336 $this->tpl[
'typent'] = $arr[$this->
object->typent_code];
339 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
342 $langs->load(
"languages");
343 $this->tpl[
'default_lang'] = (empty($this->object->default_lang) ?
'' : $langs->trans(
'Language_'.$this->object->default_lang));
346 $this->tpl[
'image_edit'] =
img_edit();
348 $this->tpl[
'display_rib'] = $this->
object->display_rib();
351 $this->tpl[
'sales_representatives'] =
'';
352 $listsalesrepresentatives = $this->
object->getSalesRepresentatives($user);
353 $nbofsalesrepresentative = count($listsalesrepresentatives);
354 if ($nbofsalesrepresentative > 3) {
355 $this->tpl[
'sales_representatives'] .= $nbofsalesrepresentative;
356 } elseif ($nbofsalesrepresentative > 0) {
357 $userstatic =
new User($this->db);
359 foreach ($listsalesrepresentatives as $val) {
360 $userstatic->id = $val[
'id'];
361 $userstatic->lastname = $val[
'lastname'];
362 $userstatic->firstname = $val[
'firstname'];
363 $this->tpl[
'sales_representatives'] .= $userstatic->getNomUrl(1);
365 if ($i < $nbofsalesrepresentative) {
366 $this->tpl[
'sales_representatives'] .=
', ';
370 $this->tpl[
'sales_representatives'] .= $langs->trans(
"NoSalesRepresentativeAffected");
375 $langs->load(
"members");
377 $result = $adh->fetch(0,
'', $this->object->id);
379 $adh->ref = $adh->getFullName($langs);
380 $this->tpl[
'linked_member'] = $adh->getNomUrl(1);
382 $this->tpl[
'linked_member'] = $langs->trans(
"ThirdpartyNotLinkedToMember");
388 if (
$mysoc->country_code ==
'ES') {
389 $this->tpl[
'localtax'] =
'';
391 if (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj ==
"1") {
392 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
393 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax1_assuj).
'</td>';
394 $this->tpl[
'localtax'] .=
'<td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
395 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax2_assuj).
'</td></tr>';
396 } elseif (
$mysoc->localtax1_assuj ==
"1") {
397 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
398 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax1_assuj).
'</td></tr>';
399 } elseif (
$mysoc->localtax2_assuj ==
"1") {
400 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
401 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax2_assuj).
'</td></tr>';