<commit_before><?php
include ("./lib/customer.defines.php");
include ("./lib/customer.module.access.php");
include ("./lib/Form/Class.FormHandler.inc.php");
include ("./form_data/FG_var_ticket.inc");
include ("./lib/customer.smarty.php");

if (! has_rights (ACX_SUPPORT)) {
	Header ("HTTP/1.0 401 Unauthorized");
	Header ("Location: PP_error.php?c=accessdenied");
	die();
}


getpost_ifset(array('title', 'description', 'priority' , 'component'));


$HD_Form -> setDBHandler (DbConnect());
$HD_Form -> init();

/************************************  ADD TICKET  ***********************************************/
if (strlen($description)>0  && is_numeric($priority) && strlen($title)>0  && is_numeric($component)){

		$FG_SPEEDDIAL_TABLE  = "cc_ticket";
		$instance_sub_table = new Table($FG_SPEEDDIAL_TABLE, "*");

		$QUERY = "INSERT INTO cc_ticket (creator,title, description, id_component, priority, viewed_cust) VALUES ('".$_SESSION["card_id"]."', '".$title."', '".$description."', '".$component."', '".$priority ."' ,'0')";
		
		$result = $instance_sub_table -> SQLExec ($HD_Form -> DBHandle, $QUERY, 0);
		NotificationsDAO::AddNotification("ticket_added_cust",Notification::$LOW,Notification::$CUST,$_SESSION['card_id']);
		$update_msg = gettext("Ticket added successfully");

}

if ($id!="" || !is_null($id)) {
	$HD_Form -> FG_EDITION_CLAUSE = str_replace("%id", "$id", $HD_Form -> FG_EDITION_CLAUSE);
}

if (!isset($form_action))  $form_action="list"; //ask-add
if (!isset($action)) $action = $form_action;
$list = $HD_Form -> perform_action($form_action);

// #### HEADER SECTION
$smarty->display('main.tpl');

if ($form_action == "list") {
    $HD_Form -> create_toppage ("ask-add");
    if (strlen($_GET["menu"])>0) $_SESSION["menu"] = $_GET["menu"];
<commit_msg>ticket #578: Customer ticket improvements<commit_after><?php
include ("./lib/customer.defines.php");
include ("./lib/customer.module.access.php");
include ("./lib/Form/Class.FormHandler.inc.php");
include ("./form_data/FG_var_ticket.inc");
include ("./lib/customer.smarty.php");

if (! has_rights (ACX_SUPPORT)) {
	Header ("HTTP/1.0 401 Unauthorized");
	Header ("Location: PP_error.php?c=accessdenied");
	die();
}


getpost_ifset(array('title', 'description', 'priority' , 'component'));


$HD_Form -> setDBHandler (DbConnect());
$HD_Form -> init();

/************************************  ADD TICKET  ***********************************************/
if ( (strlen($description)>0 || strlen($title)>0 ) && is_numeric($priority) && is_numeric($component)){

		$FG_SPEEDDIAL_TABLE  = "cc_ticket";
		$instance_sub_table = new Table($FG_SPEEDDIAL_TABLE, "*");

		$QUERY = "INSERT INTO cc_ticket (creator,title, description, id_component, priority, viewed_cust) VALUES ('".$_SESSION["card_id"]."', '".$title."', '".$description."', '".$component."', '".$priority ."' ,'0')";
		
		$result = $instance_sub_table -> SQLExec ($HD_Form -> DBHandle, $QUERY, 0);
		NotificationsDAO::AddNotification("ticket_added_cust",Notification::$LOW,Notification::$CUST,$_SESSION['card_id']);
		$update_msg = gettext("Ticket added successfully");

} elseif((strlen($description) + strlen($title) == 0 )) {
	$update_msg = gettext("Please complete the title and description portions of the form.");
} else {
	$update_msg = gettext("Sorry, There was a problem creating your ticket.");
}

if ($id!="" || !is_null($id)) {
	$HD_Form -> FG_EDITION_CLAUSE = str_replace("%id", "$id", $HD_Form -> FG_EDITION_CLAUSE);
}

if (!isset($form_action))  $form_action="list"; //ask-add
if (!isset($action)) $action = $form_action;
$list = $HD_Form -> perform_action($form_action);

// #### HEADER SECTION
$smarty->display('main.tpl');

if ($form_action == "list") {
    $HD_Form -> create_toppage ("ask-add");
    if (strlen($_GET["menu"])>0) $_SESSION["menu"] = $_GET["menu"];

{'fraction_non_alphanumeric': 0.2510504201680672, 'fraction_numerical': 0.0063025210084033615, 'mean_word_length': 6.186792452830189, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7523441', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1294, 'n_words': 236}