Skip to content

Commit b6ea58f

Browse files
committed
FIX Management of status prospect/customer/supplier
1 parent f834aa8 commit b6ea58f

File tree

3 files changed

+299
-118
lines changed

3 files changed

+299
-118
lines changed

htdocs/cabinetmed/canvas/patient/tpl/card_create.tpl.php

Lines changed: 185 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @var Conf $conf
2020
* @var DoliDB $db
2121
* @var CommonObject $object
22+
*
23+
* @var string $action
2224
*/
2325
// Protection to avoid direct call of template
2426
if (empty($conf) || ! is_object($conf)) {
@@ -73,15 +75,31 @@
7375
$formcompany=new FormCompany($GLOBALS['db']);
7476
$formadmin=new FormAdmin($GLOBALS['db']);
7577

76-
// Define if customer/prospect or supplier status is set or not
77-
$object->client = -1;
78-
if (getDolGlobalString('THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT')) {
79-
$object->client = 3;
80-
}
81-
if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') && $object->client == 3) {
82-
$object->client = 1;
78+
79+
// Prospect/Customer/Supplier
80+
$selected = $object->client;
81+
$selectedcustomer = ((getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==1 && GETPOST("type", 'aZ') != 'p' && GETPOST("type", 'aZ') != 'f') || (getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==3 && GETPOST("type", 'aZ') != 'p' && GETPOST("type", 'aZ') != 'f') ? 1 : 0);
82+
$selectedprospect = ((getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==2 && GETPOST("type", 'aZ') != 'c' && GETPOST("type", 'aZ') != 'f') || (getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==3 && GETPOST("type", 'aZ') != 'c' && GETPOST("type", 'aZ') != 'f') ? 1 : 0);
83+
switch ($selected) {
84+
case 1:
85+
$selectedcustomer = 1;
86+
break;
87+
case 2:
88+
$selectedprospect = 1;
89+
break;
90+
case 3:
91+
$selectedprospect = 1;
92+
$selectedcustomer = 1;
93+
break;
94+
default:
95+
break;
8396
}
8497

98+
$selectedprospect = ((GETPOSTISSET('prospect') && $action == 'create') ? GETPOSTINT('prospect') : $selectedprospect);
99+
$selectedcustomer = ((GETPOSTISSET('customer') && $action == 'create') ? GETPOSTINT('customer') : $selectedcustomer);
100+
$selectedsupplier = ((GETPOSTISSET('supplier') && $action == 'create') ? GETPOSTINT('supplier') : $object->fournisseur);
101+
102+
85103
$object->name = GETPOST("name");
86104
$object->lastname = GETPOST("name");
87105
$object->firstname = GETPOST("firstname");
@@ -252,117 +270,181 @@
252270
print '</td><td colspan="2"></td>';
253271
print '</tr>';
254272

255-
// Customer code
256-
print '<tr>';
257-
print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
258-
print '<table class="nobordernopadding"><tr><td>';
259-
$tmpcode = $object->code_client ?? '';
260-
if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
261-
$tmpcode = $modCodeClient->getNextValue($object, 0);
262-
}
263-
print '<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
264-
print '</td><td>';
265-
$s = $modCodeClient->getToolTip($langs, $object, 0);
266-
print $form->textwithpicto('', $s, 1);
267-
print '</td></tr></table>';
268-
print '</td>';
273+
// Customer code
274+
print '<tr>';
275+
print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
276+
print '<table class="nobordernopadding"><tr><td>';
277+
$tmpcode = $object->code_client ?? '';
278+
if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
279+
$tmpcode = $modCodeClient->getNextValue($object, 0);
280+
}
281+
print '<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
282+
print '</td><td>';
283+
$s = $modCodeClient->getToolTip($langs, $object, 0);
284+
print $form->textwithpicto('', $s, 1);
285+
print '</td></tr></table>';
286+
print '</td>';
269287

