コード例 #1
0
ファイル: EmployeeSearch.php プロジェクト: sindotnet/cona
 /**
  * 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;
 }
コード例 #2
0
ファイル: Salary.php プロジェクト: vbboy2012/1861886
 public function checkName($attribute, $params)
 {
     $employee = Employee::find()->where(['name' => $this->name])->one();
     if (count($employee) <= 0) {
         $this->addError('name', '员工不存在');
     }
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
 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]);
 }
コード例 #5
0
 /**
  * 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, 'office_id' => $this->office_id, 'group_id' => $this->group_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'name_en', $this->name_en])->andFilterWhere(['like', 'lastname_en', $this->lastname_en])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
コード例 #6
0
ファイル: EmployeeModel.php プロジェクト: arrhkm/da_basic
 /**
  * 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;
 }
コード例 #7
0
ファイル: EmployeeSearch.php プロジェクト: vbboy2012/1861886
 /**
  * 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;
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
 /**
  * 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 any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['emp_id' => $this->emp_id, 'sex' => $this->sex, 'birthday' => $this->birthday, 'modify_date' => $this->modify_date, 'create_date' => $this->create_date, 'salary' => $this->salary, 'expire_date' => $this->expire_date, 'countries' => $this->countries, 'age' => $this->age, 'marital' => $this->marital]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'mobile_phone', $this->mobile_phone])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'skill', $this->skill])->andFilterWhere(['like', 'experience', $this->experience])->andFilterWhere(['like', 'personal_id', $this->personal_id])->andFilterWhere(['like', 'province', $this->province])->andFilterWhere(['like', 'amphur', $this->amphur])->andFilterWhere(['like', 'district', $this->district])->andFilterWhere(['like', 'social', $this->social]);
     return $dataProvider;
 }
コード例 #10
0
ファイル: EmployeeSearch.php プロジェクト: vab777/marts.id_be
 /**
  * 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->joinWith(['position']);
     $query->andFilterWhere(['employee_id' => $this->employee_id, 'salutation' => $this->salutation, 'birthday' => $this->birthday, 'gender' => $this->gender, 'last_password_gen' => $this->last_password_gen, 'last_visit' => $this->last_visit, 'status' => $this->status, 'flag_active' => $this->flag_active, 'date_added' => $this->date_added, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'position_name', $this->position_id])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'mobile_phone', $this->mobile_phone])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
コード例 #11
0
ファイル: EmployeeRequest.php プロジェクト: saj696/pipe
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $employee = Employee::find($this->employees);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['name' => 'required', 'mobile' => 'required|min:11', 'joining_date' => 'required|date', 'designation_id' => 'required|integer', 'workspace_id' => 'required|integer', 'photo' => 'image', 'username' => 'required_if:as_user,1|alpha_dash|min:3|unique:users', 'email' => 'required|email|unique:users', 'password' => 'required_if:as_user,1|min:6', 'user_group_id' => 'required_if:as_user,1|integer'];
         case 'PUT':
         case 'PATCH':
             return ['name' => 'required', 'mobile' => 'required|min:11', 'joining_date' => 'required|date', 'designation_id' => 'required|integer', 'workspace_id' => 'required|integer', 'photo' => 'image', 'email' => 'required|email|unique:employees,email,' . $employee->id];
         default:
             break;
     }
 }
コード例 #12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Employee::find()->joinWith(['department', 'chief' => function (Query $query) {
         $query->from(Employee::tableName() . ' chief');
     }]);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['department.name'] = ['asc' => ['department.name' => SORT_ASC], 'desc' => ['department.name' => SORT_DESC]];
     $dataProvider->sort->attributes['chief.Name'] = ['asc' => ['chief.Name' => SORT_ASC], 'desc' => ['chief.Name' => 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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'Salary' => $this->Salary]);
     $query->andFilterWhere(['like', 'Name', $this->Name]);
     $query->andFilterWhere(['like', 'department.name', $this->getAttribute('department.name')]);
     $query->andFilterWhere(['like', 'chief.Name', $this->getAttribute('chief.Name')]);
     return $dataProvider;
 }
コード例 #13
0
 /**
  * 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]);
     $dataProvider->setSort(['attributes' => ['id', 'fullNameEmployee' => ['asc' => ['last_name' => SORT_ASC], 'desc' => ['last_name' => SORT_DESC], 'label' => 'ФИО'], 'departmentName' => ['asc' => ['department.title' => SORT_ASC], 'desc' => ['department.title' => SORT_DESC], 'label' => 'Секция'], 'fullPhoneNumberEmployee' => ['asc' => ['phone_number' => SORT_ASC], 'desc' => ['phone_number' => SORT_DESC], 'label' => 'Телефонный номер сотрудника'], 'statusTitle' => ['asc' => ['status_employee.title' => SORT_ASC], 'desc' => ['status_employee.title' => SORT_DESC], 'label' => 'Статус сотрудника'], 'birthday' => ['asc' => ['birthday' => SORT_ASC], 'desc' => ['birthday' => SORT_DESC], 'label' => 'День рождения'], 'date_start' => ['asc' => ['date_start' => SORT_ASC], 'desc' => ['date_start' => SORT_DESC], 'label' => 'Дата начала работы сотрудника'], 'date_end' => ['asc' => ['date_end' => SORT_ASC], 'desc' => ['date_end' => SORT_DESC], 'label' => 'Дата увольнения сотрудника'], 'roleTitle' => ['asc' => ['role.title' => SORT_ASC], 'desc' => ['role.title' => SORT_DESC], 'label' => 'Должность сотрудника']]]);
     $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->id, 'is_active' => $this->is_active, 'id_role' => $this->roleTitle, 'id_status' => $this->statusTitle, 'id_department' => $this->departmentName]);
     $query->andFilterWhere(['like', 'CONCAT(employee.last_name,employee.first_name,employee.middle_name)', $this->fullNameEmployee])->andFilterWhere(['like', "DATE_FORMAT(birthday,'%d.%m.%Y')", $this->birthday])->andFilterWhere(['like', "DATE_FORMAT(date_start,'%d.%m.%Y')", $this->date_start])->andFilterWhere(['like', "DATE_FORMAT(date_end,'%d.%m.%Y')", $this->date_end])->andFilterWhere(['like', 'phone_number', $this->fullPhoneNumberEmployee]);
     $query->joinWith(['department' => function ($q) {
         //$q->where('department.title LIKE "%' . $this->departmentName . '%"');
     }]);
     $query->joinWith(['role' => function ($q) {
         //$q->where('role.title LIKE "%' . $this->roleTitle . '%"');
     }]);
     $query->joinWith(['status' => function ($q) {
         //$q->where('status_employee.title LIKE "%' . $this->statusTitle . '%"');
     }]);
     return $dataProvider;
 }
コード例 #14
0
 public function getforaccountingdetailbyid($id, $donumberformat)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $accountingdetail = new AccountingDetail();
     $accountingdetail->carpaymentid = $id;
     $carpayment = CarPayment::find($id);
     $branch = Branch::find($carpayment->branchid);
     $accountingdetail->branchname = $branch->name;
     $carpreemption = CarPreemption::find($carpayment->carpreemptionid);
     $customer = Customer::find($carpreemption->buyercustomerid);
     $accountingdetail->customername = $customer->title . $customer->firstname . ' ' . $customer->lastname;
     if ($carpayment->deliverycardate != null && $carpayment->deliverycardate != '') {
         $accountingdetail->date = date('d-m-Y', strtotime($carpayment->deliverycardate));
         $accountingdetail->deliverycardate = date('d-m-Y', strtotime($carpayment->deliverycardate));
     } else {
         $accountingdetail->date = null;
         $accountingdetail->deliverycardate = "-";
     }
     $pricelist = Pricelist::find($carpreemption->pricelistid);
     $accountingdetail->carpriceinpricelist = $pricelist->sellingpricewithaccessories;
     $accountingdetail->colorprice = $carpreemption->colorprice;
     $carwithcolorprice = $pricelist->sellingpricewithaccessories + $carpreemption->colorprice;
     $accountingdetail->carwithcolorprice = $carwithcolorprice;
     $accountingdetail->purchasetype = $carpreemption->purchasetype;
     if ($carpreemption->purchasetype == 0) {
         $openbill = $accountingdetail->carwithcolorprice - $carpreemption->discount;
     } else {
         $openbill = $accountingdetail->carwithcolorprice - $carpreemption->discount + $carpreemption->accessories + $carpayment->accessoriesfeeincludeinyodjud;
     }
     $accountingdetail->openbill = $openbill;
     $accountingdetail->accessoriesfeeincludeinyodjud = $carpayment->accessoriesfeeincludeinyodjud;
     $accountingdetail->fakeaccessories = $carpreemption->accessories;
     $accountingdetail->discount = $carpreemption->discount;
     $accountingdetail->subdown = $carpreemption->subdown;
     $realsalesprice = $carwithcolorprice + $carpayment->accessoriesfeeincludeinyodjud - $carpreemption->discount - $carpreemption->subdown;
     $accountingdetail->realsalesprice = $realsalesprice;
     $accountingdetail->accessoriesfeeactuallypaid = $carpayment->accessoriesfeeactuallypaid;
     $registrationfee = $carpreemption->registrationfeefree ? 0 : $carpreemption->registrationfee;
     $accountingdetail->registrationfee = $registrationfee;
     $accountingdetail->actualinsurancefee = $carpreemption->insurancefee;
     if ($carpreemption->purchasetype == 0) {
         $compulsorymotorinsurancefeecash = $carpreemption->compulsorymotorinsurancefeefree ? 0 : $carpreemption->compulsorymotorinsurancefee;
         $conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeecash;
         $accountingdetail->compulsorymotorinsurancefeecash = $compulsorymotorinsurancefeecash;
         $insurancefeecash = $carpreemption->insurancefeefree ? 0 : $carpreemption->insurancefee;
         $accountingdetail->insurancefeecash = $insurancefeecash;
         $accountingdetail->compulsorymotorinsurancefeefn = 0;
         $compulsorymotorinsurancefeefn = 0;
         $accountingdetail->insurancefeefn = 0;
         $insurancefeefn = 0;
         $accountingdetail->firstinstallmentpayamount = 0;
         $firstinstallmentpayamount = 0;
         $accountingdetail->installmentsinadvance = 0;
         $accountingdetail->amountperinstallment = 0;
         $accountingdetail->payinadvanceamount = 0;
         $payinadvanceamount = 0;
         $accountingdetail->insurancepremium = 0;
         $accountingdetail->totalinadvancefees = 0;
         $totalinadvancefees = 0;
         $accountingdetail->conditioninsurancefee = $carpreemption->insurancefee;
         $accountingdetail->conditioninsurancefeecustomerpaid = $insurancefeecash;
         $conditioninsurancefeecompanypaid = $carpreemption->insurancefee - $insurancefeecash;
         $accountingdetail->conditioninsurancefeecompanypaid = $conditioninsurancefeecompanypaid;
         $accountingdetail->conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeecash;
     } else {
         $compulsorymotorinsurancefeecash = 0;
         $insurancefeecash = 0;
         $compulsorymotorinsurancefeefn = $carpreemption->compulsorymotorinsurancefeefree ? 0 : $carpreemption->compulsorymotorinsurancefee;
         $conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeefn;
         $accountingdetail->compulsorymotorinsurancefeefn = $compulsorymotorinsurancefeefn;
         $insurancefeefn = $carpreemption->insurancefeefree ? 0 : $carpreemption->insurancefee;
         $accountingdetail->insurancefeefn = $insurancefeefn;
         $firstinstallmentpayamount = $carpayment->firstinstallmentpay ? $carpayment->amountperinstallment : 0;
         $accountingdetail->firstinstallmentpayamount = $firstinstallmentpayamount;
         $accountingdetail->installmentsinadvance = $carpayment->installmentsinadvance;
         $accountingdetail->amountperinstallment = $carpayment->amountperinstallment;
         $payinadvanceamount = $carpayment->installmentsinadvance * $carpayment->amountperinstallment;
         $accountingdetail->payinadvanceamount = $payinadvanceamount;
         $accountingdetail->insurancepremium = $carpayment->insurancepremium;
         $totalinadvancefees = $insurancefeefn + $compulsorymotorinsurancefeefn + $firstinstallmentpayamount + $payinadvanceamount + $carpayment->insurancepremium;
         $accountingdetail->totalinadvancefees = $totalinadvancefees;
         $accountingdetail->compulsorymotorinsurancefeecash = 0;
         $accountingdetail->insurancefeecash = 0;
         $accountingdetail->conditioninsurancefee = $carpreemption->insurancefee;
         $accountingdetail->conditioninsurancefeecustomerpaid = $insurancefeefn;
         $conditioninsurancefeecompanypaid = $carpreemption->insurancefee - $insurancefeefn;
         $accountingdetail->conditioninsurancefeecompanypaid = $conditioninsurancefeecompanypaid;
         $accountingdetail->conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeefn;
     }
     $implementfee = $carpreemption->implementfeefree ? 0 : $carpreemption->implementfee;
     $accountingdetail->implementfee = $implementfee;
     $subsidise = $carpreemption->subsidisefree ? 0 : $carpreemption->subsidise;
     $accountingdetail->subsidise = $subsidise;
     $accountingdetail->giveawaywithholdingtax = $carpreemption->giveawaywithholdingtax;
     $accountingdetail->otherfee = $carpreemption->otherfee;
     $accountingdetail->otherfeedetail = $carpreemption->otherfeedetail;
     $accountingdetail->otherfee2 = $carpreemption->otherfee2;
     $accountingdetail->otherfeedetail2 = $carpreemption->otherfeedetail2;
     $accountingdetail->otherfee3 = $carpreemption->otherfee3;
     $accountingdetail->otherfeedetail3 = $carpreemption->otherfeedetail3;
     $totalotherfee = $subsidise + $carpreemption->giveawaywithholdingtax + $carpreemption->otherfee + $carpreemption->otherfee2 + $carpreemption->otherfee3;
     $accountingdetail->totalotherfee = $totalotherfee;
     $totalotherfees = $carpayment->accessoriesfeeactuallypaid + $registrationfee + $compulsorymotorinsurancefeecash + $insurancefeecash + $implementfee + $totalotherfee;
     $accountingdetail->totalotherfees = $totalotherfees;
     $carmodel = CarModel::find($carpreemption->carmodelid);
     $carsubmodel = CarSubModel::find($carpreemption->carsubmodelid);
     $accountingdetail->submodel = $carmodel->name . '/' . $carsubmodel->name;
     $car = Car::find($carpayment->carid);
     $accountingdetail->carno = $car->no;
     $accountingdetail->engineno = $car->engineno;
     $accountingdetail->chassisno = $car->chassisno;
     $color = Color::find($car->colorid);
     $accountingdetail->color = $color->code;
     $accountingdetail->purchasetypetext = $carpreemption->purchasetype == 0 ? "C" : "F";
     $accountingdetail->down = $carpreemption->down;
     $insurancecompany = InsuranceCompany::find($carpayment->insurancecompanyid);
     if ($insurancecompany != null) {
         $accountingdetail->insurancecompany = $insurancecompany->name;
     }
     $accountingdetail->capitalinsurance = $carpayment->capitalinsurance;
     $compulsorymotorinsurancecompany = InsuranceCompany::find($carpayment->compulsorymotorinsurancecompanyid);
     if ($compulsorymotorinsurancecompany != null) {
         $accountingdetail->compulsorymotorinsurancecompany = $compulsorymotorinsurancecompany->name;
     }
     $cartype = CarType::find($carmodel->cartypeid);
     $accountingdetail->conditioncompulsorymotorinsurancefee = $cartype->actpaidincludevat;
     $accountingdetail->hascompulsorymotorinsurancefee = $cartype->actpaidincludevat == 0 ? 0 : 1;
     $conditioncompulsorymotorinsurancefeecompanypaid = $cartype->actpaidincludevat - $conditioncompulsorymotorinsurancefeecustomerpaid;
     $accountingdetail->conditioncompulsorymotorinsurancefeecompanypaid = $conditioncompulsorymotorinsurancefeecompanypaid;
     $note1insurancefee = $carpreemption->insurancefee * 100 / 107.0;
     $accountingdetail->note1insurancefee = $note1insurancefee;
     $accountingdetail->note1insurancefeeincludevat = $carpreemption->insurancefee;
     $note1insurancefeevat = $carpreemption->insurancefee - $note1insurancefee;
     $accountingdetail->note1insurancefeevat = $note1insurancefeevat;
     $accountingdetail->note1compulsorymotorinsurancefee = $cartype->actpaid;
     $accountingdetail->note1compulsorymotorinsurancefeevat = $cartype->actpaidincludevat - $cartype->actpaid;
     $accountingdetail->note1compulsorymotorinsurancefeeincludevat = $cartype->actpaidincludevat;
     $note1totalfee = $note1insurancefee + $cartype->actpaid;
     $accountingdetail->note1totalfee = $note1totalfee;
     $note1totalfeevat = $note1insurancefeevat + ($cartype->actpaidincludevat - $cartype->actpaid);
     $accountingdetail->note1totalfeevat = $note1totalfeevat;
     $note1totalfeeincludevat = $carpreemption->insurancefee + $cartype->actpaidincludevat;
     $accountingdetail->note1totalfeeincludevat = $note1totalfeeincludevat;
     $cashpledgeredlabel = $carpreemption->cashpledgeredlabel;
     $accountingdetail->cashpledgeredlabel = $cashpledgeredlabel;
     if ($cashpledgeredlabel == null || $cashpledgeredlabel == 0) {
         $accountingdetail->hascashpledgeredlabel = 0;
     } else {
         $accountingdetail->hascashpledgeredlabel = 1;
     }
     $redlabelhistory = Redlabelhistory::where('carpreemptionid', $carpreemption->id)->orderBy('id', 'desc')->first();
     if ($redlabelhistory != null) {
         if ($redlabelhistory->returndate != null) {
             $accountingdetail->redlabelreturncashpledgedate = date('d-m-Y', strtotime($redlabelhistory->returncashpledgedate));
         } else {
             $accountingdetail->redlabelreturncashpledgedate = "-";
         }
     } else {
         $accountingdetail->redlabelreturncashpledgedate = "ไม่เอาป้าย";
     }
     $cashpledge = $carpreemption->cashpledge;
     $accountingdetail->cashpledge = $cashpledge;
     $totalcashpledge = $cashpledgeredlabel - $cashpledge;
     $accountingdetail->totalcashpledge = $totalcashpledge;
     $totalcash = $realsalesprice + $totalotherfees + $totalinadvancefees + $totalcashpledge;
     $accountingdetail->totalcash = $totalcash;
     $finacecompany = FinaceCompany::find($carpreemption->finacecompanyid);
     if ($finacecompany != null) {
         $accountingdetail->finacecompany = $finacecompany->name;
     }
     $accountingdetail->incasefinace = $carpreemption->purchasetype;
     if ($carpreemption->purchasetype == 1) {
         $accountingdetail->interest = $carpreemption->interest;
         $accountingdetail->installments = $carpreemption->installments;
         $pricelist = Pricelist::find($carpreemption->pricelistid);
         $carprice = $pricelist->sellingpricewithaccessories + $carpreemption->colorprice;
         $yodjud = $carprice - $carpreemption->discount - $carpreemption->down + $carpreemption->accessories + $carpayment->accessoriesfeeincludeinyodjud;
         $yodjudwithinsurancepremium = $yodjud + $carpayment->insurancepremium;
         $accountingdetail->yodjud = $yodjudwithinsurancepremium;
         $yodjudwithinterest = $yodjudwithinsurancepremium * ($carpreemption->interest + 100) / 100.0;
         $accountingdetail->yodjudwithinterest = $yodjudwithinterest;
         $finaceprofit = $yodjudwithinterest - $yodjudwithinsurancepremium;
         $commissionfinace = CommissionFinace::where('finacecompanyid', $carpreemption->finacecompanyid)->where('interestratetypeid', $carpreemption->interestratetypeid)->where('finaceminimumprofit', '<=', $finaceprofit)->where('effectivefrom', '<=', $carpreemption->date)->where('effectiveto', '>=', $carpreemption->date)->whereHas('commissionFinaceCars', function ($query) use($carpreemption) {
             $query->where('carmodelid', $carpreemption->carmodelid)->Where(function ($query) use($carpreemption) {
                 $query->where('carsubmodelid', $carpreemption->carsubmodelid)->orWhere('carsubmodelid', 0);
             });
         })->first();
         $percentdown = $carpreemption->down * 100.0 / ($carprice - $carpreemption->discount + $carpreemption->accessories);
         $accountingdetail->comfinpercent = null;
         $comfinpercent = 0;
         $accountingdetail->comfinyear = null;
         $comfinyear = 0;
         if ($commissionfinace != null) {
             $commissionfinaceinterest = CommissionFinaceInterest::where('commissionfinaceid', $commissionfinace->id)->where('downfrom', '<=', $percentdown)->where('downto', '>=', $percentdown)->first();
             if ($commissionfinaceinterest != null) {
                 $commissionstandardinterest = 0;
                 switch ($carpreemption->installments) {
                     case 24:
                         $commissionstandardinterest = $commissionfinaceinterest->installment24;
                         break;
                     case 36:
                         $commissionstandardinterest = $commissionfinaceinterest->installment36;
                         break;
                     case 48:
                         $commissionstandardinterest = $commissionfinaceinterest->installment48;
                         break;
                     case 60:
                         $commissionstandardinterest = $commissionfinaceinterest->installment60;
                         break;
                     case 72:
                         $commissionstandardinterest = $commissionfinaceinterest->installment72;
                         break;
                     case 84:
                         $commissionstandardinterest = $commissionfinaceinterest->installment84;
                         break;
                 }
                 $commissionfinaceinterests = CommissionFinaceCom::where('commissionfinaceid', $commissionfinace->id)->orderBy('com', 'asc')->get();
                 $previousstepcom = null;
                 foreach ($commissionfinaceinterests as $item) {
                     if ($carpreemption->interestratemode == 0) {
                         $currentstepinterest = $commissionstandardinterest + $item->interestcalculationbeginning;
                     } else {
                         $currentstepinterest = $commissionstandardinterest + $item->interestcalculationending;
                     }
                     if ($carpreemption->interest == $currentstepinterest) {
                         $accountingdetail->comfinpercent = $item->com;
                         $accountingdetail->comfinyear = $commissionfinace->years;
                         $comfinpercent = $item->com;
                         $comfinyear = $commissionfinace->years;
                         break;
                     } else {
                         if ($carpreemption->interest < $currentstepinterest) {
                             if ($previousstepcom != null) {
                                 $accountingdetail->comfinpercent = $previousstepcom;
                                 $accountingdetail->comfinyear = $commissionfinace->years;
                                 $comfinpercent = $previousstepcom;
                                 $comfinyear = $commissionfinace->years;
                             } else {
                                 $accountingdetail->comfinpercent = null;
                                 $accountingdetail->comfinyear = null;
                                 $comfinpercent = 0;
                                 $comfinyear = 0;
                             }
                             break;
                         } else {
                             if ($carpreemption->interest > $currentstepinterest) {
                                 $previousstepcom = $item->com;
                             }
                         }
                     }
                 }
                 if ($accountingdetail->comfinpercent == null) {
                     if ($previousstepcom != null) {
                         $accountingdetail->comfinpercent = $previousstepcom;
                         $accountingdetail->comfinyear = $commissionfinace->years;
                         $comfinpercent = $previousstepcom;
                         $comfinyear = $commissionfinace->years;
                     }
                 }
             }
         }
         $employee = Employee::find($carpreemption->salesmanemployeeid);
         $accountingdetail->salename = $employee->title . $employee->firstname . ' ' . $employee->lastname;
         $accountingdetail->incasefinaceinsurancefee = $carpreemption->insurancefee;
         $accountingdetail->note2insurancefeewhtax = $note1insurancefee / 100.0;
         $accountingdetail->note2insurancefee = $insurancefeefn;
         $note2insurancefeeexpense = $conditioninsurancefeecompanypaid > 0 ? $conditioninsurancefeecompanypaid : 0;
         $accountingdetail->note2insurancefeeexpense = $note2insurancefeeexpense;
         $note2insurancefeeincome = $conditioninsurancefeecompanypaid < 0 ? $conditioninsurancefeecompanypaid * -1 : 0;
         $accountingdetail->note2insurancefeeincome = $note2insurancefeeincome;
         $accountingdetail->incasefinacecompulsorymotorinsurancefee = $cartype->actpaidincludevat;
         $accountingdetail->note2compulsorymotorinsurancefeewhtax = $cartype->actpaid / 100.0;
         $accountingdetail->note2compulsorymotorinsurancefee = $compulsorymotorinsurancefeefn;
         $note2compulsorymotorinsurancefeeexpense = $conditioncompulsorymotorinsurancefeecompanypaid > 0 ? $conditioncompulsorymotorinsurancefeecompanypaid : 0;
         $accountingdetail->note2compulsorymotorinsurancefeeexpense = $note2compulsorymotorinsurancefeeexpense;
         $note2compulsorymotorinsurancefeeincome = $conditioncompulsorymotorinsurancefeecompanypaid < 0 ? $conditioncompulsorymotorinsurancefeecompanypaid * -1 : 0;
         $accountingdetail->note2compulsorymotorinsurancefeeincome = $note2compulsorymotorinsurancefeeincome;
         $accountingdetail->incasefinacefirstinstallmentpayamount = $firstinstallmentpayamount;
         $accountingdetail->note2firstinstallmentpayamount = $firstinstallmentpayamount;
         $accountingdetail->incasefinacepayinadvanceamount = $payinadvanceamount;
         $accountingdetail->note2payinadvanceamount = $payinadvanceamount;
         $accountingdetail->incasefinaceinsurancepremium = $carpayment->insurancepremium;
         $accountingdetail->note2insurancepremium = $carpayment->insurancepremium;
         $totalincasefinace = $carpreemption->insurancefee + $cartype->actpaidincludevat + $firstinstallmentpayamount + $payinadvanceamount + $carpayment->insurancepremium;
         $accountingdetail->totalincasefinace = $totalincasefinace;
         $accountingdetail->incasefinacereceivedcash = $yodjudwithinsurancepremium - $totalincasefinace;
         $note2total1 = $insurancefeefn + $compulsorymotorinsurancefeefn + $firstinstallmentpayamount + $payinadvanceamount + $carpayment->insurancepremium;
         $accountingdetail->note2total1 = $note2total1;
         $note2total2 = $note2insurancefeeexpense + $note2compulsorymotorinsurancefeeexpense;
         $accountingdetail->note2total2 = $note2total2;
         $note2total3 = $note2insurancefeeincome + $note2compulsorymotorinsurancefeeincome;
         $accountingdetail->note2total3 = $note2total3;
         $accountingdetail->incasefinacesubsidise = $carpreemption->subsidise;
         $incasefinacesubsidisewithvat = $carpreemption->subsidise + $carpreemption->subsidise * 0.07000000000000001;
         $accountingdetail->incasefinacesubsidisewithvat = $incasefinacesubsidisewithvat;
         $accountingdetail->note2subsidisewhtax = $carpreemption->subsidise * 0.03;
         $note2subsidisetotal = $carpreemption->subsidise + $carpreemption->subsidise * 0.07000000000000001 - $carpreemption->subsidise * 0.03;
         $accountingdetail->note2subsidisetotal = $note2subsidisetotal;
         $incasefinacehassubsidisereceivedcash = $yodjudwithinsurancepremium - $totalincasefinace - $incasefinacesubsidisewithvat;
         $accountingdetail->incasefinacehassubsidisereceivedcash = $incasefinacehassubsidisereceivedcash;
         $note2totalwhtax = $note1insurancefee / 100.0 + $cartype->actpaid / 100.0 + $carpreemption->subsidise * 0.03;
         $accountingdetail->note2totalwhtax = $note2totalwhtax;
         //NLTH,AYCAL,KL
         if ($carpreemption->finacecompanyid == 1 || $carpreemption->finacecompanyid == 2 || $carpreemption->finacecompanyid == 4) {
             $incasefinacecomfinamountwithvat = $yodjud * ($carpreemption->interest / 100.0) * $comfinyear * ($comfinpercent / 100.0);
             $incasefinacecomfinamount = $incasefinacecomfinamountwithvat / 1.07;
             $incasefinacecomfinvat = $incasefinacecomfinamountwithvat - $incasefinacecomfinamount;
         } else {
             if ($carpreemption->finacecompanyid == 3 || $carpreemption->finacecompanyid == 5) {
                 $incasefinacecomfinamount = floor($yodjud / 1.07 * ($carpreemption->interest / 100.0) * $comfinyear * ($comfinpercent / 100.0));
                 $incasefinacecomfinvat = $incasefinacecomfinamount * 0.07000000000000001;
                 $incasefinacecomfinamountwithvat = $incasefinacecomfinamount + $incasefinacecomfinvat;
             } else {
                 if ($carpreemption->finacecompanyid == 6) {
                     $incasefinacecomfinamount = round($yodjud / 1.07 * ($carpreemption->interest / 100.0) * $comfinyear * ($comfinpercent / 100.0), 2);
                     $incasefinacecomfinvat = $incasefinacecomfinamount * 0.07000000000000001;
                     $incasefinacecomfinamountwithvat = $incasefinacecomfinamount + $incasefinacecomfinvat;
                 } else {
                     if ($carpreemption->finacecompanyid == 7) {
                         $incasefinacecomfinamount = ($carpayment->amountperinstallment / 1.07 * $carpreemption->installments - $yodjud / 1.07) * ($comfinpercent / 100.0) * 48 / $carpreemption->installments;
                         $incasefinacecomfinvat = $incasefinacecomfinamount * 0.07000000000000001;
                         $incasefinacecomfinamountwithvat = $incasefinacecomfinamount + $incasefinacecomfinvat;
                     }
                 }
             }
         }
         $accountingdetail->incasefinacecomfinamount = $incasefinacecomfinamount;
         $accountingdetail->incasefinacecomfinvat = $incasefinacecomfinvat;
         $accountingdetail->incasefinacecomfinamountwithvat = $incasefinacecomfinamountwithvat;
         $accountingdetail->incasefinacecomfinwhtax = $incasefinacecomfinamount * 0.03;
         $incasefinacecomfintotal = $incasefinacecomfinamountwithvat - $incasefinacecomfinamount * 0.03;
         $accountingdetail->incasefinacecomfintotal = $incasefinacecomfintotal;
         $commissionextra = CommissionExtra::where('finacecompanyid', $carpreemption->finacecompanyid)->where('effectivefrom', '<=', $carpreemption->date)->where('effectiveto', '>=', $carpreemption->date)->whereHas('commissionExtraCars', function ($query) use($carpreemption) {
             $query->where('carmodelid', $carpreemption->carmodelid)->Where(function ($query) use($carpreemption) {
                 $query->where('carsubmodelid', $carpreemption->carsubmodelid)->orWhere('carsubmodelid', 0);
             });
         })->first();
         if ($commissionfinace != null) {
             $accountingdetail->incasefinacecomextraamount = $commissionextra->amount;
             $incasefinacecomextraamount = $commissionextra->amount;
             $accountingdetail->incasefinacecomextravat = $commissionextra->amount * 0.07000000000000001;
             $incasefinacecomextravat = $commissionextra->amount * 0.07000000000000001;
             $incasefinacecomextraamountwithvat = $commissionextra->amount + $commissionextra->amount * 0.07000000000000001;
             $accountingdetail->incasefinacecomextraamountwithvat = $incasefinacecomextraamountwithvat;
             $accountingdetail->incasefinacecomextrawhtax = $commissionextra->amount * 0.03;
             $incasefinacecomextrawhtax = $commissionextra->amount * 0.03;
             $incasefinacecomextratotal = $incasefinacecomextraamountwithvat - $commissionextra->amount * 0.03;
             $accountingdetail->incasefinacecomextratotal = $incasefinacecomextratotal;
         } else {
             $accountingdetail->incasefinacecomextraamount = 0;
             $incasefinacecomextraamount = 0;
             $accountingdetail->incasefinacecomextravat = 0;
             $incasefinacecomextravat = 0;
             $accountingdetail->incasefinacecomextraamountwithvat = 0;
             $accountingdetail->incasefinacecomextrawhtax = 0;
             $incasefinacecomextrawhtax = 0;
             $accountingdetail->incasefinacecomextratotal = 0;
             $incasefinacecomextratotal = 0;
         }
         if ($carpayment->insurancepremium > 0) {
             $commissionpa = CommissionPA::where('finacecompanyid', $carpreemption->finacecompanyid)->where('effectivefrom', '<=', $carpreemption->date)->where('effectiveto', '>=', $carpreemption->date)->first();
             if ($commissionpa != null) {
                 $accountingdetail->incasefinacecompaamount = $commissionpa->amount;
                 $incasefinacecompaamount = $commissionpa->amount;
                 $accountingdetail->incasefinacecompavat = $commissionpa->amount * 0.07000000000000001;
                 $incasefinacecompavat = $commissionpa->amount * 0.07000000000000001;
                 $incasefinacecompaamountwithvat = $commissionpa->amount + $commissionpa->amount * 0.07000000000000001;
                 $accountingdetail->incasefinacecompaamountwithvat = $incasefinacecompaamountwithvat;
                 $accountingdetail->incasefinacecompawhtax = $commissionpa->amount * 0.03;
                 $incasefinacecompawhtax = $commissionpa->amount * 0.03;
                 $incasefinacecompatotal = $incasefinacecompaamountwithvat - $commissionpa->amount * 0.03;
                 $accountingdetail->incasefinacecompatotal = $incasefinacecompatotal;
             } else {
                 $accountingdetail->incasefinacecompaamount = 0;
                 $incasefinacecompaamount = 0;
                 $accountingdetail->incasefinacecompavat = 0;
                 $incasefinacecompavat = 0;
                 $accountingdetail->incasefinacecompaamountwithvat = 0;
                 $accountingdetail->incasefinacecompawhtax = 0;
                 $incasefinacecompawhtax = 0;
                 $accountingdetail->incasefinacecompatotal = 0;
                 $incasefinacecompatotal = 0;
             }
         } else {
             $accountingdetail->incasefinacecompaamount = 0;
             $incasefinacecompaamount = 0;
             $accountingdetail->incasefinacecompavat = 0;
             $incasefinacecompavat = 0;
             $accountingdetail->incasefinacecompaamountwithvat = 0;
             $accountingdetail->incasefinacecompawhtax = 0;
             $incasefinacecompawhtax = 0;
             $accountingdetail->incasefinacecompatotal = 0;
             $incasefinacecompatotal = 0;
         }
         $incasefinacetotalcomamount = $incasefinacecomfinamount + $incasefinacecomextraamount + $incasefinacecompaamount;
         $accountingdetail->incasefinacetotalcomamount = $incasefinacetotalcomamount;
         $incasefinacetotalcomvat = $incasefinacecomfinamount * 0.07000000000000001 + $incasefinacecomextravat + $incasefinacecompavat;
         $accountingdetail->incasefinacetotalcomvat = $incasefinacetotalcomvat;
         $incasefinacetotalcomamountwithvat = $incasefinacetotalcomamount + $incasefinacetotalcomvat;
         $accountingdetail->incasefinacetotalcomamountwithvat = $incasefinacetotalcomamountwithvat;
         $incasefinacetotalcomwhtax = $incasefinacecomfinamount * 0.03 + $incasefinacecomextrawhtax + $incasefinacecompawhtax;
         $accountingdetail->incasefinacetotalcomwhtax = $incasefinacetotalcomwhtax;
         $incasefinacetotalcomtotal = $incasefinacecomfintotal + $incasefinacecomextratotal + $incasefinacecompatotal;
         $accountingdetail->incasefinacetotalcomtotal = $incasefinacetotalcomtotal;
         $receivedcashfromfinace = round($incasefinacehassubsidisereceivedcash, 2) + round($note2totalwhtax, 2) + round($incasefinacetotalcomtotal, 2);
         $accountingdetail->receivedcashfromfinace = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinacenet = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinaceshort = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinacenetshort = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinaceover = 0;
         $accountingdetail->receivedcashfromfinacenetover = 0;
     } else {
         $yodjud = 0;
         $yodjudwithinsurancepremium = 0;
         $accountingdetail->incasefinacereceivedcash = 0;
     }
     $tradereceivableaccount2amount = $totalcash - $yodjudwithinsurancepremium;
     $accountingdetail->tradereceivableaccount2amount = $tradereceivableaccount2amount;
     $oldcarprice = $carpreemption->oldcarprice;
     $accountingdetail->oldcarprice = $oldcarprice;
     $overdue = $carpayment->overdue;
     $accountingdetail->overdue = $overdue;
     $tradereceivableaccount2remainingamount = $tradereceivableaccount2amount - $oldcarprice - $overdue;
     $accountingdetail->tradereceivableaccount2remainingamount = $tradereceivableaccount2remainingamount;
     $accountingdetail->ins = $accountingdetail->note1insurancefeeincludevat;
     //$carpreemption->insurancefee;
     $accountingdetail->prb = $accountingdetail->note1compulsorymotorinsurancefeeincludevat;
     //$carpreemption->compulsorymotorinsurancefee;
     $accountingdetail->dc = $carpreemption->accessories + $carpreemption->subdown;
     $accountingdetail->totalacc2 = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalacc2short = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalacc2over = 0;
     $accountingdetail->totalaccount2 = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalaccount2short = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalaccount2over = 0;
     $arrNotFormatted = array("id", "purchasetype", "carpaymentid", "hasinsurancefee", "hascompulsorymotorinsurancefee", "hascashpledgeredlabel", "systemcalincasefinacecomfinamount", "systemcalincasefinacecomfinvat", "systemcalincasefinacecomfinamountwithvat", "systemcalincasefinacecomfinwhtax", "systemcalincasefinacecomfintotal", "receivedcashfromfinacenet", "receivedcashfromfinacenetshort", "receivedcashfromfinacenetover", "totalaccount1", "totalaccount1short", "totalaccount1over", "totalaccount2", "totalaccount2short", "totalaccount2over", 'totalaccounts', 'totalaccountsshort', 'totalaccountsover', "invoiceno", "additionalopenbill", "deliverycardate", "cashpledgeredlabelreceiptbookno", "cashpledgeredlabelreceiptno", "cashpledgeredlabelreceiptdate", "redlabelreturncashpledgedate", "cashpledgereceiptbookno", "cashpledgereceiptno", "cashpledgereceiptdate", "incasefinacecomfinamount", "incasefinacecomfinvat", "incasefinacecomfinamountwithvat", "incasefinacecomfinwhtax", "incasefinacecomfintotal", "oldcarcomamount", 'oldcarcomdate', "adj", "insurancefeereceiptcondition", "compulsorymotorinsurancefeereceiptcondition", "payinadvanceamountreimbursementdate", "payinadvanceamountreimbursementdocno", 'insurancebilldifferent', "note1insurancefeereceiptcondition", "note1compulsorymotorinsurancefeereceiptcondition", 'insurancefeepayment', 'insurancefeepaidseparatelydate', 'insurancepremiumnet', 'insurancepremiumcom', 'insurancefeepaidseparatelytotal', 'compulsorymotorinsurancefeepayment', 'compulsorymotorinsurancefeepaidseparatelydate', 'compulsorymotorinsurancepremiumnet', 'compulsorymotorinsurancepremiumcom', 'compulsorymotorinsurancefeepaidseparatelytotal', "carno", "installmentsinadvance", "installments", "comfinyear", "createdby", "createddate", "modifiedby", "modifieddate", 'actualinsurancefee');
     if ($donumberformat == 1) {
         foreach ($accountingdetail->toArray() as $key => $value) {
             if (!in_array($key, $arrNotFormatted)) {
                 if (is_numeric($value) && (double) $value != 0.0) {
                     $value = number_format($value, 2, '.', ',');
                 } else {
                     if ($value == null || $value == '' || is_numeric($value) && (double) $value == 0.0) {
                         $value = '-';
                     }
                 }
                 $accountingdetail->{$key} = $value;
             }
         }
     }
     return $accountingdetail;
 }
コード例 #15
0
ファイル: CarPreemption.php プロジェクト: x-Zyte/nissanhippro
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $employee = Employee::find($model->salesmanemployeeid);
         $model->salesmanteamid = $employee->teamid;
         $model->provinceid = $employee->branch->provinceid;
         $model->branchid = $employee->branchid;
         $model->status = 0;
         if ($model->carobjectivetype == 0) {
             $model->financingfee = null;
             $model->transferfee = null;
             $model->transferoperationfee = null;
         } else {
             if ($model->carobjectivetype == 1) {
                 $model->cashpledgeredlabel = null;
                 $model->registerprovinceid = null;
                 $model->registrationtype = null;
                 $model->registrationfee = null;
             }
         }
         if ($model->contractdate == '') {
             $model->contractdate = null;
         }
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
         Customer::where('id', $model->bookingcustomerid)->orWhere('id', $model->buyercustomerid)->update(['statusexpect' => 0]);
         $bookingcustomerid = $model->bookingcustomerid;
         $buyercustomerid = $model->buyercustomerid;
         CustomerExpectation::where('active', true)->where(function ($query) use($bookingcustomerid, $buyercustomerid) {
             $query->where('customerid', $bookingcustomerid)->orWhere('customerid', $buyercustomerid);
         })->update(['active' => false]);
     });
     static::updating(function ($model) {
         if ($model->carobjectivetype == 0) {
             $model->financingfee = null;
             $model->transferfee = null;
             $model->transferoperationfee = null;
         } else {
             if ($model->carobjectivetype == 1) {
                 $model->cashpledgeredlabel = null;
                 $model->registerprovinceid = null;
                 $model->registrationtype = null;
                 $model->registrationfee = null;
             }
         }
         if ($model->contractdate == '') {
             $model->contractdate = null;
         }
         $model->carPreemptionGiveaways()->delete();
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
 }
コード例 #16
0
ファイル: PostjobController.php プロジェクト: urtop/agency
 /**
  * @param $id
  * @return \yii\web\Response
  */
 public function actionDetails($id)
 {
     $model = $this->findModel($id);
     $dataProvider = new ActiveDataProvider(['query' => Employee::find(), 'pagination' => ['pagesize' => Yii::$app->params['page_size']]]);
     return $this->render('details', ['model' => $model, 'dataProvider' => $dataProvider]);
 }
