2020-10-24 07:04:06 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
{literal}
|
|
|
|
|
|
|
|
function updateSum(){
|
|
|
|
var total = 0;
|
|
|
|
e = document.querySelectorAll('input[name="prix[]"]');
|
2021-12-17 14:17:59 +01:00
|
|
|
e.forEach((item) => {
|
|
|
|
if (!item.value) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
total += g.getMoneyAsInt(item.value);
|
2020-10-24 07:04:06 +02:00
|
|
|
});
|
2021-12-17 14:17:59 +01:00
|
|
|
document.getElementById('total').innerHTML = g.formatMoney(total);
|
2020-10-24 07:04:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
function plus(){
|
|
|
|
var newdiv = document.createElement('tr');
|
|
|
|
newdiv.innerHTML = document.getElementById('Line1').innerHTML;
|
2024-10-19 14:26:06 +02:00
|
|
|
newdiv.getElementsByTagName('textarea')[0].setAttribute('name', 'designation[]');
|
|
|
|
newdiv.getElementsByTagName('input')[0].setAttribute('name', 'prix[]');
|
2020-12-29 18:07:26 +01:00
|
|
|
newdiv.querySelector('.fact_rm_line button').onclick = function(){
|
|
|
|
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
|
|
|
updateSum();
|
|
|
|
};
|
2021-12-17 14:17:59 +01:00
|
|
|
newdiv.getElementsByTagName('input')[0].onkeyup = updateSum;
|
2020-10-24 07:04:06 +02:00
|
|
|
document.getElementById('Lines').appendChild(newdiv);
|
|
|
|
}
|
|
|
|
plus();
|
2020-12-29 18:07:26 +01:00
|
|
|
updateSum();
|
2020-10-24 07:04:06 +02:00
|
|
|
|
|
|
|
$('#ajouter_ligne').onclick = plus;
|
|
|
|
|
2024-10-19 14:26:06 +02:00
|
|
|
a = document.querySelectorAll('[name="remove_line"]');
|
2020-12-29 18:07:26 +01:00
|
|
|
l = a.length;
|
|
|
|
for(i = 0; i < l; i++) {
|
|
|
|
a[i].onclick = function(){
|
|
|
|
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
2024-10-19 14:26:06 +02:00
|
|
|
updateSum();
|
2020-12-29 18:07:26 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-24 07:04:06 +02:00
|
|
|
function changeTypeSaisie(type)
|
|
|
|
{
|
|
|
|
g.toggle(['.type_client', '.type_membre'], false);
|
2021-12-17 14:09:27 +01:00
|
|
|
|
|
|
|
if (type) {
|
|
|
|
g.toggle('.type_' + type, true);
|
|
|
|
}
|
2020-10-24 07:04:06 +02:00
|
|
|
}
|
|
|
|
|
2021-12-17 12:07:53 +01:00
|
|
|
const form = document.querySelector('#f_numero_facture').form;
|
2021-12-17 14:09:27 +01:00
|
|
|
changeTypeSaisie(form.base_receveur.value);
|
2020-10-24 07:04:06 +02:00
|
|
|
|
|
|
|
var inputs = $('input[name="base_receveur"]');
|
|
|
|
|
|
|
|
for (var i = 0; i < inputs.length; i++)
|
|
|
|
{
|
|
|
|
inputs[i].onchange = function (e) {
|
|
|
|
changeTypeSaisie(this.value);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
} ());
|
2020-12-29 18:07:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Hide type specific parts of the form
|
|
|
|
function hideAllTypes() {
|
|
|
|
g.toggle('[data-types]', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Toggle parts of the form when a type is selected
|
|
|
|
function selectType(v) {
|
|
|
|
hideAllTypes();
|
|
|
|
g.toggle('[data-types~=t' + v + ']', true);
|
|
|
|
g.toggle('[data-types=all-but-advanced]', v != 0);
|
|
|
|
// Disable required form elements, or the form won't be able to be submitted
|
|
|
|
$('[data-types=all-but-advanced] input[required]').forEach((e) => {
|
|
|
|
e.disabled = v == 'advanced' ? true : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var radios = $('fieldset input[type=radio][name=type]');
|
|
|
|
|
|
|
|
radios.forEach((e) => {
|
|
|
|
e.onchange = () => {
|
|
|
|
document.querySelectorAll('fieldset').forEach((e, k) => {
|
|
|
|
if (k == 0 || e.dataset.types) return;
|
|
|
|
g.toggle(e, true);
|
|
|
|
g.toggle('p.submit', true);
|
|
|
|
});
|
|
|
|
selectType(e.value);
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
hideAllTypes();
|
2020-10-24 07:04:06 +02:00
|
|
|
{/literal}
|
2020-12-29 18:07:26 +01:00
|
|
|
selectType({$radio.type});
|
2020-10-24 07:04:06 +02:00
|
|
|
</script>
|