<?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");

$flag		= false;
$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$id			= isset($_REQUEST['id'])	?	trim($_REQUEST['id'])	:	"0";
$aid		= isset($_REQUEST['aid'])	?	trim($_REQUEST['aid'])	:	"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);
	$flag		= $objU->mobile_alert_activated();
	$flag		= true;
	$objU->set_user_alert($_POST);
	if (isset($_POST['SaveNow'])) {
		$message	= $objU->save_user_alerts($id, $aid);
		if ($aid <= 0 AND $message == "")
			$aid	= $objU->nAlert_Id;
		if ($message == "")
			$message	.= "<font color='green'>Your alerts have been saved.<br></font>";
	} elseif (isset($_POST['BackNow'])) {
		if ($message == "") {
			header("Location: users.php?page=$page");
			exit;
		}
	} else {
		$array	= $objU->get_user_alerts($id);
		$objU->set_user_alert($array);
		$aid	= $objU->nAlert_Id;
	}
}

include_once('title.inc.php');
?>
<script language="javascript" type="text/javascript">
function validate()
{
	var frm	= document.frmUser;
	return true;
}
</script>
<?php include_once('tophtml.php');?>
<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">
			<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" colspan="2">Manage Alert Settings</td>
              </tr>
			  </table>
			  <div class="bordernew padding2">
			  <table width="100%">
              <tr>
                <td colspan="2" class="maintext"><?php include_once('usertabs.php');?></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%" class="maintext2">New Registration</td>
                  <td width="70%" class="maintext2"><input type="checkbox" name="nNewUser" value="Y" <?php echo $objU->nNewUser == "Y" ? "checked" : ""?>></td>
  				</tr>
                 <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td class="maintext2">Profile Viewed</td>
                  <td class="maintext2"><input type="checkbox" name="nProfileViewed" value="Y" <?php echo $objU->nProfileViewed == "Y" ? "checked" : ""?>></td>
                 </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td class="maintext2">Added As Hot</td>
                  <td class="maintext2"><input type="checkbox" name="nAddHot" value="Y" <?php echo $objU->nAddHot == "Y" ? "checked" : ""?>></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td class="maintext2">New Message (Mobile)</td>
                  <td class="maintext2"><input type="checkbox" name="nNewMessageMobile" value="Y" <?php echo $objU->nNewMessageMobile == "Y" ? "checked" : ""?>></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td width="27%" class="maintext2">New Interest (Mobile)</td>
                  <td width="70%" class="maintext2"><input type="checkbox" name="nNewInterestMobile" value="Y" <?php echo $objU->nNewInterestMobile == "Y" ? "checked" : ""?>></td>
                </tr>
                <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2"><strong>Note:</strong> <em>Users will not receive mobile alerts, if the user doesn't enter a valid mobile number (with country code i.e. 18885554657) and the correct corresponding mobile service provider in his/her profile.</em></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 type="submit" style="margin-right:20px;"  class="loginbutton" name="SaveNow" value="Save"><input type="hidden" name="page" value="<?php echo $page?>">
                                      <input type="hidden" name="id" value="<?php echo $id?>">
									   <input type="hidden" name="aid" value="<?php echo $aid?>"></td>
							<?php if ($id > 0) { ?>
                              <td><input name="BackNow" type="submit" class="back-btn" value="Back"></td>
							  <?php } ?>
                              </tr>
                        </table></td>
                      </tr>
                    </table>
					<?php 		
						}//end first if
				?></td>
                  </tr>
                </table></td>
            </tr>
          </table></form>
			</div>
			</td>
          </tr>
        </table>
		</td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>