<?php

function draw_itemSupplier($itemSupplier_id,$ledger_number, $connection){
	
	$querylog="SELECT FI_Suppliers as loginaccess,language from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
	$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlog)){
		extract($rows);
	}
	
	$querylang="select load_items
 from ".$_SESSION['dbLabel'].".buttons_label 
where language='$language'";


$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){$load_items=$rows[0];}
	
	
	$querylang="select  language, supplier_group, item_code, item_desc  from ".$_SESSION['dbLabel'].".suppliers_label where 
	language='$language'";

//echo $querylang;
$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
		
		$supplier_group=$rows[1];
		$item_code_label=$rows[2];
		$item_desc_label=$rows[3];
	}
echo"		<table border='0' style='table-layout:fixed' align='left' valign='top' width='630px'>
					 <col width=40>
					 <col width=40>
					 <col width=500>
					 <col width=50>";	

echo "<tr height='30px'><td colspan='2'><span class='style1'>$supplier_group</span></td><td><span class='style1'><input type='text' name='group_code' value='$group_code' readonly style='width:120px;' >
		<input type='text' name='group_name' value='$group_name' readonly style='width:230px;'>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistgrouping(11); '  /></span></label>
		
		</span></td><td><button type='button' id='btnLoad' name='btnLoad' onclick=\"loadItems('$ledger_number'); return false;\" title='Load Items'><span><span>$load_items</span></span></button></td></tr>";
					 
if($itemSupplier_id != ''){
	$queryitem = " select item_supplier.item_code, Item_Description ".
			 " from item_supplier left join items on items.item_code = item_supplier.item_code ".
			 " where itemSupplier_id = '$itemSupplier_id' order by item_code";	
	$resitem = mysql_query($queryitem, $connection);
	$rwitem = mysql_fetch_row($resitem);
	$item_code = $rwitem[0]; 
	$item_desc = $rwitem[1];
}					 
echo "<tr height='30px'><td></td><td></td><td></td><td></td></tr>";
echo "<tr><td></td><td></td><td><span class='style1'>$item_code_label/ $item_desc_label</span></td><td></td></tr>";
echo "<tr><td></td><td></td><td><input type='text' name='item_code' id='item_code' value='$item_code' style='width:180px;'>
		<input type='text' name='item_desc' id='item_desc' value='$item_desc' style='width:280px;'>
		<label><span class='style11'><a href='javascript:void(0);' title=' Select Item ' onClick='showlistitem(13); '>
		<img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> </td>
		<td><input id='imgSubmit_1' onclick=\"insertitem('$itemSupplier_id','$ledger_number'); return false;\" title='Submit Record' style='width:20px; height:20px; vertical-align:bottom; cursor:pointer; outline:none; border:0px; background-image:url(img/confirm-1.png)' type='button'></td>
	</tr>";
echo "<tr height='30px'><td colspan='4'></td></tr>";
echo "</table>";
echo "<br>";
echo"<div style='height: 600px;overflow-y: auto;width: 630px;overflow-x: hidden;'><table border='0' style='table-layout:fixed' align='left' valign='top' width='630px'>
	 <col width=40>
	 <col width=40>
	 <col width=500>
	 <col width=50>";	
if($ledger_number != ''){
$queryitem = " select itemSupplier_id, item_supplier.item_code, Item_Description ".
			 " from item_supplier left join items on items.item_code = item_supplier.item_code ".
			 " where supplier_code = '$ledger_number' order by item_code";	
$resitem = mysql_query($queryitem, $connection);
while($rwitem = mysql_fetch_row($resitem)){	
	if($i%2==0)
		$Color="background-color:#E6E6E6;";
	else			
		$Color="background-color:#F7F7F7;";	
	if($item_code == $rwitem[1]) $Color="background-color:#1e87a5;";		
	
	echo"<tr  height='20px' style='$Color'>
			<td align='center'><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\" name='' title='Delete' onclick=\" deleteItem('$rwitem[0]','$ledger_number');\"></td>
			<td align='center'><img src='img/edit.png' onmouseover=\"style.cursor='pointer'\"  title='Save' onclick=\"getItem('$rwitem[0]','$ledger_number');\"></td>
			<td>$rwitem[1] - $rwitem[2]</td><td></td></tr>";
}
}
echo "</table></div>";
}					


