<?php if(!isset($_SESSION)) { session_start(); }
date_default_timezone_set('Asia/Kolkata');
	//error_reporting( E_ALL );
	//ini_set('display_errors', 1);
	include("include/config.php");
	include("classes/Database.class.php");
	//require 'PHPMailer-5.2.14/class.phpmailer.php';
	function __autoload($className)
	{
		//require_once("classes/{$className}.php");
		if (file_exists('classes/{$className}.php')) 
		{
			include("classes/{$className}.php");
			return true;
		}
		 return false;
	}
    //==================make db connection for all files. Dont Delete
    $db = new Database();
	$db->connect();
	//=======================
	/*$mail = new PHPMailer;
	$mail->SMTPDebug=1;   
	$mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
	$mail->SMTPAuth = true;                               // Enable SMTP authentication
	$mail->Username = 'kiran.vyavahare@waakan.com';                   // SMTP username
	$mail->Password = '';                            // SMTP password
	$mail->SMTPSecure = 'ssl';                            // Enable encryption, 'tls' also accepted
	$mail->Port = 465;
	
	$mail->setFrom('kiran.vyavahare@waakan.com','isasbeautyschool');     //Set who the message is to be sent from
	$mail->addReplyTo('kiran.vyavahare@waakan.com', 'isas');*/
?>
<?php


