<commit_before><?php
    global $_config;
	$page = new \Site\Page();
	$page->fromRequest();
	$page->requireRole('support user');

	if (isset($_REQUEST['action_id'])) {
		$action = new \Support\Request\Item\Action($_REQUEST['action_id']);
	} elseif ($GLOBALS['_REQUEST_']->query_vars_array[0]) {
		$action = new \Support\Request\Item\Action($GLOBALS['_REQUEST_']->query_vars_array[0]);
	} else {
		$page->addError("Action not found!");
		return;
	}
	
	if ($action->error()) $page->addError($action->error());
	$item = $action->item;
	$request = $item->request;

	// get number of other actions for current action
	$actionList = new \Support\Request\Item\ActionList();
	$actionItemsCount = 0;
	if (isset($action->item->id) && !empty($action->item->id)) {
    	$actionItems = $actionList->find(array('item_id' => $action->item->id));
    	foreach ($actionItems as $actionItem) $actionItemsCount = $actionItemsCount + 1;
	}
	
	if (isset($_REQUEST['btn_add_event'])) {
		if ($_REQUEST['status'] != $action->status) $_REQUEST['description'] .= "<br>Status changed from ".$action->status." to ".$_REQUEST['status'];
		$action->update(array('status' => 'ACTIVE'));
		$parameters = array(
			'action_id'		=> $action->id,
			'date_event'	=> $_REQUEST['date_event'],
			'user_id'		=> $_REQUEST['user_id'],
			'description'	=> $_REQUEST['description'],
			'hours_worked'	=> $_REQUEST['hours_worked']
		);
		
		if ($action->addEvent($parameters)) {
			$page->success = "Event created";
			if ($_REQUEST['status'] != $action->status) $action->update(array('status' => $_REQUEST['status']));
		} else {
			$page->addError($action->error());
		}

        // close the overall request_item here if 'yes' set to close the parent ticke (request item) as well
        if (isset($_REQUEST['close_ticket_too']) && !empty($_REQUEST['close_ticket_too'])) {
            if ($_REQUEST['close_ticket_too'] == 'yes') {
                $item = new \Support\Request\Item($action->item_id);
                $item->update(array('status' => 'COMPLETE'));
            }
        }

        // Event Occured Customer Ticket Notification        
        $notification = new \Email\Notification (
            array (<commit_msg>62f67eec7508c Close Ticket too<commit_after><?php
    global $_config;
	$page = new \Site\Page();
	$page->fromRequest();
	$page->requireRole('support user');

	if (isset($_REQUEST['action_id'])) {
		$action = new \Support\Request\Item\Action($_REQUEST['action_id']);
	} elseif ($GLOBALS['_REQUEST_']->query_vars_array[0]) {
		$action = new \Support\Request\Item\Action($GLOBALS['_REQUEST_']->query_vars_array[0]);
	} else {
		$page->addError("Action not found!");
		return;
	}
	
	if ($action->error()) $page->addError($action->error());
	$item = $action->item;
	$request = $item->request;

	// get number of other actions for current action
	$actionList = new \Support\Request\Item\ActionList();
	$actionItemsCount = 0;
	if (isset($action->item->id) && !empty($action->item->id)) {
    	$actionItems = $actionList->find(array('item_id' => $action->item->id));
    	foreach ($actionItems as $actionItem) $actionItemsCount = $actionItemsCount + 1;
	}
	
	if (isset($_REQUEST['btn_add_event'])) {
		if ($_REQUEST['status'] != $action->status) $_REQUEST['description'] .= "<br>Status changed from ".$action->status." to ".$_REQUEST['status'];
		$action->update(array('status' => 'ACTIVE'));
		$parameters = array(
			'action_id'		=> $action->id,
			'date_event'	=> $_REQUEST['date_event'],
			'user_id'		=> $_REQUEST['user_id'],
			'description'	=> $_REQUEST['description'],
			'hours_worked'	=> $_REQUEST['hours_worked']
		);
		
		if ($action->addEvent($parameters)) {
			$page->success = "Event created";
			if ($_REQUEST['status'] != $action->status) $action->update(array('status' => $_REQUEST['status']));
		} else {
			$page->addError($action->error());
		}

        // close the overall request_item here if 'yes' set to close the parent ticke (request item) as well
        if (isset($_REQUEST['close_ticket_too']) && !empty($_REQUEST['close_ticket_too'])) {        
            if ($_REQUEST['close_ticket_too'] == 'yes') {
                $requestItem = new \Support\Request\Item($action->id);
                $requestItem->update(array('status' => 'COMPLETE'));
            }
        }

        // Event Occured Customer Ticket Notification        
        $notification = new \Email\Notification (
            array (
{'fraction_non_alphanumeric': 0.19664703217036703, 'fraction_numerical': 0.0036248300860897147, 'mean_word_length': 3.8838495575221237, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 81, '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': '4807534', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1377, 'n_words': 267}