</div> <div role="tabpanel" class="tab-pane" id="outbox"> <?php foreach ($model['outbox'] as $data) { echo '<div class="messagesBox">'; echo ' <div class="title"> ' . $data->title . ' [ ' . date("d-m-Y H:i:s", strtotime($data->created_at)) . ' ] ' . ($data->read == 0 ? '<span class="newMsg">Новое письмо</span>' : '') . ' </div>'; echo ' <div class="body"> ' . $data->body . ' '; foreach (WebsiteMessages::model()->findAll('delivery_name LIKE ("' . $data->delivery_name . '") AND recipient_id IN (' . $data->author_id . ') ORDER BY id DESC') as $sub) { echo ' <HR style="border: 1px dashed"> <span>от <b>' . User::model()->findByPk($sub->author_id)->email . '</b> [ ' . date("d-m-Y H:i:s", strtotime($data->created_at)) . ' ]</span></BR>' . $sub->body; } echo ' <hr> ' . ($data->read == 0 ? '<div class="readBoxBlock"><input type="checkbox" data-id="' . $data->id . '" class="readBox" /><span class="readBoxTxt">Отметить, как прочитанное</span></div>' : '') . ' '; echo '</div>'; echo '</div>'; echo '<div style="clear: both;"></div>'; } ?> </div>
?> <!-- Fields with <span class="required">*</span> are required. --> <!--<p class="help-block"><?php echo Yii::t("Bootstrap", "PHRASE.FIELDS_REQUIRED"); ?> </p>--> <?php echo $form->errorSummary($model); ?> <!-- Получатель --> <?php echo $form->dropDownListRow($model, 'recipient_id', WebsiteMessages::model()->getUsergroup(), array('class' => 'span5')); ?> <?php echo $form->textFieldRow($model, 'title', array('class' => 'span5', 'maxlength' => 350)); Yii::import('ext.imperavi-redactor-widget-master.ImperaviRedactorWidget'); $this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'body', 'options' => array('lang' => 'ru', 'imageUpload' => Yii::app()->createAbsoluteUrl('/' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/imageUpload')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js'))))); //echo $form->textFieldRow($model,'send_date',array('class'=>'span5'));; ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'htmlOptions' => array('style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE'))); ?>
public function actionAjax() { if (Yii::app()->request->isPostRequest) { $type = Yii::app()->request->getParam('type', array()); if (isset($type)) { $id = Yii::app()->request->getParam('id', array()); switch ($type) { case 'confRead': $model = WebsiteMessages::model()->findByPk($id); if ($model) { $model->read = 1; $model->save(); } break; case 'answerMsg': if ($this->rule == 1) { break; } $msg = Yii::app()->request->getParam('msg', array()); $modelMessages = WebsiteMessages::model()->findByPk((int) $id); $model = new WebsiteMessages(); $model->author_id = Yii::app()->user->id; $model->recipient_id = $modelMessages->author_id; $model->title = 'RE: ' . $modelMessages->title; $model->body = $msg; $model->delivery_name = $modelMessages->delivery_name; $model->read = 0; $model->save(); $modelMessages->read = 1; $modelMessages->save(); break; case 'deleteMsg': if ($this->rule == 1 || $this->rule == 2) { break; } $model = WebsiteMessages::model()->findByPk($id); if ($model) { $model->delete(); } break; } echo 'ok'; Yii::app()->end(); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
<legend><?php echo Yii::t("Bootstrap", "LIST.WebsiteMessages"); ?> </legend> <?php $assetsDir = Yii::app()->basePath; $labels = WebsiteMessages::model()->attributeLabels(); echo '<a href="/admin/websitemessages/websitemessages/create" style="margin-bottom: 20px" class="btn">Создать</a>'; echo ' <ul class="nav nav-tabs" role="tablist"> <li role="webmessages"><a href="#inbox" aria-controls="inbox" role="tab" data-toggle="tab">Входящие</a></li> <li role="webmessages" class="active"><a href="#outbox" aria-controls="outbox" role="tab" data-toggle="tab">Отправленные</a></li> </ul> '; echo ' <div class="tab-content" id="tabListData"> <div role="tabpanel" class="tab-pane active" id="outbox"> '; //Исходящие $this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'website-in-messages-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $provider['outbox'], 'filter' => $model, 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["author_id"], 'name' => 'author_id', 'value' => '$data->author ? $data->author->username : ""', 'filter' => CHtml::listData(User::model()->findAll(array('order' => 'username')), 'id', 'username')), array('header' => $labels["title"], 'name' => "title"), array('header' => $labels["body"], 'name' => "body"), array('header' => $labels["created_at"], 'name' => "created_at", 'value' => 'date("d-m-Y H:m:s", strtotime($data->created_at))'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{delete}', 'buttons' => array('delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap'))))); echo ' </div> <div role="tabpanel" class="tab-pane" id="inbox"> '; //Входящие $this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'website-out-messages-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $provider['inbox'], 'filter' => $model, 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["author_id"], 'name' => 'author_id', 'value' => '$data->author ? $data->author->username : ""', 'filter' => CHtml::listData(User::model()->findAll(array('order' => 'username')), 'id', 'username')), array('header' => $labels["title"], 'name' => "title"), array('header' => $labels["body"], 'name' => "body"), array('header' => $labels["created_at"], 'name' => "created_at", 'value' => 'date("d-m-Y H:m:s", strtotime($data->created_at))'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'buttons' => array('update' => array('label' => 'Ответить', 'url' => 'CHtml::normalizeUrl(array("answer", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap'))))); echo ' </div> </div>
public function actionAnswer($id) { $msgSelected = WebsiteMessages::model()->findByPk($id); $model = WebsiteMessages::model()->findAll('delivery_name LIKE ("' . $msgSelected->delivery_name . '") AND recipient_id IN (' . $msgSelected->recipient_id . ',' . $msgSelected->author_id . ') ORDER BY id DESC'); if (isset($_POST['WebsiteMessages'])) { $modelAnswer = new WebsiteMessages(); $modelAnswer->attributes = $_POST['WebsiteMessages']; $modelAnswer->author_id = Yii::app()->user->id; $modelAnswer->recipient_id = $msgSelected->author_id; $modelAnswer->title = 'RE: ' . $msgSelected->title; $modelAnswer->read = 0; $modelAnswer->delivery_name = $msgSelected->delivery_name; $modelAnswer->save(); $this->redirect($this->listUrl('index')); } $this->render('answer', array('model' => $model)); }