public function checkPrice() { $totalPrice = 0; $cost = $this->User->UserDB->cost; $racquetCustomer = TblRacquetsUser::finder()->findBy_id($this->DDLCustomerRacquets->SelectedValue); $this->customer = TblUsers::finder()->findBy_id($racquetCustomer->tbl_users_id); $costCustomer = $this->customer->cost; if ($costCustomer == 0) { $totalPrice += $cost; } else { $totalPrice += $costCustomer; } $mainString = TblStrings::finder()->findBy_id($this->DDLStringMains->SelectedValue); $mainStringCost = RelStringPrice::finder()->find('id_strings = ? AND id_stringer = ?', $mainString->id, $this->User->UserDB->id); $costMain = $mainStringCost->price / 2; $totalPrice += $costMain; $costCross = 0; if (!$this->ActivateStringCross->Checked) { $costCross = $costMain; } else { $crossString = TblStrings::finder()->findBy_id($this->DDLStringCross->SelectedValue); $crossStringCost = RelStringPrice::finder()->find('id_strings = ? AND id_stringer = ?', $crossString->id, $this->User->UserDB->id); $costCross = $crossStringCost->price / 2; } $totalPrice += $costCross; if ($this->DDLGrips->SelectedValue != 0) { $totalPrice += TblGrips::finder()->findBy_id($this->DDLGrips->SelectedValue)->price; } if ($this->DDLOvergrips->SelectedValue != 0) { $totalPrice += TblOvergrips::finder()->findBy_id($this->DDLOvergrips->SelectedValue)->price; } $this->TotalPrice->Text = $totalPrice; }
public function saveClicked() { if ($this->getViewState('string', null) == null) { $this->string = new TblStrings(); } else { $this->string = $this->getViewState('string', null); } $this->string->tbl_brands_id = $this->DDLBrands->SelectedValue; $this->string->tbl_gauges_id = $this->DDLGauges->SelectedValue; $this->string->tbl_string_type_id = $this->DDLType->SelectedValue; $this->string->model = $this->Model->Text; $this->string->code = $this->Code->Text; $this->string->exact_gauge = $this->ExactGauge->Text; $this->string->save(); $price = RelStringPrice::finder()->find('id_stringer = ? AND id_strings = ?', $this->User->UserDB->id, $this->string->id); if ($price == null) { $price = new RelStringPrice(); $price->id_stringer = $this->User->UserDB->id; $price->id_strings = $this->string->id; } $price->price = $this->Price->Text; $price->save(); $this->editable->Visible = false; $this->RefreshData(); $this->DataGridStrings->SelectedItemIndex = -1; $this->DataGridStrings->DataSource = $this->Data; $this->DataGridStrings->dataBind(); }