<?php

/**
 * Fired during plugin activation
 *
 * @link       https://profile.fraxzon.com
 * @since      1.0.0
 *
 * @package    Ffl_Dealers
 * @subpackage Ffl_Dealers/includes
 */

/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      1.0.0
 * @package    Ffl_Dealers
 * @subpackage Ffl_Dealers/includes
 * @author     shafiq <shafiq6171@gmail.com>
 */
class Ffl_Dealers_Activator {

	/**
	 * Short Description. (use period)
	 *
	 * Long Description.
	 *
	 * @since    1.0.0
	 */
	public static function activate() {
		global $wpdb;
        $charset_collate = $wpdb->get_charset_collate();
        $firegun_delear = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ffl_dealers` (
		`id` int(11) NOT NULL AUTO_INCREMENT,
		`license_number` varchar(30) NOT NULL,
		`short_lic` varchar(12) NOT NULL,
		`license_name` varchar(100) NOT NULL,
		`business_name` varchar(100) NOT NULL,
		`premise_street` varchar(50) NOT NULL,
		`premise_city` varchar(30) NOT NULL,
		`premise_state` varchar(20) NOT NULL,
		`premise_zip_code` varchar(10) NOT NULL,
		`lat` varchar(20) NOT NULL,
		`lng` varchar(20) NOT NULL,
		`voice_phone` varchar(15) NOT NULL,
		`check_status` TINYINT(1) NOT NULL DEFAULT '0',
		`default_dealer` TINYINT(1) NOT NULL DEFAULT '0',
        PRIMARY KEY (`id`)
       )$charset_collate;";
	    if (!function_exists('dbDelta')) {
            require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        }
        dbDelta($firegun_delear);
		$plugin_installed = get_option('ffl_dealer_activation_time');
		if(!$plugin_installed){
			$get_activation_time = strtotime("now");
			add_option('ffl_dealer_activation_time', $get_activation_time );
		}
		add_option( 'ffl_dealer_plugin_activation', true );
		update_option( 'woocommerce_ship_to_destination','yes');
	}

}
