<script type="application/javascript">
$(document).ready(function() {
	$("#grid_block_5").hide();
	$('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();
            });
        });	
		jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
});
function selectCustomer(){
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/customerSearch',
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
//					items.push('<option value=""><?php echo $this->lang->line('pleaseselect')?></option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].ID+'">'
//						+ content.message[i].code + ' [ '+ content.message[i].desc + ' ]</option>');
						+ content.message[i].customerName + ' [ ' + content.message[i].accountCode + ' ]</option>');
					}
//					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#customerID";
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}
function refreshLocation(){
 $.ajax({
	type: "POST",
	url: "<?php echo base_url() ?>purchasetransaction/refreshLocation",
	success: function(data) {
	
	   var resul = eval ("(" + data + ")"); 
	   var n=resul.records.length;
	   var i=0;
	   var opt='' +
		'<option></option>';
		for (i=0;i<n;i++)
			opt=opt + '<option value="' + resul.records[i].id +'">' + resul.records[i].location + '</option>';
		$('#locationID').empty();
		$('#locationID').append(opt);
	}
   });	
}
function selectSO(obj){
//						alert($("#salesorder option:selected").val());
	var customerID = obj.value;
			postData = {
				customerID : customerID
			};
	if($("#salesorder option:selected").val() == 0){ 
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/SalesOrderSearch',
			dataType:"json",
			data: postData,
			success: function(content){
				if(content.status == "success") {
					var items = [];
					items.push('<option value=""><?php echo $this->lang->line('pleaseselect')?></option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].ID+'">'
//						+ content.message[i].code + ' [ '+ content.message[i].desc + ' ]</option>');
						+ content.message[i].OrderNo + '</option>');
					}
//					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#salesorder";
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
						$('#currencyID').val(content.message1.currencyID).change();
						$('#exchangeRate').val(parseFloat(content.exchangeRate).toFixed(5));
					return false;
			}
		});
	}
	$("#grid_block_5").show();
	return;
}
function fromSO(obj){
 	$("#oTable tbody tr").remove(); 	
	var soID = obj.value;
//	alert(soID);
	postData = {
		soID : soID
	};
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/soDetailsSearch',
			dataType:"json",
			data: postData,
			success: function(content){
				if(content.status == "success") {
					for ( var i = 0; i < content.message.length; i++) {
    						$("#oTable tbody").append(
							"<tr><td style='display:none'>"+content.message[i].ID+"</td>" +
        					"<td>"+content.message[i].itemCode+"</td>" +
        					"<td>"+content.message[i].description+"</td>" +
        					"<td>"+(content.message[i].requiredDate).substr(8, 2) + 
							"-" + (content.message[i].requiredDate).substr(5, 2) +
							"-" + (content.message[i].requiredDate).substr(0, 4) + "</td>" +
        					"<td>"+content.message[i].code+"</td>" +
        					"<td class='tar'>"+parseFloat(content.message[i].unitPrice).toFixed(2)+"</td>" +
        					"<td class='tar'>"+parseFloat(content.message[i].quantityOrder)+"</td>" +
        					"<td class='tar'>"+parseFloat(content.message[i].quantityShip)+"</td>" +
        					"<td class='tar'><input type='text' name='qtySent' class='span12 validate[custom[integer]] tar' onBlur='calculate_amount(this)' value='0' /></td>" +
        					"<td class='tar'><input type='text' name='amount' class='span12 validate[custom[integer]] tar' disabled/></td>" +
					        "</tr>");
					}
 					$('#customerID').val(content.soHeader.customerID).change();
 					$('#customerID').attr('readonly','readonly');
					$('#currencyID').val(content.soHeader.currencyID).change();
					$('#deliveryToID').val(content.soHeader.deliveryToID);
					$('#exchangeRate').val(parseFloat(content.soHeader.exchangeRate).toFixed(5));
					$('#address').html(
						content.soShipto.addressName + '\n' + 
						content.soShipto.line1 + '\n' + 
						content.soShipto.line2 + '\n' + 
						content.soShipto.line3 + '\n' + 
						content.soShipto.city + ' ' + 
						content.soShipto.postCode + ' ' + 
						content.soShipto.fldname + ' ' + 
						content.soShipto.fldcountry);
//					alert(content.message);
				}
			}
		});
}
function refreshEmployee(){
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/employeeSearch',
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
//					items.push('<option value=""><?php echo $this->lang->line('pleaseselect')?></option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].ID+'">'
//						+ content.message[i].code + ' [ '+ content.message[i].desc + ' ]</option>');
						+ content.message[i].employeeName + '</option>');
					}
