Skip to content

Commit

Permalink
#239 [Certificate] add: JS selector for use generic select object
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 6, 2023
1 parent 2f83990 commit 577afcf
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion view/certificate/certificate_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,36 @@
}
if (!empty($conf->societe->enabled)) {
$elementList['product'] .= img_picto('', 'product', 'class="pictofixedwidth"') . dol_escape_htmltag($langs->trans('Product'));
}
} ?>

print '<tr><td class="titlefieldcreate"><label for="element_type">' . $langs->trans('ElementType') . '</label></td>';
print '<td class="valuefieldcreate">' . $form::selectarray('element_type', $elementList, GETPOSTISSET('element_type') ? GETPOST('element_type') : 'user', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx') . '</td>';
print '</tr>';

<script>
$(document).ready(function(){
$('#element_type').on('change', function(){
let value = $(this).val();
let url = new URL(document.URL)
let search_params = url.searchParams;
search_params.set('element_type', value);
url.search = search_params.toString();
location.href = url.toString()
});
});
</script>
<?php

switch (GETPOST('element_type')) {
case 'user' :
$object->fields['fk_element']['type'] = 'integer:User:user/class/user.class.php';
$object->fields['fk_element']['picto'] = 'user';
break;
case 'product' :
$object->fields['fk_element']['type'] = 'integer:Product:product/class/product.class.php';
$object->fields['fk_element']['picto'] = 'product';
break;
}

// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
Expand Down

0 comments on commit 577afcf

Please sign in to comment.