from lib.database.db_manager import DBManager


class UnpaidMaestroManager:
    db_params = None
    db_man = None

    def __init__(self, mode):
        self.db_man = DBManager(mode)

    def get_unpaid_7days_maestro_list(self):
        unpaid_7days_sql = 'select * from maestro \
where DATE(NOW()) - INTERVAL 7 DAY > AcceptClausesDateTime AND ActivateStatus = 0'
        day7_maestro_list = self.db_man.select(unpaid_7days_sql)
        return day7_maestro_list

    def get_unpaid_8days_maestro_list(self):
        unpaid_8days_sql = 'select * from maestro \
where DATE(NOW()) - INTERVAL 8 DAY > AcceptClausesDateTime AND ActivateStatus = 0'
        day8_maestro_list = self.db_man.select(unpaid_8days_sql)
        return day8_maestro_list

    def insert_maestro_log(self, maestro_id, remark):
        sql = 'INSERT INTO maestro_log (Type, MaestroID, LogDateTime, Remark) \
VALUES (\'delete_maestro\', %s, %s, %s)'
        params = (maestro_id, DBManager.get_datetime_now(), remark)
        # print(sql)
        # print(params)
        self.db_man.insert(sql, params)

    def delete_maestro_list(self, maestro_id):
        sql = 'DELETE FROM maestro WHERE MaestroID = %s'
        params = (maestro_id)
        # print(sql)
        # print(params)
        self.db_man.delete(sql, params)