<?php require('includes/finance/finance_functions.php');?>

<div id="start" class="mt-n5">

    <div class="col-12 "><span class="badge badge-pill badge-info">1</span> Select client and date range to begin</div>
    <hr>
    <div class="row">
        <div class="col-12 col-md-4">
            <div class="col-12 lead"><label for="date_start">SELECT CLIENT</label></div>
            <div class="col-12"><?= listClient($_REQUEST['clientnumber'],'clientnumber','select')?></div>
        </div>

        <div class="col-12 col-md-8">
            <div class="col-12 lead"><label for="date_start">SELECT DATE RANGE</label></div>
            <div class="row">
                <div class="col-12 col-md-6 input-group mb-4"><input class="form-control datepicker2" type="text" name="date_start" id="date_start" placeholder="START DATE" /></div>
                <div class="col-12 col-md-6 input-group mb-4"><input class="form-control datepicker2" type="text" name="date_end" id="date_end" placeholder="END DATE" value="<?= date('d-m-Y')?>" /></div>
            </div>
        </div>
    </div>
    <div class="col-md-12 text-center">
        <a href="javascript:void(0)" onClick="loadData()" class="btn btn-info">Next</a>
    </div>
</div>

<div id="data"></div>


<script>
function loadData() {
    var cn = $('#clientnumber').val()
    var ds = $('#date_start').val()
    var de = $('#date_end').val()
    if (cn === '' || ds === '' || de === '') {
        response('warning', 'Please complete all fields before proceeding')
    } else {
        $('#start').css('display', 'none')
        $('#data').load('includes/finance/statement_data.php?clientnumber=' + cn + '&start=' + ds + '&end=' + de + '&mode=choose').css('display', 'block')
    }
}

$('#navBox').html(
    '<li class="breadrumb-item"><a href="index.php?t=includes/finance&p=finance_invoices.php">Finance</a><i class="fad fa-angle-double-right mx-2 mt-1"" aria-hidden="true"></i></li><li class="breadrumb-item active">Statements</li>')
$(".datepicker2").pickadate({
    format: 'dd-mm-yyyy'
})
</script>