<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Callme_install extends InstallController
{

    public function __construct()
    {
        parent::__construct();
        $folder_name = 'callme';
        $this->lang->load($folder_name . '/install');
        // Set acl module name
        $this->module_config['module_acl_name'] = $folder_name;
        // Set title
        $this->module_config['module_title'] = $this->lang->line('module_name');
        // Set module image
        $this->module_config['module_image'] = 'fa-commenting-o';
        // Set actions
        $this->module_config['module_actions'] = $this->lang->line('module_actions');
        // Set menu items
        $this->module_config['module_menu_items'] = $this->lang->line('module_menu_items');
    }

    public function install($options = [])
    {
        // Create table
        $query = '
            CREATE TABLE IF NOT EXISTS `callme` (
                `id_callme` int(11) NOT NULL AUTO_INCREMENT,
                `name` varchar(32) NOT NULL,
                `text` varchar(512) NOT NULL,
                `phone` varchar(16) NOT NULL,
                `email` varchar(128) NOT NULL,
                `date_add` date NOT NULL,
                `worked_out` tinyint(1) NOT NULL DEFAULT \'0\',
                PRIMARY KEY (`id_callme`)
              ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
        ';
        $this->db->query($query);

        return parent::install($options);
    }

    public function uninstall($options = [])
    {
        return parent::uninstall([
                    'dropTables' => [
                        'callme',
                        'captcha',
                    ],
        ]);
    }

}
