HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/barbeatleanalyti/www/barisnew.beatleanalytics.com/runajax.php
<?php
header('Access-Control-Allow-Origin: https://beatleanalytics.com'); 
header('Access-Control-Allow-Origin: http://beatleanalytics.com'); 
header('Access-Control-Allow-Origin: *'); 

// Include common files.
error_reporting(0);
include_once("site/include/config.php");
include_once(INCLUDE_PATH."/dbClass.php");
$objDB 		= new MySQLCN();
include_once(INCLUDE_PATH."/functions.php");
include_once(INCLUDE_PATH."/storeconfig.php");
$storeconfig = new storeconfig();

include_once(TEMPLATE_PATH."/common_include.php");

error_reporting(0);

$acn = $_REQUEST['acn'];
$method = $_POST['method'];
$FromDate = $_REQUEST['startdate'];
$FromDate = date("Y-m-d",strtotime($FromDate));

$ToDate = $_REQUEST['enddate'];
$ToDate = date("Y-m-d",strtotime($ToDate));

$OrgID = $_REQUEST['orgid'];
$OrgType = $_REQUEST['orgtype'];
$indid = $_REQUEST['indid'];
$branchid = $_REQUEST['branchid'];
$stateid =  $_REQUEST['sid'];
$point =  $_REQUEST['point'];


session_start();

//echo "<pre>";
if($acn == 'FetchGraphData'){


	$datetime1 = new DateTime($FromDate);
	$datetime2 = new DateTime($ToDate);
	$interval = $datetime1->diff($datetime2);
	$diff = $interval->format('%a');
	

	
	/*
	$date1=date_create($FromDate);
	$date2=date_create($ToDate);
	echo $diff = date_diff($date1,$date2);	
	die;*/
	

	include(INCLUDE_PATH."/dashboardma.php");
	$objDashboard = new include_dashboardma();
	
	$frmDt = $FromDate;
	//echo "ORGANIZATION ID = ".$OrgID;
	//echo "<br />";
	
	$returnArr = array();
	$avgIndArr = array();
	$avgUsArr = array();
	//$returnArr['ind'] = array();
	//$returnArr['us'] = array();
	//$returnArr['date'] = array();
	
	if(strtolower($_SESSION['UserInfo']['UType']) == 'owner') {
		
		$rsBranches = $objDashboard->fetchBranchesData();
		$avgUSTotal = 0;
		
		//print_r($rsBranches);
		//die;
		
		// old = i;
		
		for($br=0; $br<count($rsBranches); $br++) {

			//echo "BRANCH ID = ".$rsBranches[$br]['branchId'];
			//echo "<br />";
			
			$rsIndustryData = $objDashboard->fetchIndustryData($rsBranches[$br]['branchId']);
			
			
			if(count($rsIndustryData) > 0) {

				$avgUS = 0;
				$avgInd = 0;						

				// old = j;
				
				for($indd=0; $indd<count($rsIndustryData); $indd++) { 
					
					$frmDt = $FromDate;
					
					//echo "INDUSTRY ID = ".$rsIndustryData[$indd]['IndId'];
					//echo "<br />";
					for($dt=0; $dt<=$diff; $dt++){
						
						
						
						$avgInd = $objDashboard->fetchRatingForCurrentIndustry($rsIndustryData[$indd]['IndId'],$rsBranches[$br]['branchId'],$OrgID,'us',$frmDt,$frmDt); 
						//$avgUs = $objDashboard->fetchRatingForCurrentIndustry($rsIndustryData[$indd]['IndId'],$rsBranches[$br]['branchId'],$OrgID,'us',$frmDt,$frmDt); 
						
						$avgUs = $objDashboard->fetchRatingForOhterIndustry($OrgID,$OrgType,'ind',$frmDt,$frmDt);
						//echo ":".$dt." &nbsp; : ";
						//echo "AVG IND  = ".$avgInd." ";
						//echo "AVG US  = ".$avgUs." DATE = ".$frmDt;
						
						if(!in_array($frmDt,$returnArr['date'])) {
							$returnArr['date'][] = date("Y-m-d",strtotime($frmDt));
							$returnArr['date_format'][] =  date("d",strtotime($frmDt));
						}
						
						$avgIndArr[$indd][] = $avgInd;
						$avgUsArr[$indd][]  = $avgUs;
						
						$frmDt = date("Y-m-d",strtotime("+1 day".$frmDt));
						
						//echo "<br />";
						

					}
					
					$returnArr['avg_ind'] = $avgIndArr;
					$returnArr['avg_us'] = $avgUsArr;
					
					
					//echo "<br /><br />";
					//$avg = $objDashboard->fetchRatingForCurrentIndustry($rsIndustryData[$indd]['IndId'],$rsBranches[$br]['branchId'],$OrgID,'ind',$FromDate,$ToDate); 
					
					//echo $avgInd =  (float)$avgInd + (float)$avg; 
					//echo "<br /> <br />";
					
					//$avg = $objDashboard->fetchRatingForCurrentIndustry($rsIndustryData[$indd]['IndId'],$rsBranches[$br]['branchId'],$OrgID,'us',$FromDate,$ToDate); 
					
					//echo $avgInd =  (float)$avgInd + (float)$avg; 
					//echo "<br />";


				}
			}
			

		}
	}
	
	
	$finalAvgArr = array();
	$ArrArr = array();
	$finalAvgArr[0] =  $returnArr['date_format'];
	
	for($dt=0; $dt<=$diff; $dt++){
		$avg1 = 0;
		$avg2 = 0;
		for($cnt=0; $cnt<count($returnArr['avg_ind']); $cnt++){
			$avg1 += $returnArr['avg_ind'][$cnt][$dt];
			$avg2 += $returnArr['avg_us'][$cnt][$dt];
		}
		//echo $avg;
		$ArrArr[1][] = number_format($avg1/count($returnArr['avg_ind']),1);
		$ArrArr[2][] = number_format($avg2/count($returnArr['avg_us']),1);
		//echo "<br />";
	} 
	
	$finalAvgArr[1] =  $ArrArr[1];
	$finalAvgArr[2] =  $ArrArr[2];
	
	//echo "<pre>";
//	print_r($finalAvgArr);
	//die;

	echo json_encode($finalAvgArr);
	exit;
}

