Browse Source

优化委托管理送样人

huangsanjia 2 years ago
parent
commit
3571250c81

+ 29 - 20
application/admin/controller/Entrust.php

@@ -60,17 +60,18 @@ class Entrust extends Backend
                 ->paginate($limit);
         }else{
             $userinfo = Db::name('admin')->where('id',$user_id)->find();
-            $pidList = Db::name('company')->where('pid',$userinfo['company'])->select();
-            $map = [];
-            if (!empty($pidList)){//总公司
-                $pid = [];
-                foreach ($pidList as $key=>$value){
-                    $pid[$key] = $value['id'];
-                }
-                $map['work_unit'] = array('in',$pid);
-            }else{//分公司
-                $map['work_unit'] = $userinfo['company'];
-            }
+//            $pidList = Db::name('company')->where('pid',$userinfo['company'])->select();
+//            $map = [];
+//            if (!empty($pidList)){//总公司
+//                $pid = [];
+//                foreach ($pidList as $key=>$value){
+//                    $pid[$key] = $value['id'];
+//                }
+//                $map['work_unit'] = array('in',$pid);
+//            }else{//分公司
+//                $map['work_unit'] = $userinfo['company'];
+//            }
+            $map['work_unit'] = $userinfo['company'];
             $list = $this->model
                 ->where($where)
                 ->where($map)
@@ -110,10 +111,12 @@ class Entrust extends Backend
             if (empty($company)){
                 $company = Db::name('company')->where('id',$company_id)->column('id,name');
             }
-            $this->assign('company',$company);
             $judgeData = Db::name('item_judge')->whereNull('delete')->order('weigh asc')->column('id,name');
+            $receiveData = Db::name('receive_people')->where('company_id',$company_id)->column('id,name');
+            $this->assign('company',$company);
             $this->view->assign('judgeData', $judgeData);
             $this->view->assign('nickname', $nickname);
+            $this->view->assign('receiveData', $receiveData);
             return $this->view->fetch();
         }
         $params = $this->request->post('row/a');
@@ -131,11 +134,12 @@ class Entrust extends Backend
         $params['standard_id'] = preg_replace('/\s+/','',$params['standard_id']);
         $judge = Db::name('item_judge')->where('id',$params['standard_id'])->find();
         $params['standard_name'] = $judge['name'];
+        $params['receive_sample'] = Db::name('receive_people')->where('id',$params['receive_sample'])->value('name');
         $params['user_name'] = $userinfo['username'];
         $params['work_unit'] = $userinfo['company'];
         $params['work_name'] = Db::name('company')->where('id',$userinfo['company'])->value('name');
         $params['company'] = Db::name('company')->where('id',$params['company'])->value('name');
