<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}
include("config.inc.php");
include("supplier_function.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2,maxperpage, ifnull(project_ticket,0) as project_ticket from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());

$query_language  = "select user_account, Language from ".$_SESSION['dbLabel'].".login  where user_account = '".$_SESSION['useraccount']."'";
$result_language = mysql_query($query_language, $connection); 
$row_language    = mysql_fetch_array($result_language);
extract($row_language);

$query_project_labels  = "select Language as Language1, Code as Code1, Name as Name1, Deactivate as Deactivate1, MainPage as MainPage1, Detail as Detail1, CreationDate as CreationDate1, Email as Email1, 
						Parent as Parent1, People as People1, View as View1, Floor as Floor1, Smoking as Smoking1, AddProject as AddProject1
                          From ".$_SESSION['dbLabel'].".project_label
                          where Language = '".$Language."'";
$result_project_labels = mysql_query($query_project_labels, $connection);
$row_project_labels    = mysql_fetch_array($result_project_labels);
extract($row_project_labels);

$querymodule  = "select ifnull(module_transactionweight,0) as module_transactionweight, ifnull(Module_TicketSupport,0) as Module_TicketSupport,ifNull(Module_genproject,0) As Module_genproject 
                 From module ";
$resultmodule = mysql_query($querymodule, $connection);
while($rowmodule= mysql_fetch_array($resultmodule)){
extract($rowmodule);
}

$query_navigator = "SELECT LANGUAGE,
       ClearPage,
       Excel,
       Save,
       Print,
       Addd,
       SEARCH,
       Pending,
       CopyJV,
       PaymentRequests,
       ExportExcel
FROM ".$_SESSION['dbLabel'].".mainform_label
WHERE LANGUAGE = '".$Language."'";
$result_navigator = mysql_query($query_navigator, $connection);
$row_navigator    = mysql_fetch_array($result_navigator);
extract($row_navigator);

$query_project  = "select Project as Project1, ResultsPage as ResultsPage1
                   from ".$_SESSION['dbLabel'].".mainform_label
				   where Language = '".$Language."'";
$result_project = mysql_query($query_project, $connection);
$row_project    = mysql_fetch_array($result_project);
extract($row_project);

while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

class tabs {
	var $name;
	var $tabs;
	var $active;
	var $current;
function start($name){
		if (empty($this->active)){ $this->active = $name; }
		$this->current = $name;
		ob_start();
	}
	function end(){
		$this->tabs[$this->current] = ob_get_contents();
		ob_end_clean();
	}
	function run(){
	
		if (count($this->tabs) > 0){
			echo "<DIV CLASS='tabs'>\n";
			$jsClear = "";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				$jsClear .= "\tdocument.getElementById('$tabid').className = 'tab_inactive';\n";
				$jsClear .= "\tdocument.getElementById('$contentid').style.display = 'none';\n";
			}
			echo "<script type=\"text/javascript\">\n";
			echo "function tab_".$this->name."(id,fieldname){\n";
			
			
			
			echo "$jsClear";
			echo "\tdocument.getElementById('tab_".$this->name."_'+id).className = 'tab_active';\n";
			echo "\tdocument.getElementById('tabcontent_".$this->name."_'+id).style.display = '';\n";
			echo"	
				//alert(fieldname);
				if(fieldname!='' && fieldname!=undefined)
					
					document.supplierdt[fieldname].focus();
				";
			echo "}\n";
			echo "</script>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV CLASS='";
				if ($this->active == $tabname){ echo "tab_active"; }else{ echo "tab_inactive"; }
				echo "' ID='$tabid' ";
				echo "onClick=\"tab_".$this->name."('$tabname');\">$tabname</DIV>\n";
			}
			echo "<DIV STYLE='float: center; clear:both;'></DIV>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV ID = '$contentid' CLASS='tab_content' STYLE='display: ";
				if ($this->active == $tabname){ echo "block"; }else{ echo "none"; }
				echo ";'>$tabcontent</DIV>\n";
			}
			echo "</DIV>\n";
			echo "<DIV STYLE='clear: both;'></DIV>\n";
		}}
}	
$querylog="SELECT Project as loginaccess 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);
	}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");
	
	
//User Access
$querypurchase=" select ifNull(ShowLC,0) As ShowLC from purchasesetup  ";
$resultsetup=mysql_query($querypurchase,$connection) or die(mysql_error());
		  
//echo $querylog;
while($rows=mysql_fetch_array($resultsetup)){
	extract($rows);
}

$querylog=" select ifNull(FA_ProjectApp,0) As FA_ProjectApp, ifNull(FA_ProjectDel,0) As FA_ProjectDel, ".
          "ifNull(FA_ProjectMod,0) As FA_ProjectMod 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());
		  
//echo $querylog;
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

$HideMenu   = $_POST["HideMenu"]; if ($HideMenu == ""){$HideMenu = $_GET["HideMenu"];}   
$mode   	 = $_POST["mode"]; if ($mode == ""){$mode = $_GET["mode"];}   
$modedt   	 = $_POST["modedt"]; if ($modedt == ""){$modedt = $_GET["modedt"];}   
$message 	 = $_POST["message"]; if ($message == ""){$message = $_GET["message"];}   
$Project_Id  = $_POST["Project_Id"]; if ($Project_Id == ""){$Project_Id = $_GET["Project_Id"];} 

$txtKeyword  = $_POST["txtKeyword"]; if ($txtKeyword == ""){$txtKeyword = $_GET["txtKeyword"];}   
$perpage 	 = $_POST["perpage"]; if ($perpage == ""){$perpage = $_GET["perpage"];} 
$startrange	 = $_POST["startrange"]; if ($startrange == ""){$startrange = $_GET["startrange"];} 

$creation_date	 = $_POST["creation_date"]; if ($creation_date == ""){$creation_date = $_GET["creation_date"];} 
$project_code  	 = $_POST["project_code"]; if ($project_code == ""){$project_code = $_GET["project_code"];} 
$project_name 	 = $_POST["project_name"]; if ($project_name == ""){$project_name = $_GET["project_name"];} 
$parent_code 	 = $_POST["parent_code"]; if ($parent_code == ""){$parent_code = $_GET["parent_code"];} 
$project_active	 = $_POST["project_active"]; if ($project_active == ""){$project_active = $_GET["project_active"];} 
$txtCostCentCode = $_POST["txtCostCentCode"]; if ($txtCostCentCode == ""){	$txtCostCentCode = $_GET["txtCostCentCode"];}