270-
/*
271-
if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))
272-
|| (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
273-
if ($conf->browser->layout == 'phone') {
274-
print '<td colspan="2"></td>';
275-
print '</tr><tr>';
288+
/*
289+
if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))
290+
|| (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
291+
if ($conf->browser->layout == 'phone') {
292+
print '<td colspan="2"></td>';
293+
print '</tr><tr>';
294+
}
295+
print '<td>'.$form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0).'</td><td>';
296+
print '<table class="nobordernopadding"><tr><td>';
297+
$tmpcode = $object->code_fournisseur ?? '';
298+
if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
299+
$tmpcode = $modCodeFournisseur->getNextValue($object, 1);
300+
}
301+
print '<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
302+
print '</td><td>';
303+
$s = $modCodeFournisseur->getToolTip($langs, $object, 1);
304+
print $form->textwithpicto('', $s, 1);
305+
print '</td></tr></table>';
306+
print '</td>';
307+
} else {
308+
print '<td colspan="2"></td>';
309+
}
310+
*/
311+
print '<td colspan="2"></td>';
312+
print '</tr>';
313+
314+
print '<tr class="marginbottomlarge height50">';
315+
if ($conf->browser->layout != 'phone') {
316+
print '<td class="titlefieldcreate">'.$form->editfieldkey('', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
317+
}
318+
print '<td class="maxwidthonsmartphone"'.($conf->browser->layout != 'phone' ? 'colspan="3"' : 'colspan="2"').'>';
319+
320+
if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
321+
print '<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans("Prospect").'</label><input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'></span>';
322+
}
323+
324+
if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
325+
print '<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans("Customer").'</label><input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'></span>';
326+
}
327+
328+
if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))
329+
|| (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
330+
// Supplier
331+
print '<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans("Vendor").'</label><input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selectedsupplier ? ' checked="checked"' : '').'></span>';
332+
}
333+
// Add js to manage the background of nature
334+
if ($conf->use_javascript_ajax) {
335+
print '<script>
336+
function refreshNatureCss() {
337+
jQuery(".spannature").each(function( index ) {
338+
id = $(this).attr("id").split("spannature")[1];
339+
console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
340+
if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
341+
if (id == 1) {
342+
jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
276343
}
277-
print '<td>'.$form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0).'</td><td>';
278-
print '<table class="nobordernopadding"><tr><td>';
279-
$tmpcode = $object->code_fournisseur ?? '';
280-
if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
281-
$tmpcode = $modCodeFournisseur->getNextValue($object, 1);
344+
if (id == 2) {
345+
jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
346+
}
347+
if (id == 3) {
348+
jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
282349
}
283-
print '<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
284-
print '</td><td>';
285-
$s = $modCodeFournisseur->getToolTip($langs, $object, 1);
286-
print $form->textwithpicto('', $s, 1);
287-
print '</td></tr></table>';
288-
print '</td>';
289350
} else {
290-
print '<td colspan="2"></td>';
351+
jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
291352
}
292-
*/
293-
print '<td colspan="2"></td>';
294-
print '</tr>';
353+
});
354+
}
295355
296-
// Barcode
297-
if (isModEnabled('barcode')) {
298-
print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
299-
print '<td colspan="3">';
300-
print img_picto('', 'barcode', 'class="pictofixedwidth"');
301-
print '<input type="text" class="minwidth200 maxwidth300 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">';
302-
print '</td></tr>';
303-
}
356+
function manageprospectcustomer(element) {
357+
console.log("We uncheck unwanted values on a nature");
358+
id = $(element).attr("id").split("spannature")[1];
359+
if ( id == 1){
360+
$("#spannature2 .checkforselect").prop("checked", false);
361+
}
362+
if ( id == 2){
363+
$("#spannature1 .checkforselect").prop("checked", false);
364+
}
365+
}
304366
305-
print '<tr><td colspan="4">&nbsp;</td></tr>';
367+
jQuery(".spannature").click(function(){
368+
console.log("We click on a nature");
369+
'.(getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ? 'manageprospectcustomer($(this));' : '').'
370+
refreshNatureCss();
371+
});
372+
refreshNatureCss();
373+
</script>';
374+
}
375+
print '</td>';
376+
print '</tr>';
306377

307-
// Address
308-
print '<tr><td class="tdtop">';
309-
print $form->editfieldkey('Address', 'address', '', $object, 0);
310-
print '</td>';
311-
print '<td colspan="3">';
312-
print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.'" wrap="soft">';
313-
print dol_escape_htmltag($object->address, 0, 1);
314-
print '</textarea>';
315-
print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
316-
print '</td></tr>';
317-
318-
// Zip / Town
319-
print '<tr><td>'.$langs->trans('Zip').'</td><td>';
320-
print $formcompany->select_ziptown($object->zip, 'zipcode', array('town','selectcountry_id','departement_id'), 0, 0, '', 'maxwidth100');
321-
print '</td>';
322-
if ($conf->browser->layout == 'phone') {
323-
print '</tr><tr>';
324-
}
325-
print '<td>'.$langs->trans('Town').'</td><td>';
326-
print $formcompany->select_ziptown($object->town, 'town', array('zipcode','selectcountry_id','departement_id'), 0, 0, '', 'maxwidth150 quatrevingtpercent');
327-
print '</td></tr>';
378+
// Barcode
379+
if (isModEnabled('barcode')) {
380+
print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
381+
print '<td colspan="3">';
382+
print img_picto('', 'barcode', 'class="pictofixedwidth"');
383+
print '<input type="text" class="minwidth200 maxwidth300 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">';
384+
print '</td></tr>';
385+
}
328386