function draw_SupplierAccess($ledger_number, $encryptpassrd, $connection){
	echo "<table border='0' style='table-layout:fixed' align='left' valign='top' width='630px'>
		  <col width=40><col width=200><col width=300><col width=50>";	
		  
	$query = "select if('".$encryptpassrd."' = '1', encryptpassword(user_password), user_password) 
			from ".$_SESSION['dbLabel'].".users where User_account = '".$ledger_number."' and upper(concat(defaultComp,'_',defaultyear)) = upper('".$_SESSION['dbName']."') ;";
	$res = mysql_query($query,$connection);	  
	$row = mysql_fetch_row($res);
	$user_password = $row[0];
	if($usercode == '') $usercode = $ledger_number;			
	
	echo "<tr height='25px'><td></td>
			<td><span class='style1'>User Code</span></td>
			<td><input type='text' name='usercode' id='usercode' value='$usercode' readonly style='width: 200px;border-radius: 4px;font-size: 14px;font-family: monospace;'></td>
			<td></td>
		</tr>";
		
	echo "<tr height='25px'><td></td>
			<td><span class='style1'>Password</span></td>
			<td><input type='password' name='user_password' id='user_password' value='$user_password' style='width: 200px;border-radius: 4px;font-size: 14px;font-family: monospace;'></td>
			<td></td>
		</tr>";
	echo "</table>";	
}

function drawProjectWarehouse($project_code, $connection){
	
	echo "<table style='table-layout:fixed; width:560px;' border=0>
			<col width=30><col width=200><col width=300><col width=30>";
	echo "<tr height='30px' bgcolor='#D0D0D0'>
			<td></td>
			<td align='center'><span class='style1'>Warehouse Code</span></td>
			<td align='center'><span class='style1'>Warehouse Description</span></td>
			<td></td>
		 </tr>";	
	$i=0;
	$querywh = "select wp_id, warehouseProject.warehouse_code, warehouse_name
				from warehouseProject
				inner join warehouse on warehouse.warehouse_code = warehouseProject.warehouse_code
				where project_code='$project_code' ";
	$reswh = mysql_query($querywh, $connection);
	while($rwwh = mysql_fetch_array($reswh)){
		
		echo "<tr bgcolor='#F7F7F7'>
			<td align='center'><img border='0' src='img/c_delete.png' width='9' height='10' title='Delete Detail' onmouseover=\"this.style.cursor='pointer'\" onclick=\"removeWarehouse('$i');\" style='cursor: pointer;'></td>
			<td align='center'><input type='text' name='warehousecode$i' id='warehousecode[$i]' value='$rwwh[1]' style='width:170px;border-radius:5px;font-size: 12px;font-family: monospace;'>
				<input type='hidden' name='wpid$i' id='wpid[$i]' value='$rwwh[0]'>
				<img src='img/btnopen.jpg' title='Select Warehouse' width='15' height='15' border='0' onmouseover=\"style.cursor='hand';\" onclick=\"showlistWarehouse('$i'); \" style='cursor: pointer;'>
			</td>
			<td align='center'><input type='text' name='warehousedesc$i' id='warehousedesc[$i]' value='$rwwh[2]' style='width:280px;border-radius:5px;font-size: 12px;font-family: monospace;' readonly></td>
			<td align='center'><button type='button' id='addButton' onclick=\"submitWarehouse('$i');\"><b>&#10004</b></button></td>
		 </tr>";
		$i++;
	}	
	
	echo "<tr bgcolor='#F7F7F7'>
			<td align='center'></td>
			<td align='center'><input type='text' name='warehousecode$i' id='warehousecode[$i]' value='' style='width:170px;border-radius:5px; font-size: 12px;font-family: monospace;'>
				<input type='hidden' name='wpid$i' id='wpid[$i]' value=''>
				<img src='img/btnopen.jpg' title='Select Warehouse' width='15' height='15' border='0' onmouseover=\"style.cursor='hand';\" onclick=\"showlistWarehouse('$i'); \" style='cursor: pointer;'>
			</td>
			<td align='center'><input type='text' name='warehousedesc$i' id='warehousedesc[$i]' value='' style='width:280px;border-radius:5px;font-size: 12px;font-family: monospace;' readonly></td>
			<td align='center'><button type='button' id='addButton' onclick=\"submitWarehouse('$i');\"><b>&#10004</b></button></td>
		 </tr>";	
	echo"</table>";
}