//					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#salesPerson";
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}
function addRow(){
	var tablerows = $("#bill").val();
    var rowToInsert = '';
    rowToInsert = "<td class='span2'><select id='itemID"+ tablerows +"' style='width: 200px;' onChange='selectDesc(this)'></select></td>";
    rowToInsertUM = "<td class='span1'><select id='unitOfMeasureID"+ tablerows +"' class='input-mini' ></select></td>";
    $("#oTable2 tbody").append(
		"<tr>" +
		rowToInsert +
        "<td class='span4'><input type='text' name='description' class='span12'/>"+
		rowToInsertUM +
        "<td class='span2 tar'><input type='text' name='unitprice' class='span12 tar' onBlur='calculate_amount1(this)' value='0'/></td>"+
        "<td class='span2 tar'><input type='text' name='qtySent' class='span12 tar' onBlur='calculate_amount1(this)' value='0'/></td>"+
        "<td class='span2 tar'><input type='text' name='amount' class='span12 tar' disabled/></td>"+
        "<td class='tac'><button class='btn btn-mini btn-danger remove' title='<?php echo $this->lang->line('delete') ?>' onClick='removeLine(this)'><span class='i-trashcan'></button></td>"+
        "</tr>");
	$('#itemID'+tablerows).select2();
	$('#unitOfMeasureID'+tablerows).select2();
  	selectoption(tablerows);
//  	$("#bill").val(parseInt(tablerows) + 1);
  	selectUnitmeasure(tablerows);
}
function selectoption(line){
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/itemSearch',
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
					items.push('<option value=""><?php echo $this->lang->line('pleaseselect')?></option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].ID+'">'
						+ content.message[i].itemCode + ' [ '+ content.message[i].name + ' ]</option>');
					}
//					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#itemID"+line;
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}
function selectDesc(obj){
    var eRow   = $(this).parents('tr');
	var ID = obj.value;
	var customerID = $("#customerID option:selected").val();
	var currencyID = $("#currencyID option:selected").val();
	var effdate = $("#effdate").val();
	postData = {
		ID : ID,
		customerID : customerID,
		currencyID : currencyID,
		effdate : effdate
	};
	
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/itemSearch2',
			dataType:"json",
			data: postData,
	  				async: false,
			success: function(content){
				if(content.status == "success") {
					$('td:eq(1)', $(obj).parents('tr')).find("input").val(content.message.description);
 					$('td:eq(3)', $(obj).parents('tr')).find("input").val(content.price);
 					$('td:eq(2)', $(obj).parents('tr')).find("select").val(content.message.unitOfMeasureID).change();
// 					$('#unitOfMeasureID').val(content.message.unitOfMeasureID).change();
				}
			}
		});
}
function selectUnitmeasure(line){
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/umSearch',
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
//					items.push('<option value=""><?php echo $this->lang->line('pleaseselect')?></option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].fldid+'">'
//						+ content.message[i].code + ' [ '+ content.message[i].desc + ' ]</option>');
						+ content.message[i].code + '</option>');
					}
