function save(array $params) { $response = new ResponseEntity(); try { $user = new User(); $user->email = $params['email']; $user->password = bcrypt($params['password']); $user->status = 'ACTIVE'; $user->save(); $employee = new Employee(); $employee->user_id = 10; $employee->employee_id = Config::get('hris_system.employee_id_prefix') . 10; $employee->first_name = $params['first_name']; $employee->last_name = $params['last_name']; $employee->middle_name = $params['middle_name']; $employee->sex = $params['sex']; $employee->birthday = '1990-11-20'; $employee->department_id = $params['department_id']; $employee->position_id = $params['position_id']; $ok = $employee->save(); if ($ok) { $response->setSuccess(true); $response->setMessages(['Employee successfully created!']); } else { $response->setMessages(['Failed to create employee!']); } } catch (\Exception $ex) { $response->setMessages([$ex->getMessage()]); } return $response; }
public function actionIndex() { $model = new EmployeeAttendance(); $empModel = new Employee(); $empList = $empModel->getEmployeeList(); $todaysList = $model->getTodaysList(); return $this->render('index', ['model' => $model, 'empList' => $empList, 'todaysList' => $todaysList]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $wherelist1 = ''; $wherelist2 = ''; if (isset($params['from_date']) && !empty($params['from_date'])) { $from_date = $params['from_date']; $wherelist1 = 'register_date >= "' . $from_date . '"'; } if (isset($params['to_date']) && !empty($params['to_date'])) { $to_date = $params['to_date']; $wherelist2 = 'register_date <= "' . $to_date . '"'; } $query = Employee::find(); $query = $query->select(['*', 'is_assigned' => '(CASE WHEN employee_id IN (SELECT employee_id from wolf_job_schedule) THEN 1 ELSE 0 END)']); if ($wherelist1 != "") { $query = $query->andWhere($wherelist1); } if ($wherelist2 != "") { $query = $query->andWhere($wherelist2); } $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['register_date' => SORT_DESC, 'employee_id' => SORT_DESC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['employee_id' => $this->employee_id, 'company_id' => $this->company_id, 'dob' => $this->dob, 'age' => $this->age, 'highest_educate' => $this->highest_educate, 'educate_from' => $this->educate_from, 'educate_to' => $this->educate_to, 'student_pass_expiry' => $this->student_pass_expiry, 'suspended' => $this->suspended, 'register_date' => $this->register_date]); $query->andFilterWhere(['like', 'fullname', $this->fullname])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'NRIC', $this->NRIC])->andFilterWhere(['like', 'passport_no', $this->passport_no])->andFilterWhere(['like', 'pob', $this->pob])->andFilterWhere(['like', 'citizenship', $this->citizenship])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'race', $this->race])->andFilterWhere(['like', 'mobiletel', $this->mobiletel])->andFilterWhere(['like', 'hometel', $this->hometel])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'referee', $this->referee])->andFilterWhere(['like', 'educate_level', $this->educate_level])->andFilterWhere(['like', 'school', $this->school])->andFilterWhere(['like', 'course', $this->course])->andFilterWhere(['like', 'contact_name', $this->contact_name])->andFilterWhere(['like', 'contact_mobiletel', $this->contact_mobiletel])->andFilterWhere(['like', 'contact_hometel', $this->contact_hometel])->andFilterWhere(['like', 'contact_relationship', $this->contact_relationship])->andFilterWhere(['like', 'contact_address', $this->contact_address])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'signature', $this->signature])->andFilterWhere(['like', 'profile_image', $this->profile_image])->andFilterWhere(['like', 'NRIC_front', $this->NRIC_front])->andFilterWhere(['like', 'NRIC_back', $this->NRIC_back]); return $dataProvider; }
/** * Save a model with it's relations. * * @param $data * @param null $id * * @return static */ public static function save($data, $id = null) { if ($id) { $employee = Employee::findOrFail($id); $employee->fill($data); } else { $employee = Employee::create($data); } Address::whereEmployeeId($employee->id)->delete(); // flush Course::whereEmployeeId($employee->id)->delete(); foreach (array_get($data, 'address', []) as $key => $d) { if (empty($d['city']) && empty($d['street']) && empty($d['number'])) { continue; } $address = new Address($d); $address->employee_id = $employee->id; $address->save(); } foreach (array_get($data, 'course', []) as $key => $d) { if (empty($d['title']) && empty($d['start']) && empty($d['end'])) { continue; } $course = new Course($d); $course->employee_id = $employee->id; $course->save(); } $employee->save(); return $employee; }
/** * @return array * handel search conditions */ function handel_search() { $query = Schedule::find(); switch ($_REQUEST['st']) { case 1: $_REQUEST['search_input'] ? $arr['employee_id'] = Employee::findOne(['name' => $_REQUEST['search_input']])->id : ''; //search employee name break; case 2: //($_REQUEST['search_input'])?$arr['mobile']=$_REQUEST['search_input']:''; $_REQUEST['search_input'] ? $condition['mobile'] = $_REQUEST['search_input'] : ''; break; default: } $arr['agency_id'] = Yii::$app->user->identity->id; $query->where($arr); if ($_REQUEST['st']) { //($_REQUEST['status'])?$arr['job_id']=PostJob::findOne(['job_status'=>$_REQUEST['status']])->id:''; //search job status // ($_REQUEST['service_type'])?$arr['job_id']=$_REQUEST['service_type']:''; //search service_type $_REQUEST['status'] ? $condition['job_status'] = $_REQUEST['status'] : ''; $_REQUEST['service_type'] ? $condition['service_type'] = $_REQUEST['service_type'] : ''; $res = PostJob::find()->where($condition)->all(); if (count($res) > 0) { foreach ($res as $k => $v) { $ids[] = $v->id; } $query->andWhere(['in', 'job_id', $ids]); } else { $query->andWhere(['job_id' => '-1']); } } return $query; }
public function post(Request $request) { $rules = array('datetime' => 'required', 'txncode' => 'required', 'entrytype' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { $respone = array('code' => '400', 'status' => 'error', 'message' => 'Error on validation'); } else { $employee = Employee::with('branch')->where('rfid', '=', $request->input('rfid'))->get(); if (!isset($employee[0])) { // employee does not exist having the RFID submitted $respone = array('code' => '401', 'status' => 'error', 'message' => 'Invalid RFID: ' . $request->input('rfid'), 'data' => ''); } else { $timelog = new Timelog(); //$timelog->employeeid = $request->get('employeeid'); $timelog->employeeid = $employee[0]->id; $timelog->datetime = $request->input('datetime'); $timelog->txncode = $request->input('txncode'); $timelog->entrytype = $request->input('entrytype'); //$timelog->terminalid = $request->get('terminalid'); $timelog->terminal = gethostname(); $timelog->id = strtoupper(Timelog::get_uid()); if ($timelog->save()) { $respone = array('code' => '200', 'status' => 'success', 'message' => 'Record saved!'); $datetime = explode(' ', $timelog->datetime); $txncode = $timelog->txncode == 'to' ? 'Time Out' : 'Time In'; $data = array('empno' => $employee[0]->code, 'lastname' => $employee[0]->lastname, 'firstname' => $employee[0]->firstname, 'middlename' => $employee[0]->middlename, 'position' => $employee[0]->position, 'date' => $datetime[0], 'time' => $datetime[1], 'txncode' => $timelog->txncode, 'txnname' => $txncode, 'branch' => $employee[0]->branch->code, 'timelogid' => $timelog->id); $respone['data'] = $data; } else { $respone = array('code' => '400', 'status' => 'error', 'message' => 'Error on saving locally!'); } } } return json_encode($respone); }
/** * Finds user by [[NRIC]] * * @return User|null */ public function getEmployee() { if ($this->_employee === false) { $this->_employee = Employee::findByNRIC($this->NRIC); } return $this->_employee; }
/** * O método precisa informar uma lista de produtos * @return {view} */ public function create() { $stocks = Stock::all(); $customers = Customer::all(); $employees = Employee::all(); return view('pages.new_sale', ['stocks' => $stocks, 'customers' => $customers, 'employees' => $employees]); }
public function checkName($attribute, $params) { $employee = Employee::find()->where(['name' => $this->name])->one(); if (count($employee) <= 0) { $this->addError('name', '员工不存在'); } }
/** * Display all EmployeeDocuments * * @param search, skip, take * @return JSend Response */ public function index($org_id = null, $employ_id = null) { $employee = \App\Models\Employee::organisationid($org_id)->id($employ_id)->first(); if (!$employee) { return new JSend('error', (array) Input::all(), 'Karyawan tidak valid.'); } $result = \App\Models\EmploymentDocument::personid($employ_id); if (Input::has('search')) { $search = Input::get('search'); foreach ($search as $key => $value) { switch (strtolower($key)) { default: # code... break; } } } $count = $result->count(); if (Input::has('skip')) { $skip = Input::get('skip'); $result = $result->skip($skip); } if (Input::has('take')) { $take = Input::get('take'); $result = $result->take($take); } $result = $result->with(['document', 'documentdetails', 'documentdetails.template'])->get()->toArray(); return new JSend('success', (array) ['count' => $count, 'data' => $result]); }
/** * observe Employee event saving * 1. check need rehash * 2. auto add last password updated at * 3. unique nik * 4. unique username * 5. act, accept or refuse * * @param $model * @return bool */ public function saving($model) { $errors = new MessageBag(); //1. check need rehash if (Hash::needsRehash($model->password)) { $model->password = bcrypt($model->password); } //2. auto add last password updated at if (isset($model->getDirty()['last_password_updated_at'])) { $model->last_password_updated_at = Carbon::now()->format('Y-m-d H:i:s'); } if (is_null($model->id)) { $id = 0; } else { $id = $model->id; } //3. unique nik $other_employee = Employee::nik($model->uniqid)->notid($id)->first(); if ($other_employee) { $errors->add('Employee', 'NIK sudah terdaftar'); } //4. unique username $other_employee = Employee::username($model->uniqid)->notid($id)->first(); if ($other_employee) { $errors->add('Employee', 'Username sudah terdaftar'); } if ($errors->count()) { $model['errors'] = $errors; return false; } return true; }
public function postLogin(Request $request) { $this->validate($request, ['username' => 'required', 'password' => 'required']); $credentials = $request->only('username', 'password', 'active'); $employee = Employee::where('username', $credentials['username'])->where('active', true)->first(); if ($employee != null && password_verify($credentials['password'], $employee->password)) { if (!$employee->isadmin) { if (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } else { $ip = getenv('REMOTE_ADDR'); } $host = gethostbyaddr($ip); $ipAddress = 'Address : ' . $ip . ' Host : ' . $host; $count = Ipaddress::where('ip', $ip)->count(); $today = date("Y-m-d"); if ($count == 0 || $employee->loginstartdate == null || $today < date('Y-m-d', strtotime($employee->loginstartdate)) || $employee->loginenddate != null && $today > date('Y-m-d', strtotime($employee->loginenddate))) { return view('errors.permissiondenied', ['ipAddress' => $ipAddress]); } if ($employee->branchid == null) { return redirect($this->loginPath())->withInput($request->only('username', 'remember'))->withErrors(['username' => 'บัญชีเข้าใช้งานของคุณยังไม่ได้ผูกกับสาขา โปรดติดต่อหัวหน้า หรือผู้ดูแล']); } } if ($this->auth->attempt($credentials, $request->has('remember'))) { return redirect()->intended($this->redirectPath()); } } else { return redirect($this->loginPath())->withInput($request->only('username', 'remember'))->withErrors(['username' => $this->getFailedLoginMessage()]); } }
public function create() { $current_date = strtotime(date('d-m-Y')); $payments = Wage::where('employee_type', '=', Config::get('common.employee_type.Daily Worker'))->where('payment_date', '=', $current_date)->get(['employee_id'])->toArray(); $emp = array_values(array_column($payments, 'employee_id')); $employees = Employee::where('employee_type', '=', Config::get('common.employee_type.Daily Worker'))->whereNotIn('id', $emp)->with('designation')->get(); return view('payrolls.dailyWagePayment.create')->with(compact('employees')); }
/** * Finds the Employee model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Employee the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Employee::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
function findBy($field, $kwari, array $cols = []) { $q = Employee::where($field, $kwari); if ($cols) { $q->select($cols); } return $q->first(); }
public function create() { $types = StockType::getType(); $employees = Employee::all(); $products = Product::all(); $params = ['types' => $types, 'employees' => $employees, 'products' => $products]; return view('pages.new_stock', $params); }
private function empGrpByDept() { $depts = [['name' => 'Dining', 'employees' => [], 'deptid' => ['75B34178674011E596ECDA40B3C0AA12', '201E68D4674111E596ECDA40B3C0AA12']], ['name' => 'Kitchen', 'employees' => [], 'deptid' => ['71B0A2D2674011E596ECDA40B3C0AA12']]]; for ($i = 0; $i <= 1; $i++) { $employees = Employee::with('position')->select('lastname', 'firstname', 'positionid', 'employee.id')->join('position', 'position.id', '=', 'employee.positionid')->where('branchid', $this->branchid)->whereIn('deptid', $depts[$i]['deptid'])->orderBy('position.ordinal', 'ASC')->get(); $depts[$i]['employees'] = $employees; } return $depts; }
public function actionIndex() { $projectModel = new Project(); $empModel = new Employee(); $projectPaymentModel = new ProjectPayment(); $empList = $empModel->getEmployeeList(); //$projectList = $projectModel->getProjectList(); $projectList = Project::find(); $countProjestQuery = clone $projectList; $projectPages = new Pagination(['totalCount' => $countProjestQuery->count(), 'pageSize' => 10]); $projectList = $projectList->offset($projectPages->offset)->limit(10)->all(); //$projectPaymentList = $projectPaymentModel->getPaymentList(); $projectPaymentList = ProjectPayment::find(); $countProjectPaymentQuery = clone $projectPaymentList; $projectPaymentPages = new Pagination(['totalCount' => $countProjectPaymentQuery->count(), 'pageSize' => 10]); $projectPaymentList = $projectPaymentList->offset($projectPaymentPages->offset)->limit(10)->all(); return $this->render('index', ['projectModel' => $projectModel, 'projectPaymentModel' => $projectPaymentModel, 'empList' => $empList, 'projectList' => $projectList, 'projectPaymentList' => $projectPaymentList, 'projectPages' => $projectPages, 'projectPaymentPages' => $projectPaymentPages]); }
private function updateId() { $employees = Employee::all(); foreach ($employees as $employee) { $new = Employee::find($employee->id); $new->code = str_pad($new->code, 6, '0', STR_PAD_LEFT); //$new->id = Employee::get_uid(); $new->save(); } }
public function getByField($field, $value) { $employee = Employee::with('position')->where($field, '=', $value)->first(); if ($employee) { $respone = array('code' => '200', 'status' => 'success', 'message' => 'Hello ' . $employee->firstname . '=)', 'data' => $employee->toArray()); } else { $respone = array('code' => '404', 'status' => 'danger', 'message' => 'Invalid RFID! Record no found.', 'data' => ''); } return $respone; }
/** * Create a new controller instance. * * @return void */ public function index(Request $request) { $email = Option::where('key', 'contact.email')->first()->value; $phone = Option::where('key', 'contact.phone')->first()->value; $slogan = Option::where('key', 'site.slogan')->first()->value; $description = Option::where('key', 'site.description')->first()->value; $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value); $data = array('photos' => Photo::orderBy('sort_order')->get(), 'employees' => Employee::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'slogan' => $slogan, 'description' => $description, 'social_links' => $social_links); return view('about', $data); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $rules = ['id_number' => 'required|numeric', 'email' => 'required|email|unique:users,email', 'first_name' => 'required|max:255', 'middle_name' => 'max:255', 'last_name' => 'required|max:255', 'sex' => 'required|in:Male,Female', 'birthday' => 'required|date', 'shift_id' => 'required|numeric', 'group_id' => 'required|numeric']; // update mode $e = Employee::with('user')->find(Input::get('empId')); if ($e && $e->user) { $rules['email'] = $rules['email'] . ',' . $e->user->id; } return $rules; }
public function index() { if (!$this->hasPermission($this->menuPermissionName)) { return view($this->viewPermissiondeniedName); } $provinces = Province::whereHas('branchs', function ($q) { $q->where('isheadquarter', true); })->orderBy('name', 'asc')->get(['id', 'name']); $provinceselectlist = array(); array_push($provinceselectlist, ':เลือกจังหวัด'); foreach ($provinces as $item) { array_push($provinceselectlist, $item->id . ':' . $item->name); } if (Auth::user()->isadmin) { $customers = Customer::has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']); } else { $customers = Customer::where('provinceid', Auth::user()->provinceid)->has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']); } $customerselectlist = array(); foreach ($customers as $item) { array_push($customerselectlist, $item->id . ':' . $item->title . ' ' . $item->firstname . ' ' . $item->lastname); } if (Auth::user()->isadmin) { $cars = Car::has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']); } else { $cars = Car::where('provinceid', Auth::user()->provinceid)->has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']); } $carselectlist = array(); array_push($carselectlist, ':เลือกรถ'); foreach ($cars as $item) { array_push($carselectlist, $item->id . ':' . $item->chassisno . '/' . $item->engineno); } if (Auth::user()->isadmin) { $carpreemptions = CarPreemption::has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']); } else { $carpreemptions = CarPreemption::where('provinceid', Auth::user()->provinceid)->has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']); } $carpreemptionselectlist = array(); array_push($carpreemptionselectlist, ':เลือกการจอง'); foreach ($carpreemptions as $item) { $buyercustomer = Customer::find($item->buyercustomerid); $buyercustomername = $buyercustomer->title . ' ' . $buyercustomer->firstname . ' ' . $buyercustomer->lastname; $salesmanemployee = Employee::find($item->salesmanemployeeid); $salesmanemployeename = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname; array_push($carpreemptionselectlist, $item->id . ':' . str_pad($item->bookno . '/' . $item->no, strlen($item->bookno . '/' . $item->no) + 15, " ") . str_pad($buyercustomername, strlen($buyercustomername) + 15, " ") . $salesmanemployeename); } $defaultProvince = ''; if (Auth::user()->isadmin == false) { $defaultProvince = Auth::user()->provinceid; } return view('redlabel', ['provinceselectlist' => implode(";", $provinceselectlist), 'customerselectlist' => implode(";", $customerselectlist), 'carselectlist' => implode(";", $carselectlist), 'carpreemptionselectlist' => implode(";", $carpreemptionselectlist), 'defaultProvince' => $defaultProvince]); }
public function index() { /*$branchs = Branch::orderBy('name', 'asc')->get(['id', 'name']); $branchselectlist = array(); array_push($branchselectlist,':เลือกสาขา'); foreach($branchs as $item){ array_push($branchselectlist,$item->id.':'.$item->name); }*/ $provinces = Province::orderBy('name', 'asc')->get(['id', 'name']); $provinceselectlist = array(); array_push($provinceselectlist, ':เลือกจังหวัด'); foreach ($provinces as $item) { array_push($provinceselectlist, $item->id . ':' . $item->name); } $occupations = Occupation::orderBy('name', 'asc')->get(['id', 'name']); $occupationselectlist = array(); array_push($occupationselectlist, ':เลือกอาชีพ'); foreach ($occupations as $item) { array_push($occupationselectlist, $item->id . ':' . $item->name); } $amphurids = Customer::distinct()->lists('amphurid'); $amphurs = Amphur::whereIn('id', $amphurids)->orderBy('name', 'asc')->get(['id', 'name']); $amphurselectlist = array(); array_push($amphurselectlist, ':เลือกเขต/อำเภอ'); foreach ($amphurs as $item) { array_push($amphurselectlist, $item->id . ':' . $item->name); } $districtids = Customer::distinct()->lists('districtid'); $districts = District::whereIn('id', $districtids)->orderBy('name', 'asc')->get(['id', 'name']); $districtselectlist = array(); array_push($districtselectlist, ':เลือกตำบล/แขวง'); foreach ($districts as $item) { array_push($districtselectlist, $item->id . ':' . $item->name); } $employees = Employee::all(['id', 'firstname', 'lastname']); $employeeselectlist = array(); array_push($employeeselectlist, ':เลือกพนักงาน'); foreach ($employees as $emp) { array_push($employeeselectlist, $emp->id . ':' . $emp->firstname . ' ' . $emp->lastname); } $carmodels = CarModel::all(['id', 'name']); $carmodelselectlist = array(); array_push($carmodelselectlist, ':เลือกแบบ'); foreach ($carmodels as $cm) { array_push($carmodelselectlist, $cm->id . ':' . $cm->name); } $defaultProvince = ''; if (Auth::user()->isadmin == false) { $defaultProvince = Auth::user()->branchid == null ? '' : Auth::user()->branch->provinceid; } return view('customer', ['provinceselectlist' => implode(";", $provinceselectlist), 'amphurselectlist' => implode(";", $amphurselectlist), 'districtselectlist' => implode(";", $districtselectlist), 'carmodelselectlist' => implode(";", $carmodelselectlist), 'employeeselectlist' => implode(";", $employeeselectlist), 'occupationselectlist' => implode(";", $occupationselectlist), 'defaultProvince' => $defaultProvince]); }
private function getEmployeeDtr(Request $request, $employeeid) { $employee = Employee::findOrFail($employeeid); foreach ($this->dr->dateInterval() as $key => $date) { $timesheets[$key]['date'] = $date; $timelogs = $this->timelog->skipCriteria()->getRawEmployeeTimelog($employeeid, $date, $date)->all(); //array_push($timesheets[$key]['timelog'], $this->timelog->generateTimesheet($employee->id, $date, collect($timelogs))); $timesheets[$key]['timelog'] = $this->timelog->generateTimesheet($employee->id, $date, collect($timelogs)); } $header = new StdClass(); $header->totalWorkedHours = collect($timesheets)->pluck('timelog')->sum('workedHours'); return $this->setViewWithDR(view('timesheet.employee-dtr')->with('timesheets', $timesheets)->with('employee', $employee)->with('header', $header)->with('dr', $this->dr)); }
public function edit($id) { $e = $this->empDto->findById($id); if ($e) { $sup = Employee::where('id', $e->supervisor_id)->select(['id', 'first_name', 'last_name', 'middle_name'])->first(); if ($sup) { $e->supervisor = ['id' => $sup->id, 'full_name' => $sup->last_name . ', ' . $sup->first_name . ' ' . $sup->middle_name]; } return view('admin.emp.edit', ['employee' => $e]); } else { abort(404); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Employee::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'bod' => $this->bod]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Employee::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'sex' => $this->sex, 'birthdate' => $this->birthdate, 'tumbon' => $this->tumbon, 'ampur' => $this->ampur, 'chw' => $this->chw, 'department_id' => $this->department_id, 'comein' => $this->comein, 'status' => $this->status]); $query->andFilterWhere(['like', 'cid', $this->cid])->andFilterWhere(['like', 'pname', $this->pname])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'education', $this->education])->andFilterWhere(['like', 'ability', $this->ability])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'avatar', $this->avatar]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Employee::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'sex' => $this->sex, 'age' => $this->age, 'salary' => $this->salary, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'remove_at' => $this->remove_at, 'status' => $this->status, 'uid' => Yii::$app->user->id]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'tell', $this->tell])->andFilterWhere(['like', 'sfzid', $this->sfzid])->andFilterWhere(['like', 'sfzaddr', $this->sfzaddr])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'remark', $this->remark]); return $dataProvider; }
public function byDepartment(Request $request) { $department = new Department(); $d1 = array_flatten($department->whereNotIn('code', ['KIT'])->orderBy('code', 'DESC')->get(['id'])->toArray()); $depts = [['name' => 'Dining', 'employees' => [], 'deptid' => $d1], ['name' => 'Kitchen', 'employees' => [], 'deptid' => ['71B0A2D2674011E596ECDA40B3C0AA12']]]; for ($i = 0; $i <= 1; $i++) { $employees = Employee::with('position')->select('lastname', 'firstname', 'positionid', 'employee.id')->join('position', 'position.id', '=', 'employee.positionid')->where('branchid', $request->user()->branchid)->whereIn('deptid', $depts[$i]['deptid'])->orderBy('employee.lastname', 'ASC')->orderBy('employee.firstname', 'ASC')->get(); $depts[$i]['employees'] = $employees; } return $depts; }