function docalc($project_code, $proj_id, $connection){
	if ($proj_id != ''){
		$query = "select project_percentage, project_number from project where project_code = '$proj_id' ";
		$res = mysql_query($query, $connection);
		$row = mysql_fetch_row($res);
		$proj_percentage = $row[0];
		$proj_number 	 = $row[1];
	}
	echo "<table style='table-layout:fixed; width:100%;' border=0>
			<col width=100%>";
	echo "<tr><td valign='top' align='left'><table>";		
	echo"	
		  <tr><td><span class='style11'>Projectcode</span>
				<input type='text' name='proj_id' id='proj_id' value='$proj_id' style='font-size:12px; width:100px; height:18px;' readonly/>
				
		<td><span class='style11'>Percentage</span>
				<input type='text' name='proj_percentage' id='proj_percentage' value='$proj_percentage' style='font-size:12px; width:100px; height:18px;'/>
				<td><span class='style11'>Number</span>
				<input type='text' name='proj_number' id='proj_number' value='$proj_number' style='font-size:12px; width:100px; height:18px;'/>
		
		<td> <button type='button' id='btnSubmit' name='btnSubmit' onclick='saveval();'><span><span>Submit</span></span></button></td></tr>
		
		";
		echo "</table></td></tr>";
		echo"<tr><td><div id='loadergif' style='display:none;'><img src='img/Loading_icon.gif' width='100px' height='100px'></div></td></tr>";
		echo "<tr><td valign='top' align='center'><div style='overflow-x:hidden;overflow-y:scroll;width:100%;height:100px;'>
			<table border=0 cellpadding=0 cellspacing=0 width=100%><col width=30%><col width=40%><col width=15%><col width=15%>";
		echo "<tr height='25px' bgcolor='darkgray'><td align='left'><span class='style11'>Code</span></td><td align='left'><span class='style11'>Name</span></td><td align='left'><span class='style11'>Percentage</span></td><td align='center'><span class='style11'>Number</span></td></tr>";	

		$querydt = "select project_code, project_name, project_percentage, project_number from project where project_code like '$project_code%'";
		$resdt = mysql_query($querydt, $connection);
		$ct = 0;
		while($rwdt = mysql_fetch_array($resdt)){
			if($ct%2) $bgcolor = "bgcolor='#E6E6E6'";	
			else $bgcolor = "bgcolor='#F7F7F7'";

			echo "<tr $bgcolor><td align='left' style='cursor:pointer;' onclick=\"setChild('$rwdt[0]');\"><span class='style15'>$rwdt[0]</span></td>
			<td align='left' style='cursor:pointer;'  onclick=\"setChild('$rwdt[0]');\"><span class='style15'>$rwdt[1]</span></td>
			<td align='center' style='cursor:pointer;'  onclick=\"setChild('$rwdt[0]');\"><span class='style15'>$rwdt[2]</span></td>
			<td align='center' style='cursor:pointer;'  onclick=\"setChild('$rwdt[0]');\"><span class='style15'>$rwdt[3]</span></td></tr>";
			$ct++;
		}
		echo "</table></div></td></tr>";
		echo"</table>";

}

