Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace js with css for third party types and membres #32614

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion htdocs/accountancy/admin/subaccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
$s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
} elseif ($obj->type == 3) {
// User - Employee
$s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->rowid.'">'.$langs->trans("Employee").'</a>';
$s .= '<a class="back user" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->rowid.'">'.$langs->trans("Employee").'</a>';
}
print $s;
print '</td>';
Expand Down
64 changes: 24 additions & 40 deletions htdocs/adherents/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1030,40 +1030,18 @@
print "</td>\n";

// Morphy
$morphys = array();
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
$checkednature = (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy);
$checkedNature = (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy);
print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n";
print '<span id="spannature1" class="nonature-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys["phy"].'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature == "phy" ? ' checked="checked"' : '').'></label></span>';
print '<span id="spannature2" class="nonature-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys["mor"].'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature == "mor" ? ' 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("member-individual-back").removeClass("nonature-back");
}
if (index+1 == 2) {
jQuery("#spannature"+(index+1)).addClass("member-company-back").removeClass("nonature-back");
}
} else {
jQuery("#spannature"+(index+1)).removeClass("member-individual-back").removeClass("member-company-back").addClass("nonature-back");
}
});
}
jQuery(".spannature").click(function(){
console.log("We click on a nature");
refreshNatureCss();
});
refreshNatureCss();
</script>';
}

?>
<span class="nature paddinglarge marginrightonly">
<input type="radio" id="physical-input" name="morphy" value="phy" <?= $checkedNature == "phy" ? 'checked="checked"' : '' ?>>

Check failure on line 1037 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $checkedNature ..." but found "<?= $checkedNature ..."
<label for="physical-input"><?= $langs->trans("Physical") ?></label>

Check failure on line 1038 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $langs ..." but found "<?= $langs ..."
</span>
<span class="nature paddinglarge marginrightonly">
<input type="radio" id="moral-input" name="morphy" value="mor" <?= $checkedNature == "mor" ? 'checked="checked"' : '' ?>>

Check failure on line 1041 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $checkedNature ..." but found "<?= $checkedNature ..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace <?= with <?php echo
The tag <?= is often disabled on some secured php.

Copy link
Contributor Author

@atm-etienne atm-etienne Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short echo tag <?= ... ?> can't be disabled, since PHP 5.4
What is disabled in the secured PHP is the short open tag <? ... ?>, which has not effect on the short echo tag

Mentioned in the php.ini

; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It is
; generally recommended that <?php and ?> should be used and that this feature
; should be disabled, as enabling it may result in issues when generating XML
; documents, however this remains supported for backward compatibility reasons.
; Note that this directive does not control the <?= shorthand tag, which can be
; used regardless of this directive.
; Default Value: On
; Development Value: Off
; Production Value: Off
; https://php.net/short-open-tag
short_open_tag = Off

; Note that this directive does not control the <?= shorthand tag, which can be used regardless of this directive.

I can still replace it, if you prefer, but I think the short echo tag is easier to read und understand, while printing lot of HTML code

<label for="moral-input"><?= $langs->trans("Moral"); ?></label>

Check failure on line 1042 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $langs ..." but found "<?= $langs ..."
</span>
<?php
print "</td>\n";

// Company
Expand Down Expand Up @@ -1293,13 +1271,19 @@
print "</td></tr>";

// Morphy
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
$checkednature = (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy);
print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>';
print '<span id="spannature1" class="member-individual-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys["phy"].'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature == "phy" ? ' checked="checked"' : '').'></label></span>';
print '<span id="spannature1" class="member-company-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys["mor"].'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature == "mor" ? ' checked="checked"' : '').'></label></span>';
print "</td></tr>";
$checkedNature = (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy);
print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n";
?>
<span class="back nature paddinglarge marginrightonly">
<input type="radio" id="physical-input" name="morphy" value="phy" <?= $checkedNature == "phy" ? 'checked="checked"' : '' ?>>

