<?php
include "chkuser.php";
include "includefilemng.php";
	
	$edit=false;
	$edit_id=0;
	$proceed_flag=0;
	$id=0;
	$subject=''; 
	$description='';
	$url="http://www.ourdemourl.com/perfectlyclean/franchise_account.php";
	$update_id="id";
	$insert_primary_table="franchise";
	$pPosition='';
	$mendatry_check_array=array('subject'); 
	$unset_array=array('send');
	$validate_check_array=array();								
	if(isset($_GET['fid'])){
	  $edit_id=$_GET['fid'];
	  $edit=true;	  
	  }
  
   if($edit){  
		$pdelre =array(); 
		$pdelr = "select * from ".$insert_primary_table." where  ".$update_id." ='$edit_id'";			
		$pdelq = mysql_query($pdelr);
		$pdelre = mysql_fetch_object($pdelq);		
		
		$fname=$pdelre->fname;
		$lname=$pdelre->lname;
		$email=$pdelre->email;
		$username=$pdelre->uname;
		$password=$pdelre->pass;
		
		$description.="Dear ".$fname."&nbsp;".$lname."<br/>";
		$description.="Welcome to www.perfectlymaid.com.au<br/>";
		$description.="Here is the franchise details :<br/><br/>";
		$description.="Username : ".$username."<br/>";
		$description.="Password : ".$password."<br/><br/>";
		$description.="<a href=\"$url\">http://www.ourdemourl.com/perfectlyclean/franchise_account.php</a><br/>";
		$description.="";
     }


if(count($_POST)){
$temp_data=$post_data=$_POST;
$edit_id=0;
$proceed_flag=0;
$errormsg='';
list($proceed_flag,$errormsg)=validate_form_field($mendatry_check_array,$validate_check_array,$post_data,$edit_id);
	 
	if($proceed_flag < 1)
	{				
	//---------------------------------------------
				$msubject=$_POST['subject'];
				$mdescription=html_entity_decode(stripslashes($_POST['description']));
			 $mail_to=$email;
				
				$headers="";				
				$sql = "select sendemailid,siteurl,site_name from admin";
				$result = mysql_query($sql);
				$data_admin = mysql_fetch_object($result);
				$sendemailid=$data_admin->sendemailid;
				$siteurl=$data_admin->siteurl;
				$sitename=$data_admin->site_name;
							
				
				$mail_subject=$msubject;				
				$mail_body = "<table style=font:Verdana; font-size:11px; color:#000000><tr><td>";
				$mail_body .= $mdescription;
				$mail_body .= "</td></tr></table>";
				$headers =  "Content-Type: text/html;charset=iso-8859-1\n";
				$headers = $headers . "From:".$sendemailid."";
				mail($mail_to,$mail_subject,$mail_body,$headers);				
				//--------------------------------------------
	            $description="";
				
				?>
                <META HTTP-EQUIV=REFRESH CONTENT="1;URL=franchise_settings.php">
                <?php
	}
	else
	{
	$haderr="yes";
	$errormsg = $errormsg;
	extract($temp_data);
	}


}

?>
<html>
<head>
<title>control panel </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="ssi.css" rel="stylesheet" type="text/css">
<script language="javascript" src="includenp/functions.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript" src="tinymca.js"></script>	

<style type="text/css">
<!--
.style2 {color: #000000}
-->
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td width="1%"   bgcolor="#C9C9C9"></td>
	<td width="98%"><?php include_once "top.php";?></td>
	<td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
   <td width="1%"   bgcolor="#C9C9C9"></td>
    <td width="98%"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="centertable">
      <tr>
        <td><table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="40" class="bigblackTxt">&nbsp;<a href="view_franchise.php" class="normalLink">Manage</a>  :: <a href="franchise_settings.php" class="normalLink">Settings</a></td>
          </tr>
          <tr>
            <td><?php 
		  if(isset($errormsg))
		  	{echo display_error_msg($errormsg);
		   	}
			?>            </td>
          </tr>
          <tr>
            <td>
            
              <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="4">
                <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>?fid=<?php echo $edit_id;?>" name="SaveForm" ID="SaveForm">                 
                  <tr>
                    <td colspan="2" class="bigblackTxt">&nbsp;</td>
                  </tr>
				  <tr>
                    <td height="24" colspan="2" class="errFont"> * marked fields are mandatory </td>
                  </tr>
				  <tr>
                    <td colspan="2" class="normalBoldblackTxt">&nbsp;</td>
                  </tr>
                   <tr>
                    <td class="bluebold"><span class="errFont">*</span>Subject</td>
                    <td>
                      <input name="subject" type="text" class="inputBOX" id="subject" value="<?php echo $subject;?>" size="35">                    </td>
                  </tr>
				  <tr>
                    <td width="26%" class="bluebold">Description</span>: </td>
                    <td width="74%">
<textarea name="description" cols="90" rows="20" class="inputBOX" id="description"><?php echo stripslashes($description);?></textarea></td>
                  </tr>
				  
				 
				 
				
				  <tr>
                  <td class="bluebold">&nbsp;</td>
				    <td class="bluebold">&nbsp;</td>
				    </tr>
				  <tr>
                    <td width="26%" class="bluebold">&nbsp;</td>
                    <td width="74%">                    
                      <input name="send" type="submit" class="hbutton" id="send" value="Send Mail"></td>
                  </tr>
				  <tr>
                    <td align="right">&nbsp;</td>
                    <td>&nbsp;                      
                    
                      </td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                </form>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
    <td   bgcolor="#C9C9C9" width="1%"></td>
	<td><?php include_once "footer.php";?></td>
	<td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
</table>
</body>
</html>
