<script type="text/javascript">
$(document).ready(function() {
   /* Build the DataTable with third column using our custom sort functions */
   
   //Data table configurations
   var oTable = $("#test").dataTable({
	   	"iDisplayLength": 10,
		"aLengthMenu": [5,10,25,50,100],
		"sPaginationType": "full_numbers",
		"aoColumns": [{"bSortable": false},
						{"bSortable": false},
						{"bSortable": false},
						null,
						null,
						null,
						null,
						null,
						{"bSortable": false},
						{"bSortable": false}
					] 
	});
	oTable.fnSort( [ [1,'asc'] ] );
	
   	$("table .checkall1").live("click", "checkall1",function(){           
		$(oTable.fnGetNodes()).find(':checkbox').prop('checked', this.checked);
	});
	
    $("table.editable").on("click",".edit",function(){
        //rRow = $(this).parents("tr");
        ID = $(this).parents('tr').find('.itemID').text(); 
        $("#row_edit").dialog("open");
    });
	
	$("#row_edit").dialog({
        autoOpen: false,
        resizable: false,        
        modal: true,
        buttons: {
            "Continue...": function() {
				window.location.href = "<?php echo base_url();?>locationtransfer/edit/" + ID;		
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close");
            }
        }
    });
   /*
    $("table.editable").on("click",".copy",function(){
        rRow = $(this).parents("tr");
        fldid = $('td:first', $(this).parents('tr')).text(); 
        $("#row_edit").dialog("open");
    });
    $("#row_edit").dialog({
        autoOpen: false,
        resizable: false,        
        modal: true,
        buttons: {
            "Continue...": function() {
				window.location.href = "<?php echo base_url();?>GLtransaction/jlCopy/" + fldid;		
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close");
            }
        }
    });*/  
	
	//Remove location transfer information
	$('.remove').live('click',function(){
		var url = $(this).attr('href');
		
		$('#popupModal').modal('show');
		$("#_popupTitle").html("Confirm delete");
		$("#_popupContent").html("Your about to delete definively this row. <br/> Click on ok to confirm");
		
		$('#_popupFooter').empty();
		   $('#_popupFooter').append('<button class="btn-form btn-success-form" id="detButton">Ok</button>' +
		'<button class="btn-form btn-danger-form" id="canb">Cancel</button>');
		$("#_popupTitle").html("Confirm delete");
		$( "#canb" ).click(function() {
			$('#popupModal').modal('hide');
		});
		
		$( "#detButton" ).live('click',function() {
			$('#popupModal').modal('hide');
			window.location = url;
		});
		
		return false;
	});  

	//Confirm transection
	$('.confirm').live('click',function(){
		var transferList = '';
		$('.itemList').each(function(){
			if($(this).find('input:checked').attr('checked') == 'checked'){
				if(transferList == '')	transferList += $(this).find('.itemID').text();
				else					transferList += ','+$(this).find('.itemID').text();
			}
		}); 
		jQuery.ajax({
			url: "<?php echo base_url(); ?>locationtransfer/confirm/",
			async: false,
			type: "POST",
			data: 'locID='+transferList,
			dataType: "html",
			success: function(data) {
				if(data == 'success'){
					location.reload();	
				}	
			}
		});
	});
}); 
 
