<?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 supplierSModel 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_PREFIXSA."supplier ".$where;
                    $total      = parent::$obj->fetch_count($countsql);
                    $sql        = "SELECT * FROM ".DB_PREFIXSA."supplier ".$where." ORDER BY id asc LIMIT ".$start.", ".$items['pagesize']."";
                    $array = parent::$obj->getall($sql);
                    return array($total, $array);
        }

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

       public function doEdit($id,$arr){
                 
                unset($arr['id']);
                unset($arr['opmode']);        
                $result = parent::$obj->update(DB_PREFIXSA.'supplier', $arr, 'id='.$id.'');
                return $result;
        }  
        public function doAdd($array) {
            /// print_r($array);die;
             unset($array['opmode']);
             $array['create_user']= $_SESSION['sale_id'];
             $array['create_user_name']= $_SESSION['sale_name'];
             $array['add_time']= time();
           return parent::$obj->insert(DB_PREFIXSA.'supplier', $array); 
      }
      public function del($id){
        $sql = "DELETE FROM ".DB_PREFIXSA."supplier WHERE id='".intval($id)."'";
        return parent::$obj->query($sql);
      }
      
      public function popup(){
         $id = parent::$obj->fetch_newid('SELECT MAX(id) FROM '.DB_PREFIXSA.'supplier', 1);
         return $id;
     }
        
}
?>