Check failure on line 1278 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $checkedNature ..." but found "<?= $checkedNature ..."
<label for="physical-input"><?= $langs->trans("Physical") ?></label>

Check failure on line 1279 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $langs ..." but found "<?= $langs ..."
</span>
<span class="back nature paddinglarge marginrightonly">
<input type="radio" id="moral-input" name="morphy" value="mor" <?= $checkedNature == "mor" ? 'checked="checked"' : '' ?>>

Check failure on line 1282 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $checkedNature ..." but found "<?= $checkedNature ..."
<label for="moral-input"><?= $langs->trans("Moral"); ?></label>

Check failure on line 1283 in htdocs/adherents/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $langs ..." but found "<?= $langs ..."
</span>
<?php
print "</td></tr>\n";

// Company
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOSTISSET("societe") ? GETPOST("societe", 'alphanohtml', 2) : $object->company).'"></td></tr>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/class/adherent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public function getmorphylib($morphy = '', $addbadge = 0)
$labeltoshow = dol_strtoupper(dolGetFirstLetters($labeltoshowp, 2));
}
}
$s .= '<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans("Physical").'">'.$labeltoshow.'</span>';
$s .= '<span class="back physical paddingleftimp paddingrightimp" title="'.$langs->trans("Physical").'">'.$labeltoshow.'</span>';
}
if ($morphy == 'mor') {
$labeltoshow = $labeltoshowm;
Expand All @@ -597,7 +597,7 @@ public function getmorphylib($morphy = '', $addbadge = 0)
$labeltoshow = dol_strtoupper(dolGetFirstLetters($labeltoshowm, 2));
}
}
$s .= '<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans("Moral").'">'.$labeltoshow.'</span>';
$s .= '<span class="back moral paddingleftimp paddingrightimp" title="'.$langs->trans("Moral").'">'.$labeltoshow.'</span>';
}
} else {
if ($morphy == 'phy') {
Expand Down
160 changes: 53 additions & 107 deletions htdocs/societe/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1466,86 +1466,59 @@

// Prospect/Customer/Supplier
$selected = $object->client;
$selectedcustomer = 0;
$selectedprospect = 0;
$selectedCustomer = 0;
$selectedProspect = 0;
switch ($selected) {
case 1:
$selectedcustomer = 1;
$selectedCustomer = 1;
break;
case 2:
$selectedprospect = 1;
$selectedProspect = 1;
break;
case 3:
$selectedprospect = 1;
$selectedcustomer = 1;
$selectedProspect = 1;
$selectedCustomer = 1;
break;
default:
break;
}

$selectedprospect = (GETPOSTISSET('prospect') ? GETPOSTINT('prospect') : $selectedprospect);
$selectedcustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedcustomer);
$selectedProspect = (GETPOSTISSET('prospect') ? GETPOSTINT('prospect') : $selectedProspect);
$selectedCustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedCustomer);
print '<tr class="marginbottomlarge height50">';
if ($conf->browser->layout != 'phone') {
print '<td class="titlefieldcreate">'.$form->editfieldkey('', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
}
print '<td class="maxwidthonsmartphone"'.($conf->browser->layout != 'phone' ? 'colspan="3"' : 'colspan="2"').'>';

if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
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>';
?>
<span class="back nature paddinglarge marginrightonly">
<input type="checkbox" id="prospect-input" name="prospect" value="2" <?= $selectedProspect ? 'checked="checked"' : '' ?>>
<label for="prospect-input"><?= $langs->trans("Prospect") ?></label>

Check failure on line 1498 in htdocs/societe/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $selectedProspect ..." but found "<?= $selectedProspect ..."
</span>

Check failure on line 1499 in htdocs/societe/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Short PHP opening tag used with echo; expected "<?php echo $langs ..." but found "<?= $langs ..."
<?php
}

if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
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>';
?>
<span class="back nature paddinglarge marginrightonly">
<input type="checkbox" id="customer-input" name="customer" value="1" <?= $selectedCustomer ? 'checked="checked"' : '' ?>>
<label for="customer-input"><?= $langs->trans("Customer") ?></label>
</span>
<?php
}

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 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 ) {
id = $(this).attr("id").split("spannature")[1];
console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
if (id == 1) {
jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
}
if (id == 2) {
jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
}
if (id == 3) {
jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
}
} else {
jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
}
});
}

