コード例 #1
0
 public function manualPost(Request $request)
 {
     $rules = array('employeeid' => 'required|max:32|min:32', 'date' => 'required|date', 'time' => 'required');
     $messages = ['employeeid.required' => 'Employee is required.', 'employeeid.max' => 'Employee is required..', 'employeeid.min' => 'Employee is required...', 'time.date_format' => 'The time does not match the format HH:MM. (e.g 02:30, 17:00)'];
     $validator = Validator::make($request->all(), $rules, $messages);
     if ($validator->fails()) {
         return redirect('/timelog/add')->withErrors($validator);
     }
     try {
         $datetime = Carbon::parse($request->input('date') . ' ' . $request->input('time'));
     } catch (\Exception $e) {
         return redirect('/timelog/add')->withErrors(['message' => 'The time does not match the format 12 Hrs (01:30 PM) or 24 Hrs (13:30)']);
     }
     $employee = Employee::where('id', $request->input('employeeid'))->where('branchid', $request->user()->branchid)->first();
     if (is_null($employee)) {
         return redirect('/timelog/add')->withErrors(['message' => 'Employee not found on this branch.']);
     }
     $attributes = ['employeeid' => $employee->id, 'branchid' => $this->_branchid, 'datetime' => $datetime->format('Y-m-d H:i') . ':00', 'txncode' => $request->input('txncode'), 'entrytype' => 2, 'terminalid' => clientIP()];
     return $timelog = $this->repository->create($attributes);
     if (is_null($timelog)) {
         return redirect('/timelog/add')->withErrors(['message' => 'Unable to save timelog.']);
     } else {
         $uri = is_null(request()->input('ref')) ? '/timelog/add' : '/timesheet';
         return redirect($uri)->with('alert-success', 'Timelog saved!');
     }
     return $timelog;
 }
コード例 #2
0
 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()]);
     }
 }
コード例 #3
0
 public function search(Request $request, $param1 = null)
 {
     $limit = empty($request->input('maxRows')) ? 10 : $request->input('maxRows');
     $res = Employee::where('branchid', $request->user()->branchid)->where(function ($query) use($request) {
         $query->orWhere('code', 'like', '%' . $request->input('q') . '%')->orWhere('lastname', 'like', '%' . $request->input('q') . '%')->orWhere('firstname', 'like', '%' . $request->input('q') . '%')->orWhere('middlename', 'like', '%' . $request->input('q') . '%')->orWhere('rfid', 'like', '%' . $request->input('q') . '%');
     })->take($limit)->get();
     return $res;
 }
コード例 #4
0
 function findBy($field, $kwari, array $cols = [])
 {
     $q = Employee::where($field, $kwari);
     if ($cols) {
         $q->select($cols);
     }
     return $q->first();
 }
