<?php

/**
 * Class that operate on table 'employeeclosedaysubgroupstatus'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2020-11-19 05:41
 */
class EmployeeclosedaysubgroupstatusMySqlExtDAO extends EmployeeclosedaysubgroupstatusMySqlDAO {

    public function insertAllSubGroupStatusForADaySpecial($day, $userid, $sysdate) {
        $sql = 'INSERT IGNORE INTO employeeclosedaysubgroupstatus (day, employeesubgroupid, status, userid, sysdate, conditions)
                SELECT "' . $day . '",id , 1,' . $userid . ', "' . $sysdate . '",0
                from employeesubgroup where employeesubgroup.del=0';
        $sqlQuery = new SqlQuery($sql);
        return $this->executeUpdate($sqlQuery);
    }

    public function queryByEmployeegroupidAndDayGetDistinctSubGroupsClosed($employeegroupid, $day) {
        $sql = 'SELECT Distinct employeeclosedaysubgroupstatus.employeesubgroupid
                FROM employeeclosedaysubgroupstatus
                join employeesubgroup on employeesubgroup.id = employeeclosedaysubgroupstatus.employeesubgroupid
                join employeegroup on employeegroup.id=employeesubgroup.employeegroupid
                WHERE employeesubgroup.employeegroupid = ' . $employeegroupid . ' and employeeclosedaysubgroupstatus.day="' . $day . '" and employeeclosedaysubgroupstatus.status = 1';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }
    
    public function queryByDayAndEmployeesubgroupid($employeesubgroupid, $day) {
        $sql = 'SELECT *
                FROM employeeclosedaysubgroupstatus
                WHERE employeesubgroupid = ' . $employeesubgroupid . ' and day="' . $day . '" ';
        $sqlQuery = new SqlQuery($sql);
        return $this->getRow($sqlQuery);
    }

}

?>