<?php
include("db.php");
include("checklogin.php");
//die('hello');
$id="";

if(isset($_SESSION["user"]["uid"]))$id=$_SESSION["user"]["uid"];
else{
  redirect(URL_ROOT."index.php");
}

$profiledetail=$objindex->profile($_SESSION['user']['uid']);

    
if(isset($_POST['submit']))
{
 if($_POST['topic']=="")
 {
	array_push($alert_err,"Please enter Topic "); }elseif($_POST['detail']==""){
	array_push($alert_err,"Please enter Details"); }
 else{
	 $aryData=array(
		 "topic"=>$_POST['topic'],
		 "detail"=>$_POST['detail'],
		 "student_id"=>$profiledetail['idno'],
		 "school_id"=>$profiledetail['school_id']
	 );

  $insert_complain=$db->insertAry("complain",$aryData);
  
  if($insert_complain>0){
	   $smarty->assign("complain_insertion",1);
	  }else{
	  echo $db->getErMsg();exit;
	  }
 } 
}


$smarty->assign("profile",$profiledetail);

$smarty->assign("error",$alert_err);

//echo "<pre>";print_r($_SESSION);print_r($objindex->profile($_SESSION['user']['uid']));echo "</pre>";

$profile=$objindex->profile($_SESSION['user']['uid']);

$smarty->assign("mycomplains",$objindex->complain($_SESSION['user']['uid']));

//echo "<pre>";print_r($objindex->complain($_SESSION['user']['uid']));exit;

$smarty->display('complain.html');