<script type="application/javascript">
$(document).ready(function() {
	$('select').select2();
	/*****GST Register supplier's color change start******/    
    function format(state) {
    var text = state.text.match(/\(GST\)/g);
    var modTxt = state.text.replace("(GST)","");
    if(text != null)  return '<span style="color:#85c420;">'+modTxt+"</span>";
    else              return modTxt;
    }
    $("#customerID").select2({
    formatResult: format,
    formatSelection: format,
    escapeMarkup: function(m) { return m; }
    });
    /*****GST Register supplier's color change end******/
	$("#addLine").hide();
	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
});
function selectshipto(obj){
		var customerID = obj.value;
		var effdate = $("#effdate").val();
//		alert(year);
			postData = {
				customerID : customerID,
				effdate : effdate
			};
			$.ajax({
  				type: "POST",
	  			dataType: "json",
				url: "<?php echo base_url()?>sotransaction/shipto",
				data: postData,
	  			async: false,
  				success: function(content){
					if(content.status == "success") {
					var items = [];
					//items.push('<option>-Please Select-</option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].ID+'">'+ content.message[i].addressCode + ' [ ' +content.message[i].addressName + ' ]</option>');
					}  //end for
					jQuery("#deliveryToID").empty();
					jQuery("#deliveryToID").append(items);
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				} //end if
					$('#currencyID').val(content.message1.currencyID).change();
					$('#exchangeRate').val(parseFloat(content.exchangeRate).toFixed(5));
					$("#addLine").show();
			} //end success
				
			}); //end ajax

}
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)'></select></td>";
    rowTax = "<td class='span1'><select id='taxpercentage' onChange='modifyTax(this)' class='span12'></select></td>";
    rowToInsertUM = "<td id='unitOfMeasureID' class='span2'><input type='text' class='span12' value='' /></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)' onkeyup='calculate_amount(this)'/></td>"+
        "<td class='span1 tar'><input type='text' name='qtyOrd' class='span12 tar' onkeyup='calculate_amount(this)' onBlur='calculate_amount(this)' value='0' /></td>"+
        "<td class='span2 tar'><input type='text' name='amountExcTax' class='span12 tar' disabled/></td>"+
        "<td class='span1'><div  class='input-prepend'><input data-taxid='' id='itemTax' onkeyup='calculate_amount()' disabled name='itemTax' class='span6 validate[required, custom[number]]' type='text' placeholder='Tax(%)'><span onclick='taxPopup()' style='margin-top:0;' id='displayTaxCode'  class='btn add-on'>....</span></div></td>"+
        "<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 modifyTax(me){
	$('#taxRate').val($(me).select2().find(":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) select', $(obj).parents('tr')).select2('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) select', $(obj).parents('tr')).select2('val');
				var taxID = $("#itemTax").attr("data-taxid");
				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 taxRate = $("#itemTax").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(accounting.formatNumber(totalAmount,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'>"+accounting.formatNumber(unitPrice,2)+"</td>" +
        					"<td class='tar'>"+quoteQty+"</td>" +
        					"<td class='tar'>"+accounting.formatNumber(amount,2)+"</td>" +
        					"<td class='tar'>"+content.tax+"</td>" +
        					"<td class='tar'>"+accounting.formatNumber(taxAmount,2)+"</td>" +
        					"<td class='tar'>"+accounting.formatNumber(IncTaxAmount,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 taxRate = $("#itemTax").val();
	//alert(taxRate);
	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);
	
	if (isNaN(amount))
	   amount = 0;
	   
	   if (isNaN(taxAmount))
	   taxAmount = 0;
	   
	   if (isNaN(totalTaxAmount))
	   totalTaxAmount = 0;
	$('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();
						}
					}
				});
}
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 taxPopup () {
        $('#popupModal').modal('show');
        $("#_popupTitle").html("Purchase Invoice");
        $("#_popupContent").html('' +
          '<label>Select a tax</label>' +
          '<select style="width:100%;" onchange="calculate_amount()" name="listTaxPopup" id="listTaxPopup" >' +
<?php
if ($taxmaster) {
    foreach ($taxmaster as $row2) {
        $temp = str_replace(array("\n", "\r", "'"), " ", $row2->name, $count);
        ?>
                    '<option data-taxcode="<?php echo $row2->code ?>" value="<?php echo $row2->ID; ?>" data-tax="' + <?php echo $row2->taxPercentage; ?> + '">' + 
                    '<?php echo $row2->code . " | " . $row2->taxPercentage . " | ";
        echo $temp; ?></option>'+
    <?php }
} ?>
            '</select>');
            $("#listTaxPopup").select2();
	
        $('#_popupFooter').empty();
           $('#_popupFooter').append('<button class="btn-form btn-success-form" id="confButton">Ok</button>' +
        '<button class="btn-form btn-danger-form" id="canb">Cancel</button>');
        $("#_popupTitle").html("Tax Master");
        $( "#canb" ).click(function() {
                $('#popupModal').modal('hide');
        });
        $( "#confButton" ).click(function() {
                $('#popupModal').modal('hide');
                 $("#itemTax,#listTax").attr("data-taxid",$("#listTaxPopup").val() );
                 $("#itemTax,#listTax").val ($("#listTaxPopup option:selected").attr("data-tax"));
                 $("#displayTaxCode,#displayCode").html($("#listTaxPopup option:selected").attr("data-taxcode"));
				var me  =  $("#itemTax");
                 calculate_amount(me);
        });
		
}
</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 = '';
							$options[] = $this->lang->line('pleaseselect');
							if($customers){
							foreach($customers as $row){
								if($row->gstRegNo != '' && $row->gstRegNo != '0'){
									$options[$row->ID] = $row->customerName.' [ '.$row->accountCode.' ]'.' (GST)';
								}else{
									$options[$row->ID] = $row->customerName.' [ '.$row->accountCode.' ]';
								}
								
							}
							}
							$js='class="span8" onChange="selectshipto(this)" id="customerID"';
							echo form_dropdown('customerID', $options, $preselcust, $js);
						?>       
                	<div class="btn-group span2">
						<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', 
									'style'=>'color:red;',
									'class'=>'span5 validate[required,maxSize[32]]',); 
								echo form_input($data, $formNo); ?>
                            	<?php 								
								$data = array(
									'name'=>'ID', 
									'id'=>'ID', 
									'class'=>'hidden',
									'disabled'=>'disabled',
									'class'=>'span3',
									'placeholder'=>'Serial'
									); 
								echo form_input($data); ?>
                  		</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 span12">
                        	<span class="add-on span2"><i class="i-calendar"></i></span>
                            	<?php 								
								$data = array(
									'type'=>'text',
									'name'=>'effdate', 
									'id'=>'effdate', 
									'class'=>'span6 datepicker2 financhk',); 
								echo form_input($data, date("d-m-Y")); ?>
                        </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 = '';
							$options = '';
							$options[] = $this->lang->line('pleaseselect');
							if($employees){
							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 span2">
						<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 = '';
							$options ='';
							$options[] = $this->lang->line('pleaseselect');
							$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 = '';
							$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,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 validate[required,maxSize[32]] tar',); 
								echo form_input($data, 0); ?>
                  		</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); ?>
                  		</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%">
         		<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>
                </tbody>
     		</table>
          </div><!--content -->
            <div class="footer">
            	<div class="side fr">
                	<div class="btn-group">
            			<a class="btn-icon btn-warning-form" onClick="addRow()" id="addLine">
                			<span class="i-plus-2"></span> <?php echo $this->lang->line('addnewline')?>
						</a>
                    </div>
                </div>
            </div>                                    
        </div><!--grid_block_3 -->
      </div><!--span6 scCol -->
    </div><!--row-fluid scRow -->
</div><!--grid_content_1 -->
</div><!--wrap -->
</div><!--content -->
