<?php

namespace CarDealerPress\Includes\Functions;

use CarDealerPress\Includes\Database\Requests;
use CarDealerPress\includes\helpers\helpers;
use CarDealerPress\Includes\Helpers\Option;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Shortcode {

	public $theme_options;
	public $admin_options;
	private $vms;

	public function __construct() {
		$this->set_option_variables();
		$this->add_shortcode();
	}

	function set_option_variables() {
		$this->theme_options = Option::get_cdp_theme_options();
		$this->admin_options = Option::get_cdp_admin_options();
		$this->vms           = new VehicleManagementSystem( $this->admin_options['admin']['help']['host'], helpers::company_id() );

	}

	function add_shortcode() {
		$db_companies = ( new Requests() )->cdp_company_request();
		if ( $db_companies ) {
			$company = $db_companies[0];
		} else {
			$company = array();
		}
		$sc_run = new Sc_Run( $this->vms, $company, $this->theme_options );
		add_shortcode( 'inventory_list', array( $sc_run, 'inventory_list' ) );
		add_shortcode( 'inventory_detail', array( $sc_run, 'inventory_detail' ) );
		add_shortcode( 'inventory_slider', array( $sc_run, 'inventory_slider' ) );
		add_shortcode( 'inventory_counter', array( $sc_run, 'inventory_counter' ) );
		add_shortcode( 'inventory_search', array( $sc_run, 'inventory_search' ) );
	}
}
