本文整理汇总了PHP中Appointment::setInstructions方法的典型用法代码示例。如果您正苦于以下问题:PHP Appointment::setInstructions方法的具体用法?PHP Appointment::setInstructions怎么用?PHP Appointment::setInstructions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appointment
的用法示例。
在下文中一共展示了Appointment::setInstructions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
protected function afterSave()
{
/** @var $user User */
$userId = $this->followUpUser ?: Yii::app()->user->id;
$user = User::model()->findByPk($userId);
if ($this->followUpDue) {
if ($note = $this->followUpAppointment) {
$note->app_start = date("Y-m-d", strtotime($this->followUpDue));
$note->app_user = $user ? $user->use_id : $note->app_user;
$note->calendarID = $user ? $user->use_branch : $note->calendarID;
} else {
if (!$user) {
throw new Exception('User for follow up is not selected');
}
$note = new Appointment();
$note->app_type = Appointment::TYPE_VALUATION_FOLLOW_UP;
$note->app_start = date("Y-m-d", strtotime($this->followUpDue));
$note->app_user = $user->use_id;
$note->calendarID = $user->use_branch;
$note->app_subject = $this->property->address->toString(', ');
$note->setInstructions([$this->dea_id]);
}
$existingFollowUps = Appointment::model()->findByAttributes(array("app_user" => $note->app_user, 'app_type' => Appointment::TYPE_VALUATION_FOLLOW_UP), array('order' => 'app_start DESC', 'condition' => 'DATE(app_start) = "' . date("Y-m-d", strtotime($note->app_start)) . '"'));
if (!$existingFollowUps) {
$note->app_start = date("Y-m-d", strtotime($note->app_start)) . " 09:00:00";
// hardcoded time, not best solution ever
$note->app_end = date("Y-m-d", strtotime($note->app_start)) . " 09:30:00";
} else {
$note->app_start = $existingFollowUps->app_end;
$note->app_end = date("Y-m-d H:i:s", strtotime($note->app_start . " + 30 minutes"));
}
if ($note->save()) {
$this->followUpAppointmentId = $note->app_id;
$this->saveAttributes(['followUpAppointmentId']);
} else {
$this->addError("followUpUppointment", "Could not save follow up appointment");
}
$this->followUpAppointment = $note;
}
parent::afterSave();
}