<?php
/* 
----------------------------------------------------------
  MODULE :  AJAX BOOL ACTIVATION 
  V1.0 / 2018
  AUTHOR : SGHAIER MAHMOUD  
----------------------------------------------------------
*/
require_once(__DIR__.'/../ssinclude/app-init.php');
require_once(__DIR__.'/../ssinclude/app-session.php');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$id = verif_get('id');
$tbl = verif_get('tbl');
$tblid= verif_get('tblkey');
$fld = verif_get('fld');
// decrypt id
if ( !empty($id) && !empty($tbl) && !empty($fld) && !empty($tblid))
{  
	$id = decrypt_data($id);
	if ( is_numeric($id) ) { 
    // db update 
	try
     {
		$sql="UPDATE $tbl SET $fld=not $fld Where $tblid=$id;";
	    $affectedrows  = $db->exec($sql);
			if ( isset($affectedrows) )
				{
					//echo "Record has been successfully updated";
					echo ("1"); // true
				}           
			}
	catch (PDOException $e)
	  {
		//echo "There is some problem in connection: " . $e->getMessage();
		echo ("0"); // false error 
	  }
   }   
}
require_once(__DIR__.'/../ssinclude/app-close.php');
?>