<link href="css/cssicon/style.css" rel="stylesheet" type="text/css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script type='text/javascript' src='js/charts.js'></script>

<script>
$(document).ready(function(){
	deliveryOrders();
	supplierInvoices();
 	//loadItemSalesPie();
});
</script>
<script type="text/javascript">


function deliveryOrders(){
 	$("#doSupply tbody tr").remove(); 	
	$.ajax({
		type: "POST",
       	url: '<?php echo base_url();?>sotransaction/SalesOrderSearch1',
		dataType:"json",
		success: function(content){
			if(content.status == "success") {
				$("#doCount").html("+"+content.message.length);
				if(content.message.length > 5){
					var lengthRec = 5;
				}else{
					var lengthRec = content.message.length;
				}
				for ( var i = 0; i < lengthRec; i++) {
    					$("#doSupply tbody").append(
						"<tr><td style='display:none'>"+content.message[i].ID+"</td>" +
        					"<td><a href='sotransaction/salesOrder/"+ content.message[i].ID +"'>"+(content.message[i].salesOrderDate).substr(8, 2) + 
							"-" + (content.message[i].salesOrderDate).substr(5, 2) +
							"-" + (content.message[i].salesOrderDate).substr(0, 4) + "</a></td>" +
        				"<td>"+content.message[i].customerName+"</td>" +
        				"<td>"+content.message[i].phoneNumber1+"</td>" +
        				"<td class='tar'>"+content.message[i].fldcurr_code + ' ' + accounting.formatNumber(content.message[i].totalAmount,2)+"</td>" +
				        "</tr>");
				}
			}
		}
	});
}



function supplierInvoices(){
 	$("#invoicesAp tbody tr").remove(); 	
	$.ajax({
		type: "POST",
       	url: '<?php echo base_url();?>home/openPurchaseInvoice',
		dataType:"json",
		success: function(content){
			if(content.status == "success") {
				$("#invCount").html("+"+content.message.length);
				if(content.message.length > 5){
					var lengthRec = 5;
				}else{
					var lengthRec = content.message.length;
				}
				for ( var i = 0; i < lengthRec; i++) {
    					$("#invoicesAp tbody").append(
						"<tr><td style='display:none'>"+content.message[i].ID+"</td>" +
        					"<td><a href='<?php echo base_url(); ?>apreports/purchaseInvoiceDetail/"+ content.message[i].ID +"' target='_blank'>"+(content.message[i].invoiceDate).substr(8, 2) + 
							"-" + (content.message[i].invoiceDate).substr(5, 2) +
							"-" + (content.message[i].invoiceDate).substr(0, 4) + "</a></td>" +
						"<td>"+content.message[i].supplierInvoiceNo+"</td>" +
        				"<td>"+content.message[i].supplierName+' ['+content.message[i].formNo+"]</td>" +
        				"<td>"+content.message[i].phoneNumber1+' ['+content.message[i].attention+"]</td>" +
        				"<td class='tar'>"+content.message[i].fldcurr_code + ' ' + accounting.formatNumber(content.message[i].totalPayable,2)+"</td>" +
				        "</tr>");
				}
			}
		}
	});
}
function soList(){
	var urls = "<?php echo base_url();?>sotransaction/SalesOrderList";
		window.location = urls;
}
function invList(){
	var urls = "<?php echo base_url();?>apreports/purchaseinvoicelist";
		window.location = urls;
}
</script>


<script type="text/javascript">
$(document).ready(function() {
   $('select').select2();
}); 
 
function changeList(){
	var addyear = $('#add_year option:selected').val();
	var addper = $('#add_period option:selected').val();
	var acctNo = $('#acctNo option:selected').val();
	var urls = "<?php echo base_url();?>glreports/accountBalanceSummary/"+addyear+"/"+addper+"/"+acctNo;
		window.location = urls;
}

function do_print(){
	var addyear = $('#add_year option:selected').val();
	var addper = $('#add_period option:selected').val();
	var acctNo = $('#acctNo option:selected').val();
	window.open("<?php echo base_url() ?>glreports/accountBalanceSummary_print/"+addyear+"/"+addper+"/"+acctNo);
}

function selectYearPeriod(obj){
		var year = obj.value;
//		alert(year);
			
			$.ajax({
  				type: "POST",
	  			dataType: "json",
				url: "<?php echo base_url()?>glreports/get_TrialBalance_year/"+year,
				data: year,
	  			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].financialPeriod + '</option>');
					}  //end for
					jQuery("#add_period").empty();
					jQuery("#add_period").append(items.join('</br>'));
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				} //end if
			} //end success
				
			}); //end ajax
//	window.location.reload(true); 
}

</script>
	<div id="content">                        
        <div class="wrap">
            <div class="head"><!-- 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 class="active"><?php echo $this->lang->line('dashboard') ?></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>                    
            <div class="content sortableContent">
				<div class="row-fluid">
					<div class="span12">
						<div class="widgets">
							<div class="tile tile-item icodshbrd-tile-dashboard">
								<a href="<?php echo base_url()?>home" class="ascensorLink tile-nav ">
									<p>Dashboard</p>	
								</a>
							</div>   
							<div class="tile tile-item icodshbrd-tile-gl">
								<a href="<?php echo base_url()?>GeneralLedger" class="ascensorLink tile-nav">
									<p>General Ledger</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-accountreceivables">
								<a href="<?php echo base_url()?>AccountReceivables" class="ascensorLink tile-nav">
									<p>Account Receivables</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-accountpayables">
								<a href="<?php echo base_url()?>AccountPayables" class="ascensorLink tile-nav">
									<p>Account Payables</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-inventorycontrol">
								<a href="<?php echo base_url()?>inventoryControl" class="ascensorLink tile-nav">
									<p>Inventory Control</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-Purchasing">
								<a href="<?php echo base_url()?>purchasing" class="ascensorLink tile-nav">
									<p>Purchasing</p>	
								</a>
							</div> 
							<div class="tile tile-item icodshbrd-tile-sales">
								<a href="<?php echo base_url()?>SalesOrder" class="ascensorLink tile-nav">
									<p>Sales Order</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-zktwkf">
								<a href="<?php echo base_url()?>zakat" class="ascensorLink tile-nav">
									<p>Zakat &amp; Wakaf</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-gst">
								<a href="<?php echo base_url()?>gst" class="ascensorLink tile-nav">
									<p>Goods &amp; Services Tax</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-setup">
								<a href="<?php echo base_url()?>setting/companyList" class="ascensorLink tile-nav">
									<p>General Setup</p>	
								</a>
							</div>
							<div class="tile tile-item icodshbrd-tile-admin">								
                                <a href="<?php echo base_url()?>admin/usermasterlist" class="ascensorLink tile-nav">                     
									<p>Admin</p>	
								</a>
							</div>
						    <div class="tile tile-item icodshbrd-tile-userguide">								
                                <a href="<?php echo base_url()?>userguide" class="ascensorLink tile-nav">                          
									<p>User Guide</p>	
								</a>
							</div>
                       </div>                     
                    </div><!-- end metro design -->
					

                    <?php
                    if(!empty($graph)){
                    	foreach($graph as $v){
                    		echo ${$v->slug};
                    	}
                    }
                    ?>
                    
					            
			</div><!-- content -->
		</div><!-- wrap -->  
  </div><!-- content --> 		  				
        