<? require_once("../includes/main.inc.php");
/**for  delete  groups **/

if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete'){
	 $page_id=$_GET['page_id'];
	 $sql8 = "delete from `tbl_faq` where id in ($page_id)";	 
	 db_query($sql8);
	 set_session_msg("Selected records have been deleted successfully");
	header("Location: ".$_SERVER['HTTP_REFERER']);
	exit;
}

$start = isset($start) ? intval($start): '0';
$pagesize = isset($pagesize) ? intval($pagesize): 100;

$columns = "select * ";
$sql = " from `tbl_faq` ";
$sql .= " where 1 ";
//$order_by == '' ? $order_by = '`tbl_faq`.id' : true;
//$order_by2 == '' ? $order_by2 = 'ASC' : true;
$sql_count = "select count(*) ".$sql; 
$sql .= "order by id ASC ";
$sql .= "limit $start, $pagesize ";
$sql = $columns.$sql;
$result = db_query($sql);
$reccnt = db_scalar($sql_count);


?><link href="styles.css" rel="stylesheet" type="text/css">

<? include("top.inc.php");?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>
    <td id="pageHead"><div id="txtPageHead">
    Manage Services ( FAQ's )</div></td>
  </tr>

</table>

		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td id="content">
        <div align="center"><span class="msg"><?=display_sess_msg();?></span></div><br />
        <a href="faq.php?page_id=&start=0" class="redcolor">Add New FAQ's</a>

      <? if(mysqli_num_rows($result)==0){?>
      <div class="msg">Sorry, No Records Found.</div>

      <? } else{ ?>

      <div align="right"> Showing Records: <?= $start+1?> to   <?=($reccnt<$start+$pagesize)?($reccnt-$start):($start+$pagesize)?>    of   <?=$reccnt?> </div>

      <form method="post" name="form1" id="form1" onSubmit="confirm_submit(this)">
        <table width="100%"  border="0" cellpadding="0" cellspacing="1" class="tableList">

          <tr>
          <th  align="center" width="4%">SL</th>
		  <th  align="left" width="12%" style="padding-left:10px;">Parent</th>
		  <th  align="left" width="15%" style="padding-left:10px;">Service Name</th>
		  <th  align="left" width="15%" style="padding-left:10px;">Questions</th>
		  <th  align="left" width="15%" style="padding-left:10px;">Answers</th>
          <th  align="center" width="8%">Status</th>
          <th align="center" width="4%">Edit</th>
          <th align="center" width="4%">Delete</th>
          </tr>

      <? 
if($start==0){
	$cnt=0;
}
else{
	$cnt=$start;
}
while ($line_raw = mysqli_fetch_array($result)) {
	$cnt++;
$line = ms_display_value($line_raw);
@extract($line);
//$css = ($css=='trOdd')?'trEven':'trOdd';
$css=isset($css) ? ($css=='trOdd')?'trEven':'trOdd':'trOdd';
?>
<tr class="<?=$css?>">
<?php 
$sqlParent = "select country_name from tbl_country where country_id = '$parent' and parent_childs='0'";
$resultParent = db_query($sqlParent);
$c=mysqli_fetch_assoc($resultParent);
$parentname=$c['country_name'];

?>
<?php 
$sqlParent1 = "select country_name from tbl_country where country_id = '$child' and parent_childs!='0'";
$resultParent1 = db_query($sqlParent1);
$c1=mysqli_fetch_assoc($resultParent1);
$child_name=$c1['country_name'] ?? '';

?>
<td  valign="top" align="center"><?=stripslashes($id)?></td>
<td align="left" valign="middle" style="padding-left:10px;"><?=stripslashes($parentname)?></td>
<td align="left" valign="middle" style="padding-left:10px;"><?=stripslashes($child_name)?></td>
<td align="left" valign="middle" style="padding-left:10px;"><?=stripslashes($question1)?></td>

<!--<td align="center" valign="middle"><?php// if($country_status=='1'){ echo 'Active'; }else{ echo '<span style="color:red;">InActive</span>'; } ?></td>-->
<td align="center" valign="top"><a href="faq.php?page_id=<?=$id?>&start=<?=$start?>"><img src="images/icons/edit.png" alt="Edit" width="16" height="16" border="0" /></a></td>
<td align="center" valign="top"><a href="faq_list.php?page_id=<?=$id?>&start=<?=$start?>&action=delete" onclick="return stdel_confirm();"><img src="images/icons/trash-20.png" alt="Edit" width="16" height="16" border="0" /></a></td>

</tr>

<? }?> </table>

 </form>

<? }?>

 <? include("paging.inc.php");?>    </td>
  </tr>
</table>

<script>
function stdel_confirm(){  return confirm("Are you sure want to delete?"); }
</script>

<? include("bottom.inc.php");?>