//					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#unitOfMeasureID"+line;
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}
function shipMethodSelect(){
 $.ajax({
	type: "POST",
	url: "<?php echo base_url() ?>setting/refreshShippingMethod",
	success: function(data) {
	
	   var resul = eval ("(" + data + ")"); 
	   var n=resul.records.length;
	   var i=0;
	   var opt='' +
		'<option></option>';
		for (i=0;i<n;i++)
			opt=opt + '<option value="' + resul.records[i].id +'">' + resul.records[i].name + '</option>';
		$('#shippingmethod').empty();
		$('#shippingmethod').append(opt);
	}
   });		
}
function calculate_amount(obj){
	var totalAmount = $("#totalAmount").val();
	var totalShiped = parseFloat($('td:eq(6)', $(obj).parents('tr')).text()) - parseFloat($('td:eq(7)', $(obj).parents('tr')).text());
	var qtysent = $('td:eq(8)', $(obj).parents('tr')).find("input").val();
	if(qtysent > totalShiped){
		alert("<?php echo $this->lang->line('message9') ?>");
	}
	var amount = parseFloat($('td:eq(8)', $(obj).parents('tr')).find("input").val()) * parseFloat($('td:eq(5)', $(obj).parents('tr')).text());
	$('td:eq(9)', $(obj).parents('tr')).find("input").val(amount.toFixed(2));
	$("#totalAmount").val((parseFloat(totalAmount) + parseFloat(amount)).toFixed(2));
}
function calculate_amount1(obj){
	var totalAmount = $("#totalAmount").val();
	var amount = parseFloat($('td:eq(4)', $(obj).parents('tr')).find("input").val()) * parseFloat($('td:eq(3)', $(obj).parents('tr')).find("input").val());
	$("#totalAmount").val((parseFloat(totalAmount) + parseFloat(amount)).toFixed(2));
	$('td:eq(5)', $(obj).parents('tr')).find("input").val(amount.toFixed(2));
}
function removeLine(obj){
	var totalAmount = $("#totalAmount").val();
	var amount = parseFloat($('td:eq(5)', $(obj).parents('tr')).find("input").val());
	$("#totalAmount").val((parseFloat(totalAmount) - parseFloat(amount)).toFixed(2));
    var eRow   = $(obj).parents('tr');
	eRow.remove();
}
function createDO(){
	if($("#paymentDetail").validationEngine('validate')){	
    var eRow   = '';
	var totalAmount = $("#totalAmount").val();
	var customerID = $("#customerID option:selected").val();
	var formNo = $("#formNo").val();
	var effdate = $("#effdate").val();
	var locationID = $("#locationID option:selected").val();
	var salesorder = $("#salesorder option:selected").val();
	var currencyID = $("#currencyID option:selected").val();
	var exchangeRate = $("#exchangeRate").val();
	var salesPerson = $("#salesPerson option:selected").val();
	var deliveryToID = $("#deliveryToID").val();
	var address = $("#address").val();
	var memo = $("#memo").val();
	var tablerows1 = $("#oTable > tbody >tr").length;
	if(tablerows1 > 0) var rows1 = $("#oTable").dataTable().fnGetNodes();
	var tablerows2 = $("#oTable2 > tbody >tr").length;
//	if(tablerows2 > 0) 
	var rows2 = $("#oTable2").dataTable().fnGetNodes();
//	alert(tablerows2);
	for (var i = 0; i < tablerows1 ; i++){
		if($(rows1[i]).find("td:eq(9) input").val() > 0){
			var deliveryID = $("#deliveryID").val();
			postData = {
				'ID' : deliveryID,
				'sodLineNo' : $(rows1[i]).find("td:first").text(),
				'dateRequired' : $(rows1[i]).find("td:eq(4)").text(),
				'qtySent' : $(rows1[i]).find("td:eq(8) input").val(),
				'amount' : $(rows1[i]).find("td:eq(9) input").val(),
				'formNo' : formNo,
				'effdate' : effdate,
				'totalAmount' : totalAmount,
				'customerID' : customerID,
				'locationID' : locationID,
				'salesOrderID' : salesorder,
				'currencyID' : currencyID,
				'exchangeRate' : exchangeRate,
				'salesPerson' : salesPerson,
				'deliveryToID' : deliveryToID,
				'address' : address,
				'memo' : memo,
			};
 				$.ajax({
  					type: "POST",
  					dataType: "json",
					url: "<?php base_url()?>deliveryOrder_insert",
					data: postData ,
	  				async: false,
					success: function(content){
						if(content.status == "success") {
							$("#deliveryID").val(content.ID);
//							location.reload();
						}
					}
				});  
		}
	}
	for (var i = 0; i < tablerows2 ; i++){
		if($(rows2[i]).find("td:eq(5) input").val() > 0){
			var deliveryID = $("#deliveryID").val();
			postData = {
				'ID' : deliveryID,
				'itemID' : $(rows2[i]).find("td:first option:selected").val(),
				'description' : $(rows2[i]).find("td:eq(1) input").val(),
				'unitmeasure' : $(rows2[i]).find("td:eq(2) option:selected").val(),
				'unitPrice' : $(rows2[i]).find("td:eq(3) input").val(),
				'qtySent' : $(rows2[i]).find("td:eq(4) input").val(),
				'amount' : $(rows2[i]).find("td:eq(5) input").val(),
				'formNo' : formNo,
				'effdate' : effdate,
				'totalAmount' : totalAmount,
				'customerID' : customerID,
				'locationID' : locationID,
				'salesOrderID' : salesorder,
				'currencyID' : currencyID,
				'exchangeRate' : exchangeRate,
				'salesPerson' : salesPerson,
				'deliveryToID' : deliveryToID,
				'address' : address,
				'memo' : memo,
			};
 				$.ajax({
  					type: "POST",
  					dataType: "json",
					url: "<?php base_url()?>deliveryOrderWo_insert",
					data: postData ,
	  				async: false,
					success: function(content){
						if(content.status == "success") {
							$("#deliveryID").val(content.ID);
//							location.reload();
						}
					}
				});  
		} 
	}
	window.location.href=window.location.href;
	}
}
</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()."home" ?>'><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                <li><a href='<?php echo base_url()."so/home" ?>'> <?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" id="grid_content_1">
	<div class="row-fluid">
		<div class="alert alert-info">
			<strong><?php echo $this->lang->line('title') ?></strong>
		</div>
	</div>
      	<div class="block">
      	<div class="content">
	<div class="row-fluid scRow">                            
	<form id="paymentDetail" action="#">
	  <div class="span6 scCol">
		<div class="block ns" id="grid_block_1">
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('customer') ?></div>
              	<div class="span9">
					<?php
							$preselcust = '';
							$options[] = $this->lang->line('pleaseselect');
							foreach($customers as $row){
								$options[$row->ID] = $row->customerName.' [ '.$row->accountCode.' ]';
							}
							$js='class="span11 validate[required]" onChange="selectSO(this)" id="customerID"';
							echo form_dropdown('customerID', $options, $preselcust, $js);
						?>       
                	<div class="btn-group span1">
						<button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                		<span class="i-arrow-down-2"></span>
                		</button>
						<ul class="dropdown-menu">
      					<!-- dropdown menu links -->
      						<li><a target="_blank" href="<?php echo base_url() ?>CustomerSetup/CustomerNew"  id="btnNewCustomer">
                    			<i class="icon-plus-sign"></i> <?php echo $this->lang->line('addNewCustomer')?></a></li>
                                <li><a href="#" onclick="selectCustomer()"><i class="icon-refresh"></i> <?php echo $this->lang->line('refreshlist')?></a></li>
						</ul>
         			</div><!-- btn group -->
            	</div>                
         	</div><!-- End Row 1 -->
                	<div class="controls-row"><!-- Row 4-->
                    	<div class="span3"><?php echo $this->lang->line('orderNo');?></div>
                   		<div class="span9">
                            	<?php 								
								$data = array(
									'name'=>'formNo', 
									'id'=>'formNo', 
									'class'=>'span11',); 
								echo form_input($data, $formNo); ?>
                            	<?php 								
								$data = array(
									'name'=>'deliveryToID', 
									'id'=>'deliveryToID', 
									'type'=>'hidden',); 
								echo form_input($data); ?>
                  		</div>
                 	</div><!-- End Row 4-->
                  <div class="controls-row"><!-- Row 3 -->
                    	<div class="span3"><?php echo $this->lang->line('effective_date');?></div>
                    <div class="span9">
                    	<div class="input-prepend">
                        	<span class="add-on"><i class="i-calendar"></i></span>
                            	<?php 								
								$data = array(
									'name'=>'deliveryID', 
									'id'=>'deliveryID', 
									'type'=>'hidden',); 
								echo form_input($data); ?>
                            	<?php 								
								$data = array(
									'type'=>'text',
									'name'=>'effdate', 
									'id'=>'effdate', 
									'class'=>'input-medium datepicker2',); 
								echo form_input($data, date(element('dtFormat', $this->session->userdata('logged_in')))); ?>
                        </div>                                                                                                
                     </div>
                    </div><!-- End Row 3 -->
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('location') ?></div>
              	<div class="span9">
					<?php
							$presellocation = '';
							$options = '';
							$options[NULL] = $this->lang->line('pleaseselect');
							foreach($location as $row){
								$options[$row->fldid] = $row->city . '=>' . $row->address;
							}
							$js='class="span11 validate[required]" id="locationID"';
							echo form_dropdown('locationID', $options, $presellocation, $js);
						?>       
                	<div class="btn-group span1">
						<button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                		<span class="i-arrow-down-2"></span>
                		</button>
						<ul class="dropdown-menu">
      					<!-- dropdown menu links -->
      						<li><a target="_blank" href="<?php echo base_url() ?>setting/location"  id="btnLocation">
                    			<i class="icon-plus-sign"></i> <?php echo $this->lang->line('addLocation')?></a></li>
                                <li><a href="#"  onclick="refreshLocation()"><i class="icon-refresh"></i> <?php echo $this->lang->line('refreshlist')?></a></li>
						</ul>
         			</div><!-- btn group -->
            	</div>                
         	</div><!-- End Row 1 -->
        </div><!--grid_block_1 -->
      </div><!--span6 scCol -->
	  <div class="span6 scCol">
		<div class="block ns" id="grid_block_1">
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('salesorder') ?></div>
              	<div class="span9">
					<?php
							$preselso = '';
							$options = '';
							$options[] = $this->lang->line('pleaseselect');
							if($salesorder){
							foreach($salesorder as $row){
								$options[$row->ID] = $row->OrderNo;
							}
							}
							$js='class="span11" id="salesorder" onChange="fromSO(this)"';
							echo form_dropdown('salesorder', $options, $presellocation, $js);
						?>       
            	</div>                
         	</div><!-- End Row 1 -->
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('currency') ?></div>
              	<div class="span9">
					<?php
							$preselcurrency = '';
							$options[] = $this->lang->line('pleaseselect');
							if($currency){
							foreach($currency as $row){
								$options[$row->fldid] = $row->fldcurr_code.' [ '.$row->fldcurr_desc.' ]';
							}
							}
							$js='class="span8" id="currencyID" disabled';
							echo form_dropdown('currencyID', $options, $preselcurrency, $js);
						?>       
            	</div>                
         	</div><!-- End Row 1 -->
                	<div class="controls-row"><!-- Row 4-->
                    	<div class="span3"><?php echo form_label($this->lang->line('exchangerate'),'exchangeRate');?></div>
                   		<div class="span9">
                            	<?php 								
								$data = array(
									'name'=>'exchangeRate', 
									'id'=>'exchangeRate', 
									'class'=>'input-medium tar',); 
								echo form_input($data, number_format(1,2)); ?>
                  		</div>
                 	</div><!-- End Row 4-->
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('salesperson') ?></div>
              	<div class="span9">
					<?php
							$preselperson = '';
							$options = '';
							$options[] = $this->lang->line('pleaseselect');
							foreach($employees as $row){
								$options[$row->ID] = $row->employeeName;
							}
							$js='class="span11" id="salesPerson"';
							echo form_dropdown('salesPerson', $options, $preselperson, $js);
						?>       
                	<div class="btn-group span1">
						<button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                		<span class="i-arrow-down-2"></span>
                		</button>
						<ul class="dropdown-menu">
      					<!-- dropdown menu links -->
      						<li><a target="_blank" href="<?php echo base_url() ?>employeeSetup/EmployeeNew"  id="btnNewEmpoyee">
                    			<i class="icon-plus-sign"></i> <?php echo $this->lang->line('addNewEmployee')?></a></li>
                                <li><a href="#" onclick="refreshEmployee()" id="btnNewEmpoyee"><i class="icon-refresh"></i> <?php echo $this->lang->line('refreshlist')?></a></li>
						</ul>
         			</div><!-- btn group -->
            	</div>                
         	</div><!-- End Row 1 -->
        </div><!--grid_block_1 -->
      </div><!--span6 scCol -->
    </div><!--row-fluid scRow -->
	<div class="row-fluid scRow">                            
	  <div class="span12 scCol">
		<div class="block ns" id="grid_block_3">
                  <div class="controls-row"><!-- Row 5 -->
                  	<div class="span1"><?php echo $this->lang->line('shipto')?></div>
                   	<div class="span5">
						<?php
							$data = array(
									'name'=>'address', 
									'id'=>'address', 
									'class'=>'span12',);
							$js = 'style="height:80px"'; 
							echo form_textarea($data, set_value('address'), $js); ?>                       
                    </div>                        
                  	<div class="span1 tar"><?php echo $this->lang->line('memo')?></div>
                   	<div class="span5">
						<?php
							$data = array(
									'name'=>'memo', 
									'id'=>'memo', 
									'class'=>'span12',);
							$js = 'style="height:80px"'; 
							echo form_textarea($data, set_value('memo'), $js); ?>                       
                             	<?php 								
								$data = array(
									'name'=>'bill', 
									'id'=>'bill', 
									'value'=> 1,
									'type' => 'hidden'); 
								echo form_input($data); ?>
                   </div>                        
                  </div><!-- End Row 5-->
        </div><!--grid_block_1 -->
      </div><!--span12 scCol -->
    </div><!--row-fluid scRow -->
    </div><!--row-fluid scRow -->
    </div><!--row-fluid scRow -->
	<div class="row-fluid scRow">                            
	  <div class="span12 scCol">
		<div class="block" id="grid_block_4">
	       <div class="head">
           	<h2><?php echo $this->lang->line('outstanding')?></h2>
                    	<ul class="buttons">
                            <li><a href="#" class="block_toggle" title="Close"><span class="i-arrow-down-3"></span></a></li>
                        </ul>                                        
          </div><!-- head -->
          <div class="content np">
   			<table id="oTable" cellpadding="0" cellspacing="0" width="100%">
         		<thead>
             	<tr>
                	<th style='display:none'></th>
            		<th><?php echo $this->lang->line('itemCode')?></th>
            		<th><?php echo $this->lang->line('description')?></th>
            		<th><?php echo $this->lang->line('daterequired')?></th>
            		<th><?php echo $this->lang->line('um')?></th>
            		<th class="tar"><?php echo $this->lang->line('unitPrice')?></th>
            		<th class="tar"><?php echo $this->lang->line('qtyOrd')?></th>
            		<th class="tar"><?php echo $this->lang->line('totalQtySend')?></th>
            		<th class="tar"><?php echo $this->lang->line('qtySend')?></th>
            		<th class="tar"><?php echo $this->lang->line('amount')?></th>
              	</tr>
        		</thead>
                <tbody>
                </tbody>
     		</table>
          </div><!--content -->
        </div><!--grid_block_4 -->
      </div><!--span6 scCol -->
    </div><!--row-fluid scRow -->
	<div class="row-fluid scRow">                            
	  <div class="span12 scCol">
		<div class="block" id="grid_block_5">
	       <div class="head">
           	<h2><?php echo $this->lang->line('withoutso')?></h2>
                    	<ul class="buttons">
                            <li><a href="#" class="block_toggle" title="Close"><span class="i-arrow-down-3"></span></a></li>
                        </ul>                                        
          </div><!-- head -->
          <div class="content np">
   			<table id="oTable2" cellpadding="0" cellspacing="0" width="100%">
         		<thead>
             	<tr>
            		<th><?php echo $this->lang->line('itemCode')?></th>
            		<th><?php echo $this->lang->line('description')?></th>
            		<th><?php echo $this->lang->line('um')?></th>
            		<th class="tar"><?php echo $this->lang->line('unitPrice')?></th>
            		<th class="tar"><?php echo $this->lang->line('qtySend')?></th>
            		<th class="tar"><?php echo $this->lang->line('amount')?></th>
            		<th class="tar"><?php echo $this->lang->line('action')?></th>
              	</tr>
        		</thead>
                <tbody>
                </tbody>
     		</table>
          </div><!--content -->
          </form>
            <div class="footer">
            	<div class="side fl">
                	<div class="btn-group">
            				<button class="btn btn-small btn-primary" onClick="addRow()" id="addLine">
                				<span class="i-plus"></span> <?php echo $this->lang->line('addnewline')?></button>
                    </div>
                </div>
            	<div class="side fr">
                	<div class="btn-group">
            				<button class="btn btn-small btn-warning" onClick="createDO()" id="mySubmit"><?php echo $this->lang->line('submit')?></button>
                    </div>
                </div>
            </div>                                    
        </div><!--grid_block_5 -->
      </div><!--span6 scCol -->
    </div><!--row-fluid scRow -->
	<div class="row-fluid scRow">                            
	  <div class="span12 scCol">
		<div class="block" id="grid_block_3">
            	<div class="head">
                	<h2><?php echo $this->lang->line('memoandshipto') ?></h2>
                    	<ul class="buttons">
                            <li><a href="#" class="block_toggle" title="Close"><span class="i-arrow-down-3"></span></a></li>
                        </ul>                                        
                </div>
          <div class="content">
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span2"><?php echo $this->lang->line('shipMethod') ?></div>
              	<div class="span4">
					<?php
							$preselshipmethod = '';
							$options = '';
							$options[] = $this->lang->line('pleaseselect');
							foreach($shippingMethod as $row){
								$options[$row->ID] = $row->code . ' [ ' . $row->name . ' ]';
							}
							$js='class="span11" id="shippingmethod"';
							echo form_dropdown('shippingmethod', $options, $preselshipmethod, $js);
						?>       
                	<div class="btn-group span1">
						<button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                		<span class="i-arrow-down-2"></span>
                		</button>
						<ul class="dropdown-menu">
      					<!-- dropdown menu links -->
      						<li><a target="_blank" href="<?php echo base_url() ?>setting/masterCodeSetup"  id="btnNewShipMethod">
                    			<i class="icon-plus-sign"></i> <?php echo $this->lang->line('newShipMethod')?></a></li>
                                <li><a href="#" onclick="shipMethodSelect()"><i class="icon-refresh"></i> <?php echo $this->lang->line('refreshlist')?></a></li>
						</ul>
         			</div><!-- btn group -->
            	</div>                
                    	<div class="span2 tar"><?php echo $this->lang->line('totalAmount');?></div>
                   		<div class="span4">
                            	<?php 								
								$data = array(
									'name'=>'totalAmount', 
									'id'=>'totalAmount', 
									'disabled'=>'disabled', 
									'class'=>'span12 tar',); 
								echo form_input($data, 0); ?>
                  		</div>
                 	</div><!-- End Row 4-->
          </div><!--content -->
        </div><!--grid_block_1 -->
      </div><!--span12 scCol -->
    </div><!--row-fluid scRow -->
</div><!--grid_content_1 -->
</div><!--wrap -->
</div><!--content -->
