/** * This action will trigger every 15 minute * @return avoid */ public function actionIndex() { // send message $mschedules = MessageSchedule::find()->all(); $this->_run($mschedules); // send checklist $cschedules = ChecklistSchedule::find()->all(); $this->_run($cschedules); }
/** * Deletes an existing Message model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $this->findModel($id)->delete(); MessageSchedule::deleteAll(['messages_id' => $id]); return $this->redirect(['/messages']); }
<?php use app\models\MessageSchedule; ?> <table class="table table-striped table-vcenter"> <tbody> <?php $mschedules = MessageSchedule::find()->where(['messages_id' => $message_id])->orderBy('id DESC')->all(); if (!empty($mschedules)) { foreach ($mschedules as $key => $mschedule) { ?> <tr> <td> <small data-toggle="tooltip" data-original-title="Client"><span class="label label-default"><i class="fa fa-fw fa-user"></i></span></small> <small data-toggle="tooltip" data-original-title="Active"><span class="label label-default"><i class="fa fa-fw fa-bell"></i></span></small> <?php echo $mschedule->descriptions; ?> </td> <td class="text-right" style="width:140px;"> <a data-toggle="modal" href="#modal-mchedules-message-view" class="btn btn-xs btn-default btn-view-mschedules" data-to="/mschedules/view/<?php echo $mschedule->id; ?> " data-update="#message-view"><i class="fa fa-eye"></i>View</a> <a data-toggle="modal" href="#modal-schedules-edit" class="btn btn-xs btn-default btn-edit-mschedule" data-to="/mschedules/edit/<?php echo $mschedule->id; ?> " data-load="/mschedules/load/<?php echo $mschedule->id; ?> " data-message-id="<?php echo $message_id;
/** * Finds the MessageSchedule model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MessageSchedule the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MessageSchedule::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getMschedule() { return $this->hasMany(MessageSchedule::className(), ['messages_id' => 'id']); }