function getCostcentChild($Costcent_code, $cost_id, $connection){
	if ($cost_id != ''){ 
	$query = "select CostCent_Percentage, costcent_number from costcent where Costcent_code = '$cost_id'";

		$result=mysql_query($query,$connection);
		$row=mysql_fetch_row($result);
		$cost_percentage = $row[0];
		$cost_number = $row[1];
	}

	echo "	<table style='table-layout:fixed; width:100%;' border=0>
				<col width=100%>
				<tr><td valign='top' align='left'><table>
				<tr><td><span class='style1'>Costcentcode</span></td>
				<td align='left'>
						<input type='text' name='cost_id' id='cost_id' value='$cost_id' style='font-size:12px; width:100px; height:18px;'/>";
						
echo"		<td><span class='style1'>Percentage</span></td>
				<td align='left'>
						<input type='text' name='cost_percentage' id='cost_percentage' value='$cost_percentage' style='font-size:12px; width:100px; height:18px;'/>
						
						<td><span class='style1'>Number</span></td>
				<td align='left'>
						<input type='text' name='cost_number' id='cost_number' value='$cost_number' style='font-size:12px; width:100px; height:18px;'/>
				
				<td> <button type='button' id='btnSubmit' name='btnSubmit' onclick='saveval();'><span><span>Submit</span></span></button></td></tr>
				
				</table></td></tr>
				<div id='loadergif' style='display:none;'><img src='img/Loading_icon.gif' width='100px' height='100px'></div>";
echo "<td valign='top' align='center'><div style='overflow-x:none;overflow-y:scroll;width:100%;height:100px;border-left: 1px solid lightgray;
    border-bottom: 1px solid lightgray;'><table border=0 cellpadding=0 cellspacing=0 width=100%>
    <col width=30%><col width=40%><col width=15%><col width=15%>";
echo "<tr height='25px' bgcolor='darkgray'><td align='left'><span class='style1'>Code</span></td><td align='left'><span class='style1'>Name</span></td><td align='left'><span class='style1'>Percentage</span></td><td align='center'><span class='style1'>Number</span></td></tr>";	
$querydt = "select costcent_code,costcent_name, CostCent_Percentage, costcent_number from costcent where costcent_code like '".$Costcent_code."%' ";
		$resdt = mysql_query($querydt, $connection);
		$ct = 0;
		while($rwdt = mysql_fetch_array($resdt)){
			if($ct%2) $bgcolor = "bgcolor='#E6E6E6'";	
			else $bgcolor = "bgcolor='#F7F7F7'";

			echo "<tr $bgcolor><td align='left' style='cursor:pointer;' onclick=\"SetCostcent1('$rwdt[0]');\"><span class='style15'>$rwdt[0]</span></td>
			<td align='left' style='cursor:pointer;'  onclick=\"SetCostcent1('$rwdt[0]');\"><span class='style15'>$rwdt[1]</span></td>
			<td align='center' style='cursor:pointer;'  onclick=\"SetCostcent1('$rwdt[0]');\"><span class='style15'>$rwdt[2]</span></td>
			<td align='center' style='cursor:pointer;'  onclick=\"SetCostcent1('$rwdt[0]');\"><span class='style15'>$rwdt[3]</span></td></tr>";
			$ct++;
		}
echo "</table></div></td></tr>
	</table>";


}