$ProjectDt_Id	    = $_POST["ProjectDt_Id"]; if ($ProjectDt_Id == ""){$ProjectDt_Id = $_GET["ProjectDt_Id"];} 
$ProjectDt_Name		= $_POST["ProjectDt_Name"]; if ($ProjectDt_Name == ""){$ProjectDt_Name = $_GET["ProjectDt_Name"];} 
$ProjectDt_NumberofSeats  	= $_POST["ProjectDt_NumberofSeats"]; if ($ProjectDt_NumberofSeats == ""){$ProjectDt_NumberofSeats = $_GET["ProjectDt_NumberofSeats"];} 
$ProjectDt_View 	= $_POST["ProjectDt_View"]; if ($ProjectDt_View == ""){$ProjectDt_View = $_GET["ProjectDt_View"];} 
$ProjectDt_Floor 	= $_POST["ProjectDt_Floor"]; if ($ProjectDt_Floor == ""){$ProjectDt_Floor = $_GET["ProjectDt_Floor"];} 
$ProjectDt_Smoking	= $_POST["ProjectDt_Smoking"]; if ($ProjectDt_Smoking == ""){$ProjectDt_Smoking = $_GET["ProjectDt_Smoking"];} 

$thickness_id	= $_POST["thickness_id"]; if ($thickness_id == ""){$thickness_id = $_GET["thickness_id"];} 
$width_id		= $_POST["width_id"]; if ($width_id == ""){$width_id = $_GET["width_id"];} 

//Access mode On Insert/Edit/Delete
$Insmode = '';
if ($FA_ProjectApp == 0)
	$Insmode = ' disabled ';
	


if($project_active=='')
	$project_active=0;

$saveEnabled = 0;
if ( ($FA_ProjectMod == 1 && $mode=='editmode') || ($FA_ProjectApp == 1))
	$saveEnabled = 1;


if($mode=='editmode'){

	$query_edit="select Project_Id, project.project_code,project_name,date_format(project_date,'%d-%m-%Y'),Project_Deactivate,parent_code,
				project_email, FormM_No, BA_No, Bank_Name, LC_No, thickness_id, width_id, gross_weight, net_weight, ifnull(project_blocked,0), distribution_code , project_client , ledger_name , project_job,project_position
				from project left join clients on clients.ledger_number = project_client where Project_Id='".$Project_Id."'";
			//	echo$query_edit;
	$resultedit = mysql_query($query_edit, $connection);
	while($row=mysql_fetch_array($resultedit)){

		$Project_Id		= $row[0];
		$project_code	= $row[1];
		$project_name	= $row[2];
		$creation_date	= $row[3];
		$project_active	= $row[4];
		$parent_code	= $row[5];
		$project_email	= $row[6];
		$txtfromMNo		= $row[7];
		$txtBaNo		= $row[8];
		$txtBankName	= $row[9];
		$txtLcNo		= $row[10];
		$thickness_id	= $row[11];
		$width_id		= $row[12];
		$gross_weight	= $row[13];
		$net_weight		= $row[14];
		$project_blocked = $row[15];
		$txtCostCentCode = $row[16];
		$project_clientcode = $row[17];
		$project_client = $row[18];
		$project_job = $row[19];
		$project_position = $row[20];
	}
	$mode='edit';
}

if($modedt=='editdt'){
	$querydt = " select ProjectDt_Id, ProjectDt_Name, ProjectDt_NumberofSeats, ProjectDt_View, ProjectDt_Floor, ProjectDt_Smoking ".
			   " from ProjectDt ".
			   " where ProjectDt_Id='".$ProjectDt_Id."'";
		   	
	//echo $querydt;
	$resultdt = mysql_query($querydt, $connection);
	while($rowdt=mysql_fetch_array($resultdt)){
        
		$ProjectDt_Id=$rowdt[0];
		$ProjectDt_Name=$rowdt[1];
		$ProjectDt_NumberofSeats=$rowdt[2];
		$ProjectDt_View=$rowdt[3];
		$ProjectDt_Floor=$rowdt[4];
		$ProjectDt_Smoking=$rowdt[5];
	}
}

if($mode=='') $mode='insert';

print <<<HERE
<Html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="css/tabs.css">
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript" language="javascript">



function showcode(){
	x = document.project;
	 
project_client = x.project_client.value;
project_job = x.project_job.value;
project_position = x.project_position.value;
parent = x.parent_code.value;
		// var xmlhttp = getXMLHttpRequest();	
		
		
		// xmlhttp.onreadystatechange=function()
		// {
		// 	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		// 	{	 
		// 	//alert( xmlhttp.responseText);
		// 		x.project_code.value = xmlhttp.responseText;
		// 	}
		// }

		// xmlhttp.open("GET","Form_project_Actions.php?actionmode=Get_ItemCode&project_position="+project_position+"&project_job="+project_job+"&project_client="+project_client+"&parent="+parent);
		// xmlhttp.send();
	 


		//document.getElementById('loadergif').style.display = 'block';
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			xmlhttp.onreadystatechange=function()
			  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
					
					var data = xmlhttp.responseText.split("[BRK]");
					x.project_code.value = xmlhttp.responseText;

					
				}
			  }
			  xmlhttp.open("GET","Form_project_Actions.php?actionmode=Get_ItemCode&project_position="+project_position+"&project_job="+project_job+"&project_client="+project_client+"&parent="+parent);
			  xmlhttp.send();

	
}


