function selectPresents(checkbox_object, subscription_id, sf_type) { var div_name = "sub_div_" + sf_type + "_" + subscription_id + ""; var div_object = document.getElementById('' + div_name + ''); var sub_count_name = "sub_row_count_" + sf_type + "_" + subscription_id + ""; if (checkbox_object.checked == false) { //vynuluj pocet objednanych predplatnych document.getElementById('' + sub_count_name + '').value = 0; countPrice(subscription_id, sf_type); //zrus vsetky darceky var input_childs = div_object.getElementsByTagName('input'); for (var i = 0; i < input_childs.length; i++) { input_childs[i].checked = false; } div_object.style.backgroundColor = "#FFFFFF"; // alert(document.getElementById('num_of_unselected_presents').value); document.getElementById('num_of_unselected_presents').value--; } else { //ak mam iba jeden mozny darcek, mal by som ho hned vyplnit //ak mam viac ako jeden darcek, mal by som byt upozorneny ze bacha zober si darcek, mojko //pri druhej moznosti dam cervenym pozadie darcekoveho pola var input_childs = div_object.getElementsByTagName('input'); if (input_childs.length == 1) { //je iba jeden darcek input_childs[0].checked = true; } else if (input_childs.length > 1) { //je viac ako jeden darcek alert("K zvolenému predplatnému si prosím nezabudnite vybrať darček"); div_object.style.backgroundColor = "#f6d1c9"; document.getElementById('num_of_unselected_presents').value++; } document.getElementById('' + sub_count_name + '').value = 1; countPrice(subscription_id, sf_type); } } function countPrice(subscription_id, sf_type) { var sub_count_name = "sub_row_count_" + sf_type + "_" + subscription_id + ""; var sub_price_name = "sub_row_price_" + sf_type + "_" + subscription_id + ""; var sub_total_name = "sub_row_total_" + sf_type + "_" + subscription_id + ""; var sub_count = document.getElementById('' + sub_count_name + '').value; var sub_price = document.getElementById('' + sub_price_name + '').innerHTML; var priceTotal = sub_price * sub_count; //document.getElementById('' + sub_total_name + '').innerHTML = priceTotal; document.getElementById('' + sub_total_name + '').innerHTML = priceTotal.toFixed(2);var Tp = new Number(((priceTotal*30.126)*100)/100);var priceTotal_convert = Tp.toFixed(0);var vypis = " " + priceTotal_convert + " ";var sub_bublina_name = "sub_buble_" + subscription_id +"";document.getElementById('' + sub_bublina_name + '').innerHTML = vypis //ak som zadal priamo do inputu pocet, odfajkni checkbox var sub_checkbox = "subscription_" + sf_type + "_" + subscription_id + ""; if (sub_count == 0) { document.getElementById('' + sub_checkbox + '').checked = false; } else { document.getElementById('' + sub_checkbox + '').checked = true; } countTotalPrice(); } function countTotalPrice() { var main_table = document.getElementById('subscription_table_subscriptions'); var input_childs = main_table.getElementsByTagName('input'); var num_of_subscriptions = 0; var total_sum = 0; for (var i = 0; i < input_childs.length; i++) { var input_id_string = new String(input_childs[i].id); if (input_id_string.substr(0, 14) == "sub_row_count_") { var element_identifier = input_id_string.substr(14); var total_price_span_name = "sub_row_total_" + element_identifier + ""; num_of_subscriptions = num_of_subscriptions - (-input_childs[i].value); total_sum = total_sum - (-document.getElementById('' + total_price_span_name + '').innerHTML); // alert(input_id_string + " / " + element_identifier + " / " + total_price_span_name); } document.getElementById('sub_sum_count').innerHTML = num_of_subscriptions; document.getElementById('sub_sum_count_input').value = num_of_subscriptions; document.getElementById('sub_sum_total_price').innerHTML = total_sum; var Tp = new Number(total_sum*30.126);document.getElementById('convert_sub_sum_total_price').innerHTML = Tp.toFixed(0); } } function checkNumOfPresents(sf_type, element_id, action_id, num_of_alloved, element_nr) { var main_input_name = "subscription_" + sf_type + "_" + element_id; var main_input_object = document.getElementById('' + main_input_name + ''); var input_name = "sub_present_" + sf_type + "_" + element_id + "_" + action_id + "_p"; var div_name = "sub_div_" + sf_type + "_" + element_id + ""; var div_object = document.getElementById('' + div_name + ''); // alert(main_input_object.checked); // if (main_input_object.checked == true) { // //ak mam vyplnene // // // div_object.style.backgroundColor = "#ffffff"; // } else { // //divko v ktorom su predploatne dat zasa pekne bielou // div_object.style.backgroundColor = "#f6d1c9"; // } if (main_input_object.checked == false) { if (confirm('Nie je možné dostať darček bez zvolenia si predplatného, prajete si objednať uvedené predplatné?')) { document.getElementById('' + main_input_name + '').checked = true; //nastav ze chcem jedno predplatne var sub_count_name = "sub_row_count_" + sf_type + "_" + element_id + ""; document.getElementById('' + sub_count_name + '').value = 1; countPrice(element_id, sf_type); } else { document.getElementById('' + input_name + '[' + element_nr + ']').checked = false; } //ak je zvolene predplatne a nie je zvoleny darcek, vykreslit celu plochu na ruzovo } else { var input_childs = div_object.getElementsByTagName('input'); var num_of_checked_children = 0; for (var i = 0; i < input_childs.length; i++) { if (input_childs[i].checked == true) { num_of_checked_children++; } } if (num_of_checked_children == 0) { div_object.style.backgroundColor = "#f6d1c9"; document.getElementById('num_of_unselected_presents').value++; } else { div_object.style.backgroundColor = "#FFFFFF"; document.getElementById('num_of_unselected_presents').value--; } } //mozem mat teoreticky 4 darceky, je otazka kolko z nich mozem rozdat var present_1 = document.getElementById('' + input_name + '[1]'); var present_2 = document.getElementById('' + input_name + '[2]'); var present_3 = document.getElementById('' + input_name + '[3]'); var present_4 = document.getElementById('' + input_name + '[4]'); var num_of_selected = 0; if (present_1 != null) { if (present_1.checked == true) { num_of_selected = num_of_selected + 1; } } if (present_2 != null) { if (present_2.checked == true) { num_of_selected = num_of_selected + 1; } } if (present_3 != null) { if (present_3.checked == true) { num_of_selected = num_of_selected + 1; } } if (present_4 != null) { if (present_4.checked == true) { num_of_selected = num_of_selected + 1; } } if (num_of_selected > num_of_alloved) { alert("Nie je možné vybrať si viac ako " + num_of_alloved + " darčekov"); document.getElementById('' + input_name + '[' + element_nr + ']').checked = false; } } function checkSubscription() { var firstname = document.getElementById("firstname"); var surname = document.getElementById("surname"); var company = document.getElementById("company"); var address = document.getElementById("address"); var town = document.getElementById("town"); var psc = document.getElementById("psc"); var ico = document.getElementById("ico"); var icodph = document.getElementById("icodph"); var tel = document.getElementById("tel"); var email = document.getElementById("email"); var name_ob = document.getElementById("name_ob"); var surname_ob = document.getElementById("surname_ob"); var address_ob = document.getElementById("address_ob"); var town_ob = document.getElementById("town_ob"); var psc_ob = document.getElementById("psc_ob"); var tel_ob = document.getElementById("tel_ob"); var email_ob = document.getElementById("email_ob"); var other_address = document.getElementById('other_address'); var sub_sum_count_input = document.getElementById('sub_sum_count_input'); var payment_method_1 = document.getElementById("payment_method_1"); var payment_method_2 = document.getElementById("payment_method_2"); var num_of_unselected_presents = document.getElementById("num_of_unselected_presents"); // alert(sub_sum_count_input.value); if (sub_sum_count_input.value < 1) { alert("Please choose a subscription" ); return false; } else if (firstname.value=="") { alert("Vyplňte, prosím, meno platcu" ); firstname.focus(); return false; } else if (surname.value=="") { alert("Vyplňte, prosím, priezvisko platcu" ); surname.focus(); return false; } else if (address.value=="") { alert("Vyplňte, prosím, adresu platcu" ); address.focus(); return false; } else if (town.value=="") { alert("Vyplňte, prosím, mesto platcu" ); town.focus(); return false; } else if (psc.value=="") { alert("Vyplňte, prosím, PSČ platcu" ); psc.focus(); return false; } else if (email.value=="") { alert("Vyplňte, prosím, email platcu" ); email.focus(); return false; } else if (company.value!="" && ico.value=="") { alert("Vyplňte, prosím, IČO platcu" ); ico.focus(); return false; } else if (company.value!="" && ico.value!="" && icodph.value=="") { alert("Vyplňte, prosím, IČO DPH platcu" ); icodph.focus(); return false; } else if (tel.value=="") { alert("Vyplňte, prosím, telefónne číslo platcu" ); tel.focus(); return false; } else if (other_address.checked == true && name_ob.value=="") { alert("Vyplňte, prosím, meno obdarovaného" ); name_ob.focus(); return false; } else if (other_address.checked == true && surname_ob.value=="") { alert("Vyplňte, prosím, priezvisko obdarovaného" ); surname_ob.focus(); return false; } else if (other_address.checked == true && address_ob.value=="") { alert("Vyplňte, prosím, adresu obdarovaného" ); address_ob.focus(); return false; } else if (other_address.checked == true && town_ob.value=="") { alert("Vyplňte, prosím, mesto obdarovaného" ); town_ob.focus(); return false; } else if (other_address.checked == true && psc_ob.value=="") { alert("Vyplňte, prosím, PSČ obdarovaného" ); psc_ob.focus(); return false; } else if (other_address.checked == true && tel_ob.value=="") { alert("Vyplňte, prosím, telefónne číslo obdarovaného" ); tel_ob.focus(); return false; } else if (other_address.checked == true && email_ob.value=="") { alert("Vyplňte, prosím, email obdarovaného" ); email_ob.focus(); return false; } else if (payment_method_1.checked == false && payment_method_2.checked == false) { alert("Vyberte prosím spôsob platby" ); return false; } else if (num_of_unselected_presents.value > 0) { alert("Vyberte si prosím všetky darčeky k predplatnému, nezvolené darčeky sú farebne odlíšené" ); return false; } else { return true; } } function otherAddress() { var other_address = document.getElementById('other_address'); var other_address_table = document.getElementById('other_address_table'); if (other_address.checked == true) { other_address_table.style.display = 'block'; } else { other_address_table.style.display = 'none'; } }