function draw_ProjectVisit($project_code, $connection){ 
	
	$query = "select date_format(project_startingDate,'%d/%m/%Y'), date_format(project_preventifDate,'%d/%m/%Y'), project_nbrVisits, project_periodMonth, 
			Project_state, Project_LGA, Project_region, project_address, project_BranchManager, project_BranchManagerPhone, project_infoType, project_counters
			from project where project_code = '$project_code' ";
	$result = mysql_query($query, $connection);
	$row = mysql_fetch_row($result);
	$pStartDate 	= $row[0];
	$pPreventDate 	= $row[1];
	$pNbrVisit 		= $row[2];
	$pNbrMonth 		= $row[3];
	
	$pState 		= $row[4];
	$pLga	 		= $row[5];
	$pRegion 		= $row[6];
	$pAddress 		= $row[7];
	$pBranchMan		= $row[8];
	$pManagerPhone	= $row[9];
	$pInfoType		= $row[10];
	$pInfoCounter	= $row[11];
	
	echo "<table style='table-layout:fixed; width:100%;' border=0>
			<col width=100%>";
	echo "<tr><td valign='top' align='left'><table>
			<col width=10%><col width=15%><col width=10%>
			<col width=15%><col width=15%><col width=10%>
			<col width=15%><col width=10%><col width=20%>";		
	echo"	
		<tr>
			<td><span class='style11'>Starting Date</span></td>
			<td><input type='text' name='pStartDate' id='pStartDate' value='$pStartDate' style='font-size:12px; width:70%;' />
			<a href='#' onclick=\"displayCalendar(document.project.pStartDate,'dd/mm/yyyy',this);  return false;\" name='anchor1' id='anchor1'><img src='./img/cal.gif' border='0' align='center'></a>
			</td>
			<td><span class='style11'>Preventive Date</span></td>
			<td><input type='text' name='pPreventDate' id='pPreventDate' value='$pPreventDate' style='font-size:12px;width:70%;'/>
			<a href='#' onclick=\"displayCalendar(document.project.pPreventDate,'dd/mm/yyyy',this);  return false;\" name='anchor1' id='anchor1'><img src='./img/cal.gif' border='0' align='center'></a>
			</td>
			<td><span class='style11'>Number of Visits</span></td>
			<td><input type='text' name='pNbrVisit' id='pNbrVisit' value='$pNbrVisit' style='font-size:12px; width:70%;' onkeypress=\"return ((event.charCode >=48 && event.charCode <=57) || event.charCode==46);\"/></td>
			<td><span class='style11'>Number of Months</span></td>
			<td><input type='text' name='pNbrMonth' id='pNbrMonth' value='$pNbrMonth' style='font-size:12px; width:70%;' onkeypress=\"return ((event.charCode >=48 && event.charCode <=57) || event.charCode==46);\"/></td>
			<td></td>
		</tr>";
		
	echo"	
		<tr>
			<td><span class='style11'>State</span></td>
			<td colspan='3'><input type='text' name='pState' id='pState' value='".htmlspecialchars($pState, ENT_QUOTES)."' style='font-size:12px; width:90%;' readonly />
			<img src='img/btnopen.jpg' width='15px' height='20px' onclick=\"showLocationList('1','1');\" title='Select a State'>
			</td>
			<td><span class='style11'>LGA</span></td>
			<td colspan='3'><input type='text' name='pLga' id='pLga' value='".htmlspecialchars($pLga, ENT_QUOTES)."' style='font-size:12px; width:90%;' readonly/>
			<img src='img/btnopen.jpg' width='15px' height='20px' onclick=\"showLocationList('1','2');\" title='Select a LGA'>
			</td>
			
		</tr>";	
	echo"	
		<tr>
			<td><span class='style11'>Region</span></td>
			<td colspan='3'><input type='text' name='pRegion' id='pRegion' value='".htmlspecialchars($pRegion, ENT_QUOTES)."' style='font-size:12px; width:90%;' readonly/>
			<img src='img/btnopen.jpg' width='15px' height='20px' onclick=\"showLocationList('1','3');\" title='Select a Region'>
			</td>
			<td><span class='style11'>Address</span></td>
			<td colspan='3'><textarea name='pAddress' id='pAddress' rows='2' cols='45'>".htmlspecialchars($pAddress, ENT_QUOTES)."</textarea>
			</td>
			
		</tr>";
	echo"	
		<tr>
			<td><span class='style11'>Branch Manager</span></td>
			<td colspan='3'><input type='text' name='pBranchMan' id='pBranchMan' value='".htmlspecialchars($pBranchMan, ENT_QUOTES)."' style='font-size:12px; width:90%;' /></td>
			<td><span class='style11'>Branch Manager Phone No.</span></td>
			<td colspan='3'><input type='text' name='pManagerPhone' id='pManagerPhone' value='".htmlspecialchars($pManagerPhone, ENT_QUOTES)."' style='font-size:12px; width:90%;' />
			</td>
			
		</tr>";	
echo"	
		<tr>
			<td><span class='style11'>Type</span></td>
			<td colspan='3'><input type='text' name='pInfoType' id='pInfoType' value='".htmlspecialchars($pInfoType, ENT_QUOTES)."' style='font-size:12px; width:90%;' readonly/>
			<img src='img/btnopen.jpg' width='15px' height='20px' onclick=\"showLocationList('2','');\" title='Select a Type'></td>
			<td><span class='style11'>Counters</span></td>
			<td colspan='3'><input type='text' name='pInfoCounter' id='pInfoCounter' value='".htmlspecialchars($pInfoCounter, ENT_QUOTES)."' style='font-size:12px; width:50%;' />
			</td>
			
		</tr>";			
		//<td> <button type='button' id='btnSubmit' name='btnSubmit' onclick='saveval();'><span><span>Submit</span></span></button></td>
		echo "</table></td></tr>";
	
		echo"</table>";
}

