<?php
if (isset($_POST['id_active'])){
	if (settype($_POST['id_active'], 'integer')) $id_active = $_POST['id_active'];
} else $id_active = 0;

if ($id_active){
	$sql = "UPDATE ".$module." SET c_active = (CASE WHEN c_active = '1' THEN '0' ELSE '1' END) WHERE id = :id";
	$result = $conn->prepare($sql);
	$result->bindValue(':id', $id_active, PDO::PARAM_INT);
	$result->execute();
	$id_active = 0;
}

if (isset($_POST['multi_activate']) && $_POST['multi_activate']){
	if (isset($_POST['c_check'])){
		foreach ($_POST['c_check'] AS $check_id => $value){
			$sql = "UPDATE ".$module." SET c_active = '1' WHERE id = :id";
			$result = $conn->prepare($sql);
			$result->bindValue(':id', $check_id, PDO::PARAM_INT);
			$result->execute();
		}
	}
}

if (isset($_POST['multi_deactivate']) && $_POST['multi_deactivate']){
	if (isset($_POST['c_check'])){
		foreach ($_POST['c_check'] AS $check_id => $value){
			$sql = "UPDATE ".$module." SET c_active = '0' WHERE id = :id";
			$result = $conn->prepare($sql);
			$result->bindValue(':id', $check_id, PDO::PARAM_INT);
			$result->execute();
		}
	}
}


print "
<input type='hidden' name='id_active' value='".$id_active."' />
<input type='hidden' name='multi_activate' value='0' />
<input type='hidden' name='multi_deactivate' value='0' />";
