system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
<?php
?>
<?php
class Model_MSubAdminManagement
{
function showSubAdminSettings()
{
$query = new Bin_Query();
$sql = "SELECT * FROM `admin_table` WHERE `admin_id` > 1";
if($query->executeQuery($sql))
$records = $query->records;
if(count($Err->messages) > 0 )
{
$records = $Err->values;
}
return Display_DSubAdminManagement::showSubAdminSettings($records);
}
function addSubAdminDetails()
{
$query = new Bin_Query();
$admin_password = md5(md5($_POST['sadmin_password']));
$sql = 'INSERT INTO `admin_table` (`admin_username`, `admin_password`, `admin_status`, `admin_email`, `admin_name`, `admin_settings1`, `admin_settings2`, `admin_settings3`, `admin_settings4`) VALUES ("'.$_POST['sadmin_uname'].'","'.$admin_password.'","'.$_POST['sadmin_status'].'","'.$_POST['sadmin_email'].'","'.$_POST['sadmin_name'].'","'.$_POST['sadmin_settings1'].'","'.$_POST['sadmin_settings2'].'","'.$_POST['sadmin_settings3'].'","'.$_POST['sadmin_settings4'].'");';
if($query->updateQuery($sql))
$_SESSION['message'] = 'Sub Admin has been Added Successfully';
else
$_SESSION['error_message'] = 'Unabele to insert the details';
return true;
}
function showEditSubAdmin($Err)
{
$id = (isset($_GET["sadmin_id"]) & ctype_digit($_GET["sadmin_id"])) ? (int)($_GET["sadmin_id"]) : "";
$query = new Bin_Query();
$sql = "SELECT * FROM admin_table WHERE admin_id ='".$id."'";
$query->executeQuery($sql);
if(count($Err->messages) > 0)
{
$records = $Err->values;
}
else
{
$records = $query->records[0];
}
return $records;
}
function updateSubAdmin()
{
$query = new Bin_Query();
$sql = 'UPDATE `admin_table` SET `admin_status` = "'.$_POST['sadmin_status'].'", `admin_name` = "'.$_POST['sadmin_name'].'",`admin_email` = "'.$_POST['sadmin_email'].'" ,`admin_settings1` = "'.$_POST['sadmin_settings1'].'", `admin_settings2` = "'.$_POST['sadmin_settings2'].'",`admin_settings3` = "'.$_POST['sadmin_settings3'].'",`admin_settings4` = "'.$_POST['sadmin_settings4'].'" WHERE `admin_id` = "'.$_POST['sadmin_id'].'"';
if($query->updateQuery($sql))
$_SESSION['message'] = 'Sub-Admin details has been Updated Successfully';
return true;
}
function deleteSubAdmin()
{
$obj= new Bin_Query();
foreach($_POST as $key=>$value)
{
if($key == $value)
$sql= "DELETE FROM `admin_table` WHERE `admin_id` ='".(int)$key."' ";
if($obj->updateQuery($sql))
$_SESSION['message']='Sub-Admin had been deleted Sucessfully';
else
$_SESSION['error_message']='Please select the item to be Deleted';
}
header("location:?do=subadmin");
}
}
?>