function draw_ProjectItems($project_code, $item_id, $connection){
	echo "<table style='table-layout:fixed; width:80%;' border=0>
			<col width=50%>";
	echo "<tr><td valign='top' align='left'><div  style='overflow-x:hidden;overflow-y:scroll;height:300px;'><table>
			<col width=5%><col width=40%><col width=20%><col width=5%>";	
	
	echo "<tr height='30px' bgcolor='#D0D0D0'><td></td><td align='center'><span class='style1'>Item Code/Description</span></td><td align='center'><span class='style1'>Quantity</span>	</td><td></td></tr>";	
	$i=0;
	$query = "select projetItems_id, project_items.item_code, item_Description, projetItems_qty 
			from project_items 
			inner join items on items.item_code = project_items.item_code
			where project_items.project_code = '$project_code' ";		
	$result = mysql_query($query, $connection);
	while($row = mysql_fetch_array($result)){
		if($i%2) $bgcolor = "bgcolor='#E6E6E6'";	
		else $bgcolor = "bgcolor='#F7F7F7'";		
		
		echo "<tr height='20px' $bgcolor>
				<td align='center'><img src='img/c_delete.png' width='' height='' onmouseover=\"this.style.cursor='pointer';\" title='Delete Record' onclick=\"deleteItem('$project_code','$row[0]');\"></td>
				<td align='center'>
					<img src='img/addledger.png' width='18' height='18' onmouseover=\"this.style.cursor='pointer';\" title='Add Serial' onclick=\"showSerial('$row[0]');\">
					<input type='text' name='pItem_code[$i]' id='pItem_code[$i]' value='$row[1]' style='font-family: monospace;font-size:12px;width:30%;border-radius:5px;' > 
					<input type='text' name='pItem_desc[$i]' id='pItem_desc[$i]' value='$row[2]' style='font-family: monospace;font-size:12px;width:50%;border-radius:5px;' readonly> 
					<img src='img/btnopen.jpg' width='15' height='20' onmouseover=\"style.cursor='hand';\" title='Select an Item' onclick=\"showlistItems('$i')\">
				</td>
				<td align='center'><input type='text' name='pItem_qty[$i]' id='pItem_qty[$i]' value='$row[3]' style='font-family: monospace;font-size:12px;width:70%;border-radius:5px;' onkeypress=\"return ((event.charCode >=48 && event.charCode <=57) || event.charCode==46);\"></td>
				<td align='center'><button type='button' name='addbutton1' id='addButton' onclick=\"addItem('$project_code','$row[0]', '$i');\" ><b>&#10004</b></button></td>
			</tr>";	
		echo "<tr><td></td><td colspan='3' align='left'>
			<div id='Serial-$row[0]' style='display:none;'>
			<div style='width:6%;height:100px;float:left;'></div><div id='Serial2-$row[0]' style='height:100px;width:30%;border:2px solid darkgray;box-shadow:4px 4px lightgrey;border-radius: 5px;background-color:#e0e2e6;overflow-y:scroll;overflow-x:hidden;
				padding-top:6px;'>";
			serialNumberGrid ($serial_id, $row[0],$connection);
		echo "</div></div></td></tr>";	
		$i++;	
	}
	echo "<tr height='20px' $bgcolor>
			<td></td>
			<td align='center'><input type='text' name='pItem_code[$i]' id='pItem_code[$i]' value='$pItem_code[$i]' style='font-family: monospace;font-size:12px;width:30%;border-radius:5px;' autofocus> 
				<input type='text' name='pItem_desc[$i]' id='pItem_desc[$i]' value='$pItem_desc[$i]' style='font-family: monospace;font-size:12px;width:50%;border-radius:5px;' readonly> 
				<img src='img/btnopen.jpg' width='15' height='20' onmouseover=\"style.cursor='hand';\" title='Select an Item' onclick=\"showlistItems('$i')\">
			</td>
			<td align='center'><input type='text' name='pItem_qty[$i]' id='pItem_qty[$i]' value='$pItem_qty[$i]' style='font-family: monospace;font-size:12px;width:70%;border-radius:5px;' onkeypress=\"return ((event.charCode >=48 && event.charCode <=57) || event.charCode==46);\"></td>
			<td align='center'><button type='button' name='addbutton1' id='addButton' onclick=\"addItem('$project_code','$item_id', '$i');\" ><b>&#10004</b></button></td>
		</tr>";	
	echo "</table></div></td></tr>";
	echo"<tr><td align='center'><div id='loadergif2' style='display:none;'><img src='img/Loading_icon.gif' width='100px'></div></td></tr>";

	echo"</table>";		
}

