| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class Staff extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_staff','staff');
 
- 		$this->load->_model('Model_staffclass','staffclass');
 
- 		$this->load->_model('Model_stafflist','stafflist');
 
- 		$this->load->_model('Model_staffzw','staffzw');
 
- 	}
 
- 	//定义方法的调用规则 获取URI第二段值
 
-     public function _remap($arg,$arg_array)
 
-     {
 
- 		if($arg == 'add')//添加
 
-         {
 
-              $this->_add();
 
-         }
 
- 		else if($arg == 'edit')//修改
 
-         {
 
-              $this->_edit($arg_array);
 
-         }
 
- 		else if($arg == 'del')//修改
 
-         {
 
-              $this->_del();
 
-         }
 
- 		else if($arg == 'listadd')//添加
 
-         {
 
-              $this->_listadd();
 
-         }
 
- 		else if($arg == 'listedit')//修改
 
-         {
 
-              $this->_listedit($arg_array);
 
-         }
 
- 		else if($arg == 'list')//修改
 
-         {
 
-              $this->_list();
 
-         }
 
- 		else if($arg == 'rows')//修改
 
-         {
 
-              $this->_rows();
 
-         }
 
- 		else
 
- 		{
 
- 			 $this->_index();
 
- 		}
 
-     }
 
- 	//管理
 
- 	public function _index()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['page']))  
 
- 		{
 
- 		    $page = $this->input->post('page',true);
 
- 		    $perpage = $this->input->post('perpage',true);
 
- 			$name = $this->input->post('name',true);
 
- 			$position = $this->input->post('position',true);
 
- 			$phone = $this->input->post('phone',true);
 
- 			$type = $this->input->post('type',true);
 
- 			$xztime = $this->input->post('xztime',true);
 
- 			$timetk = $this->input->post('timetk',true);
 
- 			$timetj = $this->input->post('timetj',true);
 
- 			$timetk = strtotime($timetk);
 
- 			$timetj = strtotime($timetj);
 
- 			$where = "1=1 ";
 
- 			if($timetk && $timetj && $xztime)
 
-             {
 
-                 $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
 
-             }
 
- 			if($name)
 
-             {
 
-                 $where  .= " and name = '$name'";
 
-             }
 
- 			if($phone)
 
-             {
 
-                 $where  .= " and phone = '$phone'";
 
-             }
 
- 			if($position)
 
-             {
 
-                 $where  .= " and position = '$position'";
 
-             }
 
- 			if($type)
 
-             {
 
-                 $where  .= " and type = '$type'";
 
-             }
 
-             //数据排序
 
-             $order_str = "id asc";
 
-             if(empty($page))
 
- 		    {
 
-                 $start = 0;
 
- 		    	$perpage = 1;
 
-             }
 
- 		    else
 
- 		    {
 
-                 $start = ($page - 1)*$perpage;
 
-             }
 
-             //取得信息列表
 
-             $info_list = $this->staff->find_all($where,'id,number,position,name,sex,birthday,phone,urgentname,urgentphone,address,entrytime,outtime',$order_str,$start,$perpage);
 
- 			foreach ($info_list as $key=>$value) 
 
- 		    {
 
- 				if($value['sex'] == 1)
 
- 				{
 
- 					$info_list[$key]['sex'] = "男";
 
- 				}
 
- 				else
 
- 				{
 
- 					$info_list[$key]['sex'] = "女";
 
- 				}
 
- 				if($value['outtime'] > 0)
 
- 				{
 
- 					$info_list[$key]['outtime'] = date('Y-m-d',$value['outtime']);
 
- 				}
 
- 				else
 
- 				{
 
- 					$info_list[$key]['outtime'] = "";
 
- 				}
 
- 				$info_list[$key]['number'] = 10000+$value['id'];
 
- 				$info_list[$key]['birthday'] = date('Y-m-d',$value['birthday']);
 
- 				$info_list[$key]['entrytime'] = date('Y-m-d',$value['entrytime']);
 
- 				$position = $this->staffclass->read($value['position']);
 
- 				$info_list[$key]['position'] = $position['name'];
 
- 		    }
 
- 		    $total = $this->staff->find_count($where);
 
- 		    $pagenum = ceil($total/$perpage);
 
- 		    $over = $total-($start+$perpage);
 
- 		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
 
- 		    echo json_encode($rows);exit;
 
- 		}
 
