Skip to content

Commit

Permalink
Enhance selction of nature of thirdparties
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 1, 2024
1 parent ce507fc commit 5f27830
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 10 deletions.
75 changes: 65 additions & 10 deletions htdocs/societe/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1382,20 +1382,47 @@ function formatCustomerSelection (selection) {
$selectedcustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedcustomer);
print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('NatureOfThirdParty', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
print '<td class="maxwidthonsmartphone" colspan="3">';
print '<span class="customer-back opacitymedium"><label for="prospectinput">'.$langs->trans("Prospect").'</label></span><input id="prospectinput" class="flat checkforselect marginleftonly" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans("Prospect").'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'></label></span>';

print '<span class="customer-back"><label for="customerinput">'.$langs->trans("Customer").'</label></span><input id="customerinput" class="flat checkforselect marginleftonly" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans("Customer").'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'></label></span>';

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'))
|| (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
// Supplier
$selected = (GETPOSTISSET('supplier') ? GETPOSTINT('supplier') : $object->fournisseur);
print '<span class="vendor-back"><label for="supplierinput">'.$langs->trans("Vendor").'</label></span><input id="supplierinput" class="flat checkforselect marginleftonly" type="checkbox" name="supplier" value="1"'.($selected ? ' checked="checked"' : '').'>';
print '<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans("Vendor").'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selected ? ' checked="checked"' : '').'></label></span>';
}
// Add js to manage the background of nature
if ($conf->use_javascript_ajax) {
print '<script>
function refreshNatureCss() {
jQuery(".spannature").each(function( index ) {
console.log(jQuery("#spannature"+(index+1)+" .checkforselect").is(":checked"));
if (jQuery("#spannature"+(index+1)+" .checkforselect").is(":checked")) {
if (index+1 == 1) {
jQuery("#spannature"+(index+1)).addClass("prospect-back").removeClass("nonature-back");
}
if (index+1 == 2) {
jQuery("#spannature"+(index+1)).addClass("customer-back").removeClass("nonature-back");
}
if (index+1 == 3) {
jQuery("#spannature"+(index+1)).addClass("vendor-back").removeClass("nonature-back");
}
} else {
jQuery("#spannature"+(index+1)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
}
});
}
jQuery(".spannature").click(function(){
console.log("We click on a nature");
refreshNatureCss();
});
refreshNatureCss();
</script>';
}
print '</td>';
print '</tr>';

print '<tr><td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
print '<table class="nobordernopadding"><tr><td>';
$tmpcode = $object->code_client;
Expand Down Expand Up @@ -2122,21 +2149,49 @@ function init_supplier_categ() {
break;
}

// Nature of thirdparty
$selectedprospect = (GETPOSTISSET('prospect') ? GETPOSTINT('prospect') : $selectedprospect);
$selectedcustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedcustomer);
print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('NatureOfThirdParty', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
print '<td class="maxwidthonsmartphone" colspan="3">';
print '<span class="customer-back opacitymedium"><label for="prospectinput">'.$langs->trans("Prospect").'</label></span><input id="prospectinput" class="flat checkforselect marginleftonly" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans("Prospect").'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'></label></span>';

print '<span class="customer-back"><label for="customerinput">'.$langs->trans("Customer").'</label></span><input id="customerinput" class="flat checkforselect marginleftonly" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans("Customer").'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'></label></span>';

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'))
|| (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
// Supplier
$selected = (GETPOSTISSET('supplier') ? GETPOSTINT('supplier') : $object->fournisseur);
print '<span class="vendor-back"><label for="supplierinput">'.$langs->trans("Vendor").'</label></span><input id="supplierinput" class="flat checkforselect marginleftonly" type="checkbox" name="supplier" value="1"'.($selected ? ' checked="checked"' : '').'>';
print '<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans("Vendor").'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selected ? ' checked="checked"' : '').'></label></span>';
}

// Add js to manage the background of nature
if ($conf->use_javascript_ajax) {
print '<script>
function refreshNatureCss() {
jQuery(".spannature").each(function( index ) {
console.log(jQuery("#spannature"+(index+1)+" .checkforselect").is(":checked"));
if (jQuery("#spannature"+(index+1)+" .checkforselect").is(":checked")) {
if (index+1 == 1) {
jQuery("#spannature"+(index+1)).addClass("prospect-back").removeClass("nonature-back");
}
if (index+1 == 2) {
jQuery("#spannature"+(index+1)).addClass("customer-back").removeClass("nonature-back");
}
if (index+1 == 3) {
jQuery("#spannature"+(index+1)).addClass("vendor-back").removeClass("nonature-back");
}
} else {
jQuery("#spannature"+(index+1)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
}
});
}
jQuery(".spannature").click(function(){
console.log("We click on a nature");
refreshNatureCss();
});
refreshNatureCss();
</script>';
}
print '</td>';
print '</tr>';
Expand Down
3 changes: 3 additions & 0 deletions htdocs/theme/eldy/global.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@
.marginright2 {
margin-<?php print $right; ?>: 2px;
}
.paddinglarge {
padding: 6px !important;
}
.nowidthimp {
width: unset !important;
}
Expand Down
13 changes: 13 additions & 0 deletions htdocs/theme/eldy/info-box.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@
<?php } ?>
}

.nonature-back {
background-color: #EEE;
padding: 2px;
margin: 2px;
border-radius: 3px;
}
.prospect-back {
background-color: #b7d5c0 !important;
color: #FFF !important;
padding: 2px;
margin: 2px;
border-radius: 3px;
}
.customer-back {
background-color: #55955d !important;
color: #FFF !important;
Expand Down
6 changes: 6 additions & 0 deletions htdocs/theme/md/info-box.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@

?>

.nonature-back {
background-color: #EEE;
padding: 2px;
margin: 2px;
border-radius: 3px;
}
.customer-back {
background-color: #65953d !important;
color: #FFF !important;
Expand Down

0 comments on commit 5f27830

Please sign in to comment.