function serialNumberGrid ($serial_id, $projetItem_id,$connection) {
	$t=0;
	echo "<div style='float:left;width:10%;text-align:center;height='20px;'>
			&nbsp;
		</div>
		<div style='float:left;width:80%;height='20px;'><input type='text' name='serialNbr$projetItem_id-$t' id='serialNbr$projetItem_id-$t' value='' title='Serial Number' style='width:95%;border:1px solid lightgray;' maxlength=50></div>
		<div style='float:right;width:10%;'><button type='button' name='addbutton1' id='addButton' onclick=\"addSerial('', '$projetItem_id', '$t');\" style='height: 15px;width: 15px;font-size: 12px;'><b>&#10004</b></button>	
		</div>";
	$query = "select serial_id, serial_number from projectItems_Serial where projectItem_id = $projetItem_id ";
	$res = mysql_query($query, $connection);
	while ($row = mysql_fetch_array($res)){
		$t++;	
		echo "<br>
			<div style='width:100%;float: left;'>
			<div style='float:left;width:10%;text-align:center;height='20px;'>
				<img src='img/c_delete.png' width='' height='' onmouseover=\"this.style.cursor='pointer';\" title='Delete Record' onclick=\"deleteSerial('$row[0]', '$projetItem_id');\">
			</div>
			<div style='float:left;width:80%;height='20px;'><input type='text' name='serialNbr$projetItem_id-$t' id='serialNbr$projetItem_id-$t' value='$row[1]' title='Serial Number' style='width:95%;border:1px solid lightgray;' maxlength=50></div>
			<div style='float:right;width:10%;'><button type='button' name='addbutton1' id='addButton' onclick=\"addSerial('$row[0]', '$projetItem_id', '$t');\" style='height: 15px;width: 15px;font-size: 12px;'><b>&#10004</b></button>	
			</div></div>";
		
	}

}


//Form_Project.php
function draw_ProjectIP($project_code, $connection){
	$query = "select project_IP, project_subnet, project_gateWay from project where project_code = '$project_code' ";
	$result = mysql_query($query,$connection);
	$row = mysql_fetch_row($result);
	$pIP 	  = $row[0];
	$pSubnet  = $row[1];
	$pGateway = $row[2];
	
	echo "<table style='table-layout:fixed; width:100%;' border=0>
			<col width=12%><col width=23%><col width=12%><col width=23%><col width=12%><col width=23%>";
	echo "<tr>
			<td><span class='style11'>IP</span></td>
			<td><input type='text' name='pIP' id='pIP' value='".htmlentities($pIP,ENT_QUOTES)."'></td>
			<td><span class='style11'>Subnet</span></td>
			<td><input type='text' name='pSubnet' id='pSubnet' value='".htmlentities($pSubnet,ENT_QUOTES)."'></td>
			<td><span class='style11'>Gateway</span></td>
			<td><input type='text' name='pGateway' id='pGateway' value='".htmlentities($pGateway,ENT_QUOTES)."'></td>
		</tr>";	
	echo "<tr>
		<td><span class='style11'>HUB WAN MAC ADDRESS</span></td>
		<td><img src='img/show.png' id='img-wan' title='Show list of HUB WAN MAC Addresses' style='cursor: pointer;' width='16px' height='16px' onclick=\"showDiv('wan');\"></td>
		<td><span class='style11'>HUB LAN MAC ADDRESS</span></td>
		<td><img src='img/show.png' id='img-lan' title='Show list of HUB LAN MAC Addresses' style='cursor: pointer;' width='16px' height='16px' onclick=\"showDiv('lan');\"></td>
		<td><span class='style11'>PRINTER MAC ADDRESS</span></td>
		<td><img src='img/show.png' id='img-print' title='Show list of PRINTER MAC Addresses' style='cursor: pointer;' width='16px' height='16px' onclick=\"showDiv('print');\"></td>
	</tr>";	
	echo "<tr>
			<td></td>
			<td><div id='grid-wan' class='gridclass'>";
			showMacAddress($project_code,'wan',$connection);
	echo "</div></td>
			<td></td>
			<td><div id='grid-lan' class='gridclass'>";
			showMacAddress($project_code,'lan',$connection);
	echo"	</div></td>
			<td></td>
			<td><div id='grid-print' class='gridclass'>";
			showMacAddress($project_code,'print',$connection);
	echo"	</div></td>
		</tr>";
		
	echo "<tr>
			<td><span class='style11'>HUB SOFTWARE VERSION</span></td>
			<td><img src='img/show.png' id='img-soft' title='Show list of HUB SOFTWARE Version' style='cursor: pointer;' width='16px' height='16px' onclick=\"showDiv('soft');\"></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>";
	echo "<tr>
			<td></td>
			<td><div id='grid-soft' class='gridclass'>";
			showMacAddress($project_code,'soft',$connection);
	echo "</div></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>";	
	echo "</table>";
}