コード例 #17
0
 public function readCarPreemptionSelectlistForDisplayInGrid($redlabelid)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     if (Auth::user()->isadmin) {
         $carpreemptions = CarPreemption::whereHas('redlabelhistories', function ($q) use($redlabelid) {
             $q->where('redlabelid', $redlabelid);
         })->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']);
     } else {
         $carpreemptions = CarPreemption::where('provinceid', Auth::user()->provinceid)->whereHas('redlabelhistories', function ($q) use($redlabelid) {
             $q->where('redlabelid', $redlabelid);
         })->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);
     }
     return ['carpreemptionselectlist' => implode(";", $carpreemptionselectlist)];
 }
コード例 #18
0
 /**
  * Lists all Employee models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Employee::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #19
0
 public function getbyidforcancelcarpreemption($id)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $model = CarPreemption::find($id);
     $customer = Customer::find($model->buyercustomerid);
     $model->customer = $customer->title . ' ' . $customer->firstname . ' ' . $customer->lastname;
     $carmodel = CarModel::find($model->carmodelid);
     $carsubmodel = CarSubModel::find($model->carsubmodelid);
     $model->carmodel = $carmodel->name . '/' . $carsubmodel->name;
     $salesmanemployee = Employee::find($model->salesmanemployeeid);
     $model->salesmanemployee = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname;
     $model->date = date('d-m-Y', strtotime($model->date));
     return $model;
 }
コード例 #20
0
ファイル: EmployeeController.php プロジェクト: urtop/agency
 /**
  * Lists all Employee models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Employee::find()->where($this->handel_search()), 'pagination' => ['pagesize' => Yii::$app->params['page_size']]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #21
0
 public function actionStafflist($no)
 {
     $model = Employee::find()->where(['no' => $no])->one();
     return Json::encode(['no' => $model->no, 'code' => $model->code, 'title' => $model->title, 'name' => $model->name, 'surname' => $model->surname]);
 }
コード例 #22
0
 public function actionTree()
 {
     /**
      * @var Employee[] $items
      */
     $items = Employee::find()->all();
     $list = [];
     foreach ($items as $item) {
         if (empty($item->parent_id)) {
             if (isset($list[0]) === false) {
                 $list[0] = [];
             }
             $list[0][] = $item;
         } else {
             if (isset($list[$item->parent_id]) === false) {
                 $list[$item->parent_id] = [];
             }
             $list[$item->parent_id][] = $item;
         }
     }
     return $this->render('tree_view', ['list' => $list]);
 }