$show_records=array(0=>'10',1=>'20','50','100','500','1000');
function addNotifications($args)
{
    $sql_loggein= "SELECT cm_id,type,admin_id,name FROM site_setting where admin_id='".$_SESSION['admin_id']."' ";
	$db112=mysql_query($sql_loggein);
    $row_loggedin=mysql_fetch_array($db112);
	$action=trim($args['on_action']);
    if(trim($args['on_action']) == "enquiry_added")
    {
		$inquiry_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
        //----get logged in user type and based on that send the notification ----
        //print_r($row_loggedin);
        if($row_loggedin['type'] == 'A')
        {
            //--first message to the Councellor---
            '<br/>'.$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='C' and cm_id='".$row_loggedin['admin_id']."'";
            $row_Councellor =$db1->fetch_array($db1->query($sql_councellor));
			//echo $row_Councellor['admin_id'];
            if($row_Councellor['admin_id'])
            {
                $data_record['notification'] = 'New inquiry added by '.$row_loggedin['name'];
                $data_record['redirect_page_url'] = 'manage_student.php?record_id='.$args['reference_id'];
                $data_record['added_by'] = $_SESSION['admin_id'];
                $data_record['added_for'] = $row_Councellor['admin_id'];
                $data_record['on_action'] = $args['on_action'];
                $data_record['is_read'] = 'No';
                $data_record['added_date'] = date("Y-m-d H:i:s");
                $ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
				$ptr_inst=mysql_query($ins_notifi);
            }
            //--second message to the admin---
            if($row_loggedin['cm_id'])
            {
                $data_record['notification'] = 'New inquiry added by '.$row_loggedin['name'];
                $data_record['redirect_page_url'] = 'manage_student.php?record_id='.$args['reference_id'];
                $data_record['added_by'] = $_SESSION['admin_id'];
                $data_record['added_for'] = $row_loggedin['cm_id'];
                $data_record['on_action'] = $args['on_action'];
                $data_record['is_read'] = 'No';
                $data_record['added_date'] = date("Y-m-d H:i:s");
                $ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
				$ptr_inst=mysql_query($ins_notifi);
            }
            //--to own---
          
        }
        else if($row_loggedin['type'] == 'C')
        {
            //--first message to the cm---
            if($row_loggedin['cm_id'])
            {
                $data_record['notification'] = 'New inquiry added by '.$row_loggedin['name'];
                $data_record['redirect_page_url'] = 'manage_student.php?record_id='.$args['reference_id'];
                $data_record['added_by'] = $_SESSION['admin_id'];
                $data_record['added_for'] = $row_loggedin['cm_id'];
                $data_record['on_action'] = $args['on_action'];
                $data_record['is_read'] = 'No';
                $data_record['added_date'] = date("Y-m-d H:i:s");
				
                $ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
				$ptr_inst=mysql_query($ins_notifi);
            }
            //--second message to the admin---
            $sql_cm = "SELECT admin_id,cm_id FROM site_setting where type='C' and cm_id='".$row_loggedin['cm_id']."'";
			$db1=mysql_query($sql_cm);
			while($row_cm =mysql_fetch_array($db1))
			{
                $data_record['notification'] = 'New inquiry added by '.$row_loggedin['name'];
                $data_record['redirect_page_url'] = 'manage_student.php?record_id='.$args['reference_id'];
                $data_record['added_by'] = $_SESSION['admin_id'];
                $data_record['added_for'] = $row_cm['admin_id'];
                $data_record['on_action'] = $args['on_action'];
                $data_record['is_read'] = 'No';
                $data_record['added_date'] = date("Y-m-d H:i:s");
				
				$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
				$ptr_inst=mysql_query($ins_notifi);
            }
            
        }
		else if($row_loggedin['type'] == 'S')
        {
            //--first message to the cm---
			"<br/>". $sql_cm = "SELECT admin_id,cm_id FROM site_setting where type='A' and cm_id='".$_SESSION['cm_id_notification']."'";
			$db155=mysql_query($sql_cm);
            $row_cm =mysql_fetch_array($db155);
            if($row_cm['cm_id'])
            {
                $data_record['notification'] = 'New inquiry added by '.$row_loggedin['name'];
                $data_record['redirect_page_url'] = 'manage_student.php?record_id='.$args['reference_id'];
                $data_record['added_by'] = $_SESSION['admin_id'];
                $data_record['added_for'] = $row_cm['admin_id'];
                $data_record['on_action'] = $args['on_action'];
                $data_record['is_read'] = 'No';
                $data_record['added_date'] = date("Y-m-d H:i:s");
				
				"<br/>".$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
				$ptr_inst=mysql_query($ins_notifi);
                //$db1->query_insert('notifications',$data_record);
            }
            //--second message to the Councellor and Super admin---
			$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='C' or type='S' and admin_id!='".$_SESSION['admin_id']."' and cm_id='".$_SESSION['cm_id_notification']."'";
			$db11=mysql_query($sql_councellor);
            while($row_Councellor =mysql_fetch_array($db11))
			{
				if($row_Councellor['cm_id'])
				{
					$data_record['notification'] = 'New inquiry added by '.$row_loggedin['name'];
					$data_record['redirect_page_url'] = 'manage_student.php?record_id='.$args['reference_id'];
					$data_record['added_by'] = $_SESSION['admin_id'];
					$data_record['added_for'] = $row_Councellor['admin_id'];
					$data_record['on_action'] = $args['on_action'];
					$data_record['is_read'] = 'No';
					$data_record['added_date'] = date("Y-m-d H:i:s");
					
					$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
					$ptr_inst=mysql_query($ins_notifi);
					//$db1->query_insert('notifications',$data_record);
				}
			}
        }
    }
	else if(trim($args['on_action']) == "enroll")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		"<br/>".$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='C' or type='S' or type='A' or type='AC' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Enrollment added by '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_enroll_student.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			"<br/>". $ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "add_new_course")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='C' or type='S' or type='A' or type='AC' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Course added by Enrolled student by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_enroll_student.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "installment_payment")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='C' or type='S' or type='A' or type='AC' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Installment payment done by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_enroll_student.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "batch_added")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='C' or type='S' or type='A' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Batch added by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'add_batch.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "receipt_payment")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Incomming payment by receipt by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'receipt.php?receipt_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "expense")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Expense added by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'expense.php?expense_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "book_service")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = ' Customer Service Booked by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_cust_services.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "sale_voucher")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Sale Voucher to customer by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_memb_package_voucher.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "sale_package")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Sale Package to customer by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_memb_package_voucher.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "product_purchase")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' or type='ST' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Purchase product from vendor by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_inventory.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "product_purchase_payment")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' or type='ST' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Payment paid to vendor for product purchase by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'inventory_payment_details.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "product_sale_payment")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' or type='ST' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Payment received from customer for product sale by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'sales_prod_payment_details.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "product_sale")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' or type='ST' and cm_id='".$row_loggedin['cm_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Sale product to customer by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_sales_product.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
		}
	}
	else if(trim($args['on_action']) == "expence_type_added")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='ST' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Expence type added by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'expence_type_edit.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "service_category_added")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='ST' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Service Category added by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'service_category.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "enroll_verify")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='AC' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'Enrollment Verified by faculty '.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'manage_enroll_student.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "service_added")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='ST' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Service type added by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'service_category.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "customer_added")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='ST' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New Customer added by client added by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'service_category.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if(trim($args['on_action']) == "vendor_added")
	{
		$enroll_id = $args['reference_id'];//----you can use if you want to send the more details regarding the inquiry
		//----get logged in user type and based on that send the notification ----
		$sql_councellor = "SELECT admin_id,cm_id FROM site_setting where type='S' or type='A' or type='ST' and cm_id='".$row_loggedin['admin_id']."'";
		$db1=mysql_query($sql_councellor);
		while($row_Councellor =mysql_fetch_array($db1))
		{
			$data_record['notification'] = 'New vendor added by client added by faculty'.$row_loggedin['name'];
			$data_record['redirect_page_url'] = 'service_category.php?record_id='.$args['reference_id'];
			$data_record['added_by'] = $_SESSION['admin_id'];
			$data_record['added_for'] = $row_Councellor['admin_id'];
			$data_record['on_action'] = $args['on_action'];
			$data_record['is_read'] = 'No';
			$data_record['added_date'] = date("Y-m-d H:i:s");
			$ins_notifi="insert into notifications(`notification`,`redirect_page_url`,`added_by`,`added_for`,`on_action`,`is_read`,`added_date`) values('".$data_record['notification']."','".$data_record['redirect_page_url']."','".$data_record['added_by']."','".$data_record['added_for']."','".$data_record['on_action']."','".$data_record['is_read']."','".$data_record['added_date']."')";
			$ptr_inst=mysql_query($ins_notifi);
			
		}
		
	}
	else if($args['on_action'] == 'course_added')  ////========== Logsheet req added or custome corse added
	{
		 //--second message to the Councellor---
            $sql_councellor = "SELECT admin_id FROM site_setting where type='C' and cm_id='".$_SESSION['cm_id']."'";
            $row_Councellor =$db1->fetch_array($db1->query($sql_councellor));
            if($row_Councellor['admin_id'])
            {
				
				 $get="SELECT course_id,course_name FROM courses where course_id='".$args['reference_id']."' ";
                 $myQuery=mysql_query($get);
				 $data_course = mysql_fetch_array($myQuery);
				
                $data_record['notification'] = 'Customised Course '.$data_course['course_name'].' added by '.$row_loggedin['name'];
                $data_record['redirect_page_url'] = 'add_course.php?record_id='.$args['reference_id'];
                $data_record['added_by'] = $_SESSION['admin_id'];
                $data_record['added_for'] = $row_Councellor['admin_id'];
                $data_record['on_action'] = $args['on_action'];
                $data_record['is_read'] = 'No';
                $data_record['added_date'] = date("Y-m-d H:i:s");
                $db1->query_insert('notifications',$data_record);
            }
	}
    else
    {
        $data_record['notification'] = $args['notification'];
        $data_record['redirect_page_url'] = $args['redirect_page_url'];
        $data_record['added_by'] = $args['added_by'];
        $data_record['added_for'] = $args['added_for'];
        $data_record['on_action'] = $args['on_action'];
        $data_record['is_read'] = 'No';
        $data_record['added_date'] = date("Y-m-d H:i:s");
        $RecordId=$db1->query_insert('notifications',$data_record);
    }
   // $db1->close();
    if($RecordId)
        return $RecordId;
    else
        return false;
}
function taskScheduler($taskargs)
{
	//echo"<br/> Function Array - ".print_r($taskargs);
	
  	$action=trim($taskargs['on_action']);
	$data_task['task_type'] = "system";
	$data_task['task_name'] = $taskargs['task_name'];
	$data_task['description'] = $taskargs['description'];
	$data_task['hours'] = $taskargs['hours'];
	$data_task['points'] = $taskargs['points'];
	$data_task['due_date'] = $taskargs['due_date'];
	$data_task['Validation'] = $taskargs['Validation'];
	$data_task['priority'] = $taskargs['priority'];
	$data_task['status'] = $taskargs['status'];
	$data_task['deadline_count']=$taskargs['deadline_count'];
	$data_task['staff_id'] = $taskargs['staff_id'];
	$data_task['admin_id'] = $taskargs['admin_id'];
	$data_task['added_date'] = $taskargs['added_date'];
	$data_task['cm_id'] = $taskargs['cm_id'];
	$data_task['action_name'] = $taskargs['action_name'];
	$data_task['action_id'] = $taskargs['action_id'];
	$data_task['url'] = $taskargs['url'];
		
	//$TaskId=$db1->query_insert('tk_individual_task',$data_task);
	$ins_notifi="insert into tk_individual_task(`task_type`,`task_name`,`description`,`hours`,`points`,`due_date`,`Validation`,`priority`,`status`,`staff_id`,`admin_id`,`added_date`,`cm_id`,`action_name`,`action_id`,`url`,`deadline_count`,`date`,`assign_by`,`assign_type`,`repetation_id`) values('system','".$taskargs['task_name']."','".$taskargs['description']."','".$taskargs['hours']."','".$taskargs['points']."','".$taskargs['due_date']."','".$taskargs['Validation']."','".$taskargs['priority']."','".$taskargs['status']."','".$taskargs['staff_id']."','".$taskargs['admin_id']."','".$taskargs['added_date']."','".$taskargs['cm_id']."','".$taskargs['action_name']."','".$taskargs['action_id']."','".$taskargs['url']."','1','".$taskargs['added_date']."','".$taskargs['staff_id']."','self','0')";
	$ptr_inst=mysql_query($ins_notifi);
	$task_id=mysql_insert_id();
	
	$ins_details="insert into individual_task_details (`staff_task_id`,`comment`,`type`,`admin_id`,`cm_id`,`added_date`) values('".$task_id."','".$taskargs['description']."','comment','".$taskargs['admin_id']."','".$taskargs['cm_id']."','".$taskargs['added_date']."')";
	$ptr_details=mysql_query($ins_details);
	
	
    if(trim($taskargs['on_action']) == "add_lead")
    {
		echo $inquiry_id = $taskargs['on_action'];

	}
}
?>