<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

class schedulOModel extends X {

        
        public function get_list($where){
                $sql = "SELECT * FROM ".DB_PREFIXOA."schedule WHERE ".$where."ORDER BY start_time,priority desc";
                $array = parent::$obj->getall($sql);
		return $array;
        }

  
        public function get_data($id,$userid){
	        $sql = "SELECT * FROM ".DB_PREFIXOA."schedule WHERE id='".$id."' AND user_id='$userid'";
                return parent::$obj->fetch_first($sql);
	}


        


        public function get_menu_list(){
            $sql='SELECT `id`,`pid`,`name`,`is_del` FROM `oa_dept` ORDER BY sort asc';
            $list = parent::$obj->getall($sql);
            return $list;
        }

        public function get_DeptGrade_list(){
             $sql=' SELECT `id`,`name` FROM `oa_dept_grade` WHERE ( is_del=0 ) ORDER BY sort asc';
             $list = parent::$obj->getall($sql);
             return $list;
        }

                public function doEdit($id,$arr){
                unset($arr['id']);
                unset($arr['opmode']);   
                 unset($arr['ajax']);   
                $result = parent::$obj->update(DB_PREFIXOA.'schedule', $arr, 'id='.$id.'');
                return $result;
        }  
        public function doAdd($array) {
              unset($array['ajax']);
              unset($array['opmode']);
           return parent::$obj->insert(DB_PREFIXOA.'schedule', $array); 
      }
      public function del($id){
        $sql = "DELETE FROM ".DB_PREFIXOA."schedule WHERE id='".intval($id)."'";
        return parent::$obj->query($sql);
      }
        
      public function popup($dept){
          $sql="SELECT User.id AS id,User.emp_no AS emp_no,User.name AS name,User.letter AS letter,User.dept_id AS dept_id,User.position_id AS position_id,User.email AS email,User.duty AS duty,User.office_tel AS office_tel,User.mobile_tel AS mobile_tel,User.pic AS pic,User.birthday AS birthday,User.sex AS sex,User.password AS password,User.is_del AS is_del,Position.name AS position_name,Dept.name AS dept_name FROM oa_user User  JOIN oa_position Position ON Position.id=User.position_id  JOIN oa_dept Dept ON Dept.id=User.dept_id WHERE User.dept_id IN ($dept) AND User.is_del = 0 ";
                          $array = parent::$obj->getall($sql);
		return $array;
      }
}
?>
