<script type="text/javascript">
$(document).ready(function() {   
	$('select').select2();

	$.each($(".select2-container"), function (i, n) {
        $(n).next().show().fadeTo(0,0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
        $(n).prepend($(n).next());
        $(n).delay(500).queue(function () {
            $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
            $(this).dequeue();
        });
    });	

	//Data table configurations
   var oTable = $("#test").dataTable({
	   	"iDisplayLength": 10,
		"aLengthMenu": [5,10,25,50,100],
		"sPaginationType": "full_numbers",
		"aoColumns": [	null,
						null,
						null,
						{"bSortable": false},
						{"bSortable": false}
					] 
	});
	oTable.fnSort( [ [1,'asc'] ] );
   
	$('#location').live('change',function(){
		if($(this).val() != 0 && $(this).val() != 'all'){
			window.location = "<?php echo base_url() ?>countsheet/index/"+$(this).val();
		}else if($(this).val() == 'all'){
			window.location = "<?php echo base_url() ?>countsheet/";
		}
		console.log($(this).val());
	});
}); 
 
</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">
                        <?php if(!empty($location)): ?>
                        <div class="block">
                        	<div class="head">
                            	<h2><?php echo $this->lang->line('selectLoc') ?></h2>
                            </div>
                            <div class="content">
                            	<div class="controls-row"><!-- Row 4-->
                                    <div class="span5 tac">
                                    	<div class="span4 tar"><?php echo form_label($this->lang->line('selectLoc'));?></div>
                                        <div class="span6">
                                            <?php
                                                $preselcat = $id?$id:'';
												$options[0] = '--Select Location--';
												$options['all'] = 'All';
                                                foreach($location as $row){
                                                    $options[$row->fldid] = $row->code;
                                                }
                                                $js='id="location" class="span12"';
                                                echo form_dropdown('location', $options, $preselcat, $js);
                                            ?>
                                        </div>
                                	</div>
                                </div>
                            </div>
                            <div class="footer"></div>
                        </div>
                        <?php endif; ?>
                        <div class="block">                            
                            <div class="head">
                                <h2><?php echo $this->lang->line('title') ?></h2>
                            	<ul class="buttons">
                                     <li><a href="<?php echo base_url()?>countsheet/printCountSheet/<?php echo $id; ?>" title="updatePosting" onclick=""><?php echo $this->lang->line('print') ?></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 class="tac"><?php echo $this->lang->line('item') ?></th>
                                        <th class="tac"><?php echo $this->lang->line('UOM') ?></th>
                                        <th class="tar"><?php echo $this->lang->line('quantity') ?></th>
                                        <th class="tar"><?php echo $this->lang->line('actualQuantity') ?></th>
                                        <th class="tac"></th>
                                        
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php $bil = 0; 
                                    if(isset($datatbls) && !empty($datatbls)):
                                        foreach($datatbls as $item):
                                        $bil++?>
                                        <tr class="itemList">
                                            <td class="tac span2"><?php echo '['.$item->itemCode.'] '.$item->itemName; ?></td>
                                            <td class="tac span2"><?php echo $item->UOM; ?></td>
                                            <td class="tar span2"><?php echo $item->quantity; ?></td>
                                            <td class="tac span2"></td>
                                            <td class="tac span2"></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>
