107 global
$conf, $langs, $db, $user, $mysoc, $canvas;
108 global $form, $formadmin, $formcompany;
110 @phan-var-force Form $form
111 @phan-var-force FormAdmin $formadmin
112 @phan-var-force FormCompany $formcompany
115 if ($action ==
'add' || $action ==
'update') {
120 $this->
object->fournisseur = 1;
123 $this->
object->client = 1;
126 $this->
object->client = 2;
129 $this->
object->client = 3;
132 $this->
object->particulier = 1;
135 foreach ($this->
object as $key => $value) {
136 $this->tpl[$key] = $value;
140 if (is_array($GLOBALS[
'errors'])) {
144 if ($action ==
'create') {
145 if (
$conf->use_javascript_ajax) {
146 $this->tpl[
'ajax_selecttype'] =
"\n".
'<script type="text/javascript">
147 $(document).ready(function () {
148 $("#radiocompany").click(function() {
149 document.formsoc.action.value="create";
150 document.formsoc.canvas.value="company";
151 document.formsoc.private.value=0;
152 document.formsoc.submit();
154 $("#radioprivate").click(function() {
155 document.formsoc.action.value="create";
156 document.formsoc.canvas.value="individual";
157 document.formsoc.private.value=1;
158 document.formsoc.submit();
165 if ($action ==
'create' || $action ==
'edit') {
166 if (
$conf->use_javascript_ajax) {
167 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript">
168 $(document).ready(function () {
169 $("#selectcountry_id").change(function() {
170 document.formsoc.action.value="'.$action.
'";
171 document.formsoc.canvas.value="'.$canvas.
'";
172 document.formsoc.submit();
180 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
181 $module = substr($module, 0,
dol_strlen($module) - 4);
183 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
184 foreach ($dirsociete as $dirroot) {
190 $modCodeClient =
new $module($db);
191 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
192 $this->tpl[
'auto_customercode'] = $modCodeClient->code_auto;
194 if ($modCodeClient->code_auto) {
195 $this->tpl[
'prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
200 0 => $langs->trans(
'NorProspectNorCustomer'),
201 1 => $langs->trans(
'Customer'),
202 2 => $langs->trans(
'Prospect'),
203 3 => $langs->trans(
'ProspectCustomer')
204 ), $this->object->client);
207 $this->tpl[
'customercode'] = $this->
object->code_client;
208 if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
209 $this->tpl[
'customercode'] = $modCodeClient->getNextValue($this->
object, 0);
211 $this->tpl[
'ismodifiable_customercode'] = $this->
object->codeclient_modifiable();
212 $s = $modCodeClient->getToolTip($langs, $this->
object, 0);
213 $this->tpl[
'help_customercode'] = $form->textwithpicto(
'', $s, 1);
215 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
216 $this->tpl[
'supplier_enabled'] = 1;
220 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
221 $module = substr($module, 0,
dol_strlen($module) - 4);
223 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
224 foreach ($dirsociete as $dirroot) {
230 $modCodeFournisseur =
new $module();
231 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
232 $this->tpl[
'auto_suppliercode'] = $modCodeFournisseur->code_auto;
234 if ($modCodeFournisseur->code_auto) {
235 $this->tpl[
'prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
239 $this->tpl[
'yn_supplier'] = $form->selectyesno(
"fournisseur", $this->object->fournisseur, 1);
240 $this->tpl[
'suppliercode'] = $this->
object->code_fournisseur;
241 if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
242 $this->tpl[
'suppliercode'] = $modCodeFournisseur->getNextValue($this->
object, 1);
244 $this->tpl[
'ismodifiable_suppliercode'] = $this->
object->codefournisseur_modifiable();
245 $s = $modCodeFournisseur->getToolTip($langs, $this->
object, 1);
246 $this->tpl[
'help_suppliercode'] = $form->textwithpicto(
'', $s, 1);
248 $this->
object->LoadSupplierCateg();
249 $this->tpl[
'suppliercategory'] = $this->
object->SupplierCategories;
253 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
256 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
259 $this->
object->country_id = ($this->
object->country_id ? $this->
object->country_id : $mysoc->country_id);
260 $this->
object->country_code = ($this->
object->country_code ? $this->
object->country_code : $mysoc->country_code);
261 $this->tpl[
'select_country'] = $form->select_country($this->object->country_id,
'country_id');
262 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
265 $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
269 if ($this->object->country_id) {
270 $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
272 $this->tpl[
'select_state'] = $countrynotdefined;
277 $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);
281 $this->tpl[
'yn_assujtva'] = $form->selectyesno(
'assujtva_value', $this->tpl[
'tva_assuj'], 1);
284 $this->tpl[
'select_users'] = $form->select_dolusers($this->object->commercial_id,
'commercial_id', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
288 if ($mysoc->country_code ==
'ES') {
289 $this->tpl[
'localtax'] =
'';
291 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
292 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td>';
293 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
294 $this->tpl[
'localtax'] .=
'</td><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td>';
295 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
296 $this->tpl[
'localtax'] .=
'</td></tr>';
297 } elseif ($mysoc->localtax1_assuj ==
"1") {
298 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td><td colspan="3">';
299 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax1assuj_value', $this->object->localtax1_assuj, 1);
300 $this->tpl[
'localtax'] .=
'</td><tr>';
301 } elseif ($mysoc->localtax2_assuj ==
"1") {
302 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td><td colspan="3">';
303 $this->tpl[
'localtax'] .= $form->selectyesno(
'localtax2assuj_value', $this->object->localtax1_assuj, 1);
304 $this->tpl[
'localtax'] .=
'</td><tr>';
313 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
315 $this->tpl[
'checkcustomercode'] = $this->
object->check_codeclient();
316 $this->tpl[
'checksuppliercode'] = $this->
object->check_codefournisseur();
317 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
320 if ($this->object->isInEEC()) {
321 $this->tpl[
'country'] = $form->textwithpicto(($img ? $img.
' ' :
'').$this->object->country, $langs->trans(
"CountryIsInEEC"), 1, 0);
323 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
325 $this->tpl[
'phone'] =
dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
326 $this->tpl[
'phone_mobile'] =
dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_MOB');
327 $this->tpl[
'fax'] =
dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id,
'AC_FAX');
328 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id, 1);
331 $this->tpl[
'tva_assuj'] =
yn($this->object->tva_assuj);
334 $arr = $formcompany->typent_array(1);
335 $this->tpl[
'typent'] = $arr[$this->
object->typent_code];
338 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
341 $langs->load(
"languages");
342 $this->tpl[
'default_lang'] = (empty($this->object->default_lang) ?
'' : $langs->trans(
'Language_'.$this->object->default_lang));
345 $this->tpl[
'image_edit'] =
img_edit();
347 $this->tpl[
'display_rib'] = $this->
object->display_rib();
350 $this->tpl[
'sales_representatives'] =
'';
351 $listsalesrepresentatives = $this->
object->getSalesRepresentatives($user);
352 $nbofsalesrepresentative = count($listsalesrepresentatives);
353 if ($nbofsalesrepresentative > 3) {
354 $this->tpl[
'sales_representatives'] .= $nbofsalesrepresentative;
355 } elseif ($nbofsalesrepresentative > 0) {
356 $userstatic =
new User($this->db);
358 foreach ($listsalesrepresentatives as $val) {
359 $userstatic->id = $val[
'id'];
360 $userstatic->lastname = $val[
'name'];
361 $userstatic->firstname = $val[
'firstname'];
362 $this->tpl[
'sales_representatives'] .= $userstatic->getNomUrl(1);
364 if ($i < $nbofsalesrepresentative) {
365 $this->tpl[
'sales_representatives'] .=
', ';
369 $this->tpl[
'sales_representatives'] .= $langs->trans(
"NoSalesRepresentativeAffected");
373 if (isModEnabled(
'member')) {
374 $langs->load(
"members");
376 $result = $adh->fetch(0,
'', $this->object->id);
378 $adh->ref = $adh->getFullName($langs);
379 $this->tpl[
'linked_member'] = $adh->getNomUrl(1);
381 $this->tpl[
'linked_member'] = $langs->trans(
"ThirdpartyNotLinkedToMember");
387 if ($mysoc->country_code ==
'ES') {
388 $this->tpl[
'localtax'] =
'';
390 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
391 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
392 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax1_assuj).
'</td>';
393 $this->tpl[
'localtax'] .=
'<td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
394 $this->tpl[
'localtax'] .=
'<td>'.yn($this->object->localtax2_assuj).
'</td></tr>';
395 } elseif ($mysoc->localtax1_assuj ==
"1") {
396 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax1IsUsedES").
'</td>';
397 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax1_assuj).
'</td></tr>';
398 } elseif ($mysoc->localtax2_assuj ==
"1") {
399 $this->tpl[
'localtax'] .=
'<tr><td>'.$langs->trans(
"LocalTax2IsUsedES").
'</td>';
400 $this->tpl[
'localtax'] .=
'<td colspan="3">'.yn($this->object->localtax2_assuj).
'</td></tr>';