<script type="application/javascript">
$(document).ready(function() {
	$('select').select2();
//	$("#addLine").hide();
	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});

 /*   $("table.editable td").live('dblclick',function () {        
        
		var fldid = $('td:first', $(this).parents('tr')).text(); 
		var fieldname = $(this).attr('id');
        var eContent = $(this).text();
        var eCell = $(this);
            
        if(eContent.indexOf('<') >= 0 || eCell.parents('table').hasClass('oc_disable')) return false;    
		if(    
            
        eCell.addClass("editing");        
        eCell.html('<input type="text" value="' + eContent + '"/>');
        
        var eInput = eCell.find("input");
        eInput.focus();
 
        eInput.keypress(function(e){
            if (e.which == 13) {
                var newContent = $(this).val();
                eCell.html(newContent).removeClass("editing");
				var dataToSend= {fldid: fldid, fieldname: fieldname, content: newContent};
			 $.ajax({
  				type: "POST",
  				url: "quoteDetails_update",
				data:dataToSend,
  				success: function(){
				alert('Data has been saved...');
				}, 
			 });       
                // Here your ajax actions after pressed Enter button
            }
        });
 
        eInput.focusout(function(){
            eCell.text(eContent).removeClass("editing");            
            // Here your ajax action after focus out from input
			alert('Data not saved...');
        });        
    }); */
}); 
function addRow(){
var rowCount = document.getElementById('oTable').rows.length - 1 ;
var rowArrayId = rowCount ;
var toBeAdded = 1;
if (toBeAdded=='')
    { toBeAdded = 2; }	
else if(toBeAdded>100)
{
  toBeAdded = 100;
}
  for (var i = 1; i <= toBeAdded; i++) {
    var rowToInsert = '';
    rowToInsert = "<td class='span4'><select id='itemID' class='span12' onChange='selectDesc(this)'><option value=''>--Please Select--</option></select></td>";
    rowTax = "<td class='span1'><select id='taxpercentage' class='span12' onChange='changeTaxPercentage(this)'></select></td>";
    rowToInsertUM = "<td id='unitOfMeasureID' class='span1'><input type='text' placeholder='UM'/></td>";
    $("#oTable tbody").append(
		"<tr><td style='display:none'></td>" +
		rowToInsert +
        "<td class='span3'><input type='text' name='description' class='span12 description'/>"+
        rowToInsertUM +
        "<td class='span1 tar'><input type='text' name='unitprice' id='unitprice' class='span12 tar' onBlur='calculate_amount(this)'/></td>"+
        "<td class='span1 tar'><input type='text' name='qtyOrd' class='span12 tar' onBlur='calculate_amount(this)' value='0' /></td>"+
        "<td class='span2 tar'><input type='text' name='amountExcTax' class='span12 tar' disabled/></td>"+
        rowTax+
        "<td class='span1 tar'><input type='text' name='taxAmount' class='span12 tar' disabled/></td>"+
        "<td class='span2 tar'><input type='text' name='amountIncTax' class='span12 tar' disabled/></td>"+
        "<td class='tac'><input type='hidden' name='taxRate' id='taxRate'/>" + 
		"<button class='btn-icon btn-mini btn-success-form' title='<?php echo $this->lang->line('save') ?>' onClick='saveDetails(this)'><span class='i-checkmark-3'></button><button class='btn-icon btn-mini btn-danger-form remove' title='<?php echo $this->lang->line('cancel') ?>' onClick='cancelRow(this)'><span class='i-cross'></button></td>"+
        "</tr>");

//	$('select').select2();
	rowArrayId = rowArrayId + 1;
  }
  selectoption(toBeAdded);
  //selectUnitmeasure();
  selectTaxCode();
	$('select').select2({
		placeholder: 'Please',
	});
	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
	$("#addLine").hide(); 
	$("#mysubmit").show(); 
//	$("#savedetails").show(); 
}

function changeTaxPercentage(me){
	$('#taxRate').val($(me).select2().find('option:selected').data('percentage'));
	calculate_amount(me);		
}

