<?php
$pgMod="complaindetail";
$pgAct="view";

//echo "<pre>";print_r($_SESSION);echo "</pre>";

if(isset($_POST['submit']))
{

//echo"<pre>";print_r($_POST);echo"</pre>";exit;

 if($_POST["reply"]==""){
	echo "reply box is empty";	
 }elseif($_POST["reply"]==""){
	echo "reply box is empty";	
 }else{

$aryData=array(
				"reply"=>$_POST['reply'],
				"school_id"=>$_SESSION['admin']['school_id'],
				"reply_by"=>$_SESSION['admin']['uid'],
				"reply_date"=>date("Y-m-d H:i:s"),
				"is_read"=>1
			  );
			//print_r($aryData);die();
	$updateAry=$db->updateAry("complain",$aryData," where id=".$_REQUEST['complain_id']." ");		
	if($updateAry!==""){
//echo"updated";exit;

				$_SESSION['msg']="Reply added succefully";
				unset($_SESSION['form']);
				redirect(URL_ADMIN_HOME.getQueryString(array("page_id"=>'complain')));


	}else{
		echo $db->getErMsg();	
	}					 
 }
}

if(isset($_GET['action']) && trim($_GET['action'])!='')
	$pgAct=strtolower($_GET['action']);

if($pgAct=="delete" && isset($_GET['id']) && trim($_GET['id'])!='')
{
	$res=$db->delete("complain","where  id='".$_GET['id']."'");
	if(!is_null($res)) { $_SESSION['msg']='Deleted Successfully'; }
	else { array_push($alert_err,$db->getErMsg()); }
	redirect(URL_ADMIN_HOME.getQueryString(array("page_id"=>$pgMod)));
} 
if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
	?>
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>complain</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>complain</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}
else{

?>
<style>
.side2{
padding-left: 25px !important;
color:#666;
}
</style>

	<div class="row-fluid"><div class="span12"><div class="top-bar">
    <h3><i class="icon-eye-open"></i> <?php echo ucwords($pgAct." ".$pgMod); ?></h3>
    </div>
    <div class="well no-padding">
	<?php
	$aryPgAct=array("page_id"=>$pgMod,"action"=>"add");

	$aryList=$db->getRow("SELECT * FROM teacher_complain where  id =".$_GET['id'] ); $i=0;

//echo "<pre>";print_r($aryList);exit;

	if(is_array($aryList) && count($aryList)>0)
	{
		?>
        <table class="table" id="example">
            
          <form method="post">  
            
            <tbody>
            <?php $aryList;
			 $i++; 
	$stu_detail=$objindex->profile($aryList['student_id']);
			
            ?>
                <tr>
                    
                    <td> Complain by </td>
                    
                    <td class="side2"> <?php echo   $stu_detail['name']."(".$stu_detail['admissionno'].")";	?>
</td>
                    
                </tr>
                <tr>
                    
                    <td> Detail  </td>
                    
                    <td class="side2"><?php echo  $aryList['detail'];	?>
</td>
                    
                </tr>
                
                <tr>
                    
                    <td> Reply </td>
                    
                    <td class="side2"><textarea name='reply' rows='8'  style="resize:none;width:85%" ><?php echo $aryList['detail'] ?></textarea>
</td>
                    
                </tr>
                
<!--btn-->                
                <tr>
                
                    
                    <td colspan="2" >
                    
					<?php $aryPgAct['action']="edit"; ?>
<input type="hidden" name="complain_id" value="<?php echo $aryList['id'];?>"  >

                         <a style="float:left" href="<?php echo URL_ADMIN_HOME.getQueryString($aryPgAct); ?>"><button type="submit" name="submit" class="btn btn-info">Submit</button></a>
                    <?php $aryPgAct['action']="delete"; ?>
                         <a href="javascript:;" onclick="del('<?php echo URL_ADMIN_HOME.getQueryString($aryPgAct); ?>')" class="confirmation"><button type="button" class="btn btn-danger">Delete</button></a>  

                    </td>
					
                    
                
                </tr>
            <?php  ?>
            </tbody>
           
          </form>  
            
            <tfoot>
                <tr>
                    <th></th>
                    <th colspan="2"></th>
                </tr>
            </tfoot> 
            
        </table>
		<?php
	}
	else{
		?>
        <div class="alert alert-info">
          <a class="close" data-dismiss="alert">×</a>
          <i class="icon icon-warning-sign"></i> <b>complain</b> Record not found </i>
        </div>
        <?php
	} 
	?>
	</div></div></div>
	<?php
}
?>
<!-- / Forms -->