BigNumber.config({ROUNDING_MODE: 4}); function doLoadCot() { var prdcodes = document.getElementById('prdcodes').value; var prdcodesHEB = document.getElementById('prdcodesHEB').value; prdcodes = prdcodes.split(','); var MTHTT1_Total = new BigNumber("0.0"); var MTTVAT1_Total = new BigNumber("0.0"); var MTHTT2_Total = new BigNumber("0.0"); var MTTVAT2_Total = new BigNumber("0.0"); //http://u-project2.umanis.com/view.php?id=36186 produits à cotisation variable - plafonnement for(i=0; i < prdcodes.length; i++){ if(document.getElementById('qu_'+prdcodes[i])){ var qt = new BigNumber(document.getElementById('qu_'+prdcodes[i]).value); var qt2 = new BigNumber(document.getElementById('max_qu_'+prdcodes[i]).value); if(parseInt(qt.toString()) > parseInt(qt2.toString()) && (prdcodesHEB.indexOf("="+prdcodes[i]+"=") > -1)) qt = new BigNumber(qt2.toString()); var pr = new BigNumber(document.getElementById('pr_'+prdcodes[i]).value); var rem = new BigNumber(document.getElementById('REM_tofil_'+ prdcodes[i]).value); var tvam = new BigNumber(document.getElementById('TVA_tofil_'+ prdcodes[i]).value); var ProUnitHTT1_ = new BigNumber(document.getElementById('ProUnitHTT1_'+ prdcodes[i]).value); var TVAT1_ = new BigNumber(document.getElementById('TVAT1_'+ prdcodes[i]).value); var pr2 = pr.minus(rem); pr = pr.plus(tvam).minus(rem); var to = qt.mul(pr); var to2 = new BigNumber(qt.mul(pr2).toFixed(2)); MTHTT1_Total = MTHTT1_Total.plus(to2); var to3 = ProUnitHTT1_.mul(qt).mul(TVAT1_).div(new BigNumber("100")).toFixed(2); // verif var to = new BigNumber(to2.plus(to3).toFixed(2)); MTTVAT1_Total = MTTVAT1_Total.plus(to3);//verif document.getElementById('tofil_'+ prdcodes[i]).value = to.toString(); document.getElementById('MTHTT1_'+ prdcodes[i]).innerHTML = ''+to2.toString()+' €'; document.getElementById('MTTVAT1_'+ prdcodes[i]).innerHTML = ''+to3.toString()+' €'; } if(document.getElementById('2qu_'+prdcodes[i])){ var qt = new BigNumber(document.getElementById('2qu_'+prdcodes[i]).value); var qt2 = new BigNumber(document.getElementById('max_2qu_'+prdcodes[i]).value); if(parseInt(qt.toString()) > parseInt(qt2.toString()) && (prdcodesHEB.indexOf("="+prdcodes[i]+"=") > -1)) qt = new BigNumber(qt2.toString()); var pr = new BigNumber(document.getElementById('2pr_'+prdcodes[i]).value); var rem = new BigNumber(document.getElementById('REM_todep_'+ prdcodes[i]).value); var tvam = new BigNumber(document.getElementById('TVA_todep_'+ prdcodes[i]).value); var tvam2 = new BigNumber(document.getElementById('TVAT2_'+ prdcodes[i]).value); var ProUnitHTT2_ = new BigNumber(document.getElementById('ProUnitHTT2_'+ prdcodes[i]).value); var TVAT2_ = new BigNumber(document.getElementById('TVAT2_'+ prdcodes[i]).value); var pr2 = pr.minus(rem); tvam = pr2.div("100").mul(tvam2); pr = pr.plus(tvam).minus(rem); var to = qt.mul(pr); var to2 = new BigNumber(qt.mul(pr2).toFixed(2)); MTHTT2_Total = MTHTT2_Total.plus(to2); var to3 = new BigNumber(ProUnitHTT2_.mul(qt).mul(TVAT2_).div(new BigNumber("100")).toFixed(2)); to = new BigNumber(to2.plus(to3).toFixed(2)); MTTVAT2_Total = MTTVAT2_Total.plus(to3); document.getElementById('todep_'+ prdcodes[i]).value = to.toString(); //document.getElementById('MTHTT2_'+ prdcodes[i]).innerHTML = ''+to2.toString()+' €'; //document.getElementById('MTTVAT2_'+ prdcodes[i]).innerHTML = ''+to3.toString()+' €'; } } document.getElementById('MTHTT1_Total').innerHTML = ''+MTHTT1_Total.toFixed(2).toString()+' €'; document.getElementById('MTTVAT1_Total').innerHTML = ''+MTTVAT1_Total.toFixed(2).toString()+' €'; //document.getElementById('MTHTT2_Total').innerHTML = ''+MTHTT2_Total.toFixed(2).toString()+' €'; //document.getElementById('MTTVAT2_Total').innerHTML = ''+MTTVAT2_Total.toFixed(2).toString()+' €'; calculToto(); } function calculToto(){ var tofil = 0; //var todep = 0; var prdcodes = document.getElementById('prdcodes').value; prdcodes = prdcodes.split(','); for(i=0; i < prdcodes.length; i++){ if(document.getElementById('tofil_'+prdcodes[i])){ var t = document.getElementById('tofil_'+prdcodes[i]).value; tofil = parseFloat(tofil) + parseFloat(t); } //if(document.getElementById('todep_'+prdcodes[i])){ //var t = document.getElementById('todep_'+prdcodes[i]).value; //todep = parseFloat(todep) + parseFloat(t); //} } //todep = todep.toFixed(2); tofil = tofil.toFixed(2); document.getElementById('tofil').value = tofil; //document.getElementById('todep').value = todep; } function getElementsByIdStartsWith(container, selectorTag, prefix) { var items = []; var myPosts = document.getElementById(container).getElementsByTagName(selectorTag); for (var i = 0; i < myPosts.length; i++) { //omitting undefined null check for brevity if (myPosts[i].id.lastIndexOf(prefix, 0) === 0) { items.push(myPosts[i]); } } return items; } function doSaveCotValues(){ var prdcodes = document.getElementById('prdcodes').value; prdcodes = prdcodes.split(','); for(i=0; i < prdcodes.length; i++){ if(document.getElementById('qu_'+prdcodes[i])){ var qt = document.getElementById('qu_'+prdcodes[i]).value; document.getElementById(prdcodes[i]).value = qt; } } } $(document).ready(function(){ $('input[type="file"]').ajaxfileupload({ 'action': '/upload_custom_ajax.fl', 'onComplete': function(response) { response = response.replace("", ""); response = response.substr(response.length-16,response.length); document.getElementById('photoAttID').value = response; document.getElementById('photo').src= '/download?id=' + response; $('#upload').hide(); }, 'onStart': function() { $('#upload').show(); } }); $("ul.ul_w95ofh input[type=radio]").live('click', function() { $("ul.ul_w95ofh").find("input[type=radio]").each(function(){ if(this.checked){ $("#div3_w50fl input[name='490_ResponseInt']").attr('disabled','disabled'); $("#div3_w50fl input[name='490_ResponseInt']").val(""); }else{ $("#div3_w50fl input[name='490_ResponseInt']").removeAttr('disabled'); } }); }); $("#div1_w50fl input[name='56_ResponseTxt']").live('keyup change', function() { var checker = $.trim($(this).val()).length === 0; $("#div3_w50fl input[name='57_ResponseInt']").attr('disabled', !checker); }); $("#div3_w50fl input[name='57_ResponseInt']").live('keyup change', function() { var checker = $.trim($(this).val()).length === 0; $("#div1_w50fl input[name='56_ResponseTxt']").attr('disabled', !checker); }); formatSiret($("#div1_w50fl input[name='270_ResponseTxt']").get(0)); $('textarea.input_textarea').each(function(index){ var trimmed = $.trim($(this).val()).replace(/\s*[\r\n]+\s*/g, '\n') .replace(/(<[^\/][^>]*>)\s*/g, '$1') .replace(/\s*(<\/[^>]+>)/g, '$1'); $(this).val(trimmed); $(this).html(trimmed); $(this).text(trimmed); }); }); function isDate(txtDate) { var currVal = txtDate; if(currVal == '') return false; var rxDatePattern = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/; //Declare Regex var dtArray = currVal.match(rxDatePattern); // is format OK? if (dtArray == null) return false; //Checks for dd/mm/yyyy format. dtMonth = dtArray[3]; dtDay= dtArray[1]; dtYear = dtArray[5]; if (dtMonth < 1 || dtMonth > 12) return false; else if (dtDay < 1 || dtDay> 31) return false; else if ((dtMonth==4 || dtMonth==6 || dtMonth==9 || dtMonth==11) && dtDay ==31) return false; else if (dtMonth == 2) { var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); if (dtDay> 29 || (dtDay ==29 && !isleap)) return false; } return true; } function getDatefromString(str1){ // str1 format should be dd/mm/yyyy. Separator can be anything e.g. / or -. It wont effect var from = str1.split("/"); var date1 = new Date(from[2], from[1] - 1, from[0]); return date1; } function trim1(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } function areTheyValid(type,element){ var element1 = document.getElementsByName(element.name)[0]; var element2 = document.getElementsByName(element.name)[1]; element1.value = trim1(element1.value); element2.value = trim1(element2.value); if(!element1.value && !element2.value) return true; if(isItValid(type,element1)) if(!element2.value){ if(type == 'java.util.Date|java.util.Date'){ element2.focus(); } }else{ if(isItValid(type,element2)) return isIntervalValid(type,element); } return false; } function checkSemaineLivraison(element){ var rrr = isItValid('java.lang.Integer',element); if(rrr){ return isIntervalValid('7to23',element); } } function clearDates(elementName){ document.getElementsByName(elementName)[0].value = ''; document.getElementsByName(elementName)[1].value = ''; } function _tempSave(endPos) { var f = document.forms[0]; f.action = '/save_partial_web_form.fl?fromToSave=0&toToSave=' + endPos; f.submit(); } function _save() { var f = document.forms[0]; f.action = '/save_web_form.fl'; f.submit(); } function sortNum(a, b) { return 1 * $(a).find('.sort').text() < 1 * $(b).find('.sort').text() ? 0 : 1; } function sortTheTable(idtbl){ $(function() { var elems = $.makeArray($('tr:has(.sort)').remove()) elems.sort(sortNum) $('table#'+idtbl).append($(elems)); }); } function sortNum2(a, b) { return 1 * $(a).find('.sort2').text() < 1 * $(b).find('.sort2').text() ? 0 : 1; } function sortTheTable2(idtbl){ $(function() { var elems = $.makeArray($('tr:has(.sort2)').remove()) elems.sort(sortNum2) $('table#'+idtbl).append($(elems)); }); } function openTiersTab(elem, tabName,scroll) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(tabName).style.display = "block"; elem.className += " active"; if(scroll == null || scroll == true){ $("html, body").animate({scrollTop : 0}); } } window.onscroll = function() {myFunction()}; //Get the header //var header = document.getElementById("myHeader"); //Get the offset position of the navbar //var sticky = document.getElementById("myHeader").offsetTop; //Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position function myFunction() { if (window.pageYOffset > document.getElementById("myHeader").offsetTop) { document.getElementById("myHeader").classList.add("sticky"); } else { document.getElementById("myHeader").classList.remove("sticky"); } } function topForm(){ $("html, body").animate({scrollTop : 0}); } function bottomForm(){ $("html, body").animate({scrollTop : document.body.scrollHeight}); } function loadingPopUp(){ document.getElementById('light').style.display='block'; document.getElementById('fade').style.display='block'; document.getElementById('webform').style.display='none'; setTimeout(function(){return;}, 3000000); } function doSubmit(navigation) { f=document.forms[0]; if (navigation) { f.action+= '&' + navigation; } $("*[disabled]").css("visibility", "hidden"); $("*[disabled]").removeAttr("disabled"); // popup pour chargement loadingPopUp(); f.submit(); } function doSubmitAjax(navigation) { $("*[disabled]").css("visibility", "hidden"); $("*[disabled]").removeAttr("disabled"); for (var index = document.forms.length - 1; index > -1; index--) { var form = document.forms[index]; var formID = form.getAttribute("id"); // popup pour chargement if (navigation) { form.action+= '&' + navigation; } loadingPopUp(); if(index == 0){ form.submit(); }else{ var frm = $('#'+formID); $.ajax({ type: frm.attr('method'), url: frm.attr('action'), contentType: "application/x-www-form-urlencoded", data: frm.serialize(), async: false, success: function (data) { console.log('Submission was successful.'); console.log(data); }, error: function (data) { console.log('An error occurred.'); console.log(data); }, }); } }//for }//function