function manageprospectcustomer(element) {
console.log("We uncheck unwanted values on a nature");
id = $(element).attr("id").split("spannature")[1];
if ( id == 1){
$("#spannature2 .checkforselect").prop("checked", false);
}
if ( id == 2){
$("#spannature1 .checkforselect").prop("checked", false);
}
}

jQuery(".spannature").click(function(){
console.log("We click on a nature");
'.(getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ? 'manageprospectcustomer($(this));' : '').'
refreshNatureCss();
});
refreshNatureCss();
</script>';
?>
<span class="back nature paddinglarge marginrightonly">
<input type="checkbox" id="supplier-input" name="supplier" value="1" <?= $selected ? 'checked="checked"' : '' ?>>
<label for="supplier-input"><?= $langs->trans("Vendor") ?></label>
</span>
<?php
}
print '</td>';
print '</tr>';
Expand Down Expand Up @@ -2308,85 +2281,58 @@

// Prospect/Customer/Supplier
$selected = $object->client;
$selectedcustomer = 0;
$selectedprospect = 0;
$selectedCustomer = 0;
$selectedProspect = 0;
switch ($selected) {
case 1:
$selectedcustomer = 1;
$selectedCustomer = 1;
break;
case 2:
$selectedprospect = 1;
$selectedProspect = 1;
break;
case 3:
$selectedprospect = 1;
$selectedcustomer = 1;
$selectedProspect = 1;
$selectedCustomer = 1;
break;
default:
break;
}

// Nature of thirdparty
$selectedprospect = (GETPOSTISSET('prospect') ? GETPOSTINT('prospect') : $selectedprospect);
$selectedcustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedcustomer);
$selectedProspect = (GETPOSTISSET('prospect') ? GETPOSTINT('prospect') : $selectedProspect);
$selectedCustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedCustomer);
print '<tr class="marginbottomlarge height50"><td class="titlefieldcreate">'.$form->editfieldkey('', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
print '<td class="maxwidthonsmartphone" colspan="3">';

if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
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>';
?>
<span class="back nature paddinglarge marginrightonly">
<input type="checkbox" id="prospect-input" name="prospect" value="2" <?= $selectedProspect ? 'checked="checked"' : '' ?>>
<label for="prospect-input"><?= $langs->trans("Prospect") ?></label>
</span>
<?php
}

if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
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>';
?>
<span class="back nature paddinglarge marginrightonly">
<input type="checkbox" id="customer-input" name="customer" value="1" <?= $selectedCustomer ? 'checked="checked"' : '' ?>>
<label for="customer-input"><?= $langs->trans("Customer") ?></label>
</span>
<?php
}
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 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 ) {
id = $(this).attr("id").split("spannature")[1];
console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
if (id == 1) {
jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
}
if (id == 2) {
jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
}
if (id == 3) {
jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
}
} else {
jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
}
})
}

function manageprospectcustomer(element) {
console.log("We uncheck unwanted values on a nature");
id = $(element).attr("id").split("spannature")[1];
if ( id == 1){
$("#spannature2 .checkforselect").prop("checked", false);
}
if ( id == 2){
$("#spannature1 .checkforselect").prop("checked", false);
}
}

jQuery(".spannature").click(function(){
console.log("We click on a nature");
'.(getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ? 'manageprospectcustomer($(this));' : '').'
refreshNatureCss();
});
refreshNatureCss();
</script>';
?>
<span class="back nature paddinglarge marginrightonly">
<input type="checkbox" id="supplier-input" name="supplier" value="1" <?= $selected ? 'checked="checked"' : '' ?>>
<label for="supplier-input"><?= $langs->trans("Vendor") ?></label>
</span>
<?php
}

print '</td>';
print '</tr>';
print '<tr><td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
Expand Down
Loading
Loading