function showlistClient(str){

  
	window.open('List_SorClient.php?frm=22&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistJob(str){

  
	window.open('List_ProjJob.php?str=1&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistPosition(str){

  
	window.open('List_ProjPosition.php?str=1&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function editmode () {

	document.project.action="Form_Project.php?mode=edit";
	document.project.submit();
}

function AddProject () {
     ClearForm('All');
	document.project.mode.value='insert'; 
	document.project.action="Form_Project.php";
	document.project.submit();
}

function SubmitRecord(option) { 
	var pergage=document.project.perpage.value; 
	if (document.project.project_code.value=='' ){
		alert('Unable to save : check missing field Name ');
		document.project.project_code.focus();
	
	}
	else  if (document.project.project_name.value=='' ){
		alert('Unable to save : check missing field Name ');
		document.project.project_name.focus();
	}
	else if (document.project.ProjectDt_Name.value=='' && option == 2)
	{
		alert('Unable to save : check missing field Detail Name ');
		document.project.ProjectDt_Name.focus();
	}
	else if (document.project.ProjectDt_NumberofSeats.value=='' && option == 2)
	{
		alert('Unable to save : check missing field Detail # of Seats ');
		document.project.ProjectDt_NumberofSeats.focus();
	}	
	else {
		//alert('Form_Project_Actions.php?&perpage='+perpage);
		document.project.action="Form_Project_Actions.php?&perpage='+perpage";
		document.project.submit();
	}
}

function DeleteDetail(ProjectDtId){

	if (confirm ( "Are you sure you want to Delete record?"))
	{
		vMainMode = document.project.mode.value;
		document.project.ProjectDt_Id.value = ProjectDtId;
		document.project.modedt.value = 'deletedt';
		
		document.project.action="Form_Project_Actions.php?mode="+vMainMode+"&modedt=deletedt";
		document.project.submit();
		
	}	

}

function UpdateDetail(ProjectDtId){
	vMainMode = document.project.mode.value;
	document.project.ProjectDt_Id.value = ProjectDtId;
	document.project.modedt.value = 'editdt';
		
	document.project.action="Form_Project.php?mode="+vMainMode+"&modedt=editdt";
	document.project.submit();

}

function ClearPage(){
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
			x.mode.value='';
			x.message.value = '';
			x.project_active.value = '';
			x.parent_code.value='';
			x.txtCostCentCode.value = '';
		if(x.txtfromMNo) 	
			x.txtfromMNo.value  = '';
		if(x.txtBaNo) 		
			x.txtBaNo.value	 	= '';
		if(x.txtBankName) 	
			x.txtBankName.value = '';
		if(x.txtLcNo) 		
			x.txtLcNo.value 	= '';
		x.thickness_id.value='';
		x.width_id.value='';
		x.gross_weight.value='';
		x.net_weight.value='';
		x.project_blocked.value='';
		if (x.proj_id) x.proj_id.value = '';
		if (x.proj_percentage) x.proj_percentage.value = '';
		if (x.proj_number) x.proj_number.value = '';
		if (x.pIP) x.pIP.value = '';
		if (x.pSubnet) x.pSubnet.value = '';
		if (x.pGateway) x.pGateway.value = '';
		if (x.project_client) x.project_client.value = '';
		if (x.project_clientcode) x.project_clientcode.value = '';
		if (x.project_position) x.project_position.value = '';
		if (x.project_job) x.project_job.value = '';

		x.action='Form_Project.php';
		x.submit();
	}	
}

function ClearDetail() {
	x = document.project;
	
	x.ProjectDt_Id.value='';
	x.ProjectDt_Name.value='';
	x.ProjectDt_NumberofSeats.value='';
	x.ProjectDt_View.value='';
	x.ProjectDt_Floor.value='';
	x.ProjectDt_Smoking.value='';
	
	x.submit();

}

//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.project;
	x.Project_Id.value='';
	//x.creation_date.value='';
	x.project_code.value='';
	x.project_name.value='';
	x.project_email.value='';
	
	if (x.pStartDate) 	x.pStartDate.value='';
	if (x.pPreventDate) x.pPreventDate.value='';
	if (x.pNbrVisit) 	x.pNbrVisit.value='';
	if (x.pNbrMonth) 	x.pNbrMonth.value='';
}

/*
function SearchForProject(){
    ClearForm('All');
    x = document.Project;
    win = window.open('Form_ProjectSearch.php', 'Form_ProjectSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=775,height=450,top=100,left=100');		
	win.creator = self;
	win.focus();		
			
}*/

function PrintPreview() {
	let str = '';
	str = 'Form_ProjectPreview.php';
	
	window.open(str);

}

function printExcel(Vrs){
	let str = '';
	if (Vrs == 1)
		str = 'Exp_ProjectSupportInfo.php';
	else if (Vrs == 2)
		str = 'Exp_ProjectSupportItems.php';
	window.open(str);
}

function ChkActive(){

	x = document.project;
	if(x.Chk_Active.checked)
		x.project_active.value=1;
	else x.project_active.value=0;	
}

function ChkSmoking(){
	x = document.project;
	
	if(x.Chk_Smoking.checked)
		x.ProjectDt_Smoking.value=1;
	else 
		x.ProjectDt_Smoking.value=0;	
}



function SetNextPage(startrange,perpage){
	document.project.action='Form_Project.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.project.submit();
}

function SetPrvPage(startrange,perpage){
	document.project.action='Form_Project.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.project.submit();
}

function SearchForProject(){
	x = document.project;
	document.project.action='Form_Project.php?startrange=0';
	document.project.submit();
}

function ClearKeyword(){
	x = document.project;
	x.txtKeyword.value='';
	document.project.submit();
}

/* function SetProject(Projectcode){
	
	document.project.Projectcode.value=Projectcode;
	document.project.message.value='';
	document.project.mode.value='editmode';
	document.project.submit();
} */
function SetProject(ProjectId){
	
	document.project.Project_Id.value=ProjectId;
	document.project.message.value='';
	document.project.mode.value='editmode';
	document.project.submit();
}

function set_limit(){

	perpage=document.project.perpage.value;
	document.project.action='Form_Project.php?perpage='+perpage+'&startrange=0';
	document.project.submit();
}

function submitenter(myfield,e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   	document.project.action='Form_Project.php?startrange=0';
	document.project.submit();
  
   return false;
   }
else
   return true;
}

function confirm_delete(Code) {
	
				
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
		//window.event.returnValue = true;
		document.project.mode.value='delete';	
		
		document.project.action='Form_Project_Actions.php?ProjectId='+Code;
		document.project.submit();
	}
					
}
function setBlock(){
	if (document.getElementById('project_blocked').checked)
		document.getElementById('project_blocked').value=1;
	else document.getElementById('project_blocked').value=0;
}

