public function approveApplication(Request $request) { $shop_card_application_id = $request->input('require_id'); $application = ShopCardApplication::find($shop_card_application_id); $customer = Customer::find($application->customer_id); $card_type = $application->cardType; try { \DB::transaction(function () use($application, $customer, $card_type) { $customer_rows = \DB::table('customers')->where('id', $customer->id); $customer_rows->lockForUpdate(); $customer_row = $customer_rows->first(); if ($customer_row->beans_total < $card_type->beans_value * $application->amount) { throw new NotEnoughBeansException(); } $cards = \DB::table('shop_cards')->where('card_type_id', '=', $card_type->id)->whereNull('customer_id')->limit($application->amount); $cards->lockForUpdate(); if ($cards->count() < $application->amount) { throw new CardNotEnoughException(); } $customer->minusBeansByHand($application->amount * $card_type->beans_value); $cards->update(['customer_id' => $customer->id, 'bought_at' => Carbon::now()]); $application->update(['authorized' => true]); return true; }); } catch (CardNotEnoughException $e) { return '相应卡片不足,无法继续。'; } catch (NotEnoughBeansException $e) { return '用户迈豆不足!'; } return "操作成功!"; }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validation_rules($request); $customerUpdate = $request->input(); $customer = Customer::find($id); $customer->update($customerUpdate); Session::flash('flash_message', 'Data pelanggan berhasil diupdate!'); return redirect('admin/customer'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $customer = Customer::find($id); if (!$customer) { return response()->json('Le client n\'existe pas.', 404); } $customer->delete(); return 'Le client a bien été supprimé.'; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $customer = null; if (!empty($id)) { $customer = Customer::find($id); $customer_details = DB::table('customer_details')->where('customer_uuid', $customer->uuid)->get(); } // print_r($customer); return view('customer.edit', ['theme' => 'default', 'customer' => $customer, 'customer_details' => $customer_details]); }
public function testInvite() { $c = Customer::find(3); $counter = new CustomerInvitationCounter(Customer::find(1)); $before = $counter->getMonthlyCount(); // $this->assertEquals(0, $before); event(new Register($c)); $after = $counter->getMonthlyCount(); $this->assertEquals($before + 1, $after); }
public function actionCategory($url = null) { $query = Project::find(); $addition = Project::find()->select('id')->orderBy('id ASC')->limit(3)->asArray()->all(); if (!is_null($url)) { $query->innerJoinWith('category', 'category_id = category_id')->where(['url' => $url]); } $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 9]]); $projectModel = Project::find()->joinWith('category', 'category.category_id = project.category_id')->orderBy('id ASC')->limit(3)->all(); return $this->render('category', ['dataProvider' => $dataProvider, 'categoryModel' => Category::find()->all(), 'customerModel' => Customer::find()->all(), 'projectModel' => $projectModel]); }
public function update(Request $request, $id) { $this->validate($request, $this->rules); $data = $request->all(); /* @var Receivable $receivable */ $receivable = Receivable::find($id); $receivable->update($data); $customer = Customer::find($data['customer']['id']); $receivable->customer()->associate($customer); $receivable->save(); return (new ApiParcel())->addMessage('general', 'Conta a pagar alterado com sucesso!'); }
public function getIndex() { if (Auth::customer()->check()) { $id = Auth::customer()->user()->id; $table = new Customer(); if (!empty($id)) { $table = Customer::find($id); } return viewc('client.' . self::NAMEC . '.index', compact('table')); } return redirect('login')->with('messageError', 'Inicie sesion'); }
public function getAppointments() { $appointments = Appointment::all(); $calendarAppointments = array(); foreach ($appointments as $a) { $customer = Customer::find($a['customer_id']); $customer = $customer->first_name . ' ' . $customer->last_name; $event = array('title' => 'Appointment with ' . $customer, 'start' => $a['appointment_datetime']); array_push($calendarAppointments, $event); } return response()->json($calendarAppointments); }
public function index() { if (!$this->hasPermission($this->menuPermissionName)) { return view($this->viewPermissiondeniedName); } $provinces = Province::whereHas('branchs', function ($q) { $q->where('isheadquarter', true); })->orderBy('name', 'asc')->get(['id', 'name']); $provinceselectlist = array(); array_push($provinceselectlist, ':เลือกจังหวัด'); foreach ($provinces as $item) { array_push($provinceselectlist, $item->id . ':' . $item->name); } if (Auth::user()->isadmin) { $customers = Customer::has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']); } else { $customers = Customer::where('provinceid', Auth::user()->provinceid)->has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']); } $customerselectlist = array(); foreach ($customers as $item) { array_push($customerselectlist, $item->id . ':' . $item->title . ' ' . $item->firstname . ' ' . $item->lastname); } if (Auth::user()->isadmin) { $cars = Car::has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']); } else { $cars = Car::where('provinceid', Auth::user()->provinceid)->has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']); } $carselectlist = array(); array_push($carselectlist, ':เลือกรถ'); foreach ($cars as $item) { array_push($carselectlist, $item->id . ':' . $item->chassisno . '/' . $item->engineno); } if (Auth::user()->isadmin) { $carpreemptions = CarPreemption::has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']); } else { $carpreemptions = CarPreemption::where('provinceid', Auth::user()->provinceid)->has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']); } $carpreemptionselectlist = array(); array_push($carpreemptionselectlist, ':เลือกการจอง'); foreach ($carpreemptions as $item) { $buyercustomer = Customer::find($item->buyercustomerid); $buyercustomername = $buyercustomer->title . ' ' . $buyercustomer->firstname . ' ' . $buyercustomer->lastname; $salesmanemployee = Employee::find($item->salesmanemployeeid); $salesmanemployeename = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname; array_push($carpreemptionselectlist, $item->id . ':' . str_pad($item->bookno . '/' . $item->no, strlen($item->bookno . '/' . $item->no) + 15, " ") . str_pad($buyercustomername, strlen($buyercustomername) + 15, " ") . $salesmanemployeename); } $defaultProvince = ''; if (Auth::user()->isadmin == false) { $defaultProvince = Auth::user()->provinceid; } return view('redlabel', ['provinceselectlist' => implode(";", $provinceselectlist), 'customerselectlist' => implode(";", $customerselectlist), 'carselectlist' => implode(";", $carselectlist), 'carpreemptionselectlist' => implode(";", $carpreemptionselectlist), 'defaultProvince' => $defaultProvince]); }
public function actionIndex() { $categoryModel = Category::find()->All(); $projectModel = Project::find()->where(['show_in_index' => '1'])->limit(6)->all(); $customerModel = Customer::find()->All(); $applicationConfig = ApplicationConfig::find()->one(); $newsModel = News::find()->where(['show_in_index' => '1'])->limit(2)->all(); $galleryModel = Gallery::find()->orderBy(new Expression('rand()'))->limit(6)->all(); $visitor = ApplicationConfig::findOne(1); $visitor->visitors_count = $visitor->visitors_count + 1; $visitor->save(); return $this->render('index', ['categoryModel' => $categoryModel, 'projectModel' => $projectModel, 'customerModel' => $customerModel, 'applicationConfig' => $applicationConfig, 'newsModel' => $newsModel, 'galleryModel' => $galleryModel]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::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(['like', 'username', $this->username])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::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(['customer_id' => $this->customer_id, 'cust_group_id' => $this->cust_group_id, 'salutation' => $this->salutation, 'gender' => $this->gender, 'last_password_gen' => $this->last_password_gen, 'birthday' => $this->birthday, 'flag_newsletter' => $this->flag_newsletter, 'status' => $this->status, 'flag_active' => $this->flag_active, 'date_added' => $this->date_added, 'date_update' => $this->date_update]); $query->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', 'ip_add_newsletter', $this->ip_add_newsletter])->andFilterWhere(['like', 'note', $this->note])->andFilterWhere(['like', 'last_visit', $this->last_visit]); return $dataProvider; }
public function search_supplier($params) { $query = Customer::find()->where(['customer_type' => 'S']); $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(['customer_id' => $this->customer_id, 'customer_poscode' => $this->customer_poscode]); $query->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'customer_add1', $this->customer_add1])->andFilterWhere(['like', 'customer_add2', $this->customer_add2])->andFilterWhere(['like', 'customer_add3', $this->customer_add3])->andFilterWhere(['like', 'customer_tel', $this->customer_tel])->andFilterWhere(['like', 'customer_fax', $this->customer_fax])->andFilterWhere(['like', 'customer_email', $this->customer_email])->andFilterWhere(['like', 'customer_type', $this->customer_type])->andFilterWhere(['like', 'customer_remark', $this->customer_remark])->andFilterWhere(['like', 'customer_attention', $this->customer_attention])->andFilterWhere(['like', 'customer_active', $this->customer_active])->andFilterWhere(['like', 'customer_GSTno', $this->customer_GSTno]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::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, 'uid' => Yii::$app->user->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'tell', $this->tell])->andFilterWhere(['like', 'addr', $this->addr])->andFilterWhere(['like', 'remark', $this->remark]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $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_customer' => $this->id_customer]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'country', $this->country]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['cus_id']]]); $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, 'create_date' => $this->create_date]); $query->andFilterWhere(['like', 'cus_id', $this->company])->andFilterWhere(['like', 'tax_number', $this->tax_number])->andFilterWhere(['like', 'company', $this->company])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'agent', $this->agent]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'registration_date', $this->registration_date])->andFilterWhere(['like', 'author_id', $this->author_id])->andFilterWhere(['like', 'updater_id', $this->updater_id])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at]); return $dataProvider; }
public function update($id, Request $request) { $customer = Customer::find($id); $rules = $customer->getValidatorRules(); $validator = $this->validate($request, $rules); if ($validator) { return response()->json($validator, '404'); } $input = $request->all(); if (isset($input['image']) && empty($input['image'])) { unset($input['image']); } $customer->update($input); $customer->save(); return $customer; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['customer_id' => $this->customer_id]); $query->andFilterWhere(['like', 'customer_nama', $this->customer_nama])->andFilterWhere(['like', 'customer_alamat', $this->customer_alamat])->andFilterWhere(['like', 'customer_no_hp', $this->customer_no_hp])->andFilterWhere(['like', 'customer_email', $this->customer_email])->andFilterWhere(['like', 'customer_password', $this->customer_password]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'phone_number', $this->phone_number]); return $dataProvider; }
/** * Retrieves all appointments and returns them * in fullCalendar expected JSON */ public function GetAllAppointments() { $appointments = Appointment::all(); $calendarAppointments = array(); foreach ($appointments as $a) { $customer = Customer::find($a['customer_id']); $customer = $customer->first_name . ' ' . $customer->last_name; $package = Package::find($a['appointment_type']); $startDate = date_create($a['appointment_datetime']); $endDate = date_create($a['appointment_datetime']); $time = (string) $package->package_time . ' hours'; $endDate = date_add($endDate, date_interval_create_from_date_string($time)); $event = array('id' => $a['id'], 'title' => 'Appointment with ' . $customer, 'start' => $startDate->format('Y-m-d\\TH:i:s'), 'end' => $endDate->format('Y-m-d\\TH:i:s')); array_push($calendarAppointments, $event); } return response()->json($calendarAppointments); }
public function actionIndex() { //一个顾客有多少订单 $customer = Customer::find()->where(['id' => 1])->one(); //$orders=$customer->hasMany('\app\models\Order',array('cid'=>'id'))->asArray()->all(); //获取类的全路径 echo Order::className(); //降低耦合:存在的问题是:如果表字段更换,就得从新再修改控制器,所以把这部分业务放在model中处理,以后修改字段,修改model, //$orders=$customer->hasMany(Order::className(),array('cid'=>'id'))->asArray()->all(); //调用model中的方法 //$orders=$customer->getOrder(); //调用类中的魔术方法__get,order属性不存在时,就调用getOrder方法 $orders = $customer->order; var_dump($orders); //查看一个订单属于哪个顾客 $order = Order::find()->where(['id' => 3])->one(); $o = $order->hasOne(Customer::className(), array('id' => 'cid'))->asArray()->one(); var_dump($o); }
public function postIndex(FormCustomerRequest $request) { if (!empty($request)) { $data = $request->all(); // $data['flagactive'] = $request->get('flagactive', 1); $id = Auth::customer()->user()->id; unset($data['password']); $password = $request->get('password', null); if (!empty($password)) { $data['password'] = Hash::make($request->get('password')); } if ($id) { $obj = Customer::find($id); $obj->update($data); } return redirect('admclient/' . self::NAMEC)->with('messageSuccess', 'Perfil Guardado'); } return redirect('admclient')->with('messageError', 'Error al guardar el perfil'); }
public function a() { $p = 0; for ($i = 87; $i <= CustomerInformation::orderBy('id', 'desc')->first()->id; $i++) { $info = CustomerInformation::find($i); if (!$info) { continue; } if ($info->type == 'A' && ($customer_id = $info->customer_id)) { $customer = Customer::find($customer_id); $counter = new CustomerInvitationCounter($customer); print $info->name; print ' '; print $counter->getMonthlyCount(); print '<br>'; $p++; } } print '共' . $p . '人'; }
/** * Creates a new Customer model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Customer(); if ($model->load(Yii::$app->request->post())) { $tax_number = $model->tax_number; $check = $model->find()->where(['tax_number' => $tax_number])->one(); if ($check['tax_number'] != '') { $config = new \app\models\Config_system(); $cusId = $config->autoId("customer", "cus_id", 7); return $this->render('create', ['error' => "ลูกค้าบริษัทนี้นี้มีอยู่ในระบบแล้ว ...!", 'model' => $model, 'cus_id' => $cusId]); } else { $model->create_date = date("Y-m-d H:i:s"); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } } else { $config = new \app\models\Config_system(); $cusId = $config->autoId("customer", "cus_id", 7); return $this->render('create', ['error' => '', 'model' => $model, 'cus_id' => $cusId]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customer::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; } if (isset($this->time) && $this->time != '') { $date_explode = explode(" to ", $this->time); $date1 = trim($date_explode[0]); $date2 = trim($date_explode[1]); $date2 = date("Y-m-d", strtotime("+1 day", strtotime($date2))); $query->andFilterWhere(['between', 'time', $date1, $date2]); } $query->andFilterWhere(['id' => $this->id, 'unpay' => $this->unpay, 'payed' => $this->payed, 'sum' => $this->sum]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'info', $this->info]); return $dataProvider; }
public function shopIndex(Request $request) { if (\Helper::hasSessionCachedUser()) { return redirect('/shop/index'); } elseif ($request->has('customer_id')) { $customer = Customer::find($request->input('customer_id')); \Session::put(AppConstant::SESSION_USER_KEY, ['openid' => $customer->openid]); return redirect('/shop/index'); } else { return redirect('http://www.ohmate.cn/redirect/web-shop-index'); } // $user = \Helper::getUser(); // $customer = \Helper::getCustomerOrNull(); // // if (!$customer) { // $customer = Customer::create([ // 'openid' => $user['openid'], // 'referrer_id' => 0, // 'type_id' => 1, // ]); // } }
/** * Record activity to Logs * AJAX * * @param Request $request */ public function getTransactionHistory(Request $request) { if ($request->ajax()) { $history = Customer::find($request->customerId)->transactionLogs; return collect($history)->toJson(); } }
/** * Updates an existing Quotation model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $updateQuotationDetail = new QuotationDetail(); $quotationDetails = QuotationDetail::find()->where(['quotationdetail_quotationid' => $id])->orderBy('quotationdetail_id')->all(); $product = Product::find()->where(['product_type' => 'p'])->orderBy('product_id')->all(); $service = Product::find()->where(['product_type' => 's'])->orderBy('product_id')->all(); $customer = Customer::find()->orderBy('customer_name')->all(); $company = Company::findOne(1); $customerID = $model->quotation_customerid; $thisCustomer = Customer::findOne($customerID); $uid = Yii::$app->user->identity->user_id; $uname = Yii::$app->user->identity->user_name; $details = []; foreach ($quotationDetails as $detail) { $details[] = $detail->quotationdetail_id; } if (isset($_POST['description'])) { $quotationDetailList = $_POST['description']; $customer_id = $_POST['customer-list']; $quotation_id = $_POST['quotation_id']; $quotation_no = $_POST['quotation_no']; $quotation_date = $_POST['quotation_date']; $productType = $_POST['productType']; $qty = $_POST['qty']; $unit = $_POST['unit']; $cost = $_POST['cost']; $remarks = $_POST['remarks']; $hidden_price = $_POST['hidden_price']; $hidden_gst = $_POST['hidden_gst']; $hidden_tax_code = $_POST['hidden_tax_code']; $hidden_tax_rate = $_POST['hidden_tax_rate']; $hidden_price_gst = $_POST['hidden_price_gst']; $hidden_total = $_POST['hidden_total']; $hidden_gsttotal = $_POST['hidden_gsttotal']; $hidden_gstpricetotal = $_POST['hidden_gstpricetotal']; $hidden_id = $_POST['hidden_id']; $hidden_quotationid = $_POST['hidden_quotationid']; $hidden_product_name = $_POST['hidden_product_name']; if ($quotationDetailList != NULL) { if ($remarks == NULL) { $remarks = "-"; } $updateQuotation = $this->findModel($id); $updateQuotation->quotation_id = $quotation_id; $updateQuotation->quotation_no = $quotation_no; $updateQuotation->quotation_date = $quotation_date; $updateQuotation->quotation_date_transaction = $quotation_date; $updateQuotation->quotation_customerid = $customer_id; $updateQuotation->quotation_createid = $uid; $updateQuotation->quotation_createname = $uname; $updateQuotation->quotation_remark = $remarks; $updateQuotation->quotation_system = "y"; $updateQuotation->quotation_partno = "y"; $updateQuotation->quotation_invoice = "123"; $updateQuotation->quotation_deliveryorder = "lol"; $updateQuotation->quotation_charge = 123; $updateQuotation->quotation_tax_label = "lol"; $updateQuotation->quotation_tax_percent = 1; $updateQuotation->quotation_tax_amount = 100; $updateQuotation->quotation_printed_status = "y"; $updateQuotation->quotation_revision = 1; $updateQuotation->quotation_parts_total = $hidden_total; $updateQuotation->quotation_no_user_format = "lol"; $updateQuotation->quotation_gst_payable = $hidden_gsttotal; $updateQuotation->quotation_total_amount = $hidden_gstpricetotal; $updateQuotation->save(); foreach ($quotationDetailList as $key => $n) { if ($hidden_quotationid[$key] == NULL || $hidden_quotationid[$key] == '') { if ($unit[$key] == NULL) { $unit[$key] = "-"; } $newQuotationDetail = new QuotationDetail(); $newQuotationDetail->quotationdetail_quotationid = $quotation_id; $newQuotationDetail->quotationdetail_productid = $n; $newQuotationDetail->quotationdetail_partno = "lol"; $newQuotationDetail->quotationdetail_productname = $hidden_product_name[$key]; $newQuotationDetail->quotationdetail_producttype = $productType[$key]; $newQuotationDetail->quotationdetail_unit = $qty[$key]; $newQuotationDetail->quotationdetail_unitname = $unit[$key]; $newQuotationDetail->quotationdetail_product_cost = $cost[$key]; $newQuotationDetail->quotationdetail_price = $hidden_price[$key]; $newQuotationDetail->quotationdetail_tax_code = $hidden_tax_code[$key]; $newQuotationDetail->quotationdetail_tax_rate = $hidden_tax_rate[$key]; $newQuotationDetail->quotationdetail_tax_amount = $hidden_gst[$key]; $newQuotationDetail->quotationdetail_total_amount = $hidden_price_gst[$key]; $newQuotationDetail->quotationdetail_gst_status = 1; $newQuotationDetail->save(); } elseif (in_array($hidden_quotationid[$key], $details)) { $delete = array_search($hidden_quotationid[$key], $details); if ($delete !== false) { unset($details[$delete]); } if ($unit[$key] == NULL) { $unit[$key] = "-"; } $qid = $hidden_id[$key]; $updateQuotationDetail = QuotationDetail::findOne($qid); $updateQuotationDetail->quotationdetail_quotationid = $quotation_id; $updateQuotationDetail->quotationdetail_productid = $n; $updateQuotationDetail->quotationdetail_partno = "lol"; $updateQuotationDetail->quotationdetail_productname = $hidden_product_name[$key]; $updateQuotationDetail->quotationdetail_producttype = $productType[$key]; $updateQuotationDetail->quotationdetail_unit = $qty[$key]; $updateQuotationDetail->quotationdetail_unitname = $unit[$key]; $updateQuotationDetail->quotationdetail_product_cost = $cost[$key]; $updateQuotationDetail->quotationdetail_price = $hidden_price[$key]; $updateQuotationDetail->quotationdetail_tax_code = $hidden_tax_code[$key]; $updateQuotationDetail->quotationdetail_tax_rate = $hidden_tax_rate[$key]; $updateQuotationDetail->quotationdetail_tax_amount = $hidden_gst[$key]; $updateQuotationDetail->quotationdetail_total_amount = $hidden_price_gst[$key]; $updateQuotationDetail->quotationdetail_gst_status = 1; $updateQuotationDetail->save(); } } foreach ($details as $delete) { QuotationDetail::findOne($delete)->delete(); } } } if ($updateQuotationDetail->save()) { return $this->redirect(['index']); } elseif ($updateQuotationDetail->load(Yii::$app->request->post())) { return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model, 'quotationDetails' => $quotationDetails, 'product' => $product, 'service' => $service, 'customer' => $customer, 'thisCustomer' => $thisCustomer, 'company' => $company]); } }