Exemplo n.º 1
0
 /**
  * 获取供应商信息列表
  */
 public function actionGetdatalist()
 {
     if (isset($_POST['param'])) {
         $param = $_POST['param'];
     }
     if ($param != null) {
         if ($param == "suppliers") {
             $model = Suppliers::find()->where(['uid' => Yii::$app->user->id])->all();
         } else {
             if ($param == "warehouse") {
                 $model = Warehouse::find()->where(['uid' => Yii::$app->user->id])->all();
             } else {
                 if ($param == "color") {
                     $model = Color::find()->where(['uid' => Yii::$app->user->id])->all();
                 }
             }
         }
         if ($model) {
             $json = array();
             $infoArray = array();
             $json['return_code'] = 1;
             foreach ($model as $item) {
                 $infoArray[] = $item->getAttribute('name');
             }
             $json['infoArray'] = $infoArray;
         } else {
             $json['return_code'] = 0;
         }
         echo json_encode($json);
     }
 }
 public function readSelectlist($carmodelid)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $colors = Color::whereHas('carModelColors', function ($q) use($carmodelid) {
         $q->where('carmodelid', $carmodelid);
     })->orderBy('code', 'asc')->get(['id', 'code', 'name']);
     return $colors;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Color::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, 'name' => $this->name, 'uid' => Yii::$app->user->id]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 public function index()
 {
     $cartypes = CarType::all(['id', 'name']);
     $cartypeselectlist = array();
     array_push($cartypeselectlist, ':เลือกประเภทรถ');
     foreach ($cartypes as $ct) {
         array_push($cartypeselectlist, $ct->id . ':' . $ct->name);
     }
     $colors = Color::all(['id', 'code', 'name']);
     $colorselectlist = array();
     array_push($colorselectlist, ':เลือกสี');
     foreach ($colors as $item) {
         array_push($colorselectlist, $item->id . ':' . $item->code . ' - ' . $item->name);
     }
     return view('settings.carmodel', ['cartypeselectlist' => implode(";", $cartypeselectlist), 'colorselectlist' => implode(";", $colorselectlist)]);
 }
Exemplo n.º 5
0
 public function readSelectlistForDisplayInGrid()
 {
     $carsubmodelids = Car::distinct()->lists('carsubmodelid');
     $carsubmodels = CarSubModel::whereIn('id', $carsubmodelids)->orderBy('name', 'asc')->get(['id', 'name']);
     $carsubmodelselectlist = array();
     array_push($carsubmodelselectlist, ':เลือกรุ่น');
     foreach ($carsubmodels as $item) {
         array_push($carsubmodelselectlist, $item->id . ':' . $item->name);
     }
     $colorids = Car::distinct()->lists('colorid');
     $colors = Color::whereIn('id', $colorids)->orderBy('code', 'asc')->get(['id', 'code', 'name']);
     $colorselectlist = array();
     array_push($colorselectlist, ':เลือกสี');
     foreach ($colors as $item) {
         array_push($colorselectlist, $item->id . ':' . $item->code . ' - ' . $item->name);
     }
     return ['carsubmodelselectlist' => implode(";", $carsubmodelselectlist), 'colorselectlist' => implode(";", $colorselectlist)];
 }
Exemplo n.º 6
0
 public function readSelectlist($carmodelid)
 {
     $colorids = CarModelColor::where('carmodelid', $carmodelid)->lists('colorid');
     $colors = Color::whereIn('id', $colorids)->orderBy('code', 'asc')->get(['id', 'code', 'name']);
     return $colors;
 }
Exemplo n.º 7
0
 public function getColors()
 {
     return $this->hasMany(Color::className(), ['id' => 'color_id'])->viaTable('product_color', ['product_id' => 'id']);
 }
Exemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $item = Color::find($id);
     File::delete($item->image);
     $item->delete();
     return redirect("admin/{$this->key}");
 }
 public function getbyid($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;
     $color = Color::find($model->colorid);
     $model->carcolor = $color->code . ' - ' . $color->name;
     $pricelist = Pricelist::find($model->pricelistid);
     $model->carprice = $pricelist->sellingpricewithaccessories + $model->colorprice;
     if (Auth::user()->isadmin) {
         if ($model->carobjectivetype == 0) {
             $cars = Car::doesntHave('carPayment')->where('objective', 0)->where('carmodelid', $model->carmodelid)->where('carsubmodelid', $model->carsubmodelid)->where('colorid', $model->colorid)->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
         } else {
             $cars = Car::doesntHave('carPayment')->where('objective', '!=', 0)->where('carmodelid', $model->carmodelid)->where('carsubmodelid', $model->carsubmodelid)->where('colorid', $model->colorid)->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
         }
     } else {
         if ($model->carobjectivetype == 0) {
             $cars = Car::where('provinceid', Auth::user()->provinceid)->doesntHave('carPayment')->where('objective', 0)->where('carmodelid', $model->carmodelid)->where('carsubmodelid', $model->carsubmodelid)->where('colorid', $model->colorid)->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
         } else {
             $cars = Car::where('provinceid', Auth::user()->provinceid)->doesntHave('carPayment')->where('objective', '!=', 0)->where('carmodelid', $model->carmodelid)->where('carsubmodelid', $model->carsubmodelid)->where('colorid', $model->colorid)->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
         }
     }
     $model->cars = $cars;
     if ($model->finacecompanyid != null && $model->finacecompanyid != '') {
         $finacecompany = FinaceCompany::find($model->finacecompanyid);
         $model->finacecompany = $finacecompany->name;
     }
     if ($model->interestratetypeid != null && $model->interestratetypeid != '') {
         $interestratetype = InterestRateType::find($model->interestratetypeid);
         $model->interestratetype = $interestratetype->name;
     }
     if ($model->purchasetype == 0) {
         $model->yodjud = 0;
         $model->realprice = $model->carprice - $model->discount;
     } else {
         $model->yodjud = $model->carprice - $model->discount - $model->down + $model->accessories;
         $model->realprice = $model->carprice - $model->discount - $model->subdown;
     }
     $salesmanemployee = Employee::find($model->salesmanemployeeid);
     $model->salesmanemployee = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname;
     $approversemployee = Employee::find($model->approversemployeeid);
     $model->approversemployee = $approversemployee->title . ' ' . $approversemployee->firstname . ' ' . $approversemployee->lastname;
     if ($model->carobjectivetype == 0) {
         $registerprovince = Province::find($model->registerprovinceid);
         $model->registerprovince = $registerprovince->name;
         $redlabelhistory = Redlabelhistory::where('carpreemptionid', $id)->first();
         if ($redlabelhistory != null) {
             $redlabel = Redlabel::find($redlabelhistory->redlabelid);
             $model->redlabel = $redlabel->no;
         } else {
             $model->redlabel = "ไม่มีป้าย";
         }
     } else {
         $model->redlabel = null;
     }
     //if($cust->birthdate != null)
     //$cust->birthdate = date('d-m-Y', strtotime($cust->birthdate));
     return $model;
 }
