	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_start_end_time` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_start_end_time`(IN `p_ProcessID` VARCHAR(2000), IN `p_tbltempusagedetail_name` VARCHAR(50))
BEGIN
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

    set @stm1 = CONCAT('select 
   MAX(disconnect_time) as max_date,MIN(connect_time)  as min_date
   from RMCDR3.`' , p_tbltempusagedetail_name , '` where ProcessID = "' , p_ProcessID , '"');
   
   PREPARE stmt1 FROM @stm1;
    EXECUTE stmt1;
    DEALLOCATE PREPARE stmt1;
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateDefaultPrefix` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_updateDefaultPrefix`(IN `p_processId` INT, IN `p_tbltempusagedetail_name` VARCHAR(200))
BEGIN
	DECLARE v_pointer_ INT;	
	DECLARE v_partition_limit_ INT;
	
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail_(
		TempUsageDetailID int,
		prefix varchar(50),
		INDEX IX_TempUsageDetailID(`TempUsageDetailID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail2_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail2_(
		TempUsageDetailID int,
		prefix varchar(50),
		INDEX IX_TempUsageDetailID2(`TempUsageDetailID`)
	);
	

	/* find prefix from default codes and accounts doen't have active trunks */
	
	SET v_pointer_ = 0;
	SET v_partition_limit_ = 1000;
	SET @stm = CONCAT('
		SET @rowCount = (SELECT   COUNT(*)   FROM RMCDR3.' , p_tbltempusagedetail_name , '  ud LEFT JOIN tmp_Accounts_ a ON a.AccountID = ud.AccountID WHERE a.AccountID IS NULL AND ProcessID = "' , p_processId , '"  );
	');
	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;
	
	WHILE v_pointer_ <= @rowCount
	DO
		
			
		DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetailPart_;
		CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetailPart_(
			TempUsageDetailID int,
			cld varchar(500),
			INDEX IX_TempUsageDetailID(`TempUsageDetailID`),
			INDEX IX_cld(`cld`)
		);
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetailPart_
		SELECT 
			TempUsageDetailID,
			cld
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
		LEFT JOIN tmp_Accounts_ a
			ON a.AccountID = ud.AccountID
		WHERE a.AccountID IS NULL 
			AND ProcessID = "' , p_processId , '"  
			AND area_prefix = "Other"  
		LIMIT ',v_partition_limit_,' OFFSET ',v_pointer_,';
		');
		PREPARE stmt FROM @stm;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;
		
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempUsageDetailID,
			c.code AS prefix
		FROM tmp_TempUsageDetailPart_ ud
		INNER JOIN Ratemanagement3.tmp_codes_ c 
			ON  cld like  CONCAT(c.Code,"%");
			
		SET v_pointer_ = v_pointer_ + v_partition_limit_;
		
	END WHILE;
	
	


	INSERT INTO tmp_TempUsageDetail2_
	SELECT tbl.TempUsageDetailID,MAX(tbl.prefix)  
	FROM tmp_TempUsageDetail_ tbl
	GROUP BY tbl.TempUsageDetailID;

	SET @stm = CONCAT('UPDATE RMCDR3.' , p_tbltempusagedetail_name , ' tbl2
	INNER JOIN tmp_TempUsageDetail2_ tbl
		ON tbl2.TempUsageDetailID = tbl.TempUsageDetailID
	SET area_prefix = prefix
	WHERE tbl2.processId = "' , p_processId , '"
	');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;     

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateDefaultVendorPrefix` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_updateDefaultVendorPrefix`(IN `p_processId` INT, IN `p_tbltempusagedetail_name` VARCHAR(200))
BEGIN
	DECLARE v_pointer_ INT;	
	DECLARE v_partition_limit_ INT;
	
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail_(
		TempVendorCDRID int,
		prefix varchar(50),
		INDEX IX_TempVendorCDRID(`TempVendorCDRID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail2_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail2_(
		TempVendorCDRID int,
		prefix varchar(50),
		INDEX IX_TempVendorCDRID2(`TempVendorCDRID`)
	);
	

	/* find prefix from default codes and accounts doen't have active trunks */
	
	SET v_pointer_ = 0;
	SET v_partition_limit_ = 1000;
	SET @stm = CONCAT('
		SET @rowCount = (SELECT   COUNT(*)   FROM RMCDR3.' , p_tbltempusagedetail_name , '  ud LEFT JOIN tmp_Accounts_ a ON a.AccountID = ud.AccountID WHERE a.AccountID IS NULL AND ProcessID = "' , p_processId , '"  );
	');
	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;
	
	WHILE v_pointer_ <= @rowCount
	DO
		
			
		DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetailPart_;
		CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetailPart_(
			TempVendorCDRID int,
			cld varchar(500),
			INDEX IX_TempVendorCDRID(`TempVendorCDRID`),
			INDEX IX_cld(`cld`)
		);
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetailPart_
		SELECT 
			TempVendorCDRID,
			cld
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
		LEFT JOIN tmp_Accounts_ a
			ON a.AccountID = ud.AccountID
		WHERE a.AccountID IS NULL 
			AND ProcessID = "' , p_processId , '"  
			AND area_prefix = "Other"  
		LIMIT ',v_partition_limit_,' OFFSET ',v_pointer_,';
		');
		PREPARE stmt FROM @stm;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;
		
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempVendorCDRID,
			c.code AS prefix
		FROM tmp_TempUsageDetailPart_ ud
		INNER JOIN Ratemanagement3.tmp_codes_ c 
			ON  cld like  CONCAT(c.Code,"%");
			
		SET v_pointer_ = v_pointer_ + v_partition_limit_;
		
	END WHILE;
	
	


	INSERT INTO tmp_TempUsageDetail2_
	SELECT tbl.TempVendorCDRID,MAX(tbl.prefix)  
	FROM tmp_TempUsageDetail_ tbl
	GROUP BY tbl.TempVendorCDRID;

	SET @stm = CONCAT('UPDATE RMCDR3.' , p_tbltempusagedetail_name , ' tbl2
	INNER JOIN tmp_TempUsageDetail2_ tbl
		ON tbl2.TempVendorCDRID = tbl.TempVendorCDRID
	SET area_prefix = prefix
	WHERE tbl2.processId = "' , p_processId , '"
	');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;     

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateInboundPrefix` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_updateInboundPrefix`(
	IN `p_AccountID` INT,
	IN `p_processId` INT,
	IN `p_tbltempusagedetail_name` VARCHAR(200),
	IN `p_CLD` VARCHAR(500),
	IN `p_ServiceID` INT
)
BEGIN

	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail_(
		TempUsageDetailID int,
		prefix varchar(50),
		INDEX IX_TempUsageDetailID(`TempUsageDetailID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail2_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail2_(
		TempUsageDetailID int,
		prefix varchar(50),
		INDEX IX_TempUsageDetailID2(`TempUsageDetailID`)
	);

	IF p_CLD != ''
	THEN 
		
		/* find prefix */
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempUsageDetailID,
			c.code AS prefix
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud 
		INNER JOIN Ratemanagement3.tmp_inboundcodes_ c 
		ON ud.ProcessID = ' , p_processId , '
			AND ud.is_inbound = 1 
			AND ud.AccountID = ' , p_AccountID , '
			AND ("' , p_CLD , '" = "" OR cld = "' , p_CLD , '")
			AND ud.area_prefix = "Other"
			AND cli like  CONCAT(c.Code,"%");
		');
		
	ELSE
		
		/* find prefix */
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempUsageDetailID,
			c.code AS prefix
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud 
		INNER JOIN Ratemanagement3.tmp_inboundcodes_ c 
		ON ud.ProcessID = ' , p_processId , '
			AND ud.is_inbound = 1 
			AND ud.AccountID = ' , p_AccountID , '
			AND ud.ServiceID = ' , p_ServiceID , '
			AND ud.area_prefix = "Other"
			AND cld like  CONCAT(c.Code,"%");
		');
	
	END IF;

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	SET @stm = CONCAT('INSERT INTO tmp_TempUsageDetail2_
	SELECT tbl.TempUsageDetailID,MAX(tbl.prefix)  
	FROM tmp_TempUsageDetail_ tbl
	GROUP BY tbl.TempUsageDetailID;');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	SET @stm = CONCAT('UPDATE RMCDR3.' , p_tbltempusagedetail_name , ' tbl2
	INNER JOIN tmp_TempUsageDetail2_ tbl
		ON tbl2.TempUsageDetailID = tbl.TempUsageDetailID
	SET area_prefix = prefix
	WHERE tbl2.processId = "' , p_processId , '"
	');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateInboundRate` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_updateInboundRate`(
	IN `p_AccountID` INT,
	IN `p_processId` INT,
	IN `p_tbltempusagedetail_name` VARCHAR(200),
	IN `p_CLD` VARCHAR(500),
	IN `p_ServiceID` INT
)
BEGIN

	SET @stm = CONCAT('UPDATE   RMCDR3.`' , p_tbltempusagedetail_name , '` ud SET cost = 0,is_rerated=0  WHERE ProcessID = "',p_processId,'" AND AccountID = "',p_AccountID ,'" AND ServiceID = "',p_ServiceID ,'" AND ("' , p_CLD , '" = "" OR cld = "' , p_CLD , '") AND is_inbound = 1 ') ;

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	SET @stm = CONCAT('
	UPDATE   RMCDR3.`' , p_tbltempusagedetail_name , '` ud 
	INNER JOIN Ratemanagement3.tmp_inboundcodes_ cr ON cr.Code = ud.area_prefix
	SET cost = 
		CASE WHEN  billed_second >= Interval1
		THEN
			(Rate/60.0)*Interval1+CEILING((billed_second-Interval1)/IntervalN)*(Rate/60.0)*IntervalN+IFNULL(ConnectionFee,0)
		ElSE
			CASE WHEN  billed_second > 0
			THEN
				Rate+IFNULL(ConnectionFee,0)
			ELSE
				0
			END
		END
	,is_rerated=1
	,duration=billed_second
	,billed_duration =
		CASE WHEN  billed_second >= Interval1
		THEN
			Interval1+CEILING((billed_second-Interval1)/IntervalN)*IntervalN
		ElSE 
			CASE WHEN  billed_second > 0
			THEN
				Interval1
			ELSE
				0
			END
		END 
	WHERE ProcessID = "',p_processId,'"
	AND AccountID = "',p_AccountID ,'"
	AND ServiceID = "',p_ServiceID ,'"
	AND ("' , p_CLD , '" = "" OR cld = "' , p_CLD , '")
	AND is_inbound = 1') ;
	
	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateOutboundRate` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_updateOutboundRate`(
	IN `p_AccountID` INT,
	IN `p_TrunkID` INT,
	IN `p_processId` INT,
	IN `p_tbltempusagedetail_name` VARCHAR(200),
	IN `p_ServiceID` INT
)
BEGIN

	SET @stm = CONCAT('UPDATE   RMCDR3.`' , p_tbltempusagedetail_name , '` ud SET cost = 0,is_rerated=0  WHERE ProcessID = "',p_processId,'" AND AccountID = "',p_AccountID ,'" AND ServiceID = "',p_ServiceID ,'" AND ("',p_TrunkID ,'" = 0 OR TrunkID = "',p_TrunkID ,'") AND is_inbound = 0 ') ;

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	SET @stm = CONCAT('
	UPDATE   RMCDR3.`' , p_tbltempusagedetail_name , '` ud 
	INNER JOIN Ratemanagement3.tmp_codes_ cr ON cr.Code = ud.area_prefix
	SET cost = 
		CASE WHEN  billed_second >= Interval1
		THEN
			(Rate/60.0)*Interval1+CEILING((billed_second-Interval1)/IntervalN)*(Rate/60.0)*IntervalN+IFNULL(ConnectionFee,0)
		ElSE
			CASE WHEN  billed_second > 0
			THEN
				Rate+IFNULL(ConnectionFee,0)
			ELSE
				0
			END
		END
	,is_rerated=1
	,duration = billed_second
	,billed_duration =
		CASE WHEN  billed_second >= Interval1
		THEN
			Interval1+CEILING((billed_second-Interval1)/IntervalN)*IntervalN
		ElSE 
			CASE WHEN  billed_second > 0
			THEN
				Interval1
			ELSE
				0
			END
		END 
	WHERE ProcessID = "',p_processId,'"
	AND AccountID = "',p_AccountID ,'" 
	AND ServiceID = "',p_ServiceID ,'" 
	AND ("',p_TrunkID ,'" = 0 OR TrunkID = "',p_TrunkID ,'")
	AND is_inbound = 0') ;

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updatePrefix` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_updatePrefix`(
	IN `p_AccountID` INT,
	IN `p_TrunkID` INT,
	IN `p_processId` INT,
	IN `p_tbltempusagedetail_name` VARCHAR(200),
	IN `p_ServiceID` INT
)
BEGIN

	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail_(
		TempUsageDetailID int,
		prefix varchar(50),
		INDEX IX_TempUsageDetailID(`TempUsageDetailID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail2_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail2_(
		TempUsageDetailID int,
		prefix varchar(50),
		INDEX IX_TempUsageDetailID2(`TempUsageDetailID`)
	);

	IF p_TrunkID > 0
	THEN
		/* find prefix without use in billing */
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempUsageDetailID,
			c.code AS prefix
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
		INNER JOIN Ratemanagement3.tmp_codes_ c 
		ON ud.ProcessID = ' , p_processId , '
			AND ud.is_inbound = 0 
			AND ud.AccountID = ' , p_AccountID , '
			AND ud.TrunkID = ' , p_TrunkID , '
			AND ud.UseInBilling = 0
			AND ud.area_prefix = "Other"
			AND ( extension <> cld or extension IS NULL)
			AND cld REGEXP "^[0-9]+$"
			AND cld like  CONCAT(c.Code,"%");
		');

		PREPARE stmt FROM @stm;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;

		/* find prefix with use in billing */
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempUsageDetailID,
			c.code AS prefix
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
		INNER JOIN Ratemanagement3.tmp_codes_ c 
		ON ud.ProcessID = ' , p_processId , '
			AND ud.is_inbound = 0
			AND ud.AccountID = ' , p_AccountID , '
			AND ud.TrunkID = ' , p_TrunkID , '
			AND ud.UseInBilling = 1 
			AND ud.area_prefix = "Other"
			AND ( extension <> cld or extension IS NULL)
			AND cld REGEXP "^[0-9]+$"
			AND cld like  CONCAT(ud.TrunkPrefix,c.Code,"%");
		');

		PREPARE stmt FROM @stm;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;

	ELSE

		/* find prefix */
		SET @stm = CONCAT('
		INSERT INTO tmp_TempUsageDetail_
		SELECT
			TempUsageDetailID,
			c.code AS prefix
		FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
		INNER JOIN Ratemanagement3.tmp_codes_ c 
		ON ud.ProcessID = ' , p_processId , '
			AND ud.is_inbound = 0 
			AND ud.AccountID = ' , p_AccountID , '
			AND ud.ServiceID = ' , p_ServiceID , '
			AND ud.area_prefix = "Other"
			AND ( extension <> cld or extension IS NULL)
			AND cld REGEXP "^[0-9]+$"
			AND cld like  CONCAT(c.Code,"%");
		');

		PREPARE stmt FROM @stm;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;

	END IF;

	PREPARE stm FROM @stm;
	EXECUTE stm;
	DEALLOCATE PREPARE stm;

	INSERT INTO tmp_TempUsageDetail2_
	SELECT tbl.TempUsageDetailID,MAX(tbl.prefix)  
	FROM tmp_TempUsageDetail_ tbl
	GROUP BY tbl.TempUsageDetailID;

	SET @stm = CONCAT('UPDATE RMCDR3.' , p_tbltempusagedetail_name , ' tbl2
	INNER JOIN tmp_TempUsageDetail2_ tbl
		ON tbl2.TempUsageDetailID = tbl.TempUsageDetailID
	SET area_prefix = prefix
	WHERE tbl2.processId = "' , p_processId , '"
	');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;     

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateSOAOffSet` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_updateSOAOffSet`(
	IN `p_CompanyID` INT,
	IN `p_AccountID` INT
)
BEGIN
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	DROP TEMPORARY TABLE IF EXISTS tmp_AccountSOA;
	CREATE TEMPORARY TABLE tmp_AccountSOA (
		AccountID INT,
		Amount NUMERIC(18, 8),
		PaymentType VARCHAR(50),
		InvoiceType int
	);
	
	DROP TEMPORARY TABLE IF EXISTS tmp_AccountSOABal;
	CREATE TEMPORARY TABLE tmp_AccountSOABal (
		AccountID INT,
		Amount NUMERIC(18, 8)
	);

     -- 1 Invoices
	INSERT into tmp_AccountSOA(AccountID,Amount,InvoiceType)
	SELECT
		tblInvoice.AccountID,
		tblInvoice.GrandTotal,
		tblInvoice.InvoiceType
	FROM tblInvoice
	WHERE tblInvoice.CompanyID = p_CompanyID
	AND ( (tblInvoice.InvoiceType = 2) OR ( tblInvoice.InvoiceType = 1 AND tblInvoice.InvoiceStatus NOT IN ( 'cancel' , 'draft' , 'awaiting') )  )
	AND (p_AccountID = 0 OR  tblInvoice.AccountID = p_AccountID);

     -- 2 Payments
	INSERT into tmp_AccountSOA(AccountID,Amount,PaymentType)
	SELECT
		tblPayment.AccountID,
		tblPayment.Amount,
		tblPayment.PaymentType
	FROM tblPayment
	WHERE tblPayment.CompanyID = p_CompanyID
	AND tblPayment.Status = 'Approved'
	AND tblPayment.Recall = 0
	AND (p_AccountID = 0 OR  tblPayment.AccountID = p_AccountID);
	
	INSERT INTO tmp_AccountSOABal
	SELECT AccountID,(SUM(IF(InvoiceType=1,Amount,0)) -  SUM(IF(PaymentType='Payment In',Amount,0))) - (SUM(IF(InvoiceType=2,Amount,0)) - SUM(IF(PaymentType='Payment Out',Amount,0))) as SOAOffSet 
	FROM tmp_AccountSOA 
	GROUP BY AccountID;
	
	INSERT INTO tmp_AccountSOABal
	SELECT DISTINCT tblAccount.AccountID ,0 FROM Ratemanagement3.tblAccount
	LEFT JOIN tmp_AccountSOA ON tblAccount.AccountID = tmp_AccountSOA.AccountID
	WHERE tblAccount.CompanyID = p_CompanyID
	AND tmp_AccountSOA.AccountID IS NULL
	AND (p_AccountID = 0 OR  tblAccount.AccountID = p_AccountID);
	
	UPDATE Ratemanagement3.tblAccountBalance
	INNER JOIN tmp_AccountSOABal 
		ON  tblAccountBalance.AccountID = tmp_AccountSOABal.AccountID
	SET SOAOffset=tmp_AccountSOABal.Amount;
	
	UPDATE Ratemanagement3.tblAccountBalance SET tblAccountBalance.BalanceAmount = COALESCE(tblAccountBalance.SOAOffset,0) + COALESCE(tblAccountBalance.UnbilledAmount,0)  - COALESCE(tblAccountBalance.VendorUnbilledAmount,0);
	
	INSERT INTO Ratemanagement3.tblAccountBalance (AccountID,BalanceAmount,UnbilledAmount,SOAOffset)
	SELECT tmp_AccountSOABal.AccountID,tmp_AccountSOABal.Amount,0,tmp_AccountSOABal.Amount
	FROM tmp_AccountSOABal 
	LEFT JOIN Ratemanagement3.tblAccountBalance
		ON tblAccountBalance.AccountID = tmp_AccountSOABal.AccountID
	WHERE tblAccountBalance.AccountID IS NULL;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateVendorPrefix` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_updateVendorPrefix`(IN `p_AccountID` INT, IN `p_TrunkID` INT, IN `p_processId` INT, IN `p_tbltempusagedetail_name` VARCHAR(200))
BEGIN

	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail_(
		TempVendorCDRID int,
		prefix varchar(50),
		INDEX IX_TempVendorCDRID(`TempVendorCDRID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_TempUsageDetail2_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_TempUsageDetail2_(
		TempVendorCDRID int,
		prefix varchar(50),
		INDEX IX_TempVendorCDRID2(`TempVendorCDRID`)
	);

	
	SET @stm = CONCAT('
	INSERT INTO tmp_TempUsageDetail_
	SELECT
		TempVendorCDRID,
		c.code AS prefix
	FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
	INNER JOIN Ratemanagement3.tmp_vcodes_ c 
	ON ud.ProcessID = ' , p_processId , '
		AND ud.AccountID = ' , p_AccountID , '
		AND ud.TrunkID = ' , p_TrunkID , '
		AND ud.UseInBilling = 0
		AND ud.area_prefix = "Other"
		AND cld like  CONCAT(c.Code,"%");
	');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	
	SET @stm = CONCAT('
	INSERT INTO tmp_TempUsageDetail_
	SELECT
		TempVendorCDRID,
		c.code AS prefix
	FROM RMCDR3.' , p_tbltempusagedetail_name , ' ud
	INNER JOIN Ratemanagement3.tmp_vcodes_ c 
	ON ud.ProcessID = ' , p_processId , '
		AND ud.AccountID = ' , p_AccountID , '
		AND ud.TrunkID = ' , p_TrunkID , '
		AND ud.UseInBilling = 1 
		AND ud.area_prefix = "Other"
		AND cld like  CONCAT(ud.TrunkPrefix,c.Code,"%");
	');

	PREPARE stm FROM @stm;
	EXECUTE stm;
	DEALLOCATE PREPARE stm;

	SET @stm = CONCAT('INSERT INTO tmp_TempUsageDetail2_
	SELECT tbl.TempVendorCDRID,MAX(tbl.prefix)  
	FROM tmp_TempUsageDetail_ tbl
	GROUP BY tbl.TempVendorCDRID;');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	SET @stm = CONCAT('UPDATE RMCDR3.' , p_tbltempusagedetail_name , ' tbl2
	INNER JOIN tmp_TempUsageDetail2_ tbl
		ON tbl2.TempVendorCDRID = tbl.TempVendorCDRID
	SET area_prefix = prefix
	WHERE tbl2.processId = "' , p_processId , '"
	');

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;     

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateVendorRate` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_updateVendorRate`(IN `p_AccountID` INT, IN `p_TrunkID` INT, IN `p_processId` INT, IN `p_tbltempusagedetail_name` VARCHAR(200))
BEGIN
	
	SET @stm = CONCAT('UPDATE   RMCDR3.`' , p_tbltempusagedetail_name , '` ud SET selling_cost = 0,is_rerated=0  WHERE ProcessID = "',p_processId,'" AND AccountID = "',p_AccountID ,'" AND TrunkID = "',p_TrunkID ,'"') ;

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

	SET @stm = CONCAT('
	UPDATE   RMCDR3.`' , p_tbltempusagedetail_name , '` ud 
	INNER JOIN Ratemanagement3.tmp_vcodes_ cr ON cr.Code = ud.area_prefix
	SET selling_cost = 
		CASE WHEN  billed_second >= Interval1
		THEN
			(Rate/60.0)*Interval1+CEILING((billed_second-Interval1)/IntervalN)*(Rate/60.0)*IntervalN+IFNULL(ConnectionFee,0)
		ElSE
			CASE WHEN  billed_second > 0
			THEN
				Rate+IFNULL(ConnectionFee,0)
			ELSE
				0
			END		    
		END
	,is_rerated=1
	,duration=billed_second
	,billed_duration =
		CASE WHEN  billed_second >= Interval1
		THEN
			Interval1+CEILING((billed_second-Interval1)/IntervalN)*IntervalN
		ElSE 
			CASE WHEN  billed_second > 0
			THEN
				Interval1
			ELSE
				0
			END
		END
	WHERE ProcessID = "',p_processId,'"
	AND AccountID = "',p_AccountID ,'" 
	AND TrunkID = "',p_TrunkID ,'"') ;

	PREPARE stmt FROM @stm;
	EXECUTE stmt;
	DEALLOCATE PREPARE stmt;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_validatePayments` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_validatePayments`(
	IN `p_CompanyID` INT,
	IN `p_ProcessID` VARCHAR(50)

)
BEGIN

SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET SESSION group_concat_max_len=5000;


	DROP TEMPORARY TABLE IF EXISTS tmp_error_;
	CREATE TEMPORARY TABLE tmp_error_(
		`ErrorMessage` VARCHAR(500)
	);
	
		INSERT INTO tmp_error_	
	SELECT DISTINCT CONCAT('Future payments will not be uploaded - Account: ',IFNULL(ac.AccountName,''),' Action: ' ,IFNULL(pt.PaymentType,''),' Payment Date: ',IFNULL(pt.PaymentDate,''),' Amount: ',pt.Amount) as ErrorMessage
	FROM tblTempPayment pt
	INNER JOIN Ratemanagement3.tblAccount ac on ac.AccountID = pt.AccountID
	WHERE pt.CompanyID = p_CompanyID
		AND pt.PaymentDate > NOW()
		AND pt.ProcessID = p_ProcessID;

	INSERT INTO tmp_error_
	SELECT distinct CONCAT('Duplicate payment in file - Account: ',IFNULL(ac.AccountName,''),' Action: ' ,IFNULL(pt.PaymentType,''),' Payment Date: ',IFNULL(pt.PaymentDate,''),' Amount: ',pt.Amount) as ErrorMessage  
	FROM tblTempPayment pt
	INNER JOIN Ratemanagement3.tblAccount ac on ac.AccountID = pt.AccountID
	INNER JOIN tblTempPayment tp on tp.ProcessID = pt.ProcessID
		AND tp.AccountID = pt.AccountID
		AND tp.PaymentDate = pt.PaymentDate
		AND tp.Amount = pt.Amount
		AND tp.PaymentType = pt.PaymentType
		AND tp.PaymentMethod = pt.PaymentMethod
	WHERE pt.CompanyID = p_CompanyID
		AND pt.ProcessID = p_ProcessID
 	GROUP BY pt.InvoiceNo,pt.AccountID,pt.PaymentDate,pt.PaymentType,pt.PaymentMethod,pt.Amount having count(*)>=2;
 	
	INSERT INTO tmp_error_	
	SELECT DISTINCT
		CONCAT('Duplicate payment in system - Account: ',IFNULL(ac.AccountName,''),' Action: ' ,IFNULL(pt.PaymentType,''),' Payment Date: ',IFNULL(pt.PaymentDate,''),' Amount: ',pt.Amount) as ErrorMessage
	FROM tblTempPayment pt
	INNER JOIN Ratemanagement3.tblAccount ac on ac.AccountID = pt.AccountID
	INNER JOIN tblPayment p on p.CompanyID = pt.CompanyID 
		AND p.AccountID = pt.AccountID
		AND p.PaymentDate = pt.PaymentDate
		AND p.Amount = pt.Amount
		AND p.PaymentType = pt.PaymentType
		AND p.Recall = 0
	WHERE pt.CompanyID = p_CompanyID
		AND pt.ProcessID = p_ProcessID;
		
		
		INSERT INTO tmp_error_	
	SELECT DISTINCT
		CONCAT('Currency Not Set - Account: ',IFNULL(ac.AccountName,''),' Action: ' ,IFNULL(pt.PaymentType,''),' Payment Date: ',IFNULL(pt.PaymentDate,''),' Amount: ',pt.Amount) as ErrorMessage
	FROM tblTempPayment pt
	INNER JOIN Ratemanagement3.tblAccount ac on ac.AccountID = pt.AccountID
			and ac.AccountType = 1
		WHERE pt.CompanyID = p_CompanyID
		   AND ac.CurrencyId IS NULL
			AND pt.ProcessID = p_ProcessID;
	
	
	IF (SELECT COUNT(*) FROM tmp_error_) > 0
	THEN
	SELECT GROUP_CONCAT(ErrorMessage SEPARATOR "\r\n" ) as ErrorMessage FROM	tmp_error_;
		
	END IF;
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
END ;;
DELIMITER ;

--
-- Current Database: `RMCDR3`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `RMCDR3` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;

USE `RMCDR3`;

--
-- Table structure for table `tblCDRPostProcess`
--

CREATE TABLE `tblCDRPostProcess` (
  `CDRPostProcessID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`CDRPostProcessID`),
  KEY `IX_tblCDRPostProcess_PID_AID` (`ProcessID`,`AccountID`),
  KEY `IX_tblCDRPostProcess_CID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_110`
--

CREATE TABLE `tblTempUsageDetail_110` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_110PID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_116`
--

CREATE TABLE `tblTempUsageDetail_116` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_116PID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_117`
--

CREATE TABLE `tblTempUsageDetail_117` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_117PID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_117cdr`
--

CREATE TABLE `tblTempUsageDetail_117cdr` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_117cdrPID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_119`
--

CREATE TABLE `tblTempUsageDetail_119` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_119PID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_15`
--

CREATE TABLE `tblTempUsageDetail_15` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_15PID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempUsageDetail_15recal`
--

CREATE TABLE `tblTempUsageDetail_15recal` (
  `TempUsageDetailID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `is_rerated` tinyint(1) DEFAULT '0',
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TempUsageDetailID`),
  KEY `IX_tblTempUsageDetail_15recalPID_I_AID` (`ProcessID`,`is_inbound`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempVendorCDR_116`
--

CREATE TABLE `tblTempVendorCDR_116` (
  `TempVendorCDRID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `selling_cost` double DEFAULT NULL,
  `buying_cost` double DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `is_rerated` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`TempVendorCDRID`),
  KEY `IX_tblTempVendorCDR_116PID_I_AID` (`ProcessID`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblTempVendorCDR_119`
--

CREATE TABLE `tblTempVendorCDR_119` (
  `TempVendorCDRID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountNumber` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountCLI` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountIP` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  `selling_cost` double DEFAULT NULL,
  `buying_cost` double DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TrunkPrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `is_rerated` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`TempVendorCDRID`),
  KEY `IX_tblTempVendorCDR_119PID_I_AID` (`ProcessID`,`AccountID`),
  KEY `IX_U` (`AccountName`,`AccountNumber`,`AccountCLI`,`AccountIP`,`CompanyGatewayID`,`ServiceID`,`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageDetailFailedCall`
--

CREATE TABLE `tblUsageDetailFailedCall` (
  `UsageDetailFailedCallID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `UsageHeaderID` int(11) NOT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ProcessID` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `billed_second` int(11) DEFAULT NULL,
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`UsageDetailFailedCallID`),
  KEY `IX_ID` (`ID`),
  KEY `IX_UsageHeaderID` (`UsageHeaderID`),
  KEY `IX_ProcessID` (`ProcessID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageDetails`
--

CREATE TABLE `tblUsageDetails` (
  `UsageDetailID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `UsageHeaderID` int(11) NOT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cost` decimal(18,6) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ProcessID` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `is_inbound` tinyint(1) DEFAULT '0',
  `billed_second` int(11) DEFAULT NULL,
  `disposition` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`UsageDetailID`),
  KEY `IXUsageDetailCMP_GaTGatACPrID` (`UsageHeaderID`),
  KEY `Index_ID` (`ID`),
  KEY `Index_ProcessID` (`ProcessID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageHeader`
--

CREATE TABLE `tblUsageHeader` (
  `UsageHeaderID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `StartDate` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT '0',
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  PRIMARY KEY (`UsageHeaderID`),
  KEY `Index_Com_GA_CG_A` (`CompanyID`,`GatewayAccountID`,`CompanyGatewayID`,`AccountID`),
  KEY `Index_A_STD_CG` (`AccountID`,`StartDate`,`CompanyGatewayID`),
  KEY `IX_GAID` (`GatewayAccountPKID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblVCDRPostProcess`
--

CREATE TABLE `tblVCDRPostProcess` (
  `VCDRPostProcessID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `TrunkID` int(11) DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `UseInBilling` tinyint(1) DEFAULT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extension` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `selling_cost` double DEFAULT NULL,
  `buying_cost` double DEFAULT NULL,
  `ProcessID` bigint(20) unsigned DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  PRIMARY KEY (`VCDRPostProcessID`),
  KEY `IX_tblVCDRPostProcess_PID_AID` (`ProcessID`,`AccountID`),
  KEY `IX_tblVCDRPostProcess_CID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblVendorCDR`
--

CREATE TABLE `tblVendorCDR` (
  `VendorCDRID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `VendorCDRHeaderID` int(11) NOT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `selling_cost` double DEFAULT NULL,
  `buying_cost` double DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ProcessID` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorCDRID`),
  KEY `IX_ProcessID` (`ProcessID`),
  KEY `IX_VendorCDRHeaderID` (`VendorCDRHeaderID`,`connect_time`,`disconnect_time`),
  KEY `Index 4` (`connect_time`),
  KEY `IX_ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblVendorCDRFailed`
--

CREATE TABLE `tblVendorCDRFailed` (
  `VendorCDRFailedID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `VendorCDRHeaderID` int(11) NOT NULL,
  `connect_time` datetime DEFAULT NULL,
  `disconnect_time` datetime DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `ID` int(11) DEFAULT NULL,
  `selling_cost` double DEFAULT NULL,
  `buying_cost` double DEFAULT NULL,
  `cli` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `cld` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `remote_ip` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ProcessID` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billed_second` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorCDRFailedID`),
  KEY `IX_VendorCDRHeaderID` (`VendorCDRHeaderID`),
  KEY `IX_ProcessID` (`ProcessID`),
  KEY `IX_ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblVendorCDRHeader`
--

CREATE TABLE `tblVendorCDRHeader` (
  `VendorCDRHeaderID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `StartDate` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT '0',
  `GatewayAccountPKID` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorCDRHeaderID`),
  KEY `Index_C_CG_A_GA` (`CompanyID`,`CompanyGatewayID`,`GatewayAccountID`,`AccountID`),
  KEY `Index_A_S_CG` (`AccountID`,`StartDate`,`CompanyGatewayID`),
  KEY `IX_GAID` (`GatewayAccountPKID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping routines for database 'RMCDR3'
--
/*!50003 DROP PROCEDURE IF EXISTS `prc_deleteCustomerCDRByRetention` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_deleteCustomerCDRByRetention`(IN `p_CompanyID` INT, IN `p_DeleteDate` DATETIME)
BEGIN
 	
 	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	-- DELETE all Record of customer cdr by date
	
	-- DELETE tblUsageDetails table
	DELETE tblUsageDetails
	 FROM tblUsageDetails
		 INNER JOIN tblUsageHeader
		 	 ON tblUsageDetails.UsageHeaderID = tblUsageHeader.UsageHeaderID
	 WHERE StartDate = p_DeleteDate
	  AND CompanyID = p_CompanyID;
	 
	 -- DELETE tblUsageDetailFailedCall table
	 
	 DELETE tblUsageDetailFailedCall
	  FROM tblUsageDetailFailedCall
	 	 INNER JOIN tblUsageHeader
		  	 ON tblUsageDetailFailedCall.UsageHeaderID = tblUsageHeader.UsageHeaderID
	 WHERE StartDate = p_DeleteDate
	  AND CompanyID = p_CompanyID;
	
	-- DELETE tblUsageHeader table
	
	DELETE FROM tblUsageHeader
	 WHERE StartDate = p_DeleteDate
	  AND CompanyID = p_CompanyID;
		
   SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_DeleteDuplicateUniqueID` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_DeleteDuplicateUniqueID`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_ProcessID` VARCHAR(200), IN `p_tbltempusagedetail_name` VARCHAR(200))
BEGIN
 	
 	SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

	SET @stm1 = CONCAT('DELETE tud FROM     `' , p_tbltempusagedetail_name , '` tud
	INNER JOIN tblUsageDetails ud ON tud.ID =ud.ID
	INNER JOIN  tblUsageHeader uh on uh.UsageHeaderID = ud.UsageHeaderID
		AND tud.CompanyID = uh.CompanyID
		AND tud.CompanyGatewayID = uh.CompanyGatewayID
	WHERE
	 	  tud.CompanyID = "' , p_CompanyID , '"
	AND  tud.CompanyGatewayID = "' , p_CompanyGatewayID , '"
	AND  tud.ProcessID = "' , p_processId , '";
	');
	PREPARE stmt1 FROM @stm1;
   EXECUTE stmt1;
   DEALLOCATE PREPARE stmt1;
   
   SET @stm2 = CONCAT('DELETE tud FROM     `' , p_tbltempusagedetail_name , '` tud
	INNER JOIN tblUsageDetailFailedCall ud ON tud.ID =ud.ID
	INNER JOIN  tblUsageHeader uh on uh.UsageHeaderID = ud.UsageHeaderID
		AND tud.CompanyID = uh.CompanyID
		AND tud.CompanyGatewayID = uh.CompanyGatewayID
	WHERE  
		  tud.CompanyID = "' , p_CompanyID , '"
	AND  tud.CompanyGatewayID = "' , p_CompanyGatewayID , '"
	AND  tud.ProcessID = "' , p_processId , '";
	');
	PREPARE stmt2 FROM @stm2;
   EXECUTE stmt2;
   DEALLOCATE PREPARE stmt2;
	
   SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_DeleteDuplicateUniqueID2` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_DeleteDuplicateUniqueID2`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_ProcessID` VARCHAR(200), IN `p_tbltempusagedetail_name` VARCHAR(200))
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

	SET @stm1 = CONCAT('
		DELETE tud FROM `' , p_tbltempusagedetail_name , '` tud
		INNER JOIN tblVendorCDR ud ON tud.ID =ud.ID
		INNER JOIN  tblVendorCDRHeader uh on uh.VendorCDRHeaderID = ud.VendorCDRHeaderID
			AND tud.CompanyID = uh.CompanyID
			AND tud.CompanyGatewayID = uh.CompanyGatewayID
		WHERE tud.CompanyID = "' , p_CompanyID , '"
		AND tud.CompanyGatewayID = "' , p_CompanyGatewayID , '"
		AND tud.ProcessID = "' , p_processId , '";
	');
	PREPARE stmt1 FROM @stm1;
	EXECUTE stmt1;
	DEALLOCATE PREPARE stmt1;

	SET @stm2 = CONCAT('
		DELETE tud FROM `' , p_tbltempusagedetail_name , '` tud
		INNER JOIN tblVendorCDRFailed ud ON tud.ID =ud.ID
		INNER JOIN  tblVendorCDRHeader uh on uh.VendorCDRHeaderID = ud.VendorCDRHeaderID
			AND tud.CompanyID = uh.CompanyID
			AND tud.CompanyGatewayID = uh.CompanyGatewayID
		WHERE tud.CompanyID = "' , p_CompanyID , '"
		AND tud.CompanyGatewayID = "' , p_CompanyGatewayID , '"
		AND tud.ProcessID = "' , p_processId , '";
	');
	PREPARE stmt2 FROM @stm2;
	EXECUTE stmt2;
	DEALLOCATE PREPARE stmt2;
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_deleteVendorCDRByRetention` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_deleteVendorCDRByRetention`(IN `p_CompanyID` INT, IN `p_DeleteDate` DATETIME)
BEGIN
 	
 	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	-- DELETE all Record of vendor cdr by date
	
	-- DELETE tblVendorCDR table
	DELETE tblVendorCDR
	 FROM tblVendorCDR
		 INNER JOIN tblVendorCDRHeader
		 	 ON tblVendorCDR.VendorCDRHeaderID = tblVendorCDRHeader.VendorCDRHeaderID
	 WHERE StartDate = p_DeleteDate
	  AND CompanyID = p_CompanyID;
	 
	 -- DELETE tblVendorCDRFailed table
	 
	 DELETE tblVendorCDRFailed
	  FROM tblVendorCDRFailed
	 	 INNER JOIN tblVendorCDRHeader
		  	 ON tblVendorCDRFailed.VendorCDRHeaderID = tblVendorCDRHeader.VendorCDRHeaderID
	 WHERE StartDate = p_DeleteDate
	  AND CompanyID = p_CompanyID;
	
	-- DELETE tblVendorCDRHeader table
	
	DELETE FROM tblVendorCDRHeader
	 WHERE StartDate = p_DeleteDate
	  AND CompanyID = p_CompanyID;
		
   SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_insertCDR` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_insertCDR`(
	IN `p_processId` varchar(200),
	IN `p_tbltempusagedetail_name` VARCHAR(200)
)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

	SET SESSION innodb_lock_wait_timeout = 180;

	SET @stm2 = CONCAT('
	INSERT INTO   tblUsageHeader (CompanyID,CompanyGatewayID,GatewayAccountPKID,GatewayAccountID,AccountID,StartDate,created_at,ServiceID)
	SELECT DISTINCT d.CompanyID,d.CompanyGatewayID,d.GatewayAccountPKID,d.GatewayAccountID,d.AccountID,DATE_FORMAT(connect_time,"%Y-%m-%d"),NOW(),d.ServiceID
	FROM `' , p_tbltempusagedetail_name , '` d
	LEFT JOIN tblUsageHeader h
	ON h.GatewayAccountPKID = d.GatewayAccountPKID
		AND h.StartDate = DATE_FORMAT(connect_time,"%Y-%m-%d")
	WHERE h.GatewayAccountID IS NULL AND processid = "' , p_processId , '";
	');

	PREPARE stmt2 FROM @stm2;
	EXECUTE stmt2;
	DEALLOCATE PREPARE stmt2;

	SET @stm3 = CONCAT('
	INSERT INTO tblUsageDetailFailedCall (UsageHeaderID,connect_time,disconnect_time,billed_duration,billed_second,area_prefix,pincode,extension,cli,cld,cost,remote_ip,duration,trunk,ProcessID,ID,is_inbound,disposition)
	SELECT UsageHeaderID,connect_time,disconnect_time,billed_duration,billed_second,area_prefix,pincode,extension,cli,cld,cost,remote_ip,duration,trunk,ProcessID,ID,is_inbound,disposition
	FROM  `' , p_tbltempusagedetail_name , '` d
	INNER JOIN tblUsageHeader h
	ON h.GatewayAccountPKID = d.GatewayAccountPKID
		AND h.StartDate = DATE_FORMAT(connect_time,"%Y-%m-%d")
	WHERE   processid = "' , p_processId , '"
		AND billed_duration = 0 AND cost = 0 AND ( disposition <> "ANSWERED" OR disposition IS NULL);

	');

	PREPARE stmt3 FROM @stm3;
	EXECUTE stmt3;
	DEALLOCATE PREPARE stmt3;

	SET @stm4 = CONCAT('    
	DELETE FROM `' , p_tbltempusagedetail_name , '` WHERE processid = "' , p_processId , '"  AND billed_duration = 0 AND cost = 0 AND ( disposition <> "ANSWERED" OR disposition IS NULL);
	');

	PREPARE stmt4 FROM @stm4;
	EXECUTE stmt4;
	DEALLOCATE PREPARE stmt4;

	SET @stm5 = CONCAT(' 
	INSERT INTO tblUsageDetails (UsageHeaderID,connect_time,disconnect_time,billed_duration,billed_second,area_prefix,pincode,extension,cli,cld,cost,remote_ip,duration,trunk,ProcessID,ID,is_inbound,disposition)
	SELECT UsageHeaderID,connect_time,disconnect_time,billed_duration,billed_second,area_prefix,pincode,extension,cli,cld,cost,remote_ip,duration,trunk,ProcessID,ID,is_inbound,disposition
	FROM  `' , p_tbltempusagedetail_name , '` d
	INNER JOIN tblUsageHeader h
	ON h.GatewayAccountPKID = d.GatewayAccountPKID
		AND h.StartDate = DATE_FORMAT(connect_time,"%Y-%m-%d")
	WHERE   processid = "' , p_processId , '" ;
	');

	PREPARE stmt5 FROM @stm5;
	EXECUTE stmt5;
	DEALLOCATE PREPARE stmt5;

	SET @stm6 = CONCAT(' 
	DELETE FROM `' , p_tbltempusagedetail_name , '` WHERE processid = "' , p_processId , '" ;
	');

	PREPARE stmt6 FROM @stm6;
	EXECUTE stmt6;
	DEALLOCATE PREPARE stmt6;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_insertPostProcessCDR` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_insertPostProcessCDR`(IN `p_ProcessID` VarCHAR(200))
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	INSERT INTO tblCDRPostProcess(CompanyID,CompanyGatewayID,GatewayAccountID,AccountID,connect_time,disconnect_time,billed_duration,billed_second,area_prefix,pincode,extension,cli,cld,cost,remote_ip,duration,trunk,ProcessID,ID)
	SELECT
		CompanyID,
		CompanyGatewayID,
		GatewayAccountID,
		AccountID,
		connect_time,
		disconnect_time,
		billed_duration,
		billed_second,
		area_prefix,
		pincode,
		extension,
		cli,
		cld,
		cost,
		remote_ip,
		duration,
		trunk,
		ProcessID,
		ID
	FROM tblUsageDetails ud
	INNER JOIN tblUsageHeader uh
		ON uh.UsageHeaderID = ud.UsageHeaderID
	WHERE  uh.AccountID IS NOT NULL
		AND ud.ProcessID = p_ProcessID;
	
	INSERT INTO tblVCDRPostProcess(CompanyID,CompanyGatewayID,GatewayAccountID,AccountID,billed_duration,billed_second, ID, selling_cost, buying_cost, connect_time, disconnect_time,cli, cld,trunk,area_prefix,  remote_ip, ProcessID)
	SELECT
		CompanyID,
		CompanyGatewayID,
		GatewayAccountID,
		AccountID,
		billed_duration,
		billed_second, 
		ID, 
		selling_cost, 
		buying_cost, 
		connect_time, 
		disconnect_time,
		cli, 
		cld,
		trunk,
		area_prefix,  
		remote_ip, 
		ProcessID
	FROM tblVendorCDR ud
	INNER JOIN tblVendorCDRHeader uh
		ON uh.VendorCDRHeaderID = ud.VendorCDRHeaderID
	WHERE  uh.AccountID IS NOT NULL
		AND ud.ProcessID = p_ProcessID;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_insertVendorCDR` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_insertVendorCDR`(
	IN `p_processId` VARCHAR(200),
	IN `p_tbltempusagedetail_name` VARCHAR(50)
)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

	SET SESSION innodb_lock_wait_timeout = 180;

	SET @stm2 = CONCAT('
	INSERT INTO   tblVendorCDRHeader (CompanyID,CompanyGatewayID,GatewayAccountPKID,GatewayAccountID,AccountID,StartDate,created_at,ServiceID)
	SELECT DISTINCT d.CompanyID,d.CompanyGatewayID,d.GatewayAccountPKID,d.GatewayAccountID,d.AccountID,DATE_FORMAT(connect_time,"%Y-%m-%d"),NOW(),d.ServiceID
	FROM `' , p_tbltempusagedetail_name , '` d
	LEFT JOIN tblVendorCDRHeader h 
	ON h.GatewayAccountPKID = d.GatewayAccountPKID
		AND h.StartDate = DATE_FORMAT(connect_time,"%Y-%m-%d")
	WHERE h.GatewayAccountID IS NULL AND processid = "' , p_processId , '";
	');

	PREPARE stmt2 FROM @stm2;
	EXECUTE stmt2;
	DEALLOCATE PREPARE stmt2;

	SET @stm6 = CONCAT('
	INSERT INTO tblVendorCDRFailed (VendorCDRHeaderID,billed_duration,duration,billed_second, ID, selling_cost, buying_cost, connect_time, disconnect_time,cli, cld,trunk,area_prefix,  remote_ip, ProcessID)
	SELECT VendorCDRHeaderID,billed_duration,duration,billed_second, ID, selling_cost, buying_cost, connect_time, disconnect_time,cli, cld,trunk,area_prefix,  remote_ip, ProcessID
	FROM `' , p_tbltempusagedetail_name , '` d 
	INNER JOIN tblVendorCDRHeader h	 
	ON h.GatewayAccountPKID = d.GatewayAccountPKID
		AND h.StartDate = DATE_FORMAT(connect_time,"%Y-%m-%d")
	WHERE processid = "' , p_processId , '" AND  billed_duration = 0 AND buying_cost = 0 ;
	');

	PREPARE stmt6 FROM @stm6;
	EXECUTE stmt6;
	DEALLOCATE PREPARE stmt6;

	SET @stm3 = CONCAT('
	DELETE FROM `' , p_tbltempusagedetail_name , '` WHERE processid = "' , p_processId , '"  AND billed_duration = 0 AND buying_cost = 0;
	');
	
	PREPARE stmt3 FROM @stm3;
	EXECUTE stmt3;
	DEALLOCATE PREPARE stmt3;

	SET @stm4 = CONCAT('
	INSERT INTO tblVendorCDR (VendorCDRHeaderID,billed_duration,duration,billed_second, ID, selling_cost, buying_cost, connect_time, disconnect_time,cli, cld,trunk,area_prefix,  remote_ip, ProcessID)
	SELECT VendorCDRHeaderID,billed_duration,duration,billed_second, ID, selling_cost, buying_cost, connect_time, disconnect_time,cli, cld,trunk,area_prefix,  remote_ip, ProcessID
	FROM `' , p_tbltempusagedetail_name , '` d 
	INNER JOIN tblVendorCDRHeader h	 
	ON h.GatewayAccountPKID = d.GatewayAccountPKID
		AND h.StartDate = DATE_FORMAT(connect_time,"%Y-%m-%d")
	WHERE processid = "' , p_processId , '" ;
	');
	
	PREPARE stmt4 FROM @stm4;
	EXECUTE stmt4;
	DEALLOCATE PREPARE stmt4;

	SET @stm5 = CONCAT(' 
	DELETE FROM `' , p_tbltempusagedetail_name , '` WHERE processid = "' , p_processId , '" ;
	');
	
	PREPARE stmt5 FROM @stm5;
	EXECUTE stmt5;
	DEALLOCATE PREPARE stmt5;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_invoice_in_reconcile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_invoice_in_reconcile`(IN `p_CompanyID` INT, IN `p_AccountID` INT, IN `StartTime` DATETIME, IN `EndTime` DATETIME)
BEGIN


		SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
		
		select ifnull(sum(vc.buying_cost),0) as DisputeTotal , ifnull(sum(billed_duration),0) as DisputeMinutes 
		from tblVendorCDR vc
		inner join tblVendorCDRHeader vh on vh.VendorCDRHeaderID = vc.VendorCDRHeaderID
		where vh.CompanyID = p_CompanyID and vh.AccountID = p_AccountID 
		and connect_time >= StartTime and connect_time <= EndTime;
		
		SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_PostProcessCDR` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_PostProcessCDR`(IN `p_CompanyID` INT)
BEGIN

	DECLARE v_rowCount_ INT;
	DECLARE v_pointer_ INT;	
	DECLARE v_ProcessID_ VARCHAR(200);

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	DROP TEMPORARY TABLE IF EXISTS tmp_ProcessIDS;
	CREATE TEMPORARY TABLE tmp_ProcessIDS  (
		RowID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
		TempUsageDownloadLogID INT,
		ProcessID VARCHAR(200)
	);
	
	INSERT INTO tmp_ProcessIDS(TempUsageDownloadLogID,ProcessID)
	SELECT TempUsageDownloadLogID,ProcessID FROM  RMBilling3.tblTempUsageDownloadLog WHERE CompanyID = p_CompanyID AND PostProcessStatus=0 LIMIT 50;
	
	DELETE FROM tblCDRPostProcess WHERE CompanyID = p_CompanyID;
	DELETE FROM tblVCDRPostProcess WHERE CompanyID = p_CompanyID;
	
	SET v_pointer_ = 1;
	SET v_rowCount_ = (SELECT COUNT(*)FROM tmp_ProcessIDS);

	WHILE v_pointer_ <= v_rowCount_
	DO
		SET v_ProcessID_ = (SELECT ProcessID FROM tmp_ProcessIDS t WHERE t.RowID = v_pointer_);
		
		CALL prc_insertPostProcessCDR(v_ProcessID_); 
		
	SET v_pointer_ = v_pointer_ + 1;
	END WHILE;
	
	UPDATE tblCDRPostProcess 
	INNER JOIN  Ratemanagement3.tblCountry ON area_prefix LIKE CONCAT(Prefix , "%")
	SET tblCDRPostProcess.CountryID =tblCountry.CountryID
	WHERE tblCDRPostProcess.CompanyID = p_CompanyID;
	
	UPDATE tblVCDRPostProcess 
	INNER JOIN  Ratemanagement3.tblCountry ON area_prefix LIKE CONCAT(Prefix , "%")
	SET tblVCDRPostProcess.CountryID =tblCountry.CountryID
	WHERE tblVCDRPostProcess.CompanyID = p_CompanyID;
	
	SELECT * FROM tmp_ProcessIDS;
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_RetailMonitorCalls` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_RetailMonitorCalls`(
	IN `p_CompanyID` INT,
	IN `p_AccountID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_Type` VARCHAR(50)

)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	/* lognest duration call*/	
	IF p_Type = 'call_duraition'
	THEN

		SELECT 
			cli,
			cld,
			billed_duration  
		FROM tblUsageDetails  ud
		INNER JOIN tblUsageHeader uh
			ON uh.UsageHeaderID = ud.UsageHeaderID
		WHERE uh.CompanyID = p_CompanyID
		AND uh.AccountID IS NOT NULL
		AND (p_AccountID = 0 OR uh.AccountID = p_AccountID)
		AND StartDate BETWEEN p_StartDate AND p_EndDate
		ORDER BY billed_duration DESC LIMIT 10;

	END IF;

	/* most expensive call */	
	IF p_Type = 'call_cost'
	THEN

		SELECT 
			cli,
			cld,
			cost,
			billed_duration
		FROM tblUsageDetails  ud
		INNER JOIN tblUsageHeader uh
			ON uh.UsageHeaderID = ud.UsageHeaderID
		WHERE uh.CompanyID = p_CompanyID
		AND uh.AccountID IS NOT NULL
		AND (p_AccountID = 0 OR uh.AccountID = p_AccountID)
		AND StartDate BETWEEN p_StartDate AND p_EndDate
		ORDER BY cost DESC LIMIT 10;

	END IF;
	
	/* most dailed numner*/
	IF p_Type = 'most_dialed'
	THEN

		SELECT 
			cld,
			count(*) AS dail_count,
			SUM(billed_duration) AS billed_duration
		FROM tblUsageDetails  ud
		INNER JOIN tblUsageHeader uh
			ON uh.UsageHeaderID = ud.UsageHeaderID
		WHERE uh.CompanyID = p_CompanyID
		AND uh.AccountID IS NOT NULL
		AND (p_AccountID = 0 OR uh.AccountID = p_AccountID)
		AND StartDate BETWEEN p_StartDate AND p_EndDate
		GROUP BY cld
		ORDER BY dail_count DESC
		LIMIT 10;

	END IF;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_unsetCDRUsageAccount` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_unsetCDRUsageAccount`(
	IN `p_CompanyID` INT,
	IN `p_IPs` LONGTEXT,
	IN `p_StartDate` VARCHAR(100),
	IN `p_Confirm` INT,
	IN `p_ServiceID` INT
)
BEGIN

	DECLARE v_AccountID int;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SET v_AccountID = 0;
		SELECT DISTINCT GAC.AccountID INTO v_AccountID 
		FROM RMBilling3.tblGatewayAccount GAC
		WHERE GAC.CompanyID = p_CompanyID
		AND GAC.ServiceID = p_ServiceID
		AND AccountID IS NOT NULL
		AND  FIND_IN_SET(GAC.GatewayAccountID, p_IPs) > 0
		LIMIT 1;
	
	IF v_AccountID = 0
	THEN
		SELECT DISTINCT AccountID INTO v_AccountID FROM tblUsageHeader UH
			WHERE UH.CompanyID = p_CompanyID
			AND UH.ServiceID = p_ServiceID
			AND AccountID IS NOT NULL
			AND  FIND_IN_SET(UH.CompanyGatewayID, p_IPs) > 0
			LIMIT 1; 
	END IF;
	
	IF v_AccountID = 0
	THEN
		SELECT DISTINCT AccountID INTO v_AccountID FROM tblVendorCDRHeader VH
			WHERE VH.CompanyID = p_CompanyID
			AND VH.ServiceID = p_ServiceID
			AND AccountID IS NOT NULL
			AND  FIND_IN_SET(VH.GatewayAccountID, p_IPs) > 0
			LIMIT 1; 
	END IF;
	IF v_AccountID >0 AND p_Confirm = 1 THEN
			UPDATE RMBilling3.tblGatewayAccount GAC SET GAC.AccountID = NULL
			WHERE GAC.CompanyID = p_CompanyID
			AND GAC.ServiceID = p_ServiceID
			AND  FIND_IN_SET(GAC.GatewayAccountID, p_IPs) > 0;
	
			Update tblUsageHeader SET AccountID = NULL
			WHERE CompanyID = p_CompanyID
			AND ServiceID = p_ServiceID
			AND FIND_IN_SET(GatewayAccountID,p_IPs)>0			
			AND StartDate >= p_StartDate;
						
			Update tblVendorCDRHeader SET AccountID = NULL
			WHERE CompanyID = p_CompanyID
			AND ServiceID = p_ServiceID
			AND FIND_IN_SET(GatewayAccountID,p_IPs)>0
			AND StartDate >= p_StartDate;
	SET v_AccountID = -1;
	END IF;

	SELECT v_AccountID as `Status`;

SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 
END ;;
DELIMITER ;

--
-- Current Database: `StagingReport`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `StagingReport` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;

USE `StagingReport`;

--
-- Table structure for table `#Tableau_0_sid_00471F53_4_Group`
--

CREATE TABLE `#Tableau_0_sid_00471F53_4_Group` (
  `Account ID (group)` varchar(5) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `AccountID` int(11) DEFAULT NULL,
  KEY `_tidx_#Tableau_0_sid_00471F53_4_Group_2a` (`AccountID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblDimDate`
--

CREATE TABLE `tblDimDate` (
  `DateID` bigint(20) NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `day` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `day_abbrev` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
  `day_of_week` int(11) DEFAULT NULL,
  `day_of_month` int(11) DEFAULT NULL,
  `day_of_quarter` int(11) DEFAULT NULL,
  `day_of_semester` int(11) DEFAULT NULL,
  `day_of_year` int(11) DEFAULT NULL,
  `weekend` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Weekday',
  `week_of_month` int(11) DEFAULT NULL,
  `week_of_quarter` int(11) DEFAULT NULL,
  `week_of_semester` int(11) DEFAULT NULL,
  `week_of_year` int(11) DEFAULT NULL,
  `month` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `month_abbrev` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
  `month_of_quarter` int(11) DEFAULT NULL,
  `month_of_year` int(11) DEFAULT NULL,
  `quarter_of_year` int(11) DEFAULT NULL,
  `previous_day` date NOT NULL,
  `next_day` date NOT NULL,
  `start_week` date NOT NULL,
  `end_week` date NOT NULL,
  `start_month` date NOT NULL,
  `end_month` date NOT NULL,
  `start_quarter` date NOT NULL,
  `end_quarter` date NOT NULL,
  `year` int(11) DEFAULT NULL,
  `week_month_name` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `week_quarter_name` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `week_year_name` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `month_quarter_name` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `month_year_name` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `quarter_year_name` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`DateID`),
  UNIQUE KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblDimTime`
--

CREATE TABLE `tblDimTime` (
  `TimeID` int(11) NOT NULL AUTO_INCREMENT,
  `fulltime` time DEFAULT NULL,
  `hour` int(11) DEFAULT NULL,
  `minute` int(11) DEFAULT NULL,
  `second` int(11) DEFAULT NULL,
  `ampm` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`TimeID`),
  KEY `IX_fulltime` (`fulltime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblHeader`
--

CREATE TABLE `tblHeader` (
  `HeaderID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  PRIMARY KEY (`HeaderID`),
  UNIQUE KEY `Unique_key` (`DateID`,`AccountID`),
  KEY `FK_tblSummaryHeaderNew_dim_date` (`DateID`),
  KEY `IX_CompanyID` (`CompanyID`),
  CONSTRAINT `tblHeader_ibfk_1` FOREIGN KEY (`DateID`) REFERENCES `tblDimDate` (`DateID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblHeaderV`
--

CREATE TABLE `tblHeaderV` (
  `HeaderVID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `VAccountID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  PRIMARY KEY (`HeaderVID`),
  UNIQUE KEY `Unique_key` (`DateID`,`VAccountID`),
  KEY `FK_tblHeaderV_dim_date` (`DateID`),
  KEY `IX_CompanyID` (`CompanyID`),
  CONSTRAINT `tblHeader_ibfk_2` FOREIGN KEY (`DateID`) REFERENCES `tblDimDate` (`DateID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblSummaryHeader`
--

CREATE TABLE `tblSummaryHeader` (
  `SummaryHeaderID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT '0',
  PRIMARY KEY (`SummaryHeaderID`),
  KEY `FK_tblSummaryHeader_dim_date` (`DateID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`GatewayAccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`),
  CONSTRAINT `FK_tblSummaryHeader_dim_date` FOREIGN KEY (`DateID`) REFERENCES `tblDimDate` (`DateID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblSummaryVendorHeader`
--

CREATE TABLE `tblSummaryVendorHeader` (
  `SummaryVendorHeaderID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT '0',
  PRIMARY KEY (`SummaryVendorHeaderID`),
  KEY `FK_tblSummaryVendorHeader_dim_date` (`DateID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`GatewayAccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`),
  CONSTRAINT `FK_tblSummaryVendorHeader_dim_date` FOREIGN KEY (`DateID`) REFERENCES `tblDimDate` (`DateID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageSummary`
--

CREATE TABLE `tblUsageSummary` (
  `UsageSummaryID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryHeaderID` bigint(20) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageSummaryID`),
  KEY `FK_tblUsageSummary_dim_date` (`SummaryHeaderID`),
  CONSTRAINT `FK_tblUsageSummary_tblSummaryHeader` FOREIGN KEY (`SummaryHeaderID`) REFERENCES `tblSummaryHeader` (`SummaryHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageSummaryDetail`
--

CREATE TABLE `tblUsageSummaryDetail` (
  `UsageSummaryDetailID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryHeaderID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageSummaryDetailID`),
  KEY `FK_tblUsageSummaryDetail_dim_time` (`TimeID`),
  KEY `FK_tblUsageSummaryDetail_tblSummaryHeader` (`SummaryHeaderID`),
  CONSTRAINT `FK_tblUsageSummaryDetail_tblDimTime` FOREIGN KEY (`TimeID`) REFERENCES `tblDimTime` (`TimeID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_tblUsageSummaryDetail_tblSummaryHeader` FOREIGN KEY (`SummaryHeaderID`) REFERENCES `tblSummaryHeader` (`SummaryHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageSummaryDetailLive`
--

CREATE TABLE `tblUsageSummaryDetailLive` (
  `UsageSummaryDetailLiveID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryHeaderID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageSummaryDetailLiveID`),
  KEY `FK_tblUsageSummaryDetailLive_dim_time` (`TimeID`),
  KEY `FK_tblUsageSummaryDetailLive_tblSummaryHeader` (`SummaryHeaderID`),
  CONSTRAINT `FK_tblUsageSummaryDetailLive_tblDimTime` FOREIGN KEY (`TimeID`) REFERENCES `tblDimTime` (`TimeID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_tblUsageSummaryDetailLive_tblSummaryHeader` FOREIGN KEY (`SummaryHeaderID`) REFERENCES `tblSummaryHeader` (`SummaryHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageSummaryLive`
--

CREATE TABLE `tblUsageSummaryLive` (
  `UsageSummaryLiveID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryHeaderID` bigint(20) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageSummaryLiveID`),
  KEY `FK_tblUsageSummaryLive_dim_date` (`SummaryHeaderID`),
  CONSTRAINT `FK_tblUsageSummaryLive_tblSummaryHeader` FOREIGN KEY (`SummaryHeaderID`) REFERENCES `tblSummaryHeader` (`SummaryHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageVendorSummary`
--

CREATE TABLE `tblUsageVendorSummary` (
  `UsageVendorSummaryID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryVendorHeaderID` bigint(20) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageVendorSummaryID`),
  KEY `FK_tblUsageVendorSummary_dim_date` (`SummaryVendorHeaderID`),
  CONSTRAINT `FK_tblUsageVendorSummary_tblSummaryVendorHeader` FOREIGN KEY (`SummaryVendorHeaderID`) REFERENCES `tblSummaryVendorHeader` (`SummaryVendorHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageVendorSummaryDetail`
--

CREATE TABLE `tblUsageVendorSummaryDetail` (
  `UsageVendorSummaryDetailID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryVendorHeaderID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageVendorSummaryDetailID`),
  KEY `FK_tblUsageVendorSummaryDetail_dim_time` (`TimeID`),
  KEY `FK_tblUsageVendorSummaryDetail_tblSummaryVendorHeader` (`SummaryVendorHeaderID`),
  CONSTRAINT `FK_tblUsageVendorSummaryDetail_tblDimTime` FOREIGN KEY (`TimeID`) REFERENCES `tblDimTime` (`TimeID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_tblUsageVendorSummaryDetail_tblSummaryVendorHeader` FOREIGN KEY (`SummaryVendorHeaderID`) REFERENCES `tblSummaryVendorHeader` (`SummaryVendorHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageVendorSummaryDetailLive`
--

CREATE TABLE `tblUsageVendorSummaryDetailLive` (
  `UsageVendorSummaryDetailLiveID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryVendorHeaderID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageVendorSummaryDetailLiveID`),
  KEY `FK_tblUsageVendorSummaryDetailLive_dim_time` (`TimeID`),
  KEY `FK_tblUsageVendorSummaryDetailLive_tblSummaryVendorHeader` (`SummaryVendorHeaderID`),
  CONSTRAINT `FK_tblUsageVendorSummaryDetailLive_tblDimTime` FOREIGN KEY (`TimeID`) REFERENCES `tblDimTime` (`TimeID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_tblUsageVendorSummaryDetailLive_tblSummaryVendorHeader` FOREIGN KEY (`SummaryVendorHeaderID`) REFERENCES `tblSummaryVendorHeader` (`SummaryVendorHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblUsageVendorSummaryLive`
--

CREATE TABLE `tblUsageVendorSummaryLive` (
  `UsageVendorSummaryLiveID` bigint(20) NOT NULL AUTO_INCREMENT,
  `SummaryVendorHeaderID` bigint(20) NOT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT NULL,
  `NoOfFailCalls` int(11) DEFAULT NULL,
  `FinalStatus` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UsageVendorSummaryLiveID`),
  KEY `FK_tblUsageVendorSummaryLive_dim_date` (`SummaryVendorHeaderID`),
  CONSTRAINT `FK_tblUsageVendorSummaryLive_tblSummaryVendorHeader` FOREIGN KEY (`SummaryVendorHeaderID`) REFERENCES `tblSummaryVendorHeader` (`SummaryVendorHeaderID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_SummaryHeader`
--

CREATE TABLE `tmp_SummaryHeader` (
  `SummaryHeaderID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`SummaryHeaderID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_SummaryHeaderLive`
--

CREATE TABLE `tmp_SummaryHeaderLive` (
  `SummaryHeaderID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`SummaryHeaderID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_SummaryVendorHeader`
--

CREATE TABLE `tmp_SummaryVendorHeader` (
  `SummaryVendorHeaderID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`SummaryVendorHeaderID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_SummaryVendorHeaderLive`
--

CREATE TABLE `tmp_SummaryVendorHeaderLive` (
  `SummaryVendorHeaderID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `CountryID` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`SummaryVendorHeaderID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_UsageSummary`
--

CREATE TABLE `tmp_UsageSummary` (
  `UsageSummaryID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `CompanyID` int(11) NOT NULL,
  `CompanyGatewayID` int(11) NOT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) NOT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT '0',
  `NoOfFailCalls` int(11) DEFAULT '0',
  `FinalStatus` int(11) DEFAULT '0',
  `CountryID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`UsageSummaryID`),
  KEY `tblUsageSummary_dim_date` (`DateID`),
  KEY `tmp_UsageSummary_AreaPrefix` (`AreaPrefix`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`GatewayAccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_UsageSummaryLive`
--

CREATE TABLE `tmp_UsageSummaryLive` (
  `UsageSummaryLiveID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `CompanyID` int(11) NOT NULL,
  `CompanyGatewayID` int(11) NOT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) NOT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT '0',
  `NoOfFailCalls` int(11) DEFAULT '0',
  `FinalStatus` int(11) DEFAULT '0',
  `CountryID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`UsageSummaryLiveID`),
  KEY `tmp_UsageSummary_AreaPrefix` (`AreaPrefix`),
  KEY `IX_CompanyID` (`CompanyID`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`),
  KEY `tblUsageSummary_dim_date` (`DateID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_VendorUsageSummary`
--

CREATE TABLE `tmp_VendorUsageSummary` (
  `VendorUsageSummaryID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `CompanyID` int(11) NOT NULL,
  `CompanyGatewayID` int(11) NOT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) NOT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT '0',
  `NoOfFailCalls` int(11) DEFAULT '0',
  `FinalStatus` int(11) DEFAULT '0',
  `CountryID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorUsageSummaryID`),
  KEY `tmp_VendorUsageSummary_dim_date` (`DateID`),
  KEY `tmp_VendorUsageSummary_AreaPrefix` (`AreaPrefix`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`GatewayAccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_VendorUsageSummaryLive`
--

CREATE TABLE `tmp_VendorUsageSummaryLive` (
  `VendorUsageSummaryLiveID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `DateID` bigint(20) NOT NULL,
  `TimeID` int(11) NOT NULL,
  `CompanyID` int(11) NOT NULL,
  `CompanyGatewayID` int(11) NOT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AccountID` int(11) NOT NULL,
  `Trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `AreaPrefix` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `TotalCharges` double DEFAULT NULL,
  `TotalSales` double DEFAULT NULL,
  `TotalBilledDuration` int(11) DEFAULT NULL,
  `TotalDuration` int(11) DEFAULT NULL,
  `NoOfCalls` int(11) DEFAULT '0',
  `NoOfFailCalls` int(11) DEFAULT '0',
  `FinalStatus` int(11) DEFAULT '0',
  `CountryID` int(11) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorUsageSummaryLiveID`),
  KEY `tmp_VendorUsageSummary_dim_date` (`DateID`),
  KEY `tmp_VendorUsageSummary_AreaPrefix` (`AreaPrefix`),
  KEY `Unique_key` (`DateID`,`CompanyID`,`AccountID`,`GatewayAccountID`,`CompanyGatewayID`,`Trunk`,`AreaPrefix`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_tblUsageDetailsReport`
--

CREATE TABLE `tmp_tblUsageDetailsReport` (
  `UsageDetailsReportID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `UsageDetailID` bigint(20) unsigned DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `cost` decimal(18,6) DEFAULT NULL,
  `connect_time` time DEFAULT NULL,
  `connect_date` date DEFAULT NULL,
  `call_status` tinyint(4) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`UsageDetailsReportID`),
  KEY `temp_connect_time` (`connect_time`,`connect_date`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_tblUsageDetailsReportLive`
--

CREATE TABLE `tmp_tblUsageDetailsReportLive` (
  `UsageDetailsReportLiveID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `UsageDetailID` bigint(20) unsigned DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `cost` decimal(18,6) DEFAULT NULL,
  `connect_time` time DEFAULT NULL,
  `connect_date` date DEFAULT NULL,
  `call_status` tinyint(4) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`UsageDetailsReportLiveID`),
  KEY `temp_connect_time` (`connect_time`,`connect_date`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_tblVendorUsageDetailsReport`
--

CREATE TABLE `tmp_tblVendorUsageDetailsReport` (
  `VendorUsageDetailsReportID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `VendorCDRID` bigint(20) unsigned DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `buying_cost` decimal(18,6) DEFAULT NULL,
  `selling_cost` decimal(18,6) DEFAULT NULL,
  `connect_time` time DEFAULT NULL,
  `connect_date` date DEFAULT NULL,
  `call_status` tinyint(4) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorUsageDetailsReportID`),
  KEY `temp_connect_time` (`connect_time`,`connect_date`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tmp_tblVendorUsageDetailsReportLive`
--

CREATE TABLE `tmp_tblVendorUsageDetailsReportLive` (
  `VendorUsageDetailsReportLiveID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `VendorCDRID` bigint(20) unsigned DEFAULT NULL,
  `AccountID` int(11) DEFAULT NULL,
  `CompanyID` int(11) DEFAULT NULL,
  `CompanyGatewayID` int(11) DEFAULT NULL,
  `GatewayAccountID` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `trunk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `area_prefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `billed_duration` int(11) DEFAULT NULL,
  `buying_cost` decimal(18,6) DEFAULT NULL,
  `selling_cost` decimal(18,6) DEFAULT NULL,
  `connect_time` time DEFAULT NULL,
  `connect_date` date DEFAULT NULL,
  `call_status` tinyint(4) DEFAULT NULL,
  `ServiceID` int(11) DEFAULT NULL,
  PRIMARY KEY (`VendorUsageDetailsReportLiveID`),
  KEY `temp_connect_time` (`connect_time`,`connect_date`),
  KEY `IX_CompanyID` (`CompanyID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping routines for database 'StagingReport'
--
/*!50003 DROP FUNCTION IF EXISTS `fnDurationmmss` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `fnDurationmmss`(`p_Duration` INT) RETURNS varchar(50) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN

DECLARE v_FormattedDuration_ VARCHAR(50);

SELECT CONCAT(FLOOR(p_Duration/60), ':' ,p_Duration % 60) INTO v_FormattedDuration_;

RETURN v_FormattedDuration_;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `fnGetCompanyGatewayName` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `fnGetCompanyGatewayName`(`p_CompanyGatewayID` INT) RETURNS varchar(200) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN
DECLARE v_Title_ VARCHAR(200);

SELECT cg.Title INTO v_Title_ from Ratemanagement3.tblCompanyGateway cg where cg.CompanyGatewayID = p_CompanyGatewayID;

RETURN v_Title_;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `fngetLastInvoiceDate` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` FUNCTION `fngetLastInvoiceDate`(
	`p_AccountID` INT

) RETURNS date
BEGIN
	
	DECLARE v_LastInvoiceDate_ DATE;
	
	SELECT 
		CASE WHEN tblAccountBilling.LastInvoiceDate IS NOT NULL AND tblAccountBilling.LastInvoiceDate <> '' 
		THEN 
			DATE_FORMAT(tblAccountBilling.LastInvoiceDate,'%Y-%m-%d')
		ELSE 
			CASE WHEN tblAccountBilling.BillingStartDate IS NOT NULL AND tblAccountBilling.BillingStartDate <> ''
			THEN
				DATE_FORMAT(tblAccountBilling.BillingStartDate,'%Y-%m-%d')
			ELSE DATE_FORMAT(tblAccount.created_at,'%Y-%m-%d')
			END 
		END
		INTO v_LastInvoiceDate_ 
	FROM Ratemanagement3.tblAccount
	LEFT JOIN Ratemanagement3.tblAccountBilling 
		ON tblAccountBilling.AccountID = tblAccount.AccountID AND tblAccountBilling.ServiceID = 0
	WHERE tblAccount.AccountID = p_AccountID
	LIMIT 1;
	
	RETURN v_LastInvoiceDate_;
	
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `fngetLastVendorInvoiceDate` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `fngetLastVendorInvoiceDate`(
	`p_AccountID` INT





) RETURNS datetime
BEGIN
	
	DECLARE v_LastInvoiceDate_ DATETIME;
	
	SELECT
		CASE WHEN EndDate IS NOT NULL AND EndDate <> '' AND EndDate <> '0000-00-00 00:00:00'
		THEN 
			EndDate
		ELSE 
			CASE WHEN BillingStartDate IS NOT NULL AND BillingStartDate <> ''
			THEN
				DATE_FORMAT(BillingStartDate,'%Y-%m-%d')
			ELSE DATE_FORMAT(tblAccount.created_at,'%Y-%m-%d')
			END 
		END  INTO v_LastInvoiceDate_
 	FROM Ratemanagement3.tblAccount
	LEFT JOIN Ratemanagement3.tblAccountBilling 
		ON tblAccountBilling.AccountID = tblAccount.AccountID AND tblAccountBilling.ServiceID = 0
	LEFT JOIN RMBilling3.tblInvoice 
		ON tblAccount.AccountID = tblInvoice.AccountID AND InvoiceType =2
	LEFT JOIN RMBilling3.tblInvoiceDetail
		ON tblInvoice.InvoiceID =  tblInvoiceDetail.InvoiceID
	WHERE tblAccount.AccountID = p_AccountID 
	ORDER BY IssueDate DESC 
	LIMIT 1;

	RETURN v_LastInvoiceDate_;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `fnGetMonthDifference` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` FUNCTION `fnGetMonthDifference`(`p_Date1` DATE, `p_Date2` DATE) RETURNS int(11)
BEGIN

DECLARE v_Month INT;

SELECT 12 * (YEAR(p_Date2) - YEAR(p_Date1)) + MONTH(p_Date2) -  MONTH(p_Date1) INTO v_Month;

RETURN v_Month;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `fnGetRoundingPoint` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` FUNCTION `fnGetRoundingPoint`(
	`p_CompanyID` INT

) RETURNS int(11)
BEGIN

DECLARE v_Round_ int;

SELECT cs.Value INTO v_Round_ from Ratemanagement3.tblCompanySetting cs where cs.`Key` = 'RoundChargesAmount' AND cs.CompanyID = p_CompanyID AND cs.Value <> '';

SET v_Round_ = IFNULL(v_Round_,2);

RETURN v_Round_;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnGetCountry` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fnGetCountry`()
BEGIN

DROP TEMPORARY TABLE IF EXISTS temptblCountry;
CREATE TEMPORARY TABLE IF NOT EXISTS `temptblCountry` (
	`CountryID` INT(11) NOT NULL AUTO_INCREMENT,
	`Prefix` VARCHAR(50) NULL DEFAULT NULL,
	`Country` VARCHAR(100) NULL DEFAULT NULL,
	`ISO2` VARCHAR(5)  NULL DEFAULT NULL,
	`ISO3` VARCHAR(5) NULL DEFAULT NULL,
	PRIMARY KEY (`CountryID`),
	INDEX tempCountry_Prefix(`Prefix`)
);
INSERT INTO temptblCountry(CountryID,Prefix,Country,ISO2,ISO3)
SELECT CountryID,Prefix,Country,ISO2,ISO3 FROM Ratemanagement3.tblCountry;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fngetDefaultCodes` */;
DELIMITER ;;
CREATE DEFINER=`neon-user-bhavin`@`117.247.87.156` PROCEDURE `fngetDefaultCodes`(IN `p_CompanyID` INT)
BEGIN
	
	DROP TEMPORARY TABLE IF EXISTS tmp_codes_;
	CREATE TEMPORARY TABLE tmp_codes_ (
		CountryID INT,
		Code VARCHAR(50),
		INDEX tmp_codes_CountryID (`CountryID`),
		INDEX tmp_codes_Code (`Code`)
	);

	INSERT INTO tmp_codes_
	SELECT
	DISTINCT
		tblRate.CountryID,
		tblRate.Code
	FROM Ratemanagement3.tblRate
	INNER JOIN Ratemanagement3.tblCodeDeck
		ON tblCodeDeck.CodeDeckId = tblRate.CodeDeckId
	WHERE tblCodeDeck.CompanyId = p_CompanyID
	AND tblCodeDeck.DefaultCodedeck = 1 ;
	
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnGetUsageForSummary` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `fnGetUsageForSummary`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE
)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	DELETE FROM tmp_tblUsageDetailsReport WHERE CompanyID = p_CompanyID;

	INSERT INTO tmp_tblUsageDetailsReport (UsageDetailID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,cost,connect_time,connect_date,call_status)
	SELECT
		ud.UsageDetailID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		1 as call_status
	FROM RMCDR3.tblUsageDetails  ud
	INNER JOIN RMCDR3.tblUsageHeader uh
		ON uh.UsageHeaderID = ud.UsageHeaderID
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID is not null
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

	INSERT INTO tmp_tblUsageDetailsReport (UsageDetailID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,cost,connect_time,connect_date,call_status)
	SELECT
		ud.UsageDetailFailedCallID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		2 as call_status
	FROM RMCDR3.tblUsageDetailFailedCall  ud
	INNER JOIN RMCDR3.tblUsageHeader uh
		ON uh.UsageHeaderID = ud.UsageHeaderID
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID is not null
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnGetUsageForSummaryLive` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `fnGetUsageForSummaryLive`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE
)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	DELETE FROM tmp_tblUsageDetailsReportLive WHERE CompanyID = p_CompanyID;
	
	INSERT INTO tmp_tblUsageDetailsReportLive (UsageDetailID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,cost,connect_time,connect_date,call_status)
	SELECT
		ud.UsageDetailID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		1 AS call_status
	FROM RMCDR3.tblUsageDetails  ud
	INNER JOIN RMCDR3.tblUsageHeader uh
		ON uh.UsageHeaderID = ud.UsageHeaderID
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID IS NOT NULL
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

	INSERT INTO tmp_tblUsageDetailsReportLive (UsageDetailID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,cost,connect_time,connect_date,call_status)
	SELECT
		ud.UsageDetailFailedCallID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		2 AS call_status
	FROM RMCDR3.tblUsageDetailFailedCall  ud
	INNER JOIN RMCDR3.tblUsageHeader uh
		ON uh.UsageHeaderID = ud.UsageHeaderID
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID IS NOT NULL
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnGetVendorUsageForSummary` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `fnGetVendorUsageForSummary`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE
)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	DELETE FROM tmp_tblVendorUsageDetailsReport WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_tblVendorUsageDetailsReport (VendorCDRID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,buying_cost,selling_cost,connect_time,connect_date,call_status)
	SELECT
		ud.VendorCDRID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		buying_cost,
		selling_cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		1 AS call_status
	FROM RMCDR3.tblVendorCDR  ud
	INNER JOIN RMCDR3.tblVendorCDRHeader uh
		ON uh.VendorCDRHeaderID = ud.VendorCDRHeaderID 
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID IS NOT NULL
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

	INSERT INTO tmp_tblVendorUsageDetailsReport (VendorCDRID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,buying_cost,selling_cost,connect_time,connect_date,call_status)
	SELECT
		ud.VendorCDRFailedID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		buying_cost,
		selling_cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		2 AS call_status
	FROM RMCDR3.tblVendorCDRFailed  ud
	INNER JOIN RMCDR3.tblVendorCDRHeader uh
		ON uh.VendorCDRHeaderID = ud.VendorCDRHeaderID 
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID IS NOT NULL
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnGetVendorUsageForSummaryLive` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `fnGetVendorUsageForSummaryLive`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE
)
BEGIN

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	DELETE FROM tmp_tblVendorUsageDetailsReportLive WHERE CompanyID = p_CompanyID;
	
	INSERT INTO tmp_tblVendorUsageDetailsReportLive (VendorCDRID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,buying_cost,selling_cost,connect_time,connect_date,call_status)
	SELECT
		ud.VendorCDRID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		buying_cost,
		selling_cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		1 AS call_status
	FROM RMCDR3.tblVendorCDR  ud
	INNER JOIN RMCDR3.tblVendorCDRHeader uh
		ON uh.VendorCDRHeaderID = ud.VendorCDRHeaderID 
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID IS NOT NULL
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

	INSERT INTO tmp_tblVendorUsageDetailsReportLive (VendorCDRID,AccountID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,trunk,area_prefix,duration,billed_duration,buying_cost,selling_cost,connect_time,connect_date,call_status)
	SELECT
		ud.VendorCDRFailedID,
		uh.AccountID,
		uh.CompanyID,
		uh.CompanyGatewayID,
		uh.ServiceID,
		uh.GatewayAccountID,
		trunk,
		area_prefix,
		duration,
		billed_duration,
		buying_cost,
		selling_cost,
		CONCAT(DATE_FORMAT(ud.connect_time,'%H'),':',IF(MINUTE(ud.connect_time)<30,'00','30'),':00'),
		DATE_FORMAT(ud.connect_time,'%Y-%m-%d'),
		2 AS call_status
	FROM RMCDR3.tblVendorCDRFailed  ud
	INNER JOIN RMCDR3.tblVendorCDRHeader uh
		ON uh.VendorCDRHeaderID = ud.VendorCDRHeaderID 
	WHERE
		uh.CompanyID = p_CompanyID
	AND uh.AccountID IS NOT NULL
	AND uh.StartDate BETWEEN p_StartDate AND p_EndDate;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnUsageSummary` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `fnUsageSummary`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` INT,
	IN `p_AccountID` INT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` VARCHAR(50),
	IN `p_Trunk` VARCHAR(50),
	IN `p_CountryID` INT,
	IN `p_UserID` INT ,
	IN `p_isAdmin` INT,
	IN `p_Detail` INT





)
BEGIN
	DECLARE v_TimeId_ INT;
	
	IF DATEDIFF(p_EndDate,p_StartDate) > 31 AND p_Detail = 2
	THEN
		SET p_Detail = 1;
	END IF;

	IF p_Detail = 1 
	THEN
	
		DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageSummary_;
		CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageSummary_(
				`DateID` BIGINT(20) NOT NULL,
				`CompanyID` INT(11) NOT NULL,
				`AccountID` INT(11) NOT NULL,
				`GatewayAccountID` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CompanyGatewayID` INT(11) NOT NULL,
				`Trunk` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CountryID` INT(11) NULL DEFAULT NULL,
				`TotalCharges` DOUBLE NULL DEFAULT NULL,
				`TotalBilledDuration` INT(11) NULL DEFAULT NULL,
				`TotalDuration` INT(11) NULL DEFAULT NULL,
				`NoOfCalls` INT(11) NULL DEFAULT NULL,
				`NoOfFailCalls` INT(11) NULL DEFAULT NULL,
				`AccountName` varchar(100),
				INDEX `tblUsageSummary_dim_date` (`DateID`)
		);
		INSERT INTO tmp_tblUsageSummary_
		SELECT
			sh.DateID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			us.TotalCharges,
			us.TotalBilledDuration,
			us.TotalDuration,
			us.NoOfCalls,
			us.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryHeader sh
		INNER JOIN tblUsageSummary us
			ON us.SummaryHeaderID = sh.SummaryHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
		INSERT INTO tmp_tblUsageSummary_
		SELECT
			sh.DateID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			us.TotalCharges,
			us.TotalBilledDuration,
			us.TotalDuration,
			us.NoOfCalls,
			us.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryHeader sh
		INNER JOIN tblUsageSummaryLive us
			ON us.SummaryHeaderID = sh.SummaryHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
		
		
	END IF;
	
	IF p_Detail = 2
	THEN
	
		DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageSummary_;
		CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageSummary_(
				`DateID` BIGINT(20) NOT NULL,
				`TimeID` INT(11) NOT NULL,
				`CompanyID` INT(11) NOT NULL,
				`AccountID` INT(11) NOT NULL,
				`GatewayAccountID` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CompanyGatewayID` INT(11) NOT NULL,
				`Trunk` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CountryID` INT(11) NULL DEFAULT NULL,
				`TotalCharges` DOUBLE NULL DEFAULT NULL,
				`TotalBilledDuration` INT(11) NULL DEFAULT NULL,
				`TotalDuration` INT(11) NULL DEFAULT NULL,
				`NoOfCalls` INT(11) NULL DEFAULT NULL,
				`NoOfFailCalls` INT(11) NULL DEFAULT NULL,
				`AccountName` varchar(100),
				INDEX `tblUsageSummary_dim_date` (`DateID`)
		);
		
		INSERT INTO tmp_tblUsageSummary_
		SELECT
			sh.DateID,
			dt.TimeID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			usd.TotalCharges,
			usd.TotalBilledDuration,
			usd.TotalDuration,
			usd.NoOfCalls,
			usd.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryHeader sh
		INNER JOIN tblUsageSummaryDetail usd
			ON usd.SummaryHeaderID = sh.SummaryHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN tblDimTime dt
			ON dt.TimeID = usd.TimeID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
		AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
		INSERT INTO tmp_tblUsageSummary_
		SELECT
			sh.DateID,
			dt.TimeID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			usd.TotalCharges,
			usd.TotalBilledDuration,
			usd.TotalDuration,
			usd.NoOfCalls,
			usd.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryHeader sh
		INNER JOIN tblUsageSummaryDetailLive usd
			ON usd.SummaryHeaderID = sh.SummaryHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN tblDimTime dt
			ON dt.TimeID = usd.TimeID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
		AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);			
		
	END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnUsageSummaryDetail` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fnUsageSummaryDetail`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` TEXT,
	IN `p_AccountID` TEXT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` TEXT,
	IN `p_Trunk` TEXT,
	IN `p_CountryID` TEXT,
	IN `p_UserID` INT ,
	IN `p_isAdmin` INT

)
BEGIN
	
	DECLARE i INTEGER;

	DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageSummary_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageSummary_(
			`DateID` BIGINT(20) NOT NULL,
			`TimeID` INT(11) NOT NULL,
			`Time` VARCHAR(50) NOT NULL,
			`CompanyID` INT(11) NOT NULL,
			`AccountID` INT(11) NOT NULL,
			`GatewayAccountID` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
			`CompanyGatewayID` INT(11) NOT NULL,
			`Trunk` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
			`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
			`CountryID` INT(11) NULL DEFAULT NULL,
			`TotalCharges` DOUBLE NULL DEFAULT NULL,
			`TotalBilledDuration` INT(11) NULL DEFAULT NULL,
			`TotalDuration` INT(11) NULL DEFAULT NULL,
			`NoOfCalls` INT(11) NULL DEFAULT NULL,
			`NoOfFailCalls` INT(11) NULL DEFAULT NULL,
			`AccountName` varchar(100),
			INDEX `tblUsageSummary_dim_date` (`DateID`)
	);
	
	DROP TEMPORARY TABLE IF EXISTS tmp_AreaPrefix_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_AreaPrefix_ (
		`Code` Text NULL DEFAULT NULL
	);
    
	SET i = 1;
	REPEAT
		INSERT INTO tmp_AreaPrefix_ ( Code)
		SELECT Ratemanagement3.FnStringSplit(p_AreaPrefix, ',', i) FROM tblDimDate WHERE Ratemanagement3.FnStringSplit(p_AreaPrefix, ',', i) IS NOT NULL LIMIT 1;
		SET i = i + 1;
		UNTIL ROW_COUNT() = 0
	END REPEAT;
		
	INSERT INTO tmp_tblUsageSummary_
	SELECT
		sh.DateID,
		dt.TimeID,
		CONCAT(dd.date,' ',dt.fulltime),
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		usd.TotalCharges,
		usd.TotalBilledDuration,
		usd.TotalDuration,
		usd.NoOfCalls,
		usd.NoOfFailCalls,
		a.AccountName
	FROM tblSummaryHeader sh
	INNER JOIN tblUsageSummaryDetail usd
		ON usd.SummaryHeaderID = sh.SummaryHeaderID 
	INNER JOIN tblDimDate dd
		ON dd.DateID = sh.DateID
	INNER JOIN tblDimTime dt
		ON dt.TimeID = usd.TimeID
	INNER JOIN Ratemanagement3.tblAccount a
		ON sh.AccountID = a.AccountID
	LEFT JOIN Ratemanagement3.tblTrunk t
		ON t.Trunk = sh.Trunk
	LEFT JOIN tmp_AreaPrefix_ ap 
		ON sh.AreaPrefix LIKE REPLACE(ap.Code, '*', '%')
	WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
	AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
	AND sh.CompanyID = p_CompanyID
	AND (p_AccountID = '' OR FIND_IN_SET(sh.AccountID,p_AccountID))
	AND (p_CompanyGatewayID = '' OR FIND_IN_SET(sh.CompanyGatewayID,p_CompanyGatewayID))
	AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
	AND (p_Trunk = '' OR FIND_IN_SET(t.TrunkID,p_Trunk))
	AND (p_CountryID = '' OR FIND_IN_SET(sh.CountryID,p_CountryID))
	AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID)
	AND (p_AreaPrefix ='' OR ap.Code IS NOT NULL);
		
	INSERT INTO tmp_tblUsageSummary_
	SELECT
		sh.DateID,
		dt.TimeID,
		CONCAT(dd.date,' ',dt.fulltime),
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		usd.TotalCharges,
		usd.TotalBilledDuration,
		usd.TotalDuration,
		usd.NoOfCalls,
		usd.NoOfFailCalls,
		a.AccountName
	FROM tblSummaryHeader sh
	INNER JOIN tblUsageSummaryDetailLive usd
		ON usd.SummaryHeaderID = sh.SummaryHeaderID 
	INNER JOIN tblDimDate dd
		ON dd.DateID = sh.DateID
	INNER JOIN tblDimTime dt
		ON dt.TimeID = usd.TimeID
	INNER JOIN Ratemanagement3.tblAccount a
		ON sh.AccountID = a.AccountID
	LEFT JOIN Ratemanagement3.tblTrunk t
		ON t.Trunk = sh.Trunk
	LEFT JOIN tmp_AreaPrefix_ ap 
		ON (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(ap.Code, '*', '%') )
	WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
	AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
	AND sh.CompanyID = p_CompanyID
	AND (p_AccountID = '' OR FIND_IN_SET(sh.AccountID,p_AccountID))
	AND (p_CompanyGatewayID = '' OR FIND_IN_SET(sh.CompanyGatewayID,p_CompanyGatewayID))
	AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
	AND (p_Trunk = '' OR FIND_IN_SET(t.TrunkID,p_Trunk))
	AND (p_CountryID = '' OR FIND_IN_SET(sh.CountryID,p_CountryID))
	AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID)
	AND (p_AreaPrefix ='' OR ap.Code IS NOT NULL);

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnUsageVendorSummary` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `fnUsageVendorSummary`(
	IN `p_CompanyID` int ,
	IN `p_CompanyGatewayID` int ,
	IN `p_AccountID` int ,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` datetime ,
	IN `p_EndDate` datetime ,
	IN `p_AreaPrefix` VARCHAR(50),
	IN `p_Trunk` VARCHAR(50),
	IN `p_CountryID` INT,
	IN `p_UserID` INT ,
	IN `p_isAdmin` INT,
	IN `p_Detail` INT

)
BEGIN
	DECLARE v_TimeId_ INT;
	
	IF DATEDIFF(p_EndDate,p_StartDate) > 31 AND p_Detail =2
	THEN
		SET p_Detail = 1;
	END IF;
	
	IF p_Detail = 1 
	THEN
	
		DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageVendorSummary_;
		CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageVendorSummary_(
				`DateID` BIGINT(20) NOT NULL,
				`CompanyID` INT(11) NOT NULL,
				`AccountID` INT(11) NOT NULL,
				`GatewayAccountID` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CompanyGatewayID` INT(11) NOT NULL,
				`Trunk` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CountryID` INT(11) NULL DEFAULT NULL,
				`TotalCharges` DOUBLE NULL DEFAULT NULL,
				`TotalBilledDuration` INT(11) NULL DEFAULT NULL,
				`TotalDuration` INT(11) NULL DEFAULT NULL,
				`NoOfCalls` INT(11) NULL DEFAULT NULL,
				`NoOfFailCalls` INT(11) NULL DEFAULT NULL,
				`AccountName` varchar(100),
				INDEX `tblUsageSummary_dim_date` (`DateID`)
		);
		INSERT INTO tmp_tblUsageVendorSummary_
		SELECT
			sh.DateID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			us.TotalCharges,
			us.TotalBilledDuration,
			us.TotalDuration,
			us.NoOfCalls,
			us.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryVendorHeader sh
		INNER JOIN tblUsageVendorSummary us
			ON us.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
		INSERT INTO tmp_tblUsageVendorSummary_
		SELECT
			sh.DateID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			us.TotalCharges,
			us.TotalBilledDuration,
			us.TotalDuration,
			us.NoOfCalls,
			us.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryVendorHeader sh
		INNER JOIN tblUsageVendorSummaryLive us
			ON us.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
		
	END IF;
	
	IF p_Detail = 2 
	THEN
	
		DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageVendorSummary_;
		CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageVendorSummary_(
				`DateID` BIGINT(20) NOT NULL,
				`TimeID` INT(11) NOT NULL,
				`CompanyID` INT(11) NOT NULL,
				`AccountID` INT(11) NOT NULL,
				`GatewayAccountID` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CompanyGatewayID` INT(11) NOT NULL,
				`Trunk` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
				`CountryID` INT(11) NULL DEFAULT NULL,
				`TotalCharges` DOUBLE NULL DEFAULT NULL,
				`TotalBilledDuration` INT(11) NULL DEFAULT NULL,
				`TotalDuration` INT(11) NULL DEFAULT NULL,
				`NoOfCalls` INT(11) NULL DEFAULT NULL,
				`NoOfFailCalls` INT(11) NULL DEFAULT NULL,
				`AccountName` varchar(100),
				INDEX `tblUsageSummary_dim_date` (`DateID`)
		);
		
		INSERT INTO tmp_tblUsageVendorSummary_
		SELECT
			sh.DateID,
			dt.TimeID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			usd.TotalCharges,
			usd.TotalBilledDuration,
			usd.TotalDuration,
			usd.NoOfCalls,
			usd.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryVendorHeader sh
		INNER JOIN tblUsageVendorSummaryDetail usd
			ON usd.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN tblDimTime dt
			ON dt.TimeID = usd.TimeID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
		AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
		INSERT INTO tmp_tblUsageVendorSummary_
		SELECT
			sh.DateID,
			dt.TimeID,
			sh.CompanyID,
			sh.AccountID,
			sh.GatewayAccountID,
			sh.CompanyGatewayID,
			sh.Trunk,
			sh.AreaPrefix,
			sh.CountryID,
			usd.TotalCharges,
			usd.TotalBilledDuration,
			usd.TotalDuration,
			usd.NoOfCalls,
			usd.NoOfFailCalls,
			a.AccountName
		FROM tblSummaryVendorHeader sh
		INNER JOIN tblUsageVendorSummaryDetailLive usd
			ON usd.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
		INNER JOIN tblDimDate dd
			ON dd.DateID = sh.DateID
		INNER JOIN tblDimTime dt
			ON dt.TimeID = usd.TimeID
		INNER JOIN Ratemanagement3.tblAccount a
			ON sh.AccountID = a.AccountID
		WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
		AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
		AND sh.CompanyID = p_CompanyID
		AND (p_AccountID = 0 OR sh.AccountID = p_AccountID)
		AND (p_CompanyGatewayID = 0 OR sh.CompanyGatewayID = p_CompanyGatewayID)
		AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
		AND (p_Trunk = '' OR sh.Trunk LIKE REPLACE(p_Trunk, '*', '%'))
		AND (p_AreaPrefix = '' OR sh.AreaPrefix LIKE REPLACE(p_AreaPrefix, '*', '%') )
		AND (p_CountryID = 0 OR sh.CountryID = p_CountryID)
		AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID);
		
	END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `fnUsageVendorSummaryDetail` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fnUsageVendorSummaryDetail`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` TEXT,
	IN `p_AccountID` TEXT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` TEXT,
	IN `p_Trunk` TEXT,
	IN `p_CountryID` TEXT,
	IN `p_UserID` INT,
	IN `p_isAdmin` INT


)
BEGIN
	
	DECLARE i INTEGER;
	
	DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageVendorSummary_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageVendorSummary_(
			`DateID` BIGINT(20) NOT NULL,
			`TimeID` INT(11) NOT NULL,
			`Time` VARCHAR(50) NOT NULL,
			`CompanyID` INT(11) NOT NULL,
			`AccountID` INT(11) NOT NULL,
			`GatewayAccountID` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
			`CompanyGatewayID` INT(11) NOT NULL,
			`Trunk` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
			`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
			`CountryID` INT(11) NULL DEFAULT NULL,
			`TotalCharges` DOUBLE NULL DEFAULT NULL,
			`TotalBilledDuration` INT(11) NULL DEFAULT NULL,
			`TotalDuration` INT(11) NULL DEFAULT NULL,
			`NoOfCalls` INT(11) NULL DEFAULT NULL,
			`NoOfFailCalls` INT(11) NULL DEFAULT NULL,
			`AccountName` varchar(100),
			INDEX `tblUsageSummary_dim_date` (`DateID`)
	);
	
	DROP TEMPORARY TABLE IF EXISTS tmp_AreaPrefix_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_AreaPrefix_ (
		`Code` Text NULL DEFAULT NULL
	);
    
	SET i = 1;
	REPEAT
		INSERT INTO tmp_AreaPrefix_ ( Code)
		SELECT Ratemanagement3.FnStringSplit(p_AreaPrefix, ',', i) FROM tblDimDate WHERE Ratemanagement3.FnStringSplit(p_AreaPrefix, ',', i) IS NOT NULL LIMIT 1;
		SET i = i + 1;
		UNTIL ROW_COUNT() = 0
	END REPEAT;
	
	INSERT INTO tmp_tblUsageVendorSummary_
	SELECT
		sh.DateID,
		dt.TimeID,
		CONCAT(dd.date,' ',dt.fulltime),
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		usd.TotalCharges,
		usd.TotalBilledDuration,
		usd.TotalDuration,
		usd.NoOfCalls,
		usd.NoOfFailCalls,
		a.AccountName
	FROM tblSummaryVendorHeader sh
	INNER JOIN tblUsageVendorSummaryDetail usd
		ON usd.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
	INNER JOIN tblDimDate dd
		ON dd.DateID = sh.DateID
	INNER JOIN tblDimTime dt
		ON dt.TimeID = usd.TimeID
	INNER JOIN Ratemanagement3.tblAccount a
		ON sh.AccountID = a.AccountID
	LEFT JOIN Ratemanagement3.tblTrunk t
		ON t.Trunk = sh.Trunk
	LEFT JOIN tmp_AreaPrefix_ ap 
		ON sh.AreaPrefix LIKE REPLACE(ap.Code, '*', '%')
	WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
	AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
	AND sh.CompanyID = p_CompanyID
	AND (p_AccountID = '' OR FIND_IN_SET(sh.AccountID,p_AccountID))
	AND (p_CompanyGatewayID = '' OR FIND_IN_SET(sh.CompanyGatewayID,p_CompanyGatewayID))
	AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
	AND (p_Trunk = '' OR FIND_IN_SET(t.TrunkID,p_Trunk))
	AND (p_CountryID = '' OR FIND_IN_SET(sh.CountryID,p_CountryID))
	AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID)
	AND (p_AreaPrefix ='' OR ap.Code IS NOT NULL);
	
	INSERT INTO tmp_tblUsageVendorSummary_
	SELECT
		sh.DateID,
		dt.TimeID,
		CONCAT(dd.date,' ',dt.fulltime),
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		usd.TotalCharges,
		usd.TotalBilledDuration,
		usd.TotalDuration,
		usd.NoOfCalls,
		usd.NoOfFailCalls,
		a.AccountName
	FROM tblSummaryVendorHeader sh
	INNER JOIN tblUsageVendorSummaryDetailLive usd
		ON usd.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
	INNER JOIN tblDimDate dd
		ON dd.DateID = sh.DateID
	INNER JOIN tblDimTime dt
		ON dt.TimeID = usd.TimeID
	INNER JOIN Ratemanagement3.tblAccount a
		ON sh.AccountID = a.AccountID
	LEFT JOIN Ratemanagement3.tblTrunk t
		ON t.Trunk = sh.Trunk
	LEFT JOIN tmp_AreaPrefix_ ap 
		ON sh.AreaPrefix LIKE REPLACE(ap.Code, '*', '%')
	WHERE dd.date BETWEEN DATE(p_StartDate) AND DATE(p_EndDate)
	AND CONCAT(dd.date,' ',dt.fulltime) BETWEEN p_StartDate AND p_EndDate
	AND sh.CompanyID = p_CompanyID
	AND (p_AccountID = '' OR FIND_IN_SET(sh.AccountID,p_AccountID))
	AND (p_CompanyGatewayID = '' OR FIND_IN_SET(sh.CompanyGatewayID,p_CompanyGatewayID))
	AND (p_isAdmin = 1 OR (p_isAdmin= 0 AND a.Owner = p_UserID))
	AND (p_Trunk = '' OR FIND_IN_SET(t.TrunkID,p_Trunk))
	AND (p_CountryID = '' OR FIND_IN_SET(sh.CountryID,p_CountryID))
	AND (p_CurrencyID = 0 OR a.CurrencyId = p_CurrencyID)
	AND (p_AreaPrefix ='' OR ap.Code IS NOT NULL);

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_datedimbuild` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_datedimbuild`(IN `p_start_date` DATE, IN `p_end_date` DATE)
BEGIN
    DECLARE v_full_date DATE;

     DELETE FROM tblDimDate;

    SET v_full_date = p_start_date;
    WHILE v_full_date < p_end_date DO

        INSERT INTO tblDimDate (
            	`date`,
					`day`,
					`day_abbrev`,
					`day_of_week`,
					`day_of_month`,
					`day_of_quarter`,
					`day_of_semester`,
					`day_of_year`,
					`weekend`,
					`week_of_month`,
					`week_of_quarter`,
					`week_of_semester`,
					`week_of_year`,
					`month`,
					`month_abbrev`,
					`month_of_quarter`,
					`month_of_year`,
					`quarter_of_year`,
					`previous_day`,
					`next_day`,
					`start_week`,
					`end_week`,
					`start_month`,
					`end_month`,
					`start_quarter`,
					`end_quarter`,
					`year`,
					`week_month_name`,
					`week_quarter_name`,
					`week_year_name`,
					`month_quarter_name`,
					`month_year_name`,
					`quarter_year_name`
        ) VALUES (
        			v_full_date,
					DATE_FORMAT( v_full_date , "%W" ),
					DATE_FORMAT( v_full_date , "%a"),
					DAYOFWEEK(v_full_date),
					DAYOFMONTH(v_full_date),
					NULL,
					NULL,
					DAYOFYEAR(v_full_date),
					IF( DATE_FORMAT( v_full_date, "%W" ) IN ('Saturday','Sunday'), 'Weekend', 'Weekday'),
					WEEK(v_full_date) - WEEK(DATE_ADD(v_full_date,INTERVAL -DAY(v_full_date)+1 DAY)),
					NULL,
					NULL,
					WEEKOFYEAR(v_full_date),
					DATE_FORMAT( v_full_date , "%M"),
					DATE_FORMAT( v_full_date , "%b"),
					MOD(MONTH('2016-02-20')-1,3)+1,
					MONTH(v_full_date),
					QUARTER(v_full_date),
					DATE_ADD(v_full_date, INTERVAL -1 DAY),
					DATE_ADD(v_full_date, INTERVAL +1 DAY),
					v_full_date,
					v_full_date,
					v_full_date,
					v_full_date,
					v_full_date,
					v_full_date,
					YEAR(v_full_date),
					CONCAT(WEEK(v_full_date) - WEEK(DATE_ADD(v_full_date,INTERVAL -DAY(v_full_date)+1 DAY)),'-',DATE_FORMAT( v_full_date , "%M")),
					NULL,
					CONCAT(WEEK(date),'-',DATE_FORMAT( date , "%Y")),
					NULL,
					CONCAT(month_abbrev,'-',year),
					CONCAT(quarter_of_year,'-',year)
        );

        SET v_full_date = DATE_ADD(v_full_date, INTERVAL 1 DAY);
    END WHILE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_generateSummary` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_generateSummary`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE




)
BEGIN
	DECLARE EXIT HANDLER FOR SQLEXCEPTION
	BEGIN
		
		GET DIAGNOSTICS CONDITION 1
		@p2 = MESSAGE_TEXT;
	
		SELECT @p2 as Message;
		ROLLBACK;
	END;
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	CALL fngetDefaultCodes(p_CompanyID); 
	CALL fnGetUsageForSummary(p_CompanyID,p_StartDate,p_EndDate);
 
 	
 	DELETE FROM tmp_UsageSummary WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_UsageSummary(DateID,TimeID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,AccountID,Trunk,AreaPrefix,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		d.DateID,
		t.TimeID,
		ud.CompanyID,
		ud.CompanyGatewayID,
		ud.ServiceID,
		ANY_VALUE(ud.GatewayAccountID),
		ud.AccountID,
		ud.trunk,
		ud.area_prefix,
		COALESCE(SUM(ud.cost),0)  AS TotalCharges ,
		COALESCE(SUM(ud.billed_duration),0) AS TotalBilledDuration ,
		COALESCE(SUM(ud.duration),0) AS TotalDuration,
		SUM(IF(ud.call_status=1,1,0)) AS  NoOfCalls,
		SUM(IF(ud.call_status=2,1,0)) AS  NoOfFailCalls
	FROM tmp_tblUsageDetailsReport ud  
	INNER JOIN tblDimTime t ON t.fulltime = connect_time
	INNER JOIN tblDimDate d ON d.date = connect_date
	GROUP BY d.DateID,t.TimeID,ud.area_prefix,ud.trunk,ud.AccountID,ud.CompanyGatewayID,ud.ServiceID,ud.CompanyID;

	UPDATE tmp_UsageSummary 
	INNER JOIN  tmp_codes_ as code ON AreaPrefix = code.code
	SET tmp_UsageSummary.CountryID =code.CountryID
	WHERE tmp_UsageSummary.CompanyID = p_CompanyID AND code.CountryID > 0;

	DELETE FROM tmp_SummaryHeader WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_SummaryHeader (SummaryHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_UsageSummary)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;
	
	START TRANSACTION;
	
	INSERT INTO tblSummaryHeader (DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT us.DateID,us.CompanyID,us.AccountID,ANY_VALUE(us.GatewayAccountID),us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix,ANY_VALUE(us.CountryID),now() 
	FROM tmp_UsageSummary us
	LEFT JOIN tmp_SummaryHeader sh	 
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID
	WHERE sh.SummaryHeaderID IS NULL
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;
	
	DELETE FROM tmp_SummaryHeader WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_SummaryHeader (SummaryHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_UsageSummary)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	DELETE us FROM tblUsageSummary us 
	INNER JOIN tblSummaryHeader sh ON us.SummaryHeaderID = sh.SummaryHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE date BETWEEN p_StartDate AND p_EndDate AND sh.CompanyID = p_CompanyID;
	
	DELETE usd FROM tblUsageSummaryDetail usd
	INNER JOIN tblSummaryHeader sh ON usd.SummaryHeaderID = sh.SummaryHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE date BETWEEN p_StartDate AND p_EndDate AND sh.CompanyID = p_CompanyID;
	
	INSERT INTO tblUsageSummary (SummaryHeaderID,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT ANY_VALUE(sh.SummaryHeaderID),SUM(us.TotalCharges),SUM(us.TotalBilledDuration),SUM(us.TotalDuration),SUM(us.NoOfCalls),SUM(us.NoOfFailCalls)
	FROM tmp_SummaryHeader sh
	INNER JOIN tmp_UsageSummary us FORCE INDEX (Unique_key)	 
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;
	
	INSERT INTO tblUsageSummaryDetail (SummaryHeaderID,TimeID,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT sh.SummaryHeaderID,TimeID,us.TotalCharges,us.TotalBilledDuration,us.TotalDuration,us.NoOfCalls,us.NoOfFailCalls
	FROM tmp_SummaryHeader sh
	INNER JOIN tmp_UsageSummary us FORCE INDEX (Unique_key)
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID;

	DELETE h FROM tblHeader h 
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_UsageSummary)u
		ON h.DateID = u.DateID 
		AND h.CompanyID = u.CompanyID
	WHERE u.CompanyID = p_CompanyID;
	
	INSERT INTO tblHeader(DateID,CompanyID,AccountID,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		u.DateID,
		u.CompanyID,
		u.AccountID,
		SUM(u.TotalCharges) as TotalCharges,
		SUM(u.TotalBilledDuration) as TotalBilledDuration,
		SUM(u.TotalDuration) as TotalDuration,
		SUM(u.NoOfCalls) as NoOfCalls,
		SUM(u.NoOfFailCalls) as NoOfFailCalls
	FROM tmp_UsageSummary u 
	WHERE u.CompanyID = p_CompanyID
	GROUP BY u.DateID,u.AccountID,u.CompanyID;

	COMMIT;
	
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_generateSummaryLive` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_generateSummaryLive`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE




)
BEGIN

	DECLARE EXIT HANDLER FOR SQLEXCEPTION
	BEGIN
		
		GET DIAGNOSTICS CONDITION 1
		@p2 = MESSAGE_TEXT;
	
		SELECT @p2 as Message;
		ROLLBACK;
	END;
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	CALL fngetDefaultCodes(p_CompanyID); 
	CALL fnGetUsageForSummaryLive(p_CompanyID, p_StartDate, p_EndDate);
	 
 	
 	DELETE FROM tmp_UsageSummaryLive WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_UsageSummaryLive(DateID,TimeID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,AccountID,Trunk,AreaPrefix,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		d.DateID,
		t.TimeID,
		ud.CompanyID,
		ud.CompanyGatewayID,
		ud.ServiceID,
		ANY_VALUE(ud.GatewayAccountID),
		ud.AccountID,
		ud.trunk,
		ud.area_prefix,
		COALESCE(SUM(ud.cost),0)  AS TotalCharges ,
		COALESCE(SUM(ud.billed_duration),0) AS TotalBilledDuration ,
		COALESCE(SUM(ud.duration),0) AS TotalDuration,
		SUM(IF(ud.call_status=1,1,0)) AS  NoOfCalls,
		SUM(IF(ud.call_status=2,1,0)) AS  NoOfFailCalls
	FROM tmp_tblUsageDetailsReportLive ud  
	INNER JOIN tblDimTime t ON t.fulltime = connect_time
	INNER JOIN tblDimDate d ON d.date = connect_date
	GROUP BY d.DateID,t.TimeID,ud.area_prefix,ud.trunk,ud.AccountID,ud.CompanyGatewayID,ud.ServiceID,ud.CompanyID;

	UPDATE tmp_UsageSummaryLive 
	INNER JOIN  tmp_codes_ as code ON AreaPrefix = code.code
	SET tmp_UsageSummaryLive.CountryID =code.CountryID
	WHERE tmp_UsageSummaryLive.CompanyID = p_CompanyID AND code.CountryID > 0;

	DELETE FROM tmp_SummaryHeaderLive WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_SummaryHeaderLive (SummaryHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_UsageSummaryLive)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	START TRANSACTION;

	INSERT INTO tblSummaryHeader (DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT us.DateID,us.CompanyID,us.AccountID,ANY_VALUE(us.GatewayAccountID),us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix,ANY_VALUE(us.CountryID),now() 
	FROM tmp_UsageSummaryLive us
	LEFT JOIN tmp_SummaryHeaderLive sh	 
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID
	WHERE sh.SummaryHeaderID IS NULL
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;

	DELETE FROM tmp_SummaryHeaderLive WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_SummaryHeaderLive (SummaryHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_UsageSummaryLive)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	DELETE us FROM tblUsageSummaryLive us 
	INNER JOIN tblSummaryHeader sh ON us.SummaryHeaderID = sh.SummaryHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE sh.CompanyID = p_CompanyID; 

	DELETE usd FROM tblUsageSummaryDetailLive usd
	INNER JOIN tblSummaryHeader sh ON usd.SummaryHeaderID = sh.SummaryHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE sh.CompanyID = p_CompanyID;

	INSERT INTO tblUsageSummaryLive (SummaryHeaderID,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT ANY_VALUE(sh.SummaryHeaderID),SUM(us.TotalCharges),SUM(us.TotalBilledDuration),SUM(us.TotalDuration),SUM(us.NoOfCalls),SUM(us.NoOfFailCalls)
	FROM tmp_SummaryHeaderLive sh
	INNER JOIN tmp_UsageSummaryLive us FORCE INDEX (Unique_key)
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix; 
	
	INSERT INTO tblUsageSummaryDetailLive (SummaryHeaderID,TimeID,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT sh.SummaryHeaderID,TimeID,us.TotalCharges,us.TotalBilledDuration,us.TotalDuration,us.NoOfCalls,us.NoOfFailCalls
	FROM tmp_SummaryHeaderLive sh
	INNER JOIN tmp_UsageSummaryLive us FORCE INDEX (Unique_key)
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID;
	
	DELETE h FROM tblHeader h 
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_UsageSummaryLive)u
		ON h.DateID = u.DateID 
		AND h.CompanyID = u.CompanyID
	WHERE u.CompanyID = p_CompanyID;
	
	INSERT INTO tblHeader(DateID,CompanyID,AccountID,TotalCharges,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		u.DateID,
		u.CompanyID,
		u.AccountID,
		SUM(u.TotalCharges) as TotalCharges,
		SUM(u.TotalBilledDuration) as TotalBilledDuration,
		SUM(u.TotalDuration) as TotalDuration,
		SUM(u.NoOfCalls) as NoOfCalls,
		SUM(u.NoOfFailCalls) as NoOfFailCalls
	FROM tmp_UsageSummaryLive u 
	WHERE u.CompanyID = p_CompanyID
	GROUP BY u.DateID,u.AccountID,u.CompanyID;
	

	COMMIT;
	
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_generateVendorSummary` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_generateVendorSummary`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE





)
BEGIN
	DECLARE EXIT HANDLER FOR SQLEXCEPTION
	BEGIN
		-- ERROR
		GET DIAGNOSTICS CONDITION 1
		@p2 = MESSAGE_TEXT;
	
		SELECT @p2 as Message;
		ROLLBACK;
	END;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	CALL fngetDefaultCodes(p_CompanyID); 
	CALL fnGetVendorUsageForSummary(p_CompanyID,p_StartDate,p_EndDate);

 	/* insert into success summary*/
 	DELETE FROM tmp_VendorUsageSummary WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_VendorUsageSummary(DateID,TimeID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,AccountID,Trunk,AreaPrefix,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		d.DateID,
		t.TimeID,
		ud.CompanyID,
		ud.CompanyGatewayID,
		ud.ServiceID,
		ANY_VALUE(ud.GatewayAccountID),
		ud.AccountID,
		ud.trunk,
		ud.area_prefix,
		COALESCE(SUM(ud.buying_cost),0)  AS TotalCharges ,
		COALESCE(SUM(ud.selling_cost),0)  AS TotalSales ,
		COALESCE(SUM(ud.billed_duration),0) AS TotalBilledDuration ,
		COALESCE(SUM(ud.duration),0) AS TotalDuration,
		SUM(IF(ud.call_status=1,1,0)) AS  NoOfCalls,
		SUM(IF(ud.call_status=2,1,0)) AS  NoOfFailCalls
	FROM tmp_tblVendorUsageDetailsReport ud  
	INNER JOIN tblDimTime t ON t.fulltime = connect_time
	INNER JOIN tblDimDate d ON d.date = connect_date
	GROUP BY d.DateID,t.TimeID,ud.area_prefix,ud.trunk,ud.AccountID,ud.CompanyGatewayID,ud.ServiceID,ud.CompanyID;

	UPDATE tmp_VendorUsageSummary 
	INNER JOIN  tmp_codes_ as code ON AreaPrefix = code.code
	SET tmp_VendorUsageSummary.CountryID =code.CountryID
	WHERE tmp_VendorUsageSummary.CompanyID = p_CompanyID AND code.CountryID > 0;

	DELETE FROM tmp_SummaryVendorHeader WHERE CompanyID = p_CompanyID;

	INSERT INTO tmp_SummaryVendorHeader (SummaryVendorHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryVendorHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryVendorHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_VendorUsageSummary)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	START TRANSACTION;

	INSERT INTO tblSummaryVendorHeader (DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT us.DateID,us.CompanyID,us.AccountID,ANY_VALUE(us.GatewayAccountID),us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix,ANY_VALUE(us.CountryID),now() 
	FROM tmp_VendorUsageSummary us
	LEFT JOIN tmp_SummaryVendorHeader sh	 
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID
	WHERE sh.SummaryVendorHeaderID IS NULL
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;

	DELETE FROM tmp_SummaryVendorHeader WHERE CompanyID = p_CompanyID;

	INSERT INTO tmp_SummaryVendorHeader (SummaryVendorHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryVendorHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryVendorHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_VendorUsageSummary)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	DELETE us FROM tblUsageVendorSummary us 
	INNER JOIN tblSummaryVendorHeader sh ON us.SummaryVendorHeaderID = sh.SummaryVendorHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE date BETWEEN p_StartDate AND p_EndDate AND sh.CompanyID = p_CompanyID;

	DELETE usd FROM tblUsageVendorSummaryDetail usd
	INNER JOIN tblSummaryVendorHeader sh ON usd.SummaryVendorHeaderID = sh.SummaryVendorHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE date BETWEEN p_StartDate AND p_EndDate AND sh.CompanyID = p_CompanyID;

	INSERT INTO tblUsageVendorSummary (SummaryVendorHeaderID,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT ANY_VALUE(sh.SummaryVendorHeaderID),SUM(us.TotalCharges),SUM(us.TotalSales),SUM(us.TotalBilledDuration),SUM(us.TotalDuration),SUM(us.NoOfCalls),SUM(us.NoOfFailCalls)
	FROM tmp_SummaryVendorHeader sh
	INNER JOIN tmp_VendorUsageSummary us FORCE INDEX (Unique_key)	 
	ON 
		 sh.DateID = us.DateID
	AND sh.CompanyID = us.CompanyID
	AND sh.AccountID = us.AccountID
	AND sh.CompanyGatewayID = us.CompanyGatewayID
	AND sh.Trunk = us.Trunk
	AND sh.AreaPrefix = us.AreaPrefix
	AND sh.ServiceID = us.ServiceID
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;

	INSERT INTO tblUsageVendorSummaryDetail (SummaryVendorHeaderID,TimeID,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT sh.SummaryVendorHeaderID,TimeID,us.TotalCharges,us.TotalSales,us.TotalBilledDuration,us.TotalDuration,us.NoOfCalls,us.NoOfFailCalls
	FROM tmp_SummaryVendorHeader sh
	INNER JOIN tmp_VendorUsageSummary us FORCE INDEX (Unique_key)
	ON 
		sh.DateID = us.DateID
	AND sh.CompanyID = us.CompanyID
	AND sh.AccountID = us.AccountID
	AND sh.CompanyGatewayID = us.CompanyGatewayID
	AND sh.Trunk = us.Trunk
	AND sh.AreaPrefix = us.AreaPrefix
	AND sh.ServiceID = us.ServiceID;

	DELETE h FROM tblHeaderV h 
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_VendorUsageSummary)u
		ON h.DateID = u.DateID 
		AND h.CompanyID = u.CompanyID
	WHERE u.CompanyID = p_CompanyID;
	
	INSERT INTO tblHeaderV(DateID,CompanyID,VAccountID,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		u.DateID,
		u.CompanyID,
		u.AccountID,
		SUM(u.TotalCharges) as TotalCharges,
		SUM(u.TotalSales) as TotalSales,
		SUM(u.TotalBilledDuration) as TotalBilledDuration,
		SUM(u.TotalDuration) as TotalDuration,
		SUM(u.NoOfCalls) as NoOfCalls,
		SUM(u.NoOfFailCalls) as NoOfFailCalls
	FROM tmp_VendorUsageSummary u 
	WHERE u.CompanyID = p_CompanyID
	GROUP BY u.DateID,u.AccountID,u.CompanyID;
	
	COMMIT;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_generateVendorSummaryLive` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_generateVendorSummaryLive`(
	IN `p_CompanyID` INT,
	IN `p_StartDate` DATE,
	IN `p_EndDate` DATE





)
BEGIN
	
	DECLARE EXIT HANDLER FOR SQLEXCEPTION
	BEGIN
		-- ERROR
		GET DIAGNOSTICS CONDITION 1
		@p2 = MESSAGE_TEXT;
	
		SELECT @p2 as Message;
		ROLLBACK;
	END;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	CALL fngetDefaultCodes(p_CompanyID); 
	CALL fnGetVendorUsageForSummaryLive(p_CompanyID, p_StartDate, p_EndDate);

 	/* insert into success summary*/
 	DELETE FROM tmp_VendorUsageSummaryLive WHERE CompanyID = p_CompanyID;
	INSERT INTO tmp_VendorUsageSummaryLive(DateID,TimeID,CompanyID,CompanyGatewayID,ServiceID,GatewayAccountID,AccountID,Trunk,AreaPrefix,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		d.DateID,
		t.TimeID,
		ud.CompanyID,
		ud.CompanyGatewayID,
		ud.ServiceID,
		ANY_VALUE(ud.GatewayAccountID),
		ud.AccountID,
		ud.trunk,
		ud.area_prefix,
		COALESCE(SUM(ud.buying_cost),0)  AS TotalCharges ,
		COALESCE(SUM(ud.selling_cost),0)  AS TotalSales ,
		COALESCE(SUM(ud.billed_duration),0) AS TotalBilledDuration ,
		COALESCE(SUM(ud.duration),0) AS TotalDuration,
		SUM(IF(ud.call_status=1,1,0)) AS  NoOfCalls,
		SUM(IF(ud.call_status=2,1,0)) AS  NoOfFailCalls
	FROM tmp_tblVendorUsageDetailsReportLive ud  
	INNER JOIN tblDimTime t ON t.fulltime = connect_time
	INNER JOIN tblDimDate d ON d.date = connect_date
	GROUP BY d.DateID,t.TimeID,ud.area_prefix,ud.trunk,ud.AccountID,ud.CompanyGatewayID,ud.ServiceID,ud.CompanyID;

	UPDATE tmp_VendorUsageSummaryLive 
	INNER JOIN  tmp_codes_ as code ON AreaPrefix = code.code
	SET tmp_VendorUsageSummaryLive.CountryID =code.CountryID
	WHERE tmp_VendorUsageSummaryLive.CompanyID = p_CompanyID AND code.CountryID > 0;

	DELETE FROM tmp_SummaryVendorHeaderLive WHERE CompanyID = p_CompanyID;

	INSERT INTO tmp_SummaryVendorHeaderLive (SummaryVendorHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryVendorHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryVendorHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_VendorUsageSummaryLive)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	START TRANSACTION;

	INSERT INTO tblSummaryVendorHeader (DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT us.DateID,us.CompanyID,us.AccountID,ANY_VALUE(us.GatewayAccountID),us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix,ANY_VALUE(us.CountryID),now() 
	FROM tmp_VendorUsageSummaryLive us
	LEFT JOIN tmp_SummaryVendorHeaderLive sh	 
	ON 
		 us.DateID = sh.DateID
	AND us.CompanyID = sh.CompanyID
	AND us.AccountID = sh.AccountID
	AND us.CompanyGatewayID = sh.CompanyGatewayID
	AND us.Trunk = sh.Trunk
	AND us.AreaPrefix = sh.AreaPrefix
	AND us.ServiceID = sh.ServiceID
	WHERE sh.SummaryVendorHeaderID IS NULL
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;

	DELETE FROM tmp_SummaryVendorHeaderLive WHERE CompanyID = p_CompanyID;

	INSERT INTO tmp_SummaryVendorHeaderLive (SummaryVendorHeaderID,DateID,CompanyID,AccountID,GatewayAccountID,CompanyGatewayID,ServiceID,Trunk,AreaPrefix,CountryID,created_at)
	SELECT 
		sh.SummaryVendorHeaderID,
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.GatewayAccountID,
		sh.CompanyGatewayID,
		sh.ServiceID,
		sh.Trunk,
		sh.AreaPrefix,
		sh.CountryID,
		sh.created_at 
	FROM tblSummaryVendorHeader sh
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_VendorUsageSummaryLive)TBL
	ON TBL.DateID = sh.DateID AND TBL.CompanyID = sh.CompanyID
	WHERE sh.CompanyID =  p_CompanyID ;

	DELETE us FROM tblUsageVendorSummaryLive us 
	INNER JOIN tblSummaryVendorHeader sh ON us.SummaryVendorHeaderID = sh.SummaryVendorHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE sh.CompanyID = p_CompanyID;

	DELETE usd FROM tblUsageVendorSummaryDetailLive usd
	INNER JOIN tblSummaryVendorHeader sh ON usd.SummaryVendorHeaderID = sh.SummaryVendorHeaderID
	INNER JOIN tblDimDate d ON d.DateID = sh.DateID
	WHERE sh.CompanyID = p_CompanyID;

	INSERT INTO tblUsageVendorSummaryLive (SummaryVendorHeaderID,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT ANY_VALUE(sh.SummaryVendorHeaderID),SUM(us.TotalCharges),SUM(us.TotalSales),SUM(us.TotalBilledDuration),SUM(us.TotalDuration),SUM(us.NoOfCalls),SUM(us.NoOfFailCalls)
	FROM tmp_SummaryVendorHeaderLive sh
	INNER JOIN tmp_VendorUsageSummaryLive us FORCE INDEX (Unique_key)	 
	ON 
		 sh.DateID = us.DateID
	AND sh.CompanyID = us.CompanyID
	AND sh.AccountID = us.AccountID
	AND sh.CompanyGatewayID = us.CompanyGatewayID
	AND sh.Trunk = us.Trunk
	AND sh.AreaPrefix = us.AreaPrefix
	AND sh.ServiceID = us.ServiceID
	GROUP BY us.DateID,us.CompanyID,us.AccountID,us.CompanyGatewayID,us.ServiceID,us.Trunk,us.AreaPrefix;

	INSERT INTO tblUsageVendorSummaryDetailLive (SummaryVendorHeaderID,TimeID,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT sh.SummaryVendorHeaderID,TimeID,us.TotalCharges,us.TotalSales,us.TotalBilledDuration,us.TotalDuration,us.NoOfCalls,us.NoOfFailCalls
	FROM tmp_SummaryVendorHeaderLive sh
	INNER JOIN tmp_VendorUsageSummaryLive us FORCE INDEX (Unique_key)
	ON 
		 sh.DateID = us.DateID
	AND sh.CompanyID = us.CompanyID
	AND sh.AccountID = us.AccountID
	AND sh.CompanyGatewayID = us.CompanyGatewayID
	AND sh.Trunk = us.Trunk
	AND sh.AreaPrefix = us.AreaPrefix
	AND sh.ServiceID = us.ServiceID;
	
	DELETE h FROM tblHeaderV h 
	INNER JOIN (SELECT DISTINCT DateID,CompanyID FROM tmp_VendorUsageSummaryLive)u
		ON h.DateID = u.DateID 
		AND h.CompanyID = u.CompanyID
	WHERE u.CompanyID = p_CompanyID;
	
	INSERT INTO tblHeaderV(DateID,CompanyID,VAccountID,TotalCharges,TotalSales,TotalBilledDuration,TotalDuration,NoOfCalls,NoOfFailCalls)
	SELECT 
		u.DateID,
		u.CompanyID,
		u.AccountID,
		SUM(u.TotalCharges) as TotalCharges,
		SUM(u.TotalSales) as TotalSales,
		SUM(u.TotalBilledDuration) as TotalBilledDuration,
		SUM(u.TotalDuration) as TotalDuration,
		SUM(u.NoOfCalls) as NoOfCalls,
		SUM(u.NoOfFailCalls) as NoOfFailCalls
	FROM tmp_VendorUsageSummaryLive u 
	WHERE u.CompanyID = p_CompanyID
	GROUP BY u.DateID,u.AccountID,u.CompanyID;

	COMMIT;
	
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getAccountExpense` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getAccountExpense`(IN `p_CompanyID` INT, IN `p_AccountID` INT)
BEGIN
	DECLARE v_Round_ int;
	DECLARE v_DateID_ int;
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	SELECT MIN(DateID) INTO v_DateID_ FROM tblDimDate WHERE fnGetMonthDifference(date,NOW()) <= 12;

	DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageSummary_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageSummary_(
		`DateID` BIGINT(20) NOT NULL,
		`CompanyID` INT(11) NOT NULL,
		`AccountID` INT(11) NOT NULL,
		`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
		`TotalCharges` DOUBLE NULL DEFAULT NULL,
		`CustomerVendor` INT,
		INDEX `tmp_tblUsageSummary_DateID` (`DateID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_tblUsageSummary2_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblUsageSummary2_(
		`DateID` BIGINT(20) NOT NULL,
		`CompanyID` INT(11) NOT NULL,
		`AccountID` INT(11) NOT NULL,
		`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
		`TotalCharges` DOUBLE NULL DEFAULT NULL,
		`CustomerVendor` INT,
		INDEX `tmp_tblUsageSummary_DateID` (`DateID`)
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_tblCustomerPrefix_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblCustomerPrefix_(
		`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
		`CustomerTotal` DOUBLE NULL DEFAULT NULL,
		`FinalTotal` DOUBLE NULL DEFAULT NULL,
		`YearMonth` VARCHAR(50) NOT NULL
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_tblVendorPrefix_;
	CREATE TEMPORARY TABLE IF NOT EXISTS tmp_tblVendorPrefix_(
		`AreaPrefix` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
		`VendorTotal` DOUBLE NULL DEFAULT NULL,
		`FinalTotal` DOUBLE NULL DEFAULT NULL,
		`YearMonth` VARCHAR(50) NOT NULL
	);
	
	/* insert customer summary */
	INSERT INTO tmp_tblUsageSummary_
	SELECT
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.AreaPrefix,
		us.TotalCharges,
		1 as Customer
	FROM tblSummaryHeader sh
	INNER JOIN tblUsageSummary us
		ON us.SummaryHeaderID = sh.SummaryHeaderID 
	WHERE  sh.CompanyID = p_CompanyID
	AND sh.AccountID = p_AccountID;
	
	INSERT INTO tmp_tblUsageSummary_
	SELECT
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.AreaPrefix,
		us.TotalCharges,
		1 as Customer
	FROM tblSummaryHeader sh
	INNER JOIN tblUsageSummaryLive us
		ON us.SummaryHeaderID = sh.SummaryHeaderID 
	WHERE  sh.CompanyID = p_CompanyID
	AND sh.AccountID = p_AccountID;
	
	/* insert vendor summary */
	INSERT INTO tmp_tblUsageSummary_
	SELECT
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.AreaPrefix,
		us.TotalCharges,
		2 as Vendor
	FROM tblSummaryVendorHeader sh
	INNER JOIN tblUsageVendorSummary us
		ON us.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
	WHERE  sh.CompanyID = p_CompanyID
	AND sh.AccountID = p_AccountID;
	
	INSERT INTO tmp_tblUsageSummary_
	SELECT
		sh.DateID,
		sh.CompanyID,
		sh.AccountID,
		sh.AreaPrefix,
		us.TotalCharges,
		2 as Vendor
	FROM tblSummaryVendorHeader sh
	INNER JOIN tblUsageVendorSummaryLive us
		ON us.SummaryVendorHeaderID = sh.SummaryVendorHeaderID 
	WHERE  sh.CompanyID = p_CompanyID
	AND sh.AccountID = p_AccountID;
	
	INSERT INTO tmp_tblUsageSummary2_
	SELECT * FROM tmp_tblUsageSummary_;
	
	/* customer and vendor chart by month and year */
	SELECT 
		ROUND(SUM(IF(CustomerVendor=1,TotalCharges,0)),v_Round_) AS  CustomerTotal,
		ROUND(SUM(IF(CustomerVendor=2,TotalCharges,0)),v_Round_) AS  VendorTotal,
		dd.year as Year,
		dd.month_of_year as Month
	FROM tmp_tblUsageSummary_ us 
	INNER JOIN tblDimDate dd ON dd.DateID = us.DateID
	GROUP BY dd.year,dd.month_of_year;
	
	/* top 5 customer destination month and year */
	INSERT INTO tmp_tblCustomerPrefix_
	SELECT 
		us.AreaPrefix,
		ROUND(SUM(TotalCharges),2) AS  CustomerTotal,
		FinalTotal,
		CONCAT(dd.year,'-',dd.month_of_year) as YearMonth
	FROM tmp_tblUsageSummary_ us 
	INNER JOIN 
	(SELECT SUM(TotalCharges) as FinalTotal,AreaPrefix FROM tmp_tblUsageSummary2_ WHERE CustomerVendor = 1 AND AreaPrefix != 'other' AND DateID >= v_DateID_ GROUP BY AreaPrefix ORDER BY FinalTotal DESC LIMIT 5 ) tbl
	ON tbl.AreaPrefix = us.AreaPrefix
	INNER JOIN tblDimDate dd ON dd.DateID = us.DateID
	WHERE 
			 us.CustomerVendor = 1 
		AND us.AreaPrefix != 'other'
		AND dd.DateID >= v_DateID_
	GROUP BY dd.year,dd.month_of_year,us.AreaPrefix;
	
	/* convert into pivot table*/
	
	IF (SELECT COUNT(*) FROM tmp_tblCustomerPrefix_) > 0
	THEN
		SET @sql = NULL;
		
		SELECT
			GROUP_CONCAT( DISTINCT CONCAT('MAX(IF(YearMonth = ''',YearMonth,''', CustomerTotal, 0)) AS ''',YearMonth,'''') ) INTO @sql
		FROM tmp_tblCustomerPrefix_;
	
		SET @sql = CONCAT('
							SELECT AreaPrefix , ', @sql, ' 
							FROM tmp_tblCustomerPrefix_ 
							GROUP BY AreaPrefix
							ORDER BY MAX(FinalTotal) desc, MAX(YearMonth)
						');
		
		PREPARE stmt FROM @sql;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;
	ELSE
		SELECT 0 as datacount;
	END IF;

	/* top 5 vendor destination month and year */
	INSERT INTO tmp_tblVendorPrefix_
	SELECT 
		us.AreaPrefix,
		ROUND(SUM(TotalCharges),2) AS  VendorTotal,
		FinalTotal,
		CONCAT(dd.year,'-',dd.month_of_year) as YearMonth
	FROM tmp_tblUsageSummary_ us 
	INNER JOIN 
	(SELECT SUM(TotalCharges) as FinalTotal,AreaPrefix FROM tmp_tblUsageSummary2_ WHERE CustomerVendor = 2 AND AreaPrefix != 'other' AND DateID >= v_DateID_ GROUP BY AreaPrefix ORDER BY FinalTotal DESC LIMIT 5 ) tbl
	ON tbl.AreaPrefix = us.AreaPrefix
	INNER JOIN tblDimDate dd ON dd.DateID = us.DateID
	WHERE 
			 us.CustomerVendor = 2 
		AND us.AreaPrefix != 'other'
		AND dd.DateID >= v_DateID_
	GROUP BY dd.year,dd.month_of_year,us.AreaPrefix;

	/* convert into pivot table*/
	
	IF (SELECT COUNT(*) FROM tmp_tblVendorPrefix_) > 0
	THEN
	
		SET @stm = NULL;
		SELECT
			GROUP_CONCAT( DISTINCT CONCAT('MAX(IF(YearMonth = ''',YearMonth,''', VendorTotal, 0)) AS ''',YearMonth,'''') ) INTO @stm
		FROM tmp_tblVendorPrefix_;

		SET @stm = CONCAT('
							SELECT AreaPrefix , ', @stm, ' 
							FROM tmp_tblVendorPrefix_ 
							GROUP BY AreaPrefix
							ORDER BY MAX(FinalTotal) desc, MAX(YearMonth)
						');
		PREPARE stmt FROM @stm;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;
	ELSE
		SELECT 0 as datacount;	
	END IF;
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
	
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getAccountReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getAccountReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* account by call count */	
	SELECT AccountName ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,MAX(AccountID) as AccountID
	FROM tmp_tblUsageSummary_ us
	GROUP BY AccountName   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AccountNameDESC') THEN AccountName
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AccountNameASC') THEN AccountName
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT AccountName ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AccountName
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   AccountName  as Name ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AccountName;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 account by call count */	
		SELECT AccountName as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AccountName HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 account by call cost */	
		SELECT AccountName as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AccountName HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 account by call minutes */	
		SELECT AccountName as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AccountName HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getACD_ASR_Alert` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getACD_ASR_Alert`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` TEXT,
	IN `p_AccountID` TEXT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` TEXT,
	IN `p_Trunk` TEXT,
	IN `p_CountryID` TEXT
)
BEGIN
	
	DECLARE v_Round_ INT;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageSummaryDetail(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,0,1);

	IF p_AccountID = ''
	THEN
		SELECT
			IF(SUM(NoOfCalls)>0,COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls),0) as ACD , 
			ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
			HOUR(ANY_VALUE(Time)) as Hour,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as Minutes,
			COALESCE(SUM(NoOfCalls),0) as Connected,
			COALESCE(SUM(NoOfCalls),0)+COALESCE(SUM(NoOfFailCalls),0) as Attempts
		FROM tmp_tblUsageSummary_ us;
		
	END IF;
	
	IF p_AccountID != ''
	THEN
		SELECT
			IF(SUM(NoOfCalls)>0,COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls),0) as ACD , 
			ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
			AccountID,
			HOUR(ANY_VALUE(Time)) as Hour,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as Minutes,
			COALESCE(SUM(NoOfCalls),0) as Connected,
			COALESCE(SUM(NoOfCalls),0)+COALESCE(SUM(NoOfFailCalls),0) as Attempts
		FROM tmp_tblUsageSummary_ us
		GROUP BY AccountID;
	END IF;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getDashboardPayableReceivable` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getDashboardPayableReceivable`(
	IN `p_CompanyID` INT,
	IN `p_CurrencyID` INT,
	IN `p_AccountID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_Unbilled` INT,
	IN `p_ListType` VARCHAR(50)




)
BEGIN
	DECLARE v_Round_ INT;
	DECLARE prev_TotalInvoiceOut  DECIMAL(18,6);
	DECLARE prev_TotalInvoiceIn DECIMAL(18,6);
	DECLARE prev_TotalPaymentOut DECIMAL(18,6);
	DECLARE prev_TotalPaymentIn DECIMAL(18,6);
	DECLARE prev_CustomerUnbill DECIMAL(18,6);
	DECLARE prev_VendrorUnbill DECIMAL(18,6);

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	DROP TEMPORARY TABLE IF EXISTS tmp_CustomerUnbilled_;
	CREATE TEMPORARY TABLE tmp_CustomerUnbilled_  (
		DateID INT,
		CustomerUnbill DOUBLE
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_VendorUbilled_;
	CREATE TEMPORARY TABLE tmp_VendorUbilled_  (
		DateID INT,
		VendrorUnbill DOUBLE
	);
	
	DROP TEMPORARY TABLE IF EXISTS tmp_FinalResult_;
	CREATE TEMPORARY TABLE tmp_FinalResult_  (
		TotalInvoiceOut DOUBLE,
		TotalInvoiceIn DOUBLE,
		TotalPaymentOut DOUBLE,
		TotalPaymentIn DOUBLE,
		CustomerUnbill DOUBLE,
		VendrorUnbill DOUBLE,
		date DATE,
		TotalOutstanding DOUBLE,
		TotalPayable DOUBLE,
		TotalReceivable DOUBLE
	);
	
	DROP TEMPORARY TABLE IF EXISTS tmp_FinalResult2_;
	CREATE TEMPORARY TABLE tmp_FinalResult2_  (
		TotalInvoiceOut DOUBLE,
		TotalInvoiceIn DOUBLE,
		TotalPaymentOut DOUBLE,
		TotalPaymentIn DOUBLE,
		CustomerUnbill DOUBLE,
		VendrorUnbill DOUBLE,
		date DATE,
		TotalOutstanding DOUBLE,
		TotalPayable DOUBLE,
		TotalReceivable DOUBLE
	);
	
	IF p_Unbilled = 1
	THEN
		DROP TEMPORARY TABLE IF EXISTS tmp_Account_;
		CREATE TEMPORARY TABLE tmp_Account_  (
			RowID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
			AccountID INT,
			LastInvoiceDate DATE
		);
		DROP TEMPORARY TABLE IF EXISTS tmp_Account2_;
		CREATE TEMPORARY TABLE tmp_Account2_  (
			RowID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
			AccountID INT,
			LastInvoiceDate DATE
		);

		INSERT INTO tmp_Account_ (AccountID)
		SELECT DISTINCT tblSummaryHeader.AccountID  FROM tblSummaryHeader INNER JOIN Ratemanagement3.tblAccount ON tblAccount.AccountID = tblSummaryHeader.AccountID WHERE tblSummaryHeader.CompanyID = 1;

		UPDATE tmp_Account_ SET LastInvoiceDate = fngetLastInvoiceDate(AccountID);

		INSERT INTO tmp_Account2_ (AccountID)
		SELECT DISTINCT tblSummaryVendorHeader.AccountID  FROM tblSummaryVendorHeader INNER JOIN Ratemanagement3.tblAccount ON tblAccount.AccountID = tblSummaryVendorHeader.AccountID WHERE tblSummaryVendorHeader.CompanyID = p_CompanyID;

		UPDATE tmp_Account2_ SET LastInvoiceDate = fngetLastVendorInvoiceDate(AccountID);

		SELECT 
			SUM(h.TotalCharges)
		INTO
			prev_CustomerUnbill
		FROM tmp_Account_ a
		INNER JOIN tblDimDate dd
			ON dd.date >= a.LastInvoiceDate
		INNER JOIN tblHeader h
			ON h.AccountID = a.AccountID
			AND h.DateID = dd.DateID
		WHERE dd.date < p_StartDate;
		
		SELECT 
			SUM(h.TotalCharges)
		INTO 
			prev_VendrorUnbill
		FROM tmp_Account2_ a
		INNER JOIN tblDimDate dd
			ON dd.date >= a.LastInvoiceDate
		INNER JOIN tblHeaderV h
			ON h.VAccountID = a.AccountID
			AND h.DateID = dd.DateID
		WHERE dd.date < p_StartDate;

		INSERT INTO tmp_CustomerUnbilled_(DateID,CustomerUnbill)
		SELECT 
			dd.DateID,
			SUM(h.TotalCharges)
		FROM tmp_Account_ a
		INNER JOIN tblDimDate dd
			ON dd.date >= a.LastInvoiceDate
		INNER JOIN tblHeader h
			ON h.AccountID = a.AccountID
			AND h.DateID = dd.DateID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		GROUP BY dd.date;

		INSERT INTO tmp_VendorUbilled_ (DateID,VendrorUnbill)
		SELECT 
			dd.DateID,
			SUM(h.TotalCharges)
		FROM tmp_Account2_ a
		INNER JOIN tblDimDate dd
			ON dd.date >= a.LastInvoiceDate
		INNER JOIN tblHeaderV h
			ON h.VAccountID = a.AccountID
			AND h.DateID = dd.DateID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		GROUP BY dd.date;
	
	END IF;

	SELECT 
		SUM(IF(InvoiceType=1,GrandTotal,0)),
		SUM(IF(InvoiceType=2,GrandTotal,0)) 
	INTO 
		prev_TotalInvoiceOut,
		prev_TotalInvoiceIn
	FROM RMBilling3.tblInvoice 
	WHERE 
		CompanyID = p_CompanyID
		AND CurrencyID = p_CurrencyID
		AND ( (InvoiceType = 2) OR ( InvoiceType = 1 AND InvoiceStatus NOT IN ( 'cancel' , 'draft') )  )
		AND (p_AccountID = 0 or AccountID = p_AccountID)
	AND tblInvoice.IssueDate < p_StartDate ;

	SELECT 
		SUM(IF(PaymentType='Payment In',p.Amount,0)),
		SUM(IF(PaymentType='Payment Out',p.Amount,0)) 
	INTO 
		prev_TotalPaymentIn,
		prev_TotalPaymentOut
	FROM RMBilling3.tblPayment p 
	INNER JOIN Ratemanagement3.tblAccount ac 
		ON ac.AccountID = p.AccountID
	WHERE 
		p.CompanyID = p_CompanyID
		AND ac.CurrencyId = p_CurrencyID
		AND p.Status = 'Approved'
		AND p.Recall=0
		AND (p_AccountID = 0 or p.AccountID = p_AccountID)
	AND p.PaymentDate < p_StartDate;
	
	SET @prev_TotalInvoiceOut := IFNULL(prev_TotalInvoiceOut,0) ;
	SET @prev_TotalInvoiceIn := IFNULL(prev_TotalInvoiceIn,0) ;
	SET @prev_TotalPaymentOut := IFNULL(prev_TotalPaymentOut,0) ;
	SET @prev_TotalPaymentIn := IFNULL(prev_TotalPaymentIn,0) ;
	SET @prev_CustomerUnbill := IFNULL(prev_CustomerUnbill,0) ;
	SET @prev_VendrorUnbill := IFNULL(prev_VendrorUnbill,0) ;
	
	INSERT INTO tmp_FinalResult_(TotalInvoiceOut,TotalInvoiceIn,TotalPaymentOut,TotalPaymentIn,CustomerUnbill,VendrorUnbill,date,TotalOutstanding,TotalReceivable,TotalPayable)
	SELECT 
		@prev_TotalInvoiceOut := @prev_TotalInvoiceOut +    IFNULL(TotalInvoiceOut,0) AS TotalInvoiceOut ,
		@prev_TotalInvoiceIn := @prev_TotalInvoiceIn +   IFNULL(TotalInvoiceIn,0) AS TotalInvoiceIn,
		@prev_TotalPaymentOut := @prev_TotalPaymentOut +   IFNULL(TotalPaymentOut,0) AS TotalPaymentOut,
		@prev_TotalPaymentIn := @prev_TotalPaymentIn +   IFNULL(TotalPaymentIn,0) AS TotalPaymentIn,
		@prev_CustomerUnbill := @prev_CustomerUnbill +   IFNULL(CustomerUnbill,0) AS CustomerUnbill,
		@prev_VendrorUnbill := @prev_VendrorUnbill +   IFNULL(VendrorUnbill,0) AS VendrorUnbill,
		date,
		ROUND( ( @prev_TotalInvoiceOut - @prev_TotalPaymentIn ) - ( @prev_TotalInvoiceIn - @prev_TotalPaymentOut ) + ( @prev_CustomerUnbill - @prev_VendrorUnbill ) , v_Round_ ) AS TotalOutstanding,
		ROUND( ( @prev_TotalInvoiceOut - @prev_TotalPaymentIn + @prev_CustomerUnbill ), v_Round_ ) AS TotalReceivable,
		ROUND( ( @prev_TotalInvoiceIn - @prev_TotalPaymentOut + @prev_VendrorUnbill), v_Round_ ) AS TotalPayable
	FROM(
		SELECT 
			dd.date,
			TotalPaymentIn,
			TotalPaymentOut,
			TotalInvoiceOut,
			TotalInvoiceIn,
			CustomerUnbill,
			VendrorUnbill
		FROM tblDimDate dd 
		LEFT JOIN(
			SELECT 
				SUM(IF(InvoiceType=1,GrandTotal,0)) AS TotalInvoiceOut,
				SUM(IF(InvoiceType=2,GrandTotal,0)) AS TotalInvoiceIn,
				DATE(tblInvoice.IssueDate) AS  IssueDate 
			FROM RMBilling3.tblInvoice 
			WHERE 
				CompanyID = p_CompanyID
				AND CurrencyID = p_CurrencyID
				AND ( (InvoiceType = 2) OR ( InvoiceType = 1 AND InvoiceStatus NOT IN ( 'cancel' , 'draft') )  )
				AND (p_AccountID = 0 or AccountID = p_AccountID)
				AND IssueDate BETWEEN p_StartDate AND p_EndDate
			GROUP BY DATE(tblInvoice.IssueDate)
			HAVING (TotalInvoiceOut <> 0 OR TotalInvoiceIn <> 0)
		) TBL ON IssueDate = dd.date
		LEFT JOIN (
			SELECT
				SUM(IF(PaymentType='Payment In',p.Amount,0)) AS TotalPaymentIn ,
				SUM(IF(PaymentType='Payment Out',p.Amount,0)) AS TotalPaymentOut,
				DATE(p.PaymentDate) AS PaymentDate
			FROM RMBilling3.tblPayment p
			INNER JOIN Ratemanagement3.tblAccount ac
				ON ac.AccountID = p.AccountID
			WHERE
				p.CompanyID = p_CompanyID
				AND ac.CurrencyId = p_CurrencyID
				AND p.Status = 'Approved'
				AND p.Recall=0
				AND (p_AccountID = 0 or p.AccountID = p_AccountID)
				AND PaymentDate BETWEEN p_StartDate AND p_EndDate
			GROUP BY DATE(p.PaymentDate)
			HAVING (TotalPaymentIn <> 0 OR TotalPaymentOut <> 0)
		)TBL2 ON PaymentDate = dd.date
		LEFT JOIN tmp_CustomerUnbilled_ cu 
			ON cu.DateID = dd.DateID
		LEFT JOIN tmp_VendorUbilled_ vu
			ON vu.DateID = dd.DateID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		AND ( PaymentDate IS NOT NULL OR IssueDate IS NOT NULL OR cu.DateID IS NOT NULL OR vu.DateID IS NOT NULL)
		ORDER BY dd.date
	)tbl;
	
	INSERT INTO tmp_FinalResult2_
	SELECT * FROM tmp_FinalResult_;

	IF p_ListType = 'Daily'
	THEN

		SELECT
			TotalOutstanding,
			TotalPayable,
			TotalReceivable,
			date AS Date
		FROM  tmp_FinalResult_;

	END IF;

	IF p_ListType = 'Weekly'
	THEN

		SELECT 
			TotalOutstanding,
			TotalPayable,
			TotalReceivable,
			CONCAT( YEAR(date),' - ',WEEK(date,1)) AS Date
		FROM	tmp_FinalResult_ t1
		INNER JOIN (
			SELECT 
				MAX(date) as finaldate
			FROM tmp_FinalResult2_
			GROUP BY
			YEAR(date),WEEK(date,1)
		)TBL ON TBL.finaldate = t1.date;

	END IF;
	
	IF p_ListType = 'Monthly'
	THEN

		SELECT 
			TotalOutstanding,
			TotalPayable,
			TotalReceivable,
			CONCAT( YEAR(date),' - ',MONTHNAME(date)) AS Date
		FROM	tmp_FinalResult_ t1
		INNER JOIN (
			SELECT 
				MAX(date) as finaldate
			FROM tmp_FinalResult2_
			GROUP BY
			YEAR(date),MONTH(date)
		)TBL ON TBL.finaldate = t1.date;

	END IF;
	

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getDashboardProfitLoss` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getDashboardProfitLoss`(
	IN `p_CompanyID` INT,
	IN `p_CurrencyID` INT,
	IN `p_AccountID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_ListType` VARCHAR(50)

)
BEGIN
	DECLARE v_Round_ INT;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	DROP TEMPORARY TABLE IF EXISTS tmp_Customerbilled_;
	CREATE TEMPORARY TABLE tmp_Customerbilled_  (
		DateID INT,
		Customerbill DOUBLE
	);
	DROP TEMPORARY TABLE IF EXISTS tmp_Vendorbilled_;
	CREATE TEMPORARY TABLE tmp_Vendorbilled_  (
		DateID INT,
		Vendrorbill DOUBLE
	);
	
	DROP TEMPORARY TABLE IF EXISTS tmp_FinalResult_;
	CREATE TEMPORARY TABLE tmp_FinalResult_  (
		Customerbill DOUBLE,
		Vendrorbill DOUBLE,
		date DATE
	);

	INSERT INTO tmp_Customerbilled_(DateID,Customerbill)
	SELECT 
		dd.DateID,
		SUM(h.TotalCharges)
	FROM tblDimDate dd
	INNER JOIN tblHeader h
		ON h.DateID = dd.DateID
	WHERE dd.date BETWEEN p_StartDate AND p_EndDate
	AND (p_AccountID = 0 or AccountID = p_AccountID)
	GROUP BY dd.date;

	INSERT INTO tmp_Vendorbilled_ (DateID,Vendrorbill)
	SELECT 
		dd.DateID,
		SUM(h.TotalCharges)
	FROM tblDimDate dd
	INNER JOIN tblHeaderV h
		ON h.DateID = dd.DateID
	WHERE dd.date BETWEEN p_StartDate AND p_EndDate
	AND (p_AccountID = 0 or VAccountID = p_AccountID)
	GROUP BY dd.date;

	INSERT INTO tmp_FinalResult_(Customerbill,Vendrorbill,date)
	SELECT 
		IFNULL(Customerbill,0) AS Customerbill,
		IFNULL(Vendrorbill,0) AS Vendrorbill,
		date
	FROM(
		SELECT 
			dd.date,
			Customerbill,
			Vendrorbill
		FROM tblDimDate dd 
		LEFT JOIN tmp_Customerbilled_ cu 
			ON cu.DateID = dd.DateID
		LEFT JOIN tmp_Vendorbilled_ vu
			ON vu.DateID = dd.DateID
		WHERE dd.date BETWEEN p_StartDate AND p_EndDate
		AND (cu.DateID IS NOT NULL OR vu.DateID IS NOT NULL)
		ORDER BY dd.date
	)tbl;
	
	IF p_ListType = 'Daily'
	THEN

		SELECT
			ROUND(Customerbill - Vendrorbill,v_Round_) AS PL,
			date AS Date
		FROM  tmp_FinalResult_
		ORDER BY date;

	END IF;

	IF p_ListType = 'Weekly'
	THEN

		SELECT 
			ROUND(SUM(Customerbill) - SUM(Vendrorbill),v_Round_) AS PL,
			CONCAT( YEAR(MAX(date)),' - ',WEEK(MAX(date))) AS Date
		FROM	tmp_FinalResult_
		GROUP BY 
			YEAR(date),
			WEEK(date)
		ORDER BY
			YEAR(date),
			WEEK(date);

	END IF;
	
	IF p_ListType = 'Monthly'
	THEN

		SELECT 
			ROUND(SUM(Customerbill) - SUM(Vendrorbill),v_Round_) AS PL,
			CONCAT( YEAR(MAX(date)),' - ',MONTHNAME(MAX(date))) AS Date
		FROM	tmp_FinalResult_
		GROUP BY
			YEAR(date)
			,MONTH(date)
		ORDER BY 
			YEAR(date)
			,MONTH(date);

	END IF;
	

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getDestinationReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getDestinationReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnGetCountry();
		 
	
	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* country by call count */	
	SELECT IFNULL(Country,'Other') as Country ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , IF(SUM(NoOfCalls)>0,ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_),0) as ASR
	FROM tmp_tblUsageSummary_ us
	LEFT JOIN temptblCountry c ON c.CountryID = us.CountryID
	WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
	GROUP BY c.Country   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CountryDESC') THEN Country
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CountryASC') THEN Country
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN IF(SUM(NoOfCalls)>0,(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN IF(SUM(NoOfCalls)>0,(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	

	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM(
		SELECT IFNULL(Country,'Other') as Country ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , IF(SUM(NoOfCalls)>0,ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_),0) as ASR
		FROM tmp_tblUsageSummary_ us
		LEFT JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY c.Country
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT SQL_CALC_FOUND_ROWS IFNULL(Country,'Other') as Country ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		LEFT JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 country by call count */	
		SELECT Country as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		INNER JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 country by call cost */	
		SELECT Country as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		INNER JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 country by call minutes */	
		SELECT Country as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		INNER JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getGatewayReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getGatewayReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* CompanyGatewayID by call count */	
	SELECT fnGetCompanyGatewayName(CompanyGatewayID) ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,CompanyGatewayID
	FROM tmp_tblUsageSummary_ us
	GROUP BY CompanyGatewayID   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'GatewayDESC') THEN fnGetCompanyGatewayName(CompanyGatewayID)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'GatewayASC') THEN fnGetCompanyGatewayName(CompanyGatewayID)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY CompanyGatewayID
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   fnGetCompanyGatewayName(CompanyGatewayID)  as Name ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY CompanyGatewayID;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 CompanyGatewayID by call count */	
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.CompanyGatewayID != 'Other'
		GROUP BY CompanyGatewayID HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 CompanyGatewayID by call cost */	
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.CompanyGatewayID != 'Other'
		GROUP BY CompanyGatewayID HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 CompanyGatewayID by call minutes */	
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.CompanyGatewayID != 'Other'
		GROUP BY CompanyGatewayID HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getHourlyReport` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getHourlyReport`(
	IN `p_CompanyID` INT,
	IN `p_UserID` INT,
	IN `p_isAdmin` INT,
	IN `p_AccountID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME
)
BEGIN
	
	DECLARE v_Round_ int;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	CALL fnUsageSummary(p_CompanyID,0,p_AccountID,0,p_StartDate,p_EndDate,'','',0,p_UserID,p_isAdmin,2);
	
	/* total cost */
	SELECT ROUND(COALESCE(SUM(TotalCharges),0),v_Round_) as TotalCost FROM tmp_tblUsageSummary_;
	
	/* cost per hour*/
	SELECT dt.hour as HOUR ,ROUND(COALESCE(SUM(TotalCharges),0),v_Round_) as TotalCost FROM tmp_tblUsageSummary_ us INNER JOIN tblDimTime dt on us.TimeID =  dt.TimeID GROUP BY dt.hour;
	
	/* total duration or minutes*/
	SELECT ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes FROM tmp_tblUsageSummary_;
	
	/* minutes pre hour*/
	SELECT dt.hour as HOUR ,ROUND(COALESCE(SUM(TotalBilledDuration),0) / 60,0) as TotalMinutes FROM tmp_tblUsageSummary_ us INNER JOIN tblDimTime dt on us.TimeID =  dt.TimeID GROUP BY dt.hour;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getPrefixReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getPrefixReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* AreaPrefix by call count */	
	SELECT AreaPrefix ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
	FROM tmp_tblUsageSummary_ us
	GROUP BY AreaPrefix   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AreaPrefixDESC') THEN AreaPrefix
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AreaPrefixASC') THEN AreaPrefix
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT AreaPrefix ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AreaPrefix
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   AreaPrefix ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY AreaPrefix;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 AreaPrefix by call count */	
		SELECT AreaPrefix as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.AreaPrefix != 'Other'
		GROUP BY AreaPrefix HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 AreaPrefix by call cost */	
		SELECT AreaPrefix as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.AreaPrefix != 'Other'
		GROUP BY AreaPrefix HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 AreaPrefix by call minutes */	
		SELECT AreaPrefix as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.AreaPrefix != 'Other'
		GROUP BY AreaPrefix HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getReportByTime` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getReportByTime`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` INT,
	IN `p_AccountID` INT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` VARCHAR(50),
	IN `p_Trunk` VARCHAR(50),
	IN `p_CountryID` INT,
	IN `p_UserID` INT,
	IN `p_isAdmin` INT,
	IN `p_ReportType` INT



)
BEGIN

	DECLARE v_Round_ INT;
	DECLARE V_Detail INT;

	SET V_Detail = 2;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,V_Detail);

	/* hourly report */
	IF p_ReportType =1
	THEN
	
		SELECT 
			CONCAT(dt.hour,' Hour') as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageSummary_ us
		INNER JOIN tblDimTime dt on dt.TimeID = us.TimeID
		GROUP BY  us.DateID,dt.hour;

	END IF;

	/* daily report */
	IF p_ReportType =2
	THEN

		SELECT 
			dd.date as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  us.DateID;
	END IF;

	/* weekly report */
	IF p_ReportType =3
	THEN

		SELECT 
			ANY_VALUE(dd.week_year_name) as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year,dd.week_of_year
		ORDER BY dd.year,dd.week_of_year;

	END IF;

	/* monthly report */
	IF p_ReportType =4
	THEN

		SELECT 
			ANY_VALUE(dd.month_year_name) as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year,dd.month_of_year
		ORDER BY dd.year,dd.month_of_year;

	END IF;

	/* queterly report */
	IF p_ReportType =5
	THEN

		SELECT 
			CONCAT('Q-',ANY_VALUE(dd.quarter_year_name)) as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year,dd.quarter_of_year
		ORDER BY dd.year,dd.quarter_of_year;

	END IF;

	/* yearly report */
	IF p_ReportType =6
	THEN

		SELECT 
			dd.year as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year;

	END IF;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getTrunkReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getTrunkReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* Trunk by call count */	
	SELECT Trunk ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
	FROM tmp_tblUsageSummary_ us
	GROUP BY Trunk   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TrunkDESC') THEN Trunk
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TrunkASC') THEN Trunk
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT Trunk ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY Trunk
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   Trunk ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		GROUP BY Trunk;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 Trunk by call count */	
		SELECT Trunk as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.Trunk != 'Other'
		GROUP BY Trunk HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 Trunk by call cost */	
		SELECT Trunk as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.Trunk != 'Other'
		GROUP BY Trunk HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 Trunk by call minutes */	
		SELECT Trunk as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageSummary_ us
		WHERE us.Trunk != 'Other'
		GROUP BY Trunk HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getUnbilledReport` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getUnbilledReport`(
	IN `p_CompanyID` INT,
	IN `p_AccountID` INT,
	IN `p_LastInvoiceDate` DATETIME,
	IN `p_Today` DATETIME,
	IN `p_Detail` INT


)
BEGIN
	
	DECLARE v_Round_ INT;
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	
	IF p_Detail = 1
	THEN
	
		SELECT 
			dd.date,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tblHeader us
		INNER JOIN tblDimDate dd ON dd.DateID = us.DateID
		WHERE dd.date BETWEEN p_LastInvoiceDate AND p_Today 
		AND us.CompanyID = p_CompanyID
		AND us.AccountID = p_AccountID
		GROUP BY us.DateID;	
		
	
	END IF;
	
	IF p_Detail = 3
	THEN
	
		DROP TEMPORARY TABLE IF EXISTS tmp_FinalAmount_;
		CREATE TEMPORARY TABLE tmp_FinalAmount_  (
			FinalAmount DOUBLE
		);
		INSERT INTO tmp_FinalAmount_
		SELECT 
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
		FROM tblHeader us
		INNER JOIN tblDimDate dd ON dd.DateID = us.DateID
		WHERE dd.date BETWEEN p_LastInvoiceDate AND p_Today 
		AND us.CompanyID = p_CompanyID
		AND us.AccountID = p_AccountID;
		
	END IF;
 
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorAccountReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getVendorAccountReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* account by call count */	
	SELECT AccountName ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,MAX(AccountID) as AccountID
	FROM tmp_tblUsageVendorSummary_ us
	GROUP BY AccountName   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AccountNameDESC') THEN AccountName
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AccountNameASC') THEN AccountName
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT AccountName ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AccountName
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   AccountName  as Name ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AccountName;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 account by call count */	
		SELECT AccountName as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AccountName HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 account by call cost */	
		SELECT AccountName as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AccountName HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 account by call minutes */	
		SELECT AccountName as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AccountName HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorACD_ASR_Alert` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getVendorACD_ASR_Alert`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` TEXT,
	IN `p_AccountID` TEXT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` TEXT,
	IN `p_Trunk` TEXT,
	IN `p_CountryID` TEXT
)
BEGIN
	
	DECLARE v_Round_ INT;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageVendorSummaryDetail(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,0,1);

	IF p_AccountID = ''
	THEN
		SELECT
			IF(SUM(NoOfCalls)>0,COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls),0) as ACD , 
			ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
			HOUR(ANY_VALUE(Time)) as Hour,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as Minutes,
			COALESCE(SUM(NoOfCalls),0) as Connected,
			COALESCE(SUM(NoOfCalls),0)+COALESCE(SUM(NoOfFailCalls),0) as Attempts
		FROM tmp_tblUsageVendorSummary_ us;
		
	END IF;
	
	IF p_AccountID != ''
	THEN
		SELECT
			IF(SUM(NoOfCalls)>0,COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls),0) as ACD , 
			ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
			AccountID,
			HOUR(ANY_VALUE(Time)) as Hour,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as Minutes,
			COALESCE(SUM(NoOfCalls),0) as Connected,
			COALESCE(SUM(NoOfCalls),0)+COALESCE(SUM(NoOfFailCalls),0) as Attempts
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AccountID;
	END IF;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorBalanceReport` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getVendorBalanceReport`(
	IN `p_CompanyID` INT,
	IN `p_AccountID` TEXT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME
)
BEGIN
	
	DECLARE v_Round_ INT;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageVendorSummaryDetail(p_CompanyID,'',p_AccountID,0,p_StartDate,p_EndDate,'','','',0,1);

	SELECT
		MAX(AccountName) as AccountName,
		IF(SUM(NoOfCalls)>0,COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls),0) as ACD , 
		ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
		AccountID,
		DATE(Time) as Date,
		HOUR(Time) as Hour,
		COALESCE(SUM(TotalCharges),0) as Cost,
		ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as Minutes,
		COALESCE(SUM(NoOfCalls),0) as Connected,
		COALESCE(SUM(NoOfCalls),0)+COALESCE(SUM(NoOfFailCalls),0) as Attempts
	FROM tmp_tblUsageVendorSummary_ us
	GROUP BY AccountID,DATE(Time),HOUR(Time);

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorDestinationReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getVendorDestinationReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnGetCountry();
		 
	
	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* country by call count */	
	SELECT IFNULL(Country,'Other') as Country ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , IF(SUM(NoOfCalls)>0,ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_),0) as ASR
	FROM tmp_tblUsageVendorSummary_ us
	LEFT JOIN temptblCountry c ON c.CountryID = us.CountryID
	WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
	GROUP BY c.Country   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CountryDESC') THEN Country
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CountryASC') THEN Country
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT IFNULL(Country,'Other') as Country ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , IF(SUM(NoOfCalls)>0,ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_),0) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		LEFT JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY c.Country
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT SQL_CALC_FOUND_ROWS IFNULL(Country,'Other') as Country ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		LEFT JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 country by call count */	
		SELECT Country as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 country by call cost */	
		SELECT Country as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 country by call minutes */	
		SELECT Country as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN temptblCountry c ON c.CountryID = us.CountryID
		WHERE (p_CountryID = 0 OR c.CountryID = p_CountryID)
		GROUP BY Country HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorGatewayReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getVendorGatewayReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* CompanyGatewayID by call count */	
	SELECT fnGetCompanyGatewayName(CompanyGatewayID) ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,CompanyGatewayID
	FROM tmp_tblUsageVendorSummary_ us
	GROUP BY CompanyGatewayID   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'GatewayDESC') THEN fnGetCompanyGatewayName(CompanyGatewayID)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'GatewayASC') THEN fnGetCompanyGatewayName(CompanyGatewayID)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY CompanyGatewayID
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   fnGetCompanyGatewayName(CompanyGatewayID)  as Name ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY CompanyGatewayID;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 CompanyGatewayID by call count */	
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.CompanyGatewayID != 'Other'
		GROUP BY CompanyGatewayID HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 CompanyGatewayID by call cost */	
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.CompanyGatewayID != 'Other'
		GROUP BY CompanyGatewayID HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 CompanyGatewayID by call minutes */	
		SELECT fnGetCompanyGatewayName(CompanyGatewayID) as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.CompanyGatewayID != 'Other'
		GROUP BY CompanyGatewayID HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorPrefixReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getVendorPrefixReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* AreaPrefix by call count */	
	SELECT AreaPrefix ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
	FROM tmp_tblUsageVendorSummary_ us
	GROUP BY AreaPrefix   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AreaPrefixDESC') THEN AreaPrefix
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'AreaPrefixASC') THEN AreaPrefix
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT AreaPrefix ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AreaPrefix
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   AreaPrefix ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY AreaPrefix;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 AreaPrefix by call count */	
		SELECT AreaPrefix as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.AreaPrefix != 'Other'
		GROUP BY AreaPrefix HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 AreaPrefix by call cost */	
		SELECT AreaPrefix as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.AreaPrefix != 'Other'
		GROUP BY AreaPrefix HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 AreaPrefix by call minutes */	
		SELECT AreaPrefix as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.AreaPrefix != 'Other'
		GROUP BY AreaPrefix HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorReportByTime` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getVendorReportByTime`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` INT,
	IN `p_AccountID` INT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` VARCHAR(50),
	IN `p_Trunk` VARCHAR(50),
	IN `p_CountryID` INT,
	IN `p_UserID` INT,
	IN `p_isAdmin` INT,
	IN `p_ReportType` INT

)
BEGIN

	DECLARE v_Round_ INT;
	DECLARE V_Detail INT;

	SET V_Detail = 2;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,V_Detail);

	/* hourly report */
	IF p_ReportType =1
	THEN

		SELECT 
			CONCAT(dt.hour,' Hour') as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN tblDimTime dt on dt.TimeID = us.TimeID
		GROUP BY  us.DateID,dt.hour;

	END IF;

	/* daily report */
	IF p_ReportType =2
	THEN

		SELECT 
			dd.date as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  us.DateID;

	END IF;

	/* weekly report */
	IF p_ReportType =3
	THEN

		SELECT 
			ANY_VALUE(dd.week_year_name) as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year,dd.week_of_year
		ORDER BY dd.year,dd.week_of_year;

	END IF;

	/* monthly report */
	IF p_ReportType =4
	THEN

		SELECT 
			ANY_VALUE(dd.month_year_name) as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year,dd.month_of_year
		ORDER BY dd.year,dd.month_of_year;

	END IF;

	/* queterly report */
	IF p_ReportType =5
	THEN

		SELECT 
			CONCAT('Q-',ANY_VALUE(dd.quarter_year_name)) as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year,dd.quarter_of_year
		ORDER BY dd.year,dd.quarter_of_year;

	END IF;

	/* yearly report */
	IF p_ReportType =6
	THEN

		SELECT 
			dd.year as category,
			SUM(NoOfCalls) AS CallCount,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tmp_tblUsageVendorSummary_ us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		GROUP BY  dd.year;

	END IF;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorTrunkReportAll` */;
DELIMITER ;;
CREATE DEFINER=`neon-user`@`117.247.87.156` PROCEDURE `prc_getVendorTrunkReportAll`(IN `p_CompanyID` INT, IN `p_CompanyGatewayID` INT, IN `p_AccountID` INT, IN `p_CurrencyID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME, IN `p_AreaPrefix` VARCHAR(50), IN `p_Trunk` VARCHAR(50), IN `p_CountryID` INT, IN `p_UserID` INT, IN `p_isAdmin` INT, IN `p_PageNumber` INT, IN `p_RowspPage` INT, IN `p_lSortCol` VARCHAR(50), IN `p_SortOrder` VARCHAR(5), IN `p_isExport` INT)
BEGIN

	DECLARE v_Round_ int;
	DECLARE v_OffSet_ int;
		
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SET v_OffSet_ = (p_PageNumber * p_RowspPage) - p_RowspPage;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	
	/* grid display*/
	IF p_isExport = 0
	THEN
	
	/* Trunk by call count */	
	SELECT Trunk ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
	FROM tmp_tblUsageVendorSummary_ us
	GROUP BY Trunk   
	ORDER BY
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountDESC') THEN SUM(NoOfCalls)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'CallCountASC') THEN SUM(NoOfCalls)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesDESC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalMinutesASC') THEN COALESCE(SUM(TotalBilledDuration),0)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TrunkDESC') THEN Trunk
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TrunkASC') THEN Trunk
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostDESC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'TotalCostASC') THEN ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDDESC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ACDASC') THEN (COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls))
	END ASC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRDESC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END DESC,
	CASE
		WHEN (CONCAT(p_lSortCol,p_SortOrder) = 'ASRASC') THEN SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100
	END ASC
	LIMIT p_RowspPage OFFSET v_OffSet_;
	
	SELECT COUNT(*) AS totalcount,SUM(CallCount) AS TotalCall,SUM(TotalSeconds) AS TotalDuration,SUM(TotalCost) AS TotalCost FROM (
		SELECT Trunk ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY Trunk
	)tbl;

	
	END IF;
	
	/* export data*/
	IF p_isExport = 1
	THEN
		SELECT   Trunk ,SUM(NoOfCalls) AS CallCount,COALESCE(SUM(TotalBilledDuration),0) as TotalSeconds,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		GROUP BY Trunk;
	END IF;
	
	
	/* chart display*/
	IF p_isExport = 2
	THEN
	
		/* top 10 Trunk by call count */	
		SELECT Trunk as ChartVal ,SUM(NoOfCalls) AS CallCount,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.Trunk != 'Other'
		GROUP BY Trunk HAVING SUM(NoOfCalls) > 0 ORDER BY CallCount DESC LIMIT 10;
		
		/* top 10 Trunk by call cost */	
		SELECT Trunk as ChartVal,ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.Trunk != 'Other'
		GROUP BY Trunk HAVING SUM(TotalCharges) > 0 ORDER BY TotalCost DESC LIMIT 10;
		
		/* top 10 Trunk by call minutes */	
		SELECT Trunk as ChartVal,ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD , ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR
		FROM tmp_tblUsageVendorSummary_ us
		WHERE us.Trunk != 'Other'
		GROUP BY Trunk HAVING SUM(TotalBilledDuration) > 0  ORDER BY TotalMinutes DESC LIMIT 10;
	
	END IF;
	
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorUnbilledReport` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getVendorUnbilledReport`(
	IN `p_CompanyID` INT,
	IN `p_AccountID` INT,
	IN `p_LastInvoiceDate` DATETIME,
	IN `p_Today` DATETIME,
	IN `p_Detail` INT


)
BEGIN
	
	DECLARE v_Round_ INT;
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	IF p_Detail = 1
	THEN
	
		SELECT 
			dd.date,
			ROUND(COALESCE(SUM(TotalBilledDuration),0)/60,0) as TotalMinutes,
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost
		FROM tblHeaderV us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		WHERE dd.date BETWEEN p_LastInvoiceDate AND p_Today 
		AND us.CompanyID = p_CompanyID
		AND us.VAccountID = p_AccountID
		GROUP BY us.DateID;	
	
	END IF;
	
	 
	
	IF p_Detail = 3
	THEN
	
		DROP TEMPORARY TABLE IF EXISTS tmp_FinalAmount_;
		CREATE TEMPORARY TABLE tmp_FinalAmount_  (
			FinalAmount DOUBLE
		);
		INSERT INTO tmp_FinalAmount_
		SELECT 
			ROUND(COALESCE(SUM(TotalCharges),0), v_Round_)
		FROM tblHeaderV us
		INNER JOIN tblDimDate dd on dd.DateID = us.DateID
		WHERE dd.date BETWEEN p_LastInvoiceDate AND p_Today 
		AND us.CompanyID = p_CompanyID
		AND us.VAccountID = p_AccountID;
	
	END IF;
 
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getVendorWorldMap` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getVendorWorldMap`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` INT,
	IN `p_AccountID` INT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` VARCHAR(50),
	IN `p_Trunk` VARCHAR(50),
	IN `p_CountryID` INT,
	IN `p_UserID` INT,
	IN `p_isAdmin` INT
)
BEGIN

	DECLARE v_Round_ int;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	CALL fnGetCountry();

	CALL fnUsageVendorSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	/* get all country call counts*/	
	SELECT 
		Country,
		SUM(NoOfCalls) AS CallCount,
		ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,
		ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,
		IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD,
		ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
		MAX(ISO2) AS ISO_Code,
		tblCountry.CountryID
	FROM tmp_tblUsageVendorSummary_ AS us
	INNER JOIN temptblCountry AS tblCountry 
		ON tblCountry.CountryID = us.CountryID
	GROUP BY Country,tblCountry.CountryID 
	HAVING SUM(NoOfCalls) > 0
	ORDER BY CallCount DESC;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_getWorldMap` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getWorldMap`(
	IN `p_CompanyID` INT,
	IN `p_CompanyGatewayID` INT,
	IN `p_AccountID` INT,
	IN `p_CurrencyID` INT,
	IN `p_StartDate` DATETIME,
	IN `p_EndDate` DATETIME,
	IN `p_AreaPrefix` VARCHAR(50),
	IN `p_Trunk` VARCHAR(50),
	IN `p_CountryID` INT,
	IN `p_UserID` INT,
	IN `p_isAdmin` INT
)
BEGIN

	DECLARE v_Round_ int;

	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;

	CALL fnGetCountry();

	CALL fnUsageSummary(p_CompanyID,p_CompanyGatewayID,p_AccountID,p_CurrencyID,p_StartDate,p_EndDate,p_AreaPrefix,p_Trunk,p_CountryID,p_UserID,p_isAdmin,2);

	/* get all country call counts*/	
	SELECT 
		Country,
		SUM(NoOfCalls) AS CallCount,
		ROUND(COALESCE(SUM(TotalCharges),0), v_Round_) as TotalCost,
		ROUND(COALESCE(SUM(TotalBilledDuration),0)/ 60,0) as TotalMinutes,
		IF(SUM(NoOfCalls)>0,fnDurationmmss(COALESCE(SUM(TotalBilledDuration),0)/SUM(NoOfCalls)),0) as ACD,
		ROUND(SUM(NoOfCalls)/(SUM(NoOfCalls)+SUM(NoOfFailCalls))*100,v_Round_) as ASR,
		MAX(ISO2) AS ISO_Code,
		tblCountry.CountryID
	FROM tmp_tblUsageSummary_
	INNER JOIN temptblCountry AS tblCountry 
		ON tblCountry.CountryID = tmp_tblUsageSummary_.CountryID
	GROUP BY Country,tblCountry.CountryID 
	HAVING SUM(NoOfCalls) > 0
	ORDER BY CallCount DESC;

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_timedimbuild` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_timedimbuild`()
BEGIN
    DECLARE v_full_date DATETIME;

    DELETE FROM tblDimTime;

    SET v_full_date = '2009-03-01 00:00:00';
    WHILE v_full_date < '2009-03-02 00:00:00' DO

        INSERT INTO tblDimTime (
            fulltime ,
            hour ,
            minute ,
            second ,
            ampm
        ) VALUES (
            TIME(v_full_date),
            HOUR(v_full_date),
            MINUTE(v_full_date),
            SECOND(v_full_date),
            DATE_FORMAT(v_full_date,'%p')
        );

        SET v_full_date = DATE_ADD(v_full_date, INTERVAL 1 SECOND);
    END WHILE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateUnbilledAmount` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_updateUnbilledAmount`(
	IN `p_CompanyID` INT,
	IN `p_Today` DATETIME

)
BEGIN
	
	DECLARE v_Round_ INT;
	DECLARE v_rowCount_ INT;
	DECLARE v_pointer_ INT;
	DECLARE v_AccountID_ INT;
	DECLARE v_LastInvoiceDate_ DATE;
	DECLARE v_FinalAmount_ DOUBLE;
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	
	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	DROP TEMPORARY TABLE IF EXISTS tmp_Account_;
	CREATE TEMPORARY TABLE tmp_Account_  (
		RowID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
		AccountID INT,
		LastInvoiceDate DATE
	);
	
	INSERT INTO tmp_Account_ (AccountID)
	SELECT DISTINCT tblSummaryHeader.AccountID  FROM tblSummaryHeader INNER JOIN Ratemanagement3.tblAccount ON tblAccount.AccountID = tblSummaryHeader.AccountID WHERE tblSummaryHeader.CompanyID = p_CompanyID;
	
	UPDATE tmp_Account_ SET LastInvoiceDate = fngetLastInvoiceDate(AccountID);
	
	SET v_pointer_ = 1;
	SET v_rowCount_ = (SELECT COUNT(*) FROM tmp_Account_);

	WHILE v_pointer_ <= v_rowCount_
	DO
		SET v_AccountID_ = (SELECT AccountID FROM tmp_Account_ t WHERE t.RowID = v_pointer_);
		SET v_LastInvoiceDate_ = (SELECT LastInvoiceDate FROM tmp_Account_ t WHERE t.RowID = v_pointer_);
		
		CALL prc_getUnbilledReport(p_CompanyID,v_AccountID_,v_LastInvoiceDate_,p_Today,3);
		
		SELECT FinalAmount INTO v_FinalAmount_ FROM tmp_FinalAmount_;
		
		IF (SELECT COUNT(*) FROM Ratemanagement3.tblAccountBalance WHERE AccountID = v_AccountID_) > 0
		THEN
			UPDATE Ratemanagement3.tblAccountBalance SET UnbilledAmount = v_FinalAmount_ WHERE AccountID = v_AccountID_;
		ELSE
			INSERT INTO Ratemanagement3.tblAccountBalance (AccountID,UnbilledAmount,BalanceAmount)
			SELECT v_AccountID_,v_FinalAmount_,v_FinalAmount_;
		END IF;
		
		SET v_pointer_ = v_pointer_ + 1;
	
	END WHILE;
	
	UPDATE 
		Ratemanagement3.tblAccountBalance 
	INNER JOIN
		(
			SELECT 
				DISTINCT tblAccount.AccountID 
			FROM Ratemanagement3.tblAccount  
			LEFT JOIN tmp_Account_ 
				ON tblAccount.AccountID = tmp_Account_.AccountID
			WHERE tmp_Account_.AccountID IS NULL AND tblAccount.CompanyID = p_CompanyID
		) TBL
	ON TBL.AccountID = tblAccountBalance.AccountID
	SET UnbilledAmount = 0;
	
	CALL prc_updateVendorUnbilledAmount(p_CompanyID,p_Today);
	
	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_updateVendorUnbilledAmount` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_updateVendorUnbilledAmount`(
	IN `p_CompanyID` INT,
	IN `p_Today` DATETIME

)
BEGIN
	
	DECLARE v_Round_ INT;
	DECLARE v_rowCount_ INT;
	DECLARE v_pointer_ INT;
	DECLARE v_AccountID_ INT;
	DECLARE v_LastInvoiceDate_ DATETIME;
	DECLARE v_FinalAmount_ DOUBLE;
	
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

	SELECT fnGetRoundingPoint(p_CompanyID) INTO v_Round_;
	
	DROP TEMPORARY TABLE IF EXISTS tmp_Account_;
	CREATE TEMPORARY TABLE tmp_Account_  (
		RowID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
		AccountID INT,
		LastInvoiceDate DATETIME
	);
	
	INSERT INTO tmp_Account_ (AccountID)
	SELECT DISTINCT tblSummaryVendorHeader.AccountID  FROM tblSummaryVendorHeader INNER JOIN Ratemanagement3.tblAccount ON tblAccount.AccountID = tblSummaryVendorHeader.AccountID WHERE tblSummaryVendorHeader.CompanyID = p_CompanyID;
	
	UPDATE tmp_Account_ SET LastInvoiceDate = fngetLastVendorInvoiceDate(AccountID);
	
	SET v_pointer_ = 1;
	SET v_rowCount_ = (SELECT COUNT(*) FROM tmp_Account_);

	WHILE v_pointer_ <= v_rowCount_
	DO
		SET v_AccountID_ = (SELECT AccountID FROM tmp_Account_ t WHERE t.RowID = v_pointer_);
		SET v_LastInvoiceDate_ = (SELECT LastInvoiceDate FROM tmp_Account_ t WHERE t.RowID = v_pointer_);
		
		IF v_LastInvoiceDate_ IS NOT NULL
		THEN
		
			CALL prc_getVendorUnbilledReport(p_CompanyID,v_AccountID_,v_LastInvoiceDate_,p_Today,3);
			
			SELECT FinalAmount INTO v_FinalAmount_ FROM tmp_FinalAmount_;
			
			IF (SELECT COUNT(*) FROM Ratemanagement3.tblAccountBalance WHERE AccountID = v_AccountID_) > 0
			THEN
				UPDATE Ratemanagement3.tblAccountBalance SET VendorUnbilledAmount = v_FinalAmount_ WHERE AccountID = v_AccountID_;
			ELSE
				INSERT INTO Ratemanagement3.tblAccountBalance (AccountID,VendorUnbilledAmount,BalanceAmount)
				SELECT v_AccountID_,v_FinalAmount_,v_FinalAmount_;
			END IF;
			
		END IF;
		
		SET v_pointer_ = v_pointer_ + 1;
	
	END WHILE;	
	
	UPDATE 
		Ratemanagement3.tblAccountBalance 
	INNER JOIN
		(
			SELECT 
				DISTINCT tblAccount.AccountID 
			FROM Ratemanagement3.tblAccount  
			LEFT JOIN tmp_Account_ 
				ON tblAccount.AccountID = tmp_Account_.AccountID
			WHERE tmp_Account_.AccountID IS NULL AND tblAccount.CompanyID = p_CompanyID
		) TBL
	ON TBL.AccountID = tblAccountBalance.AccountID
	SET VendorUnbilledAmount = 0;	

	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `prc_verifySummary` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_verifySummary`(IN `p_CompanyID` INT, IN `p_AccountID` INT, IN `p_StartDate` DATETIME, IN `p_EndDate` DATETIME)
BEGIN

	DROP TEMPORARY TABLE IF EXISTS tmp_verify_;
   CREATE TEMPORARY TABLE IF NOT EXISTS tmp_verify_(
	   AccountID INT,
	   TotalCall INT,
	   TotalCharges decimal(18,6),
	   TotalSecond BIGINT,
	   Summary INT,
	   CDR INT
   );
	SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
	CALL RMBilling3.fnUsageDetail(p_CompanyID,p_AccountID,0,p_StartDate,p_EndDate,0,1,1,'','','',0);
	
	INSERT INTO tmp_verify_ (AccountID,TotalCall,TotalCharges,TotalSecond,Summary,CDR)
	SELECT p_AccountID,COUNT(*) as TotalCall,SUM(cost) as TotalCost,SUM(billed_duration) as TotalSecond,0,1 FROM RMBilling3.tmp_tblUsageDetails_;
	
	CALL fnUsageSummary(p_CompanyID,0,p_AccountID,0,p_StartDate,p_EndDate,'','',0,0,1,1);
	
	INSERT INTO tmp_verify_ (AccountID,TotalCall,TotalCharges,TotalSecond,Summary,CDR)
	SELECT p_AccountID,SUM(NoOfCalls) as TotalCall,SUM(TotalCharges) as TotalCost,SUM(TotalBilledDuration) as TotalSecond,1,0 FROM tmp_tblUsageSummary_;
	
	SELECT * FROM tmp_verify_;

	


END ;;
DELIMITER ;


USE `Ratemanagement3`;
INSERT INTO `tblCronJobCommand` VALUES (1,1,1,'OLD Download Sippy CDR','sippyaccountusage','[[{\"title\":\"Sippy Max Interval\",\"type\":\"text\",\"value\":\"\",\"name\":\"MaxInterval\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',0,NULL,NULL),(2,1,NULL,'Rate Generator','rategenerator','[[{\"title\":\"Effective Day\",\"type\":\"text\",\"value\":\"\",\"name\":\"EffectiveDay\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-04-21 15:11:06','RateManagementSystem'),(3,1,2,'Download Porta CDR','portaaccountusage','[[{\"title\":\"Porta Max Interval\",\"type\":\"text\",\"value\":\"\",\"name\":\"MaxInterval\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-05-01 15:38:30','RateManagementSystem'),(7,1,3,'Download VOS  CDR','vosaccountusage','[[{\"title\":\"Files Max Proccess\",\"type\":\"text\",\"value\":\"\",\"name\":\"FilesMaxProccess\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-05-29 13:05:56','RateManagementSystem'),(8,1,4,'Download PBX CDR','pbxaccountusage','[[{\"title\":\"PBX Max Interval\",\"type\":\"text\",\"value\":\"\",\"name\":\"MaxInterval\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-07-09 13:56:13','RateManagementSystem'),(17,1,NULL,'DB CleanUP','dbcleanup','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-11-19 06:02:05','RateManagementSystem'),(18,1,NULL,'Server CleanUP','servercleanup','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2016-08-11 00:00:05','RateManagementSystem'),(57,1,NULL,'Invoice Generator','invoicegenerator','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-11-19 06:02:05','RateManagementSystem'),(58,1,NULL,'Bulk Auto Payment Capture','bulkautopaymentcapture','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-11-19 06:02:05','RateManagementSystem'),(59,1,NULL,'Transaction Log Email','transactionlogemail','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-11-19 06:02:06','RateManagementSystem'),(60,1,NULL,'Activity Reminder','accountactivityreminder','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-11-19 06:02:06','RateManagementSystem'),(61,1,NULL,'Active Cron Job Email','activecronjobemail','[[{\"title\":\"Alert Active Email Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"AlertEmailInterval\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-11-27 11:01:44','RateManagementSystem'),(63,1,6,'Download Sippy CDR (SFTP)','sippyaccountusage','[[{\"title\":\"Files Max Proccess\",\"type\":\"text\",\"value\":\"\",\"name\":\"FilesMaxProccess\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2016-02-17 11:34:30',NULL),(64,1,NULL,'Create Vendor Summary','createvendorsummary','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-12-01 10:11:09','RateManagementSystem'),(65,1,NULL,'Create Customer Summary Live','createsummarylive','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-12-01 10:11:09','RateManagementSystem'),(66,1,NULL,'Create Customer Summary','createsummary','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-12-01 10:11:09','RateManagementSystem'),(67,1,NULL,'Create Vendor Summary Live','createvendorsummarylive','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-12-01 10:11:09','RateManagementSystem'),(68,1,6,'Download Sippy SFTP File','sippydownloadcdr','[[{\"title\":\"Max File Download Limit\",\"type\":\"text\",\"value\":\"\",\"name\":\"FilesDownloadLimit\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2016-06-09 19:33:05',NULL),(69,1,3,'Download VOS SFTP File','vosdownloadcdr','[[{\"title\":\"Max File Download Limit\",\"type\":\"text\",\"value\":\"\",\"name\":\"FilesDownloadLimit\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-06-09 13:05:56','RateManagementSystem'),(70,1,NULL,'Neon System Alerts','neonalerts','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2016-09-28 14:07:52','RateManagementSystem'),(72,1,NULL,'Mirta Account Block','pbxaccountblock','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2016-09-28 12:13:52','RateManagementSystem'),(73,1,NULL,'Ticket Emails','reademailstickets','[[{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2016-09-28 14:07:52','RateManagementSystem'),(74,1,7,'Download FTP CDR','ftpaccountusage','[[{\"title\":\"Files Max Proccess\",\"type\":\"text\",\"value\":\"\",\"name\":\"FilesMaxProccess\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2017-04-21 12:20:01','RateManagementSystem'),(75,1,7,'Download FTP File','ftpdownloadcdr','[[{\"title\":\"Max File Download Limit\",\"type\":\"text\",\"value\":\"\",\"name\":\"FilesDownloadLimit\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2017-04-21 12:20:01','RateManagementSystem'),(83,1,8,'Download MOR CDR','moraccountusage','[[{\"title\":\"MOR Max Interval\",\"type\":\"text\",\"value\":\"\",\"name\":\"MaxInterval\"},{\"title\":\"Threshold Time (Minute)\",\"type\":\"text\",\"value\":\"\",\"name\":\"ThresholdTime\"},{\"title\":\"Success Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"SuccessEmail\"},{\"title\":\"Error Email\",\"type\":\"text\",\"value\":\"\",\"name\":\"ErrorEmail\"}]]',1,'2015-07-09 13:56:13','RateManagementSystem');
INSERT INTO `tblCountry` VALUES (1,'93','AFGHANISTAN','AF','AFG'),(2,'355','ALBANIA','AL','ALB'),(3,'213','ALGERIA','DZ','DZA'),(4,'1684','AMERICAN SAMOA','AS','ASM'),(5,'376','ANDORRA','AD','AND'),(6,'244','ANGOLA','AO','AGO'),(7,'1264','ANGUILLA','AI','AIA'),(8,'672','ANTARCTICA','AQ','ATA'),(9,'1268','ANTIGUA & BARBUDA','AG','ATG'),(10,'54','ARGENTINA','AR','ARG'),(11,'374','ARMENIA','AM','ARM'),(12,'297','ARUBA','AW','ABW'),(13,'247','ASCENSION ISLAND',NULL,NULL),(14,'61','AUSTRALIA','AU','AUS'),(15,'672','Australia Territories',NULL,NULL),(16,'43','AUSTRIA','AT','AUT'),(17,'994','AZERBAIJAN','AZ','AZE'),(18,'1242','BAHAMAS','BS','BHS'),(19,'973','BAHRAIN','BH','BHR'),(20,'880','BANGLADESH','BD','BGD'),(21,'1246','BARBADOS','BB','BRB'),(22,'375','BELARUS','BY','BLR'),(23,'32','BELGIUM','BE','BEL'),(24,'501','BELIZE','BZ','BLZ'),(25,'229','BENIN','BJ','BEN'),(26,'1441','BERMUDA','BM','BMU'),(27,'975','BHUTAN','BT','BTN'),(28,'591','BOLIVIA','BO','BOL'),(29,'387','BOSNIA & HERZEGOVINA','BA','BIH'),(30,'267','BOTSWANA','BW','BWA'),(31,'55','BRAZIL','BR','BRA'),(32,'1284','BRITISH VIRGIN ISLANDS','VG','VGB'),(33,'673','BRUNEI DARUSSALAM','BN','BRN'),(34,'359','BULGARIA','BG','BGR'),(35,'226','BURKINA FASO','BF','BFA'),(36,'257','BURUNDI','BI','BDI'),(37,'855','CAMBODIA','KH','KHM'),(38,'237','CAMEROON','CM','CMR'),(39,'1','CANADA','CA','CAN'),(40,'238','CAPE VERDE','CV','CPV'),(41,'1345','CAYMAN ISLANDS','KY','CYM'),(42,'236','CENTRAL AFRICAN REPUBLIC','CF','CAF'),(43,'235','CHAD','TD','TCD'),(44,'56','CHILE','CL','CHL'),(45,'86','CHINA','CN','CHN'),(46,'57','COLOMBIA','CO','COL'),(47,'269','COMOROS','KM','COM'),(48,'242','Republic of the Congo','CG','COG'),(49,'682','COOK ISLANDS','CK','COK'),(50,'506','COSTA RICA','CR','CRI'),(51,'1721','COUNTRY OF SINT MAARTEN','SX','SXM'),(52,'385','CROATIA','HR','HRV'),(53,'53','CUBA','CU','CUB'),(54,'357','CYPRUS','CY','CYP'),(55,'420','CZECH REPUBLIC','CZ','CZE'),(56,'243','DEM. REP. OF CONGO','CD','COD'),(57,'45','DENMARK','DK','DNK'),(58,'246','DIEGO GARCIA',NULL,NULL),(59,'253','DJIBOUTI','DJ','DJI'),(60,'1767','DOMINICA','DM','DMA'),(61,'1','DOMINICAN REPUBLIC','DO','DOM'),(62,'670','TIMOR-LESTE','TL','TLS'),(63,'593','ECUADOR','EC','ECU'),(64,'20','EGYPT','EG','EGY'),(65,'503','EL SALVADOR','SV','SLV'),(66,'881','ELLIPSO',NULL,NULL),(67,'882','EMSAT',NULL,NULL),(68,'240','EQUATORIAL GUINEA','GQ','GNQ'),(69,'291','ERITREA','ER','ERI'),(70,'372','ESTONIA','EE','EST'),(71,'251','ETHIOPIA','ET','ETH'),(72,'500','FALKLAND ISLANDS','FK','FLK'),(73,'298','FAROE ISLANDS','FO','FRO'),(74,'679','FIJI','FJ','FJI'),(75,'358','FINLAND','FI','FIN'),(76,'33','FRANCE','FR','FRA'),(77,'594','FRENCH GUIANA','GF','GUF'),(78,'689','FRENCH POLYNESIA','PF','PYF'),(79,'241','GABON','GA','GAB'),(80,'220','GAMBIA','GM','GMB'),(81,'995','GEORGIA','GE','GEO'),(82,'49','GERMANY','DE','DEU'),(83,'233','GHANA','GH','GHA'),(84,'350','GIBRALTAR','GI','GIB'),(85,'881','GLOBALSTAR',NULL,NULL),(86,'30','GREECE','GR','GRC'),(87,'299','GREENLAND','GL','GRL'),(88,'1473','GRENADA','GD','GRD'),(89,'590','GUADELOUPE','GP','GLP'),(90,'1671','GUAM','GU','GUM'),(91,'502','GUATEMALA','GT','GTM'),(92,'224','GUINEA','GN','GIN'),(93,'245','GUINEA BISSAU','GW','GNB'),(94,'592','GUYANA','GY','GUY'),(95,'509','HAITI','HT','HTI'),(96,'504','HONDURAS','HN','HND'),(97,'852','HONG KONG','HK','HKG'),(98,'36','HUNGARY','HU','HUN'),(99,'354','ICELAND','IS','ISL'),(100,'91','INDIA','IN','IND'),(101,'62','INDONESIA','ID','IDN'),(102,'870','INMARSAT SNAC',NULL,NULL),(103,'870','INMARSAT SNAC - BGAN',NULL,NULL),(104,'870','INMARSAT SNAC - BGAN HSD',NULL,NULL),(105,'882','INTL NETWORK',NULL,NULL),(106,'883','INTL NETWORK',NULL,NULL),(107,'98','IRAN','IR','IRN'),(108,'964','IRAQ','IQ','IRQ'),(109,'353','IRELAND','IE','IRL'),(110,'881','IRIDIUM',NULL,NULL),(111,'972','ISRAEL','IL','ISR'),(112,'39','ITALY','IT','ITA'),(113,'225','IVORY COAST','CI','CIV'),(114,'1876','JAMAICA','JM','JAM'),(115,'81','JAPAN','JP','JPN'),(116,'962','JORDAN','JO','JOR'),(117,'7','KAZAKHSTAN','KZ','KAZ'),(118,'254','KENYA','KE','KEN'),(119,'686','KIRIBATI','KI','KIR'),(120,'965','KUWAIT','KW','KWT'),(121,'996','KYRGYZSTAN','KG','KGZ'),(122,'856','LAOS','LA','LAO'),(123,'371','LATVIA','LV','LVA'),(124,'961','LEBANON','LB','LBN'),(125,'266','LESOTHO','LS','LSO'),(126,'231','LIBERIA','LR','LBR'),(127,'218','LIBYAN ARAB JAMAHIRIYA','LY','LBY'),(128,'423','LIECHTENSTEIN','LI','LIE'),(129,'370','LITHUANIA','LT','LTU'),(130,'352','LUXEMBOURG','LU','LUX'),(131,'853','MACAU','MO','MAC'),(132,'389','MACEDONIA - THE FORMER YUGOSLAV REPUBLIC OF','MK','MKD'),(133,'261','MADAGASCAR','MG','MDG'),(134,'265','MALAWI','MW','MWI'),(135,'60','MALAYSIA','MY','MYS'),(136,'960','MALDIVES','MV','MDV'),(137,'223','MALI','ML','MLI'),(138,'356','MALTA','MT','MLT'),(139,'1670','MARIANA ISLANDS',NULL,NULL),(140,'692','MARSHALL ISLANDS','MH','MHL'),(141,'596','MARTINIQUE','MQ','MTQ'),(142,'222','MAURITANIA','MR','MRT'),(143,'230','MAURITIUS ISLAND','MU','MUS'),(144,'262','MAYOTTE','YT','MYT'),(145,'882','MCP NETWORK',NULL,NULL),(146,'52','MEXICO','MX','MEX'),(147,'691','MICRONESIA - FEDERATED STATES OF','FM','FSM'),(148,'373','MOLDOVA','MD','MDA'),(149,'377','MONACO','MC','MCO'),(150,'976','MONGOLIA','MN','MNG'),(151,'382','Montenegro','ME','MNE'),(152,'1664','MONTSERRAT','MS','MSR'),(153,'212','MOROCCO','MA','MAR'),(154,'258','MOZAMBIQUE','MZ','MOZ'),(155,'95','MYANMAR (BURMA)','MM','MMR'),(156,'264','NAMIBIA','NA','NAM'),(157,'674','NAURU','NR','NRU'),(158,'977','NEPAL','NP','NPL'),(159,'31','NETHERLANDS','NL','NLD'),(160,'599','NETHERLANDS ANTILLES','AN','ANT'),(161,'687','NEW CALEDONIA','NC','NCL'),(162,'64','NEW ZEALAND','NZ','NZL'),(163,'505','NICARAGUA','NI','NIC'),(164,'227','NIGER','NE','NER'),(165,'234','NIGERIA','NG','NGA'),(166,'683','NIUE ISLAND','NU','NIU'),(167,'850','NORTH KOREA','KP','PRK'),(168,'47','NORWAY','NO','NOR'),(169,'968','OMAN','OM','OMN'),(170,'882','ONAIR',NULL,NULL),(171,'882','ORATION TECHNOLOGIES NETWORK',NULL,NULL),(172,'92','PAKISTAN','PK','PAK'),(173,'680','PALAU','PW','PLW'),(174,'970','PALESTINIAN TERRITORY- OCCUPIED','PS','PSE'),(175,'507','PANAMA','PA','PAN'),(176,'675','PAPUA NEW GUINEA','PG','PNG'),(177,'595','PARAGUAY','PY','PRY'),(178,'51','PERU','PE','PER'),(179,'63','PHILIPPINES','PH','PHL'),(180,'48','POLAND','PL','POL'),(181,'351','PORTUGAL','PT','PRT'),(182,'1','Puerto Rico','PR','PRI'),(183,'974','QATAR','QA','QAT'),(184,'262','REUNION','RE','REU'),(185,'40','ROMANIA','RO','ROU'),(186,'7','RUSSIAN FEDERATION','RU','RUS'),(187,'250','RWANDA','RW','RWA'),(188,'378','SAN MARINO','SM','SMR'),(189,'239','SAO TOME & PRINCIPE','ST','STP'),(190,'966','SAUDI ARABIA','SA','SAU'),(191,'221','SENEGAL','SN','SEN'),(192,'381','SERBIA','RS','SRB'),(193,'248','SEYCHELLES','SC','SYC'),(194,'232','SIERRA LEONE','SL','SLE'),(195,'65','SINGAPORE','SG','SGP'),(196,'421','SLOVAKIA','SK','SVK'),(197,'386','SLOVENIA','SI','SVN'),(198,'677','SOLOMON ISLANDS','SB','SLB'),(199,'252','SOMALIA','SO','SOM'),(200,'27','SOUTH AFRICA','ZA','ZAF'),(201,'82','SOUTH KOREA','KR','KOR'),(202,'211','South Sudan','SS','SSD'),(203,'34','SPAIN','ES','ESP'),(204,'94','SRI LANKA','LK','LKA'),(205,'290','ST. HELENA','SH','SHN'),(206,'1869','ST. KITTS & NEVIS','KN','KNA'),(207,'1758','ST. LUCIA','LC','LCA'),(208,'508','ST. PIERRE & MIQUELON','PM','SPM'),(209,'1784','ST. VINCENT & GRENADINES','VC','VCT'),(210,'249','SUDAN','SD','SDN'),(211,'597','SURINAME','SR','SUR'),(212,'268','SWAZILAND','SZ','SWZ'),(213,'46','SWEDEN','SE','SWE'),(214,'41','SWITZERLAND','CH','CHE'),(215,'963','SYRIA','SY','SYR'),(216,'886','TAIWAN - PROVINCE OF CHINA','TW','TWN'),(217,'992','TAJIKISTAN','TJ','TJK'),(218,'255','TANZANIA','TZ','TZA'),(219,'66','THAILAND','TH','THA'),(220,'882','Thuraya',NULL,NULL),(221,'228','TOGO','TG','TGO'),(222,'690','TOKELAU','TK','TKL'),(223,'676','TONGA','TO','TON'),(224,'1868','TRINIDAD & TOBAGO','TT','TTO'),(225,'216','TUNISIA','TN','TUN'),(226,'90','TURKEY','TR','TUR'),(227,'993','TURKMENISTAN','TM','TKM'),(228,'1649','TURKS & CAICOS','TC','TCA'),(229,'688','TUVALU','TV','TUV'),(230,'1340','U.S. VIRGIN ISLANDS','VI','VIR'),(231,'256','UGANDA','UG','UGA'),(232,'380','UKRAINE','UA','UKR'),(233,'971','UNITED ARAB EMIRATES','AE','ARE'),(234,'44','UNITED KINGDOM','GB','GBR'),(235,'888','UNITED NATIONS-OCHA',NULL,NULL),(236,'878','UPT',NULL,NULL),(237,'598','URUGUAY','UY','URY'),(238,'1','USA','US','USA'),(239,'998','Uzbekistan','UZ','UZB'),(240,'678','VANUATU','VU','VUT'),(241,'58','VENEZUELA','VE','VEN'),(242,'84','VIETNAM','VN','VNM'),(243,'681','WALLIS & FUTUNA','WF','WLF'),(244,'685','WESTERN SAMOA','WS','WSM'),(245,'967','Yemen','YE','YEM'),(246,'260','ZAMBIA','ZM','ZMB'),(247,'263','ZIMBABWE','ZW','ZWE'),(248,'379','VATICAN CITY STATE','VA','VAT'),(249,'871','INMARSAT - 871',NULL,NULL),(250,'872','INMARSAT - 872',NULL,NULL),(251,'873','INMARSAT - 873',NULL,NULL),(252,'874','INMARSAT - 874',NULL,NULL),(253,'870','INMARSAT - 870',NULL,NULL),(254,'684','AMERICAN SAMOA','AS','ASM'),(255,'388','EURO SAT',NULL,NULL),(256,'699','PACIFIC ISLANDS',NULL,NULL),(257,'808','MIDWAY ISLANDS',NULL,NULL),(258,'870','PITCAIRN ISLANDS','PN','PCN'),(259,'840','ABKHAZIA',NULL,NULL),(260,'907','ALASKA',NULL,NULL),(261,'383','KOSOVO','XK','RKS'),(262,'255','Zanzibar','TZ','TZA'),(263,'1','TURKS AND CAICOS ISLANDS','TC','TCA'),(264,'599','CURACAO','CW','CUW'),(265,'61','CHRISTMAS ISLAND','CX','CXR'),(266,'672','Norfolk Island','NF','NFK'),(267,'8709','INMARSAT BGAN SNAC',NULL,NULL),(268,'47','BOUVET ISLAND','BV','BVT'),(269,'246','BRITISH INDIAN OCEAN TERRITORY','IO','IOT'),(270,'891','COCOS ISLANDS','CC','CCK'),(271,'500','SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS','GS','SGS'),(272,'1','UNITED STATES MINOR OUTLYING ISLANDS','UM','UMI'),(273,'212','WESTERN SAHARA','EH','ESH'),(274,'358','AALAND ISLANDS','AX','ALA'),(275,'599','BONAIRE','BQ','BES'),(276,'1670','NORTHERN MARIANA ISLANDS','MP','MNP'),(277,'262','French Southern Territories','TF','ATF'),(278,'44','Guernsey','GG','GGY'),(279,'1721','SINT MAARTEN DUTCH PART','SX','SXM'),(280,'90','SAINT MARTIN FRENCH PART','MF','MAF'),(281,'44','ISLE OF MAN','IM','IMN'),(282,'44','JERSEY','JE','JEY'),(283,'672','HEARD AND MCDONALD ISLANDS','HM','HMD'),(284,'47','SVALBARD AND JAN MAYEN ISLANDS','SJ','SJM');
INSERT INTO `tblGateway` VALUES (1,'Sippy','Sippy',0,'RateManagementSystem','2015-03-05 07:39:00',NULL,NULL),(2,'Porta','Porta',1,'RateManagementSystem','2015-05-01 15:38:00',NULL,NULL),(3,'VOS','VOS',1,'RateManagementSystem','2015-05-29 13:06:00',NULL,NULL),(4,'PBX','PBX',1,'RateManagementSystem','2015-07-09 13:56:00',NULL,NULL),(5,'ManualCDR','ManualCDR',1,'RateManagementSystem','2015-10-30 12:01:00',NULL,NULL),(6,'Sippy SFTP','SippySFTP',1,'RateManagementSystem','2016-02-17 16:50:41',NULL,'2016-02-17 16:50:42'),(7,'FTP','FTP',1,'RateManagementSystem','2017-04-21 12:20:01',NULL,'2017-04-21 12:20:01'),(8,'MOR','MOR',1,'RateManagementSystem','2017-01-28 12:41:23',NULL,NULL);
INSERT INTO `tblGatewayConfig` VALUES (1,1,'API User','username',0,'2015-03-05 07:35:00','RateManagementSystem',NULL,NULL),(2,1,'API Password','password',0,'2015-03-05 07:35:00','RateManagementSystem',NULL,NULL),(3,1,'API Url','api_url',0,'2015-03-05 07:35:00','RateManagementSystem',NULL,NULL),(4,1,'Authentication Rule','NameFormat',0,'2015-03-05 07:35:00','RateManagementSystem',NULL,NULL),(5,2,'API Url','api_url',1,'2015-05-01 15:38:00','RateManagementSystem',NULL,NULL),(6,2,'License Key','password',1,'2015-05-01 15:38:00','RateManagementSystem',NULL,NULL),(8,2,'Authentication Rule','NameFormat',1,'2015-05-08 07:46:00','RateManagementSystem',NULL,NULL),(9,3,'SFTP Host IP','host',1,'2015-05-29 13:06:00','RateManagementSystem',NULL,NULL),(10,3,'User Name','username',1,'2015-05-29 13:06:00','RateManagementSystem',NULL,NULL),(11,3,'Password','password',1,'2015-05-29 13:06:00','RateManagementSystem',NULL,NULL),(12,3,'Authentication Rule','NameFormat',1,'2015-05-29 13:06:00','RateManagementSystem',NULL,NULL),(13,3,'SFTP CDR Download Path','cdr_folder',1,'2015-06-13 11:05:00','RateManagementSystem',NULL,NULL),(14,4,'PBX Server','dbserver',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(15,4,'PBX Username','username',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(16,4,'PBX Password','password',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(17,4,'Authentication Rule','NameFormat',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(18,1,'Billing Time','BillingTime',0,'2015-08-13 07:58:00','RateManagementSystem',NULL,NULL),(19,2,'Billing Time','BillingTime',1,'2015-08-13 07:58:00','RateManagementSystem',NULL,NULL),(20,3,'Billing Time','BillingTime',1,'2015-08-13 07:58:00','RateManagementSystem',NULL,NULL),(21,5,'Billing Time','BillingTime',1,'2015-10-30 12:03:00','RateManagementSystem',NULL,NULL),(22,5,'Authentication Rule','NameFormat',1,'2015-10-30 12:03:00','RateManagementSystem',NULL,NULL),(23,1,'CDR ReRate','RateCDR',0,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(24,2,'CDR ReRate','RateCDR',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(25,3,'CDR ReRate','RateCDR',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(26,4,'CDR ReRate','RateCDR',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(27,5,'CDR ReRate','RateCDR',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(28,1,'Rate Format','RateFormat',0,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(29,2,'Rate Format','RateFormat',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(30,3,'Rate Format','RateFormat',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(31,4,'Rate Format','RateFormat',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(32,5,'Rate Format','RateFormat',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(33,6,'SFTP Host IP','host',1,'2015-05-29 13:06:00',NULL,NULL,NULL),(34,6,'User Name','username',1,'2015-05-29 13:06:00',NULL,NULL,NULL),(35,6,'Password','password',1,'2015-05-29 13:06:00',NULL,NULL,NULL),(36,6,'Authentication Rule','NameFormat',1,'2015-05-29 13:06:00',NULL,NULL,NULL),(37,6,'SFTP CDR Download Path','cdr_folder',1,'2015-06-13 11:05:00',NULL,NULL,NULL),(38,6,'Billing Time','BillingTime',1,'2015-08-13 07:58:00',NULL,NULL,NULL),(39,6,'CDR ReRate','RateCDR',1,'2015-12-21 11:19:00',NULL,NULL,NULL),(40,6,'Rate Format','RateFormat',1,'2015-12-21 11:19:00',NULL,NULL,NULL),(41,2,'Allow Account Import','AllowAccountImport',1,'2016-03-18 11:19:00','RateManagementSystem',NULL,NULL),(42,4,'Allow Account Import','AllowAccountImport',1,'2016-03-29 11:19:00','RateManagementSystem',NULL,NULL),(43,1,'CLI Translation Rule','CLITranslationRule',0,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(44,2,'CLI Translation Rule','CLITranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(45,3,'CLI Translation Rule','CLITranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(46,4,'CLI Translation Rule','CLITranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(47,5,'CLI Translation Rule','CLITranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(48,6,'CLI Translation Rule','CLITranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(49,1,'CLD Translation Rule','CLDTranslationRule',0,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(50,2,'CLD Translation Rule','CLDTranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(51,3,'CLD Translation Rule','CLDTranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(52,4,'CLD Translation Rule','CLDTranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(53,5,'CLD Translation Rule','CLDTranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(54,6,'CLD Translation Rule','CLDTranslationRule',1,'2016-09-19 11:40:52','RateManagementSystem',NULL,NULL),(61,7,'User Name','username',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(62,7,'Rate Format','RateFormat',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(63,7,'Authentication Rule','NameFormat',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(64,7,'CDR ReRate','RateCDR',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(65,7,'CLI Translation Rule','CLITranslationRule',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(66,7,'FTP Host IP','host',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(67,7,'Password','password',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(68,7,'FTP CDR Download Path','cdr_folder',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(69,7,'CLD Translation Rule','CLDTranslationRule',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(70,7,'Billing Time','BillingTime',1,'2017-04-21 12:20:01','RateManagementSystem',NULL,NULL),(71,8,'MOR Server','dbserver',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(72,8,'MOR Username','username',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(73,8,'MOR Password','password',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(74,8,'Authentication Rule','NameFormat',1,'2015-07-09 13:56:00','RateManagementSystem',NULL,NULL),(75,8,'CDR ReRate','RateCDR',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(76,8,'Rate Format','RateFormat',1,'2015-12-21 11:19:00','RateManagementSystem',NULL,NULL),(77,8,'CLI Translation Rule','CLITranslationRule',1,'2016-09-19 10:39:33','RateManagementSystem',NULL,NULL),(78,8,'CLD Translation Rule','CLDTranslationRule',1,'2016-09-19 10:39:33','RateManagementSystem',NULL,NULL),(79,8,'Allow Account Import','AllowAccountImport',1,'2016-03-18 11:19:00','RateManagementSystem',NULL,NULL);
INSERT INTO `tblGlobalAdmin` VALUES (1,'Deven','Sitapara','globaladmin@globaladmin.com','$2y$10$V0Y68kXOSZdLLTU1kgKbCugunfhxQdXIQN2IPO/cbWSnEj1nuMTYS',1,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `tblGlobalSetting` VALUES (1,'Default_Customer_Trunk_Prefix','22221');
INSERT INTO `tblJobStatus` VALUES (1,'P','Pending',NULL,'2014-09-23 13:45:53','RateManagementSystem',NULL,NULL),(2,'I','In Progress',NULL,'2014-09-23 13:45:53','RateManagementSystem',NULL,NULL),(3,'S','Success',NULL,'2014-09-23 13:45:53','RateManagementSystem',NULL,NULL),(4,'F','Failed',NULL,'2014-09-23 13:45:53','RateManagementSystem',NULL,NULL),(5,'C','Cancelled',NULL,'2014-09-23 13:45:53','RateManagementSystem',NULL,NULL),(6,'PF','Partially Failed',NULL,'2014-12-30 16:43:46','RateManagementSystem',NULL,NULL);
INSERT INTO `tblJobType` VALUES (1,'CD','Customer Rate Sheet Download',NULL,'2014-09-23 13:45:34','RateManagementSystem',NULL,NULL),(2,'VD','Vendor Rate Sheet Download',NULL,'2014-09-23 13:45:34','RateManagementSystem',NULL,NULL),(3,'CDU','Code Deck Upload',NULL,'2014-09-23 13:45:34','RateManagementSystem',NULL,NULL),(4,'VU','Vendor Rate Upload',NULL,'2014-09-23 13:45:34','RateManagementSystem',NULL,NULL),(5,'GRT','Generate Rate Table',NULL,'2014-10-09 06:21:51','RateManagementSystem',NULL,NULL),(6,'CDR','CDR Upload',NULL,'2015-04-18 06:21:51','RateManagementSystem',NULL,NULL),(7,'BI','Bulk Invoice',NULL,'2015-05-09 14:19:43','RateManagementSystem',NULL,NULL),(8,'BIS','Bulk Invoice Send',NULL,'2015-06-13 10:50:49','RateManagementSystem',NULL,NULL),(9,'RCC','CDR Recalculate',NULL,'2015-06-23 12:03:27','RateManagementSystem',NULL,NULL),(10,'INU','Create Invoice Usage File',NULL,'2015-06-23 15:25:11','sa',NULL,NULL),(11,'BIR','Bulk Invoice Regeneration',NULL,'2015-07-27 12:54:45','sa',NULL,NULL),(12,'BLE','Bulk Leads mail send',NULL,'2015-07-28 15:02:04','RateManagementSystem',NULL,NULL),(13,'BPC','Bulk Auto Payment Capture',NULL,'2015-08-21 13:17:47','RateManagementSystem',NULL,NULL),(14,'BAE','Bulk Accounts mail send',NULL,'2015-10-07 09:01:03','RateManagementSystem',NULL,NULL),(15,'TLE','Transactions Log Email','Transactions Log Email By Daily,Weekly,Monthly','2015-10-07 09:02:43','RateManagementSystem',NULL,NULL),(16,'IR','Invoice Bulk Email',NULL,'2015-10-30 08:54:45','RateManagementSystem',NULL,NULL),(17,'AAE','Account Activity Email Send','Account Activity Email Send By Daily','2015-10-30 08:55:33','RateManagementSystem',NULL,NULL),(18,'RTU','Rate Table Upload',NULL,'2016-01-27 14:29:35','RateManagementSystem',NULL,NULL),(19,'PU','Payment Upload',NULL,'2016-02-05 12:40:29','RateManagementSystem',NULL,NULL),(20,'VDR','Vendor CDR Upload',NULL,'2016-02-17 15:30:04','RateManagementSystem',NULL,NULL),(21,'MGA','Import Account',NULL,'2016-03-17 14:30:04','RateManagementSystem',NULL,NULL),(22,'DSU','Dial String Upload',NULL,'2016-06-21 14:30:04','RateManagementSystem',NULL,NULL),(23,'QIP','QuickBook Invoice Post',NULL,'2016-10-05 16:00:00','RateManagementSystem',NULL,NULL);
INSERT INTO `tblRateSheetFormate` VALUES (1,'Vos 3.2',NULL,1,1,1,'2015-02-07 04:58:56',NULL,NULL,NULL),(2,'Rate Sheet',NULL,1,0,1,'2015-02-07 04:58:56',NULL,NULL,NULL),(3,'Sippy',NULL,1,1,1,'2015-02-07 04:58:56',NULL,NULL,NULL),(4,'Porta',NULL,1,1,1,'2015-05-26 12:01:48','RateManagementSystem',NULL,NULL);
INSERT INTO `tblResource` VALUES (1,'DashboardCustomer.home','DashboardCustomerController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',7),(2,'DashboardCustomer.invoice_expense_chart','DashboardCustomerController.invoice_expense_chart',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(3,'DashboardCustomer.invoice_expense_total','DashboardCustomerController.invoice_expense_total',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(4,'Profile.get_outstanding_amount','ProfileController.get_outstanding_amount',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(5,'InvoicesCustomer.index','InvoicesCustomerController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(6,'InvoicesCustomer.*','InvoicesCustomerController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(7,'InvoicesCustomer.ajax_datagrid','InvoicesCustomerController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(8,'InvoicesCustomer.pay_now','InvoicesCustomerController.pay_now',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(9,'PaymentsCustomer.index','PaymentsCustomerController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(10,'PaymentsCustomer.*','PaymentsCustomerController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(11,'PaymentsCustomer.create','PaymentsCustomerController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(12,'PaymentsCustomer.ajax_datagrid','PaymentsCustomerController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(13,'AccountStatementCustomer.index','AccountStatementCustomerController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(14,'AccountStatementCustomer.*','AccountStatementCustomerController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(15,'AccountStatementCustomer.getPayment','AccountStatementCustomerController.getPayment',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(16,'AccountStatementCustomer.ajax_datagrid','AccountStatementCustomerController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(17,'AccountStatementCustomer.exports','AccountStatementCustomerController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(18,'PaymentProfileCustomer.paynow','PaymentProfileCustomerController.paynow',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(19,'PaymentProfileCustomer.index','PaymentProfileCustomerController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(20,'PaymentProfileCustomer.*','PaymentProfileCustomerController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(21,'PaymentProfileCustomer.create','PaymentProfileCustomerController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(22,'PaymentProfileCustomer.delete','PaymentProfileCustomerController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(23,'PaymentProfileCustomer.update','PaymentProfileCustomerController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(24,'PaymentProfileCustomer.ajax_datagrid','PaymentProfileCustomerController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(25,'PaymentProfileCustomer.set_default','PaymentProfileCustomerController.set_default',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(26,'PaymentProfileCustomer.card_active_deactive','PaymentProfileCustomerController.card_active_deactive',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(27,'Role.index','RoleController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(28,'Role.*','RoleController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(29,'Role.storerole','RoleController.storerole',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(30,'Role.storepermission','RoleController.storepermission',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(31,'Role.store','RoleController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(32,'Role.edit','RoleController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(33,'Role.update','RoleController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(34,'Role.delete','RoleController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(35,'Role.ajax_datagrid','RoleController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(36,'Role.ajax_user_list','RoleController.ajax_user_list',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(37,'Role.ajax_role_list','RoleController.ajax_role_list',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(38,'Role.ajax_resource_list','RoleController.ajax_resource_list',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(39,'Profile.show','ProfileController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(40,'Profile.edit','ProfileController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(41,'Profile.update','ProfileController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',NULL),(42,'Users.index','UsersController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',101),(43,'Users.*','UsersController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',98),(44,'Users.add','UsersController.add',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',99),(45,'Users.store','UsersController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',99),(46,'Users.edit','UsersController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',100),(47,'Users.update','UsersController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',77),(48,'Users.exports','UsersController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',101),(49,'Users.ajax_datagrid','UsersController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',101),(50,'Users.edit_profile','UsersController.edit_profile',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',70),(51,'Users.update_profile','UsersController.update_profile',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',70),(52,'Dashboard.home','DashboardController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',7),(53,'Dashboard.salesdashboard','DashboardController.salesdashboard',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',8),(54,'Dashboard.billingdashboard','DashboardController.billingdashboard',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',9),(55,'Trunk.edit','TrunkController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',73),(56,'Trunk.update','TrunkController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',73),(57,'Trunk.store','TrunkController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',72),(58,'Trunk.create','TrunkController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:33.000','2015-11-28 09:37:33.000',72),(59,'Trunk.ajax_datagrid','TrunkController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',74),(60,'Trunk.exports','TrunkController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',74),(61,'Trunk.index','TrunkController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',74),(62,'Trunk.*','TrunkController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',71),(63,'Trunk.create','TrunkController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(64,'Trunk.store','TrunkController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(65,'Trunk.show','TrunkController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(66,'Trunk.edit','TrunkController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(67,'Trunk.update','TrunkController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(68,'Trunk.update','TrunkController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(69,'Trunk.destroy','TrunkController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(70,'Trunk.get','TrunkController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',74),(71,'Trunk.missingMethod','TrunkController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',74),(72,'CodeDecks.store','CodeDecksController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',77),(73,'CodeDecks.update','CodeDecksController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(74,'CodeDecks.upload','CodeDecksController.upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',1144),(75,'CodeDecks.ajax_datagrid','CodeDecksController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',78),(76,'CodeDecks.exports','CodeDecksController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',78),(77,'CodeDecks.delete_all','CodeDecksController.delete_all',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(78,'CodeDecks.delete_selected','CodeDecksController.delete_selected',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(79,'CodeDecks.update_selected','CodeDecksController.update_selected',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(80,'CodeDecks.download_sample_excel_file','CodeDecksController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(81,'CodeDecks.cretecodedeck','CodeDecksController.cretecodedeck',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',77),(82,'CodeDecks.delete','CodeDecksController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(83,'CodeDecks.base_datagrid','CodeDecksController.base_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',78),(84,'CodeDecks.basecodedeck','CodeDecksController.basecodedeck',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',78),(85,'CodeDecks.updatecodedeck','CodeDecksController.updatecodedeck',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(86,'CodeDecks.base_delete','CodeDecksController.base_delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(87,'CodeDecks.base_exports','CodeDecksController.base_exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',78),(88,'CodeDecks.index','CodeDecksController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',78),(89,'CodeDecks.*','CodeDecksController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',75),(90,'CodeDecks.create','CodeDecksController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',77),(91,'CodeDecks.store','CodeDecksController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(92,'CodeDecks.show','CodeDecksController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(93,'CodeDecks.edit','CodeDecksController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(94,'CodeDecks.update','CodeDecksController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(95,'CodeDecks.update','CodeDecksController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(96,'CodeDecks.destroy','CodeDecksController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(97,'CodeDecks.delete','CodeDecksController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(98,'CodeDecks.delete_selected','CodeDecksController.delete_selected',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(99,'CodeDecks.delete_all','CodeDecksController.delete_all',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',79),(100,'CodeDecks.get','CodeDecksController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(101,'CodeDecks.missingMethod','CodeDecksController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',76),(102,'Accounts.store','AccountsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',1),(103,'Accounts.update','AccountsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',2),(104,'Accounts.show','AccountsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(105,'Accounts.store_note','AccountsController.store_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(106,'Accounts.delete_note','AccountsController.delete_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(107,'Accounts.upload','AccountsController.upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',2),(108,'Accounts.download_doc','AccountsController.download_doc',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(109,'Accounts.download_doc_file','AccountsController.download_doc_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(110,'Accounts.delete_doc','AccountsController.delete_doc',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',2),(111,'Accounts.ajax_datagrid','AccountsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(112,'Accounts.exports','AccountsController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(113,'Accounts.due_ratesheet','AccountsController.due_ratesheet',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(114,'Accounts.ajax_datagrid_sheet','AccountsController.ajax_datagrid_sheet',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(115,'Accounts.ajax_datagrid_PaymentProfiles','AccountsController.ajax_datagrid_PaymentProfiles',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(116,'Accounts.addbillingaccount','AccountsController.addbillingaccount',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',1),(117,'Accounts.change_verifiaction_status','AccountsController.change_verifiaction_status',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',2),(118,'Accounts.get_outstanding_amount','AccountsController.get_outstanding_amount',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',4),(119,'Accounts.paynow','AccountsController.paynow',1,'Sumera Saeed',NULL,'2015-11-28 09:37:34.000','2015-11-28 09:37:34.000',NULL),(120,'Accounts.ajax_template','AccountsController.ajax_template',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(121,'Accounts.ajax_getEmailTemplate','AccountsController.ajax_getEmailTemplate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(122,'Accounts.bulk_mail','AccountsController.bulk_mail',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(123,'Accounts.validate_cli','AccountsController.validate_cli',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(124,'Accounts.validate_ip','AccountsController.validate_ip',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(125,'Accounts.bulk_tags','AccountsController.bulk_tags',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(126,'AccountSubscription.ajax_datagrid','AccountSubscriptionController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(127,'AccountSubscription.store','AccountSubscriptionController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(128,'AccountSubscription.update','AccountSubscriptionController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(129,'AccountSubscription.delete','AccountSubscriptionController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(130,'AccountOneOffCharge.ajax_datagrid','AccountOneOffChargeController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(131,'AccountOneOffCharge.store','AccountOneOffChargeController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(132,'AccountOneOffCharge.update','AccountOneOffChargeController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(133,'AccountOneOffCharge.delete','AccountOneOffChargeController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(134,'AccountOneOffCharge.ajax_getProductInfo','AccountOneOffChargeController.ajax_getProductInfo',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(135,'AccountActivity.ajax_datagrid','AccountActivityController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(136,'AccountActivity.store','AccountActivityController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(137,'AccountActivity.update','AccountActivityController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(138,'AccountActivity.delete','AccountActivityController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(139,'AccountActivity.ajax_datagrid_email_log','AccountActivityController.ajax_datagrid_email_log',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(140,'AccountActivity.sendMail','AccountActivityController.sendMail',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(141,'AccountActivity.view_email_log','AccountActivityController.view_email_log',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(142,'AccountActivity.delete_email_log','AccountActivityController.delete_email_log',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(143,'Accounts.convert','AccountsController.convert',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(144,'Accounts.index','AccountsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',4),(145,'Accounts.*','AccountsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(146,'Accounts.create','AccountsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',1),(147,'Accounts.store','AccountsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(148,'Accounts.show','AccountsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(149,'Accounts.edit','AccountsController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(150,'Accounts.update','AccountsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(151,'Accounts.update','AccountsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(152,'Accounts.destroy','AccountsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(153,'Accounts.delete_note','AccountsController.delete_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(154,'Accounts.delete_doc','AccountsController.delete_doc',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(155,'Accounts.get_outstanding_amount','AccountsController.get_outstanding_amount',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(156,'Accounts.get','AccountsController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(157,'Accounts.missingMethod','AccountsController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(158,'AccountStatement.index','AccountStatementController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(159,'AccountStatement.*','AccountStatementController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',51),(160,'AccountStatement.getPayment','AccountStatementController.getPayment',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(161,'AccountStatement.ajax_datagrid','AccountStatementController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(162,'AccountStatement.exports','AccountStatementController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(163,'EmailTemplate.index','EmailTemplateController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',23),(164,'EmailTemplate.*','EmailTemplateController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',12),(165,'EmailTemplate.update','EmailTemplateController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',22),(166,'EmailTemplate.edit','EmailTemplateController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',22),(167,'EmailTemplate.delete','EmailTemplateController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',24),(168,'EmailTemplate.store','EmailTemplateController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',21),(169,'EmailTemplate.ajax_datagrid','EmailTemplateController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',23),(170,'EmailTemplate.exports','EmailTemplateController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',23),(171,'Leads.store','LeadsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',14),(172,'Leads.update','LeadsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',16),(173,'Leads.show','LeadsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',15),(174,'Leads.store_note','LeadsController.store_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',15),(175,'Leads.delete_note','LeadsController.delete_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',15),(176,'Leads.convert','LeadsController.convert',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',136),(177,'Leads.ajax_template','LeadsController.ajax_template',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(178,'Leads.bulk_mail','LeadsController.bulk_mail',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',1140),(179,'Leads.bulk_tags','LeadsController.bulk_tags',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',16),(180,'Leads.ajax_datagrid','LeadsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',15),(181,'Leads.ajax_getEmailTemplate','LeadsController.ajax_getEmailTemplate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(182,'Leads.exports','LeadsController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(183,'Leads.index','LeadsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',15),(184,'Leads.*','LeadsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',10),(185,'Leads.create','LeadsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',14),(186,'Leads.store','LeadsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(187,'Leads.show','LeadsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(188,'Leads.edit','LeadsController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',16),(189,'Leads.update','LeadsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',16),(190,'Leads.update','LeadsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(191,'Leads.destroy','LeadsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(192,'Contacts.create','ContactsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',18),(193,'Contacts.store','ContactsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',18),(194,'Contacts.update','ContactsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',19),(195,'Contacts.show','ContactsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',17),(196,'Contacts.store_note','ContactsController.store_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',17),(197,'Contacts.delete_note','ContactsController.delete_note',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',17),(198,'Contacts.convert','ContactsController.convert',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(199,'Contacts.destroy','ContactsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',20),(200,'Contacts.ajax_datagrid','ContactsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',17),(201,'Contacts.exports','ContactsController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',17),(202,'Contacts.index','ContactsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',17),(203,'Contacts.*','ContactsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',11),(204,'Contacts.create','ContactsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(205,'Contacts.store','ContactsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(206,'Contacts.show','ContactsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(207,'Contacts.edit','ContactsController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',19),(208,'Contacts.update','ContactsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(209,'Contacts.update','ContactsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(210,'Contacts.destroy','ContactsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',NULL),(211,'CustomersRates.index','CustomersRatesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',120),(212,'CustomersRates.*','CustomersRatesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',119),(213,'CustomersRates.search_ajax_datagrid','CustomersRatesController.search_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',120),(214,'CustomersRates.search_customer_grid','CustomersRatesController.search_customer_grid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',6),(215,'CustomersRates.download','CustomersRatesController.download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',124),(216,'CustomersRates.process_download','CustomersRatesController.process_download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',124),(217,'CustomersRates.update','CustomersRatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',121),(218,'CustomersRates.process_bulk_rate_update','CustomersRatesController.process_bulk_rate_update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',121),(219,'CustomersRates.process_bulk_rate_clear','CustomersRatesController.process_bulk_rate_clear',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',122),(220,'CustomersRates.settings','CustomersRatesController.settings',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',123),(221,'CustomersRates.update_trunks','CustomersRatesController.update_trunks',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',123),(222,'CustomersRates.delete_customerrates','CustomersRatesController.delete_customerrates',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',123),(223,'CustomersRates.bulk_update','CustomersRatesController.bulk_update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',121),(224,'CustomersRates.ajax_datagrid_search_customer_rate','CustomersRatesController.ajax_datagrid_search_customer_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(225,'CustomersRates.clear_rate','CustomersRatesController.clear_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',122),(226,'CustomersRates.bulk_clear_rate','CustomersRatesController.bulk_clear_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',122),(227,'CustomersRates.history','CustomersRatesController.history',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',125),(228,'CustomersRates.history_ajax_datagrid','CustomersRatesController.history_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',125),(229,'CustomersRates.show_history','CustomersRatesController.show_history',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',125),(230,'CustomersRates.exports','CustomersRatesController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(231,'CustomersRates.history_exports','CustomersRatesController.history_exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',125),(232,'CustomersRates.download_excel_file','CustomersRatesController.download_excel_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(233,'CustomersRates.vendor_merge','CustomersRatesController.vendor_merge',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(234,'CustomersRates.index','CustomersRatesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(235,'CustomersRates.*','CustomersRatesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(236,'CustomersRates.create','CustomersRatesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(237,'CustomersRates.store','CustomersRatesController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(238,'CustomersRates.show','CustomersRatesController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(239,'CustomersRates.edit','CustomersRatesController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(240,'CustomersRates.update','CustomersRatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(241,'CustomersRates.update','CustomersRatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(242,'CustomersRates.destroy','CustomersRatesController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(243,'CustomersRates.delete_customerrates','CustomersRatesController.delete_customerrates',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(244,'CustomersRates.get','CustomersRatesController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',120),(245,'CustomersRates.missingMethod','CustomersRatesController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',120),(246,'VendorBlockings.index','VendorBlockingsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(247,'VendorBlockings.*','VendorBlockingsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',135),(248,'VendorBlockings.blockby_code','VendorBlockingsController.blockby_code',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(249,'VendorBlockings.block','VendorBlockingsController.block',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(250,'VendorBlockings.unblock','VendorBlockingsController.unblock',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(251,'VendorBlockings.index_blockby_code','VendorBlockingsController.index_blockby_code',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(252,'VendorBlockings.*_blockby_code','VendorBlockingsController.*_blockby_code',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(253,'VendorBlockings.unblockby_code','VendorBlockingsController.unblockby_code',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(254,'VendorBlockings.ajax_datagrid_blockbycountry','VendorBlockingsController.ajax_datagrid_blockbycountry',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(255,'VendorBlockings.blockbycountry_exports','VendorBlockingsController.blockbycountry_exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(256,'VendorBlockings.ajax_datagrid_blockbycode','VendorBlockingsController.ajax_datagrid_blockbycode',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(257,'VendorBlockings.blockbycode_exports','VendorBlockingsController.blockbycode_exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(258,'VendorBlockings.index','VendorBlockingsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(259,'VendorBlockings.*','VendorBlockingsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',126),(260,'VendorBlockings.create','VendorBlockingsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(261,'VendorBlockings.store','VendorBlockingsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(262,'VendorBlockings.show','VendorBlockingsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(263,'VendorBlockings.edit','VendorBlockingsController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(264,'VendorBlockings.update','VendorBlockingsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(265,'VendorBlockings.update','VendorBlockingsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(266,'VendorBlockings.destroy','VendorBlockingsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(267,'VendorBlockings.get','VendorBlockingsController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(268,'VendorBlockings.missingMethod','VendorBlockingsController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',NULL),(269,'VendorRates.download_sample_excel_file','VendorRatesController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(270,'VendorRates.index','VendorRatesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',127),(271,'VendorRates.*','VendorRatesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',126),(272,'VendorRates.upload','VendorRatesController.upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(273,'VendorRates.settings','VendorRatesController.settings',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',132),(274,'VendorRates.process_upload','VendorRatesController.process_upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(275,'VendorRates.download','VendorRatesController.download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(276,'VendorRates.process_download','VendorRatesController.process_download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(277,'VendorRates.history','VendorRatesController.history',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',134),(278,'VendorRates.history_ajax_datagrid','VendorRatesController.history_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',134),(279,'VendorRates.show_history','VendorRatesController.show_history',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',134),(280,'VendorRates.history_exports','VendorRatesController.history_exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',134),(281,'VendorRates.search_ajax_datagrid','VendorRatesController.search_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',127),(282,'VendorRates.exports','VendorRatesController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',127),(283,'VendorRates.delete_vendorrates','VendorRatesController.delete_vendorrates',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',132),(284,'VendorRates.update_settings','VendorRatesController.update_settings',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',132),(285,'VendorRates.downloaded_excel_file_download','VendorRatesController.downloaded_excel_file_download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',131),(286,'VendorRates.uploaded_excel_file_download','VendorRatesController.uploaded_excel_file_download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(287,'VendorRates.bulk_clear_rate','VendorRatesController.bulk_clear_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',129),(288,'VendorRates.bulk_update','VendorRatesController.bulk_update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',127),(289,'VendorRates.bulk_update_new','VendorRatesController.bulk_update_new',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',127),(290,'VendorRates.vendor_preference','VendorRatesController.vendor_preference',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',133),(291,'VendorRates.search_ajax_datagrid_preference','VendorRatesController.search_ajax_datagrid_preference',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',133),(292,'VendorRates.bulk_update_preference','VendorRatesController.bulk_update_preference',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',133),(293,'VendorRates.check_upload','VendorRatesController.check_upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(294,'VendorRates.ajaxfilegrid','VendorRatesController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(295,'VendorRates.storeTemplate','VendorRatesController.storeTemplate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',130),(296,'VendorRates.index','VendorRatesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(297,'VendorRates.*','VendorRatesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(298,'VendorRates.create','VendorRatesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(299,'VendorRates.store','VendorRatesController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(300,'VendorRates.show','VendorRatesController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(301,'VendorRates.edit','VendorRatesController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(302,'VendorRates.update','VendorRatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',127),(303,'VendorRates.update','VendorRatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(304,'VendorRates.destroy','VendorRatesController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(305,'VendorRates.delete_vendorrates','VendorRatesController.delete_vendorrates',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(306,'VendorRates.get','VendorRatesController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(307,'VendorRates.missingMethod','VendorRatesController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(308,'Jobs.index','JobsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(309,'Jobs.*','JobsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',90),(310,'Jobs.ajax_datagrid','JobsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(311,'Jobs.show','JobsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(312,'Jobs.exports','JobsController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(313,'Jobs.download_rate_sheet_file','JobsController.download_rate_sheet_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(314,'Jobs.loadDashboardJobsDropDown','JobsController.loadDashboardJobsDropDown',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',6),(315,'Jobs.resetJobsAlert','JobsController.resetJobsAlert',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(316,'Jobs.jobRead','JobsController.jobRead',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(317,'Jobs.downloaOutputFile','JobsController.downloaOutputFile',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',91),(318,'Jobs.index','JobsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(319,'Jobs.*','JobsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(320,'Jobs.create','JobsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',92),(321,'Jobs.store','JobsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',92),(322,'Jobs.show','JobsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(323,'Jobs.edit','JobsController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',93),(324,'Jobs.update','JobsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',93),(325,'Jobs.update','JobsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(326,'Jobs.destroy','JobsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',94),(327,'Jobs.get','JobsController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(328,'Jobs.missingMethod','JobsController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(329,'RateGenerators.index','RateGeneratorsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',31),(330,'RateGenerators.*','RateGeneratorsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',13),(331,'RateGenerators.ajax_datagrid','RateGeneratorsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',31),(332,'RateGenerators.ajax_margin_datagrid','RateGeneratorsController.ajax_margin_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',31),(333,'RateGenerators.delete','RateGeneratorsController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',1215),(334,'RateGenerators.create','RateGeneratorsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',33),(335,'RateGenerators.store','RateGeneratorsController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',33),(336,'RateGenerators.update','RateGeneratorsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(337,'RateGenerators.edit','RateGeneratorsController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(338,'RateGenerators.store_rule','RateGeneratorsController.store_rule',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(339,'RateGenerators.rules','RateGeneratorsController.rules',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(340,'RateGenerators.generate_rate_table','RateGeneratorsController.generate_rate_table',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(341,'RateGenerators.edit_rule','RateGeneratorsController.edit_rule',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(342,'RateGenerators.delete_rule','RateGeneratorsController.delete_rule',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(343,'RateGenerators.edit_rule_source','RateGeneratorsController.edit_rule_source',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(344,'RateGenerators.edit_rule_margin','RateGeneratorsController.edit_rule_margin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(345,'RateGenerators.update_rule_margin','RateGeneratorsController.update_rule_margin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(346,'RateGenerators.add_rule_margin','RateGeneratorsController.add_rule_margin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(347,'RateGenerators.delete_rule_margin','RateGeneratorsController.delete_rule_margin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(348,'RateGenerators.update_rule_source','RateGeneratorsController.update_rule_source',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(349,'RateGenerators.update_rule','RateGeneratorsController.update_rule',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(350,'RateGenerators.change_status','RateGeneratorsController.change_status',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(351,'RateGenerators.exports','RateGeneratorsController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',31),(352,'RateGenerators.ajax_load_rate_table_dropdown','RateGeneratorsController.ajax_load_rate_table_dropdown',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',31),(357,'RateGenerators.show','RateGeneratorsController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(361,'RateGenerators.destroy','RateGeneratorsController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(365,'RateGenerators.get','RateGeneratorsController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(366,'RateGenerators.missingMethod','RateGeneratorsController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',32),(367,'RateTables.index','RateTablesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',28),(368,'RateTables.*','RateTablesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',25),(369,'RateTables.search_ajax_datagrid','RateTablesController.search_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',28),(370,'RateTables.ajax_datagrid','RateTablesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',28),(371,'RateTables.edit_ajax_datagrid','RateTablesController.edit_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',NULL),(372,'RateTables.store','RateTablesController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',26),(373,'RateTables.delete','RateTablesController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',29),(374,'RateTables.view','RateTablesController.view',1,'Sumera Saeed',NULL,'2015-11-28 09:37:37.000','2015-11-28 09:37:37.000',28),(375,'RateTables.add_newrate','RateTablesController.add_newrate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',26),(376,'RateTables.clear_rate','RateTablesController.clear_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',29),(377,'RateTables.update_rate_table_rate','RateTablesController.update_rate_table_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',27),(378,'RateTables.bulk_update_rate_table_rate','RateTablesController.bulk_update_rate_table_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',27),(379,'RateTables.bulk_clear_rate_table_rate','RateTablesController.bulk_clear_rate_table_rate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',29),(380,'RateTables.change_status','RateTablesController.change_status',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',27),(381,'RateTables.exports','RateTablesController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',28),(382,'RateTables.rate_exports','RateTablesController.rate_exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',28),(383,'RateTables.index','RateTablesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(384,'RateTables.*','RateTablesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(385,'RateTables.create','RateTablesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',26),(386,'RateTables.store','RateTablesController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',26),(387,'RateTables.show','RateTablesController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(388,'RateTables.edit','RateTablesController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',27),(389,'RateTables.update','RateTablesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',27),(390,'RateTables.update','RateTablesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(391,'RateTables.destroy','RateTablesController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',29),(392,'RateTables.delete','RateTablesController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(393,'RateTables.get','RateTablesController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(394,'RateTables.missingMethod','RateTablesController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(395,'LCR.index','LCRController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(396,'LCR.*','LCRController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(397,'LCR.search_ajax_datagrid','LCRController.search_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(398,'LCR.exports','LCRController.exports',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(399,'LCR.index','LCRController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(400,'LCR.*','LCRController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',30),(401,'LCR.create','LCRController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(402,'LCR.store','LCRController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(403,'LCR.show','LCRController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(404,'LCR.edit','LCRController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(405,'LCR.update','LCRController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(406,'LCR.update','LCRController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(407,'LCR.destroy','LCRController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(408,'Pages.about','PagesController.about',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',97),(409,'Pages.index','PagesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(410,'Pages.*','PagesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(411,'Pages.create','PagesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(412,'Pages.store','PagesController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(413,'Pages.show','PagesController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(414,'Pages.edit','PagesController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(415,'Pages.update','PagesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(416,'Pages.update','PagesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(417,'Pages.destroy','PagesController.destroy',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(418,'Pages.get','PagesController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(419,'Pages.missingMethod','PagesController.missingMethod',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(420,'AccountApproval.ajax_datagrid','AccountApprovalController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',106),(421,'AccountApproval.create','AccountApprovalController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',103),(422,'AccountApproval.update','AccountApprovalController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',104),(423,'AccountApproval.delete','AccountApprovalController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',105),(424,'AccountApproval.index','AccountApprovalController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',106),(425,'AccountApproval.*','AccountApprovalController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',102),(426,'Gateway.ajax_datagrid','GatewayController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',143),(427,'Gateway.create','GatewayController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',141),(428,'Gateway.update','GatewayController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',142),(429,'Gateway.ajax_load_gateway_dropdown','GatewayController.ajax_load_gateway_dropdown',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',143),(430,'Gateway.delete','GatewayController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',144),(431,'Gateway.test_connetion','GatewayController.test_connetion',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',143),(432,'Gateway.index','GatewayController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',143),(433,'Gateway.*','GatewayController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',140),(434,'Summary.index','SummaryController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(435,'Summary.*','SummaryController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',35),(436,'Summary.ajax_datagrid','SummaryController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(437,'Summary.list_accounts','SummaryController.list_accounts',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(438,'Summary.list_vendor','SummaryController.list_vendor',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(439,'Summary.summrybycountry','SummaryController.summrybycountry',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(440,'Summary.summrybycustomer','SummaryController.summrybycustomer',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(441,'Summary.temp_action','SummaryController.temp_action',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(442,'Summary.daily_sales_report','SummaryController.daily_sales_report',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(443,'Summary.daily_ajax_datagrid','SummaryController.daily_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',NULL),(444,'CronJob.index','CronJobController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',110),(445,'CronJob.*','CronJobController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',107),(446,'CronJob.ajax_datagrid','CronJobController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',110),(447,'CronJob.create','CronJobController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',108),(448,'CronJob.update','CronJobController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',109),(449,'CronJob.delete','CronJobController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',111),(450,'CronJob.ajax_load_cron_dropdown','CronJobController.ajax_load_cron_dropdown',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',110),(451,'CronJob.history','CronJobController.history',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',110),(452,'CronJob.history_ajax_datagrid','CronJobController.history_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',110),(453,'Companies.edit','CompaniesController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',95),(454,'Companies.update','CompaniesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',96),(455,'Payments.index','PaymentsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',49),(456,'Payments.*','PaymentsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',47),(457,'Payments.create','PaymentsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',48),(458,'Payments.update','PaymentsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',50),(459,'Payments.delete','PaymentsController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',1147),(460,'Payments.download_doc','PaymentsController.download_doc',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',49),(461,'Payments.ajax_datagrid','PaymentsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',49),(462,'Payments.getCurrency','PaymentsController.getCurrency',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',49),(463,'Payments.payment_approve_reject','PaymentsController.payment_approve_reject',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',49),(464,'Currencies.ajax_datagrid','CurrenciesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',83),(465,'Currencies.index','CurrenciesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',83),(466,'Currencies.*','CurrenciesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',80),(467,'Currencies.create','CurrenciesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',81),(468,'Currencies.update','CurrenciesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',82),(469,'Currencies.delete','CurrenciesController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',84),(470,'CurrencyConversion.ajax_datagrid','CurrencyConversionController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',1145),(471,'CurrencyConversion.index','CurrencyConversionController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',1145),(472,'CurrencyConversion.*','CurrencyConversionController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',85),(473,'CurrencyConversion.create','CurrencyConversionController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',87),(474,'CurrencyConversion.update','CurrencyConversionController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',86),(475,'CurrencyConversion.delete','CurrencyConversionController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',89),(476,'TaxRates.ajax_datagrid','TaxRatesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',65),(477,'TaxRates.index','TaxRatesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',65),(478,'TaxRates.*','TaxRatesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',62),(479,'TaxRates.create','TaxRatesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',63),(480,'TaxRates.update','TaxRatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',64),(481,'TaxRates.delete','TaxRatesController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',66),(482,'BillingSubscription.ajax_datagrid','BillingSubscriptionController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',44),(483,'BillingSubscription.index','BillingSubscriptionController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',44),(484,'BillingSubscription.*','BillingSubscriptionController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',42),(485,'BillingSubscription.create','BillingSubscriptionController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',43),(486,'BillingSubscription.update','BillingSubscriptionController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',45),(487,'BillingSubscription.delete','BillingSubscriptionController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',46),(488,'BillingSubscription.get','BillingSubscriptionController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',44),(489,'InvoiceTemplates.ajax_datagrid','InvoiceTemplatesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',60),(490,'InvoiceTemplates.index','InvoiceTemplatesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',60),(491,'InvoiceTemplates.*','InvoiceTemplatesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',57),(492,'InvoiceTemplates.create','InvoiceTemplatesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',58),(493,'InvoiceTemplates.delete','InvoiceTemplatesController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',61),(494,'InvoiceTemplates.view','InvoiceTemplatesController.view',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',60),(495,'InvoiceTemplates.update','InvoiceTemplatesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',59),(496,'InvoiceTemplates.print_preview','InvoiceTemplatesController.print_preview',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',60),(497,'InvoiceTemplates.pdf_download','InvoiceTemplatesController.pdf_download',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',60),(498,'InvoiceTemplates.get_logo','InvoiceTemplatesController.get_logo',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',60),(499,'CDR.index','CDRController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(500,'CDR.*','CDRController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',67),(501,'CDR.bulk_recal','CDRController.bulk_recal',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(502,'CDR.cdr_recal','CDRController.cdr_recal',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(503,'CDR.upload','CDRController.upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(504,'CDR.bulk_upload','CDRController.bulk_upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(505,'CDR.download_sample_excel_file','CDRController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(506,'CDR.get_accounts','CDRController.get_accounts',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',69),(507,'CDR.show','CDRController.show',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',69),(508,'CDR.ajax_datagrid','CDRController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',69),(509,'CDR.check_upload','CDRController.check_upload',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(510,'CDR.ajaxfilegrid','CDRController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(511,'CDR.storeTemplate','CDRController.storeTemplate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',68),(512,'Invoices.index','InvoicesController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(513,'Invoices.*','InvoicesController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',37),(514,'Invoices.create','InvoicesController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',36),(515,'Invoices.store','InvoicesController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',36),(516,'Invoices.bulk_send_invoice_mail','InvoicesController.bulk_send_invoice_mail',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',39),(517,'Invoices.invoice_regen','InvoicesController.invoice_regen',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',40),(518,'Invoices.edit','InvoicesController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(519,'Invoices.delete','InvoicesController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',NULL),(520,'Invoices.view','InvoicesController.view',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(521,'Invoices.update','InvoicesController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(522,'Invoices.invoice_preview','InvoicesController.invoice_preview',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(523,'Invoices.send','InvoicesController.send',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',39),(524,'Invoices.ajax_getEmailTemplate','InvoicesController.ajax_getEmailTemplate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(525,'Invoices.invoice_email','InvoicesController.invoice_email',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',39),(526,'Invoices.invoice_change_Status','InvoicesController.invoice_change_Status',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(527,'Invoices.downloadUsageFile','InvoicesController.downloadUsageFile',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(528,'TransactionLog.log','TransactionLogController.log',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(529,'TransactionLog.ajax_datagrid','TransactionLogController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(530,'Invoices.generate','InvoicesController.generate',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',40),(531,'Invoices.ajax_datagrid','InvoicesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(532,'Invoices.calculate_total','InvoicesController.calculate_total',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(533,'Invoices.getAccountInfo','InvoicesController.getAccountInfo',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',38),(534,'Invoices.bulk_invoice','InvoicesController.bulk_invoice',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(535,'Invoices.add_invoice_in','InvoicesController.add_invoice_in',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',36),(536,'Invoices.update_invoice_in','InvoicesController.update_invoice_in',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(537,'Invoices.download_doc_file','InvoicesController.download_doc_file',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',41),(538,'Products.index','ProductsController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',55),(539,'Products.*','ProductsController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',52),(540,'Products.create','ProductsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',53),(541,'Products.update','ProductsController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',54),(542,'Products.delete','ProductsController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',56),(543,'Products.ajax_datagrid','ProductsController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',55),(544,'Products.get','ProductsController.get',1,'Sumera Saeed',NULL,'2015-11-28 09:37:39.000','2015-11-28 09:37:39.000',55),(545,'BillingDashboard@invoice_expense_chart','BillingDashboard.invoice_expense_chart',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',9),(546,'BillingDashboard@invoice_expense_total','BillingDashboard.invoice_expense_total',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',9),(547,'AccountsPaymentProfile.create','AccountsPaymentProfileController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(548,'AccountsPaymentProfile.index','AccountsPaymentProfileController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(549,'AccountsPaymentProfile.*','AccountsPaymentProfileController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(550,'AccountsPaymentProfile.ajax_datagrid','AccountsPaymentProfileController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(551,'VendorFileUploadTemplate.index','VendorFileUploadTemplateController.index',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',118),(552,'VendorFileUploadTemplate.*','VendorFileUploadTemplateController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',114),(553,'VendorFileUploadTemplate.ajax_datagrid','VendorFileUploadTemplateController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',118),(554,'VendorFileUploadTemplate.ajaxfilegrid','VendorFileUploadTemplateController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',118),(555,'VendorFileUploadTemplate.create','VendorFileUploadTemplateController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',115),(556,'VendorFileUploadTemplate.edit','VendorFileUploadTemplateController.edit',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',116),(557,'VendorFileUploadTemplate.update','VendorFileUploadTemplateController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',116),(558,'VendorFileUploadTemplate.delete','VendorFileUploadTemplateController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',117),(559,'VendorFileUploadTemplate.store','VendorFileUploadTemplateController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',115),(560,'GlobalAdmins.select_company','GlobalAdminsController.select_company',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(561,'Users.get_users_dropdown','UsersController.get_users_dropdown',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(562,'Home.do_login_for_super_admin','HomeController.do_login_for_super_admin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(563,'Home.home','HomeController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(564,'HomeCustomer.home','HomeCustomerController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(565,'HomeCustomer.home','HomeCustomerController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(566,'HomeCustomer.dologin','HomeCustomerController.dologin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(567,'HomeCustomer.dologout','HomeCustomerController.dologout',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(568,'Home.home','HomeController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(569,'Home.dologin','HomeController.dologin',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(570,'Home.forgot_password','HomeController.forgot_password',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(571,'Home.doforgot_password','HomeController.doforgot_password',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(572,'Home.dologout','HomeController.dologout',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(573,'Home.registration','HomeController.registration',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(574,'Home.doRegistration','HomeController.doRegistration',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(575,'Home.home','HomeController.home',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(576,'Closure','Closure',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',NULL),(577,'Invoices.cview','InvoicesController.cview',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(578,'Invoices.cdownloadUsageFile','InvoicesController.cdownloadUsageFile',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(579,'Invoices.display_invoice','InvoicesController.display_invoice',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(580,'Invoices.download_invoice','InvoicesController.download_invoice',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(581,'Invoices.invoice_payment','InvoicesController.invoice_payment',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(582,'Invoices.pay_invoice','InvoicesController.pay_invoice',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(583,'Invoices.invoice_thanks','InvoicesController.invoice_thanks',1,'Sumera Saeed',NULL,'2015-11-28 09:37:40.000','2015-11-28 09:37:40.000',41),(587,'Home.process_redirect','HomeController.process_redirect',1,'Sumera Saeed',NULL,'2015-12-21 10:53:28.000','2015-12-21 10:53:28.000',NULL),(588,'Leads.lead_clone','LeadsController.lead_clone',1,'Sumera Saeed',NULL,'2015-12-21 10:53:28.000','2015-12-21 10:53:28.000',16),(589,'VendorRates.search_vendor_grid','VendorRatesController.search_vendor_grid',1,'Sumera Saeed',NULL,'2015-12-21 10:53:28.000','2015-12-21 10:53:28.000',NULL),(590,'CronJob.activecronjob','CronJobController.activecronjob',1,'Sumera Saeed',NULL,'2015-12-21 10:53:28.000','2015-12-21 10:53:28.000',112),(591,'CronJob.activecronjob_ajax_datagrid','CronJobController.activecronjob_ajax_datagrid',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',112),(592,'CronJob.activeprocessdelete','CronJobController.activeprocessdelete',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',113),(593,'TransactionLog.ajax_invoice_datagrid','TransactionLogController.ajax_invoice_datagrid',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',38),(594,'VendorProfiling.index','VendorProfilingController.index',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',NULL),(595,'VendorProfiling.*','VendorProfilingController.*',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',34),(596,'VendorProfiling.active_deactivate_vendor','VendorProfilingController.active_deactivate_vendor',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',NULL),(597,'VendorProfiling.ajax_datagrid','VendorProfilingController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',NULL),(598,'VendorProfiling.block_unblockcode','VendorProfilingController.block_unblockcode',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',NULL),(599,'Home.doreset_password','HomeController.doreset_password',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',NULL),(600,'Home.reset_password','HomeController.reset_password',1,'Sumera Saeed',NULL,'2015-12-21 10:53:29.000','2015-12-21 10:53:29.000',NULL),(601,'CurrencyConversion.ajax_datagrid_history','CurrencyConversionController.ajax_datagrid_history',1,'Sumera Saeed',NULL,'2015-12-21 16:11:47.000','2015-12-21 16:11:47.000',1145),(602,'CDR.rate_cdr','CDRController.rate_cdr',1,'Sumera Saeed',NULL,'2015-12-21 16:11:47.000','2015-12-21 16:11:47.000',68),(603,'Invoices.sageExport','InvoicesController.sageExport',1,'Sumera Saeed',NULL,'2015-12-21 16:11:47.000','2015-12-21 16:11:47.000',38),(604,'Invoices.getInvoiceDetail','InvoicesController.getInvoiceDetail',1,'Sumera Saeed',NULL,'2015-12-21 16:11:47.000','2015-12-21 16:11:47.000',38),(605,'VendorProfiling.ajax_vendor','VendorProfilingController.ajax_vendor',1,'Sumera Saeed',NULL,'2015-12-22 09:55:01.000','2015-12-22 09:55:01.000',NULL),(606,'Payments.getCurrency','PaymentsController.getCurrency',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',41),(607,'Payments.create','PaymentsController.create',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',41),(608,'CustomersRates.search_customer_grid','CustomersRatesController.search_customer_grid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',120),(609,'AccountSubscription.ajax_datagrid','AccountSubscriptionController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(610,'AccountSubscription.store','AccountSubscriptionController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(611,'AccountSubscription.update','AccountSubscriptionController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(613,'AccountSubscription.delete','AccountSubscriptionController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(614,'AccountOneOffCharge.ajax_datagrid','AccountOneOffChargeController.ajax_datagrid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(615,'AccountOneOffCharge.store','AccountOneOffChargeController.store',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(616,'AccountOneOffCharge.update','AccountOneOffChargeController.update',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(617,'AccountOneOffCharge.delete','AccountOneOffChargeController.delete',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(618,'AccountOneOffCharge.ajax_getProductInfo','AccountOneOffChargeController.ajax_getProductInfo',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',2),(619,'CustomersRates.search_customer_grid','CustomersRatesController.search_customer_grid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',37),(620,'CustomersRates.search_customer_grid','CustomersRatesController.search_customer_grid',1,'Sumera Saeed',NULL,'2015-11-28 09:37:36.000','2015-11-28 09:37:36.000',38),(621,'Payments.getCurrency','PaymentsController.getCurrency',1,'Sumera Saeed',NULL,'2015-11-28 09:37:38.000','2015-11-28 09:37:38.000',37),(622,'Accounts.bulk_mail','AccountsController.bulk_mail',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',1143),(623,'Trunk.getAllowedActions','TrunkController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(624,'CodeDecks.getAllowedActions','CodeDecksController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(625,'Accounts.getAllowedActions','AccountsController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(626,'CustomersRates.getAllowedActions','CustomersRatesController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(627,'VendorBlockings.getAllowedActions','VendorBlockingsController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(628,'VendorRates.getAllowedActions','VendorRatesController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(629,'Jobs.activejob','JobsController.activejob',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(630,'Jobs.jobactive_ajax_datagrid','JobsController.jobactive_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(631,'Jobs.activeprocessdelete','JobsController.activeprocessdelete',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(632,'Jobs.getAllowedActions','JobsController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(633,'RateGenerators.getAllowedActions','RateGeneratorsController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(634,'RateTables.getAllowedActions','RateTablesController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(635,'Pages.getAllowedActions','PagesController.getAllowedActions',1,'Sumera Saeed',NULL,'2016-01-07 12:21:00.000','2016-01-07 12:21:00.000',NULL),(636,'VendorBlockings.blockbycountry','VendorBlockingsController.blockbycountry',1,'Sumera Saeed',NULL,'2016-01-17 18:33:31.000','2016-01-17 18:33:31.000',NULL),(637,'VendorBlockings.blockbycode','VendorBlockingsController.blockbycode',1,'Sumera Saeed',NULL,'2016-01-17 18:33:31.000','2016-01-17 18:33:31.000',NULL),(638,'VendorRates.clear_all_vendorrate','VendorRatesController.clear_all_vendorrate',1,'Sumera Saeed',NULL,'2016-01-17 18:33:31.000','2016-01-17 18:33:31.000',129),(639,'Dashboard.ajax_get_recent_due_sheets','DashboardController.ajax_get_recent_due_sheets',1,'Sumera Saeed',NULL,'2016-01-24 17:23:32.000','2016-01-24 17:23:32.000',7),(640,'Dashboard.ajax_get_recent_leads','DashboardController.ajax_get_recent_leads',1,'Sumera Saeed',NULL,'2016-01-24 17:23:32.000','2016-01-24 17:23:32.000',7),(641,'Dashboard.ajax_get_jobs','DashboardController.ajax_get_jobs',1,'Sumera Saeed',NULL,'2016-01-24 17:23:32.000','2016-01-24 17:23:32.000',7),(642,'Dashboard.ajax_get_processed_files','DashboardController.ajax_get_processed_files',1,'Sumera Saeed',NULL,'2016-01-24 17:23:32.000','2016-01-24 17:23:32.000',7),(643,'Dashboard.ajax_get_recent_accounts','DashboardController.ajax_get_recent_accounts',1,'Sumera Saeed',NULL,'2016-01-24 17:23:32.000','2016-01-24 17:23:32.000',1201),(644,'Dashboard.ajax_get_missing_accounts','DashboardController.ajax_get_missing_accounts',1,'Sumera Saeed',NULL,'2016-01-24 17:23:32.000','2016-01-24 17:23:32.000',1247),(645,'Wysihtml5.getfiles','Wysihtml5Controller.getfiles',1,'Sumera Saeed',NULL,'2016-01-24 17:23:33.000','2016-01-24 17:23:33.000',NULL),(646,'Wysihtml5.file_upload','Wysihtml5Controller.file_upload',1,'Sumera Saeed',NULL,'2016-01-24 17:23:33.000','2016-01-24 17:23:33.000',NULL),(653,'Authentication.authenticate','AuthenticationController.authenticate',1,'Khurram Saeed',NULL,'2016-02-04 13:12:34.000','2016-02-04 13:12:34.000',152),(654,'Authentication.authenticate_store','AuthenticationController.authenticate_store',1,'Khurram Saeed',NULL,'2016-02-04 13:12:34.000','2016-02-04 13:12:34.000',153),(1639,'AccountActivity.*','AccountActivityController.*',1,'Sumera Saeed',NULL,'2015-11-28 09:37:35.000','2015-11-28 09:37:35.000',5),(1640,'RateTables.download_sample_excel_file','RateTablesController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2016-02-10 11:28:04.000','2016-02-10 11:28:04.000',NULL),(1641,'RateTables.upload','RateTablesController.upload',1,'Sumera Saeed',NULL,'2016-02-10 11:28:04.000','2016-02-10 11:28:04.000',NULL),(1642,'RateTables.check_upload','RateTablesController.check_upload',1,'Sumera Saeed',NULL,'2016-02-10 11:28:04.000','2016-02-10 11:28:04.000',NULL),(1643,'RateTables.ajaxfilegrid','RateTablesController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2016-02-10 11:28:04.000','2016-02-10 11:28:04.000',NULL),(1644,'RateTables.storeTemplate','RateTablesController.storeTemplate',1,'Sumera Saeed',NULL,'2016-02-10 11:28:04.000','2016-02-10 11:28:04.000',NULL),(1645,'Payments.upload','PaymentsController.upload',1,'Sumera Saeed',NULL,'2016-02-10 11:28:05.000','2016-02-10 11:28:05.000',48),(1646,'Payments.download_sample_excel_file','PaymentsController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2016-02-10 11:28:05.000','2016-02-10 11:28:05.000',48),(1647,'Payments.recall','PaymentsController.recall',1,'Sumera Saeed',NULL,'2016-02-10 11:28:05.000','2016-02-10 11:28:05.000',1148),(1648,'Payments.check_upload','PaymentsController.check_upload',1,'Sumera Saeed',NULL,'2016-02-11 16:21:36.000','2016-02-11 16:21:36.000',48),(1649,'Payments.ajaxfilegrid','PaymentsController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2016-02-11 16:21:36.000','2016-02-11 16:21:36.000',48),(1650,'Accounts.update_inbound_rate_table','AccountsController.update_inbound_rate_table',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1651,'Payments.validate_column_mapping','PaymentsController.validate_column_mapping',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',48),(1652,'Payments.confirm_bulk_upload','PaymentsController.confirm_bulk_upload',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',48),(1653,'CDR.vendorcdr_show','CDRController.vendorcdr_show',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1654,'CDR.ajax_datagrid_vendorcdr','CDRController.ajax_datagrid_vendorcdr',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1655,'CDR.vendorcdr_upload','CDRController.vendorcdr_upload',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1656,'CDR.check_vendorupload','CDRController.check_vendorupload',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1657,'CDR.storeVendorTemplate','CDRController.storeVendorTemplate',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1658,'BillingDashboard@ajax_top_pincode','BillingDashboard.ajax_top_pincode',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',1249),(1659,'BillingDashboard@ajaxgrid_top_pincode','BillingDashboard.ajaxgrid_top_pincode',1,'Sumera Saeed',NULL,'2016-02-23 06:49:53.000','2016-02-23 06:49:53.000',NULL),(1660,'Role.showcategory','RoleController.showcategory',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1661,'Role.storecategory','RoleController.storecategory',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1662,'Role.categoryupdate','RoleController.categoryupdate',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1663,'Role.ajax_action_list','RoleController.ajax_action_list',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1664,'Role.skippermissionAction','RoleController.skippermissionAction',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1665,'Role.storpermissionaction','RoleController.storpermissionaction',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1666,'Home.*','HomeController.*',1,'Sumera Saeed',NULL,'2016-03-14 11:11:29.000','2016-03-14 11:11:29.000',NULL),(1667,'RateTables.getCodeByAjax','RateTablesController.getCodeByAjax',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1668,'Estimates.index','EstimatesController.index',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1669,'Estimates.*','EstimatesController.*',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1192),(1670,'Estimates.create','EstimatesController.create',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1188),(1671,'Estimates.store','EstimatesController.store',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1188),(1672,'Estimates.bulk_send_estimate_mail','EstimatesController.bulk_send_estimate_mail',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1673,'Estimates.estimate_regen','EstimatesController.estimate_regen',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1674,'Estimates.edit','EstimatesController.edit',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1189),(1675,'Estimates.delete','EstimatesController.delete',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1190),(1676,'Estimates.view','EstimatesController.view',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1677,'Estimates.update','EstimatesController.update',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1189),(1678,'Estimates.estimate_preview','EstimatesController.estimate_preview',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1679,'Estimates.send','EstimatesController.send',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1680,'Estimates.ajax_getEmailTemplate','EstimatesController.ajax_getEmailTemplate',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1681,'Estimates.estimate_email','EstimatesController.estimate_email',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1682,'Estimates.estimate_change_Status','EstimatesController.estimate_change_Status',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1189),(1683,'Estimates.estimate_change_Status_Bulk','EstimatesController.estimate_change_Status_Bulk',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1189),(1684,'Estimates.delete_bulk','EstimatesController.delete_bulk',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1190),(1685,'Estimates.downloadUsageFile','EstimatesController.downloadUsageFile',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1686,'TransactionLog.ajax_estimate_datagrid','TransactionLogController.ajax_estimate_datagrid',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1687,'Estimates.generate','EstimatesController.generate',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1688,'Estimates.ajax_datagrid','EstimatesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1689,'Estimates.ajax_datagrid_total','EstimatesController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1690,'Estimates.calculate_total','EstimatesController.calculate_total',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1188),(1691,'Estimates.getAccountInfo','EstimatesController.getAccountInfo',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1692,'Estimates.bulk_estimate','EstimatesController.bulk_estimate',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1693,'Estimates.add_estimate_in','EstimatesController.add_estimate_in',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1188),(1694,'Estimates.update_estimate_in','EstimatesController.update_estimate_in',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1189),(1695,'Estimates.download_doc_file','EstimatesController.download_doc_file',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1696,'Estimates.sageExport','EstimatesController.sageExport',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1697,'Estimates.getEstimateDetail','EstimatesController.getEstimateDetail',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',1191),(1698,'Invoices.ajax_datagrid_total','InvoicesController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',38),(1699,'Themes.index','ThemesController.index',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1700,'Themes.*','ThemesController.*',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1701,'Themes.create','ThemesController.create',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1702,'Themes.store','ThemesController.store',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1703,'Themes.bulk_send_estimate_mail','ThemesController.bulk_send_estimate_mail',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1704,'Themes.estimate_regen','ThemesController.estimate_regen',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1705,'Themes.edit','ThemesController.edit',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1706,'Themes.delete','ThemesController.delete',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1707,'Themes.view','ThemesController.view',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1708,'Themes.update','ThemesController.update',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1709,'Themes.ajax_datagrid','ThemesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1710,'Themes.themes_change_Status','ThemesController.themes_change_Status',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1711,'Themes.delete_bulk','ThemesController.delete_bulk',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1712,'Estimates.cview','EstimatesController.cview',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1713,'Estimates.display_estimate','EstimatesController.display_estimate',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1714,'Estimates.convert_estimate','EstimatesController.convert_estimate',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1715,'Estimates.download_estimate','EstimatesController.download_estimate',1,'Sumera Saeed',NULL,'2016-04-07 21:07:17.000','2016-04-07 21:07:17.000',NULL),(1716,'CustomersRates.customerdownloadtype','CustomersRatesController.customerdownloadtype',1,'Sumera Saeed',NULL,'2016-04-22 12:33:16.000','2016-04-22 12:33:16.000',NULL),(1717,'VendorRates.vendordownloadtype','VendorRatesController.vendordownloadtype',1,'Sumera Saeed',NULL,'2016-04-22 12:33:16.000','2016-04-22 12:33:16.000',NULL),(1718,'InvoicesCustomer.download_invoice_file','InvoicesCustomerController.download_invoice_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1719,'InvoicesCustomer.ajax_datagrid_total','InvoicesCustomerController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1720,'InvoicesCustomer.getInvoiceDetail','InvoicesCustomerController.getInvoiceDetail',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1721,'PaymentsCustomer.ajax_datagrid_total','PaymentsCustomerController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1722,'CDRCustomer.index','CDRCustomerController.index',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1723,'CDRCustomer.*','CDRCustomerController.*',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1724,'CDRCustomer.ajax_datagrid','CDRCustomerController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1725,'CDRCustomer.ajax_datagrid_total','CDRCustomerController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1726,'RateCustomer.settings','RateCustomerController.settings',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1727,'RateCustomer.search_ajax_datagrid','RateCustomerController.search_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1728,'RateCustomer.index','RateCustomerController.index',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1729,'RateCustomer.*','RateCustomerController.*',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1730,'RateCustomer.inboundrate','RateCustomerController.inboundrate',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1731,'RateCustomer.search_inbound_ajax_datagrid','RateCustomerController.search_inbound_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1732,'Accounts.GetTimeLineSrollData','AccountsController.GetTimeLineSrollData',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1733,'Task.create','TaskController.create',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',1156),(1734,'Accounts.upload_file','AccountsController.upload_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',4),(1735,'Accounts.delete_upload_file','AccountsController.delete_upload_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',4),(1736,'Accounts.Delete_task_parent','AccountsController.Delete_task_parent',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',4),(1737,'Accounts.createOpportunity','AccountsController.createOpportunity',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',4),(1738,'AccountActivity.sendMailApi','AccountActivityController.sendMailApi',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',4),(1739,'Imports.index','ImportsController.index',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1740,'Imports.*','ImportsController.*',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1741,'Imports.check_upload','ImportsController.check_upload',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1742,'Imports.ajaxfilegrid','ImportsController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:43.000','2016-05-19 19:22:43.000',NULL),(1743,'Imports.storeTemplate','ImportsController.storeTemplate',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1744,'Imports.getAccountInfoFromGateway','ImportsController.getAccountInfoFromGateway',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1745,'Imports.ajax_get_missing_gatewayaccounts','ImportsController.ajax_get_missing_gatewayaccounts',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1746,'Imports.download_sample_excel_file','ImportsController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1747,'Imports.add_missing_gatewayaccounts','ImportsController.add_missing_gatewayaccounts',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1748,'Imports.import_leads','ImportsController.import_leads',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1749,'Imports.leads_check_upload','ImportsController.leads_check_upload',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1750,'Imports.leads_ajaxfilegrid','ImportsController.leads_ajaxfilegrid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1751,'Imports.leads_storeTemplate','ImportsController.leads_storeTemplate',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1752,'Imports.leads_download_sample_excel_file','ImportsController.leads_download_sample_excel_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1753,'Leads.createOpportunity','LeadsController.createOpportunity',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1754,'Payments.get_currency_invoice_numbers','PaymentsController.get_currency_invoice_numbers',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1755,'Invoices.invoice_in_reconcile','InvoicesController.invoice_in_reconcile',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',NULL),(1756,'OpportunityBoard.index','OpportunityBoardController.index',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1757,'OpportunityBoard.*','OpportunityBoardController.*',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1165),(1758,'OpportunityBoard.create','OpportunityBoardController.create',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1163),(1759,'OpportunityBoard.configure','OpportunityBoardController.configure',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1760,'OpportunityBoard.manage','OpportunityBoardController.manage',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1761,'OpportunityBoard.update','OpportunityBoardController.update',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1164),(1762,'OpportunityBoard.delete','OpportunityBoardController.delete',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1763,'OpportunityBoard.ajax_datagrid','OpportunityBoardController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1165),(1764,'OpportunityBoardColumn.index','OpportunityBoardColumnController.index',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1765,'OpportunityBoardColumn.*','OpportunityBoardColumnController.*',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1766,'OpportunityBoardColumn.create','OpportunityBoardColumnController.create',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1767,'OpportunityBoardColumn.update','OpportunityBoardColumnController.update',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1768,'OpportunityBoardColumn.delete','OpportunityBoardColumnController.delete',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1769,'OpportunityBoardColumn.ajax_datacolumn','OpportunityBoardColumnController.ajax_datacolumn',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1770,'OpportunityBoardColumn.updateColumnOrder','OpportunityBoardColumnController.updateColumnOrder',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1166),(1771,'Opportunity.create','OpportunityController.create',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1149),(1772,'Opportunity.saveattachment','OpportunityController.saveattachment',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1773,'Opportunity.getLead','OpportunityController.getLead',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1774,'Opportunity.getDropdownLeadAccount','OpportunityController.getDropdownLeadAccount',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1775,'Opportunity.getopportunity','OpportunityController.getopportunity',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1776,'Opportunity.update','OpportunityController.update',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1150),(1777,'Opportunity.deleteAttachment','OpportunityController.deleteAttachment',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1179),(1778,'Opportunity.updateColumnOrder','OpportunityController.updateColumnOrder',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1150),(1779,'Opportunity.ajax_opportunity','OpportunityController.ajax_opportunity',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1780,'Opportunity.ajax_getattachments','OpportunityController.ajax_getattachments',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1159),(1781,'Opportunity.updateTaggedUser','OpportunityController.updateTaggedUser',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1150),(1782,'Opportunity.upload_file','OpportunityController.upload_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1153),(1783,'Opportunity.delete_upload_file','OpportunityController.delete_upload_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1784,'OpportunityComments.create','OpportunityCommentsController.create',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1785,'OpportunityComments.ajax_opportunityComments','OpportunityCommentsController.ajax_opportunityComments',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1151),(1786,'Task.manage','TaskController.manage',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1787,'Task.saveattachment','TaskController.saveattachment',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1161),(1788,'Task.getLead','TaskController.getLead',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1789,'Task.getDropdownLeadAccount','TaskController.getDropdownLeadAccount',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1790,'Task.getopportunity','TaskController.getopportunity',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1791,'Task.update','TaskController.update',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1157),(1792,'Task.deleteAttachment','TaskController.deleteAttachment',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1187),(1793,'Task.updateColumnOrder','TaskController.updateColumnOrder',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1157),(1794,'Task.ajax_task_board','TaskController.ajax_task_board',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1795,'Task.ajax_task_grid','TaskController.ajax_task_grid',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1796,'Task.ajax_getattachments','TaskController.ajax_getattachments',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1162),(1797,'Task.updateTaggedUser','TaskController.updateTaggedUser',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1157),(1798,'Task.upload_file','TaskController.upload_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1161),(1799,'Task.delete_upload_file','TaskController.delete_upload_file',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1800,'TaskComments.create','TaskCommentsController.create',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1156),(1801,'TaskComments.ajax_taskComments','TaskCommentsController.ajax_taskComments',1,'Sumera Saeed',NULL,'2016-05-19 19:22:44.000','2016-05-19 19:22:44.000',1158),(1812,'Currencies.exports','CurrenciesController.exports',1,'Sumera Saeed',NULL,'2016-05-23 14:14:18.000','2016-05-23 14:14:18.000',83),(1813,'DashboardCustomer.monitor_dashboard','DashboardCustomerController.monitor_dashboard',1,'Sumera Saeed',NULL,'2016-05-25 11:40:13.000','2016-05-25 11:40:13.000',1177),(1814,'Analysis.customer_index','AnalysisController.customer_index',1,'Sumera Saeed',NULL,'2016-05-25 11:40:13.000','2016-05-25 11:40:13.000',NULL),(1815,'Analysis.vendor_index','AnalysisController.vendor_index',1,'Sumera Saeed',NULL,'2016-05-25 11:40:13.000','2016-05-25 11:40:13.000',NULL),(1816,'Dashboard.monitor_dashboard','DashboardController.monitor_dashboard',1,'Sumera Saeed',NULL,'2016-05-25 11:40:13.000','2016-05-25 11:40:13.000',1177),(1817,'ChartDashboard.getHourlyData','ChartDashboardController.getHourlyData',1,'Sumera Saeed',NULL,'2016-05-25 11:40:13.000','2016-05-25 11:40:13.000',1177),(1818,'ChartDashboard.getReportData','ChartDashboardController.getReportData',1,'Sumera Saeed',NULL,'2016-05-25 11:40:13.000','2016-05-25 11:40:13.000',1177),(1819,'Analysis.index','AnalysisController.index',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',1171),(1820,'Analysis.*','AnalysisController.*',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',1171),(1821,'Analysis.ajax_datagrid','AnalysisController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',NULL),(1822,'Analysis.getAnalysisData','AnalysisController.getAnalysisData',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',NULL),(1823,'Analysis.getAnalysisBarData','AnalysisController.getAnalysisBarData',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',NULL),(1824,'VendorAnalysis.index','VendorAnalysisController.index',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',1171),(1825,'VendorAnalysis.*','VendorAnalysisController.*',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',1171),(1826,'VendorAnalysis.ajax_datagrid','VendorAnalysisController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',NULL),(1827,'VendorAnalysis.getAnalysisData','VendorAnalysisController.getAnalysisData',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',NULL),(1828,'VendorAnalysis.getAnalysisBarData','VendorAnalysisController.getAnalysisBarData',1,'Sumera Saeed',NULL,'2016-05-25 11:40:14.000','2016-05-25 11:40:14.000',NULL),(1829,'Accounts.UpdateBulkAccountStatus','AccountsController.UpdateBulkAccountStatus',1,'Sumera Saeed',NULL,'2016-06-01 12:11:39.000','2016-06-01 12:11:39.000',NULL),(1830,'Payments.ajax_datagrid_total','PaymentsController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-06-01 12:11:40.000','2016-06-01 12:11:40.000',49),(1831,'CDR.ajax_datagrid_total','CDRController.ajax_datagrid_total',1,'Sumera Saeed',NULL,'2016-06-01 12:11:40.000','2016-06-01 12:11:40.000',69),(1832,'CDR.ajax_datagrid_vendorcdr_total','CDRController.ajax_datagrid_vendorcdr_total',1,'Sumera Saeed',NULL,'2016-06-01 12:11:40.000','2016-06-01 12:11:40.000',NULL),(1833,'Payments.get_currency_invoice_numbers','PaymentsController.get_currency_invoice_numbers',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1172),(1834,'Dispute.index','DisputeController.index',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1176),(1835,'Dispute.*','DisputeController.*',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1172),(1836,'Dispute.ajax_datagrid','DisputeController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1176),(1837,'Dispute.delete','DisputeController.delete',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1174),(1838,'Dispute.update','DisputeController.update',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1174),(1839,'Dispute.create','DisputeController.create',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1173),(1840,'Dispute.change_status','DisputeController.change_status',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1175),(1841,'Dispute.download_attachment','DisputeController.download_attachment',1,'Sumera Saeed',NULL,'2016-05-23 14:46:02.000','2016-05-23 14:46:02.000',1176),(1842,'Dispute.view','DisputeController.view',1,'Sumera Saeed',NULL,'2016-05-23 14:46:02.000','2016-05-23 14:46:02.000',1176),(1843,'Payments.get_currency_invoice_numbers','PaymentsController.get_currency_invoice_numbers',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1173),(1844,'Payments.get_currency_invoice_numbers','PaymentsController.get_currency_invoice_numbers',1,'Sumera Saeed',NULL,'2016-05-23 14:46:01.000','2016-05-23 14:46:01.000',1174),(1845,'Dispute.reconcile','DisputeController.reconcile',1,'Sumera Saeed',NULL,'2016-06-06 09:49:30.000','2016-06-06 09:49:30.000',NULL),(1846,'CDR.delete_customer_cdr','CDRController.delete_customer_cdr',1,'Sumera Saeed',NULL,'2016-06-10 10:35:37.000','2016-06-10 10:35:37.000',1180),(1847,'CDR.delete_vendor_cdr','CDRController.delete_vendor_cdr',1,'Sumera Saeed',NULL,'2016-06-10 10:35:37.000','2016-06-10 10:35:37.000',1180),(1848,'Accounts.expense','AccountsController.expense',1,'Sumera Saeed',NULL,'2016-06-20 14:47:30.000','2016-06-20 14:47:30.000',1181),(1849,'Accounts.expense_chart','AccountsController.expense_chart',1,'Sumera Saeed',NULL,'2016-06-20 14:47:30.000','2016-06-20 14:47:30.000',1181),(1850,'Accounts.expense_top_destination','AccountsController.expense_top_destination',1,'Sumera Saeed',NULL,'2016-06-20 14:47:30.000','2016-06-20 14:47:30.000',1181),(1851,'DialString.index','DialStringController.index',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1183),(1852,'DialString.*','DialStringController.*',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1182),(1853,'DialString.dialstring_datagrid','DialStringController.dialstring_datagrid',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1183),(1854,'DialString.exports','DialStringController.exports',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1183),(1855,'DialString.create_dialstring','DialStringController.create_dialstring',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1184),(1856,'DialString.update_dialstring','DialStringController.update_dialstring',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1185),(1857,'DialString.delete_dialstring','DialStringController.delete_dialstring',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1186),(1858,'DialString.dialstringcode','DialStringController.dialstringcode',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1183),(1859,'DialString.ajax_datagrid','DialStringController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1183),(1860,'DialString.store','DialStringController.store',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1184),(1861,'DialString.update','DialStringController.update',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1185),(1862,'DialString.deletecode','DialStringController.deletecode',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1186),(1863,'DialString.update_selected','DialStringController.update_selected',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1185),(1864,'DialString.delete_selected','DialStringController.delete_selected',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1186),(1865,'DialString.upload','DialStringController.upload',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1187),(1866,'DialString.check_upload','DialStringController.check_upload',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1187),(1867,'DialString.ajaxfilegrid','DialStringController.ajaxfilegrid',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1187),(1868,'DialString.storeTemplate','DialStringController.storeTemplate',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1187),(1869,'DialString.download_sample_excel_file','DialStringController.download_sample_excel_file',1,'Sumera Saeed',NULL,'2016-06-22 06:36:11.000','2016-06-22 06:36:11.000',1183),(1870,'CronJob.cronjob_monitor','CronJobController.cronjob_monitor',1,'Sumera Saeed',NULL,'2016-06-22 12:55:28.000','2016-06-22 12:55:28.000',NULL),(1871,'DashboardCustomer.subscriptions','DashboardCustomerController.subscriptions',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',NULL),(1872,'DashboardCustomer.subscriptions_ajax_datagrid','DashboardCustomerController.subscriptions_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',NULL),(1875,'Task.GetTask','TaskController.GetTask',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',1158),(1876,'Task.delete_task','TaskController.delete_task',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',NULL),(1877,'Accounts.get_note','AccountsController.get_note',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',NULL),(1878,'Accounts.update_note','AccountsController.update_note',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',NULL),(1879,'Authentication.addIps','AuthenticationController.addIps',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',1193),(1880,'Authentication.deleteips','AuthenticationController.deleteips',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',1196),(1881,'Accounts.addclis','AccountsController.addclis',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',1195),(1882,'Accounts.delete_clis','AccountsController.delete_clis',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',1196),(1883,'AccountActivity.getAttachment','AccountActivityController.getAttachment',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',4),(1884,'Accounts.deleteUploadFile','AccountsController.deleteUploadFile',1,'Sumera Saeed',NULL,'2016-06-28 15:01:08.000','2016-06-28 15:01:08.000',4),(1885,'CronJob.trigger','CronJobController.trigger',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1886,'CronJob.terminate','CronJobController.terminate',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1887,'CronJob.change_status','CronJobController.change_status',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1888,'Companies.ValidateSmtp','CompaniesController.ValidateSmtp',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1889,'BillingSubscription.getSubscriptionData_ajax','BillingSubscriptionController.getSubscriptionData_ajax',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1890,'Opportunity.getAttachment','OpportunityController.getAttachment',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',1153),(1891,'Opportunity.uploadFile','OpportunityController.uploadFile',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1892,'Opportunity.deleteUploadFile','OpportunityController.deleteUploadFile',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',NULL),(1893,'OpportunityComments.getAttachment','OpportunityCommentsController.getAttachment',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',1153),(1894,'Task.getAttachment','TaskController.getAttachment',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',1160),(1895,'TaskComments.getAttachment','TaskCommentsController.getAttachment',1,'Sumera Saeed',NULL,'2016-06-28 15:01:09.000','2016-06-28 15:01:09.000',1160),(1896,'Accounts.get_credit','AccountsController.get_credit',1,'Sumera Saeed',NULL,'2016-07-12 11:23:50.000','2016-07-12 11:23:50.000',1199),(1897,'Accounts.update_credit','AccountsController.update_credit',1,'Sumera Saeed',NULL,'2016-07-12 11:23:50.000','2016-07-12 11:23:50.000',1200),(1898,'Accounts.ajax_datagrid_credit','AccountsController.ajax_datagrid_credit',1,'Sumera Saeed',NULL,'2016-07-12 11:23:50.000','2016-07-12 11:23:50.000',1199),(1899,'Accounts.unbilledreport','AccountsController.unbilledreport',1,'Sumera Saeed',NULL,'2016-07-12 11:23:50.000','2016-07-12 11:23:50.000',NULL),(1900,'Jobs.restart','JobsController.restart',1,'Sumera Saeed',NULL,'2016-07-12 11:23:50.000','2016-07-12 11:23:50.000',NULL),(1901,'Jobs.terminate','JobsController.terminate',1,'Sumera Saeed',NULL,'2016-07-12 11:23:50.000','2016-07-12 11:23:50.000',NULL),(1902,'Accounts.activity_pdf_download','AccountsController.activity_pdf_download',1,'Sumera Saeed',NULL,'2016-07-15 10:53:22.000','2016-07-15 10:53:22.000',NULL),(1903,'Jobs.cancel','JobsController.cancel',1,'Sumera Saeed',NULL,'2016-07-15 10:53:22.000','2016-07-15 10:53:22.000',NULL),(1904,'CronJob.change_crontab_status','CronJobController.change_crontab_status',1,'Sumera Saeed',NULL,'2016-07-15 10:53:22.000','2016-07-15 10:53:22.000',NULL),(1905,'Dashboard.GetUsersTasks','DashboardController.GetUsersTasks',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',1206),(1906,'Dashboard.GetPipleLineData','DashboardController.GetPipleLineData',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',1202),(1907,'Dashboard.GetForecastData','DashboardController.GetForecastData',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',1203),(1908,'Dashboard.CrmDashboard','DashboardController.CrmDashboard',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',1197),(1909,'Authentication.addclis','AuthenticationController.addclis',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',NULL),(1910,'Authentication.deleteclis','AuthenticationController.deleteclis',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',NULL),(1911,'Opportunity.ajax_grid','OpportunityController.ajax_grid',1,'Sumera Saeed',NULL,'2016-07-16 15:42:10.000','2016-07-16 15:42:10.000',1151),(1912,'Accounts.uploadFile','AccountsController.uploadFile',1,'Sumera Saeed',NULL,'2016-07-21 13:00:46.000','2016-07-21 13:00:46.000',NULL),(1913,'Authentication.addipclis','AuthenticationController.addipclis',1,'Sumera Saeed',NULL,'2016-07-21 13:00:46.000','2016-07-21 13:00:46.000',1193),(1914,'Dashboard.getSalesdata','DashboardController.getSalesdata',1,'Sumera Saeed',NULL,'2016-07-27 15:05:32.000','2016-07-27 15:05:32.000',1205),(1915,'Dashboard.CrmDashboardSalesRevenue','DashboardController.CrmDashboardSalesRevenue',1,'Sumera Saeed',NULL,'2016-07-27 15:05:32.000','2016-07-27 15:05:32.000',1198),(1916,'Dashboard.GetOpportunites','DashboardController.GetOpportunites',1,'Sumera Saeed',NULL,'2016-07-27 15:05:32.000','2016-07-27 15:05:32.000',1204),(1917,'DashboardCustomer.ajax_datagrid_Invoice_Expense','DashboardCustomerController.ajax_datagrid_Invoice_Expense',1,'Sumera Saeed',NULL,'2016-08-19 11:53:50.000','2016-08-19 11:53:50.000',NULL),(1918,'RateGenerators.ajax_existing_ratetable_cronjob','RateGeneratorsController.ajax_existing_ratetable_cronjob',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',NULL),(1919,'RateGenerators.deleteCronJob','RateGeneratorsController.deleteCronJob',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1215),(1920,'Invoices.download_attachment','InvoicesController.download_attachment',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',NULL),(1921,'BillingDashboard@ajax_datagrid_Invoice_Expense','BillingDashboard.ajax_datagrid_Invoice_Expense',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',NULL),(1922,'Notification.index','NotificationController.index',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1210),(1923,'Notification.*','NotificationController.*',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1228),(1924,'Notification.ajax_datagrid','NotificationController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1210),(1925,'Notification.store','NotificationController.store',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1207),(1926,'Notification.update','NotificationController.update',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1208),(1927,'Notification.delete','NotificationController.delete',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1209),(1928,'ServerInfo.index','ServerInfoController.index',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1214),(1929,'ServerInfo.*','ServerInfoController.*',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1229),(1930,'ServerInfo.ajax_getdata','ServerInfoController.ajax_getdata',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1214),(1931,'ServerInfo.store','ServerInfoController.store',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1211),(1932,'ServerInfo.update','ServerInfoController.update',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1212),(1933,'ServerInfo.delete','ServerInfoController.delete',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',1213),(1934,'Retention.index','RetentionController.index',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',NULL),(1935,'Retention.*','RetentionController.*',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',NULL),(1936,'Retention.create','RetentionController.create',1,'Sumera Saeed',NULL,'2016-08-19 11:53:51.000','2016-08-19 11:53:51.000',NULL),(1937,'Users.view_tracker','UsersController.view_tracker',1,'Sumera Saeed',NULL,'2016-08-20 11:53:14.000','2016-08-20 11:53:14.000',NULL),(1938,'RateGenerators.ajax_existing_rategenerator_cronjob','RateGeneratorsController.ajax_existing_rategenerator_cronjob',1,'Sumera Saeed',NULL,'2016-08-30 07:01:05.000','2016-08-30 07:01:05.000',NULL),(1939,'Dashboard.GetRevenueDrillDown','DashboardController.GetRevenueDrillDown',1,'Sumera Saeed',NULL,'2016-08-31 15:52:39.000','2016-08-31 15:52:39.000',1198),(1940,'Accounts.AjaxConversations','AccountsController.AjaxConversations',1,'Sumera Saeed',NULL,'2016-08-31 15:52:39.000','2016-08-31 15:52:39.000',NULL),(1941,'Integration.index','IntegrationController.index',1,'Sumera Saeed',NULL,'2016-08-31 15:52:39.000','2016-08-31 15:52:39.000',1216),(1942,'Integration.*','IntegrationController.*',1,'Sumera Saeed',NULL,'2016-08-31 15:52:39.000','2016-08-31 15:52:39.000',NULL),(1943,'Integration.Update','IntegrationController.Update',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',NULL),(1944,'Gateway.ajax_existing_gateway_cronjob','GatewayController.ajax_existing_gateway_cronjob',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',144),(1945,'Gateway.deleteCronJob','GatewayController.deleteCronJob',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',144),(1946,'DestinationGroup.index','DestinationGroupController.index',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1217),(1947,'DestinationGroup.*','DestinationGroupController.*',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1220),(1948,'DestinationGroup.ajax_datagrid','DestinationGroupController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1217),(1949,'DestinationGroup.store','DestinationGroupController.store',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1219),(1950,'DestinationGroup.update','DestinationGroupController.update',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1219),(1951,'DestinationGroup.delete','DestinationGroupController.delete',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1218),(1952,'DestinationGroup.show','DestinationGroupController.show',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1217),(1953,'DestinationGroup.group_ajax_datagrid','DestinationGroupController.group_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1217),(1954,'DestinationGroup.group_store','DestinationGroupController.group_store',1,'Sumera Saeed',NULL,'2016-08-31 15:52:40.000','2016-08-31 15:52:40.000',1219),(1955,'DestinationGroup.group_update','DestinationGroupController.group_update',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1219),(1956,'DestinationGroup.update_name','DestinationGroupController.update_name',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1219),(1957,'DestinationGroup.group_delete','DestinationGroupController.group_delete',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1218),(1958,'DestinationGroup.group_show','DestinationGroupController.group_show',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1217),(1959,'DestinationGroup.code_ajax_datagrid','DestinationGroupController.code_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1217),(1960,'Discount.index','DiscountController.index',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1223),(1961,'Discount.*','DiscountController.*',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1224),(1962,'Discount.ajax_datagrid','DiscountController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1223),(1963,'Discount.store','DiscountController.store',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1221),(1964,'Discount.update','DiscountController.update',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1221),(1965,'Discount.delete','DiscountController.delete',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1222),(1966,'Discount.show','DiscountController.show',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1223),(1967,'Discount.discount_ajax_datagrid','DiscountController.discount_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1223),(1968,'Discount.discount_store','DiscountController.discount_store',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1221),(1969,'Discount.discount_update','DiscountController.discount_update',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1221),(1970,'Discount.discount_delete','DiscountController.discount_delete',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',1222),(1971,'AccountDiscount.discount_plan','AccountDiscountController.discount_plan',1,'Sumera Saeed',NULL,'2016-08-31 15:52:41.000','2016-08-31 15:52:41.000',NULL),(1972,'DestinationGroup.code_ajax_datagrid','DestinationGroupController.code_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1217),(1973,'DestinationGroup.group_show','DestinationGroupController.group_show',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1217),(1974,'DestinationGroup.group_ajax_datagrid','DestinationGroupController.group_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1217),(1975,'DestinationGroup.show','DestinationGroupController.show',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1217),(1976,'DestinationGroup.ajax_datagrid','DestinationGroupController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1217),(1977,'DestinationGroup.index','DestinationGroupController.index',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1217),(1978,'DestinationGroup.delete','DestinationGroupController.delete',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1218),(1979,'DestinationGroup.group_delete','DestinationGroupController.group_delete',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1218),(1980,'DestinationGroup.update','DestinationGroupController.update',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1219),(1981,'DestinationGroup.store','DestinationGroupController.store',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1219),(1982,'DestinationGroup.group_store','DestinationGroupController.group_store',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1219),(1983,'DestinationGroup.group_update','DestinationGroupController.group_update',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1219),(1984,'DestinationGroup.update_name','DestinationGroupController.update_name',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1219),(1985,'Discount.discount_update','DiscountController.discount_update',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1221),(1986,'Discount.discount_store','DiscountController.discount_store',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1221),(1987,'Discount.store','DiscountController.store',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1221),(1988,'Discount.update','DiscountController.update',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1221),(1989,'Discount.discount_delete','DiscountController.discount_delete',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1222),(1990,'Discount.delete','DiscountController.delete',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1222),(1991,'Discount.discount_ajax_datagrid','DiscountController.discount_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1223),(1992,'AccountDiscount.discount_plan','AccountDiscountController.discount_plan',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1223),(1993,'Discount.show','DiscountController.show',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1223),(1994,'Discount.ajax_datagrid','DiscountController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1223),(1995,'Discount.index','DiscountController.index',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1223),(1996,'DestinationGroup.*','DestinationGroupController.*',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1220),(1997,'Discount.*','DiscountController.*',1,'Sumera Saeed',NULL,'2016-08-05 11:07:24.000','2016-08-05 11:07:24.000',1224),(1998,'Retention.index','RetentionController.index',1,'Sumera Saeed',NULL,'2016-08-25 17:12:14.000','2016-08-25 17:12:14.000',1226),(1999,'Retention.*','RetentionController.*',1,'Sumera Saeed',NULL,'2016-08-25 17:12:14.000','2016-08-25 17:12:14.000',1225),(2000,'Retention.create','RetentionController.create',1,'Sumera Saeed',NULL,'2016-08-25 17:12:14.000','2016-08-25 17:12:14.000',1227),(2001,'CodeDecks.setdefault','CodeDecksController.setdefault',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2002,'Estimates.estimatelog','EstimatesController.estimatelog',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2003,'Estimates.ajax_estimatelog_datagrid','EstimatesController.ajax_estimatelog_datagrid',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2004,'BillingClass.index','BillingClassController.index',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1231),(2005,'BillingClass.*','BillingClassController.*',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1230),(2006,'BillingClass.ajax_datagrid','BillingClassController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1231),(2007,'BillingClass.create','BillingClassController.create',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1231),(2008,'BillingClass.store','BillingClassController.store',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1233),(2009,'BillingClass.edit','BillingClassController.edit',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1231),(2010,'BillingClass.update','BillingClassController.update',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1233),(2011,'BillingClass.delete','BillingClassController.delete',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1232),(2012,'BillingClass.getInfo','BillingClassController.getInfo',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',1231),(2013,'Estimates.customer_accept_estimate','EstimatesController.customer_accept_estimate',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2014,'Estimates.estimate_reject_Status','EstimatesController.estimate_reject_Status',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2015,'Estimates.estimate_comment','EstimatesController.estimate_comment',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2016,'Estimates.create_comment','EstimatesController.create_comment',1,'Sumera Saeed',NULL,'2016-09-28 13:59:53.000','2016-09-28 13:59:53.000',NULL),(2017,'Dashboard.rmdashboard','DashboardController.rmdashboard',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2018,'AccountActivity.GetReplyAttachment','AccountActivityController.GetReplyAttachment',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2019,'AccountActivity.EmailAction','AccountActivityController.EmailAction',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2020,'Integration.CheckImapConnection','IntegrationController.CheckImapConnection',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2021,'Imports.getAccountInfoFromQuickbook','ImportsController.getAccountInfoFromQuickbook',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2022,'Imports.ajax_get_missing_quickbookaccounts','ImportsController.ajax_get_missing_quickbookaccounts',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2023,'Imports.add_missing_quickbookaccounts','ImportsController.add_missing_quickbookaccounts',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',NULL),(2024,'Messages.loadDashboardMsgsDropDown','MessagesController.loadDashboardMsgsDropDown',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2025,'Messages.index','MessagesController.index',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2026,'Messages.*','MessagesController.*',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1234),(2027,'Messages.ajax_datagrid','MessagesController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2028,'Messages.show','MessagesController.show',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2029,'Messages.ajex_result','MessagesController.ajex_result',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2030,'Messages.detail','MessagesController.detail',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2031,'Messages.SentBox','MessagesController.SentBox',1,'Sumera Saeed',NULL,'2016-10-10 12:38:58.000','2016-10-10 12:38:58.000',1235),(2032,'Invoices.invoice_quickbookpost','InvoicesController.invoice_quickbookpost',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',1244),(2033,'QuickBook.index','QuickBookController.index',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2034,'QuickBook.*','QuickBookController.*',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2035,'QuickBook.disconnect','QuickBookController.disconnect',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2036,'QuickBook.addCustomer','QuickBookController.addCustomer',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2037,'QuickBook.quickbookoauth','QuickBookController.quickbookoauth',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2038,'QuickBook.success','QuickBookController.success',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2039,'QuickBook.getAllCustomer','QuickBookController.getAllCustomer',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2040,'QuickBook.getAllItems','QuickBookController.getAllItems',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2041,'QuickBook.createItem','QuickBookController.createItem',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2042,'Invoices.paypal_ipn','InvoicesController.paypal_ipn',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2043,'Invoices.paypal_cancel','InvoicesController.paypal_cancel',1,'Sumera Saeed',NULL,'2016-10-10 12:38:59.000','2016-10-10 12:38:59.000',NULL),(2044,'NotificationCustomer.index','NotificationCustomerController.index',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',NULL),(2045,'NotificationCustomer.*','NotificationCustomerController.*',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',NULL),(2046,'NotificationCustomer.ajax_datagrid','NotificationCustomerController.ajax_datagrid',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',NULL),(2047,'NotificationCustomer.store','NotificationCustomerController.store',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',NULL),(2048,'NotificationCustomer.update','NotificationCustomerController.update',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',NULL),(2049,'NotificationCustomer.delete','NotificationCustomerController.delete',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',NULL),(2050,'Messages.Draft','MessagesController.Draft',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',1235),(2051,'Messages.Compose','MessagesController.Compose',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',1236),(2052,'Messages.SendMail','MessagesController.SendMail',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',1236),(2053,'Messages.Ajax_Action','MessagesController.Ajax_Action',1,'Sumera Saeed',NULL,'2016-11-04 14:29:34.000','2016-11-04 14:29:34.000',1235),(2054,'QuickBook.createJournal','QuickBookController.createJournal',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',NULL),(2055,'Notification.qos_ajax_datagrid','NotificationController.qos_ajax_datagrid',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',1242),(2056,'Notification.qos_store','NotificationController.qos_store',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',1240),(2057,'Notification.qos_update','NotificationController.qos_update',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',1240),(2058,'Notification.qos_delete','NotificationController.qos_delete',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',1241),(2059,'Notification.history','NotificationController.history',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',1242),(2060,'Notification.history_grid','NotificationController.history_grid',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',1242),(2061,'Invoices.stripe_payment','InvoicesController.stripe_payment',1,'Sumera Saeed',NULL,'2016-11-04 14:29:35.000','2016-11-04 14:29:35.000',NULL),(2062,'Tickets.index','TicketsController.index',1,'Sumera Saeed',NULL,'2016-11-09 05:27:23.000','2016-11-09 05:27:23.000',1251),(2063,'Tickets.*','TicketsController.*',1,'Sumera Saeed',NULL,'2016-11-09 05:27:23.000','2016-11-09 05:27:23.000',1250),(2064,'Tickets.TicketGroups','TicketsController.TicketGroups',1,'Sumera Saeed',NULL,'2016-11-09 05:27:23.000','2016-11-09 05:27:23.000',NULL),(2065,'Tickets.addGroups','TicketsController.addGroups',1,'Sumera Saeed',NULL,'2016-11-09 05:27:23.000','2016-11-09 05:27:23.000',NULL),(2066,'Tickets.StoreGroups','TicketsController.StoreGroups',1,'Sumera Saeed',NULL,'2016-11-09 05:27:23.000','2016-11-09 05:27:23.000',NULL),(2067,'Tickets.ajax_datagrid_groups','TicketsController.ajax_datagrid_groups',1,'Sumera Saeed',NULL,'2016-11-09 05:27:23.000','2016-11-09 05:27:23.000',1251),(2068,'Users.job_notification','UsersController.job_notification',1,'Sumera Saeed',NULL,'2016-11-09 12:59:21.000','2016-11-09 12:59:21.000',NULL),(2069,'EmailTemplate.storetemplate','EmailTemplateController.storetemplate',1,'Sumera Saeed',NULL,'2016-11-09 12:59:21.000','2016-11-09 12:59:21.000',NULL),(2070,'TransactionLog.ajax_payments_datagrid','TransactionLogController.ajax_payments_datagrid',1,'Sumera Saeed',NULL,'2016-11-09 12:59:21.000','2016-11-09 12:59:21.000',NULL),(2071,'TicketsGroup.Activate_support_email','TicketsGroupController.Activate_support_email',1,'Sumera Khan',NULL,'2016-12-07 14:36:24.000','2016-12-07 14:36:24.000',1257),(2072,'DashboardCustomer.invoice_expense_total_widget','DashboardCustomerController.invoice_expense_total_widget',1,'Sumera Khan',NULL,'2016-12-21 05:57:00.000','2016-12-21 05:57:00.000',NULL),(2073,'ChartDashboard.getWorldMap','ChartDashboardController.getWorldMap',1,'Sumera Khan',NULL,'2016-12-21 05:57:01.000','2016-12-21 05:57:01.000',1177),(2074,'ChartDashboard.getVendorWorldMap','ChartDashboardController.getVendorWorldMap',1,'Sumera Khan',NULL,'2016-12-21 05:57:01.000','2016-12-21 05:57:01.000',1177),(2075,'BillingDashboard@invoice_expense_total_widget','BillingDashboard.invoice_expense_total_widget',1,'Sumera Khan',NULL,'2016-12-21 05:57:02.000','2016-12-21 05:57:02.000',1248),(2076,'Opportunity.getLeadorAccount','OpportunityController.getLeadorAccount',1,'Sumera Khan',NULL,'2017-01-05 10:24:07.000','2017-01-05 10:24:07.000',NULL),(2077,'ChartDashboard.getMonitorDashboradCall','ChartDashboardController.getMonitorDashboradCall',1,'Sumera Khan',NULL,'2017-01-13 07:02:14.000','2017-01-13 07:02:14.000',1177),(2078,'Dashboard.getTopAlerts','DashboardController.getTopAlerts',1,'Sumera Khan',NULL,'2017-02-16 16:08:15.000','2017-02-16 16:08:15.000',1242),(2079,'Dashboard.delete_gateway_missing_account','DashboardController.delete_gateway_missing_account',1,'Sumera Khan',NULL,'2017-02-16 16:08:15.000','2017-02-16 16:08:15.000',NULL),(2080,'RecurringInvoice.index','RecurringInvoiceController.index',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2081,'RecurringInvoice.*','RecurringInvoiceController.*',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',NULL),(2082,'RecurringInvoice.create','RecurringInvoiceController.create',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1264),(2083,'RecurringInvoice.store','RecurringInvoiceController.store',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1264),(2084,'RecurringInvoice.edit','RecurringInvoiceController.edit',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1265),(2085,'RecurringInvoice.delete','RecurringInvoiceController.delete',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1266),(2086,'RecurringInvoice.update','RecurringInvoiceController.update',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',NULL),(2087,'RecurringInvoice.ajax_datagrid','RecurringInvoiceController.ajax_datagrid',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2088,'RecurringInvoice.calculate_total','RecurringInvoiceController.calculate_total',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2089,'RecurringInvoice.getAccountInfo','RecurringInvoiceController.getAccountInfo',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2090,'RecurringInvoice.getBillingClassInfo','RecurringInvoiceController.getBillingClassInfo',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2091,'RecurringInvoice.recurringinvoicelog','RecurringInvoiceController.recurringinvoicelog',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2092,'RecurringInvoice.ajax_recurringinvoicelog_datagrid','RecurringInvoiceController.ajax_recurringinvoicelog_datagrid',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2093,'RecurringInvoice.startstop','RecurringInvoiceController.startstop',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2094,'RecurringInvoice.sendInvoice','RecurringInvoiceController.sendInvoice',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',NULL),(2095,'RecurringInvoice.generate','RecurringInvoiceController.generate',1,'Sumera Khan',NULL,'2017-02-16 16:08:16.000','2017-02-16 16:08:16.000',1267),(2100,'TicketsCustomer.index','TicketsCustomerController.index',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2101,'TicketsCustomer.*','TicketsCustomerController.*',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2102,'TicketsCustomer.Detail','TicketsCustomerController.Detail',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2103,'TicketsCustomer.add','TicketsCustomerController.add',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2104,'TicketsCustomer.ajex_result','TicketsCustomerController.ajex_result',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2105,'TicketsCustomer.CloseTicket','TicketsCustomerController.CloseTicket',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2106,'TicketsCustomer.edit','TicketsCustomerController.edit',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2107,'TicketsCustomer.Update','TicketsCustomerController.Update',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2108,'TicketsCustomer.UpdateDetailPage','TicketsCustomerController.UpdateDetailPage',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2109,'TicketsCustomer.Delete','TicketsCustomerController.Delete',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2110,'TicketsCustomer.UpdateTicketAttributes','TicketsCustomerController.UpdateTicketAttributes',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2111,'TicketsCustomer.ActionSubmit','TicketsCustomerController.ActionSubmit',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2112,'TicketsCustomer.getConversationAttachment','TicketsCustomerController.getConversationAttachment',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2113,'TicketsCustomer.GetTicketAttachment','TicketsCustomerController.GetTicketAttachment',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2114,'TicketsCustomer.ajax_datagrid','TicketsCustomerController.ajax_datagrid',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2115,'TicketsCustomer.uploadFile','TicketsCustomerController.uploadFile',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2116,'TicketsCustomer.deleteUploadFile','TicketsCustomerController.deleteUploadFile',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2117,'TicketsCustomer.Store','TicketsCustomerController.Store',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2118,'TicketsCustomer.TicketAction','TicketsCustomerController.TicketAction',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2119,'TicketsCustomer.ComposeEmail','TicketsCustomerController.ComposeEmail',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2120,'EmailTemplate.ChangeStatus','EmailTemplateController.ChangeStatus',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2121,'Contacts.UpdateContactOwner','ContactsController.UpdateContactOwner',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2122,'TicketsGroup.index','TicketsGroupController.index',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1257),(2123,'TicketsGroup.*','TicketsGroupController.*',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1256),(2124,'TicketsGroup.add','TicketsGroupController.add',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1258),(2125,'TicketsGroup.Store','TicketsGroupController.Store',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1258),(2126,'TicketsGroup.ajax_datagrid','TicketsGroupController.ajax_datagrid',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1257),(2127,'TicketsGroup.Edit','TicketsGroupController.Edit',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1259),(2128,'TicketsGroup.Update','TicketsGroupController.Update',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1259),(2129,'TicketsGroup.delete','TicketsGroupController.delete',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1260),(2130,'TicketsGroup.send_activation_single','TicketsGroupController.send_activation_single',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1257),(2131,'TicketsGroup.get_group_agents','TicketsGroupController.get_group_agents',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1251),(2132,'TicketsFields.index','TicketsFieldsController.index',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2133,'TicketsFields.*','TicketsFieldsController.*',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2134,'TicketsFields.iframe','TicketsFieldsController.iframe',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2135,'TicketsFields.iframeSubmit','TicketsFieldsController.iframeSubmit',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2136,'TicketsFields.ajax_ticketsfields','TicketsFieldsController.ajax_ticketsfields',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2137,'TicketsFields.Ajax_Ticketsfields_Choices','TicketsFieldsController.Ajax_Ticketsfields_Choices',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2138,'TicketsFields.Save_Single_Field','TicketsFieldsController.Save_Single_Field',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2139,'TicketsFields.Update_Fields_Sorting','TicketsFieldsController.Update_Fields_Sorting',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1255),(2140,'Tickets.ajax_datagrid','TicketsController.ajax_datagrid',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2141,'Tickets.ajex_result','TicketsController.ajex_result',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1251),(2142,'Tickets.add','TicketsController.add',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1252),(2143,'Tickets.uploadFile','TicketsController.uploadFile',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1252),(2144,'Tickets.deleteUploadFile','TicketsController.deleteUploadFile',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2145,'Tickets.Store','TicketsController.Store',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1252),(2146,'Tickets.edit','TicketsController.edit',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2147,'Tickets.Update','TicketsController.Update',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2148,'Tickets.UpdateDetailPage','TicketsController.UpdateDetailPage',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2149,'Tickets.delete','TicketsController.delete',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1254),(2150,'Tickets.Detail','TicketsController.Detail',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1251),(2151,'Tickets.TicketAction','TicketsController.TicketAction',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2152,'Tickets.UpdateTicketAttributes','TicketsController.UpdateTicketAttributes',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2153,'Tickets.ActionSubmit','TicketsController.ActionSubmit',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2154,'Tickets.getConversationAttachment','TicketsController.getConversationAttachment',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1251),(2155,'Tickets.GetTicketAttachment','TicketsController.GetTicketAttachment',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1251),(2156,'Tickets.CloseTicket','TicketsController.CloseTicket',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2157,'Contacts.ShowTimeLine','ContactsController.ShowTimeLine',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2158,'Tickets.ComposeEmail','TicketsController.ComposeEmail',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1252),(2159,'Tickets.SendMail','TicketsController.SendMail',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1252),(2160,'Tickets.add_note','TicketsController.add_note',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',1253),(2161,'Contacts.get_note','ContactsController.get_note',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),(2162,'Contacts.update_note','ContactsController.update_note',1,'Sumera Khan',NULL,'2017-02-23 11:53:58.000','2017-02-23 11:53:58.000',NULL),