<?php defined('BASEPATH') OR exit('No direct script access allowed');

require_once APPPATH . 'processors/Transaction_processor.php';

class Salord_processor extends Transaction_processor
{
/*
	public function __construct(&$params)
	{
		parent::__construct($params);
		// $this->ci =& get_instance();
	}
*/
	public function init_save(&$data)
	{
		parent::init_save($data);

		$ci =& get_instance();

		// $this->flags->is_kot_order = !empty($data['isKot'])? true : false;
		
		TransFlag::$is_kot_order = !empty($data['isKot'])? true : false;

		if (TransFlag::$is_kot_order)
		{
			$ci->load->model('kot/KotModel','kotModel');
		}
	}

/*
	public function addValidator(&$transData)
	{
		parent::addValidator(new TransValidator($transData));
		// parent::addValidator(new SalinvValidator());
		// parent::addValidator(new SalinvValidator());
	}

	public function process_before_save(&$transData, &$postData)
	{
		parent::process_before_save($transData, $postData);

		
	}

	public function process_after_save(&$retData, &$postData)
	{
		parent::process_after_save($transData, $postData);
	}

	public function process_related_transaction($newtType, $newTransId, $tType, $transId, &$newTransData, &$postData)
	{
		parent::process_related_transaction($newtType, $newTransId, $tType, $transId, $newTransData, $postData);
	}
*/

	public function post_save(&$data, &$return)
	{
		parent::post_save($data, $return);

		if (TransFlag::$is_kot_order && !empty($data['split_ref_id']))
		{
			// split table kot
			$return['ref']	= $this->CI->kotModel->split_table(array('transId' => $data["transId"], 'split_ref_id' => $data['split_ref_id']));
		}

		
	}
}
