public function up()
 {
     Yii::app()->setImport(['application.modules.mail.models.*']);
     $this->insert('site_mail_mail_event', ['code' => 'USER_AUTOSEARCH', 'name' => 'Результаты автопоиска', 'description' => 'Результаты автопоиска']);
     $m = MailEvent::model()->findByAttributes(['code' => 'USER_AUTOSEARCH']);
     $this->insert('site_mail_mail_template', ['code' => '	USER_AUTOSEARCH', 'event_id' => $m->id, 'name' => 'Результаты автопоиска', 'description' => 'Результаты автопоиска', 'from' => '*****@*****.**', 'to' => '{user_email}', 'theme' => 'Результаты автопоиска', 'body' => '<p>Результаты автопоиска на сайте {site_name}<br></p><p>По автопоискам обнаружены новые заявки.<br></p><p>С уважением, администрация сайта {site_name} !<br><br></p>', 'status' => 1]);
 }
 public function loadModel($id)
 {
     if (($model = MailEvent::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
 /**
  * Возвращает модель по указанному идентификатору
  * Если модель не будет найдена - возникнет HTTP-исключение.
  *
  * @param integer $id - integer идентификатор нужной модели
  *
  * @return void
  *
  * @throws CHttpExcetption
  */
 public function loadModel($id)
 {
     if (($model = MailEvent::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('MailModule.mail', 'Requested page was not found.'));
     }
     return $model;
 }
Exemplo n.º 4
0
 /**
  * raiseMailEvent:
  *
  * @param  string $code - код
  * @param  array $data - данные
  * @throws CException
  * @return bool
  **/
 public function raiseMailEvent($code, array $data)
 {
     $mailEvent = MailEvent::model()->with('templates')->find(['condition' => 't.code = :code', 'params' => [':code' => $code]]);
     if (!$mailEvent) {
         throw new CException(Yii::t('MailModule.mail', 'MainEvent with "{code}" code was not found!'), [':code' => $code]);
     }
     if (!count($mailEvent->templates)) {
         throw new CException(Yii::t('MailModule.mail', 'MainEvent with code "{code}" don\'t contain any of active templates!'), [':code' => $code]);
     }
     foreach ($mailEvent->templates as $template) {
         $parsedData = $this->parseTemplate($template, $data);
         if ($this->message_layout) {
             if (isset(Yii::app()->controller)) {
                 $parsedData['body'] = Yii::app()->getController()->renderPartial($this->message_layout, ['content' => $parsedData['body']], true);
             } else {
                 $controller = new Controller('site');
                 $viewPath = Yii::getPathOfAlias('themes') . '/default/views/layouts/mail.php';
                 $parsedData['body'] = $controller->renderInternal($viewPath, ['content' => $parsedData['body']], true);
             }
         }
         if (!$this->getMailComponent()->send($parsedData['from'], $parsedData['from_name'], $parsedData['to'], $parsedData['theme'], $parsedData['body'])) {
             throw new CException(Yii::t('MailModule.mail', 'Error when sending mail!'));
         }
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * raiseMailEvent:
  *
  * @param string $code - код
  * @param array  $data - данные
  * @throws CException
  * @return bool
  **/
 public function raiseMailEvent($code, array $data)
 {
     $mailEvent = MailEvent::model()->with('templates')->find(array('condition' => 't.code = :code', 'params' => array(':code' => $code)));
     if (!$mailEvent) {
         throw new CException(Yii::t('MailModule.mail', 'MainEvent with "{code}" code was not found!'), array(':code' => $code));
     }
     if (!count($mailEvent->templates)) {
         throw new CException(Yii::t('MailModule.mail', 'MainEvent with code "{code}" don\'t contain any of active templates!'), array(':code' => $code));
     }
     foreach ($mailEvent->templates as $template) {
         $parsedData = $this->parseTemplate($template, $data);
         if (!$this->getMailComponent()->send($parsedData['from'], $parsedData['to'], $parsedData['theme'], $parsedData['body'])) {
             throw new CException(Yii::t('MailModule.mail', 'Error when sending mail!'));
         }
     }
     return true;
 }
 public function up()
 {
     /*
      * ALTER TABLE `site_response` ADD `confirmation_date` DATETIME NULL AFTER `update`;
      * ALTER TABLE `site_response` ADD `offer_to_review` DATETIME NULL AFTER `confirmation_date`;
      * ALTER TABLE `site_review` ADD INDEX( `status`, `rating`, `create`);
      */
     $this->execute("ALTER TABLE `site_response` ADD `confirmation_date` DATETIME NULL AFTER `update`;");
     $this->execute("ALTER TABLE `site_response` ADD `offer_to_review` DATETIME NULL AFTER `confirmation_date`;");
     $this->execute("ALTER TABLE `site_review` ADD INDEX( `status`, `rating`, `create`);");
     Yii::app()->setImport(['application.modules.mail.models.*']);
     $this->insert('site_mail_mail_event', ['code' => 'USER_SUPPLIER_REVIEW', 'name' => 'Оценить работу поставщика', 'description' => 'Оценить работу поставщика и написать отзыв']);
     $m = MailEvent::model()->findByAttributes(['code' => 'USER_SUPPLIER_REVIEW']);
     $this->insert('site_mail_mail_template', ['code' => 'USER_SUPPLIER_REVIEW', 'event_id' => $m->id, 'name' => 'Оценить работу поставщика', 'description' => 'Оценить работу поставщика и написать отзыв', 'from' => '*****@*****.**', 'to' => '{user_email}', 'theme' => 'Пожалуйста оцените работу поставщика', 'body' => '<p>Вы делали заказ {site_response} на сайте {site_name}<br></p><p>Предлагаем вам оценить работу поставщика и оставить отзыв, для этого нажмите {site_review}</p>' . '<p>С уважением, администрация сайта {site_name} !<br><br></p>', 'status' => 1]);
     ///////////////////////////////////////////////////////////////////////////////////////////////////////
     $this->insert('site_mail_mail_event', ['code' => 'USER_NEW_REVIEW', 'name' => 'Новый отзыв', 'description' => 'Отправить сообщение о новом отзыве']);
     $m = MailEvent::model()->findByAttributes(['code' => 'USER_NEW_REVIEW']);
     $this->insert('site_mail_mail_template', ['code' => 'USER_NEW_REVIEW', 'event_id' => $m->id, 'name' => 'Новый отзыв', 'description' => 'Отправить сообщение о новом отзыве', 'from' => '*****@*****.**', 'to' => '{user_email}', 'theme' => 'Появился новый отзыв на сайте {site_name}', 'body' => '<p>В заказе {site_response} компания {other_company_name} оставила о вас отзыв:<br></p>' . '<p>Оценка: {rating}</p>' . '<p>Отзыв: {rating_message}</p>' . '<p>С уважением, администрация сайта {site_name} !<br><br></p>', 'status' => 1]);
 }
Exemplo n.º 7
0
        <span class="required">*</span>
        <?php 
echo Yii::t('MailModule.mail', 'are required.');
?>
    </div>

    <?php 
echo $form->errorSummary($model);
?>

    <div class='control-group <?php 
echo $model->hasErrors("event_id") ? "error" : "";
?>
'>
        <?php 
echo $form->dropDownListRow($model, 'event_id', CHtml::listData(MailEvent::model()->findAll(), 'id', 'title'), array('class' => 'span7', 'maxlength' => 10, 'empty' => Yii::t('MailModule.mail', '--choose--')));
?>
    </div>
    <div class='control-group <?php 
echo $model->hasErrors("title") ? "error" : "";
?>
'>
        <?php 
echo $form->textFieldRow($model, 'title', array('class' => 'span7', 'maxlength' => 150));
?>
    </div>
    <div class='control-group <?php 
echo $model->hasErrors("code") ? "error" : "";
?>
'>
        <?php 
Exemplo n.º 8
0
echo Yii::t('MailModule.mail', 'Fields, with');
?>
    <span class="required">*</span>
    <?php 
echo Yii::t('MailModule.mail', 'are required.');
?>
</div>

<?php 
echo $form->errorSummary($model);
?>

<div class='row'>
    <div class="col-sm-4">
        <?php 
echo $form->dropDownListGroup($model, 'event_id', ['widgetOptions' => ['data' => CHtml::listData(MailEvent::model()->findAll(), 'id', 'name'), 'htmlOptions' => ['empty' => Yii::t('MailModule.mail', '--choose--')]]]);
?>
    </div>
    <div class="col-sm-3">
        <?php 
echo $form->dropDownListGroup($model, 'status', ['widgetOptions' => ['data' => $model->getStatusList(), 'htmlOptions' => []]]);
?>
    </div>
</div>
<div class='row'>
    <div class="col-sm-7">
        <?php 
echo $form->textFieldGroup($model, 'name');
?>
    </div>
</div>
Exemplo n.º 9
0
?>
<fieldset>
    <div class="row">
        <div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'name');
?>
        </div>
        <div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'code');
?>
        </div>
        <div class="col-sm-3">
            <?php 
echo $form->dropDownListGroup($model, 'event_id', ['widgetOptions' => ['data' => CHtml::listData(MailEvent::model()->findAll(), 'id', 'name'), 'htmlOptions' => ['empty' => '---']]]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'description');
?>
        </div>
        <div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'from');
?>
        </div>
        <div class="col-sm-3">
Exemplo n.º 10
0
<div class="page-header">
    <h1><?php 
echo Yii::t('MailModule.mail', 'Mail templates');
?>
        <small><?php 
echo Yii::t('MailModule.mail', 'management');
?>
</small>
    </h1>
</div>

<p>
    <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="collapse" data-target="#search-toggle">
        <i class="fa fa-search">&nbsp;</i>
        <?php 
echo Yii::t('MailModule.mail', 'Find mail templates');
?>
        <span class="caret">&nbsp;</span>
    </a>
</p>

<div id="search-toggle" class="collapse out">
    <?php 
Yii::app()->clientScript->registerScript('search', "\n    \$('.search-form').submit(function () {\n        \$.fn.yiiGridView.update('mail-template-grid', {\n            data: \$(this).serialize()\n        });\n\n        return false;\n    });\n");
$this->renderPartial('_search', ['model' => $model]);
?>
</div>

<?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'mail-template-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'actionsButtons' => [CHtml::link(Yii::t('YupeModule.yupe', 'Add'), ['/mail/templateBackend/create'], ['class' => 'btn btn-success pull-right btn-sm'])], 'columns' => [['name' => 'id', 'type' => 'raw', 'value' => 'CHtml::link($data->id, array("/mail/templateBackend/update", "id" => $data->id))', 'htmlOptions' => ['style' => 'width:20px']], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'name', 'editable' => ['url' => $this->createUrl('/mail/templateBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'filter' => CHtml::activeTextField($model, 'name', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'code', 'editable' => ['url' => $this->createUrl('/mail/templateBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'filter' => CHtml::activeTextField($model, 'code', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => ['url' => $this->createUrl('/mail/templateBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'title' => Yii::t('MailModule.mail', 'Select {field}', ['{field}' => mb_strtolower($model->getAttributeLabel('event_id'))]), 'source' => CHtml::listData(MailEvent::model()->findAll(), 'id', 'name'), 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'name' => 'event_id', 'type' => 'raw', 'value' => '$data->event->name', 'filter' => CHtml::activeDropDownList($model, 'event_id', CHtml::listData(MailEvent::model()->findAll(), 'id', 'name'), ['class' => 'form-control', 'empty' => ''])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'theme', 'editable' => ['url' => $this->createUrl('/mail/templateBackend/inline'), 'mode' => 'inline', 'type' => 'text', 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'filter' => CHtml::activeTextField($model, 'theme', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'from', 'editable' => ['url' => $this->createUrl('/mail/templateBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'filter' => CHtml::activeTextField($model, 'from', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'to', 'editable' => ['url' => $this->createUrl('/mail/templateBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'filter' => CHtml::activeTextField($model, 'to', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'status', 'url' => $this->createUrl('/mail/templateBackend/inline'), 'source' => $model->getStatusList(), 'options' => [MailTemplate::STATUS_ACTIVE => ['class' => 'label-success'], MailTemplate::STATUS_NOT_ACTIVE => ['class' => 'label-default']]], ['class' => 'yupe\\widgets\\CustomButtonColumn']]]);
Exemplo n.º 11
0
 public function getEventList()
 {
     return CHtml::listData(MailEvent::model()->findAll(), 'id', 'name');
 }
Exemplo n.º 12
0
        <div class="span3">
            <?php 
echo $form->textFieldRow($model, 'name', array('maxlength' => 300));
?>
        </div>

        <div class="span3">
            <?php 
echo $form->textFieldRow($model, 'code', array('maxlength' => 100));
?>
        </div>

        <div class="span3">
            <?php 
echo $form->dropDownListRow($model, 'event_id', CHtml::listData(MailEvent::model()->findAll(), 'id', 'name'), array('empty' => '---', 'maxlength' => 10));
?>
        </div>

    </div>

    <div class="row-fluid control-group">

        <div class="span3">
           <?php 
echo $form->textFieldRow($model, 'description');
?>
        </div>

        <div class="span3">
            <?php 
Exemplo n.º 13
0
<?php

$this->widget('yupe\\widgets\\CustomGridView', array('id' => 'mail-template-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('style' => 'width:20px')), array('name' => 'title', 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('placement' => 'right')), array('name' => 'code', 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('placement' => 'right')), array('name' => 'event_id', 'type' => 'raw', 'value' => '$data->event->title', 'filter' => CHtml::listData(MailEvent::model()->findAll(), 'id', 'title'), 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('mode' => 'popup', 'type' => 'select', 'source' => CHtml::listData(MailEvent::model()->findAll(), 'id', 'title'))), array('name' => 'theme', 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('placement' => 'right')), array('name' => 'from', 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('placement' => 'right')), array('name' => 'from_name', 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('placement' => 'right')), array('name' => 'to', 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('placement' => 'right')), array('name' => 'status', 'type' => 'raw', 'value' => '$data->getStatus()', 'filter' => $model->getStatusList(), 'class' => 'yupe.widgets.CustomEditableColumn', 'editable' => array('mode' => 'popup', 'type' => 'select', 'source' => $model->getStatusList())), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}{delete}', 'htmlOptions' => array('style' => 'width:60px')))));
Exemplo n.º 14
0
 <small><?php 
echo Yii::t('MailModule.mail', 'management');
?>
</small></h1>
</div>
<button class="btn btn-small dropdown-toggle"  data-toggle="collapse" data-target="#search-toggle" >
    <i class="icon-search"></i>
    <a class="search-button" href="#"><?php 
echo Yii::t('MailModule.mail', 'Find mail templates');
?>
</a>    <span class="caret"></span>
</button>

<div id="search-toggle" class="collapse out">
<?php 
Yii::app()->clientScript->registerScript('search', "\n    \$('.search-form').submit(function(){         \n        \$.fn.yiiGridView.update('mail-template-grid', {\n            data: \$(this).serialize()\n        });\n        return false;\n    });\n");
$this->renderPartial('_search', array('model' => $model));
?>
</div>

<br/>

<p>
    <?php 
echo Yii::t('MailModule.mail', 'This section contain mail message templates management');
?>
</p>

<?php 
$this->widget('yupe\\widgets\\CustomGridView', array('id' => 'mail-template-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'code', array('name' => 'event_id', 'value' => '$data->event->name', 'filter' => CHtml::listData(MailEvent::model()->findAll(), 'id', 'name')), 'name', 'theme', 'from', 'to', array('name' => 'status', 'value' => '$data->getStatus()'), array('class' => 'bootstrap.widgets.TbButtonColumn'))));