<?php
/**
 * Created by PhpStorm.
 * User: sicilon_IT
 * Date: 2020/1/13
 * Time: 0:25
 */
namespace app\index\model;
use think\Model;

class wheadmodel extends Model{
    protected $table='t_gheader';

    public function getgidbywid($wid){
        $arr['checkstatus']=1;
        $arr['gwid']=$wid;
        $recordlist=$this->where($arr)->find();
        if ($recordlist){
            return $recordlist['gid'];
        }else{
            return 0;
        }
    }



    public function addnewghead($arr){
        $res=$this->save($arr);
        return $res;
    }


    /*
     * 取消此人的班组
     */
    public function changeghead($wid){
        $where_arr['gwid']=$wid;
        $update_arr['checkstatus']=0;
        $res=$this->where($where_arr)->update($update_arr);
        return $res;
    }

    /*
     * 20200320
     * 设置了新班组长时，将原班组长的权限取消
     */
    public function updategheadbygid($gid){
        $where_arr['gid']=$gid;
        $where_arr['checkstatus']=1;
        $update_arr['checkstatus']=0;
        $res=$this->where($where_arr)->update($update_arr);
        return $res;
    }

    public function getwidbygid($gid){
        $where_arr['gid']=$gid;
        $where_arr['checkstatus']=1;
        $rec=$this->where($where_arr)->find();
        return $rec;
    }
}