-
+        print_r($params);die;
         $is_exit = false;//默认样品编号唯一
         if ($params['is_two'] == 1){//双样
             for ($i=0;$i<2;$i++){
@@ -201,6 +205,8 @@ class Entrust extends Backend
             $company = Db::name('company')->where('pid',$pid)->column('id,name');
             $report_grant = explode(',',$row['report_grant']);
             $sample_stand = explode(',',$row['sample_stand']);
+            $receiveData = Db::name('receive_people')->where('company_id',$company_id)->column('id,name');
+            $this->view->assign('receiveData', $receiveData);
             $this->assign('company',$company);
             $this->assign('report_grant',$report_grant);
             $this->assign('sample_stand',$sample_stand);
@@ -220,6 +226,7 @@ class Entrust extends Backend
         $item_judge = Db::name('item_judge')->field('id,name')->where('id',$params['standard_id'])->find();
         $params['standard_id'] = $item_judge['id'];
         $params['standard_name'] = $item_judge['name'];
+        $params['receive_sample'] = Db::name('receive_people')->where('id',$params['receive_sample'])->value('name');
         $params = $this->preExcludeFields($params);
         $result = false;
         Db::startTrans();
@@ -748,13 +755,15 @@ class Entrust extends Backend
         if (empty($params) || empty($company)){
             $this->error('参数错误');
         }
-        $num = Db::name('entrust')->where('sample_no','like','%'.$params.'%')->whereTime('create','d')->count();
-
-        if ($company == '亚欣'){//亚欣送样从100开始
-            $num = $num+100;
-        }else{
-            $num = $num+1;
-        }
+        $beginTime = date('Y-m-d 00:00:00');
+        $endTime = date('Y-m-d 24:00:00');
+        $num = Db::name('entrust')->where('sample_no','like','%'.$params.'%')->where('create','between',[$beginTime,$endTime])->count();
+//        if ($company == '亚欣'){//亚欣送样从100开始
+//            $num = $num+100;
+//        }else{
+//            $num = $num+1;
+//        }
+        $num = $num+1;
         if ($num < 10){
             $num = '0'.$num;
         }

+ 3 - 0
application/admin/controller/Res.php

@@ -63,6 +63,7 @@ class Res extends Backend
         }else{
             $userinfo = Db::name('admin')->where('id',$user_id)->find();
             $pidList = Db::name('company')->where('pid',$userinfo['company'])->select();
+
             $map = [];
             if (!empty($pidList)){//总公司
                 $pid = [];
@@ -73,8 +74,10 @@ class Res extends Backend
             }else{//分公司
                 $map['work_unit'] = $userinfo['company'];
             }
+
             $list = $this->model
                 ->where($where)
+                ->where($map)
                 ->whereNull('delete_time')
                 ->order($sort, $order)
                 ->paginate($limit);

+ 1 - 1
application/admin/view/entrust/add.html

@@ -91,7 +91,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">收样人:</label>
         <div class="col-xs-12 col-sm-8">
-            {:build_select('row[receive_sample]', ['王枫'=>'王枫', '邹细建'=>'邹细建','高小满'=>'高小满','顾诚康'=>'顾诚康',], $nickname,['class'=>'form-control'])}
+            {:build_select('row[receive_sample]', $receiveData, $nickname,['class'=>'form-control'])}
         </div>
     </div>
     <div class="form-group">

+ 5 - 12
application/admin/view/entrust/edit.html

@@ -98,18 +98,11 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">收样人:</label>
         <div class="col-xs-12 col-sm-8">
-            {if condition="$row.receive_sample eq '王枫'"}
-                {:build_select('row[receive_sample]', ['王枫'=>'王枫', '邹细建'=>'邹细建','高小满'=>'高小满','顾诚康'=>'顾诚康',], '王枫',['class'=>'form-control'])}
-            {/if}
-            {if condition="$row.receive_sample eq '邹细建'"}
-                {:build_select('row[receive_sample]', ['王枫'=>'王枫', '邹细建'=>'邹细建','高小满'=>'高小满','顾诚康'=>'顾诚康',], '邹细建',['class'=>'form-control'])}
-            {/if}
-            {if condition="$row.receive_sample eq '高小满'"}
-                {:build_select('row[receive_sample]', ['王枫'=>'王枫', '邹细建'=>'邹细建','高小满'=>'高小满','顾诚康'=>'顾诚康',], '高小满',['class'=>'form-control'])}
-            {/if}
-            {if condition="$row.receive_sample eq '顾诚康'"}
-                {:build_select('row[receive_sample]', ['王枫'=>'王枫', '邹细建'=>'邹细建','高小满'=>'高小满','顾诚康'=>'顾诚康',], '顾诚康',['class'=>'form-control'])}
-            {/if}
+            <select class="form-control" name="row[receive_sample]">
+                {foreach name='receiveData' id='vo' key='k'}
+                <option value="{$k}" {if condition="$vo eq $row['receive_sample']"} selected {/if}>{$vo}</option>
+                {/foreach}
+            </select>
         </div>
     </div>
     <div class="form-group">