<script type="text/javascript">
$(document).ready(function() {   
   //Datepicker
   jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
   
   //Data table configurations
   var oTable = $("#test").dataTable({
	   	"iDisplayLength": 10,
		"aLengthMenu": [5,10,25,50,100],
		"sPaginationType": "full_numbers",
		"aoColumns": [	{"bSortable": false },
						null,
					<?php foreach($tbHdr as $v): ?>
						null,
					<?php endforeach; ?>
						{"bSortable": false }
					] 
	});
	oTable.fnSort( [ [1,'asc'] ] );
	
	//Item Count Adjust detail 
	$('.detail').live('click',function(){
		window.location = "<?php echo base_url() ?>itemcountadjust/reportdetail/"+$(this).parents('tr').find('.ID').text();
	});
   
}); 

function changeList(){
	var datefrom = $('#selDateFrom').val();
	var dateto = $('#selDateTo').val();
	var urls = "<?php echo base_url();?>itemcountadjust/report/"+datefrom+"/"+dateto;
		window.location = urls;
} 

 
</script>

<div id="content">                        
<div class="wrap">
<div class="head">
	<div class="info">
        <h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
            <?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>
        <ul class="breadcrumb">
            <li><a href='<?php echo base_url(); ?>'><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
            <li><a href="<?php echo base_url(); ?>/locationtransfer"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
            <li class="active"><?php echo $this->lang->line('title') ?></li>
        </ul>
	</div>
	<div class="search">
		<form action="<?php echo base_url() ?>admin/search" method="post">
			<input name="search_text" type="text" placeholder="search..."/>                                
            <button type="submit"><span class="i-magnifier"></span></button>
		</form>
	</div>                        
</div><!-- head --> 
<div class="content">
	<!--Company information start-->
   	<?php //$this->load->view('layouts/rptheader'); ?>
    <!--Company information end-->
    
	<div class="wrap">        
        <div class="content">
            <div class="wrap">   
                
                <div class="row-fluid">
                    <div class="span12">
                        <div class="block">
                        	<div class="head">
                            	<h2><?php echo $this->lang->line('selectDate') ?></h2>
                            </div>
                            <div class="content">
                				<div class="controls-row"><!-- Row 4-->
                                    <div class="span5 tac">
                                    <div class="span2 tar"><?php echo form_label($this->lang->line('dateFrom'));?></div>
                                    <div class="input-prepend">
                                    <span class="add-on"><i class="i-calendar"></i></span>
                                             <?php
                                                    $data = array(
                                                    'name' => 'selDateFrom',
                                                    'id' => 'selDateFrom',
                                                    'type' => 'text',
                                                    'class' => 'datepicker2',);
                                                    $js='onChange="changeList()"';
                                                    echo form_input($data, date(element('dtFormat', $this->session->userdata('logged_in')), strtotime($dateFrom)), $js);
                                                    
                                                ?>
                                    </div>       
                                    </div>
                                    <div class="span5 tac">
                                    <div class="span2 tar"><?php echo form_label($this->lang->line('dateTo'));?></div>
                                    <div class="input-prepend">
                                    <span class="add-on"><i class="i-calendar"></i></span>
                                             <?php
                                                    $data = array(
                                                    'name' => 'selDateTo',
                                                    'id' => 'selDateTo',
                                                    'type' => 'text',
                                                    'class' => 'datepicker2',);
                                                    $js='onChange="changeList()"';
                                                    echo form_input($data, date(element('dtFormat', $this->session->userdata('logged_in')), strtotime($dateTo)), $js);
                                                ?>
                                    </div>       
                                    </div>
                                </div><!-- End Row 4-->
                            </div>
                            <div class="footer"></div>
                        </div>
                        <div class="block">                            
                            <div class="head">
                                <h2><?php echo $this->lang->line('title') ?></h2>
                                <ul class="buttons">
                                     <li><a href="<?php echo base_url()?>itemcountadjust/printReport/<?php echo $dateFrom.'/'.$dateTo; ?>" name="updatePosting" onclick=""><?php echo $this->lang->line('print') ?></a></li>
                                     <!--<li><a href="<?php echo base_url(); ?>itemcountadjust/" title="Add New"><span class="i-plus-2"></span></a></li>-->
                                </ul>
                            </div><!-- head -->
                            <div class="content np table-sorting">
                                <table cellpadding="0" cellspacing="0" width="100%" id="test" class="editable itemTbl">
                                    <thead>
                                    <tr>
                                    	<th style="display:none;">&nbsp;</th>
                                    	<th class="tac">#</th>
                                    <?php foreach($tbHdr as $row): ?>
                                        <th class="tac"><?php echo $this->lang->line($row); ?></th>
                                    <?php endforeach; ?>  
                                    	<th width="55" class="tac"><?php echo $this->lang->line('action');?></th> 
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php $bil = 0; 
                                    if(isset($datatbls) && !empty($datatbls)):
                                        foreach($datatbls as $item):
                                        $bil++?>
                                        <tr class="itemList">
                                        	<td class="ID" style="display:none"><?php echo $item->ID; ?></td>
                                        	<td class="tac"><?php echo $bil; ?></td>
										<?php foreach($tbHdr as $row): ?>
                                            <td class="tac span2"><?php echo $item->$row; ?></td>
                                        <?php endforeach; ?>    
                                        	<td class="tac"><?php
												$js = 'class="btn btn-mini btn-primary detail" title="'.$this->lang->line("Show Detail").'"';
												echo form_button('edit','<span class="i-pen">',$js); ?>
											</td>
                                        </tr>
                                        <?php 
                                        endforeach;
                                    endif;?>
                                    </tbody>         
                                </table>
                            </div><!-- content -->
                            <div class="footer">
                                <div class="side fr">
                                    <div class="btn-group">
                                        &nbsp;	
                                    </div>
                                </div>
                            </div><!--Footer-->                                    
                        </div><!-- block -->
                    </div><!-- span12 -->
                </div><!-- row-fluid -->	
            </div><!-- wrap -->
        </div><!-- content -->
	</div>
</div>