コード例 #23
0
 public function edit($id)
 {
     $employee = Employee::find($id);
     $types = EmployeeType::getType();
     return view('pages.edit_employee', ['employee' => $employee, 'types' => $types]);
 }
コード例 #24
0
 public function view($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;
     $toemployeeselectlist = array();
     $item = Employee::find($model->toemployeeid);
     $toemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     $item = Employee::find($model->approversemployeeid);
     $toemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     $accountandfinanceemployeeselectlist = array();
     $item = Employee::find($model->accountemployeeid);
     $accountandfinanceemployeeselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
     $item = Employee::find($model->financeemployeeid);
     $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' => 'view', 'pathPrefix' => '../../', 'cancelcarpreemption' => $model, 'carpreemptionselectlist' => $carpreemptionselectlist, 'toemployeeselectlist' => $toemployeeselectlist, 'accountandfinanceemployeeselectlist' => $accountandfinanceemployeeselectlist]);
 }
コード例 #25
0
ファイル: _form.php プロジェクト: YuukiMur/Books_first
/* @var $model app\models\Employee */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="employee-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'Department_id')->dropDownList(ArrayHelper::map(Department::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'Chief_id')->dropDownList(ArrayHelper::map(Employee::find()->all(), 'id', 'Name'));
?>

    <?php 
