var baseURL=$('meta[name="base_url"]').attr('content');
var token_key=$('#token_key').val();

$('#date-report').click(function(){
            var date = $('#date').val();
            var result=$('#dailyResult').val();
            if((date=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }
            else {
                window.open('testReport/dailyStatement?date=' + date + '&result='+result+'');
            }
        });
        $('#date-details-report').click(function(){
            var date = $('#date').val();
            if((date=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });
            }
            else {
                window.open('salesStatement/dailyDetailsStatement/'+ date+'');
            }

        });
        $('#date-range-report').click(function(){
            var start_date = $('#start_date').val();
            var end_date = $('#end_date').val();
            var result=$('#dateRangeResult').val();
            report_start_date = start_date.split('-');
            report_end_date = end_date.split('-');

            var new_start_date = new Date(report_start_date[2],report_start_date[1],report_start_date[0]);
            var new_end_date = new Date(report_end_date[2],report_end_date[1],report_end_date[0]);

            if(new_end_date<new_start_date){
                swal({
                    title: "End date can't less than start date",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'
                });
            }
            else if((start_date=='' || end_date=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }

            else {
                window.open('testReport/dateRangeStatement?start_date=' + start_date + '&end_date=' + end_date + '&result='+result+'');
            }
        });


        $('#date-range-details-report').click(function(){
            var start_date = $('#start_date').val();
            var end_date = $('#end_date').val();
            report_start_date = start_date.split('/');
            report_end_date = end_date.split('/');

            var new_start_date = new Date(report_start_date[2],report_start_date[1],report_start_date[0]);
            var new_end_date = new Date(report_end_date[2],report_end_date[1],report_end_date[0]);

            if(new_end_date<new_start_date){
                swal({
                    title: "End date can't less than start date",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'
                });
            }
            else if((start_date=='' || end_date=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }
            else {
                window.open('salesStatement/dateRangeDetailsStatement/'+ start_date+'&'+end_date+'');
            }

        });
        $('#month_year').click(function(){
            var month = $('#month').val();
            var year = $('#year').val();
            var result=$('#monthlyResult').val();
            if((month=='' || year=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }
            else {
                window.open('testReport/monthlyStatement?month=' + month+ '&year='+year+'&result='+result+'');
            }
        });
        $('#month_year-details-report').click(function(){
            var month = $('#month').val();
            var year = $('#year').val();
            var month_year=month+'&'+year;
            if((month=='' || year=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }
            else {
                window.open('salesStatement/monthlyDetailsStatement/'+month_year+'');
            }

        });
        $('#year_report').click(function(){
            var year = $('#year_only').val();
            var result=$('#yearlyResult').val();
            if((year=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }
            else {
                window.open('testReport/yearlyStatement?year='+year+'&result='+result+'');
            }
        });
        $('#year-details-report').click(function(){
            var year = $('#year_only').val();
            if((year=='')){
                swal({
                    title: "Nothing is selected",
                    type: "error",
                    timer: 1500,
                    showConfirmButton: false,
                    customClass: 'swal-height'

                });

            }
            else {
                window.open('salesStatement/yearlyDetailsStatement/'+year+'');
            }
        });
