<?php
$this->load->view ( $left );
$this->load->view ( $header );
?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-12">
        <h2>Debit Note List</h2>
    </div>
    <div class="ibox float-e-margins">
        <div class="ibox-content" style="padding: 15px 20px 15px 20px;">
            <div class="row">
                <div class="col-lg-3">
                    <label class="col-lg-3 m-t-xs">From</label>
                    <div class="date_calender col-lg-9">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input type="text" name="start_date" id="start_date" class="form-control" value="<?php echo (!empty($start_date) ? date('d/m/Y',strtotime(str_replace('/', '-', $start_date))) : date('d/m/Y'));?>">
                        </div>
                    </div>
                </div>
                <div class="col-lg-3">
                    <label class="col-lg-3 m-t-xs">To</label>
                    <div class="date_calender col-lg-9">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input type="text" name="end_date" id="end_date" class="form-control" value="<?php echo (!empty($end_date) ? date('d/m/Y',strtotime(str_replace('/', '-', $end_date))) : date('d/m/Y'));?>">
                        </div>
                    </div>
                </div>
                <div class="col-lg-1"><button type="button" class="btn btn-info generate_report"><i class="fa fa-search"></i> Search</button></div>
            </div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row text-center animated fadeInRightBig">
        <table class="table" id="myTable">
        	<thead>
        		<tr>
        			<th>Date</th>
                    <th>Debit Note#</th>
        			<th>Bill#</th>
                    <th>Customer</th>
                    <th>Amount</th>
        		</tr>
        	</thead>
            <tbody>
                <?php 
                if (count($report) > 0) {
                    foreach ($report as $key_debit_note => $value_debit_note) { ?>
                        <tr>
                           <td><?php echo !empty($value_debit_note->devid_date) ? date('d/m/Y',strtotime(str_replace('-', '/', $value_debit_note->devid_date))) : '';?></td>
                           <td><?php echo !empty($value_debit_note->devid_note_no) ? $value_debit_note->devid_note_no : '';?></td>
                           <td><?php echo !empty($value_debit_note->bill_no) ? $value_debit_note->bill_no : '';?></td>
                           <td><?php echo !empty($value_debit_note->name) ? $value_debit_note->name : '';?></td>
                           <td><?php echo !empty($value_debit_note->total ) ? number_format((float)$value_debit_note->total, 2, '.', '') : '';?></td>
                        </tr>
                <?php }
                }?>
            </tbody>
        </table>
    </div>
</div>
<?php $this->load->view($footer); ?>
<script type="text/javascript">
	$(document).ready(function(){
        
        $('.date_calender .input-group.date').datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            calendarWeeks: true,
            language: 'en',
            autoclose: true
        });

        $('.generate_report').on('click',function(){ 
            var from = chage_date_format($('#start_date').val());
            var to = chage_date_format($('#end_date').val());
            window.location.href = '<?php echo site_url("reports/debit_note_list/'+from+'/'+to+'");?>';
        });

	});
</script>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js"></script>
    <script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="//cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script> 	
	<script src="//cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
	<script src="//cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script> 
    <script src="//cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>

<script type="text/javascript">
	var jq = jQuery.noConflict();

	jq(document).ready(function() {
	jq('#myTable').DataTable( {
			dom: 'Bfrtip',
			buttons: [
				'copy', 'csv', 'excel', 'pdf', 'print'
			]
		} );
	} );

</script>	