function selectoption(toBeAdded){
//	var numrows = $("#numberofrows").val();
//	var tablerows = $("#oTable > tbody >tr").length;
//	var startrows = parseInt($("#oTable > tbody >tr").length) - numrows;
		$.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";
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}
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 selectUnitmeasure(){
		$.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";
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
//					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}
function selectTaxCode(){
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>sotransaction/taxSearch',
			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+'" data-percentage="'+content.message[i].taxPercentage+'">'
//						+ content.message[i].code + ' [ '+ content.message[i].desc + ' ]</option>');
						+ content.message[i].code + ' [ ' + content.message[i].taxPercentage + '% ]</option>');
					}
//					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#taxpercentage";
						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/itemSearch3',
			dataType:"json",
			data: postData,
	  				async: false,
			success: function(content){
				if(content.status == "success") {
					$('td:eq(2)', $(obj).parents('tr')).find("input").val(content.message.description);
					$('td:eq(4)', $(obj).parents('tr')).find("input").val(content.price);
					$('td:eq(10)', $(obj).parents('tr')).find("input").val(content.taxRate);
  					//$('#unitOfMeasureID').val(content.message.unitOfMeasureID).change();
  					$('#taxpercentage').val(content.message.outputTaxID).change();
  					$.ajax({
						 type: "POST",
			            data : {
			                option :'sale',
			                itemID : $("#itemID").select2('val'),
			                datePrice : $("#effdate").val(),
			                customerID : $("#customerID").select2('val')
			            },
			            url: "<?php echo base_url() ?>aptransaction/getUmList",
			            dataType:'JSON',
						success: function(data){
							var option = '<option value="'+data['items'][0].unitOfMeasureID+'" >'+data['items'][0].umCode+'</option>';
			                if(data['umConv']){
			                    for(i = 0; i<data['umConv'].length; i++){
			                        option += '<option value="'+data['umConv'][i].from_um+'">'+data['umConv'][i].fromCode+'</option>';
			                    }
			                }
			                $('#unitOfMeasureID').text('').append('<select class="umIDlist span12">'+
			                                        option+
			                                        '</select>');
			                $('#unitOfMeasureID select').select2();	
						}
					});
				}
			}
		});
}
function saveDetails(obj){
    var eRow   = $(obj).parents('tr');
	var customerID = $("#customerID option:selected").val();
	if(customerID == 0){
		alert("<?php echo $this->lang->line('msj_custID')?>");
		$('#customerID').focus();
		return;
	}else{
		var itemID = $('td:eq(1) option:selected', $(obj).parents('tr')).val();
		if(itemID == 0){
			alert("<?php echo $this->lang->line('msj_itemID')?>");
			$('td:eq(1)', $(obj).parents('tr')).focus();
			return;
		}else{
			var amount = $('td:eq(6)', $(obj).parents('tr')).find("input").val();
			if(amount == 0){
				alert("<?php echo $this->lang->line('msj_totalamount')?>");
				$('td:eq(5)', $(obj).parents('tr')).focus();
				return;
			}else if(amount == ''){
				alert("<?php echo $this->lang->line('msj_totalamount')?>");
				$('td:eq(5)', $(obj).parents('tr')).focus();
				return;
			}else{
				var ID = $("#ID").val();
				var formNo = $("#formNo").val();
				var effdate = $("#effdate").val();
				var salesPerson = $("#salesPerson option:selected").val();
				var deliveryToID = $("#deliveryToID option:selected").val();
				var currencyID = $("#currencyID option:selected").val();
				var exchangeRate = $("#exchangeRate").val();
				var memo = $("#memo").val();
				var lineID = $('td:first', $(obj).parents('tr')).text();
				var description = $('td:eq(2)', $(obj).parents('tr')).find("input").val();
				var unitmeasure = $('td:eq(3) option:selected', $(obj).parents('tr')).val();
				var unitPrice = $('td:eq(4)', $(obj).parents('tr')).find("input").val();
				var quoteQty = $('td:eq(5)', $(obj).parents('tr')).find("input").val();
				var amount = $('td:eq(6)', $(obj).parents('tr')).find("input").val();
				var taxID = $('td:eq(7) option:selected', $(obj).parents('tr')).val();
				var taxAmount = $('td:eq(8)', $(obj).parents('tr')).find("input").val();
				var IncTaxAmount = $('td:eq(9)', $(obj).parents('tr')).find("input").val();
				var taxRate = $('td:eq(10)', $(obj).parents('tr')).find("input").val();
				var totalAmount = parseFloat($("#totalAmount").val()) + parseFloat(IncTaxAmount);
//				alert('2');
				postData = {
					ID : ID,
					customerID : customerID,
					formNo : formNo,
					currencyID : currencyID,
					effdate : effdate,
					salesPerson : salesPerson,
					deliveryToID : deliveryToID,
					currencyID : currencyID,
					exchangeRate : exchangeRate,
					memo : memo,
					totalAmount : totalAmount,
					itemID : itemID,
					description : description,
					unitmeasure : unitmeasure,
					unitPrice : unitPrice,
					quoteQty : quoteQty,
					amount : amount,
					taxID : taxID,
					taxAmount : taxAmount,
					IncTaxAmount : IncTaxAmount,
					taxRate : taxRate,
				};
                                $(obj).attr("disabled","disabled");
				$.ajax({
					type: "POST",
        			url: '<?php echo base_url();?>sotransaction/quoteDetails_save',
					dataType:"json",
					data: postData,
	  				async: false,
					success: function(content){
						if(content.status == "success") {
  							$('#ID').val(content.quoteID);
							eRow.remove();
							$("#addLine").show(); 
							$("#customerID").attr('readonly','readonly');
							$("#formNo").val(content.formNo);
							$("#formNo").attr('readonly','readonly');
							$("#totalAmount").val(parseFloat(totalAmount).toFixed(2));
    						$("#oTable tbody").append(
							"<tr><td style='display:none'>"+content.message1+"</td>" +
        					"<td>"+content.items+"</td>" +
        					"<td>"+description+"</td>" +
        					"<td>"+content.um+"</td>" +
        					"<td class='tar'>"+parseFloat(unitPrice).toFixed(2)+"</td>" +
        					"<td class='tar'>"+quoteQty+"</td>" +
        					"<td class='tar'>"+parseFloat(amount).toFixed(2)+"</td>" +
        					"<td class='tar'>"+content.tax+"</td>" +
        					"<td class='tar'>"+parseFloat(taxAmount).toFixed(2)+"</td>" +
        					"<td class='tar'>"+parseFloat(IncTaxAmount).toFixed(2)+"</td>" +
        					"<td class='tac'><button class='btn-icon btn-mini btn-danger-form remove' title='<?php echo $this->lang->line('remove') ?>' onClick='saveRemove(this)'><span class='i-trashcan'></button></td>" +
					        "</tr>");
							alertbox(content.message,1);
						}
					}
				});
			}
		}
	}
}
function calculate_amount(obj){
//	var taxID = $("#currencyID option:selected").val();
	var taxRate = $('td:eq(10)', $(obj).parents('tr')).find("input").val();
	var amount = parseFloat($('td:eq(4)', $(obj).parents('tr')).find("input").val()) * parseFloat($('td:eq(5)', $(obj).parents('tr')).find("input").val());
	var taxAmount = parseFloat(amount) * parseFloat(taxRate) / 100;
	var totalTaxAmount = parseFloat(amount) + parseFloat(taxAmount)
	$('td:eq(6)', $(obj).parents('tr')).find("input").val(amount.toFixed(2));
	$('td:eq(8)', $(obj).parents('tr')).find("input").val(taxAmount.toFixed(2));
	$('td:eq(9)', $(obj).parents('tr')).find("input").val(totalTaxAmount.toFixed(2));
}