echo $form->field($model, 'Name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'Salary')->textInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
コード例 #26
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $guesthistory = GuestHistory::find($id);
     Event::fire(new DeleteDataPersonGeneralEvent($guesthistory));
     $dataspouse = $guesthistory->dataspouse;
     $datamother = $guesthistory->datamother;
     $datafather = $guesthistory->datafather;
     $datapresentaddress = $guesthistory->addresspresent;
     $dataoriginaladdress = $guesthistory->addressoriginal;
     foreach ($guesthistory->vehicle as $vehicle) {
         $vehicleId = $vehicle->id;
         Vehicle::find($vehicleId)->delete();
     }
     foreach ($guesthistory->datachild as $datachild) {
         $datachildId = $datachild->id;
         DataChild::find($datachildId)->delete();
     }
     foreach ($guesthistory->employee as $employee) {
         $employeeId = $employee->id;
         Employee::find($employeeId)->delete();
     }
     foreach ($guesthistory->personfamily as $personfamily) {
         $personfamilyId = $personfamily->id;
         PersonFamily::find($personfamilyId)->delete();
     }
     if ($guesthistory) {
         GuestHistory::find($id)->delete();
     }
     if ($dataspouse) {
         $spouseId = $dataspouse->id;
         DataSpouse::find($spouseId)->delete();
     }
     if ($datamother) {
         $motherId = $datamother->id;
         DataMother::find($motherId)->delete();
     }
     if ($datafather) {
         $fatherId = $datafather->id;
         DataFather::find($fatherId)->delete();
     }
     if ($datapresentaddress) {
         $presentId = $datapresentaddress->id;
         AddressPresent::find($presentId)->delete();
     }
     if ($dataoriginaladdress) {
         $original = $dataoriginaladdress->id;
         AddressOriginal::find($original)->delete();
     }
     return $guesthistory;
 }
コード例 #27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($personId, $employeeId)
 {
     $person = CriminalHistory::find($personId);
     if ($employeeId) {
         $employee = Employee::find($employeeId)->delete();
         return $person;
     } else {
         return null;
     }
 }