function showlistWarehouse(index){
	win = window.open('List_SorWarehouse.php?frm=13&index='+index, 'List_SorWarehouse', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=775,height=450,top=100,left=100');		
	win.creator = self;
	win.focus();	
}

function submitWarehouse(index){
	var x = document.project;
	var wp_id = document.getElementById('wpid['+index+']').value;
	if (wp_id != '')
		var modedt = 'updateWarehouse';
	else 
		var modedt = 'insertWarehouse';
	
	var mode 			= x.mode.value;
	var project_code 	= x.project_code.value;
	var project_name 	= x.project_name.value;
	var project_email 	= x.project_email.value;
	var parent_code 	= x.parent_code.value;
	var project_active 	= x.project_active.value;
	var project_blocked = x.project_blocked.value;
	var creation_date	= x.creation_date.value;
	
	var txtfromMNo 		= x.txtfromMNo.value;
	var txtBaNo 		= x.txtBaNo.value;
	var txtBankName 	= x.txtBankName.value;
	var txtLcNo 		= x.txtLcNo.value;
	var thickness_id	= x.thickness_id.value;
	var width_id 		= x.width_id.value;
	var gross_weight 	= x.gross_weight.value;
	var net_weight 		= x.net_weight.value;
	
	var Project_Id		= x.Project_Id.value;
	
	var warehousecode 	= document.getElementById('warehousecode['+index+']').value;
	
	if(project_code == '') {
		alert("Project Code is Empty!");
		return 0;
	}  else if(project_name == '') {
		alert("Project Name is Empty!");
		return 0;
	} else if (warehousecode == ''){
		alert("Warehouse Code is Empty!");
		return 0;
	} else {
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				if (mode == 'insert'){
					x.mode.value = 'editmode';
					x.Project_Id.value = data[2]; 
					x.submit();
				
				} else {
					if (data[1] != '') alert(data[1]);
					document.getElementById('whdiv').innerHTML = data[2];
				}
			}
		  }

	  
		xmlhttp.open("GET","Form_Project_Actions.php?mode="+mode+"&modedt="+modedt+"&project_code="+project_code+"&project_name="+project_name+"&project_email="+project_email+"&parent_code="+parent_code+
				"&project_active="+project_active+"&project_blocked="+project_blocked+"&txtfromMNo="+txtfromMNo+"&txtBaNo="+txtBaNo+"&txtBankName="+txtBankName+"&txtLcNo="+txtLcNo+"&thickness_id="+thickness_id+
				"&width_id="+width_id+"&gross_weight="+gross_weight+"&net_weight="+net_weight+"&wp_id="+wp_id+"&warehousecode="+warehousecode+"&Project_Id="+Project_Id+"&creation_date="+creation_date,true);
		xmlhttp.send();
	}
}

function removeWarehouse(index){
	var x = document.project;
	var wp_id = document.getElementById('wpid['+index+']').value;
	if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				if (data[1] != '') alert(data[1]);
				document.getElementById('whdiv').innerHTML = data[2];
				
			}
		  }
	xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=removeWarehouse&project_code="+x.project_code.value+"&wp_id="+wp_id,true);
	xmlhttp.send();
}

function returnMsg(){
	alert('Access Denied!');
	return 0;
}

function OpenProject(){
	XPos = (screen.availHeight - 560) / 2;
	YPos = (screen.availWidth - 970) / 2;
	
    win = window.open('Form_NewCostcenter.php?pagetype=P', 'Form_NewCostcenter', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=550,height=280,left='+YPos+',top='+XPos);		
	win.creator = self;
	win.focus();
}

function setChild(project_id){
	var project_code = document.project.project_code.value;

	if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				document.getElementById('childdiv').innerHTML = '';
				document.getElementById('childdiv').innerHTML = data[1];
				
			}
		  }
	xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=setChild&project_code="+project_code+"&proj_id="+project_id,true);
	xmlhttp.send();
}

function showlistCostcenter(){

	vCostcentCode = encodeURIComponent(document.getElementById('txtCostCentCode').value);
	window.open('List_SorCostcenter.php?frm=38&item=&PCostcent_Code='+vCostcentCode,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function ExportExcel() {
	var str = 'Form_ProjectExcel.php';
	window.open(str);
}

function saveval(){
	var project_code 	= document.project.project_code.value;
	var proj_id 		= document.project.proj_id.value;
	var proj_percentage = document.project.proj_percentage.value;
	var proj_number 	= document.project.proj_number.value;

if (proj_id == ''){
	alert("Please select a project first!");
	return 0;

} else { 
	document.getElementById('loadergif').style.display = 'block';
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			xmlhttp.onreadystatechange=function()
			  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
					
					var data = xmlhttp.responseText.split("[BRK]");
					document.getElementById('childdiv').innerHTML = '';
					document.getElementById('childdiv').innerHTML = data[1];

					
				}
			  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=saveval&project_code="+project_code+"&proj_id="+proj_id+"&proj_percentage="+proj_percentage+"&proj_number="+proj_number,true);
		xmlhttp.send();
	}
}
function showlistItems(index){
	XPos = (screen.availHeight - 400) / 2;
	YPos = (screen.availWidth - 850) / 2;
    window.open('select_item.php?item=19&index='+index,'Item List','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,left='+YPos+',top='+XPos);
}

function addItem(project_code,item_id,index){
	var itemCode = encodeURIComponent(document.getElementById('pItem_code['+index+']').value);
	var itemQty  = encodeURIComponent(document.getElementById('pItem_qty['+index+']').value);
	if (project_code == ''){
		alert('Project Code is Empty!');
		return 0;
	} 
	else if (itemCode == ''){
		alert('No Item was Selected!');
		document.getElementById('pItem_code['+index+']').focus();
		return 0;
	}
	else if (itemQty == ''){
		alert('Quantity is Empty!');
		document.getElementById('pItem_qty['+index+']').focus();
		return 0;
	}
	else {
		document.getElementById('loadergif2').style.display = 'block';
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			xmlhttp.onreadystatechange=function()
			  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
					
					var data = xmlhttp.responseText.split("[BRK]");
					if (data[1] != ''){
						alert(data[1]);
						document.getElementById('loadergif2').style.display = 'none';
					} else {
						document.getElementById('itemGrid').innerHTML = '';
						document.getElementById('itemGrid').innerHTML = data[2];
					}
					
				}
			  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=addItem&project_code="+project_code+"&item_id="+item_id+"&itemCode="+itemCode+"&itemQty="+itemQty,true);
		xmlhttp.send();
	}
}

function deleteItem(project_code,item_id){
	document.getElementById('loadergif2').style.display = 'block';
	
	if (confirm("Are You Sure You want to delete this Record?")){
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				
				var data = xmlhttp.responseText.split("[BRK]");
				if (data[1] != ''){
					alert(data[1]);
					document.getElementById('loadergif').style.display = 'none';
				} else {
					document.getElementById('itemGrid').innerHTML = '';
					document.getElementById('itemGrid').innerHTML = data[2];
					

				}
				
			}
		  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=deleteItem&project_code="+project_code+"&item_id="+item_id,true);
		xmlhttp.send();
	}
}

