@extends('layouts.cartMaster') @section('linkscript') {{ HTML::script('js/vols_v5.js?'.filemtime('js/vols_v5.js')) }} @endsection @section('myscript') var callurl = '{{ Account::getUrl() }}'; @if(Account::getAccount()->code != "GVI" && Account::getAccount()->code != "GVQ") var autocompleteUrl = callurl + 'autocomplete/'; @else @if(Account::getAccount()->code == "GVI") var autocompleteUrl = "http://gvi20.otfsystems.com/autocomplete/"; @else var autocompleteUrl = "http://gvq20.otfsystems.com/autocomplete/"; @endif @endif $(document).ready(function () { if(account == "ICN") { //$("#sell").attr('readonly', true); $( "#cost" ).on('change' , function(e) { updateSell(); }); $( "#cost" ).keyup(function() { updateSell(); }); } function updateSell() { var value = parseFloat($("#cost").val()); $("#sell").val((value + (value * 0.2))); } sel1 = createDll('origin', 'hOrigin'); sel2 = createDll('destination', 'hDestination'); sel1.onChange = function (_txt, _val) { $("#hOrigin").val(_txt); $("#holderLieuDepart_tvalue").val(_val); }; sel2.onChange = function (_txt, _val) { $("#hDestination").val(_txt); $("#holderLieuDestination_tvalue").val(_val); }; sel1.show(); sel2.show(); $( "#hOrigin" ).keyup(function() { setDestination('hOrigin' , sel1, 'gateway',1); }); $( "#hDestination" ).keyup(function() { setDestination('hDestination' , sel2, 'dest',1); }); $('#origin_tvalue').prop('name', 'origin_code'); $('#destination_tvalue').prop('name', 'destination_code'); $('#hOrigin').on('focus', function(e) { $('#holderLieuDepart_tvalue').attr('value', '|||||'); $('#hOrigin').val(''); }); $('#hDestination').on('focus', function(e) { $('#holderLieuDestination_tvalue').attr('value', '|||||'); $('#hDestination').val(''); }); $("#hDestination").prop('required', true); $( "#checkin, #checkout" ).keyup(function() { formValidate(); }); $( "#checkin, #checkout" ).change(function() { formValidate(); }); /* $("#cost").change(function() { calculateTaxes('cost'); }); $("#sell").change(function() { calculateTaxes('sell'); }); */ @if(isset($comp->dep)) $('#holderLieuDepart_tvalue').attr('value', "{{$comp->dep}}|||||"); $('#hOrigin').val("{{$comp->dep}}"); @endif @if(isset($comp->code)) $('#holderLieuDestination_tvalue').attr('value', "{{$comp->code}}|||||"); $('#hDestination').val("{{$comp->code}}"); @endif @if(isset($comp->checkin)) let checkin = '{{$comp->checkin}}'; let checkout = '{{$comp->checkout}}'; checkin = new Date(parseInt(checkin.substr(0,4)), parseInt(checkin.substr(5,2))-1, parseInt(checkin.substr(8,2))); checkout = new Date(parseInt(checkout.substr(0,4)), parseInt(checkout.substr(5,2))-1, parseInt(checkout.substr(8,2))); $("#checkin").datepicker('setDate', checkin); $("#checkout").datepicker('setDate', checkout); sel1.setText("{{$comp->dep}}"); sel2.setText("{{$comp->dest}}"); @endif }); function formValidate(isSubmit) { let valide = true; $("#compTitle").css("border-color", ""); $("#occTitle").css("border-color", ""); $("#checkin").css("border-color", ""); $("#checkout").css("border-color", ""); $("#hDestination").css("border-color", ""); $("#cost").css("border-color", ""); $("#sell").css("border-color", ""); $("#pc_type").css("border-color", ""); if($("#checkin").val() == "") { $("#checkin").css("border-color", "red"); valide = false; return; } if($("#checkout").val() == "") { $("#checkout").css("border-color", "red"); valide = false; return; } let checkin = new Date($("#checkin").datepicker('getUTCDate')); let checkout = new Date($("#checkout").datepicker('getUTCDate')); if(checkout < checkin) { $("#checkin").css("border-color", "red"); $("#checkout").css("border-color", "red"); valide = false; return; } if(isSubmit) { if($("#compTitle").val() == "") { $("#compTitle").css("border-color", "red"); valide = false; return; } if($("#occTitle").val() == "") { $("#occTitle").css("border-color", "red"); valide = false; return; } if($("#hDestination").val() == '') { $("#hDestination").css("border-color", "red"); valide = false; return; } if($("#cost").val() == '') { $("#cost").css("border-color", "red"); valide = false; return; } if($("#sell").val() == '') { $("#sell").css("border-color", "red"); valide = false; return; } /*if($("#pc_type").val() == '-1') { $("#pc_type").css("border-color", "red"); valide = false; return; }*/ if(valide) { $("#hOrigin").prop('name', 'origin'); $("#hDestination").prop('name', 'destination'); $("#fakeCompForm").submit(); } } } function calculateTaxes(price) { let amount = $("#"+price).val(); $("[id^='taxe_rate_']").each(function(){ let taxe = $(this).prop('id').split('_')[2]; if($(this).val() > 0){ let newTaxe = parseFloat(amount*($(this).val()/100)).toFixed(2); $("#taxe_"+price+"_"+taxe).val(newTaxe); } }); } @endsection @section('pageContent')