<?php

namespace WpBookingProFrontend\app\controllers;

use WpBookingPro\Factory;
use WpBookingPro\Filesystem\Support\StringController;
use WpBookingPro\Mvc\Controller\ControllerFrontend;
use WpBookingPro\Mvc\Model\Model;
use WpBookingPro\Utilities\Utility;
use WpBookingProFrontend\app\helpers\ConfigHelper;
use WpBookingProFrontend\app\helpers\EmailHelper;

defined('_WPBOOKINGPRO_EXEC') or die;

/**
 * Class BlockController
 */
class EmployeeController extends ControllerFrontend
{
    public function save($data = array())
    {
        $input = Factory::getInput();
        $data = $input->getData();
        $modelEmployee = Model::getInstance('employee');
        $employee = $modelEmployee->save($data);
        $link_redirect = isset($data['link_redirect'])?$data['link_redirect']:'';
        Utility::redirect($link_redirect);
    }
    
    public function delete_employee_ajax()
    {
        $input = Factory::getInput();
        $employee_id = $input->getInt('employee_id',0);
        $link_my_employee = $input->getString('link_my_employee','');
        $modelEmployee = Model::getInstance('employee');
        $modelEmployee->delete($employee_id);
        $db= Factory::getDBO();
        $query = $db->getQuery(true);
        $query->clear()
            ->delete(Utility::getTableName('service_employee'))
            ->where('employee_id='.(int)$employee_id)
        ;
        $db->setQuery($query)->execute();
        Utility::redirect($link_my_employee);
    }

}