329-
// Country
330-
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3" class="maxwidthonsmartphone">';
331-
print img_picto('', 'country', 'class="pictofixedwidth"');
332-
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth200 maxwidth300 widthcentpercentminusx');
333-
if ($user->admin) {
334-
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
335-
}
336-
print '</td></tr>';
387+
print '<tr><td colspan="4">&nbsp;</td></tr>';
388+
389+
// Address
390+
print '<tr><td class="tdtop">';
391+
print $form->editfieldkey('Address', 'address', '', $object, 0);
392+
print '</td>';
393+
print '<td colspan="3">';
394+
print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.'" wrap="soft">';
395+
print dol_escape_htmltag($object->address, 0, 1);
396+
print '</textarea>';
397+
print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
398+
print '</td></tr>';
399+
400+
// Zip / Town
401+
print '<tr><td>'.$langs->trans('Zip').'</td><td>';
402+
print $formcompany->select_ziptown($object->zip, 'zipcode', array('town','selectcountry_id','departement_id'), 0, 0, '', 'maxwidth100');
403+
print '</td>';
404+
if ($conf->browser->layout == 'phone') {
405+
print '</tr><tr>';
406+
}
407+
print '<td>'.$langs->trans('Town').'</td><td>';
408+
print $formcompany->select_ziptown($object->town, 'town', array('zipcode','selectcountry_id','departement_id'), 0, 0, '', 'maxwidth150 quatrevingtpercent');
409+
print '</td></tr>';
410+
411+
// Country
412+
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3" class="maxwidthonsmartphone">';
413+
print img_picto('', 'country', 'class="pictofixedwidth"');
414+
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth200 maxwidth300 widthcentpercentminusx');
415+
if ($user->admin) {
416+
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
417+
}
418+
print '</td></tr>';
337419

338-
// State
339-
if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
340-
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3" class="maxwidthonsmartphone">';
420+
// State
421+
if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
422+
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3" class="maxwidthonsmartphone">';
341423

342-
if ($object->country_id) {
343-
print img_picto('', 'state', 'class="pictofixedwidth"');
344-
print $formcompany->select_state($object->state_id, $object->country_code, 'state_id', 'minwidth200 maxwidth300 widthcentpercentminusx');
345-
} else {
346-
print $countrynotdefined;
347-
}
348-
print '</td></tr>';
349-
}
424+
if ($object->country_id) {
425+
print img_picto('', 'state', 'class="pictofixedwidth"');
426+
print $formcompany->select_state($object->state_id, $object->country_code, 'state_id', 'minwidth200 maxwidth300 widthcentpercentminusx');
427+
} else {
428+
print $countrynotdefined;
429+
}
430+
print '</td></tr>';
431+
}
350432

351-
// Phone / Fax
352-
print '<tr><td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
353-
print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $object->phone).'"></td>';
433+
// Phone / Fax
434+
print '<tr><td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
435+
print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $object->phone).'"></td>';
354436

355-
if ($conf->browser->layout == 'phone') {
356-
print '</tr><tr>';
357-
}
437+
if ($conf->browser->layout == 'phone') {
438+
print '</tr><tr>';
439+
}
358440

359-
// Phone mobile
360-
print '<td>'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).'</td>';
361-
print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').' <input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
441+
// Phone mobile
442+
print '<td>'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).'</td>';
443+
print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').' <input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
362444

363-
// Email
364-
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalInt('SOCIETE_EMAIL_MANDATORY')).'</td>';
365-
print '<td'.(($conf->browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td>';
445+
// Email
446+
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalInt('SOCIETE_EMAIL_MANDATORY')).'</td>';
447+
print '<td'.(($conf->browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td>';
366448

367449
/*
368450
print '<tr>';

0 commit comments

Comments
 (0)