本文整理汇总了PHP中Appointment::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Appointment::model方法的具体用法?PHP Appointment::model怎么用?PHP Appointment::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appointment
的用法示例。
在下文中一共展示了Appointment::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$apps = Appointment::model()->DIT(Appointment::DIT_BOOKED)->passed()->findAll();
foreach ($apps as $app) {
$this->log('Booking follow up for app id=' . $app->app_id);
$followUp = $app->bookDITFollowUp();
$this->log('newly created follow up id=' . $followUp->app_id);
}
}
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:9,代码来源:CronCreateFollowupsForPassedDITAppointmentsCommand.php
示例2: getDataById
private function getDataById($id)
{
$data = [];
$client = Client::model()->findByPk($id);
if ($client) {
$data[] = ['label' => 'Client: ' . $client->getFullName(), 'value' => $client->getFullName(), 'url' => $this->createUrl('client/update', ['id' => $client->cli_id])];
}
$instruction = Deal::model()->findByPk($id);
if ($instruction) {
$data[] = ['label' => 'Instruction: ' . $instruction->title, 'value' => $instruction->title, 'url' => $this->createUrl('instruction/summary', ['id' => $instruction->dea_id])];
}
/** @var Appointment $appointment */
$appointment = Appointment::model()->with('user')->findByPk($id);
if ($appointment) {
$data[] = ['label' => $appointment->app_type . ': ' . Date::formatDate('d/m H:i', $appointment->app_start) . ' ' . $appointment->user->getFullName(), 'value' => $instruction->title, 'url' => $this->createUrl('instruction/update', ['id' => $instruction->dea_id])];
}
return $data;
}
示例3: doJob
protected function doJob($arg)
{
$tomorrow = strtotime("+ 12 day", strtotime(date('Y-m-d H:i:s')));
$mAppointment = Appointment::model()->findAll(array('condition' => 't.date_appointment < "' . date('Y-m-d H:i:s', $tomorrow) . '" AND t.date_appointment > "' . date('Y-m-d H:i:s') . '"', 'order' => 't.date_appointment ASC'));
if (count($mAppointment) > 0) {
foreach ($mAppointment as $eApp) {
foreach ($eApp->bookings as $booking) {
if ($booking->email_reminded == 0) {
//send email notification to doctor
$modelEmailTemplate = EmailTemplates::model()->findByPk(8);
$dataEmail = array($booking->appointment->users->first_name . ' ' . $booking->appointment->users->last_name, $booking->user->first_name . ' ' . $booking->user->last_name, $booking->user->email, $booking->user->phone, date('l, d M Y, g:i A', strtotime($booking->appointment->date_appointment)), $booking->id, $booking->user->first_name . ' ' . $booking->user->last_name);
$pattern = array('{DOCTOR_NAME}', '{PATIENT_NAME}', '{PATIENT_EMAIL}', '{PATIENT_PHONE}', '{DATE_APPOINTMENT}', '{BOOKING_ID}', '{BOOKING_NAME}');
$message = str_replace($pattern, $dataEmail, $modelEmailTemplate->email_body);
$subject = $modelEmailTemplate->email_subject;
$data = array('subject' => $subject, 'params' => array('message' => $message), 'view' => 'message', 'to' => $booking->appointment->users->email, 'from' => Yii::app()->params['autoEmail']);
CmsEmail::mail($data);
//send email notification to patient
$modelEmailTemplate = EmailTemplates::model()->findByPk(7);
$dataEmail = array($booking->appointment->users->first_name . ' ' . $booking->appointment->users->last_name, $booking->user->first_name . ' ' . $booking->user->last_name, $booking->appointment->users->doctors->main_specialty, date('l, d M Y, g:i A', strtotime($booking->appointment->date_appointment)), $booking->id, $booking->appointment->address->address);
$pattern = array('{DOCTOR_NAME}', '{PATIENT_NAME}', '{DOCTOR_SPECIALTY}', '{DATE_APPOINTMENT}', '{BOOKING_ID}', '{DOCTOR_ADDRESS}');
$message = str_replace($pattern, $dataEmail, $modelEmailTemplate->email_body);
$subject = $modelEmailTemplate->email_subject;
$data = array('subject' => $subject, 'params' => array('message' => $message), 'view' => 'message', 'to' => $booking->user->email, 'from' => Yii::app()->params['autoEmail']);
CmsEmail::mail($data);
$booking->email_reminded = 1;
$booking->update(array('email_reminded'));
$this->index++;
//count email is sent for current cron job
if ($this->index >= $this->max) {
break;
}
}
}
}
} else {
return;
}
}
示例4: actionView
public function actionView($id)
{
/** @var $model Appointment */
$model = Appointment::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404, 'Appointment [id = ' . $id . '] is not found.');
}
if (isset($_POST['delete'])) {
$model->deactivate();
$this->redirect(['View', 'id' => $model->app_id]);
}
if (isset($_POST['restore'])) {
$model->activate();
$this->redirect(['View', 'id' => $model->app_id]);
}
if (isset($_POST['Appointment']) && $_POST['Appointment']) {
$model->attributes = $_POST['Appointment'];
if ($_POST['startDay']) {
$model->app_start = Date::formatDate("Y-m-d", $_POST['startDay']);
}
if ($_POST['startTime']) {
$model->app_start = date("Y-m-d H:i:s", strtotime($model->app_start . " " . $_POST['startTime']));
}
if ($_POST['endDay']) {
$model->app_end = Date::formatDate("Y-m-d", $_POST['endDay']);
}
if ($_POST['endTime']) {
$model->app_end = date("Y-m-d H:i:s", strtotime($model->app_end . " " . $_POST['endTime']));
}
if ($model->save()) {
Yii::app()->user->setFlash('appointment-success', 'Updated!');
$this->redirect(['View', 'id' => $model->app_id]);
}
}
$this->render('view', compact('model'));
}
示例5: 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();
}
示例6: countNumOfAppointment
public function countNumOfAppointment($date, $doctor_id)
{
$criteria = new CDbCriteria();
$criteria->compare('DATE(date_appointment)', date('Y-m-d', $date));
$criteria->compare('doctor_id', $doctor_id);
return Appointment::model()->count($criteria);
}
示例7: actionConfirm
public function actionConfirm($app)
{
/** @var Appointment $model */
$model = Appointment::model()->findByPk($app);
if (!$model) {
throw new CHttpException(404, 'Appointment [id: ' . $app . '] not found');
}
if ($_POST) {
/** @var Telephone[] $phones */
$phones = [];
// mapping phones for fast access
foreach (Telephone::model()->findAllByPk($_POST['phones']) as $value) {
$phones[$value->tel_id] = $value;
}
/** @var Deal[] $instructions */
$instructions = [];
foreach ($model->instructions as $instruction) {
$instructions[$instruction->dea_id] = $instruction;
// mapping iinstructions
}
/** @var Client[] $clients */
$clients = [];
$clientKeys = array_merge(isset($_POST['vendors']) ? array_keys($_POST['vendors']) : [], isset($_POST['clients']) ? array_keys($_POST['clients']) : []);
foreach (Client::model()->findAllByPk($clientKeys) as $key => $value) {
$clients[$value->cli_id] = $value;
}
$sendMessage = function ($clientId, $data) use($phones, $instructions, $clients, $model) {
if (!$data['send'] || !$data['send_to'] || !isset($phones[$data['send_to']])) {
return;
}
$sms = new Sms();
$sms->toNumber = $phones[$data['send_to']]->tel_number;
$sms->clientId = $clientId;
$sms->text = $data['text'];
$sms->send();
$model->addTextMessage($sms);
};
$errors = [];
if (isset($_POST['vendors'])) {
foreach ($_POST['vendors'] as $vendorId => $data) {
try {
$sendMessage($vendorId, $data);
} catch (Exception $e) {
$errors[] = $e;
}
}
}
if (isset($_POST['clients'])) {
foreach ($_POST['clients'] as $vendorId => $data) {
try {
$sendMessage($vendorId, $data);
} catch (Exception $e) {
$errors[] = $e;
}
}
}
$model->saveTextMessages();
if (!$errors) {
Yii::app()->user->setFlash('messages-sent', 'Text messages successfully sent.');
}
}
$this->render('confirm', compact('model'));
}