- 		$class = $this->staffclass->find_all();
 
- 		$this->data['class'] = $class;
 
- 		 $zw = $this->staffzw->find_all();
 
- 		$this->data['zw'] = $zw;
 
- 		$this->_Template('staff',$this->data);
 
- 	}
 
- 	//添加
 
- 	public function _add()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['type']))
 
- 		{
 
- 			$birthday = $this->input->post('birthday',true);
 
- 			$post['birthday'] = strtotime($birthday);
 
- 			
 
- 			$entrytime = $this->input->post('entrytime',true);
 
- 			$post['entrytime'] = strtotime($entrytime);
 
- 			
 
- 			$zztime = $this->input->post('zztime',true);
 
- 			$post['zztime'] = strtotime($zztime);
 
- 			
 
- 			$htktime = $this->input->post('htktime',true);
 
- 			$post['htktime'] = strtotime($htktime);
 
- 			
 
- 			$htjtime = $this->input->post('htjtime',true);
 
- 			$post['htjtime'] = strtotime($htjtime);
 
- 			
 
- 			$outtime = $this->input->post('outtime',true);
 
- 			$post['outtime'] = strtotime($outtime);
 
- 			$post['position'] = $this->input->post('position',true);
 
- 			if($post['position'] == '')
 
- 			{
 
- 				echo json_encode(array('msg'=>'必须选择职位!','success'=>false));exit;
 
- 			}
 
- 			if($this->staff->insert($post))
 
-         	{
 
- 				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		 $class = $this->staffclass->find_all();
 
- 		 $this->data['class'] = $class;
 
- 		 $zw = $this->staffzw->find_all();
 
- 		$this->data['zw'] = $zw;
 
- 		$this->_Template('staff_add',$this->data);
 
- 	}
 
- 	//修改
 
- 	public function _edit($arg_array)
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['id']))
 
- 		{
 
- 			$id = $this->input->post('id',true);
 
- 			$birthday = $this->input->post('birthday',true);
 
- 			$post['birthday'] = strtotime($birthday);
 
- 			
 
- 			$entrytime = $this->input->post('entrytime',true);
 
- 			$post['entrytime'] = strtotime($entrytime);
 
- 			
 
- 			$zztime = $this->input->post('zztime',true);
 
- 			$post['zztime'] = strtotime($zztime);
 
- 			
 
- 			$htktime = $this->input->post('htktime',true);
 
- 			$post['htktime'] = strtotime($htktime);
 
- 			
 
- 			$htjtime = $this->input->post('htjtime',true);
 
- 			$post['htjtime'] = strtotime($htjtime);
 
- 			
 
- 			$outtime = $this->input->post('outtime',true);
 
- 			$post['outtime'] = strtotime($outtime);
 
- 			$post['position'] = $this->input->post('position',true);
 
- 			if($post['position'] == '')
 
- 			{
 
- 				echo json_encode(array('msg'=>'必须选择职位!','success'=>false));exit;
 
- 			}
 
- 			if($this->staff->save($post,$id))
 
-         	{
 
-          		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		$arg_array = $arg_array[0];
 
- 		$staff = $this->staff->read($arg_array);
 
- 		$this->data['staff'] = $staff;
 
- 		$class = $this->staffclass->find_all();
 
- 		$this->data['class'] = $class;
 
- 		 $zw = $this->staffzw->find_all();
 
- 		$this->data['zw'] = $zw;
 
- 		$this->_Template('staff_edit',$this->data);
 
- 	}
 
- 	
 
- 	public function _list()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['uid']))  
 
