public function actionSelectClient() { AppointmentBuilder::start(); AppointmentBuilder::getCurrent()->setUser(Yii::app()->user->id); $availableTypes = ['viewing', 'valuation']; $appointmentType = isset($_GET['for']) && in_array($_GET['for'], $availableTypes) ? $_GET['for'] : reset($availableTypes); $appointmentDate = isset($_GET['date']) && $_GET['date'] ? Date::formatDate("Y/m/d", $_GET['date']) : date("Y/m/d"); $model = new Client('search'); $model->cli_created = ''; $model->cli_saleemail = ''; $model->telephones = [new Telephone('search')]; AppointmentBuilder::getCurrent()->setDate($appointmentDate); AppointmentBuilder::getCurrent()->setType($appointmentType); AppointmentBuilder::getCurrent()->setInstructionId(isset($_GET['instructionId']) ? $_GET['instructionId'] : null); $this->render('selectClient', compact('model', 'appointmentDate', 'appointmentType')); }