コード例 #5
0
 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'));
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 public function getReport(Request $request)
 {
     $customers = Customer::where('status', 1)->lists('name', 'id');
     $employees = Employee::where('status', 1)->lists('name', 'id');
     $suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
     $cashInHand = DB::table('workspace_ledgers')->where(['account_code' => 11000, 'balance_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_current_financial_year()])->sum('balance');
     $sales = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name', 'sales_order.customer_id', 'sales_order.customer_type')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->join('sales_order', 'sales_order.id', '=', 'general_journals.reference_id')->where(['transaction_type' => Config::get('common.transaction_type.sales'), 'account_code' => 31000, 'year' => CommonHelper::get_current_financial_year(), 'general_journals.status' => 1])->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
     $salesReturns = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name', 'sales_order.customer_id', 'sales_order.customer_type')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->join('sales_order', 'sales_order.id', '=', 'general_journals.reference_id')->where(['transaction_type' => Config::get('common.transaction_type.sales_return'), 'account_code' => 32000, 'year' => CommonHelper::get_current_financial_year(), 'general_journals.status' => 1])->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
     $expenses = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->where('general_journals.account_code', 'like', '2%')->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
     $sales = json_decode(json_encode($sales), true);
     $salesReturns = json_decode(json_encode($salesReturns), true);
     $expenses = json_decode(json_encode($expenses), true);
     $ajaxView = view('reports.cashFlow.view', compact('sales', 'salesReturns', 'expenses', 'customers', 'employees', 'suppliers', 'cashInHand'))->render();
     return response()->json($ajaxView);
 }
コード例 #8
0
 public function log(Request $request, $code)
 {
     header('Access-Control-Allow-Origin:*');
     # Check if there is a running log
     $current = Log::where('employee_code', $code)->where('image_out', '')->first();
     $image = $request->get('image');
     if (empty($current)) {
         # Create time in
         $log = new Log(['image_in' => $image]);
         Employee::where('code', $code)->first()->logs()->save($log);
     } else {
         # Create time out
         $log = Log::where('id', $current->id)->first();
         $log->image_out = $image;
         $log->save();
     }
     $this->dispatch(new NotifyJob($log));
     return $log;
 }
コード例 #9
0
ファイル: AjaxController.php プロジェクト: saj696/pipe
 public function getDailyWorkerList(Request $request)
 {
     $current_date = strtotime($request->payment_date);
     $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();
     $ajaxView = view('payrolls.dailyWagePayment.ajaxView')->with(compact('employees'))->render();
     return response()->json($ajaxView);
 }
コード例 #10
0
 public function view($id)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $model = CarPreemption::find($id);
     $bookingcustomer = Customer::find($model->bookingcustomerid);
     $model->bookingcustomername = $bookingcustomer->title . ' ' . $bookingcustomer->firstname . ' ' . $bookingcustomer->lastname;
     $model->provincebranchid = $bookingcustomer->provinceid;
     $model->bookingcustomeraddress = $bookingcustomer->address;
     $model->bookingcustomerprovinceid = $bookingcustomer->addprovinceid;
     $model->bookingcustomeramphurid = $bookingcustomer->amphurid;
     $model->bookingcustomerdistrictid = $bookingcustomer->districtid;
     $model->bookingcustomerzipcode = $bookingcustomer->zipcode;
     $model->bookingcustomerphone1 = $bookingcustomer->phone1;
     $model->bookingcustomerphone2 = $bookingcustomer->phone2;
     $model->bookingcustomeroccupationid = $bookingcustomer->occupationid;
     if ($bookingcustomer->birthdate != null && $bookingcustomer->birthdate != '') {
         $model->bookingcustomerbirthdate = date('d-m-Y', strtotime($bookingcustomer->birthdate));
     }
     if ($model->bookingcustomerid != $model->buyercustomerid) {
         $buyercustomer = Customer::find($model->buyercustomerid);
         $model->buyercustomeraddress = $buyercustomer->address;
         $model->buyercustomerprovinceid = $buyercustomer->addprovinceid;
         $model->buyercustomeramphurid = $buyercustomer->amphurid;
         $model->buyercustomerdistrictid = $buyercustomer->districtid;
         $model->buyercustomerzipcode = $buyercustomer->zipcode;
         $model->buyercustomerphone1 = $buyercustomer->phone1;
         $model->buyercustomerphone2 = $buyercustomer->phone2;
         $model->buyercustomeroccupationid = $buyercustomer->occupationid;
         if ($buyercustomer->birthdate != null && $buyercustomer->birthdate != '') {
             $model->buyercustomerbirthdate = date('d-m-Y', strtotime($buyercustomer->birthdate));
         }
     }
     $provincebranchs = Province::whereHas('branchs', function ($q) {
         $q->where('isheadquarter', true);
     })->orderBy('name', 'asc')->get(['id', 'name']);
     $provincebranchselectlist = array();
     foreach ($provincebranchs as $item) {
         $provincebranchselectlist[$item->id] = $item->name;
     }
     $customerselectlist = array();
     $customerselectlist[$bookingcustomer->id] = $bookingcustomer->title . ' ' . $bookingcustomer->firstname . ' ' . $bookingcustomer->lastname;
     if ($model->bookingcustomerid != $model->buyercustomerid) {
         $customerselectlist[$buyercustomer->id] = $buyercustomer->title . ' ' . $buyercustomer->firstname . ' ' . $buyercustomer->lastname;
     }
     $provinces = Province::orderBy('name', 'asc')->get(['id', 'name']);
     $provinceselectlist = array();
     $provinceselectlist[null] = 'เลือกจังหวัด';
     foreach ($provinces as $item) {
         $provinceselectlist[$item->id] = $item->name;
     }
     $bookingcustomeramphurselectlist = array();
     $bookingcustomeramphurselectlist[null] = 'เลือกเขต/อำเภอ';
     if ($model->bookingcustomeramphurid != null && $model->bookingcustomeramphurid != '') {
         $item = Amphur::find($model->bookingcustomeramphurid);
         $bookingcustomeramphurselectlist[$item->id] = $item->name;
     }
     $buyercustomeramphurselectlist = array();
     $buyercustomeramphurselectlist[null] = 'เลือกเขต/อำเภอ';
     if ($model->bookingcustomerid != $model->buyercustomerid && $model->buyercustomeramphurid != null && $model->buyercustomeramphurid != '') {
         $item = Amphur::find($model->buyercustomeramphurid);
         $buyercustomeramphurselectlist[$item->id] = $item->name;
     }
     $bookingcustomerdistrictselectlist = array();
     $bookingcustomerdistrictselectlist[null] = 'เลือกแขวง/ตำบล';
     if ($model->bookingcustomerdistrictid != null && $model->bookingcustomerdistrictid != '') {
         $item = District::find($model->bookingcustomerdistrictid);
         $bookingcustomerdistrictselectlist[$item->id] = $item->name;
     }
     $buyercustomerdistrictselectlist = array();
     $buyercustomerdistrictselectlist[null] = 'เลือกแขวง/ตำบล';
     if ($model->bookingcustomerid != $model->buyercustomerid && $model->buyercustomerdistrictid != null && $model->buyercustomerdistrictid != '') {
         $item = District::find($model->buyercustomerdistrictid);
         $buyercustomerdistrictselectlist[$item->id] = $item->name;
     }
     $occupations = Occupation::orderBy('name', 'asc')->get(['id', 'name']);
     $occupationselectlist = array();
     $occupationselectlist[null] = 'เลือกอาชีพ';
     foreach ($occupations as $item) {
         $occupationselectlist[$item->id] = $item->name;
     }
     $carmodelselectlist = array();
     $item = CarModel::find($model->carmodelid);
     $carmodelselectlist[$item->id] = $item->name;
     $carsubmodelselectlist = array();
     $item = CarSubModel::find($model->carsubmodelid);
     $carsubmodelselectlist[$item->id] = $item->name;
     $colorselectlist = array();
     $item = Color::find($model->colorid);
     $colorselectlist[$item->id] = $item->code . ' - ' . $item->name;
     $registerprovinceselectlist = array();
     if ($model->registerprovinceid != null && $model->registerprovinceid != '') {
         $item = Province::find($model->registerprovinceid);
         $registerprovinceselectlist[$item->id] = $item->name;
     }
     $oldcarbrandselectlist = array();
     $oldcarbrandselectlist[null] = 'เลือกยี่ห้อรถ';
     if ($model->oldcarbrandid != null) {
         $item = CarBrand::find($model->oldcarbrandid);
         $oldcarbrandselectlist[$item->id] = $item->name;
     }
     $oldcarmodelselectlist = array();
     $oldcarmodelselectlist[null] = 'เลือกแบบ';
     if ($model->oldcarmodelid != null) {
         $item = CarModel::find($model->oldcarmodelid);
         $oldcarmodelselectlist[$item->id] = $item->name;
     }
     if (Auth::user()->isadmin) {
         $saleemployees = Employee::where('departmentid', 6)->where('teamid', '<>', 1)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $saleemployees = Employee::where('provinceid', Auth::user()->provinceid)->where('departmentid', 6)->where('teamid', '<>', 1)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $saleemployeeselectlist = array();
     $saleemployeeselectlist[null] = 'เลือกพนักงาน';
     foreach ($saleemployees as $item) {
         $saleemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     }
     if (Auth::user()->isadmin) {
         $salemanageremployees = Employee::where('departmentid', 6)->where('teamid', 1)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $salemanageremployees = Employee::where('provinceid', Auth::user()->provinceid)->where('departmentid', 6)->where('teamid', 1)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $salemanageremployeeselectlist = array();
     $salemanageremployeeselectlist[null] = 'เลือกพนักงาน';
     foreach ($salemanageremployees as $item) {
         $salemanageremployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     }
     if (Auth::user()->isadmin) {
         $approveremployees = Employee::where('departmentid', 5)->orWhere(function ($query) {
             $query->where('departmentid', 6)->where('teamid', 1);
         })->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $approveremployees = Employee::where('provinceid', Auth::user()->provinceid)->where(function ($query) {
             $query->where('departmentid', 5)->orWhere(function ($query) {
                 $query->where('departmentid', 6)->where('teamid', 1);
             });
         })->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $approveremployeeselectlist = array();
     $approveremployeeselectlist[null] = 'เลือกพนักงาน';
     foreach ($approveremployees as $item) {
         $approveremployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     }
     $giveaways = Giveaway::orderBy('name', 'asc')->orderBy('saleprice', 'asc')->get(['id', 'name', 'saleprice']);
     $giveawayselectlist = array();
     array_push($giveawayselectlist, ':เลือกของแถม');
     foreach ($giveaways as $ct) {
         array_push($giveawayselectlist, $ct->id . ':' . $ct->name . ' (' . $ct->saleprice . ' บาท)');
     }
     $giveawayFrees = CarPreemptionGiveaway::where('free', true)->where('carpreemptionid', $id)->get(['id', 'giveawayid', 'price']);
     $giveawayFreeDatas = array();
     foreach ($giveawayFrees as $data) {
         $obj = (object) array("id" => $data->id, "giveawayid" => $data->giveawayid, "price" => $data->price);
         array_push($giveawayFreeDatas, $obj);
     }
     $giveawayBuys = CarPreemptionGiveaway::where('free', false)->where('carpreemptionid', $id)->get(['id', 'giveawayid']);
     $giveawayBuyDatas = array();
     foreach ($giveawayBuys as $data) {
         $obj = (object) array("id" => $data->id, "giveawayid" => $data->giveawayid);
         array_push($giveawayBuyDatas, $obj);
     }
     $finacecompanyselectlist = array();
     array_push($finacecompanyselectlist, ':เลือกบริษัท');
     if ($model->purchasetype == 1) {
         $item = FinaceCompany::find($model->finacecompanyid);
         $finacecompanyselectlist[$item->id] = $item->name;
     }
     $interestratetypeselectlist = array();
     array_push($interestratetypeselectlist, ':เลือกประเภทอัตราดอกเบี้ย');
     if ($model->purchasetype == 1) {
         $item = InterestRateType::find($model->interestratetypeid);
         $interestratetypeselectlist[$item->id] = $item->name;
     }
     $priceselectlist = array();
     $item = Pricelist::find($model->pricelistid);
     if ($item->promotion != null && $item->promotion != '') {
         $priceselectlist[$item->id] = $item->sellingpricewithaccessories . ' (' . $item->promotion . ')';
     } else {
         $priceselectlist[$item->id] = $item->sellingpricewithaccessories;
     }
     $model->date = date('d-m-Y', strtotime($model->date));
     $model->datewantgetcar = date('d-m-Y', strtotime($model->datewantgetcar));
     $model->approvaldate = date('d-m-Y', strtotime($model->approvaldate));
     if ($model->contractdate != null && $model->contractdate != '') {
         $model->contractdate = date('d-m-Y', strtotime($model->contractdate));
     }
     return view('carpreemptionform', ['oper' => 'view', 'pathPrefix' => '../../', 'carpreemption' => $model, 'carprices' => array(), 'colorprices' => array(), 'provinceregistrationfee' => array(), 'giveawayFreeDatas' => $giveawayFreeDatas, 'giveawayBuyDatas' => $giveawayBuyDatas, 'provincebranchselectlist' => $provincebranchselectlist, 'customerselectlist' => $customerselectlist, 'provinceselectlist' => $provinceselectlist, 'bookingcustomeramphurselectlist' => $bookingcustomeramphurselectlist, 'buyercustomeramphurselectlist' => $buyercustomeramphurselectlist, 'bookingcustomerdistrictselectlist' => $bookingcustomerdistrictselectlist, 'buyercustomerdistrictselectlist' => $buyercustomerdistrictselectlist, 'occupationselectlist' => $occupationselectlist, 'carmodelselectlist' => $carmodelselectlist, 'carsubmodelselectlist' => $carsubmodelselectlist, 'colorselectlist' => $colorselectlist, 'oldcarbrandselectlist' => $oldcarbrandselectlist, 'oldcarmodelselectlist' => $oldcarmodelselectlist, 'giveawayselectlist' => implode(";", $giveawayselectlist), 'saleemployeeselectlist' => $saleemployeeselectlist, 'salemanageremployeeselectlist' => $salemanageremployeeselectlist, 'approveremployeeselectlist' => $approveremployeeselectlist, 'finacecompanyselectlist' => $finacecompanyselectlist, 'interestratetypeselectlist' => $interestratetypeselectlist, 'priceselectlist' => $priceselectlist, 'registerprovinceselectlist' => $registerprovinceselectlist]);
 }
コード例 #11
0
 function save(array $params)
 {
     $response = new ResponseEntity();
     DB::transaction(function () use(&$response, $params) {
         $empId = isset($params['empId']) ? intval($params['empId']) : 0;
         $idNumber = Config::get('hris_system.employee_id_prefix') . $params['id_number'];
         $existingEmp = Employee::with('user')->find($empId);
         // check for duplicate id_number
         $tempEmp = Employee::where('id_number', '=', $idNumber)->first();
         if ($tempEmp) {
             if (!$existingEmp) {
                 // new
                 $response->setMessages(['id_number' => ['Id number is already taken']]);
                 return $response;
             } else {
                 if ($existingEmp && $existingEmp->id != $tempEmp->id) {
                     // update
                     $response->setMessages(['id_number' => ['Id number is already taken']]);
                     return $response;
                 }
             }
         }
         if ($empId > 0 && !$existingEmp) {
             // check when updating
             $response->setMessages(['Employee is not available!']);
             return $response;
         } else {
             // employee user account
             $user = $existingEmp ? $existingEmp->user : new User();
             $user->email = $params['email'];
             if (!$existingEmp) {
                 // for new employee user account
                 $user->password = Hash::make($idNumber);
                 //default password is the ID Number of the employee
                 $user->active = '1';
             }
             $user->save();
             // clear user group
             UserGroup::where('user_id', $user->id)->delete();
             // assign group
             $ug = new UserGroup();
             $ug->user_id = $user->id;
             $ug->group_id = $params['group_id'];
             $ug->save();
             // employee records
             $employee = $existingEmp ? $existingEmp : new Employee();
             $employee->user_id = $user->id;
             $employee->id_number = $idNumber;
             $employee->first_name = $params['first_name'];
             $employee->last_name = $params['last_name'];
             if (isset($params['middle_name'])) {
                 $employee->middle_name = $params['middle_name'];
             }
             if (isset($params['supervisor_id'])) {
                 $employee->supervisor_id = $params['supervisor_id'];
             }
             $employee->sex = $params['sex'];
             $employee->birthday = Carbon::createFromFormat('m/d/Y', $params['birthday']);
             $employee->shift_id = $params['shift_id'];
             $employee->active = $existingEmp ? $existingEmp->active : '1';
             $ok = $employee->save();
             if ($ok) {
                 $response->setSuccess(true);
                 $response->setData(['empId' => $employee->id]);
                 $response->setMessages(['Employee successfully ' . ($existingEmp ? 'saved' : 'created')]);
             } else {
                 $response->setMessages(['Failed to ' . ($existingEmp ? 'save' : 'create') . ' employee!']);
             }
         }
     });
     return $response;
 }
コード例 #12
0
 public function edit($id)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $model = CancelCarPreemption::find($id);
     $carpreemption = CarPreemption::find($model->carpreemptionid);
     $carpreemptionselectlist = array();
     $carpreemptionselectlist[$carpreemption->id] = $carpreemption->bookno . '/' . $carpreemption->no;
     $model->bookno = $carpreemption->bookno;
     $model->no = $carpreemption->no;
     $customer = Customer::find($carpreemption->buyercustomerid);
     $model->customer = $customer->title . ' ' . $customer->firstname . ' ' . $customer->lastname;
     $carmodel = CarModel::find($carpreemption->carmodelid);
     $carsubmodel = CarSubModel::find($carpreemption->carsubmodelid);
     $model->carmodel = $carmodel->name . '/' . $carsubmodel->name;
     $model->carpreemptiondate = date('d-m-Y', strtotime($carpreemption->date));
     $model->cashpledge = $carpreemption->cashpledge;
     if ($model->refunddate != null && $model->refunddate != '') {
         $model->refunddate = date('d-m-Y', strtotime($model->refunddate));
     }
     if ($model->confiscatedate != null && $model->confiscatedate != '') {
         $model->confiscatedate = date('d-m-Y', strtotime($model->confiscatedate));
     }
     $salesmanemployee = Employee::find($carpreemption->salesmanemployeeid);
     $model->salesmanemployee = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname;
     if (Auth::user()->isadmin) {
         $toemployees = Employee::where('departmentid', 5)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $toemployees = Employee::where('provinceid', Auth::user()->provinceid)->where('departmentid', 5)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $toemployeeselectlist = array();
     $toemployeeselectlist[null] = 'เลือกพนักงาน';
     foreach ($toemployees as $item) {
         $toemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     }
     if (Auth::user()->isadmin) {
         $accountandfinanceemployees = Employee::where('departmentid', 4)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $accountandfinanceemployees = Employee::where('provinceid', Auth::user()->provinceid)->where('departmentid', 4)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $accountandfinanceemployeeselectlist = array();
     $accountandfinanceemployeeselectlist[null] = 'เลือกพนักงาน';
     foreach ($accountandfinanceemployees as $item) {
         $accountandfinanceemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     }
     if ($model->salesmanemployeedate != null && $model->salesmanemployeedate != '') {
         $model->salesmanemployeedate = date('d-m-Y', strtotime($model->salesmanemployeedate));
     }
     if ($model->accountemployeedate != null && $model->accountemployeedate != '') {
         $model->accountemployeedate = date('d-m-Y', strtotime($model->accountemployeedate));
     }
     if ($model->financeemployeedate != null && $model->financeemployeedate != '') {
         $model->financeemployeedate = date('d-m-Y', strtotime($model->financeemployeedate));
     }
     if ($model->approversemployeedate != null && $model->approversemployeedate != '') {
         $model->approversemployeedate = date('d-m-Y', strtotime($model->approversemployeedate));
     }
     return view('cancelcarpreemptionform', ['oper' => 'edit', 'pathPrefix' => '../../', 'cancelcarpreemption' => $model, 'carpreemptionselectlist' => $carpreemptionselectlist, 'toemployeeselectlist' => $toemployeeselectlist, 'accountandfinanceemployeeselectlist' => $accountandfinanceemployeeselectlist]);
 }
コード例 #13
0
 public function edit($id)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $model = CarPayment::find($id);
     if (!Auth::user()->isadmin && $model->deliverycarbookno != null && $model->deliverycarbookno != '') {
         return "ไม่สามารถแก้ไขข้อมูลการชำระเงินได้ เนื่องจากมีการส่งรถแล้ว!!";
     }
     $carpreemption = CarPreemption::find($model->carpreemptionid);
     $carpreemptionselectlist = array();
     $carpreemptionselectlist[$carpreemption->id] = $carpreemption->bookno . '/' . $carpreemption->no;
     $model->bookno = $carpreemption->bookno;
     $model->no = $carpreemption->no;
     $model->purchasetype = $carpreemption->purchasetype;
     if ($carpreemption->purchasetype == 0) {
         $purchasetype0 = true;
         $purchasetype1 = false;
     } elseif ($carpreemption->purchasetype == 1) {
         $purchasetype0 = false;
         $purchasetype1 = true;
     }
     if ($carpreemption->carobjectivetype == 0) {
         $carobjectivetype0 = true;
         $carobjectivetype1 = false;
     } elseif ($carpreemption->carobjectivetype == 1) {
         $carobjectivetype0 = false;
         $carobjectivetype1 = true;
     }
     if ($carpreemption->registrationtype == 0) {
         $registrationtype0 = true;
         $registrationtype1 = false;
         $registrationtype2 = false;
     } elseif ($carpreemption->registrationtype == 1) {
         $registrationtype0 = false;
         $registrationtype1 = true;
         $registrationtype2 = false;
     } elseif ($carpreemption->registrationtype == 2) {
         $registrationtype0 = false;
         $registrationtype1 = false;
         $registrationtype2 = true;
     }
     $customer = Customer::find($carpreemption->buyercustomerid);
     $model->customer = $customer->title . ' ' . $customer->firstname . ' ' . $customer->lastname;
     $model->customer2 = $customer->title . ' ' . $customer->firstname . ' ' . $customer->lastname;
     $carmodel = CarModel::find($carpreemption->carmodelid);
     $carsubmodel = CarSubModel::find($carpreemption->carsubmodelid);
     $model->carmodel = $carmodel->name . '/' . $carsubmodel->name;
     $color = Color::find($carpreemption->colorid);
     $model->carcolor = $color->code . ' - ' . $color->name;
     $pricelist = Pricelist::find($carpreemption->pricelistid);
     $model->carprice = $pricelist->sellingpricewithaccessories + $carpreemption->colorprice;
     $carselectlist = array();
     $carselectlist[null] = 'เลือกรถ';
     if (Auth::user()->isadmin) {
         $cars = Car::doesntHave('carPayment')->where('carmodelid', $carpreemption->carmodelid)->where('carsubmodelid', $carpreemption->carsubmodelid)->where('colorid', $carpreemption->colorid)->orWhere(function ($query) use($model) {
             $query->where('id', $model->carid);
         })->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
     } else {
         $cars = Car::where('provinceid', Auth::user()->provinceid)->doesntHave('carPayment')->where('carmodelid', $carpreemption->carmodelid)->where('carsubmodelid', $carpreemption->carsubmodelid)->where('colorid', $carpreemption->colorid)->orWhere(function ($query) use($model) {
             $query->where('id', $model->carid);
         })->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
     }
     foreach ($cars as $item) {
         $carselectlist[$item->id] = $item->chassisno . '/' . $item->engineno;
     }
     $model->installments = $carpreemption->installments;
     $model->interest = $carpreemption->interest;
     if ($carpreemption->purchasetype == 1) {
         $finacecompany = FinaceCompany::find($carpreemption->finacecompanyid);
         $model->finacecompany = $finacecompany->name;
     }
     if ($carpreemption->purchasetype == 0) {
         $model->down = number_format($model->carprice - $carpreemption->discount, 2, '.', '');
         $model->yodjud = number_format(0, 2, '.', '');
         $model->yodjudwithinsurancepremium = number_format(0, 2, '.', '');
         if ($model->overrideopenbill != null && $model->overrideopenbill != '') {
             $model->openbill = $model->overrideopenbill;
         } else {
             $model->openbill = number_format($model->carprice - $carpreemption->discount, 2, '.', '');
         }
         $model->realprice = number_format($model->carprice - $carpreemption->discount, 2, '.', '');
         $model->payinadvanceamount = number_format(0, 2, '.', '');
     } else {
         $model->down = $carpreemption->down;
         $model->yodjud = number_format($model->carprice - $carpreemption->discount - $model->down + $carpreemption->accessories + $model->accessoriesfeeincludeinyodjud, 2, '.', '');
         $model->yodjudwithinsurancepremium = number_format($model->yodjud + $model->insurancepremium, 2, '.', '');
         $model->openbill = number_format($model->yodjud + $model->down, 2, '.', '');
         $model->realprice = number_format($model->carprice - $carpreemption->discount - $carpreemption->subdown, 2, '.', '');
         if ($model->firstinstallmentpay) {
             $model->firstinstallmentpayamount = number_format($model->amountperinstallment, 2, '.', '');
         } else {
             $model->firstinstallmentpayamount = number_format(0, 2, '.', '');
         }
         $model->payinadvanceamount = number_format($model->installmentsinadvance * $model->amountperinstallment, 2, '.', '');
         if ($carpreemption->subsidisefree) {
             $model->subsidise = number_format(0, 2, '.', '');
         } else {
             $model->subsidise = $carpreemption->subsidise;
         }
     }
     $model->accessoriesfee = $carpreemption->accessoriesfee;
     $insurancecompanies = InsuranceCompany::orderBy('name', 'asc')->get(['id', 'name']);
     $insurancecompanyselectlist = array();
     $insurancecompanyselectlist[null] = 'เลือกบริษัท';
     foreach ($insurancecompanies as $item) {
         $insurancecompanyselectlist[$item->id] = $item->name;
     }
     if ($carpreemption->insurancefeefree) {
         $model->insurancefee = number_format(0, 2, '.', '');
     } else {
         $model->insurancefee = $carpreemption->insurancefee;
     }
     if ($carpreemption->compulsorymotorinsurancefeefree) {
         $model->compulsorymotorinsurancefee = number_format(0, 2, '.', '');
     } else {
         $model->compulsorymotorinsurancefee = $carpreemption->compulsorymotorinsurancefee;
     }
     if ($carpreemption->carobjectivetype == 0) {
         $registerprovince = Province::find($carpreemption->registerprovinceid);
         $model->registerprovince = $registerprovince->name;
     } else {
         $model->registerprovince = null;
     }
     $model->registrationtype = $carpreemption->registrationtype;
     if ($carpreemption->registrationfeefree) {
         $model->registrationfee = number_format(0, 2, '.', '');
     } else {
         $model->registrationfee = $carpreemption->registrationfee;
     }
     if ($carpreemption->carobjectivetype == 0) {
         $redlabelhistory = Redlabelhistory::where('carpreemptionid', $carpreemption->id)->first();
         if ($redlabelhistory != null) {
             $redlabel = Redlabel::find($redlabelhistory->redlabelid);
             $model->redlabel = $redlabel->no;
         } else {
             $model->redlabel = "ไม่มีป้าย";
         }
     } else {
         $model->redlabel = null;
     }
     $model->cashpledgeredlabel = $carpreemption->cashpledgeredlabel;
     if ($carpreemption->implementfeefree) {
         $model->implementfee = number_format(0, 2, '.', '');
     } else {
         $model->implementfee = $carpreemption->implementfee;
     }
     $model->giveawaywithholdingtax = $carpreemption->giveawaywithholdingtax;
     $model->otherfee = $carpreemption->otherfee;
     $model->otherfeedetail = $carpreemption->otherfeedetail;
     $model->otherfee2 = $carpreemption->otherfee2;
     $model->otherfeedetail2 = $carpreemption->otherfeedetail2;
     $model->otherfee3 = $carpreemption->otherfee3;
     $model->otherfeedetail3 = $carpreemption->otherfeedetail3;
     if ($model->firstinstallmentpay) {
         $model->total = number_format($model->down + $model->amountperinstallment + $model->payinadvanceamount + $model->accessoriesfeeactuallypaid + $model->insurancefee + $model->compulsorymotorinsurancefee + $model->registrationfee + $model->cashpledgeredlabel + $model->implementfee + $model->giveawaywithholdingtax + $model->otherfee + $model->otherfee2 + $model->otherfee3, 2, '.', '');
     } else {
         $model->total = number_format($model->down + $model->payinadvanceamount + $model->accessoriesfeeactuallypaid + $model->insurancefee + $model->compulsorymotorinsurancefee + $model->registrationfee + $model->cashpledgeredlabel + $model->implementfee + $model->giveawaywithholdingtax + $model->otherfee + $model->otherfee2 + $model->otherfee3, 2, '.', '');
     }
     $model->subdown = $carpreemption->subdown;
     $model->cashpledge = $carpreemption->cashpledge;
     $model->oldcarprice = $carpreemption->oldcarprice;
     $model->totalpayments = number_format($model->total - $model->subdown - $model->cashpledge - $model->oldcarprice, 2, '.', '');
     $salesmanemployee = Employee::find($carpreemption->salesmanemployeeid);
     $model->salesmanemployee = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname;
     $approversemployee = Employee::find($carpreemption->approversemployeeid);
     $model->approversemployee = $approversemployee->title . ' ' . $approversemployee->firstname . ' ' . $approversemployee->lastname;
     if (Auth::user()->isadmin) {
         $payeeemployees = Employee::where('departmentid', 4)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $payeeemployees = Employee::where('provinceid', Auth::user()->provinceid)->where('departmentid', 4)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $payeeemployeeselectlist = array();
     $payeeemployeeselectlist[null] = 'เลือกพนักงาน';
     foreach ($payeeemployees as $item) {
         $payeeemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     }
     $model->date = date('d-m-Y', strtotime($model->date));
     if ($model->overdueinstallmentdate1 != null && $model->overdueinstallmentdate1 != '') {
         $model->overdueinstallmentdate1 = date('d-m-Y', strtotime($model->overdueinstallmentdate1));
     }
     if ($model->overdueinstallmentdate2 != null && $model->overdueinstallmentdate2 != '') {
         $model->overdueinstallmentdate2 = date('d-m-Y', strtotime($model->overdueinstallmentdate2));
     }
     if ($model->overdueinstallmentdate3 != null && $model->overdueinstallmentdate3 != '') {
         $model->overdueinstallmentdate3 = date('d-m-Y', strtotime($model->overdueinstallmentdate3));
     }
     if ($model->overdueinstallmentdate4 != null && $model->overdueinstallmentdate4 != '') {
         $model->overdueinstallmentdate4 = date('d-m-Y', strtotime($model->overdueinstallmentdate4));
     }
     if ($model->overdueinstallmentdate5 != null && $model->overdueinstallmentdate5 != '') {
         $model->overdueinstallmentdate5 = date('d-m-Y', strtotime($model->overdueinstallmentdate5));
     }
     if ($model->overdueinstallmentdate6 != null && $model->overdueinstallmentdate6 != '') {
         $model->overdueinstallmentdate6 = date('d-m-Y', strtotime($model->overdueinstallmentdate6));
     }
     if ($model->oldcarpaydate != null && $model->oldcarpaydate != '') {
         $model->oldcarpaydate = date('d-m-Y', strtotime($model->oldcarpaydate));
     }
     if ($model->deliverycardate != null && $model->deliverycardate != '') {
         $model->deliverycardate = date('d-m-Y', strtotime($model->deliverycardate));
     }
     return view('carpaymentform', ['oper' => 'edit', 'pathPrefix' => '../../', 'carpayment' => $model, 'carpreemptionselectlist' => $carpreemptionselectlist, 'carselectlist' => $carselectlist, 'insurancecompanyselectlist' => $insurancecompanyselectlist, 'payeeemployeeselectlist' => $payeeemployeeselectlist, 'purchasetype0' => $purchasetype0, 'purchasetype1' => $purchasetype1, 'carobjectivetype0' => $carobjectivetype0, 'carobjectivetype1' => $carobjectivetype1, 'registrationtype0' => $registrationtype0, 'registrationtype1' => $registrationtype1, 'registrationtype2' => $registrationtype2]);
 }
コード例 #14
0
ファイル: SalesOrderController.php プロジェクト: saj696/pipe
 public function edit($id)
 {
     $salesOrder = SalesOrder::where('id', $id)->where('status', '!=', 4)->with(['salesOrderItems', 'salesOrderItems.product', 'salesOrderItems.salesDelivery'])->first();
     if ($salesOrder->customer_type == 1) {
         $customers = Employee::where('status', 1)->lists('name', 'id');
     } elseif ($salesOrder->customer_type == 2) {
         $customers = Supplier::where('status', 1)->lists('name', 'id');
     } else {
         $customers = Customer::where('status', 1)->lists('name', 'id');
     }
     if ($salesOrder->customer_id) {
         $personalAccount = PersonalAccount::where('person_id', '=', $salesOrder->customer_id)->where('person_type', '=', $salesOrder->customer_type)->first();
     }
     return view('sales.salesOrder.edit')->with(compact('salesOrder', 'customers', 'personalAccount'));
 }
コード例 #15
0
 public function importDBFs($br)
 {
     //(Request $request){
     $logfile = base_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'db-import.txt';
     //return Employee::with('childrens')->get();
     $import = true;
     if ($import) {
         $db = dbase_open('D:\\GI\\' . $br . '\\GC113015\\PAY_MAST.DBF', 0);
     } else {
         $db = dbase_open('D:\\GI\\MAR\\GC113015\\PAY_MAST.DBF', 0);
     }
     if ($db) {
         $header = dbase_get_header_info($db);
         if (!$import) {
             echo '<table cellpadding="2" cellspacing="0" border="1"><thead>';
         }
         // render table header
         if (!$import) {
             echo '<tr>';
             foreach ($header as $key => $value) {
                 echo '<th>' . $value['name'] . '</th>';
             }
             echo '</tr>';
         }
         // render table body
         $children_ctr = 0;
         $ecperson_ctr = 0;
         $education_ctr = 0;
         $work_ctr = 0;
         $spouse_ctr = 0;
         $record_numbers = dbase_numrecords($db);
         for ($i = 1; $i <= $record_numbers; $i++) {
             $row = dbase_get_record_with_names($db, $i);
             if ($i == 1) {
                 $brcode = trim($row['BRANCH']);
             }
             if ($import) {
                 $e = Employee::where('code', trim($row['MAN_NO']))->first();
                 if (!is_null($e)) {
                     continue;
                 }
             }
             $employee = new Employee();
             $employee->code = trim($row['MAN_NO']);
             $employee->lastname = trim($row['LAST_NAM']);
             $employee->firstname = trim($row['FIRS_NAM']);
             $employee->middlename = trim($row['MIDL_NAM']);
             $employee->companyid = trim($this->getCompanyId($row['CO_NAME']));
             $employee->id = $employee->get_uid();
             $branch = Branch::where('code', trim($row['BRANCH']))->first();
             $employee->branchid = is_null($branch) ? '' : $branch->id;
             $employee->deptid = $this->getDeptId($row['DEPT']);
             $employee->positionid = $this->getPositionId(trim($row['POSITION']));
             $employee->paytype = 2;
             $employee->ratetype = 2;
             $employee->rate = trim($row['RATE_HR']);
             $employee->ecola = trim($row['RATE_HR']);
             $employee->allowance1 = trim($row['ALW1_RATE']);
             $employee->allowance2 = trim($row['ALW2_RATE']);
             $employee->phicno = trim($row['PHEALTH_NO']);
             $employee->hdmfno = trim($row['PBIG_NO']);
             $employee->tin = trim($row['WTAX_NO']);
             $employee->sssno = trim($row['SSS_NO']);
             $employee->empstatus = $this->getEmpstatus(trim($row['EMP_STUS']));
             $employee->datestart = Carbon::parse(trim($row['STARTED']));
             //$employee->datehired		= trim($row['ALW2_RATE']);
             //$employee->datestop			= trim($row['ALW2_RATE']);
             $employee->punching = 1;
             $employee->processing = 1;
             $employee->address = trim($row['ADDRESS1']) . ', ' . trim($row['ADDRESS2']) . ', ' . trim($row['ADDRESS3']);
             $employee->phone = trim($row['TEL']);
             //$employee->fax 					= trim($row['TEL']);
             $employee->mobile = trim($row['CEL']);
             $employee->email = trim($row['EMAIL']);
             $employee->gender = trim($row['SEX']) == 'M' ? 1 : 2;
             $employee->civstatus = trim($row['CIV_STUS']) == 'SINGLE' ? 1 : 2;
             $employee->height = str_replace("'", '.', trim($row['HEIGHT']));
             $employee->weight = trim($row['WEIGHT']);
             $employee->birthdate = Carbon::parse(trim($row['BIRTHDATE']));
             $employee->birthplace = trim($row['BIRTHPLC']);
             $employee->religionid = trim($this->getReligionId($row['RELIGION']));
             $employee->hobby = trim($row['HOBBIES']);
             $employee->notes = 'UNIFORM:' . trim($row['UNIFORM']) . '; ' . 'SP_NOTES1:' . trim($row['SP_NOTES1']) . '; ' . 'SP_NOTES2:' . trim($row['SP_NOTES2']) . '; ';
             $childrens = [];
             if (!empty(trim($row['CHILDREN1'])) && trim($row['CHILDREN1']) != 'N/A') {
                 $c1 = new Children();
                 $c1->firstname = trim($row['CHILDREN1']);
                 $c1->lastname = $employee->lastname;
                 $c1->id = $c1->get_uid();
                 array_push($childrens, $c1);
                 $children_ctr++;
             }
             if (!empty(trim($row['CHILDREN2'])) && trim($row['CHILDREN2']) != 'N/A') {
                 $c2 = new Children();
                 $c2->firstname = trim($row['CHILDREN2']);
                 $c2->lastname = $employee->lastname;
                 $c2->id = $c2->get_uid();
                 array_push($childrens, $c2);
                 $children_ctr++;
             }
             if ($import) {
                 $employee->childrens()->saveMany($childrens);
             }
             if (!empty(trim($row['EMER_NAM'])) && trim($row['EMER_NAM']) != 'N/A') {
                 $emer = explode(' ', trim($row['EMER_NAM']));
                 $e = new Ecperson();
                 $e->firstname = empty($emer[0]) ? '' : $emer[0];
                 $e->lastname = empty($emer[1]) ? '' : $emer[1];
                 $e->mobile = trim($row['EMER_NO']);
                 $e->id = $e->get_uid();
                 $ecperson_ctr++;
                 if ($import) {
                     $employee->ecperson()->save($e);
                 }
             }
             if (!empty(trim($row['EDUCATION'])) && trim($row['EDUCATION']) != 'N/A') {
                 $edu = new Education();
                 $edu->school = trim($row['EDUCATION']);
                 $edu->id = $edu->get_uid();
                 if ($import) {
                     $employee->educations()->saveMany([$edu]);
                 }
                 $education_ctr++;
             }
             $works = [];
             if (!empty(trim($row['WORKHIST1'])) && trim($row['WORKHIST1']) != 'N/A') {
                 $w1 = new Workexp();
                 $w1->company = trim($row['WORKHIST1']);
                 $w1->id = $w1->get_uid();
                 array_push($works, $w1);
                 $work_ctr++;
             }
             if (!empty(trim($row['WORKHIST2'])) && trim($row['WORKHIST2']) != 'N/A') {
                 $w2 = new Workexp();
                 $w2->company = trim($row['WORKHIST2']);
                 $w2->id = $w2->get_uid();
                 array_push($works, $w2);
                 $work_ctr++;
             }
             if (!empty(trim($row['WORKHIST3'])) && trim($row['WORKHIST3']) != 'N/A') {
                 $w3 = new Workexp();
                 $w3->company = trim($row['WORKHIST3']);
                 $w3->id = $w3->get_uid();
                 array_push($works, $w3);
                 $work_ctr++;
             }
             if (!empty(trim($row['WORKHIST4'])) && trim($row['WORKHIST4']) != 'N/A') {
                 $w4 = new Workexp();
                 $w4->company = trim($row['WORKHIST2']);
                 $w4->id = $w4->get_uid();
                 array_push($works, $w4);
                 $work_ctr++;
             }
             if ($import) {
                 $employee->workexps()->saveMany($works);
             }
             if (!empty(trim($row['SPOUS_NAM'])) && trim($row['SPOUS_NAM']) != 'N/A' && trim($row['SPOUS_NAM']) != 'NA/A') {
                 $sp = preg_split("/\\s+(?=\\S*+\$)/", trim($row['SPOUS_NAM']));
                 $spou = new Spouse();
                 $spou->firstname = empty($sp[0]) ? '' : $sp[0];
                 $spou->lastname = empty($sp[1]) ? '' : $sp[1];
                 $spou->id = $spou->get_uid();
                 $spouse_ctr++;
                 if ($import) {
                     $employee->spouse()->save($spou);
                 }
             }
             if ($import) {
                 $employee->save();
             }
             if (!$import) {
                 echo '<tr>';
                 foreach ($header as $key => $value) {
                     //if($value['name']=='CO_NAME')
                     //echo '<td>'.$this->getCompanyId($row[$value['name']]).'</td>';
                     //else
                     echo '<td>' . $row[$value['name']] . '</td>';
                 }
                 echo '</tr>';
             }
         }
         if ($import) {
             echo $brcode . ' imported! </br>';
             $handle = fopen($logfile, 'a');
             $content = $brcode . "\n\temployee:\t\t" . $record_numbers . "\n";
             $content .= "\tspouse:\t\t\t" . $spouse_ctr . "\n";
             $content .= "\tchildren:\t\t" . $children_ctr . "\n";
             $content .= "\tecperson:\t\t" . $ecperson_ctr . "\n";
             $content .= "\tworkexp:\t\t" . $work_ctr . "\n";
             fwrite($handle, $content);
             fclose($handle);
         }
         dbase_close($db);
     }
 }
コード例 #16
0
ファイル: Slack.php プロジェクト: pragmanila/timelog-server
 private function getEmployeeName($code)
 {
     $employee = Employee::where('code', $code)->first();
     return $employee->first_name . ' ' . $employee->last_name;
 }
コード例 #17
0
 public function saveObjectRelation(Request $request, $newsModel)
 {
     DB::table('News_Company')->where("id_News", "=", $newsModel->id_News)->delete();
     DB::table('News_Product')->where("id_News", "=", $newsModel->id_News)->delete();
     DB::table('News_Employee')->where("id_News", "=", $newsModel->id_News)->delete();
     foreach ($newsModel->target as $relationTarget) {
         $matches = preg_grep('/^' . $relationTarget . "_*/i", array_keys($request->all()));
         foreach ($matches as $targetItem) {
             if ($request->get($targetItem) == "on") {
                 $ObjectTrgetId = str_replace($relationTarget . "_", "", $targetItem);
                 switch ($relationTarget) {
                     case 'Companies':
                         $newsModel->company()->save(Companies::findOrNew($ObjectTrgetId));
                         break;
                     case 'People':
                         $employeeModel = Employee::where("id_People", "=", $ObjectTrgetId)->first();
                         //dd($employeeModel);
                         $newsModel->employee()->save(Employee::findOrNew($employeeModel->id_Employee));
                         break;
                     case 'Vertical':
                         break;
                     case 'Products':
                         $newsModel->product()->save(Products::findOrNew($ObjectTrgetId));
                         break;
                     case 'Events':
                         break;
                 }
             }
         }
     }
 }
コード例 #18
0
 public function get($code)
 {
     header('Access-Control-Allow-Origin:*');
     return Employee::where('code', $code)->firstOrFail();
 }
コード例 #19
0
 public function edit($id)
 {
     $defect = Defect::where('id', '=', $id)->with('defectItems.product')->first();
     //        dd($defect);
     if ($defect->customer_type == 1) {
         $customers = Employee::where('status', 1)->lists('name', 'id');
     } elseif ($defect->customer_type == 2) {
         $customers = Supplier::where('status', 1)->lists('company_name', 'id');
     } else {
         $customers = Customer::where('status', 1)->lists('name', 'id');
     }
     $salesOrder = new SalesOrder();
     if ($defect->is_replacement) {
         $salesOrder = SalesOrder::where('defect_id', '=', $defect->id)->with(['salesOrderItems', 'salesOrderItems.product', 'salesOrderItems.salesDelivery'])->first();
     }
     $personalAccount = PersonalAccount::where('person_type', '=', $defect->customer_type)->where('person_id', '=', $defect->customer_id)->first();
     return view('sales.receiveDefect.edit')->with(compact('defect', 'customers', 'personalAccount', 'salesOrder'));
 }