<?php
/**
* @package RSForm!Pro
* @copyright (C) 2007-2019 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

// no direct access
defined('_JEXEC') or die;

use Joomla\CMS\Table\Table;

class TableRSForm_Salesforcecase extends Table
{
	public $form_id;
	public $slsfc_action = 1;
	public $slsfc_action_field = '';
	
	public $slsfc_orgid = '';
	public $slsfc_name = '';
	public $slsfc_email = '';
	public $slsfc_phone = '';
	public $slsfc_subject = '';
	public $slsfc_description = '';
	public $slsfc_company = '';
	public $slsfc_type = '';
	public $slsfc_status = '';
	public $slsfc_reason = '';
	public $slsfc_priority = '';
	public $slsfc_debug = 0;
	public $slsfc_debugEmail = '';
	public $slsfc_custom_fields = '';
	
	public $slsfc_published = 0;
	
	public function __construct(& $db)
	{
		parent::__construct('#__rsform_salesforcecase', 'form_id', $db);
	}

	public function check()
	{
		if (is_array($this->slsfc_custom_fields))
		{
			$this->slsfc_custom_fields = serialize($this->slsfc_custom_fields);
		}

		return true;
	}

	public function hasPrimaryKey()
	{
		$db 	= $this->getDbo();
		$key 	= $this->getKeyName();
		$table	= $this->getTableName();

		$query = $db->getQuery(true)
			->select($db->qn($key))
			->from($db->qn($table))
			->where($db->qn($key) . ' = ' . $db->q($this->{$key}));

		return $db->setQuery($query)->loadResult() !== null;
	}
}