else if($acn == 'FetchBranchDetails'){
		//$SQL = '';
	if(strtolower($_SESSION['UserInfo']['UType']) == 'owner') {

		$SQL = "SELECT db_branchName,branchId FROM beatle_branch WHERE db_branchOrg = ".$_SESSION['OtherInfo']['OrgID'];

	}else if(strtolower($_SESSION['UserInfo']['UType']) == 'manager'){

		$SQL = "SELECT db_branchName,branchId FROM beatle_branch WHERE db_branchOrg = ".$_SESSION['OtherInfo']['OrgID']." and branchId = (SELECT BranchID from beatle_userlogin where userId = ".$_SESSION['UserInfo']['UserID'].")";
	}else if(strtolower($_SESSION['UserInfo']['UType']) == 'line_manager'){

		$SQL = "SELECT db_branchName,branchId FROM beatle_branch WHERE db_branchOrg = ".$_SESSION['OtherInfo']['OrgID']." and branchId = (SELECT BranchID from beatle_userlogin where userId = ".$_SESSION['UserInfo']['UserID'].")";
	}

		//$SQL = "SELECT * FROM beatle_branch WHERE db_branchOrg = '".$OrgID."' ";
	$rsBranch = $objDB->sql_query($SQL);

	$html = '';
	$html .= '<select class="form-control input-md" name="Branches" >';

	if(count($rsBranch) > 0){
		$html .= '<option value="0">Select Branch</option>';	
		for($i=0; $i<count($rsBranch); $i++){
			$html .= '<option value="'.$rsBranch[$i]['branchId'].'" >'.$rsBranch[$i]['db_branchName'].'</option>';	
		}
	}else{
		$html .= '<option value="0" class="frm-select-box-option">... No any branch found ... </option>';	
	}
	$html .= '</select>';

	echo $html;
	exit;
	
}else if($acn == 'FetchIndustryDetails'){

		//$SQL = '';
	if(strtolower($_SESSION['UserInfo']['UType']) == 'owner') {


		$SQL = "SELECT * FROM beatle_industry WHERE db_bracnchid = '".$branchid."' ";
				//$rsBranches = $objDB->sql_query($SQL);

		
	}else if(strtolower($_SESSION['UserInfo']['UType']) == 'manager'){

		$SQL = "SELECT * FROM beatle_industry WHERE db_bracnchid = '".$branchid."' ";
				//$SQL = "SELECT * FROM beatle_industry WHERE db_bracnchid = (SELECT branchId FROM beatle_branch WHERE db_branchOrg = ".$_SESSION['OtherInfo']['OrgID']." and db_branchManager = ".$_SESSION['UserInfo']['UserID'].")";
				//$rsBranches = $objDB->sql_query($SQL);


	}else if(strtolower($_SESSION['UserInfo']['UType']) == 'line_manager'){

		$SQL = "SELECT * FROM beatle_industry WHERE db_bracnchid = '".$branchid."' AND db_userid = ".$_SESSION['UserInfo']['UserID'];
				//$rsBranches = $objDB->sql_query($SQL);

	}
		//$SQL = "SELECT * FROM beatle_industry WHERE db_bracnchid = '".$branchid."' ";
	$rsBranches = $objDB->sql_query($SQL);

	$html = '';
	$html .= '<select class="form-control input-md" name="Industrys">';

	if(count($rsBranches) > 0){
		$html .= '<option value="0">Select Industry</option>';	
		for($i=0; $i<count($rsBranches); $i++){
			$html .= '<option value="'.$rsBranches[$i]['IndId'].'" >'.$rsBranches[$i]['db_industry'].'</option>';	
		}
	}else{
		$html .= '<option value="0" class="frm-select-box-option">... No any industry found ... </option>';	
	}
	$html .= '</select>';

	echo $html;
	exit;
	
}else if($acn == 'UserLogin'){

	unset($_SESSION['UserInfo']);
	unset($_SESSION['OtherInfo']);
	session_destroy();



	$returnArr = array();

	$SQL = "SELECT * FROM beatle_userlogin WHERE (db_userLoginName = '".$_REQUEST['uid']."' OR db_phone = '".$_REQUEST['uid']."' ) AND db_password = '". md5($_REQUEST['access'])."' AND (LOWER(db_usertype) = 'owner' || LOWER(db_usertype) = 'manager' || LOWER(db_usertype) = 'line_manager')";
		// Run query
	$rsAdmin = $objDB->sql_query($SQL);

	if($rsAdmin)
	{
				// Assign the UserID into session.
		$_SESSION['UserInfo']['UserID'] = $rsAdmin[0]['userId'];

				// Assign the UniqueID into the session
		$_SESSION['UserInfo']['UniqueID'] = $rsAdmin[0]['db_userRandId'];

				// Assign the workfor into session.
		$_SESSION['UserInfo']['UType'] = $rsAdmin[0]['db_usertype'];

				// Assign the session id into session.
		$_SESSION['UserInfo']['SessionID'] = session_id();


		$SQL = "SELECT OrgID,BranchID,IndustryID FROM beatle_userlogin WHERE userId = ".$_SESSION['UserInfo']['UserID'];
		$rsOwnerInfo = $objDB->sql_query($SQL);

		if(count($rsOwnerInfo) > 0) {

			$_SESSION['OtherInfo']['OrgID'] = $rsOwnerInfo[0]['OrgID'];
			$_SESSION['OtherInfo']['BranchID'] = $rsOwnerInfo[0]['BranchID'];
			$_SESSION['OtherInfo']['IndustryID'] = $rsOwnerInfo[0]['IndustryID'];

		}


		if(count($_SESSION['UserInfo']) != 4 || count($_SESSION['OtherInfo']) != 3){
			$returnArr[0] = 1;
			$returnArr[1] = 'Here is something wrong, please contact administrator.';
			echo json_encode($returnArr);
			die;
		}

					//print_r($_SESSION);

		$returnArr[0] = 0;
		$returnArr[1] = SERVER_ROOT.'dashboardma.html';
					//$returnArr[3] = $_SESSION;

		echo json_encode($returnArr);
		die;


	}

	$SQL = "SELECT * FROM beatle_userlogin WHERE (db_userLoginName = '".$_REQUEST['uid']."' OR db_phone = '".$_REQUEST['uid']."' ) AND db_password = '". md5($_REQUEST['access'])."' 
	AND LOWER(db_usertype) = 'end_user'";
		// Run query
	$rsAdmin = $objDB->sql_query($SQL);


	if($rsAdmin)
	{
				// Assign the UserID into session.
		$_SESSION['UserInfo']['UserID'] = $rsAdmin[0]['userId'];

				// Assign the UniqueID into the session
		$_SESSION['UserInfo']['UniqueID'] = $rsAdmin[0]['db_userRandId'];

				// Assign the workfor into session.
		$_SESSION['UserInfo']['UType'] = $rsAdmin[0]['db_usertype'];

				// Assign the session id into session.
		$_SESSION['UserInfo']['SessionID'] = session_id();


		$SQL = "SELECT OrgID,BranchID,IndustryID FROM beatle_userlogin WHERE userId = ".$_SESSION['UserInfo']['UserID'];
		$rsOwnerInfo = $objDB->sql_query($SQL);

		if(count($rsOwnerInfo) > 0) {

			$_SESSION['OtherInfo']['OrgID'] = $rsOwnerInfo[0]['OrgID'];
			$_SESSION['OtherInfo']['BranchID'] = $rsOwnerInfo[0]['BranchID'];
			$_SESSION['OtherInfo']['IndustryID'] = $rsOwnerInfo[0]['IndustryID'];

		}

		if(count($_SESSION['UserInfo']) != 4 || count($_SESSION['OtherInfo']) != 3){
			$returnArr[0] = 1;
			$returnArr[1] = 'Here is something wrong, please contact administrator.';
			echo json_encode($returnArr);
			die;
		}


		$returnArr[0] = 0;
		$returnArr[1] = SERVER_ROOT.'profileemp.html';

		echo json_encode($returnArr);
		die;

	}

	$returnArr[0] = 1;
	$returnArr[1] = 'Wrong userid or password';

	echo json_encode($returnArr);
	die;				
	
}else if($acn == 'fetchCityData'){
	$SQL = "SELECT id, name FROM cities where state_id = ".$stateid." order by name ASC ";
	$rsCity = $objDB->sql_query($SQL);
	
	$html = '';
	$html .= '<select class="form-control" name="city" id="city">';
	for($s = 0; $s<count($rsCity); $s++) {
		$sel = '';
		if($stateid == $rsCity[$s]['id']){
			$sel = 'selected="selected"';
		}

		$html .= '<option '.$sel.' value="'.$rsCity[$s]['id'].'">'.$rsCity[$s]['name'].'</option>';
	} 
	$html .= '</select>';

	echo $html;
	exit;
	
}else if($acn == 'getFastivalBanner'){
	
	echo '<img style="width:100% !important;" class="card-bkimg" alt="" src="http://img.beatleanalytics.com/festival/diwali/large/'.rand(0,6).'.jpg">';
	exit;
	
}else if($acn == 'applyoffertocustomer'){
	
	$SQL = "INSERT INTO beatle_points SET 
	Amount = '".$_REQUEST['readeempoint']."', 
	AddedDate = '".date("Y-m-d H:i:s")."',
	UserID = '".$_REQUEST['custid']."',
	UserType = 'End_user',
	IsRedeem = 'Y' ";
	$objDB->sql_query($SQL);

	$SQL = "UPDATE beatle_offers_apply SET 
	approved = 'Y', 
	point = '".$_REQUEST['readeempoint']."'
	WHERE
	applyid = '".$_REQUEST['applyid']."' ";

	$objDB->sql_query($SQL);

	echo 0;
	exit;
	
}else if($acn == 'fetchGraphiFrame'){


	$pg = $_REQUEST['pg'];
	$error = $_REQUEST['error'];
	$msg = $_REQUEST['msg'];
	$v = $_REQUEST['v'];
	$atype = $_REQUEST['atype'];
	$FromDate = $_REQUEST['FromDate'];
	$ToDate = $_REQUEST['ToDate'];
	$PageID = $_REQUEST['pgid'];
	$PageConID = $_REQUEST['pgcid'];
	$BranchID = $_REQUEST['brnid'];
	$IndustryID = $_REQUEST['indid'];
	$orgID = $_REQUEST['orgid'];

	
	$data = $_REQUEST['data'];
	if($data != ""){
		// Decode into base64.
		$data = urldecode(base64_decode($this->data));
		//echo "<br />";
		// Convert string to array of a data.
		$DataExplode = explode("&",$data);
		
		foreach($DataExplode as $key=>$val){
			for($i=0; $i<count($DataExplode); $i++ ){			
				$DataExpSub = explode("=",$DataExplode[$i]);
				if(preg_match('/pg=/',$DataExplode[$i])){
					$pg = $DataExpSub[1];
				}else if(preg_match('/error=/',$DataExplode[$i])){
					$error = $DataExpSub[1];
				}else if(preg_match('/msg=/',$DataExplode[$i])){
					$msg = $DataExpSub[1];
				}else if(preg_match('/v=/',$DataExplode[$i])){
					$v = $DataExpSub[1];
				}else if(preg_match('/atype=/',$DataExplode[$i])){
					$atype = $DataExpSub[1];
				}else if(preg_match('/FromDate=/',$DataExplode[$i])){
					$FromDate = $DataExpSub[1];
				}else if(preg_match('/ToDate=/',$DataExplode[$i])){
					$ToDate = $DataExpSub[1];
				}else if(preg_match('/pgid=/',$DataExplode[$i])){
					$PageID = $DataExpSub[1];
				}else if(preg_match('/pgcid=/',$DataExplode[$i])){
					$PageConID = $DataExpSub[1];
				}else if(preg_match('/brnid=/',$DataExplode[$i])){
					$BranchID = $DataExpSub[1];
				}else if(preg_match('/indid=/',$DataExplode[$i])){
					$IndustryID = $DataExpSub[1];
				}else if(preg_match('/orgid=/',$DataExplode[$i])){
					$orgID = $DataExpSub[1];
				}
			}
		}
	}
	
	include('site/include/dashboardma.php');
	$objDashboard = new include_dashboardma();
	
	//echo $FromDate."#".$ToDate;
	//die;
	
	$finalAvgArr = $objDashboard->fetchGraphDetailsGeneral($atype,$orgID,$BranchID,$IndustryID,$PageID,$PageConID,$FromDate,$ToDate);
	// echo "<pre>";
	// print_r($finalAvgArr);die()
	?>

	<script src="theme/black/r_graph/RGraph.svg.common.core.js"></script>
	<script src="theme/black/r_graph/RGraph.svg.line.js"></script>
	<script src="theme/black/r_graph/RGraph.svg.common.tooltips.js"></script>

	<div style="width: 100%; height: 250px; background:#32373a;" id="chart-container-c" ></div>


	<!-- Weekly Sales Analysis START -->
	<script>
		var linex = new RGraph.SVG.Line({
			id: 'chart-container-c',
			data: [
			[<?php echo implode(",",$finalAvgArr[2]); ?>],
			[<?php echo implode(",",$finalAvgArr[1]); ?>],
			],
			options: {
				xaxisLabels: [<?php echo implode(",",$finalAvgArr[0]); ?>],
				labelsSize: 2,
				yaxisUnitsPost: '',
				xaxisTextColor: '#333',
				yaxisTextColor: '#333',
				tooltips: [<?php echo "'".implode("','",$finalAvgArr[2])."'"?>,<?php echo "'".implode("','",$finalAvgArr[1])."'"?>],
				gutterLeft:   25,
				gutterTop:    15,
				gutterRight:  25,
				gutterBottom: 25,
				colors: ['#22b14c','#ed1c24'],
				linewidth: 2,
				shadow: true,
				shadowBlur: 3,
				tickmarks: 'circle',
				ticksize: 5,
				
				textColor: 'white',
				shadowOpacity: 0.25,

				spline: true


			}
		}).trace();
	</script>
	<style>
	text {
		fill: #fff;
		size: 10px !IMPORTANT;
		font-size: 11px;
	}


</style>
<?php
}
else if($acn == 'fetchWeeklyPerformanceOnSummeryPage'){
	
	$ind = $_REQUEST['ind'];
	$indArr = json_decode($ind);
	//echo "<br />";
	$ind  = implode(',',$indArr);
	//echo "<br />";
	$us = $_REQUEST['us'];
	$usArr = json_decode($us);
	$us  = implode(',',$usArr);
	//echo "<br />";
	$days = $_REQUEST['days'];
	
	$tooltip = "'".str_replace(",","','",$ind)."','".str_replace(",","','",$us)."'";
	?>
	<script src="theme/black/r_graph/RGraph.svg.common.core.js"></script>
	<script src="theme/black/r_graph/RGraph.svg.line.js"></script>
	<script src="theme/black/r_graph/RGraph.svg.common.tooltips.js"></script>

	<div style="width: 100%; height: 190px; background:#32373a;" id="chart-container-c" ></div>


	<!-- Weekly Sales Analysis START -->
	<script>
		var linex = new RGraph.SVG.Line({
			id: 'chart-container-c',
			data:  [
			[<?php echo $ind?>],
			[<?php echo $us?>]
			],

			options: {
				xaxisLabels:  ['<?php echo str_replace(",","','",$days);?>'],

				labelsSize: 2,
				yaxisUnitsPost: '',
				xaxisTextColor: '#333',
				yaxisTextColor: '#333',
				tooltips: [<?php echo $tooltip;?>],

				gutterLeft:   20,
				gutterTop:    20,
				gutterRight:  10,
				gutterBottom: 30,
				colors: ['#ed1c24','#22b14c'],
				linewidth: 2,
				shadow: true,
				shadowBlur: 3,
				tickmarks: 'circle',
				ticksize: 5,
				
				textColor: 'white',
				shadowOpacity: 0.25,

				spline: true


			}
		}).trace();
	</script>

	<style>
	text {
		fill: #fff;
		size: 10px !IMPORTANT;
		font-size: 11px;
	}


</style>	

<?php 
}else if($acn == 'fetchWeeklyFeedbackCountOnSummeryPage'){

	$fbCountTotal = $_REQUEST['wfbtotal'];
	$fbCountTotalArr = json_decode($fbCountTotal);
	$fbCountTotal  = implode(',',$fbCountTotalArr);

	$fbCountIndwise = $_REQUEST['wfbtotalindwise'];
/*	$fbCountIndwiseArr = json_decode($fbCountIndwise);
	$fbCountIndwise  = implode(',',$fbCountIndwiseArr);*/

/*	echo "<pre>";
	print_r($fbCountIndwise);
	echo "</pre>";*/


	$days = $_REQUEST['days'];
	$fulldays = base64_decode($_REQUEST['fulldays']);
?>
<!--     <script src="theme/black/r_graph/RGraph.svg.common.core.js" ></script>
    <script src="theme/black/r_graph/RGraph.common.dynamic.js" ></script>
    <script src="theme/black/r_graph/RGraph.modaldialog.js" ></script>
    <script src="theme/black/r_graph/RGraph.svg.bar.js" ></script> -->
    <script src="theme/black/r_graph/RGraph.svg.common.core.js"></script>
	<script src="theme/black/r_graph/RGraph.svg.common.tooltips.js"></script>
	<script src="theme/black/r_graph/RGraph.svg.bar.js"></script>
    <div style="width: 100%; height: 190px; background:#32373a; display: inline-block" id="chart-container-fcount" ></div>


    <script>
    new RGraph.SVG.Bar({
        id: 'chart-container-fcount',
        data: [<?php echo $fbCountTotal;?>],
        options: {
            colorsSequential: true,
            colors: ['Gradient(#86B5BC:#2196F3)','Gradient(#86B5BC:#2196F3)','Gradient(#86B5BC:#2196F3)','Gradient(#86B5BC:#2196F3)','Gradient(#86B5BC:#2196F3)','Gradient(#86B5BC:#2196F3)','Gradient(#86B5BC:#2196F3)'],
            tooltips: ['<?php echo str_replace(",","','",$fbCountIndwise);?>'],
            xaxisLabels: ['<?php echo str_replace(",","','",$days);?>'],
            xaxisColor: '#aaa',
            yaxisColor: '#aaa',
            yaxisLabelsCount: 5,
            labelsAbove: true,
			gutterLeft:   20,
				gutterTop:    20,
				gutterRight:  10,
				gutterBottom: 30,
				gutterLeft: 30,
            yaxisScaleUnitsPost: 'k',
            marginLeft: 45,
			textColor: 'white',
            textSize: 9,
            hmargin: 15
        }
    }).draw().on('beforetooltip', function ()
    {
        RGraph.SVG.tooltips.style.backgroundColor = 'black';
        RGraph.SVG.tooltips.style.color           = 'white';
        RGraph.SVG.tooltips.style.fontWeight      = 'bold';
    });
</script>
    
<?php 
}else if($acn == 'sendemailcronejob'){
	global $objDB;
	
	$SQL_ = "INSERT INTO beatle_cronejob_report SET  datetime  = '".date('Y-m-d H:i:s')."'";
	$objDB->sql_query($SQL_);
	
	
	$SQL = "SELECT * FROM beatle_crone WHERE status = 'queue' ORDER BY croneid ASC LIMIT 5";
	$rsData = $objDB->sql_query($SQL);
	
	for($i = 0; $i < count($rsData); $i++) {

		deductPointFromDB();
		
		$SQL = "SELECT OrgId,db_Orgname FROM beatle_organization WHERE OrgId = ".$rsData[$i]['orgid'];
		$rsOrgInfo = $objDB->sql_query($SQL);

		$objDB->SetFromName	 = $rsOrgInfo[0]['db_Orgname'];
		$objDB->ToEmail 		 = $rsData[$i]['emailid'];
		$objDB->Name 		    = $rsData[$i]['customername'];
		$objDB->EmailSubject	= $rsData[$i]['email_subject'];
		$objDB->EmailBody	   =  $rsData[$i]['emailbody'];

		if ($objDB->SendEMail()){
			//echo $rsData[$i]['croneid']. " Yes<br />";
			updateEmailSentInformation('yes',$rsData[$i]['croneid'],$objDB->mailResponse);
		}else{
			updateEmailSentInformation('no',$rsData[$i]['croneid'],$objDB->mailResponse);
			//echo $rsData[$i]['croneid']. " NO <br />";
		}
		
	}
}
else if($acn == 'total_redeem_point'){
	//echo "<pre>";	
	$val1 = fetchTotalPointsClient();
	
	if($val1 > $point) {

		$SQL = "SELECT * FROM beatle_manage_points WHERE orgid = ".$_SESSION['OtherInfo']['OrgID']." ORDER BY id DESC LIMIT 1";
		$rsUsedData = $objDB->sql_query($SQL);

		if(count($rsUsedData) > 0) {

			$remian_point  		 		= $point + $rsUsedData[0]['remian_point'];
			$point		 			   = $point;
			$customer_use_point    	  = $point + $rsUsedData[0]['customer_use_point'];

		}else{

			$remian_point       	= $point;
			$point		       = $point;
			$customer_use_point  = $point;
		}

		$SQL = "INSERT INTO beatle_manage_points SET
		remian_point 			= '".$remian_point."',
		point 					= '".$point."',
		customer_use_point 		= '".$customer_use_point."',
		orgid 					= '".$_SESSION['OtherInfo']['OrgID']."',
		created_date 			= '".date("Y-m-d H:i:s")."',
		type 					= 'email' ";
		
		$objDB->sql_query($SQL);
		
		echo 0;
		
	}else{
		
		echo 1;
	}
}else if($acn == 'FetchEmailSendData'){
	
	//echo "<pre>";
	$stateid = substr($stateid,1,strlen($stateid));
	$idArr = explode("_",$stateid);
	
	$newArr = array();
	$cnt = 0;
	foreach($idArr as $key => $val){
		if(!in_array($val,$newArr)){
			$newArr[]  = $val;
			$cnt++;
		}
	}
	
	$totalCredeits = fetchRemainPointClient('email');
	$selected = count($idArr);
	$duplicate = count($idArr) - count($newArr);
	$tosend = count($newArr);
	$invalid = 0;
	
	$html = '';
	$html .= '<h2 style="background:#ccc;height: 40px;width: 100%;text-align: center;line-height: 37px;font-weight: bold;" class="box-title">EMAIL INVENTORY</h2>';
	$html .= '<p> <strong>TOTAL CREDITS :	&nbsp; </strong> '.$totalCredeits.' </p>';
	$html .= '<p> <strong>SELECTED :	&nbsp; </strong> '.$selected.' </p>';
	$html .= '<p> <strong>REMOVED DUPLICATES :	&nbsp; </strong> '.$duplicate.' </p>';
	$html .= '<p> <strong>READY TO SEND :	&nbsp; </strong> '.$tosend.' </p>';
	$html .= '<p> <strong>REMOVED INVALIDS :	&nbsp; </strong> '.$invalid.' </p>';
	
	echo $html;
	exit;
}else if($acn == 'insertemailrequest'){
	
	$price = number_format(($point * 0.04),2);
	$tax = number_format(($price * 18 / 100),2);
	$totalprice =  ($price+$tax);
	
	
	$SQL = "INSERT INTO beatle_purchase SET 
	orgid = ".$_SESSION['OtherInfo']['OrgID'].",
	status = 'new',
	created_date = '".date('Y-m-d H:i:s')."',	
	quantity = ".$point.",
	price = ".$price.",
	taxrate = 18,
	tax = ".$tax.",
	totalprice = ".$totalprice."	";
	
	$rsData = $objDB->sql_query($SQL);
	$id = mysqli_insert_id($objDB->CONN);
	
	$uid = str_pad($id, 5, "0", STR_PAD_LEFT);  //00002
	
	$SQL = "UPDATE beatle_purchase SET 
	uiqueid = '".$uid."'
	WHERE  purchaseid = ".$id;
	$objDB->sql_query($SQL);
	
	echo 0;
	die;
	
}else if($acn == 'fetchcurrenttime'){
	echo date('Y-m-d H:i:s');
	exit;
}else if($acn == 'customizeActiveScore'){
	$activeScore = $_GET['activeScore'];
	
	$SQL = "SELECT db_pagepermistion from beatle_userlogin where userId = ".$_SESSION['UserInfo']['UserID'];
	$row = $objDB->sql_query($SQL);
	
	if(!empty($row)){
		if($activeScore == 'on'){
			if(empty($row[0]['db_pagepermistion'])){
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = 'ason' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif(strpos($row[0]['db_pagepermistion'],"asoff")){
				$replaceValue = str_replace("asoff","ason",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif($row[0]['db_pagepermistion'] == "asoff"){
				$replaceValue = str_replace("asoff","ason",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif(strpos($row[0]['db_pagepermistion'],"ason")){
				$replaceValue = str_replace("ason","ason",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}else{
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$row[0]['db_pagepermistion'].",ason' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}
				
			
		}elseif($activeScore == 'off'){
			if(empty($row[0]['db_pagepermistion'])) {
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = 'asoff' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif(strpos($row[0]['db_pagepermistion'],"ason")){
				$replaceValue = str_replace("ason","asoff",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif($row[0]['db_pagepermistion'] == "ason"){
				$replaceValue = str_replace("ason","asoff",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);	
			}elseif(strpos($row[0]['db_pagepermistion'],"asoff")){
				$replaceValue = str_replace("asoff","asoff",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}else{
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$row[0]['db_pagepermistion'].",asoff' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}	
		}
	}
}else if($acn == 'customizePercentageView'){
	$percentageview = $_GET['percentageview'];
	
	$SQL = "SELECT db_pagepermistion from beatle_userlogin where userId = ".$_SESSION['UserInfo']['UserID'];
	$row = $objDB->sql_query($SQL);
	
	if(!empty($row)){
		if($percentageview == 'on'){
			if(empty($row[0]['db_pagepermistion'])){
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = 'pvon' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif(strpos($row[0]['db_pagepermistion'],"pvoff")){
				$replaceValue = str_replace("pvoff","pvon",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif($row[0]['db_pagepermistion'] == "pvoff"){
				$replaceValue = str_replace("pvoff","pvon",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif(strpos($row[0]['db_pagepermistion'],"pvon")){
				$replaceValue = str_replace("pvon","pvon",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}else{
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$row[0]['db_pagepermistion'].",pvon' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}
				
			
		}elseif($percentageview == 'off'){
			if(empty($row[0]['db_pagepermistion'])) {
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = 'pvoff' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}elseif(strpos($row[0]['db_pagepermistion'],"pvon")){
				$replaceValue = str_replace("pvon","pvoff",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);	
			}elseif($row[0]['db_pagepermistion'] == "pvon"){
				$replaceValue = str_replace("pvon","pvoff",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);	
			}elseif(strpos($row[0]['db_pagepermistion'],"pvoff")){
				$replaceValue = str_replace("pvoff","pvoff",$row[0]['db_pagepermistion']);
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$replaceValue."' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}else{
				$SQL_ = "UPDATE beatle_userlogin set db_pagepermistion = '".$row[0]['db_pagepermistion'].",pvoff' where userId = ".$_SESSION['UserInfo']['UserID'];
				$objDB->sql_query($SQL_);
			}
		}
	}
}else if($acn == 'getIndustries'){
	$branchid = $_GET['bid'];
	include(INCLUDE_PATH."/addattendant.php");
	$objAttendant = new include_addattendant();
	
	//echo($branchid);
	$rsIndustryData = $objAttendant->fetchIndustrys($branchid);

	for($i=0; $i<count($rsIndustryData); $i++) { 

		echo "<option id='ind".$rsIndustryData[$i]['IndId']."' value='".$rsIndustryData[$i]['IndId']."'>".$rsIndustryData[$i]['db_industry']."</option>";
	}

}else if($acn == 'uplodedImageReview'){
	$ReviewId = $_REQUEST['reviewid'];

		$count = count($_FILES['file']['name']);
		$return_arr = array();
		for ($i = 0; $i < $count; $i++) {
			$filesize = $_FILES['file']['size'][$i];
			$filename = 'webreview_'.time().$i.'.jpg';
			$location = UPLOAD_REVIEWIMAGES.$filename;
			$date	= date('Y-m-d H:i:s');
			/*if(move_uploaded_file($_FILES['file']['tmp_name'][$i],$location)){
		    $src = "app_screenshots_device.jpg";
			if(is_array(getimagesize($location))){
		         $src = $location;
		     }
			$return_arr[] = array("name" => $filename,"size" => $filesize, "src"=> $src);
			}*/
			$imageFileType = pathinfo($_FILES['file']['name'][$i],PATHINFO_EXTENSION);

			if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "PNG" && $imageFileType != "JPG" && $imageFileType != "JPEG") 
			{
				echo 'e1';
			}
			else
			{
				move_uploaded_file($_FILES['file']['tmp_name'][$i],$location);
				//file_put_contents($location,$_FILES['file']['tmp_name'][$i])

				$src = "webreviewimages.jpg";
				if(is_array(getimagesize($location))){
			        $src = $location;
			    }
			    
				$SQL = "INSERT INTO beatle_review_photo (reviewId,photoName,created_date) VALUES(".$ReviewId.",'".$filename."','".$date."')" ;
				$rsData = $objDB->sql_query($SQL);
				$id = mysqli_insert_id($objDB->CONN);
				//echo $id;
				
				$return_arr[] = array("name" => $filename,"size" => $filesize, "src"=> $src, "id"=> $id);

			}

		}
		echo json_encode($return_arr);
	
}else if($acn == 'deleteReviewImage'){
	$reviewId = $_POST['id'];
	$SQL = "SELECT photoName FROM beatle_review_photo WHERE photoId = ".$reviewId."";
	$row = $objDB->sql_query($SQL);
	unlink(UPLOAD_REVIEWIMAGES.$row[0]['photoName']);
	$SQL = "DELETE FROM beatle_review_photo WHERE photoId = ".$reviewId."";
	$objDB->sql_query($SQL);

}else if($method == 'deleteAttendent'){

	$atteId = $_POST['data'];
	$SQL = "DELETE FROM `beatle_userlogin` WHERE `userId` = ".$atteId."";
	$objDB->sql_query($SQL);

}else if($method == 'uplodedAttendentProfileImage'){
	$data = $_POST['image'];
	$image_array_1 = explode(";", $data);
	$image_array_2 = explode(",", $image_array_1[1]);
	$data = base64_decode($image_array_2[1]);

			$filename = 'webattendent_'.time().'.jpg';
			$location = UPLOAD_WEBPROFILEIMAGE.$filename;
			$date	= date('Y-m-d H:i:s');
			
			//Check write Access to Directory
			if(!is_writable(dirname($location))){
				echo "Can`t write cropped File";
			}
				//move_uploaded_file($data,$location);
			
				file_put_contents($location,$data);

		echo($filename);
		

}else if($method == 'insertReviewDetails1'){
	$restType 	= strtolower($_POST['resttype']);
	//echo $restType;
	//die();
	$type 		= $_POST['type'];
	$orgid 		= $_POST['orgid'];
	$branchid 	= "0";
	if(!empty($_POST['branchid']))
		$branchid = $_POST['branchid'];

	$indid 		= "0";
	if(!empty($_POST['indid']))
		$indid = $_POST['indid'];

	$name 		= $_POST['displayName'];


	if($type == 'org'){
		$SQL = "SELECT * FROM beatle_review where orgId = ".$orgid." and type = '".$type."'";
		$result = $objDB->sql_query($SQL);
		if(count($result) > 0){
			echo $result[0]['reviewId'];
			exit;
		}
	}elseif ($type == 'ind') {
		$SQL = "SELECT * FROM beatle_review where orgId = ".$orgid." and branchId = ".$branchid." and indId = ".$indid." and type = '".$type."'";
		$result = $objDB->sql_query($SQL);
		if(count($result) > 0){
			echo $result[0]['reviewId'];	
			exit;
		}
	}

	$SQL = "INSERT INTO beatle_review (type,orgId,branchId,indId,restType,restName,restDesc,webprofileimage,updated_date,created_date,status) VALUES('".$type."',".$orgid.",".$branchid.",".$indid.",'".$restType."','".$name."','','','0000-00-00 00:00:00','".date('Y-m-d H:i:s')."','N')" ;
		
		$rsData = $objDB->sql_query($SQL);
		$id = mysqli_insert_id($objDB->CONN);
		echo $id;
	//echo $type.",".$orgid.",".$branchid.",".$indid.",".$name;

}else if($method == 'insertReviewFeedbackDetails'){

	/*$atteId = $_POST['data'];
	$SQL = "DELETE FROM `beatle_review_feedback` WHERE `reviewId` = ".$_POST['reviewid']."";
	$objDB->sql_query($SQL);*/

	$reviewid = $_POST['reviewid'];
	$userId = $_POST['userId'];
	$username = $_POST['username'];
	$avgrat = $_POST['avgrat'];
	$feedback = $_POST['feedback'];
	$tokenid = $_POST['tokenid'];
	$feedbackDate = $_POST['date'];
	//$date	= date('Y-m-d H:i:s');

	$SQL = "INSERT INTO beatle_review_feedback (reviewId,userId,username,avgRating,feedbackDetail,tokenid,feedbackDate,created_date) VALUES(".$reviewid.",".$userId.",'".$username."',".$avgrat.",'".$feedback."','".$tokenid."','".$feedbackDate."','".date('Y-m-d H:i:s')."')" ;
		
		$rsData = $objDB->sql_query($SQL);

}else if($method == 'deleteReviewFeedbackDetails'){
		$SQL = "DELETE FROM `beatle_review_feedback` WHERE `reviewId` = ".$_POST['reviewid']."";
		$objDB->sql_query($SQL);


/*baris*/
}else if($acn == 'insertAuditorDetails'){

	//echo "<pre>";
	//print_r($_POST);
	/*$atteId = $_POST['data'];
	$SQL = "DELETE FROM `beatle_review_feedback` WHERE `reviewId` = ".$_POST['reviewid']."";
	$objDB->sql_query($SQL);*/

	$username = $_POST['audi_username'];
	$fullname = $_POST['audi_fullname'];
	$password = md5($_POST['audi_password']);
	$contact_number = $_POST['audi_contact_number'];
	$email = $_POST['audi_email'];
	$designation = $_POST['audi_designation'];
	$OrgID = $_POST['OrgID'];
	$DivisionId = $_POST['DivisionId'];
	$StationId = $_POST['StationId'];
	$feedbackDate = $_POST['date'];
	$date	= date('Y-m-d H:i:s');

	$reportType = implode(',', $_POST['reportType']);

	$SQL = "INSERT INTO baris_userlogin (reportType,db_username,db_userLoginName,db_password,db_phone,db_email,db_usertype,db_designation,OrgID,DivisionId,StationId,created_date) VALUES('".$reportType."','".$fullname."','".$username."','".$password."','".$contact_number."','".$email."','auditor','".$designation."',".$OrgID.",".$DivisionId.",".$StationId.",'".$date."')" ;
		
		$rsData = $objDB->sql_query($SQL);


}else if($acn == 'editAuditorDetails'){

	// echo "<pre>";
	// print_r($_POST);
	/*$atteId = $_POST['data'];
	$SQL = "DELETE FROM `beatle_review_feedback` WHERE `reviewId` = ".$_POST['reviewid']."";
	$objDB->sql_query($SQL);*/

	$fullname = $_POST['audi_fullname_edit'];
	$username = $_POST['audi_username_edit'];
	$password = md5($_POST['audi_password_edit']);
	$contact_number = $_POST['audi_contact_number_edit'];
	$email = $_POST['audi_email_edit'];
	$designation = $_POST['audi_designation_edit'];
	$userId = $_POST['userId'];
	$reportType = implode(',', $_POST['audi_reporttype_edit']);


	$SQL = "UPDATE baris_userlogin SET 
	reportType = '".$reportType."', 
	db_username = '".$fullname."', 
	db_userLoginName = '".$username."', ";
	if(!empty($_POST['audi_password_edit'])){
		$SQL .= "db_password = '".$password."', ";
	}
	
	$SQL .= "db_phone = '".$contact_number."', 
	db_email = '".$email."', 
	db_designation = '".$designation."'  
	WHERE  userId = ".$userId;
	// echo($SQL);
	$objDB->sql_query($SQL);

	// $SQL = "INSERT INTO baris_userlogin (db_username,db_userLoginName,db_password,db_phone,db_email,db_usertype,db_designation,OrgID,DivisionId,StationId,created_date) VALUES('".$username."','".$fullname."','".$password."','".$contact_number."','".$email."','auditor','".$designation."',".$OrgID.",".$DivisionId.",".$StationId.",'".$date."')" ;
		
	// $rsData = $objDB->sql_query($SQL);

}else if($acn == 'deleteAuditorById'){
	$auditorId = $_POST['id'];
	$SQL = "DELETE FROM baris_userlogin WHERE userId = ".$auditorId."";
	$objDB->sql_query($SQL);

}else if($acn == 'addMonthlyTarget'){

	// echo "<pre>";
	// print_r($_POST);
	$SQL = "DELETE FROM baris_target WHERE OrgID = ".$_SESSION['UserInfo']['OrgID']." AND queId = ".$_POST['questionId']." AND subqueId = ".$_POST['subQuestionId']." AND month = ".$_POST['month']." AND year = ".$_POST['year'];
	$objDB->sql_query($SQL);

	$date	= date('Y-m-d H:i:s');
	$rsPagesId = explode(',', $_POST['pagesIDS']);
	foreach ($rsPagesId as $key => $value) {
		
	$SQL = "INSERT INTO baris_target (OrgID,queId,subqueId,pageId,value,month,year,created_date) VALUES(".$_SESSION['UserInfo']['OrgID'].",".$_POST['questionId'].",".$_POST['subQuestionId'].",".$value.",".$_POST[$value].",".$_POST['month'].",".$_POST['year'].",'".$date."')" ;
		
	$rsData = $objDB->sql_query($SQL);
	}
	echo "done";

}else if($acn == 'addDailyTarget'){

	// echo "<pre>";
	// print_r($_POST);
	$SQL = "DELETE FROM baris_target WHERE OrgID = ".$_SESSION['UserInfo']['OrgID']." AND queId = ".$_POST['questionId']." AND subqueId = ".$_POST['subQuestionId']." AND today_date = '".date('Y-m-d',strtotime($_POST['Date']))."' ";
	$objDB->sql_query($SQL);

	$date	= date('Y-m-d H:i:s');
	$rsPagesId = explode(',', $_POST['pagesIDS']);
	foreach ($rsPagesId as $key => $value) {
		if(strtolower($_POST[$value.'1']) == "y"){
			$shift1 = '1';
		}else{
			$shift1 = '0';
		}
		if(strtolower($_POST[$value.'2']) == "y"){
			$shift2 = '1';
		}else{
			$shift2 = '0';
		}
		if(strtolower($_POST[$value.'3']) == "y"){
			$shift3 = '1';
		}else{
			$shift3 = '0';
		}
		
		$targetValue = $shift1.','.$shift2.','.$shift3;
	$SQL = "INSERT INTO baris_target (OrgID,queId,subqueId,pageId,value,today_date,created_date) VALUES(".$_SESSION['UserInfo']['OrgID'].",".$_POST['questionId'].",".$_POST['subQuestionId'].",".$value.",'".$targetValue."','".date('Y-m-d',strtotime($_POST['Date']))."','".$date."')" ;
		//echo $SQL;


		
	$rsData = $objDB->sql_query($SQL);
	}

	echo "done";
}else if($acn == 'addDailyTargetCTS'){

	// echo "<pre>";
	// print_r($_POST);
	$SQL = "DELETE FROM baris_target WHERE OrgID = ".$_SESSION['UserInfo']['OrgID']." AND queId = ".$_POST['questionId']." AND subqueId = ".$_POST['subQuestionId']." AND today_date = '".date('Y-m-d',strtotime($_POST['Date']))."' ";
	$objDB->sql_query($SQL);

	$date	= date('Y-m-d H:i:s');
	$rsPagesId = explode(',', $_POST['pagesIDS']);
	foreach ($rsPagesId as $key => $value) {
		if(strtolower($_POST[$value.'1']) == "y"){
			$shift1 = '1';
		}else{
			$shift1 = '0';
		}
		if(strtolower($_POST[$value.'2']) == "y"){
			$shift2 = '1';
		}else{
			$shift2 = '0';
		}
		
		
		$targetValue = $shift1.','.$shift2;
	$SQL = "INSERT INTO baris_target (OrgID,queId,subqueId,pageId,value,today_date,created_date) VALUES(".$_SESSION['UserInfo']['OrgID'].",".$_POST['questionId'].",".$_POST['subQuestionId'].",".$value.",'".$targetValue."','".date('Y-m-d',strtotime($_POST['Date']))."','".$date."')" ;
		//echo $SQL;


		
	$rsData = $objDB->sql_query($SQL);
	}

	echo "done";
}else if($acn == 'addManPowerTarget'){

	// echo "<pre>";
	// print_r($_POST);
	$SQL = "DELETE FROM baris_target WHERE OrgID = ".$_SESSION['UserInfo']['OrgID']." AND queId = ".$_POST['questionId']." AND subqueId = ".$_POST['subQuestionId'];
	$objDB->sql_query($SQL);

	$date	= date('Y-m-d H:i:s');

	$rsParamIDS = explode(',', $_POST['paramIDS']);
	$rsParamChoiceCnt = explode(',', $_POST['paramChoiceCnt']);

	foreach ($rsParamIDS as $key => $value) {
		$targetValueArry = array();
		for ($i=1; $i <= $rsParamChoiceCnt[$key]; $i++) { 
			$targetValueArry[] = $_POST[$value.$i];
		}
		$targetValue = implode(",", $targetValueArry);
		$SQL = "INSERT INTO baris_target (OrgID,queId,subqueId,pageId,value,created_date) VALUES(".$_SESSION['UserInfo']['OrgID'].",".$_POST['questionId'].",".$_POST['subQuestionId'].",".$value.",'".$targetValue."','".$date."')" ;
		
		$rsData = $objDB->sql_query($SQL);	
	}
	echo "done";
	
}


?>