<?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_Salesforce extends Table
{
	public $form_id;

	public $slsf_action = 1;
	public $slsf_action_field = '';
	
	public $slsf_lead_source = '';
	public $slsf_first_name = '';
	public $slsf_last_name = '';
	public $slsf_title = '';
	public $slsf_company = '';
	public $slsf_email = '';
	public $slsf_phone = '';
	public $slsf_street = '';
	public $slsf_city = '';
	public $slsf_state = '';
	public $slsf_zip = '';
	public $slsf_country = '';
	public $slsf_debug = 0;
	public $slsf_oid = '';
	public $slsf_debugEmail = '';
	public $slsf_industry = '';
	public $slsf_description = '';
	public $slsf_mobile = '';
	public $slsf_fax = '';
	public $slsf_website = '';
	public $slsf_salutation = '';
	public $slsf_revenue = '';
	public $slsf_employees = '';
	public $slsf_custom_fields = '';
	public $slsf_campaign_id = '';
	public $slsf_donotcall = '';
	public $slsf_emailoptout = '';
	public $slsf_faxoptout = '';
	public $slsf_recordtype = '';

	public $slsf_published = 0;
	
	public function __construct(& $db)
	{
		parent::__construct('#__rsform_salesforce', 'form_id', $db);
	}

	public function check()
	{
		if (is_array($this->slsf_custom_fields))
		{
			$this->slsf_custom_fields = serialize($this->slsf_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;
	}
}