public static function createAppointmentLinkUsingDeal($instructionId, $appStartDate, $appType = Appointment::TYPE_VIEWING) { if (!$instructionId || !$appStartDate) { return false; } $appointmentsByDeal = LinkDealToAppointment::model()->findAllByAttributes(['d2a_dea' => $instructionId]); $appIdsByDeal = []; foreach ($appointmentsByDeal as $value) { /** @var $value LinkDealToAppointment[ ] */ if ($value->appointment->app_start == $appStartDate && $value->appointment->app_type == $appType) { $appIdsByDeal[] = $value->appointment->app_id; } } return AppointmentController::createAppointmentUpdateLink(reset($appIdsByDeal)); }
public function actionFeedback($id) { /** @var $model LinkDealToAppointment */ $model = LinkDealToAppointment::model()->findByPk($id); if (!$model) { throw new CHttpException(404, 'Feedback [id=' . $id . '] is not found'); } if (isset($_POST['LinkDealToAppointment']) && $_POST['LinkDealToAppointment']) { $model->attributes = $_POST['LinkDealToAppointment']; if ($model->save()) { if (isset($_POST['submitOffer']) && $_POST['submitOffer']) { $this->redirect(['Offer/create', 'feedbackId' => $model->d2a_id]); } } } $this->render('feedback', ['model' => $model]); }
public function actionCreate($instructionId = null, $feedbackId = null) { /** @var $feedback LinkDealToAppointment */ if (isset($_GET['popup'])) { $this->asPopup(); } $model = new Offer(); $model->off_deal = $instructionId; $model->off_date = date('d/m/Y'); $model->off_status = Offer::STATUS_NOT_SUBMITTED; if ($feedbackId) { $feedback = LinkDealToAppointment::model()->findByPk($feedbackId); // we get clients and instruction out of feedback; $model->off_deal = $feedback->deal->dea_id; $model->clients = $feedback->appointment->clients; $model->off_app = $feedback->appointment->app_id; } if (!$model->instruction) { throw new BadMethodCallException('Offer must be assigned to instruction'); } $this->edit($model); }