<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once ("../classes/users.class.php");

$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$id			= isset($_REQUEST['id'])	?	trim($_REQUEST['id'])	:	"0";
$pid		= isset($_REQUEST['pid'])	?	trim($_REQUEST['pid'])	:	"0";
$message	= "";
$objC		= new check();
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	if ($id <= 0) {
		header("Location:manage_user.php?id=$id&page=$page");
		exit;
	}
	$objU		= new users($objDB);
	$objU->set_partner_preference($_POST);
	if (isset($_POST['SaveNow'])) {
		$message	= $objU->save_user_partner_preference($id, $pid);
		if ($message == "" AND $pid <= 0)
			$pid	= $objU->nPartner_Pref_Id;
		if ($message == "")
			$message	.= "<font color='green'>Your partner preference has been successfully saved.</font><br>";
	} elseif (isset($_POST['BackNow'])) {
		if ($message == "") {
			header("Location: users.php?page=$page");
			exit;
		}
	} else {
		$array	= $objU->get_user_partner_preference($id);
		$objU->set_partner_preference($array);
		$pid	= $objU->nPartner_Pref_Id;
	}
}

include_once('title.inc.php');
?>
<script language="javascript" type="text/javascript">
function check_option_dosent_matter(obj)
{
	var check_flag = 0;
	var i = 0;
	for(i=0;i<document.frmUser.elements[obj.name].length;i++){
		if(check_flag == 1){
			document.frmUser.elements[obj.name][i].checked =false;
		}
		if (document.frmUser.elements[obj.name][i].value=="null" || document.frmUser.elements[obj.name][i].value=="")
		{
			if (document.frmUser.elements[obj.name][i].checked==true)
				check_flag = 1;
		}
	}
}


function check_option(obj){
	for(i=0;i<document.frmUser.elements[obj.name].length;i++){
		if (document.frmUser.elements[obj.name][i].value=="null" || document.frmUser.elements[obj.name][i].value==""){
			if (document.frmUser.elements[obj.name][i].checked==true)
				document.frmUser.elements[obj.name][i].checked =false;
			}
	}
}

function validate()
{
	var frm	= document.frmUser;
	
	return true;

}
</script>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="white"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="72%" valign="top"><?php include_once('tophtml.php');?>
			<table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td width="41%" class="headings1">Manage Partner Profile</td>
                <td width="59%" class="headings1">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2" class="maintext"><?php include_once('usertabs.php');?></td>
                </tr>
            </table></td>
          </tr>
        </table>
		<form name="frmUser" method="post" action="" onSubmit="return validate();">
          <table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
				<?php if ($objDB) 
					  { 
				?>
					<?php 	if(isset($message) && $message!='')
							{
					?>
                <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2 warning"><?php echo $message;?></td>
                  </tr>
					<?php  	}//end if?>
  				<tr align="left">
                  <td width="3%" class="maintext2">&nbsp;</td>
                  <td width="27%" valign="top" class="maintext2">Age</td>
                  <td width="70%" valign="top" class="maintext2">From 
                    <select name="nAge_Low" class="textbox2">
                                        <?php foreach ($arrPartnerAgeFrom as $key => $value) { ?>
                                        <option value="<?php echo $value?>" <?php echo $objU->nAge_Low == $value ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                          </select> To 
                                      <select name="nAge_High" class="textbox2">
                                        <?php foreach ($arrPartnerAgeTo as $key => $value) { ?>
                                        <option value="<?php echo $value?>" <?php echo $objU->nAge_High == $value ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
  				</tr>
                 <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Body Type</td>
                  <td valign="top" class="maintext2"><select name="vBody_Type" class="textbox">
                                        <?php foreach ($arrPartnerBodyType as $key => $value) { ?>
										<option value="<?php echo $key?>" <?php echo $objU->vBody_Type == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                 </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Height</td>
                  <td valign="top" class="maintext2"><strong>From</strong>
                                    <select name="vFeet_Low" class="textbox2">
                                        <?php foreach ($arrFeet as $key => $value) { ?>
                                        <option value="<?php echo $value?>" <?php echo $objU->vFeet_Low == $value ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                          </select> Ft <select name="vInch_Low" class="textbox2">
                                        <?php foreach ($arrInch as $key => $value) { ?>
                                        <option value="<?php echo $value?>" <?php echo $objU->vInch_Low == $value ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                                      </select> in. 
                                      <strong>To</strong>  <select name="vFeet_High" class="textbox2">
                                        <?php foreach ($arrFeet as $key => $value) { ?>
                                        <option value="<?php echo $value?>" <?php echo $objU->vFeet_High == $value ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                                      </select> 
                                      Ft <select name="vInch_High" class="textbox2">
                                        <?php foreach ($arrInch as $key => $value) { ?>
                                        <option value="<?php echo $value?>" <?php echo $objU->vInch_High == $value ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select> in.</td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Smoking</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vSmoking">
                                        <?php foreach ($arrPartnerSmoking as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vSmoking == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Drinking</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vDrinking">
                                        <?php foreach ($arrPartnerDrinking as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vDrinking == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td width="27%" valign="top" class="maintext2">Eye Color</td>
                  <td width="70%" valign="top" class="maintext2"><select class="textbox"name="vEye_Color">
                                        <?php foreach ($arrPartnerEyeColor as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vEye_Color == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Hair Color</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vHair_Color">
                                        <?php foreach ($arrPartnerHairColor as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vHair_Color == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Ethnicity</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vEthinicity">
                                        <?php foreach ($arrPartnerEthnicity as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vEthinicity == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Religion</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vRelegion">
                                        <?php foreach ($arrPartnerReligion as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vRelegion == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Highest Education</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vEducation">
                                        <?php foreach ($arrPartnerEducation as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vEducation == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Languages</td>
                  <td valign="top" class="maintext2"><?php echo $objC->generate_checkbox_list_js("vLanguages[]", $objU->vLanguages, $arrPartnerLanguages, 4, 'key');?></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Profession</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vProfession">
                                        <?php foreach ($arrPartnerProfession as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vProfession == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Annual Income</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vIncome">
                                        <?php foreach ($arrPartnerIncome as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vIncome == $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Relation Status</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vRelationship">
									  <?php foreach ($arrPartnerRelationShip as $key => $value) { ?>?
									    <option value="<?php echo $key?>" <?php echo $objU->vRelationship == $key ? "selected" : ""?>><?php echo $value?></option>
										<?php } ?>
					    </select></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Children</td>
                  <td valign="top" class="maintext2"><select class="textbox"name="vChildren">
                                        <?php foreach ($arrPartnerChildren as $key => $value) { ?>
                                        <option value="<?php echo $key?>" <?php echo $objU->vChildren === $key ? "selected" : ""?>>
                                        <?php echo $value?>
                                        </option>
                                        <?php } ?>
                        </select></td>
                </tr>
				<?php 			
						}//end first if
				?>
              </table>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                      <?php if ($objDB) 
					  { 
					?>
                      <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                      <tr>
                        <td align="center"><table width="10%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td><input name="SaveNow" type="submit" class="loginbutton" value="Save"><input type="hidden" name="page" value="<?php echo $page?>">
                                      <input type="hidden" name="id" value="<?php echo $id?>">
									  <input type="hidden" name="pid" value="<?php echo $pid?>"></td>
							  <?php if ($id > 0) { ?>
                              <td><input name="BackNow" type="submit" class="signupbutton" value="Back"></td>
							  <?php }//end if?>
                              </tr>
                        </table></td>
                      </tr>
                    </table>
					<?php 		
						}//end first if
				?></td>
                  </tr>
                </table></td>
            </tr>
          </table></form></td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>