function showLocationList(vFrm, vType){
	window.open('List_LocationByType.php?frm='+vFrm+'&LocType='+vType,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showSerial(pid){
	var serialId = '#Serial-'+pid;
	$(serialId).toggle();
}

function addSerial(serialid, projectItemId, index){
	
	var serialNbr = document.getElementById('serialNbr'+projectItemId+'-'+index).value;
	
	if (serialNbr == ''){
		alert('No Serial Number was Added!');
		return
	} else {
		document.getElementById('loadergif2').style.display = 'block';	
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				document.getElementById('Serial2-'+projectItemId).innerHTML = '';
				document.getElementById('Serial2-'+projectItemId).innerHTML = data[1];
				document.getElementById('loadergif2').style.display = 'none';
				document.getElementById('Serial'+projectItemId).style.display = 'block';
			}
		  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=addSerial&serialid="+serialid+"&projectItemId="+projectItemId+"&serialNbr="+serialNbr,true);
		xmlhttp.send();
	}
}

function deleteSerial(serialid, projectItemId){
	if (confirm("Are You Sure You want to delete this Record?")){
		
		document.getElementById('loadergif2').style.display = 'block';	
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				document.getElementById('Serial2-'+projectItemId).innerHTML = '';
				document.getElementById('Serial2-'+projectItemId).innerHTML = data[1];
				document.getElementById('loadergif2').style.display = 'none';
				document.getElementById('Serial'+projectItemId).style.display = 'block';
			}
		  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=deleteSerial&serialid="+serialid+"&projectItemId="+projectItemId,true);
		xmlhttp.send();
	}
}

function showDiv(mactype){
	var varArr = ["wan","lan","print","soft"];
	for(var i=0;i<varArr.length;i++){
		if (varArr[i] != mactype)
		document.getElementById('grid-'+varArr[i]).style.display = 'none';
	}  
	
	if (document.project.project_code.value == ''){
		alert("Project_code is Empty!");
		return 0;
	} else {
		$('#grid-'+mactype).toggle('slow');
		/* if(document.getElementById('grid-'+mactype).style.display == 'block')
			document.getElementById('img-'+mactype).src = 'img/hide.png';
		else document.getElementById('img-'+mactype).src = 'img/show.png'; */
	} 
}

function saveMac(index,mac_id,mactype,project_code){
	let macAddress = encodeURIComponent(document.getElementById('macaddr-'+mactype+index).value);
	
	if (macAddress == ''){
		alert('Field is Empty!');
		return 0;
	} else {
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				document.getElementById('grid-'+mactype).innerHTML = '';
				document.getElementById('grid-'+mactype).innerHTML = data[1];
			}
		  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=addMac&project_code="+project_code+"&mac_id="+mac_id+"&mactype="+mactype+"&macAddress="+macAddress,true);
		xmlhttp.send();
	} 
}
function deleteMac(index,mac_id,mactype,project_code){
	if (confirm("Are you sure you want to Delete this Record?")){
		if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				document.getElementById('grid-'+mactype).innerHTML = '';
				document.getElementById('grid-'+mactype).innerHTML = data[1];
			}
		  }
		xmlhttp.open("GET","Form_Project_Actions.php?mode=&modedt=deleteMac&project_code="+project_code+"&mac_id="+mac_id+"&mactype="+mactype,true);
		xmlhttp.send();
	} 
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>$AddProject1</title>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style11{
	color: #000000;
    font-weight: bold;
    font-size: 11px;
    font-family: Verdana, Geneva, sans-serif;
}
.style1 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #FFFFFF ;font-size: 10px;}

#addButton {
	color: black;
    font-size: 16px;
    background-color: darkgray;
    width: 20px;
    height: 20px;
    border-radius: 10px;
	box-shadow: 2px 2px lightgrey;
}

div.gridclass {
	width: 280px;
    height: 200px;
    position: absolute;
    z-index: 99999;
	background-color: #c7c4c4;
	display: none;
	overflow-y: scroll;
	overflow-x: hidden;
}
</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>

</head>
<body >
<form name='project' method='post' onKeyPress="return submitenter(this,event)">
<input type='hidden' name='HideMenu' value='$HideMenu'>
<input type='hidden' name='mode' value='$mode'>
<input type='hidden' name='modedt' value='$modedt'>
<input type=hidden name='message' value='$message'>
<input type=hidden name='Project_Id' value='$Project_Id'>
HERE;



if($mode==''){
	$status='disabled';
	$dis='disabled';
}

if($mode=='view'){
	$status='readonly';
	$dis='disabled';
}

if($mode=='insert')
$status='';



//$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
if ($HideMenu != 1) include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title' style='text-transform: uppercase'>$Project1</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";
	  

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='38'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px'>";
echo"		<button type='button' id='btnClear' name='btnClear' onclick='ClearPage(); return false;' title='Clear Page'><span><span>$ClearPage</span></span></button>";


echo"		<button type='button' id='btnPost' name='btnPost' onclick=\"";
if ($saveEnabled == 1)
	echo "SubmitRecord(1); ";
else 
	echo "returnMsg(); ";
	echo "return false;\" title='Save Changes'><span><span>$Save</span></span></button> ";


echo"<button type='button'  name='btnPrint' type='button' id='btnPrint'  onclick=\"PrintPreview();\" title='Print' /><span><span>$Print</span></span></button>
	<button type='button' id='btnExcel' name='btnExcel' onclick=\"ExportExcel(); return false;\" title='Export Excel' ><span><span>$Excel</span></span></button>
	<button type='button' id='btnNewProj' name='btnNewProj' onclick='OpenProject(); return false;' title='New Project' ><span><span>New Project</span></span></button> ";

if ($project_ticket == 1 && $Module_TicketSupport == 1)
	echo "<button type='button' id='btnExcel1' name='btnExcel1' onclick=\"printExcel('1'); return false;\" title='Export Excel' ><span><span>Export Branch Info</span></span></button> 
		 <button type='button' id='btnExcel2' name='btnExcel2' onclick=\"printExcel('2'); return false;\" title='Export Excel' ><span><span>Export Items Info</span></span></button>";
				
echo"   </td><td align='left' width='250px'>
	<input type='text' name='txtKeyword' value='$txtKeyword' style='width:110px;' onKeyPress='return submitenter(this,event)'>

    <button type='button' id='btnSearch' name='btnSearch' onclick='SearchForProject(); return false;' title='Search Project'><span><span>Find</span></span></button>";
echo"<button type='button' id='btnClear' name='btnClear' onclick='ClearKeyword(); return false;' title='Clear Keyword'><span><span>Clear</span></span></button></td><td align='left'>
<span class='style1'><b>".$ResultsPage1."</b></span>
	 <span class='style1'><select name='perpage' id='perpage' value='$perpage' onselect=set_limit();>";
	 
	
									if ($startrange=='')
										$startrange = 0;
									if ($perpage=='')
										$perpage = 20;
									//row limit loop
									foreach ($config['trowlimit'] as $value) {
										echo "<option value='$value' ";
										if($value==$perpage) echo "selected";
											echo " >$value</option>";
									}
	
	 echo"</td></tr>";
echo"	</table>";
echo"</td></tr>";


echo"<tr>
		<td id='content-body'>";	
$tabs = new tabs("Groups");	
	
$tabs->start($MainPage1);		
echo"		<table border='0'  align='center' valign='top' width='1100px' class='tablecontent' >
				<col width=64%>";
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'>";	  	
echo"				 <table border='0' style='table-layout:fixed' align='left' valign='top'>
						<col width=120>";
echo"					<tr bgcolor='#F7F7F7' height='25'>
							<td valign='center' align='left' ><span class='style11'>".$CreationDate1."&nbsp;<span class='style26'>*</span></span></td>";
								if($mode!=''){
									$today = date('d-m-Y');
									$creation_date = $today;
								}
					
echo"						<td><input type='text' name='creation_date' id='creation_date' value='$creation_date' style='font-size:12px; width:100px; height:18px;'  readonly /></td>
				</tr>";

echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td valign='center' align='left' ><span class='style11'>".$Code1."&nbsp;<span class='style26'>*</span></span>";
echo"				<td><input type='text' name='project_code'  value='".htmlspecialchars($project_code, ENT_QUOTES)."' style='font-size:12px; width:120px; height:18px;'  $status maxlength='20' />";
if($Module_genproject==1){
	echo"		<input type='button' name='but1' id='but1' value='Show Code' onclick='showcode()'>
";
}
echo"</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>".$Name1."&nbsp;<span class='style26'>*</span></span>";
echo"				<td><input type='text' name='project_name' value='".htmlspecialchars($project_name, ENT_QUOTES)."' style='font-size:12px; width:200px; height:18px;'  $status maxlength='100' /></td>
				</tr>";
				if($Module_genproject==1){
echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Client&nbsp;<span class='style26'></span></span>";
echo"				<td ><input type='text' name='project_clientcode' style='font-size:12px; width:80; height:18px;' value='".htmlspecialchars($project_clientcode, ENT_QUOTES)."' $status >
<input type='text' name='project_client' style='font-size:12px; width:115px; height:18px;' value='".htmlspecialchars($project_client, ENT_QUOTES)."' $status >
<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Client ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick=\"showlistClient('22');\" /></span></label</td>
				</tr>"; 

				echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Type&nbsp;<span class='style26'></span></span>";
echo"				<td ><input type='text' name='project_job' style='font-size:12px; width:200px; height:18px;' value='".htmlspecialchars($project_job, ENT_QUOTES)."' $status >
<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Job ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick=\"showlistJob(1);\" /></span></label</td>
				</tr>"; 

				echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Shipment&nbsp;<span class='style26'></span></span>";
echo"				<td ><input type='text' name='project_position' style='font-size:12px; width:200px; height:18px;' value='".htmlspecialchars($project_position, ENT_QUOTES)."' $status >
<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Position ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick=\"showlistPosition(1);\" /></span></label</td>
				</tr>"; 
				
				}
				else 
				echo"<input type='hidden' name='project_clientcode' value='$project_clientcode'><input type='hidden' name='project_client' value='$project_client'>
				<input type='hidden' name='project_job' value='$project_job'>
				<input type='hidden' name='project_position' value='$project_position'>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>".$Email1."&nbsp;<span class='style26'></span></span>";
echo"				<td ><input type='text' name='project_email' style='font-size:12px; width:200px; height:18px;' value='".htmlspecialchars($project_email, ENT_QUOTES)."' $status ></td>
				</tr>"; 

				$query="select project_code,project_name from project where (parent_code is null  or parent_code='') ";
				$result_parent=mysql_query($query,$connection);
				
echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>".$Parent1." &nbsp;</span></td>
					<td>
						<select name='parent_code'  $dis";
							echo"	>";
							echo"<option value=''></option>";
							while ($rowwp=mysql_fetch_row($result_parent)){
								if ($parent_code==$rowwp[0])
									echo "<option value='$rowwp[0]' selected>$rowwp[0] - $rowwp[1]</option>";
								else
									echo "<option value='$rowwp[0]'>$rowwp[0] - $rowwp[1]</option>";
							}
									
							echo"</select>
					</td>
				</tr>";
if($ShowLC == 1){

echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td valign='center' align='left' ><span class='style11'>FormM No</span></td>
					<td align='left'><input type='text' name='txtfromMNo' id='txtfromMNo' value='$txtfromMNo' style='font-size:12px; width:200px; height:18px;'></td>
					<td width='50px'></td>
					<td valign='center' align='left' ><span class='style11'>BA No</span></td>
					<td align='left'><input type='text' name='txtBaNo' id='txtBaNo' value='$txtBaNo' style='font-size:12px; width:200px; height:18px;'></td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td valign='center' align='left' ><span class='style11'>Bank Name</span></td>
					<td align='left'><input type='text' name='txtBankName' id='txtBankName' value='$txtBankName' style='font-size:12px; width:200px; height:18px;'></td>
					<td width='50px'></td>
					<td valign='center' align='left' ><span class='style11'>LC No</span></td>
					<td align='left'><input type='text' name='txtLcNo' id='txtLcNo' value='$txtLcNo' style='font-size:12px; width:200px; height:18px;'></td>
				</tr>";

}	else {
	echo "<input type='hidden' name='txtfromMNo' id='txtfromMNo' value='$txtfromMNo'>
		  <input type='hidden' name='txtBaNo' id='txtBaNo' value='$txtBaNo'>
		  <input type='hidden' name='txtBankName' id='txtBankName' value='$txtBankName'>
		  <input type='hidden' name='txtLcNo' id='txtLcNo' value='$txtLcNo'>";
}
if($module_transactionweight == '1')	{
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Thickness</span>";
echo"	<td align='left'>
			<select name='thickness_id' id='thickness_id'>";
echo "<option value=''></option>";
$query1 = "select Measurement_id,Measurement_number from measurementsetup where Measurement_Type='thickness';";
$res1 = mysql_query($query1,$connection);
while($row1 = mysql_fetch_row($res1)){
	echo "<option value='$row1[0]' ".($thickness_id==$row1[0]?'selected':'').">$row1[1]</option>";
}
echo "		</select>";				
echo"	</td>
	</tr>";
	
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Width</span>";
echo"	<td align='left'>
		<select name='width_id' id='width_id'>";
echo "<option value=''></option>";
$query2 = "select Measurement_id,Measurement_number from measurementsetup where Measurement_Type='width';";
$res2 = mysql_query($query2,$connection);
while($row2 = mysql_fetch_row($res2)){
	echo "<option value='$row2[0]' ".($width_id==$row2[0]?'selected':'').">$row2[1]</option>";
}
echo "		</select>";				
echo"	</td>
	</tr>";	
	
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Gross Weight</span></td>";
echo"	<td align='left'><input type='text' name='gross_weight' id='gross_weight' value='$gross_weight' style='width:100px;'>";
echo"	</td>
	</tr>";		

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Net Weight</span></td>";
echo"	<td align='left'><input type='text' name='net_weight' id='net_weight' value='$net_weight' style='width:100px;'>";
echo"	</td>
	</tr>";			
 } else {
	echo "<input type='hidden' name='thickness_id' id='thickness_id' value='$thickness_id'>
		  <input type='hidden' name='width_id' id='width_id' value='$width_id'>
		  <input type='hidden' name='gross_weight' id='gross_weight' value='$gross_weight'>
		  <input type='hidden' name='net_weight' id='net_weight' value='$net_weight'>"; 
 }
echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>Distributed Code</span></td>";
echo"			<td><input type='text' name='txtCostCentCode' id='txtCostCentCode' value='$txtCostCentCode' style='width:139px;' maxlength='20'
				<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Costcenter ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick=\"showlistCostcenter();\" /></span></label</td>";

echo"			<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style11'>".$Deactivate1."</span></td>";
echo"				<td align='left'>
						<input type='checkbox' name='Chk_Active' ";if($project_active==1) echo ' checked ';echo"onclick='ChkActive();' $dis>
						<input type='hidden' name='project_active' value='".htmlspecialchars($project_active, ENT_QUOTES)."' style='font-size:12px; width:400px; height:18px;'  $status maxlength='50' />
					</td>
				</tr>";
if ($project_blocked == '') $project_blocked = 0;				
echo "<tr bgcolor='#F7F7F7' height='25'>
		<td valign='center' align='left' ><span class='style11'>Blocked</span></td>
		<td align='left'><input type='checkbox' name='project_blocked' id='project_blocked' value='$project_blocked' ".($project_blocked=='1'?'checked':'')." onclick=\"setBlock();\"></td>

		</tr>";				
echo "	</table></td></tr></table>";
				
$tabs->end();
// richard tab2
$tabs->start($Detail1);
echo"		<table border='0'  align='center' valign='top' width='1100px' class='tablecontent' >
				<col width=64%>";
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'>";	  	

echo "				<table style='table-layout:fixed; width:1100px;' border=0>
						<col width=55>
						<col width=55>
						<col width=100>
						<col width=100>
						<col width=100>
						<col width=100>
						<col width=60>
						<col width=150>";
							
echo "					<tr bgcolor='#D0D0D0' height='25px'>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td align='center'><span class='style1'>".$Name1."&nbsp;<span class='style26'>*</span></span></td>
							<td align='center'><span class='style1'>".$People1."(#)&nbsp;<span class='style26'>*</span></span></td>
							<td align='center'><span class='style1'>".$View1."</span></td>
							<td align='center'><span class='style1'>".$Floor1."(#)</span></td>
							<td align='center'><span class='style1'>".$Smoking1."</span></td>
							<td>&nbsp;</td>
						</tr>";
							
echo "					<tr bgcolor='#F7F7F7'>
							<td>&nbsp</td>
							<td>&nbsp;<input type='hidden' name='ProjectDt_Id' value='$ProjectDt_Id'></td>
							<td align='center'><input type='text' name='ProjectDt_Name' id='ProjectDt_Name' value='".htmlspecialchars($ProjectDt_Name, ENT_QUOTES)."' maxlength='100' style='width:100px;'/></td>
							<td align='center'><input type='text' name='ProjectDt_NumberofSeats'  value='".htmlspecialchars($ProjectDt_NumberofSeats, ENT_QUOTES)."' maxlength='10' style='width:100px;'>
							<td align='center'><input type='text' name='ProjectDt_View'  value='".htmlspecialchars($ProjectDt_View, ENT_QUOTES)."' maxlength='50' style='width:100px;'></td>
							<td align='center'><input type='text' name='ProjectDt_Floor'  value='".htmlspecialchars($ProjectDt_Floor, ENT_QUOTES)."' maxlength='50' style='width:100px;'></td>
							<td align='center'><input type='checkbox' name='Chk_Smoking' ";if($ProjectDt_Smoking==1) echo ' checked ';echo"onclick='ChkSmoking();' $dis><input type='hidden' name='ProjectDt_Smoking'  value='$ProjectDt_Smoking' ></td>";
echo " 						<td align='left'>
								<button type='button' id='submitrecord' name='submitrecord' onclick='SubmitRecord(2); return false;' title='Save Changes' $Insmode><span><span>Submit</span></span></button>
								<button type='button' id='clearbutton' name='clearbutton' onclick='ClearDetail(); return false;' title='Clear Detail' $Insmode><span><span>Clear</span></span></button>
							</td>";
echo "					</tr>";	

					$querydt = " select ProjectDt_Id, ProjectDt_Name, ProjectDt_NumberofSeats, ProjectDt_View, ProjectDt_Floor, if(ProjectDt_Smoking=1, 'Yes', 'No') ".
							   " from ProjectDt ";
					$querydt = $querydt." where Project_Id='".$Project_Id."'";

					//echo $querydt;
						$resultdt = mysql_query($querydt, $connection);
						while($rowsdt=mysql_fetch_array($resultdt)){
										
							$ct+=1;

							if($ct%2==0)
								$Color="style='background-color:".$grid_color1."'";
							else			
								$Color="style='background-color:".$grid_color2."'";	
												
										
							echo "<tr ".$Color." >";
							echo "	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onMouseOver=\"style.cursor='hand'\" onclick=\"UpdateDetail('".$rowsdt[0]."');\" title='Edit Record'  ></span></td>";
							echo "	<td align='center' valign='center'><span class='style15'><img src='img/c_delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=\"DeleteDetail('".$rowsdt[0]."');\" title='Delete Record'  ></span></td>";
							echo "	<td align='left'><span class='style15'>".$rowsdt[1]."</span></td>";
							echo "	<td align='left'><span class='style15'>".$rowsdt[2]."</span></td>";
							echo "	<td align='left'><span class='style15'>".$rowsdt[3]."</span></td>";
							echo "	<td align='left'><span class='style15'>".$rowsdt[4]."</span></td>";
							echo "	<td align='center'><span class='style15'>".$rowsdt[5]."</span></td>";
							echo "</tr>";	
						}

echo"				</table>";
echo"			</td>
			</tr>
		</table>";
$tabs->end();
$tabs->start('Warehouse');
echo"		<table border='0'  align='center' valign='top' width='1100px' class='tablecontent' >
				<col width=64%>";
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'><div id='whdiv' style='height:350px;overflow-y: scroll;'>";	  	

drawProjectWarehouse($project_code, $connection);
echo"			</div></td>
			</tr>
		</table>";		
$tabs->end();
if ($project_code!=''){
$tabs->start("Calculations");
echo"		<table border='0'  align='center' valign='top'  class='tablecontent' >
							<col width=65%>";  	
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'><div id='childdiv' style='height:350px;'>";
docalc($project_code, $proj_id, $connection);
echo"	</div></td>
			</tr>		
		</table>";		
$tabs->end();	
}	
// Draw Project Info Tab
if ($project_ticket == 1 && $Module_TicketSupport == 1){
$tabs->start("Project Info");
echo"		<table border='0'  align='center' valign='top'  class='tablecontent' >
							<col width=65%>";  	
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'><div style='height:150px;'>";
draw_ProjectVisit($project_code, $connection);
echo"	</div></td>
			</tr>		
		</table>";		
$tabs->end();	

$tabs->start("Items");
echo"		<table border='0'  align='center' valign='top'  class='tablecontent' >
							<col width=65%>";  	
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'><div id='itemGrid' style='height:300px;'>";
draw_ProjectItems($project_code, $item_id, $connection);
echo"	</div></td>
			</tr>		
		</table>";		
$tabs->end();	

$tabs->start("IP");
echo"		<table border='0'  align='center' valign='top'  class='tablecontent' >
							<col width=65%>";  	
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'><div id='ipGrid' style='height:300px;'>";
draw_ProjectIP($project_code, $connection);
echo"	</div></td>
			</tr>		
		</table>";		
$tabs->end();	
}
$tabs->run();

echo"		<table border='0'  align='center' valign='top' width='1100px' class='tablecontent' >";
echo"   		<tr bgcolor='#F7F7F7'><td valign='top' align='left'  style='width:1100px;'>";	  	


echo"	<table style='width:1100px;' border='0'  cellspacing=0>
			<col width=30><col width=30>
			<col width=520>
			<col width=520>
			<tr height='30px' style='background-color:darkgray;'>
				<td >&nbsp;</td><td  >&nbsp;</td>
				<td align='center' ><span class='style11'><b>".$Code1."</b></td>
				<td align='center' ><span class='style11'><b>".$Name1."</b></td>
			</tr>";
	
	 
	echo"	<tr>
			<td  colspan='4' >
				<table  border='0' width='1100px;' >";
					if($FA_ProjectDel==1)	
						echo"<col width=30>
							<col width=30>
							<col width=170>
							<col width=162>";
							$querysearch="select project_id,project_code,project_name from project ";
							$querysearch=$querysearch." where (project_code like"."('%".$txtKeyword."%') or project_name like"."('%".$txtKeyword."%')) ";
						
							$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());
							$totalrows = mysql_num_rows($resultsearch);
							
							if ($startrange=='')
								$startrange = 0;
							if ($perpage=='')
								$perpage = 20;
							
							$querysearch = $querysearch." limit ".$startrange.",".$perpage;
							

							$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());	
							while($rows=mysql_fetch_array($resultsearch)){
								$ct+=1;
								$stylefont='style15';
								if($ct%2==0)
									$Color="style='background-color:".$grid_color1."'";
								else			
									$Color="style='background-color:".$grid_color2."'";	
										
								if($mode=='edit' && $Project_Id==$rows[0]){
									
									$Color="style='background-color:#1e87a5'";
									$stylefont='style28';
							}	
								
							echo'<tr '.$Color.' height="20px" >';
							if($FA_ProjectMod==1){ 
/* 	
	if($rows[0] == '')
print<<<HERE
	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onmouseover="this.style.cursor='pointer'" onclick=SetProject('$rows[1]') title=' Edit Record '  ></span></td>
HERE;
	else */
	print<<<HERE
									<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onmouseover="this.style.cursor='pointer'" onclick=SetProject('$rows[0]') title=' Edit Record '  ></span></td>
HERE;

	}
	if($FA_ProjectDel==1)	
print<<<HERE

								<td align=center ><img border='0' src='img/c_delete.png' width='9' height='10' title='Delete Detail' onmouseover="this.style.cursor='pointer'" OnClick="confirm_delete('$rows[0]')" $Delmode></td>

HERE;
else print<<<HERE

								<td align=center >&nbsp;</td>

HERE;

	echo"						<td style='cursor:pointer;' ";echo"><span class='$stylefont' >$rows[1]&nbsp;</span></font></td>
								<td style='cursor:pointer;' ";echo"><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rows[2]&nbsp;</span></font></td>";
	echo"";
	

	echo"					</tr></tr>";
}		
	
echo"					</table>
					</td>
				</tr></table>";

echo"<tr ><td >&nbsp;</td><td align='center'>";
		
		$diff= $startrange - $perpage;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange - $perpage;
			echo"<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center'>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.png' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
		} else
			echo "&nbsp;";
			
		echo"</td></tr>";

echo"</table></td>";

echo"</tr>";


echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";
include("footer.php");	
echo" </table>  ";//end of last table menu


if($pageclear == 1){
	echo"<script type='text/javascript'> ";
	echo"	ClearPage(); ";
	echo"</script>";
}

print <<<HERE
</form>
</body>

HERE;

?>