- 		{
 
- 			$uid = $this->input->post('uid',true);
 
- 			$where = "uid='$uid'";
 
-             //数据排序
 
-             $order_str = "id desc";
 
-             //取得信息列表
 
-             $info_list = $this->stafflist->find_all($where,'id,data,time',$order_str);
 
- 			foreach ($info_list as $key=>$value) 
 
- 		    {
 
- 				$info_list[$key]['time'] = date('Y-m-d',$value['time']);
 
- 		    }
 
- 		    $total = $this->stafflist->find_count($where);
 
- 		    $pagenum = 0;
 
- 		    $over = 0;
 
- 		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
 
- 		    echo json_encode($rows);exit;
 
- 		}
 
- 		if(isset($post['s']))
 
- 		{
 
-             $id_arr = $this->input->post('s');
 
-             $id_arr =  explode(',',$id_arr);
 
-             if(!$id_arr)
 
-             {
 
-                 echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
 
-             }
 
-             //循环删除记录
 
-             foreach ($id_arr as $v)
 
- 		    {
 
-                 $this->stafflist->remove($v);
 
-             }
 
-             echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
 
- 		}
 
- 	}
 
- 	
 
- 	//添加
 
- 	public function _listadd()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['data']))
 
- 		{
 
- 			$post['uid'] = $this->input->post('uid',true);
 
- 			$post['data'] = $this->input->post('data',true);
 
- 			$time = $this->input->post('time',true);
 
- 			$post['time'] = strtotime($time);
 
- 			if($post['data'] == '')
 
- 			{
 
- 				echo json_encode(array('msg'=>'必须填写内容!','success'=>false));exit;
 
- 			}
 
- 			$ok = $this->stafflist->insert($post);
 
- 			if($ok)
 
-         	{
 
- 				echo json_encode(array('msg'=>'添加成功','data'=>$post['data'],'time'=>date('Y-m-d',$post['time']),'id'=>$ok,'success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		$this->_Template('staff_listadd',$this->data);
 
- 	}
 
- 	//修改
 
- 	public function _listedit($arg_array)
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['id']))
 
- 		{
 
- 			$id = $this->input->post('id',true);
 
- 			$post['data'] = $this->input->post('data',true);
 
- 			$time = $this->input->post('time',true);
 
- 			$post['time'] = strtotime($time);
 
- 			if($post['data'] == '')
 
- 			{
 
- 				echo json_encode(array('msg'=>'必须填写内容!','success'=>false));exit;
 
- 			}
 
- 			if($this->stafflist->save($post,$id))
 
-         	{
 
-          		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		$arg_array = $arg_array[0];
 
- 		$staff = $this->staff->read($arg_array);
 
- 		$this->data['staff'] = $staff;
 
- 		$this->_Template('staff_listedit',$this->data);
 
- 	}
 
- 	//删除
 
- 	public function _listdel()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['s']))
 
- 		{
 
-             $id_arr = $this->input->post('s');
 
-             $id_arr =  explode(',',$id_arr);
 
-             if(!$id_arr)
 
-             {
 
-                 echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
 
-             }
 
-             //循环删除记录
 
-             foreach ($id_arr as $v)
 
- 		    {
 
-                 $this->stafflist->remove($v);
 
-             }
 
-             echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
 
- 		}
 
-     }
 
- 	
 
- 	public function _del()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['s']))  
 
- 		{
 
-             $id_arr = $this->input->post('s');
 
-             $id_arr =  explode(',',$id_arr);
 
-             if(!$id_arr)
 
-             {
 
-                 echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
 
-             }
 
-             //循环删除记录
 
-             foreach ($id_arr as $v) 
 
- 		    {
 
-                 $this->staff->remove($v);
 
-             }
 
-             echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
 
- 		}
 
-     }
 
- }
 
 
  |