function cancelRow(obj){
    var eRow   = $(obj).parents('tr');
	eRow.remove();
	$("#addLine").show(); 
}
function saveRemove(obj){
    var eRow   = $(obj).parents('tr');
	var totalAmount = $("#totalAmount").val();
	var IncTaxAmount = $('td:eq(9)', $(obj).parents('tr')).text();
	var Amount = parseFloat(totalAmount) - parseFloat(IncTaxAmount);
	var ID = $('td:eq(0)', $(obj).parents('tr')).text();
				postData = {
					ID : ID,
				};
				$.ajax({
					type: "POST",
        			url: '<?php echo base_url();?>sotransaction/soQuotedetails_delete',
					dataType:"json",
					data: postData,
	  				async: false,
					success: function(content){
						if(content.status == "success") {
							alert(content.message);
							$("#totalAmount").val(parseFloat(Amount).toFixed(2));
							eRow.remove();
							alertbox('The row has been deleted successfully',3)
						}
					}
				});
}
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;
			}
		});
}

</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="block">
            <div class="head">
     <h2><strong><?php echo $this->lang->line('title') ?></strong></h2>
</div><!-- head -->
      	<div class="content">
	<div class="row-fluid scRow">                            
	  <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 = $headerQuote->customerID;
							$options[] = $this->lang->line('pleaseselect');
							foreach($customers as $row){
								$options[$row->ID] = $row->customerName.' [ '.$row->accountCode.' ]';
							}
							$js='class="span8" id="customerID" disabled';
							echo form_dropdown('customerID', $options, $preselcust, $js);
						?>       
                	<div class="btn-group">
						<button class="btn-icon btn-small 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 form_label($this->lang->line('quoteNo'),'formNo');?></div>
                   		<div class="span9">
                            	<?php 								
								$data = array(
									'name'=>'formNo', 
									'id'=>'formNo', 
									'class'=>'input-medium',);
								$js="disabled"; 
								echo form_input($data, $headerQuote->formNo, $js); ?>
                            	<?php 								
								$data = array(
									'name'=>'ID', 
									'id'=>'ID', 
									'type'=>'hidden',); 
								echo form_input($data, $headerQuote->ID ); ?>
                  		</div>
                 	</div><!-- End Row 4-->
                  <div class="controls-row"><!-- Row 3 -->
                    	<div class="span3"><?php echo form_label($this->lang->line('effective_date'),'effdate');?></div>
                    <div class="span9">
                    	<div class="input-prepend">
                        	<span class="add-on"><i class="i-calendar"></i></span>
                            	<?php 								
								$data = array(
									'type'=>'text',
									'name'=>'effdate', 
									'id'=>'effdate', 
									'class'=>'input-medium datepicker2 financhk',); 
								echo form_input($data, date("d-m-Y", strtotime($headerQuote->quotationDate))); ?>
                        </div>                                                                                                
                     </div>
                    </div><!-- End Row 3 -->
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('salesperson') ?></div>
              	<div class="span9">
					<?php
							$preselperson = $headerQuote->employeeID;
							$options = '';
							$options[] = $this->lang->line('pleaseselect');
							foreach($employees as $row){
								$options[$row->ID] = $row->employeeName;
							}
							$js='class="span8" id="salesPerson"';
							echo form_dropdown('salesPerson', $options, $preselperson, $js);
						?>       
                	<div class="btn-group">
						<button class="btn-icon btn-small 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 class="span6 scCol">
		<div class="block ns" id="grid_block_2">
			<div class="controls-row"> <!-- row 1 -->
            	<div class="span3"><?php echo $this->lang->line('shipto') ?></div>
              	<div class="span9">
					<?php
							$preselshipto = $headerQuote->deliverToID;
							$options ='';
							$options[] = $this->lang->line('pleaseselect');
							if($shipTo){
								foreach($shipTo as $row){
									$options[$row->ID] = $row->addressCode.' [ '.$row->addressName.' ]';
								}
							}
							$js='class="span8" id="deliveryToID"';
							echo form_dropdown('deliveryToID', $options, $preselshipto, $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 = $headerQuote->currencyID;
							$options[] = $this->lang->line('pleaseselect');
							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($headerQuote->exchangeRate,5)); ?>
                  		</div>
                 	</div><!-- End Row 4-->
                	<div class="controls-row"><!-- Row 4-->
                    	<div class="span3"><?php echo form_label($this->lang->line('amount'),'totalAmount');?></div>
                   		<div class="span9">
                            	<?php 								
								$data = array(
									'name'=>'totalAmount', 
									'id'=>'totalAmount', 
									'disabled'=>'disabled', 
									'class'=>'input-medium tar',); 
								echo form_input($data, $headerQuote->totalTaxAmount); ?>
                  		</div>
                 	</div><!-- End Row 4-->
        </div><!--grid_block_2 -->
      </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 4-->
                    	<div class="span1"><?php echo form_label($this->lang->line('memo'),'memo');?></div>
                   		<div class="span11">
                            	<?php 								
								$data = array(
									'name'=>'memo', 
									'id'=>'memo', 
									'class'=>'span12',); 
								echo form_input($data, $headerQuote->memo); ?>
                  		</div>
                 	</div><!-- End Row 4-->
        </div><!--grid_block_3 -->
      </div><!--span6 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('orderdetails')?></h2>
           	<div class="buttons fr">
                    <div class="item">                        
                        <div class="btn-group">                        
          				</div>                                        
          			</div>                                        
          	</div>                                        
          </div><!-- head -->
          <div class="content np">
   			<table id="oTable" cellpadding="0" cellspacing="0" width="100%" class="editable">
         		<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('um')?></th>
            		<th class="tar"><?php echo $this->lang->line('unitPrice')?></th>
            		<th class="tar"><?php echo $this->lang->line('qtyQuote')?></th>
            		<th class="tar"><?php echo $this->lang->line('amountExcTax')?></th>
            		<th class="tar"><?php echo $this->lang->line('taxpercentage')?></th>
            		<th class="tar"><?php echo $this->lang->line('taxAmount')?></th>
            		<th class="tar"><?php echo $this->lang->line('amountIncTax')?></th>
            		<th class="tac"><?php echo $this->lang->line('action')?></th>
              	</tr>
        		</thead>
                <tbody>
			<?php $bil = 0; 
				if($detailsQuote){
				foreach($detailsQuote as $datatbl):
				$bil++?>
            	<tr>
                	<td style="display:none" ><?php echo $datatbl->ID; ?></td>
                	<td><?php echo $datatbl->itemCodeName; ?></td>
                	<td><?php echo $datatbl->description; ?></td>
                	<td><?php echo $datatbl->code; ?></td>
                	<td class="tar"><?php echo number_format($datatbl->unitOfPrice, 2); ?></td>
                	<td class="tar"><?php echo $datatbl->quantityOrder; ?></td>
                	<td class="tar"><?php echo number_format($datatbl->amountExcludeTax, 2); ?></td>
                	<td class="tar"><?php echo $datatbl->taxCode." [".$datatbl->taxPercentage."%]"; ?></td>
                	<td class="tar"><?php echo number_format($datatbl->taxAmount, 2) ?></td>
                	<td class="tar"><?php echo number_format($datatbl->amountIncudeTax, 2) ?></td>
                    <td class="tac"><?php 
							$js = 'class="btn-icon btn-mini btn-danger-form remove" title="Delete" onClick="saveRemove(this)"';
							echo form_button('remove','<span class="i-trashcan">',$js);
						?>
                    </td>
                </tr>
            <?php endforeach; }?>
                </tbody>
     		</table>
          </div><!--content -->
            <div class="footer">
            	<div class="side fr">
                	<div class="btn-group">
            				<button class="btn-icon btn-warning-form" onClick="addRow()" id="addLine">
                				<span class="i-plus-2"></span> <?php echo $this->lang->line('addnewline')?></button>
                    </div>
                </div>
            </div>                                    
        </div><!--grid_block_3 -->
      </div><!--span6 scCol -->
    </div><!--row-fluid scRow -->
</div><!--grid_content_1 -->
</div><!--wrap -->
</div><!--content -->
