File: /home/barbeatleanalyti/public_html/api.beatleanalytics.com/corporate/get_notification.php
<?php
/*
* Following code will get single department details
* A industry is identified by dept_id
*/
// array for JSON response
$response = array();
// include db connect class
require_once 'db_connect.php';
// connecting to db
$db = new DB_CONNECT();
if(isset($_GET["orgid"],$_GET["branchid"],$_GET["indid"])){
$orgid = $_GET["orgid"];
$branchid = $_GET["branchid"];
$indid = $_GET["indid"];
if($branchid == "0" and $indid == "0"){
//owner
$result = mysql_query("SELECT * FROM app_notification WHERE IsActive LIKE 'Y' and orgid = '$orgid' ")or die(mysql_error());
}elseif($branchid != "0" and $indid == "0"){
//branch
$result = mysql_query("SELECT * FROM app_notification WHERE IsActive LIKE 'Y' and orgid = '$orgid' and branchid = '$branchid' ")or die(mysql_error());
}elseif($branchid != "0" and $indid != "0"){
//industry
$result = mysql_query("SELECT * FROM app_notification WHERE IsActive LIKE 'Y' and orgid = '$orgid' and branchid = '$branchid' and indid = '$indid'")or die(mysql_error());
}
// $result = mysql_query("SELECT * FROM app_notification WHERE IsActive LIKE 'Y' ")or die(mysql_error());
if (!empty($result)) {
if (mysql_num_rows($result) > 0) {
$response["notificationDetail"] = array();
while ($row = mysql_fetch_array($result)) {
$notificationDetail = array();
$notificationDetail["nid"] = $row["nid"];
$notificationDetail["title"] = $row["title"];
$notificationDetail["description"] = $row["description"];
$notificationDetail["orgid"] = $row["orgid"];
$notificationDetail["branchid"] = $row["branchid"];
$notificationDetail["indid"] = $row["indid"];
$notificationDetail["type"] = $row["type"];
$notificationDetail["created_date"] = $row["created_date"];
// push single product into final response array
array_push($response["notificationDetail"], $notificationDetail);
}
// success
$response["success"] = 1;
$response["ncount"] = mysql_num_rows($result);
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No offers found";
// echo no users JSON
echo json_encode($response);
}
} else {
$response["success"] = 0;
$response["message"] = "No Notification found.";
// echo no users JSON
echo json_encode($response);
}
}elseif(isset($_GET["orgid"])){
$orgid = $_GET["orgid"];
$result = mysql_query("UPDATE app_notification set IsActive = 'N' WHERE orgid = '$orgid' and IsActive = 'Y' ")or die(mysql_error());
if (!empty($result)) {
// success
$response["success"] = 1;
$response["message"] = "Notification has been edited successfully.";
// echoing JSON response
echo json_encode($response);
} else {
// no industry found
$response["success"] = 0;
$response["message"] = "No Notification updated.";
// echo no users JSON
echo json_encode($response);
}
}else{
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
echo json_encode($response);
}
?>