<?php
$this->load->view ( $left );
$this->load->view ( $header );
?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>Debit Note List</h2>
    </div>
    <div class="col-sm-8">
        <div class="title-action">
            <a href="<?php echo site_url("debit_note/new_debit_note");?>" class="btn btn-primary addNewUser">
                <i class="fa fa-plus-square-o"></i>
                <span class="m-l-xs">Create Debit Note</span>
            </a>
        </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($debit_note_list) > 0) {
                    foreach ($debit_note_list as $key_debit_note => $value_debit_note) {
                        ?>
                        <tr data-dbtnote="<?php echo $value_debit_note->devid_note_no;?>" class="print_debit_note">
                           <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" 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'
			]
		} );
	   
        jq(document).on('click','.print_debit_note',function(){
            var dbtno = $(this).data('dbtnote');
            window.location.href = '<?php echo site_url("debit_note/debit_note_print/'+dbtno+'");?>';
        });

    });

</script>	