50], [['car_year'], 'string', 'max' => 10], [['car_man','phone','remark','company','op_user1','op_user2','op_user3','weixin','from_src'], 'string', 'max' => 200], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'user_id' => 'User ID', 'car_type_id' => 'Car Type ID', 'car_use_id' => 'Car Use ID', 'car_no' => 'Car No', 'factory_model' => 'Factory Model', 'car_model' => 'Car Model', 'register_date' => 'Register Date', 'insurer1_date' => 'Insurer 1 Date', 'insurer2_date' => 'Insurer 2 Date', 'id_man' => 'ID Man', 'id_number' => 'ID Number', 'engine_no' => 'Engine No', 'car_frame_no' => 'Car Frame No', 'brand_id' => 'Brand ID', 'series_id' => 'Series ID', 'displacement_id' => 'Displacement ID', 'car_year' => 'Car Year', 'seats' => 'Seats', 'car_man' => 'Car Man', 'phone' => 'Phone', 'weixin' => 'Weixin', 'remark' => 'Remark', 'location' => 'Location', 'invalid_flag' => 'Invalid Flag', 'invalid_id' => 'Invalid ID', 'print_date' => 'Print Date', 'car_man_number' => 'Car Man Number', 'is_track' => 'Is Track', 'times' => 'Times', 'old_user' => 'Old User', 'company' => 'Company', 'op_user1' => 'Op User1', 'op_user2' => 'Op User2', 'op_user3' => 'Op User3', 'from_src' => 'From Src', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public function getUser() { return $this->hasOne(UserT::className(),['id'=>'user_id']); } public function getCarType() { return $this->hasOne(CarTypeT::className(),['id'=>'car_type_id']); } public function getCarUse() { return $this->hasOne(CarUseT::className(),['id'=>'car_use_id']); } public function getAppointment() { return $this->hasOne(AppointmentT::className(),['car_id'=>'id']); } public function getAppointments() { return $this->hasMany(AppointmentHistoryT::className(),['car_id'=>'id']); } public function getOrders() { return $this->hasMany(OrderT::className(),['car_id'=>'id']); } public function getLastOpUser1() { $count = OrderT::find()->where('car_id='.$this->id)->count(); if($count >1){ $order = OrderT::find()->where('car_id='.$this->id)->orderBy('id ASC')->one(); return $order->user->getShowName(); } return ''; } public function getBrand() { return $this->hasOne(BrandT::className(),['id'=>'brand_id']); } public function getInvalid() { return $this->hasOne(InvalidT::className(),['id'=>'invalid_id']); } public function getSeries() { return $this->hasOne(SeriesT::className(),['id'=>'series_id']); } public function getDisplacement() { return $this->hasOne(DisplacementT::className(),['id'=>'displacement_id']); } // public function getLocation() // { // $name = ''; // switch($this->location) { // case 1: // $name = 'A库'; // break; // case 2: // $carb=CarBT::findOne(['id'=>$this->id]); // if($carb->back==1){ // $name = 'B库(新保处理无效库)'; // }else{ // $name = 'B库'; // } // break; // case 3: // $name = 'C库'; // break; // case 4: // $name = 'D库'; // $card=CarDT::findOne(['id'=>$this->id]); // if($card->back==1){ // $name = 'D库(续保处理无效库)'; // }else{ // $name = 'D库'; // } // break; // case 5: // $name = '无效库'; // break; // case 6: // $name = 'E库'; // break; // case 7: // $name = 'F库'; // break; // case 8: // $name = 'F1新保四大公司无效库'; // break; // case 9: // $name = 'F2新保其他小公司无效库'; // break; // case 10: // $name = 'F3新保正常无效库'; // break; // case 11: // $name = 'F4续保四大公司无效库'; // break; // case 12: // $name = 'F5续保其他小公司无效库'; // break; // case 13: // $name = 'F6续保正常无效库'; // break; // default: // $name = ''; // } // return $name; // } public function getLocation() { $name = ''; switch($this->location) { case 1: $car=CarT::findOne(['id'=>$this->id]); if($car->qiyong==2){ $name = 'A库(永不启用)'; }else{ $name = 'A库'; } break; case 2: $carb=CarBT::findOne(['id'=>$this->id]); if($carb->back==1){ $name = 'B库(新保处理无效库)'; }else{ $name = 'B库'; } break; case 3: $name = 'C库'; break; case 4: $name = 'D库'; $card=CarDT::findOne(['id'=>$this->id]); if($card->back==1){ $name = 'D库(续保处理无效库)'; }else{ $name = 'D库'; } break; case 5: $name = '无效库'; break; case 6: $name = 'E库'; break; case 7: $name = 'F库'; break; case 8: $name = 'F1新保四大公司无效库'; break; case 9: $name = 'F2新保其他小公司无效库'; break; case 10: $name = 'F3新保正常无效库'; break; case 11: $name = 'F4续保四大公司无效库'; break; case 12: $name = 'F5续保其他小公司无效库'; break; case 13: $name = 'F6续保正常无效库'; break; case 14: $name = '清洗岗数据库'; break; case 15: $name = '数据准确库'; break; case 16: $name = '数据不准确库'; break; default: $name = ''; } return $name; } public function getLib() { if($this->location == 1) return null; if($this->location == 2) return $this->hasOne(CarBT::className(),['id'=>'id']); if($this->location == 3) return $this->hasOne(CarCT::className(),['id'=>'id']); if($this->location == 4) return $this->hasOne(CarDT::className(),['id'=>'id']); if($this->location == 5) return $this->hasOne(CarInvalidT::className(),['id'=>'id']); if($this->location == 7) return $this->hasOne(CarFT::className(),['id'=>'id']); return null; } }