Commit 8fca25f6 authored by Shakarim Sapa's avatar Shakarim Sapa

Merge remote-tracking branch 'origin/master'

parents c8f50546 2f792aa6
<?php
namespace common\modules\testings\controllers;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\testings\models\SendHistory;
use common\modules\testings\models\SearchSendHistory;
class SendHistoryAdminController extends AdminController
{
public static function actionsTitles()
{
return array(
'Manage' => 'Управление пользователями',
'Resend-dublicates' => '',
);
}
public function actionManage($session)
{
$searchModel = new SearchSendHistory();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'История отправки дубликатов';
Yii::$app->controller->breadcrumbs = [
'История отправки дубликатов',
];
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'session_id' => $session
]);
}
public function actionResendDublicates()
{
if(Yii::app()->request->isAjaxRequest)
{
if(Yii::app()->request->getPost('email') && Yii::app()->request->getPost('id'))
{
$model = TestingSendHistory::model()->findByPK(Yii::app()->request->getPost('id'));
$path = Yii::getPathOfAlias('webroot') . TestingSendHistory::FOLDER_PATH;
$file = $path . $model->file;
if($model->file && file_exists($file))
{
$body = Setting::getValue('email_multiple_user_test_notice_body');
$subject = Setting::getValue('email_test_notice_head');
$mailer_letter = MailerLetter::model();
$body = $mailer_letter->compileText($body, array(
'test_link' => CHtml::link(Yii::app()->controller->createAbsoluteUrl('/testings/testingTest'), Yii::app()->controller->createAbsoluteUrl('/testings/testingTest')),
));
unset($mailer_letter);
$attachments = array(
$model->file => $file
);
MailerModule::sendMailUniSender(Yii::app()->request->getPost('email'), $subject, $body, $model, $attachments);
echo CJavaScript::jsonEncode(array(
'success' => true,
'message' => 'Отправка прошла успешно'
));
}
else
{
echo CJavaScript::jsonEncode(array(
'success' => false,
'message' => 'Файл возможно был удален!'
));
}
}
else
{
echo CJavaScript::jsonEncode(array(
'success' => false,
'message' => 'Данные введены не верно!'
));
}
}
else
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
/**
* Finds the Faq model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Faq the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = SendHistory::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
......@@ -6,7 +6,7 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\User;
use common\modules\users\models\User;
class Passing extends \common\components\ActiveRecordModel
{
......
<?php
namespace common\modules\testings\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\SendHistory;
class SearchSendHistory extends SendHistory
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'session_id', 'sended', 'user_id'], 'integer'],
[['id', 'email', 'session_id', 'file', 'sended', 'user_id'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params, $order = null, $limit = null)
{
$query = SendHistory::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => ['pageSize' => self::PAGE_SIZE],
'sort'=>array(
'defaultOrder'=>'sended DESC',
),
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'email' => $this->email,
'session_id' => Yii::$app->request->get('session'),
'file' => $this->file,
'sended' => $this->sended,
'user_id' => 0,
]);
if(!empty($order))
$query->orderBy($order);
if(!empty($limit))
$query->limit($limit);
return $dataProvider;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -28,9 +28,9 @@ use common\modules\testings\models\Passing;
<p>
<?= Html::a('Добавить', ['create', 'session' => $session->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Импорт из XLS-файла', ['/testings/session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('Экспорт результатов в XLS-файл', ['/testings/session-admin/export-session-result', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<!--<?= Html::a('Добавить', ['create', 'session' => $session->id], ['class' => 'btn btn-success']) ?>-->
<!--<?= Html::a('Импорт из XLS-файла', ['/testings/session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-info']) ?>-->
<!--<?= Html::a('Экспорт результатов в XLS-файл', ['/testings/session-admin/export-session-result', 'id' => $session->id], ['class' => 'btn btn-info']) ?>-->
</p>
<?php echo AdminGrid::widget([
......@@ -46,7 +46,7 @@ use common\modules\testings\models\Passing;
{
if($model->user)
{
return Html::a($model->user->fio, ["/testings/user-admin/view", "id" => $model->user->id]);
return Html::a($model->user->surname . ' ' . $model->user->name, ["/testings/user-admin/view", "id" => $model->user->id]);
}
else
{
......
<?php
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use yii\helpers\Url;
use common\modules\testings\models\SendHistory;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<?php echo AdminGrid::widget([
'dataProvider' => $dataProvider,
// 'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'email',
[
'attribute' => 'sended',
'value' => function($model)
{
return date("d.m.Y H:i:s", $model->sended);
}
],
[
'attribute' => 'unisender_status',
'value' => function($model)
{
return SendHistory::getStatusTitle($model->unisender_status);
},
'filter' => SendHistory::getStatusTitle(),
],
[
'class' => \common\components\ColorActionColumn::className(),
'template' => '{send} {file}',
'buttons' => [
'send' => function ($url, $model, $key)
{
if($model->file && file_exists($model->getFilePath()))
{
return Html::a('<i class="fa fa-envelope fa-lg"></i>', Url::to(['testings/session-admin/send-message', 'id' => $session->id, 'user' => $model->id]), [
'title' => 'Уведомить о тестировании',
'data-toggle' => 'tooltip',
'data-pjax' => '0',
]);
}
},
'file' => function ($url, $model, $key)
{
if($model->file && file_exists($model->getFilePath()))
{
return Html::a('<i class="fa fa-file-text-o fa-lg"></i>', $model->getFileUrl(), [
'title' => 'Скачать список доступов',
'data-toggle' => 'tooltip',
'data-pjax' => '0',
]);
}
},
]
]
],
]); ?>
\ No newline at end of file
<?php
$this->tabs = array(
'просмотреть сессию' => $this->createUrl('/testings/testingPassingAdmin/manage',array('session'=>$model->id)),
);
$this->page_title = 'Импорт пользователей из CSV-файла';
$this->crumbs = array(
'Список сессий' => array('/testings/testingSessionAdmin/manage'),
$model->name => array('/testings/testingPassingAdmin/manage','session'=>$model->id),
'Импорт пользователей из CSV-файла',
);
?>
<?php if (Yii::app()->user->hasFlash('flash')): ?>
<?php echo $this->msg(Yii::app()->user->getFlash('flash'), 'ok'); ?>
<?php endif ?>
<?php if (isset($log)) : ?>
<?php $this->tabs['загрузить ещё пользователей из CSV-файла'] = $this->createUrl('/testings/testingSessionAdmin/importCSV',array('id'=>$model->id)); ?>
<div><?php echo $log; ?></div>
<script type="text/javascript">
jQuery('#log_box p').each(function(){
var str = $(this).text();
var reg = /Ошибка/gi;
if (str.match(reg)) {
$(this).css('background-color','#ccc').css('color','red');
}
});
</script>
<?php endif; ?>
<span style="font-size: 14px; color: #008C66;">Краткая инструкция по файла назначения теста пользователям</span><br /><br />
<div>
Для загрузки реестра пользователей на сайт необходимо:
<ol>
<li>Заполнить <a href="/upload/users/Users_example_table.xls">шаблон</a> в формате MS Excel. Поля для назначения тестов имеют формат "да/нет".</li>
<li>ВАЖНО! Список тестов в сессии необходимо создать заранее! Порядок создания тестов в сессии определяет порядок столбцов в файле!</li>
<li>Сохранить файл как CSV (разделители-запятые).</li>
<li>Загрузить файл на сайт c помощью кнопки ниже.</li>
</ol>
<span style="color: red;">Важно!</span> Не используйте клавишу ENTER для перевода строки при заполнении шаблона. Если это необходимо, пользуйтесь вместо этого тегом <strong><span style="color: red">&lt;br&gt;</span></strong>.
<div class="message info">Внимание! Для правильной работы модуля CSV-импорта необходимо корректно заполнять шаблон. Любое отхождение от шаблона (пустая строка, добавленный столбец) может нарушить работу данной системы.</div>
<?php echo $form; ?>
\ No newline at end of file
<?php
$this->tabs = array(
'управление' => $this->createUrl('manage'),
'просмотр' => $this->createUrl('view', array('id' => $session->id)),
'продлить' => $this->createUrl('extend', array('id' => $session->id))
);
$this->crumbs = array(
'Список сессий' => array('/testings/testingSessionAdmin/manage'),
'Сессия "'.$session->name.'"' => array('/testings/testingSessionAdmin/view','id'=>$session->id),
'Редактирование',
);
echo $form;
<?php
$this->tabs = array(
'управление' => $this->createUrl('manage'),
'просмотр' => $this->createUrl('view', array('id' => $session->id)),
'продлить' => $this->createUrl('extend', array('id' => $session->id))
);
$this->crumbs = array(
'Список сессий' => array('/testings/testingSessionAdmin/manage'),
'Сессия "'.$session->name.'"' => array('/testings/testingSessionAdmin/view','id'=>$session->id),
'Редактирование',
);
echo $form;
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
?>
<?php if (\Yii::$app->session->hasFlash('flash')): ?>
<div class="alert alert-success fade in m-b-15">
<?php echo \Yii::$app->session->getFlash('flash'); ?>
<span class="close" data-dismiss="alert">×</span>
</div>
<?php endif ?>
<?php if (isset($log)) : ?>
<div id="log_box"><?php echo $log; ?></div>
<hr>
<script type="text/javascript">
jQuery('#log_box p').each(function(){
var str = $(this).text();
var reg = /Ошибка/gi;
if (str.match(reg)) {
$(this).css('color','red');
}
});
</script>
<?php endif; ?>
<span style="font-size: 14px; color: #008C66;">Краткая инструкция по файла назначения теста пользователям</span><br /><br />
<div>
Для загрузки реестра пользователей на сайт необходимо:
<ol>
<li>Заполнить <a href="/uploads/templates/Users_example_table.xlsx">шаблон</a> в формате MS Excel. Поля для назначения тестов имеют формат "да/нет".</li>
<li>ВАЖНО! Список тестов в сессии необходимо создать заранее! Порядок создания тестов в сессии определяет порядок столбцов в файле!</li>
<li>Сохранить файл как XLS.</li>
<li>Загрузить файл на сайт c помощью кнопки ниже.</li>
</ol>
<span style="color: red;">Важно!</span> Не используйте клавишу ENTER для перевода строки при заполнении шаблона. Если это необходимо, пользуйтесь вместо этого тегом <strong><span style="color: red">&lt;br&gt;</span></strong>.
<div class="message info">Внимание! Для правильной работы модуля XLS-импорта необходимо корректно заполнять шаблон. Любое отхождение от шаблона (пустая строка, добавленный столбец) может нарушить работу данной системы.</div>
<hr>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($group, 'name')->textInput() ?>
<?= $form->field($model, 'csv_file')->fileInput() ?>
<?= Html::submitButton('Загрузить', ['class' => 'btn btn-success']); ?>
<?php ActiveForm::end() ?>
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160218_131414_clear_testings extends Migration
{
public function safeUp()
{
$this->dropTable('testings_users');
$this->dropTable('testings_users_groups');
$this->dropTable('testings_users_groups_assign');
$this->dropTable('testings_users_history');
}
public function safeDown()
{
// Структура таблицы `testings_users`
$this->createTable('testings_users', [
'id' => Schema::TYPE_PK,
'sex' => 'tinyint(1) NOT NULL',
'first_name' => Schema::TYPE_STRING . '(50) NOT NULL',
'patronymic' => Schema::TYPE_STRING . '(50) DEFAULT NULL',
'last_name' => Schema::TYPE_STRING . '(50) NOT NULL',
'company_name' => Schema::TYPE_STRING . '(250) NOT NULL',
'city' => Schema::TYPE_STRING . '(100) DEFAULT NULL',
'login' => Schema::TYPE_STRING . '(30) NOT NULL',
'password' => Schema::TYPE_STRING . '(30) NOT NULL',
'email' => Schema::TYPE_STRING . '(150) NOT NULL',
'manager_id' => Schema::TYPE_INTEGER . '(11) unsigned NOT NULL',
'tki' => Schema::TYPE_STRING . '(150) DEFAULT NULL',
'region' => Schema::TYPE_STRING . '(100) DEFAULT NULL',
'is_auth' => "tinyint(1) DEFAULT '0'",
'create_date' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
]);
// Структура таблицы `testings_users_groups`
$this->createTable('testings_users_groups', [
'id' => Schema::TYPE_PK,
'session_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'name' => Schema::TYPE_STRING . '(255) DEFAULT NULL',
'created' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
]);
// Структура таблицы `testings_users_groups_assign`
$this->createTable('testings_users_groups_assign', [
'user_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'group_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'session_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
]);
// Структура таблицы `testings_users_history`
$this->createTable('testings_users_history', [
'id' => Schema::TYPE_PK,
'session_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'user_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'email' => Schema::TYPE_STRING . '(255) DEFAULT NULL',
'sended' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'file' => Schema::TYPE_STRING . '(255) DEFAULT NULL',
'unisender_email' => Schema::TYPE_STRING . '(255) DEFAULT NULL',
'unisender_status' => Schema::TYPE_STRING . '(20) DEFAULT NULL',
'notified' => Schema::TYPE_INTEGER . '(1) NOT NULL',
'created' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
]);
$this->createIndex('testings_users2users', 'testings_users', 'manager_id');
}
}
......@@ -76,9 +76,6 @@ a.login_form_link, a.login_form_popup_link, a.reg_popup_link, a.reg_form_link{
.txt_server:before {
position: absolute;
}
.article_short_txt img {
width: auto !important;
}
.reviews-block {
background: #fff;
padding-bottom: 0;
......@@ -162,7 +159,27 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow
.video_sec a.toggle_bottom {
margin-top: 153px;
}
.bx-wrapper .bx-prev {
background: #344555 url(../images/arrow_left.png) no-repeat center center;
}
.bx-wrapper .bx-pager.bx-default-pager a:hover {
background: url(../images/elips_hover.png) no-repeat center center;
}
.bx-wrapper .bx-pager.bx-default-pager a {
background: url(../images/elips.png) no-repeat center center;
}
.bx-wrapper .bx-next {
background: #344555 url(../images/arrow_right.png) no-repeat center center;
}
.bx-wrapper .bx-pager.bx-default-pager a.active {
background: url(../images/elips_active.png) no-repeat center center;
}
@media (min-width: 970px) {
.article_short_txt img {
width: auto !important;
}
}
@media (max-width: 970px) {
.e_cat_top a.toggle_bottom {
......@@ -201,4 +218,8 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow
font-size: 14px;
margin-top: 90px;
}
.calk_form .calk_form_subtitle,
.calk_form .file-upload_block {
display: none;
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment