<?
include_once("../include/main.inc.php");

if($_GET['id']=='show_sub_categories') {
	$catID=$_GET['q'];
	echo getListingSubCategoriesDropDown("industryType", $catID, $industryType, "430");
	exit;
}

check_session('MyCpanel','index.php');

################ Paging Starts From Here ##################
@extract($_REQUEST);
$start = (intval($start)==0 or $start=="")?$start=0:$start;
$pagesize = intval($pagesize)==0?$pagesize=10:$pagesize;

$record_type="Member";
$script_name="admin_staff_manage_members.php";
$table_name="member_tbl";

if($action=="add_record") {
	$numCnt=getCount($table_name," where email='$email' and status!='D'");
	if($numCnt>0) {	
		$_SESSION['session_message']=$record_type.' already exist';
	}
	else{
		$form_check_alert=dynamic_check_form_values(array("rp-4-Please enter valid email-ID" => "".$email."","rp--Please enter member password" => "".$pwd."", "rp-11-Please enter member name" => "".$memberName."", "rp-11-Please enter member's company name" => "".$companyName."", "rp-1-Please enter member's mobile number" => "".$mobileNo."", "rp-11-Please enter member's company address" => "".$address."", "rp-2-Please enter member's city" => "".$city."", "rp-2-Please enter member's country" => "".$country."", "rp-11-Please enter company owner name" => "".$ownerName."", "rp-1-Please enter company's year of establishment" => "".$yoe."", "rp-11-Please enter company's main market" => "".$mainMarket."", "rp-2-Please enter company's business country" => "".$businessCountry."", "rp-1-Please select company's business nature" => "".$businessNature."", "rp-11-Please enter company description" => "".$companyDescription.""), $validation_ans_arr);
		
		if(!strlen($form_check_alert)>0){
			$all_categories="";
  		for ($i=0; $i<count($industryType); $i++) {
			  $catids=getCategoryHierarchy($industryType[$i]);
			  $all_categories.=$catids;
		  }
		  $all_categories=substr($all_categories,0,-1);
		  $tmp=explode("^",$all_categories);
		  asort($tmp);
		  $tmp=array_unique($tmp);
		  $all_categories=implode("^",$tmp);
		  $allCategories="^".$all_categories."^";		
		  
		  if (count($industryType) > 1) {
			  $industryType1=implode("^",$industryType);
			  $industryType2="^".$industryType1."^";
		  }
		  else {
			  $industryType2="^".$industryType[0]."^";
		  }
		  $industryType=$industryType2;
		  
		  db_query("insert into member_tbl set email='$email', pwd='$pwd', nameTitle='$nameTitle', memberName='$memberName', companyName='$companyName', jobTitle='$jobTitle', address='$address', city='$city', state='$state', zipcode='$zipcode', country='$country', countryCodePhone='$countryCodePhone', areaCodePhone='$areaCodePhone', phone='$phone', countryCodeFax='$countryCodeFax', areaCodeFax='$areaCodeFax', fax='$fax', mobileNo='$mobileNo', alternateEmail='$alternateEmail', ownerName='$ownerName', officeImage='$office_image', ownershipType='$ownershipType', yoe='$yoe', certification='$certification', mainMarket='$mainMarket', companySize='$companySize', annualTurnover='$annualTurnover', businessCountry='$businessCountry', businessNature='$businessNature', mainCategory='$mainCategory', industryType='$industryType', allCategories='$allCategories', companyDescription='$companyDescription', website='$website', businessType='$businessType', aboutUs='$aboutUs', contactUs='$contactUs', status='Y', addedBy='".$_SESSION['MyAdminUserSLNO']."', recvDate=now(), ipTrack='$ipTrack', lastlogin=now()");
		  $_SESSION['session_message']=$record_type." has been added sucessfully.";
		  header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
		  exit;
	  }
	  else {
		  $msg=html_head();
			$msg.=$form_check_alert;
			$msg.=html_foot();
		}
	}
}


if($action=="update_record") {
	$numCnt=getCount($table_name," where email='$email' and status!='D' and memberID!='$recordID'");
	if($numCnt>0) {	
		$_SESSION['session_message']=$record_type.' already exist';
	}
	else {
		$form_check_alert=dynamic_check_form_values(array("rp-4-Please enter valid email-ID" => "".$email."","rp--Please enter member password" => "".$pwd."", "rp-11-Please enter member name" => "".$memberName."", "rp-11-Please enter member's company name" => "".$companyName."", "rp-1-Please enter member's mobile number" => "".$mobileNo."", "rp-11-Please enter member's company address" => "".$address."", "rp-2-Please enter member's city" => "".$city."", "rp-2-Please enter member's country" => "".$country."", "rp-11-Please enter company owner name" => "".$ownerName."", "rp-1-Please enter company's year of establishment" => "".$yoe."", "rp-11-Please enter company's main market" => "".$mainMarket."", "rp-2-Please enter company's business country" => "".$businessCountry."", "rp-1-Please select company's business nature" => "".$businessNature."", "rp-11-Please enter company description" => "".$companyDescription.""), $validation_ans_arr);
		
		if(!strlen($form_check_alert)>0){
			$all_categories="";
  		for ($i=0; $i<count($industryType); $i++) {
			  $catids=getCategoryHierarchy($industryType[$i]);
			  $all_categories.=$catids;
		  }
		  $all_categories=substr($all_categories,0,-1);
		  $tmp=explode("^",$all_categories);
		  asort($tmp);
		  $tmp=array_unique($tmp);
		  $all_categories=implode("^",$tmp);
		  $allCategories="^".$all_categories."^";		
		  
		  if (count($industryType) > 1) {
			  $industryType1=implode("^",$industryType);
			  $industryType2="^".$industryType1."^";
		  }
		  else {
			  $industryType2="^".$industryType[0]."^";
		  }
		  $industryType=$industryType2;
		  
		  updateTable("member_tbl"," nameTitle='$nameTitle', memberName='$memberName', companyName='$companyName', jobTitle='$jobTitle', address='$address', city='$city', state='$state', zipcode='$zipcode', country='$country', countryCodePhone='$countryCodePhone', areaCodePhone='$areaCodePhone', phone='$phone', countryCodeFax='$countryCodeFax', areaCodeFax='$areaCodeFax', fax='$fax', mobileNo='$mobileNo', alternateEmail='$alternateEmail', ownerName='$ownerName', ownershipType='$ownershipType', yoe='$yoe', certification='$certification', mainMarket='$mainMarket', companySize='$companySize', annualTurnover='$annualTurnover', businessCountry='$businessCountry', businessNature='$businessNature', mainCategory='$mainCategory', industryType='$industryType', allCategories='$allCategories', companyDescription='$companyDescription', website='$website', aboutUs='$aboutUs', contactUs='$contactUs', updDate=now() where memberID='$recordID'");
		  
		  $_SESSION['session_message']=$record_type.' has been updated successfully';
			header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
			exit;
		}
		else{
			$msg=html_head();
			$msg.=$form_check_alert;
			$msg.=html_foot();
		}
	}
}


if($id=="View"){
	adminheader_popup("View Member Details");
	echo view_member_details($recordID);
	adminfooter_popup();
	exit;
}

/*
if($_POST[action]=="Delete"){
	if(sizeof($_POST[cid])==0) {
		$_SESSION[session_message]='Please select a record first.';
		header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
		exit;
	}
	for ($x=0; $x < sizeof($_POST[cid]); $x++){
		$arr=$_POST[cid];
		updateTable($table_name," status='D', premiumMember='N' where memberID='$arr[$x]'");		
	}
	$_SESSION[session_message]='Record has been deleted from the admin panel.';
	header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
	exit;
}
*/

if($_POST[action]=="Activate"){
	if(sizeof($_POST[cid])==0) {
		$_SESSION[session_message]='Please select a record first.';
		header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=$start&pagesize=$pagesize");
		exit;
	}
	for ($x=0; $x < sizeof($_POST[cid]); $x++){
		$arr=$_POST[cid];
		updateTable($table_name," status='Y' where memberID='$arr[$x]'");
	}
	$_SESSION[session_message]='Selected record(s) activated successfully.';
	header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
	exit;
}


if($_POST[action]=="Deactivate"){
	if(sizeof($_POST[cid])==0) {
		$_SESSION[session_message]='Please select a record first.';
		header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=$start&pagesize=$pagesize");
		exit;
	}
	for ($x=0; $x < sizeof($_POST[cid]); $x++){
		$arr=$_POST[cid];
		updateTable($table_name," status='N', premiumMember='N' where memberID='$arr[$x]'");
	}
	$_SESSION[session_message]='Selected record(s) deactivated successfully.';
	header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
	exit;
}


if($id=="deactivate") {
	updateTable($table_name," status='N', premiumMember='N' where memberID='$recordID' and status='Y' ");	
	$_SESSION[session_message]=$record_type.' has been deactivated successfully.';
	header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
	exit;
}


if($id=="activate") {
	updateTable($table_name," status='Y' where memberID='$recordID' and status='N' ");
	$_SESSION[session_message]=$record_type.' has been activated successfully.';
	header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
	exit;
}

/*
if ($id=="delete") {
	updateTable($table_name," status='D', premiumMember='N' where memberID='$recordID'");
	$_SESSION[session_message]=$record_type.' has been deleted successfully.';
	header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&pagesize=".$pagesize);
	exit;
}
*/

admin_header();
?>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" valign="top">
 <tr>
	<td align="left" width="50%"><strong><b class="myTitle">Manage <?=$record_type;?>s</b></strong></td>
	<td align="right">
	 <form name="pg_form" action="<?=$PHP_SELF?>" method="post" style="margin:0px;padding:0px;">
	 <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" valign="top">
	  <tr>
	   <td align="right">Records Per Page:
	    <select name="pagesize" onchange="this.form.submit();">
	     <option value="0">Select</option>
	     <?php
	     foreach($_GLOBALS[pgsize_arr] as $val) {
		     if(trim($pagesize)==trim($val)) {
			     echo '<option value="'.$val.'" selected>'.$val.'</option>';
		     }
		     else{
			     echo '<option value="'.$val.'">'.$val.'</option>';
		     }
	     }
	     ?>
	    </select>
	    <input type="hidden" name="keyword" value="<?=$keyword;?>" />
	    <input type="hidden" name="status" value="<?=$status;?>" />
		 </td>
		</tr>
	 </table>
	 </form>
	</td>
 </tr>
</table>
<hr size="2" width="99%" color="#DA251C">

<?
if ($premiumMember!="") {
	if ($premiumMember=="Y") {
		updateTable($table_name," status='Y', premiumMember='$premiumMember' where memberID='$recordID'");
	}
	else {
		updateTable($table_name," premiumMember='$premiumMember' where memberID='$recordID'");
	}
}
if ($status!="") {
	$cond="where status='$status'";
	$link="&status=$status";
}
else {
	$cond="where 1";
}

$cond.=" and addedBy='".$_SESSION['MyAdminUserSLNO']."'";
$qry1="select * from $table_name $cond";
$keyword=trim($keyword);
if($keyword!=""){
  $qry1.=" and (email LIKE '%$keyword%' or memberName LIKE '%$keyword%' )"; 
}

if($_REQUEST[sortName]!=''){
	$qry1 .= " order by $_REQUEST[sortName] $_REQUEST[sortBy]";
}
else {
	$qry1 .= " order by memberID desc";
}

$reccnt = NumRows(db_query($qry1));
$qry1.=" limit $start, $pagesize";
#echo $qry1;
$qry= db_query($qry1);
echo pageNavigation($reccnt,$pagesize,$start,$link);
print_message(); 
?>

<table width="100%"  border="0" cellpadding="6" cellspacing="2" class="lightBorder">
 <tr>
  <td class="lightGrayBg" align="left"><b>Search Members</b><br>
  <form name="search2" method="POST" action="">
   Keyword: <input name="keyword" type="text" class="input" size="25" value="<?=$keyword;?>">
   <input type="hidden"  class="button" name="id" value="Search2">
   <input type="submit"  class="button" name="search" value="Search">	
  </form>
  </td>
  <td class="lightGrayBg">
  <b>Sort Members<b><br>
  <form name="search3" method="POST" action="">
   <select name="sortName" size=1>
    <option value=''>--------Select---------</option>
    <option value='recvDate' <? if($sortName=="recvDate"){ echo "selected";}?>>Join Date</option>
    <option value='memberName' <? if($sortName=="memberName"){ echo "selected";}?>>Member Name</option>
    <option value='email' <? if($sortName=="email"){ echo "selected";}?>>Member Email</option>
   </select>
   <select name="sortBy">
    <option value=''>-----Sort By-----</option>
    <option value="asc" <? if($sortBy=="asc"){ echo "selected";}?>>Ascending</option>
    <option value="desc" <? if($sortBy=="desc"){ echo "selected";}?>>Descending</option>
   </select>
   <input type="hidden"  class="button" name="id" value="Search3">
   <input type="submit"  class="button" name="search" value="Sort">
  </form>
  </td>
  <td class="lightGrayBg">
   <b>Select Status</b><br/>
   <form name="sts_form" action="<?=$PHP_SELF?>" method="post" style="margin:0px;padding:0px;">
	 <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" valign="top">
	  <tr>
	   <td align="left">
	    <select name="status" onchange="this.form.submit();">
	     <option value="">All Members</option>
	     <option value="Y" <? if($status=="Y"){ echo "selected";}?>>Active</option>
	     <option value="N" <? if($status=="N"){ echo "selected";}?>>InActive</option>
	     <!-- <option value="D" <? if($status=="D"){ echo "selected";}?>>Deleted</option> !-->
	    </select>
	    <input type="hidden" name="keyword" value="<?=$keyword;?>" />
	    <input type="hidden" name="pagesize" value="<?=$pagesize;?>" />
		 </td>
		</tr>
	 </table>
	 </form>
	</td> 
 </tr>
</table><br />

<?
if($reccnt>0){
	?>
	<form name="formn" action="" method="POST">
	<input type="hidden" name="recordID" value="" />
	<input type="hidden" name="premiumMember" value="" />
	<table width="99%" border="0" cellpadding="2" cellspacing="2" class="lightBorder">
	 <tr height="25" bgcolor="#EAEAEA">
	  <td width="3%"><input type="checkbox" name="chk" onclick="CheckAll()" class="NoStyle"></td>
	  <td width="30%"><b>Member Details</b></td>
	  <td width=20%><b>Address Details</td>
	  <td width=14%><b>Membership Type</td>
	  <td width=10% align="center"><b>Join Date</b></td>
	  <td width=8% align="center"><b>Status</b></td>
	  <td width=15%><b>Options</b></td>
	 </tr>
	 <?
	 $sl=$start+1;
	 while ($arr=mysql_fetch_array($qry)) {
		 $arr=ms_htmlentities_decode($arr);
		 if($sl%2!=0){
			 $color="#ffffff";
		 }
		 else {
			 $color="#f6f6f6";
		 }
		 if ($arr[expiryDate]!="0000-00-00") {
			 $expiryDate=$arr[expiryDate];
		 }
		 else {
			 $expiryDate="";
		 }
		 ?>
		 <tr bgcolor="<?=$color;?>">
		  <td class="<?=$class?>" valign="top"><input type=checkbox name="cid[]" value="<?=$arr[memberID]?>" class="NoStyle"></td>
		  <td class="<?=$class?>" valign="top">
		   <b><?=$arr[nameTitle];?> <?=$arr[memberName];?></b>
		   <?
		   if($arr[email]!=""){
			   ?>
			   <br /><b>Email</b>: <?=$arr[email];?>
			   <br /><b>Password</b>: <? echo $arr[pwd];			   
		   }		   
		   ?>
		   <br/><b>Company Name</b>: <? echo ucwords($arr[companyName]);
		   if ($arr[jobTitle] != "") {
			   ?>
			   <br/><b>Job Title</b>: <? echo ucwords($arr[jobTitle]);
		   }
		   ?>
			 <br/><b>Business Type</b>: <? echo getBusinessType($arr[businessType]);?>
			 <br/><b>Business Nature</b>: <? echo getBusinessNature($arr[businessNature]);?>
			 <!-- <br/><b>Establish Year</b>: <? echo $arr[yoe];?> !-->
		  </td>
      <td valign='top' class="<?=$class?>">
			 <b>Address</b>: <? echo ucwords($arr[address]);	 
			 if($arr[city]!=""){
				 ?>
				 <br /><b>City</b>: <? echo ucwords($arr[city]);
			 }
			 if($arr[state]!=""){
				 ?>
				 <br /><b>State</b>: <? echo ucwords($arr[state]);
			 }			 
			 if($arr[country]!="") {
				 ?>
				 <br /><b>Country</b>: <? echo $arr[country];
			 }
			 if($arr[zipcode]!=""){
				 ?>
				 <br /><b>Zipcode</b>: <? echo $arr[zipcode];				 
			 }
			 if($arr[mobileNo]!=""){
				 ?>
				 <br /><b>Mobile No</b>: <? echo $arr[mobileNo];				 
			 }
			 if($arr[phone]!=""){
				 ?>
				 <br /><b>Phone</b>: <? echo $arr[countryCodePhone]."-".$arr[phone];
			 }
			 if($arr[fax]!="") {
				 ?>
				 <br /><b>Fax</b>: <? echo $arr[countryCodeFax]."-".$arr[fax];
			 }
			 ?>			 
      </td>
			<td valign='top' class="<?=$class?>">
			 <strong><? echo getMembershipPlanName($arr[membershipType]);?></strong>
			 <?
			 if ($expiryDate) {
				 ?>
				 <br/><br/><i>Activation Date</i>:<br/><strong><?=show_date($arr[activationDate])?></strong><br/><br/><i>Expiry Date</i>:<br/><strong><?=show_date($arr[expiryDate])?></strong>
				 <?
			 }
			 ?>
			</td>
			<td class="<?=$class?>" valign='top' align="center"><?=show_date($arr[recvDate])?></td>
			<td valign='top' align="center">
		   <?
		   if($arr[status]=='Y') {
			   ?>
			   <strong>Active</strong>
			   <?
		   }
		   else if($arr[status]=='D') {
			   ?>
			   <strong>Deleted</strong>
			   <?
		   }
		   else {
			   ?>
			   <strong>Inactive</strong>
			   <?
		   }
		   ?>
		  </td>
			<td class="<?=$class?>" valign='top'>
			 <?
		   if($arr[status]=='Y') {
			   ?>
			   &nbsp;<a href="<?=SITE_ADMIN_URL?>/<?=$script_name;?>?id=deactivate&recordID=<?=$arr[memberID];?>&start=<?=$start;?>&pagesize=<?=$pagesize?>"><img src="<?=SITE_ADMIN_URL?>/images/active.gif" alt="Deactivate This <?=$record_type;?>" title="Deactivate This <?=$record_type;?>" border="0"></a>
			   <?
		   }
		   if($arr[status]=='N') {
			   ?>
			   &nbsp;<a href="<?=SITE_ADMIN_URL?>/<?=$script_name;?>?id=activate&recordID=<?=$arr[memberID];?>&start=<?=$start;?>&pagesize=<?=$pagesize?>"><img src="<?=SITE_ADMIN_URL?>/images/deactive.gif" alt="Activate This <?=$record_type;?>" title="Activate This <?=$record_type;?>" border="0"></a>
			   <?
		   }
		   ?>
		   &nbsp;<a href="javascript:void(0);" onclick="window.open('<?=SITE_ADMIN_URL?>/<?=$script_name;?>?id=View&recordID=<?=$arr[memberID]?>&start=<?=$start?>&pagesize=<?=$pagesize?>','pop','height=550,width=550,scrollbars=yes,resizable=yes');"><img src="<?=SITE_ADMIN_URL?>/images/preview.gif" alt="View This <?=$record_type;?> Details" title="View This <?=$record_type;?> Details" border="0"></a>
			 &nbsp;<a href="<?=$script_name;?>?id=edit_record&start=<?=$start;?>&pagesize=<?=$pagesize?>&recordID=<?=$arr['memberID'];?>#bot"><img src="<?=SITE_ADMIN_URL?>/images/edit.gif" alt="Edit This <?=$record_type;?>" title="Edit This <?=$record_type;?>" border="0"></a>
			 <?php
			 /*
			 if($arr[status]!='D') {
				 ?>
				 &nbsp;<a href="<?=$script_name;?>?id=delete&recordID=<?=$arr[memberID]?>&start=<?=$start?>&pagesize=<?=$pagesize?>" onClick="return confirm('Are you sure you want to delete this record')"><img src="<?=SITE_ADMIN_URL?>/images/cancel.gif" alt="Delete This <?=$record_type;?>" title="Delete This <?=$record_type;?>" border="0"></a>
				 <?php
			 }
			 
			 if ($arr['membershipType'] < 3 && $arr['businessNature'] == 2) {
				 ?>
				 <br/><br/><br/><br/>
			   <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" valign="top">
			    <tr>
			     <td align="center">
			      <select name="premiumMember<?=$arr[memberID];?>" onchange="return submit_form1(this.value,'<?=$arr[memberID];?>');">
			       <option value="">Set Member As</option>
			       <option value="Y" <? if($arr[premiumMember]=="Y"){ echo "selected";}?>>Premium</option>
			       <option value="N">Unset Premium</option>
			      </select>			      
			     </td>
			    </tr>
			   </table>			   
			   <?php
		   }
		   */
		   ?>
			</td>
		 </tr>
		 <?
		 $sl++;
	 }
	 ?>
	 <tr bgcolor="EAEAEA">
	  <td colspan="7">
	   <?
	   if($status=="Y"){
		   ?>
		   <!-- <input type="submit" name="action" value="Delete"  onclick="return chkdelete();" class="button"> !-->
		   <input type="submit" name="action" value="Deactivate"  onclick="return chkactivate();" class="button">
		   <?
	   }
	   else if ($status=="N"){
		   ?>
		   <!-- <input type="submit" name="action" value="Delete"  onclick="return chkdelete();" class="button"> !-->
		   <input type="submit" name="action" value="Activate"  onclick="return chkactivate();" class="button">
		   <?
	   }
	   else if ($status=="D"){
		   ?>
		   <input type="submit" name="action" value="Activate"  onclick="return chkactivate();" class="button">
		   <?
	   }
	   else {
		   ?>
		   <!-- <input type="submit" name="action" value="Delete"  onclick="return chkdelete();" class="button"> !-->
		   <input type="submit" name="action" value="Deactivate"  onclick="return chkactivate();" class="button">
		   <input type="submit" name="action" value="Activate"  onclick="return chkactivate();" class="button">
		   <?
	   }
	   ?>
	   <input name="start" type="hidden" value="<?=$start?>" />
	   <input name="pagesize" type="hidden" value="<?=$pagesize?>" />
	   <input name="status" type="hidden" value="<?=$status?>" />
	  </td>
	 </tr>
	</table><br>
	</form>
	<?
}
else{
	?>
	<table width="100%"  border="0" cellpadding="6" cellspacing="2" class="lightBorder">
	 <tr><td><br /><b>No Record Found.............</b><br /><br /></td></tr>
	</table>
	<?
}
?>
<table width="96%" align="center" cellpadding="0" cellspacing="0" border="0">
 <tr><td align="right"><input type="button" onclick="window.location.href='<?=SITE_ADMIN_URL;?>/<?=$script_name;?>?id=add_new#bot'" value="Add New <?=$record_type;?>" class="button"></td></tr>
</table>

<?php
if ($id == "add_new" || $id == "edit_record") {
	?>
	<a name="bot"></a>
	<br/><br/>
	<script type="text/javascript" src="<?=SITE_URL_PATH;?>/js/showHint.js"></script>
	<form name="admin_manage_member_form" method="post" action="" enctype="multipart/form-data" onsubmit="return validate_admin_manage_member_form();">
	<input type="hidden" name="country" value="<?=$_SESSION['MyAdminCountry'];?>" />
	<table width="99%"  border="1" cellpadding="3" cellspacing="2" class="lightBorder">
	 <?php
	 if($recordID=="" || $id!="edit_record") {
		 ?>
		 <tr><td colspan="3" align="left" class="lightBlueBg" height="20"><strong><a name="bot">Add New <?=$record_type;?></a></strong></td></tr>
		 <?php
	 }
	 else {
		 ?>
		 <tr>
		  <td align="left" class="lightBlueBg" height="20"><strong>Edit <?=$record_type;?></strong></td>
		  <td align="right" class="lightBlueBg " height="20"><a href="<?=$script_name;?>"><strong>Add New <?=$record_type;?></strong></a></td>
		 </tr>
		 <?php
	 }
	 $result=getResult($table_name," where memberID='$recordID'");
	 @extract($result);
	 
	 if($officeImage !="") {
		 $filenm1=SITE_DIR_PATH."/uploaded_files/office_images/".$officeImage;
		 if(file_exists($filenm1)) {
			 $dimens=GetImageSize($filenm1);
			 if($dimens[0]>130) {
				 $dimens[0]=$dimens[0]+50;
				 $dimens[1]=$dimens[1]+80;
			 }
			 else{
				 $dimens[0]=200;
				 $dimens[1]=200;
			 }
			 $image_link='&nbsp;<a href="javascript:void(0);" onClick="openwin(\''.SITE_URL_PATH.'/popup.php?img=office_images/'.$officeImage.'\', \''.$dimens[0].'\', \''.$dimens[1].'\')" class="red"><b>View Office Picture</b></a>';
		 }
	 }
	 ?>
	 <tr><td colspan="2" align="right"><font color="red">*</font> fields are mandatory</td></tr>
	 <tr>
	  <td class="lightBlueBg" align="left">&nbsp;</td>
	  <td class="lightBlueBg" align="left"><strong>Login Information</strong></td>
	 </tr> 
	 <tr>
	  <td class="brdrbtm" width="25%"><strong>Email Address <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="email" type="text" class="txtbox"  style="width:425px;" value="<?=$email;?>" id="NOBLANK~Please enter an email address~DM~EMAIL~Please enter a valid email" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Password <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input style="width:425px;" type="password" name="pwd" value="<?=$pwd; ?>" class="txtfieldadmin" id="NOBLANK~Please enter member password~DM~" /></td>
	 </tr>
	 <tr>
	  <td class="lightBlueBg" align="left">&nbsp;</td>
	  <td class="lightBlueBg" align="left"><strong>Personal Information</strong></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Member Name <font color="red">*</font></strong></td>
	  <td class="brdrbtm">
	   <select name="nameTitle" class="textbox" id="nameTitle">
	    <?php
	    for ($i=0;$i<count($GLOBALS['title_array']);$i++) {
		    $sel="";
		    if ($nameTitle==$GLOBALS['title_array'][$i]) {
			    $sel='selected="selected"';
		    }
		    ?>
		    <option value="<?=$GLOBALS['title_array'][$i];?>" <?=$sel;?>><?=$GLOBALS['title_array'][$i];?></option>
		    <?php
	    }
	    ?>
	   </select>
	   <input name="memberName" type="text" class="textbox" style="width:365px;" value="<?=$memberName;?>" id="NOBLANK~Please enter member name~DM~ALPHA~Please enter characters only~DM~" />
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Company Name <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="companyName" type="text" class="textbox" style="width:425px;" value="<?=$companyName;?>" id="NOBLANK~Please enter company name~DM~" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Member Designation </strong></td>
	  <td class="brdrbtm"><input name="jobTitle" type="text" class="textbox" style="width:425px;" value="<?=$jobTitle;?>" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>Registered Office Address <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><textarea name="address" class="txtfieldadmin" style="width:425px;" rows="3" id="NOBLANK~Please enter member Registered Office Address~DM~"><?=$address;?></textarea></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>City <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="city" type="text" class="textbox" style="width:425px;" value="<?=$city;?>" id="NOBLANK~Please enter member city~DM~" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>State </strong></td>
	  <td class="brdrbtm"><input name="state" type="text" class="textbox" style="width:425px;" value="<?=$state;?>" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Zip/Postal Code </strong></td>
	  <td class="brdrbtm"><input name="zipcode" type="text" class="textbox" style="width:425px;" value="<?=$zipcode;?>" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Country <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><strong><?=$_SESSION['MyAdminCountry'];?> [Note: </strong>You can add members belong to <?=$_SESSION['MyAdminCountry'];?>  only.]</td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>Phone No. </strong></td>
	  <td class="brdrbtm">
	   <table cellspacing="0" cellpadding="3" width="400" border="0">
	    <tr>
	     <td width="25%">Country Code</td>
	     <td width="25%">Area Code</td>
	     <td width="50%">Office   Number</td>
	    </tr>
	    <tr>
	     <td align="left"><input name="countryCodePhone" type="text" class="textbox" style="width:70px;" value="<?=$countryCodePhone;?>" /></td>
	     <td align="left"><input name="areaCodePhone" type="text" class="textbox" style="width:70px;" value="<?=$areaCodePhone;?>" /></td>
	     <td align="left"><input name="phone" type="text" class="textbox" style="width:255px;" value="<?=$phone;?>" /></td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>Fax No. </strong></td>
	  <td class="brdrbtm">
	   <table cellspacing="0" cellpadding="3" width="400" border="0">
	    <tr>
	     <td width="25%">Country Code</td>
	     <td width="25%">Area Code</td>
	     <td width="50%">Office   Number</td>
	    </tr>
	    <tr>
	     <td align="left"><input name="countryCodeFax" type="text" class="textbox" style="width:70px;" value="<?=$countryCodeFax;?>" /></td>
	     <td align="left"><input name="areaCodeFax" type="text" class="textbox" style="width:70px;" value="<?=$areaCodeFax;?>" /></td>
	     <td align="left"><input name="fax" type="text" class="textbox" style="width:255px;" value="<?=$fax;?>" /></td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Mobile No. <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="mobileNo" type="text" class="textbox" style="width:425px;" value="<?=$mobileNo;?>" id="NOBLANK~Please enter member mobile no~DM~NUM~Please enter numbers only~DM~" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Alternate Email ID </strong></td>
	  <td class="brdrbtm"><input name="alternateEmail" type="text" class="textbox" style="width:425px;" value="<?=$alternateEmail;?>" /></td>
	 </tr>
	 
	 <tr>
	  <td class="lightBlueBg" align="left">&nbsp;</td>
	  <td class="lightBlueBg" align="left"><strong>Company Business Profile</strong></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>Deals In <font color="red">*</font></strong></td>
	  <td class="brdrbtm" valign="top">
	   <table width="100%" border="0" cellspacing="0" cellpadding="1">
	    <?php
	    $counter=0;
	    foreach ($business_type_array as $key => $value) {
		    if ($counter == 0) {
			    ?>
			    <tr>
			    <?php
		    }
		    $chk="";
		    if ($businessType == $key) {
			    $chk='checked="checked"';
		    }
		    ?>
		    <td width="33%"><input type="radio" name="businessType" id="radio" value="<?=$key;?>" <?=$chk;?> /><?=$value;?></td>
		    <?php
		    $counter++;
		    if ($counter == 3) {
			    ?>
			    </tr>
			    <?php
			    $counter=0;
		    }
	    }
	    ?>
	   </table>
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Name of CEO/Owner <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="ownerName" type="text" class="textbox" style="width:425px;" value="<?=$ownerName;?>" id="NOBLANK~Please enter member mobile no~DM~ALPHA~Please enter characters only~DM~" /></td>
	 </tr> 
	 <tr>
	  <td class="brdrbtm"><strong>Office Picture (only 1) </strong></td>
	  <td class="brdrbtm"><input name="officeImage" type="file" class="txtbox"  style="width:425px;" /><?=$image_link;?><br/>Please upload square image (300x300 or above) for better display.</td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Ownership Type </strong></td>
	  <td class="brdrbtm"><input name="ownershipType" type="text" class="textbox" style="width:425px;" value="<?=$ownershipType;?>" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Year of Establishment <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="yoe" type="text" class="textbox" style="width:425px;" maxlength=4 value="<?=$yoe;?>" id="NOBLANK~Please enter member year of establishment~DM~NUM~Please enter numbers only~DM~" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Certificate (Quality Control) </strong></td>
	  <td class="brdrbtm"><input name="certification" type="text" class="textbox" style="width:425px;" value="<?=$certification;?>" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Main Market <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><input name="mainMarket" type="text" class="textbox" style="width:425px;" value="<?=$mainMarket;?>" id="NOBLANK~Please enter main market~DM~" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>No. of Employees <font color="red">*</font></strong></td>
	  <td class="brdrbtm">
	   <select name="companySize" size="1" style="width:430px;">
	    <?php
	    foreach($GLOBALS['company_size_array'] as $key => $val) {
		    $sel="";
		    if ($companySize==$key) {
			    $sel='selected="selected"';
		    }
		    ?>
		    <option value="<?=$key;?>" <?=$sel;?>><?=$val;?></option>
		    <?php
	    }
	    ?>
	   </select>
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Turnover </strong></td>
	  <td class="brdrbtm">
	   <select name="annualTurnover" size="1" style="width:430px;">
	    <option value="" selected="selected">----- Select Company Turnover -----</option>
	    <?php
	    foreach($GLOBALS[annual_turnover_array] as $key => $val) {
		    $sel="";
		    if ($annualTurnover==$key) {
			    $sel='selected="selected"';
		    }
		    ?>
		    <option value="<?=$key;?>" <?=$sel;?>><?=$val;?></option>
		    <?php
	    }
	    ?>
	   </select>&nbsp;<?=CURRENCY;?>
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Business Country <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><?=country("businessCountry",$businessCountry,"430px");?></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Business Nature <font color="red">*</font></strong></td>
	  <td class="brdrbtm">
	   <?php
	   foreach($GLOBALS['business_nature_array'] as $key => $val) {
		   $sel="";
		   if ($businessNature==$key) {
			   $sel='checked="checked"';
		   }
		   ?>
		   <input type="radio" name="businessNature" value="<?=$key;?>" <?=$sel;?>><?=$val;?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		   <?php
	   }
	   ?>
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Select Category <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><?=getListingCategoriesDropDownAjax("mainCategory",$mainCategory,"430");?></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Select Sub Category <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><span id="showSubCategories">
	   <?php
	   if ($mainCategory != "") {
		   echo getListingSubCategoriesDropDown("industryType", $mainCategory, $industryType, "430");
	   }
	   ?>
	   </span>   
	  </td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>Company Description <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><textarea name="companyDescription" class="txtfieldadmin" style="width:425px;" rows="10" onkeyup="return validate_company_description_chars_left();" onblur="return validate_company_description_chars_left();"><?=$companyDescription;?></textarea><br/><input type="text" name="company_description_chars_total" id="company_description_chars_total" value="<?=strlen($companyDescription);?>" style="width:25px;" /> total characters ... &nbsp;<input type="text" name="about_self_chars_left" id="company_description_chars_left" value="" style="width:25px;" /> characters left ...</td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>About Us <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><textarea name="aboutUs" class="txtfieldadmin" style="width:425px;" rows="10" id="NOBLANK~Please enter company description~DM~"><?=$aboutUs;?></textarea></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm" valign="top"><strong>Contact Us <font color="red">*</font></strong></td>
	  <td class="brdrbtm"><textarea name="contactUs" class="txtfieldadmin" style="width:425px;" rows="10" id="NOBLANK~Please enter company description~DM~"><?=$contactUs;?></textarea></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"><strong>Website Address </strong></td>
	  <td class="brdrbtm"><input name="website" type="text" class="textbox" style="width:425px;" value="<?=$website;?>" /></td>
	 </tr>
	 <tr>
	  <td class="brdrbtm"></td>
	  <td class="brdrbtm">
	   <?php
	   if($recordID!="") {
		   ?>
		   <input type="submit" name="submit" value="Update <?=$record_type;?>" class="button">
		   <input type="hidden" name="recordID" value="<?=$memberID;?>">
		   <input type="hidden" name="action" value="update_record">
		   <?php
	   }
	   else{
		   ?>
		   <input type="submit" name="submit" value="Add New <?=$record_type;?>" class="button">
		   <input type="hidden" name="action" value="add_record">
		   <?php
	   }
	   ?>
	   <input type="hidden" name="start" value="<?=$start;?>">
	   <input type="hidden" name="pagesize" value="<?=$pagesize;?>">
	  </td>
	 </tr>
	</table>
	</form>
	<script type="text/javascript">
	var oFCKeditor = new FCKeditor("aboutUs");
	oFCKeditor.BasePath = "<?=SITE_ADMIN_URL;?>/fckeditor/";
	oFCKeditor.ToolbarSet="Basic";
	oFCKeditor.Height="200";
	oFCKeditor.Width="430";
	oFCKeditor.ReplaceTextarea() ;
	
	var oFCKeditor1 = new FCKeditor("contactUs");
	oFCKeditor1.BasePath = "<?=SITE_ADMIN_URL;?>/fckeditor/";
	oFCKeditor1.ToolbarSet="Basic";
	oFCKeditor1.Height="200";
	oFCKeditor1.Width="430";
	oFCKeditor1.ReplaceTextarea() ;
	</script>
	<?php
}

admin_footer();	
exit;
?>