<?php
$urlParse = parse_url($_SERVER['REQUEST_URI']);
$urlPath = $urlParse['path'];
$urlQuery = $urlParse['query'];
if($urlQuery == '' &&  empty($_REQUEST))
{
	$module=(isset($_REQUEST['vis_module']) && $_REQUEST['vis_module']!='')?$_REQUEST['vis_module']:"ticket";
    $operation=(isset($_REQUEST['vis_operation']) && $_REQUEST['vis_operation']!='')?$_REQUEST['vis_operation']:"view_ticket";
    $ticket_hash = '';
    $ticket_id = '';
}
else if(empty($_REQUEST) && !empty($urlQuery))
{	
	$urlQuery = explode('/',$urlQuery);
	$module = $urlQuery[1];
	if(trim($urlQuery[2]) == 'ticket-details')$operation ='ticket_details';
	else if(trim($urlQuery[2]) == 'reply_ticket'){ $operation ='reply_ticket'; }
	else if(trim($urlQuery[2]) == 'ticket-reply')$operation ='ticket_reply';
	else if(trim($urlQuery[2]) == 'ticket-feedback')$operation ='ticket_feedback';
	else if(trim($urlQuery[2]) == 'rate-ticket')$operation ='rate_ticket';
	
	$ticket_hash = ($urlQuery[3]!='')?'/'.$urlQuery[3] : '';
	$ticket_id = ($urlQuery[4]!='')? '/'.$urlQuery[4] : '';
	$rate = ($urlQuery[5]!='')? '/'.$urlQuery[5] : '';
	$rating_cnt = ($urlQuery[6]!='')? '/'.$urlQuery[6] : '';
}
else
{

	if(isset($_REQUEST['search'])  && trim($_REQUEST['vis_module'])=='selfhelp') {
		$module = $_REQUEST["vis_module"];
		$operation='selfhelp_search';
		$_REQUEST['vis_search_text']=$_REQUEST['search'];
    }
    else 
    {
		$module =  $_REQUEST["vis_module"];
	    if(trim($_REQUEST["vis_operation"]) == 'update_properties'){ 
			$set_action = 1;
			$_REQUEST["vis_action"] =  'status';
			$operation ='update_properties';
		}
		else $operation = $_REQUEST["vis_operation"];
		
	}
}
$_REQUEST["vis_module"]=$module; $_GET["vis_module"]=$module; $_POST["vis_module"]=$module;
$_REQUEST["vis_operation"]=$operation; $_GET["vis_operation"]=$operation; $_POST["vis_operation"]=$operation;
if($set_action == ''){
  $_REQUEST["vis_action"] = '/'.$_REQUEST["vis_module"].'/'.$_REQUEST["vis_operation"].$ticket_hash.$ticket_id.$rate.$rating_cnt;
}
else 
{
		$set_action = 1;
		$_REQUEST["vis_action"] =  'status';
}

$request_data = $_REQUEST;

global $request_data ;
ob_start();
require_once (dirname(__FILE__) ."/integrate.php");
$_ticketdetails = ob_get_contents();
echo "<pre>";
print_r($_ticketdetails);
ob_end_clean();

$smarty->assign('vis_default_data', $_ticketdetails);

$templatefile="default";
?>
