<?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 leaveOModel extends X {

        
        public function getList($items){
                    $where      = " WHERE 1=1".$items['searchsql'];
                    $start      = ($items['page']-1)*$items['pagesize'];
                    $countsql   = "SELECT COUNT(*) AS my_count FROM ".DB_PREFIXOA."leave ".$where;
                    $total      = parent::$obj->fetch_count($countsql);
                    $sql        = "SELECT * FROM ".DB_PREFIXOA."leave ".$where." ORDER BY id desc LIMIT ".$start.", ".$items['pagesize']."";
                    $array = parent::$obj->getall($sql);
                    return array($total, $array);
        }

  
        public function get_top_menu_data($id){
	        $sql = "SELECT * FROM ".DB_PREFIXOA."leave WHERE id='".$id."'";
                return parent::$obj->fetch_first($sql);
	}
 


               public function doEdit($id,$arr){
                 
                unset($arr['id']);
                unset($arr['opmode']);
                unset($arr['ajax']);           
                $result = parent::$obj->update(DB_PREFIXOA.'leave', $arr, 'id='.$id.'');
                return $result;
        }  
        public function doAdd($array) {
          
             unset($array['ajax']);
             unset($array['opmode']);
             $array['user_id']= $_SESSION['USER_AUTH_KEY']; 
             $array['user_name']= $_SESSION['user_name']; 
             $array['dept_id']= $_SESSION['dept_id']; 
           return parent::$obj->insert(DB_PREFIXOA.'leave', $array); 
      }
      public function del($id){
        $sql = "DELETE FROM ".DB_PREFIXOA."leave WHERE id='".intval($id)."'";
        return parent::$obj->query($sql);
      }
      

        
}
?>