function showMacAddress($project_code,$mac_type,$connection){
	echo "<table width='260px' border='1' cellspacing='5' cellpadding='2' style='border-collapse:collapse;border: 1px solid white;'>
			<col width=30px><col width=200px><col width=30px>";
	if ($mac_type == 'soft')
		echo "<tr><td></td><td><b>Version</b></td><td></td></tr>";
	else
		echo "<tr><td></td><td><b>MAC Address</b></td><td></td></tr>";
	$i=0;
	
	$query = "select mac_id, mac_address  from project_macAddress where project_code = '$project_code' and mac_type = '$mac_type' ";
	$result = mysql_query($query, $connection);
	
	echo "<tr>
			<td></td>
			<td><input type='text' name='macaddr-$mac_type$i' id='macaddr-$mac_type$i' value='' style='width:190px;'></td>
			<td align='center'><img src='img/confirm-1.png' onclick=\"saveMac('$i','','$mac_type','$project_code');\" style='cursor: pointer;'></td>
		</tr>";
	
	while($row = mysql_fetch_array($result)){
		$i++;
		echo "<tr>
				<td align='center'><img src='img/c_delete.png' onclick=\"deleteMac('$i','$row[0]','$mac_type','$project_code');\" style='cursor: pointer;width: 11px;'></td>
				<td><input type='text' name='macaddr-$mac_type$i' id='macaddr-$mac_type$i' value='".htmlentities($row[1],ENT_QUOTES)."' style='width:190px;'></td>
				<td align='center'><img src='img/confirm-1.png' onclick=\"saveMac('$i','$row[0]','$mac_type','$project_code');\" style='cursor: pointer;'></td></tr>";
		
	}
	echo "</table>";
	
}


function draw_ClientAccess($ledger_number, $encryptpassrd, $connection){
	echo "<table border='0' style='table-layout:fixed' align='left' valign='top' width='630px'>
		  <col width=40><col width=200><col width=300><col width=50>";	
		  
	$query = "select if('".$encryptpassrd."' = '1', encryptpassword(user_password), user_password) 
			from ".$_SESSION['dbLabel'].".users where User_account = '".$ledger_number."' and upper(concat(defaultComp,'_',defaultyear)) = upper('".$_SESSION['dbName']."') ;";
	$res = mysql_query($query,$connection);	  
	$row = mysql_fetch_row($res);
	$user_password = $row[0];
	if($usercode == '') $usercode = $ledger_number;			
	
	echo "<tr height='25px'><td></td>
			<td><span class='style1'>User Code</span></td>
			<td><input type='text' name='usercode' id='usercode' value='$usercode' readonly style='width: 200px;border-radius: 4px;font-size: 14px;font-family: monospace;'></td>
			<td></td>
		</tr>";
		
	echo "<tr height='25px'><td></td>
			<td><span class='style1'>Password</span></td>
			<td><input type='password' name='user_password' id='user_password' value='$user_password' style='width: 200px;border-radius: 4px;font-size: 14px;font-family: monospace;'></td>
			<td></td>
		</tr>";
	echo "</table>";	
}

?>