2020-10-24 07:04:06 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
{literal}
|
|
|
|
|
|
|
|
function updateSum(){
|
|
|
|
var total = 0;
|
|
|
|
e = document.querySelectorAll('input[name="prix[]"]');
|
|
|
|
e.forEach( function sum(item, index){
|
|
|
|
total = total + Number(item.value);
|
|
|
|
});
|
|
|
|
document.getElementById('total').innerHTML = total.toFixed(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
function plus(){
|
|
|
|
var newdiv = document.createElement('tr');
|
|
|
|
newdiv.innerHTML = document.getElementById('Line1').innerHTML;
|
2021-11-05 23:47:36 +01: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();
|
|
|
|
};
|
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;
|
|
|
|
|
2020-12-29 18:07:26 +01:00
|
|
|
a = document.querySelectorAll('[name="remove_line"]');
|
|
|
|
l = a.length;
|
|
|
|
for(i = 0; i < l; i++) {
|
|
|
|
a[i].onclick = function(){
|
|
|
|
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
|
|
|
updateSum();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-24 07:04:06 +02:00
|
|
|
function changeTypeSaisie(type)
|
|
|
|
{
|
|
|
|
g.toggle(['.type_client', '.type_membre'], false);
|
|
|
|
g.toggle('.type_' + type, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
changeTypeSaisie(document.forms[0].base_receveur.value);
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
console.log(e.value);
|
|
|
|
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>
|