Exemplo n.º 10
0
 /**
  * Finds the Color model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Color the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Color::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 11
0
 public function getsubmodelandcolorbyid($id, $registrationtype, $registerprovinceid)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $carmodel = CarModel::find($id);
     $carmodelregister = CarModelRegister::where('carmodelid', $id)->where('provinceid', $registerprovinceid)->first();
     if ($carmodelregister == null) {
         $registercost = 0;
     } else {
         if ($registrationtype == 0) {
             $registercost = $carmodelregister->individualregistercost;
         } else {
             if ($registrationtype == 1) {
                 $registercost = $carmodelregister->companyregistercost;
             } else {
                 if ($registrationtype == 2) {
                     $registercost = $carmodelregister->governmentregistercost;
                 } else {
                     $registercost = null;
                 }
             }
         }
     }
     $actcharged = $carmodel->cartype->actcharged;
     $carsubmodels = CarSubModel::where('carmodelid', $id)->orderBy('name', 'asc')->get(['id', 'name']);
     $colors = Color::with(['carModelColors' => function ($query) use($id) {
         $query->where('carmodelid', $id);
     }])->whereHas('carModelColors', function ($q) use($id) {
         $q->where('carmodelid', $id);
     })->orderBy('code', 'asc')->get(['id', 'code', 'name']);
     $provinces = Province::with(['carModelRegisters' => function ($query) use($id) {
         $query->where('carmodelid', $id);
     }])->whereHas('carModelRegisters', function ($q) use($id) {
         $q->where('carmodelid', $id);
     })->orderBy('name', 'asc')->get(['id', 'name']);
     return ['carsubmodels' => $carsubmodels, 'colors' => $colors, 'actcharged' => $actcharged, 'registercost' => $registercost, 'registerprovinces' => $provinces];
 }
 public function getAll()
 {
     return \Response::json(array('datos' => Color::orderBy('ts_color.nombre_color')->get()));
 }
Exemplo n.º 13
0
 public function actionStep1()
 {
     Yii::$app->session['carPartTotal'] = 0.0;
     $carPart = new CarPart();
     $sizes = ArrayHelper::map(Size::find()->asArray()->all(), 'id', 'name');
     $colors = ArrayHelper::map(Color::find()->asArray()->all(), 'id', 'name');
     $damages = ArrayHelper::map(Damage::find()->asArray()->all(), 'id', 'name');
     return $this->render('step1', ['carPart' => $carPart, 'sizes' => $sizes, 'colors' => $colors, 'damages' => $damages]);
 }
Exemplo n.º 14
0
<div class="car-form">

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

    <?php 
//= $form->field($model, 'model_id')->textInput()
?>
    <?php 
echo $form->field($model, 'model_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Mod\CatModel::find()->all(), 'id', 'full_name')]);
?>

    <?php 
echo $form->field($model, 'color_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Mod\Color::find()->all(), 'id', 'name'), 'language' => Yii::$app->language]);
?>

	<?php 
echo $form->field($model, 'color_sal_id')->dropDownList(ArrayHelper::map(Mod\ColorSalon::find()->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Select salon color')]);
?>

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

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

    <div class="form-group">
Exemplo n.º 15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $item = Product::with(['color', 'category'])->find($id);
     $images = $item->images;
     $categories = Category::orderBy('sort', 'asc')->get();
     $formCategories = [];
     foreach ($categories as $category) {
         $formCategories[$category->id] = $category->name;
     }
     $colors = Color::all();
     $formColors = [];
     foreach ($colors as $color) {
         $formColors[$color->id] = $color->name;
     }
     $data = ['title' => Product::$tableName, 'item' => $item, 'images' => $images, 'categories' => $formCategories, 'colors' => $formColors];
     return view("admin.{$this->key}.edit", $data);
 }
Exemplo n.º 16
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;
 }
Exemplo n.º 17
0
?>

    <?php 
echo $form->field($model, 'image')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['showRemove' => false, 'showUpload' => false]]);
?>

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

    <?php 
echo $form->field($model, 'color')->widget(Select2::classname(), ['language' => $lang, 'data' => ArrayHelper::map(Color::find()->asArray()->all(), 'id', 'name'), 'options' => ['multiple' => true], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10, 'allowClear' => true], 'pluginEvents ' => ["select2:select" => "function(param) { log(param); }"]]);
?>

    <?php 
echo $form->field($model, 'traits_color')->widget(Select2::classname(), ['language' => $lang, 'data' => ArrayHelper::map(Color::find()->asArray()->all(), 'id', 'name'), 'options' => ['multiple' => true], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10, 'allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'transparency')->widget(Select2::classname(), ['language' => $lang, 'data' => $model->getTransparencyList(), 'pluginOptions' => ['allowClear' => true]]);
?>

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

    <?php 
echo $form->field($model, 'shine')->widget(Select2::classname(), ['language' => $lang, 'data' => ArrayHelper::map(Shine::find()->asArray()->all(), 'id', 'name'), 'options' => ['multiple' => true], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10, 'allowClear' => true]]);
?>

    <?php 
Exemplo n.º 18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getColor()
 {
     return $this->hasOne(Color::className(), ['id' => 'color_id']);
 }
Exemplo n.º 19
0
 public function import()
 {
     try {
         $file = Input::file('file');
         //$path = Input::file('pricelist')->getRealPath();
         $temp = null;
         Excel::load($file, function ($reader) use($temp) {
             //$reader->dump();
             $reader->skip(1);
             // Loop through all rows
             $reader->each(function ($row) {
                 $carBrand = CarBrand::where('name', 'NISSAN')->first();
                 $color = Color::where('code', trim($row->p))->first();
                 $carModel = CarModel::firstOrCreate(['name' => trim($row->c) . ' ' . trim($row->d), 'cartypeid' => $row->b, 'carbrandid' => $carBrand->id]);
                 $carSubModel = CarSubModel::firstOrCreate(['code' => trim($row->f), 'name' => trim($row->e), 'carmodelid' => $carModel->id]);
                 $car = Car::firstOrNew(['engineno' => trim($row->m), 'chassisno' => trim($row->n)]);
                 $car->datatype = 0;
                 $car->provinceid = trim($row->a);
                 $car->carmodelid = $carModel->id;
                 $car->carsubmodelid = $carSubModel->id;
                 $car->receivetype = trim($row->g);
                 $car->dealername = trim($row->h);
                 $car->no = trim($row->i);
                 $car->dodate = trim($row->j);
                 $car->dono = trim($row->k);
                 if ($row->l != null && $row->l != '') {
                     $car->receiveddate = trim($row->l);
                 }
                 if ($row->o != null && $row->o != '') {
                     $car->keyno = trim($row->o);
                 }
                 $car->colorid = $color->id;
                 $car->objective = trim($row->q);
                 if ($row->r != null && $row->r != '') {
                     $car->parklocation = trim($row->r);
                 }
                 if ($row->s != null && $row->s != '') {
                     $car->notifysolddate = trim($row->s);
                 }
                 if ($row->u != null && $row->u != '' && $row->v != null && $row->v != '') {
                     $customer = Customer::firstOrNew(['provinceid' => trim($row->a), 'title' => trim($row->u), 'firstname' => trim($row->v), 'lastname' => trim($row->w)]);
                     $customer->isreal = true;
                     if ($row->x != null && $row->x != '') {
                         $customer->phone1 = trim($row->x);
                     }
                     if ($row->y != null && $row->y != '') {
                         $customer->occupationid = trim($row->y);
                     }
                     if ($row->z != null && $row->z != '') {
                         $customer->birthdate = trim($row->z);
                     }
                     if ($row->aa != null && $row->aa != '') {
                         $customer->address = trim($row->aa);
                     }
                     $district = District::where('name', trim($row->ab))->first();
                     $amphur = Amphur::where('name', trim($row->ac))->first();
                     $province = Province::where('name', trim($row->ad))->first();
                     if ($district != null) {
                         $customer->districtid = $district->id;
                     }
                     if ($amphur != null) {
                         $customer->amphurid = $amphur->id;
                     }
                     if ($province != null) {
                         $customer->addprovinceid = $province->id;
                     }
                     if ($row->ad != null && $row->ad != '') {
                         $customer->zipcode = trim($row->ae);
                     }
                     $customer->save();
                     $car->issold = true;
                     $car->buyercustomerid = $customer->id;
                     if ($row->t != null && $row->t != '') {
                         $car->isdelivered = true;
                     }
                 }
                 $car->save();
             });
         });
     } catch (Exception $e) {
         return 'Message: ' . $e->getMessage();
     }
     return redirect()->action('CarController@index');
 }
Exemplo n.º 20
0
 public function actionColor($q = null, $id = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if (is_null($q)) {
         $q = "";
     }
     $out = ['results' => []];
     $jobs = Color::find()->where('name LIKE :q')->params([':q' => '%' . $q . '%'])->asArray()->all();
     foreach ($jobs as $job) {
         $out['results'][] = ['id' => $job['id'], 'text' => $job['name']];
     }
     return $out;
 }
Exemplo n.º 21
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);
     }
     $occupations = Occupation::orderBy('name', 'asc')->get(['id', 'name']);
     $occupationselectlist = array();
     array_push($occupationselectlist, ':เลือกอาชีพ');
     foreach ($occupations as $item) {
         array_push($occupationselectlist, $item->id . ':' . $item->name);
     }
     $addprovinces = Province::orderBy('name', 'asc')->get(['id', 'name']);
     $addprovinceselectlist = array();
     array_push($addprovinceselectlist, ':เลือกจังหวัด');
     foreach ($addprovinces as $item) {
         array_push($addprovinceselectlist, $item->id . ':' . $item->name);
     }
     $amphurs = Amphur::has('customers')->orderBy('name', 'asc')->get(['id', 'name']);
     $amphurselectlist = array();
     array_push($amphurselectlist, ':เลือกเขต/อำเภอ');
     foreach ($amphurs as $item) {
         array_push($amphurselectlist, $item->id . ':' . $item->name);
     }
     $districts = District::has('customers')->orderBy('name', 'asc')->get(['id', 'name']);
     $districtselectlist = array();
     array_push($districtselectlist, ':เลือกตำบล/แขวง');
     foreach ($districts as $item) {
         array_push($districtselectlist, $item->id . ':' . $item->name);
     }
     if (Auth::user()->isadmin) {
         $employees = Employee::orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'firstname', 'lastname']);
     } else {
         $provinceid = Auth::user()->provinceid;
         $employees = Employee::whereHas('branch', function ($q) use($provinceid) {
             $q->where('provinceid', $provinceid);
         })->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'firstname', 'lastname']);
     }
     $employeeselectlist = array();
     array_push($employeeselectlist, ':เลือกพนักงาน');
     foreach ($employees as $emp) {
         array_push($employeeselectlist, $emp->id . ':' . $emp->firstname . ' ' . $emp->lastname);
     }
     $carmodels = CarModel::whereHas("carbrand", function ($q) {
         $q->where('ismain', true);
     })->orderBy('name', 'asc')->get(['id', 'name']);
     $carmodelselectlist = array();
     array_push($carmodelselectlist, ':เลือกแบบ');
     foreach ($carmodels as $cm) {
         array_push($carmodelselectlist, $cm->id . ':' . $cm->name);
     }
     $colors = Color::all(['id', 'code', 'name']);
     $colorselectlist = array();
     array_push($colorselectlist, ':เลือกสี');
     foreach ($colors as $item) {
         array_push($colorselectlist, $item->id . ':' . $item->code . ' - ' . $item->name);
     }
     $defaultProvince = '';
     if (Auth::user()->isadmin == false) {
         $defaultProvince = Auth::user()->provinceid;
     }
     return view($this->viewname, ['colorselectlist' => implode(";", $colorselectlist), 'provinceselectlist' => implode(";", $provinceselectlist), 'addprovinceselectlist' => implode(";", $addprovinceselectlist), 'amphurselectlist' => implode(";", $amphurselectlist), 'districtselectlist' => implode(";", $districtselectlist), 'carmodelselectlist' => implode(";", $carmodelselectlist), 'employeeselectlist' => implode(";", $employeeselectlist), 'occupationselectlist' => implode(";", $occupationselectlist), 'defaultProvince' => $defaultProvince]);
 }