function changeList(){
	var addyear = $('#add_year option:selected').val();
	var addper = $('#add_period option:selected').val();
	var urls = "<?php echo base_url();?>GLtransaction/journalCopy/"+addyear+"/"+addper;
		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">
	<div class="wrap">
        <!--Alert Message start-->
        <?php 	
			$message = $this->session->flashdata('msg');
			$alert = $this->session->flashdata('danger-msg');
			if(isset($message) && $message != ''): ?>
            <div class="content alertbox">                                                
                <div class="row-fluid">
                    <div class="span12">        
                        <div class="alert alert-success">            
                            <strong>Success! </strong><?php echo $message;?>
                        </div>       
                    </div>
                </div>
            </div>
        <?php	
			elseif(isset($alert) && $alert != ''): ?>
            <div class="content alertbox">                                                
                <div class="row-fluid">
                    <div class="span12">        
                        <div class="alert alert-error">            
                            <strong>Deleted! </strong><?php echo $alert;?>
                        </div>       
                    </div>
                </div>
            </div>
		<?php endif; ?>
        <!--Alert Message end-->
        <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('title') ?></h2>
                                <div class="side fr">
                                    <a href="<?php echo base_url(); ?>locationtransfer/add" class="btn-icon btn-mini btn-warning-form" title="Add New">
									<span class="i-plus-2"></span></a>
                                </div>
                            </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"></th>
                                    <th class="tac" style="display:none;"><?php echo $this->lang->line('locID') ?></th>
                                    <th class="tac">#</th>
                                    <th class="tac"><?php echo $this->lang->line('formNo') ?></th>
                                    <th class="tac"><?php echo $this->lang->line('fromLocation') ?></th>
                                    <th class="tac"><?php echo $this->lang->line('toLocationID') ?></th>
                                    <th class="tac"><?php echo $this->lang->line('movementType') ?></th>
                                    <th class="tac"><?php echo $this->lang->line('locTransMemo') ?></th>
                                    <th class="tac"><?php echo $this->lang->line('transferDate') ?></th>
                                    <!--<th class="tac"><?php echo $this->lang->line('edit') ?></th> -->                                   
                        			<th class="tac"><input type="checkbox" id="checkall1" class="checkall1"/></th>
                                    <!--<th class="tac"><?php echo $this->lang->line('delete') ?></th>-->
                                    
                                </tr>
                                </thead>
                                <tbody>
								<?php $bil = 1; 
                                if(isset($datatbls) && !empty($datatbls)):
                                    foreach($datatbls as $item):
                                    ?>
                                    <tr class="itemList itemList<?php $item->ID; ?>">
                                        <td class="itemID" style="display:none" ><?php echo $item->ID; ?></td>
                                        <td class="tac" style="display:none"><?php echo $item->ID; ?></td>
                                        <td class="tac"><?php echo $bil++; ?></td>
                                        <td class="tac"><a href="javascript:" class="edit"><?php echo $item->FormNo; ?></a></td>
                                        <td class="tac"><?php echo $item->fromLoc; ?></td>
                                        <td class="tac"><?php echo $item->toLoc; ?></td>
                                        <td class="tac"><?php echo $item->movetype; ?></td>
                                        <td class="tac"><?php echo $item->memo; ?></td>
                                        <td class="tac"><?php echo $item->dateTransfer; ?></td>
                                        <!--<td class="tac">
                                            <div class="btn-toolbar">
                                                <div class="btn-group">
                                                    <a href="javascript:<?php //echo site_url("locationtransfer/edit/".$item->ID); ?>" class="btn btn-mini btn-primary edit"><i class="icon-pencil"></i></a>
                                                </div>
                                            </div>
                                        </td>-->
					                    <td class="tac"><input type="checkbox" class="checkbox" id="checkbox"/></td>
                                        <!--<td>    
                                        	<div class="btn-toolbar">
                                                <div class="btn-group">
                                                    <a href="<?php echo site_url("locationtransfer/delete/".$item->ID); ?>" class="btn btn-mini btn-danger remove"><span class="icon-remove"></span></a>
                                                </div>
                                            </div>
                                        </td>-->
                                    </tr>
                                    <?php 
                                    endforeach;
                                endif;?>
                            	</tbody>         
                            </table>
                        </div><!-- content -->
                        <div class="footer">
                            <div class="side fr">
                                <div class="btn-group">
                                    <?php 
                                        $data = array(
                                                'name'=>'postcrdtn', 
                                                'class'=>'btn-form btn-warning-form confirm');
                                        echo form_submit($data,$this->lang->line('confirmTransaction'));
                                        ?>
                                </div>
                            </div>
                        </div>                                    
                        </div><!-- block -->
                    </div><!-- span12 -->
                </div><!-- row-fluid -->	
            </div><!-- wrap -->
        </div><!-- content -->
	</div>
</div>
</div>
</div>
<div class="dialog" id="row_edit" style="display: none;" title=". <?php echo $this->lang->line("edit") ?> . ?">
    <p><?php echo $this->lang->line('message2');?></p>
</div>  