Commit ac79fe2c authored by Shakarim Sapa's avatar Shakarim Sapa

Merge remote-tracking branch 'origin/master'

parents 74e43f9b 6382034e
...@@ -10,7 +10,9 @@ use yii\grid; ...@@ -10,7 +10,9 @@ use yii\grid;
class ColorActionColumn extends \yii\grid\ActionColumn class ColorActionColumn extends \yii\grid\ActionColumn
{ {
public $contentOptions = [ public $contentOptions = [
'class' => 'color-column' 'class' => 'color-column',
'style' => 'white-space: nowrap;',
'align' => 'center'
]; ];
protected function initDefaultButtons() protected function initDefaultButtons()
......
<?php
namespace common\modules\testings\components;
use yii\helpers\Json;
class MarkBoxAction extends \yii\base\Action
{
public function run($session)
{
if(isset($_POST['reset']) && $_POST['reset'])
{
\Yii::$app->controller->setMarked($session, []);
echo Json::encode(array(
'qty' => 0,
'title' => "Разослать выделенным",
));
return;
}
if(!isset($_POST['data']) || !is_array($_POST['data']))
{
return;
}
$toggle = $_POST['data'];
$data = \Yii::$app->controller->getMarked($session);
$remove = []; $append = [];
foreach($toggle as $key => $value)
{
if($value)
{
$append[] = $key;
}
else
{
$remove[] = $key;
}
}
if(!empty($append))
{
$data = array_merge($data, $append);
}
$data = array_unique($data);
if(!empty($remove))
{
$data = array_diff($data, $remove);
}
\Yii::$app->controller->setMarked($session, $data);
$qty = count($data);
echo Json::encode([
'qty' => $qty,
'title' => "Разослать выделенным ($qty)",
]);
}
}
\ No newline at end of file
<?php
namespace common\modules\testings\components;
use Yii;
use yii\base\Behavior;
class MarkBoxBehavior extends Behavior
{
public $session_key = 'notify_session';
private $_marked;
public function getMarked($session)
{
$session = intval($session);
if(!isset($this->_marked[$session]))
{
$session_key = $this->session_key . '_' . $session;
if(isset(Yii::$app->session[$session_key]))
{
$data = unserialize(Yii::$app->session[$session_key]);
if($data === FALSE)
{
$data = [];
}
}
else
{
$data = [];
}
$this->_marked[$session] = $data;
}
return $this->_marked[$session];
}
public function setMarked($session, $data)
{
$session = intval($session);
$session_key = $this->session_key . '_' . $session;
$this->_marked[$session] = $data;
Yii::$app->session[$session_key] = serialize($data);
}
public function checkMark($data, $row)
{
return in_array($data->id, $this->getMarked());
}
}
\ No newline at end of file
<?php <?php
Yii::import('zii.widgets.grid.CGridColumn'); namespace common\modules\testings\components;
class MarkBoxColumn extends CGridColumn use Closure;
use yii\base\InvalidConfigException;
use yii\helpers\Html;
class MarkBoxColumn extends \yii\grid\CheckboxColumn
{ {
public $checked; public $checked;
/**
* @var array the HTML options for the data cell tags. public $contentOptions = ['class'=>'checkbox-column'];
*/
public $htmlOptions=array('class'=>'checkbox-column'); public $headerOptions = ['class'=>'checkbox-column'];
/**
* @var array the HTML options for the header cell tag. public $footerOptions = ['class'=>'checkbox-column'];
*/
public $headerHtmlOptions=array('class'=>'checkbox-column');
/**
* @var array the HTML options for the footer cell tag.
*/
public $footerHtmlOptions=array('class'=>'checkbox-column');
/**
* @var array the HTML options for the checkboxes.
*/
public $checkBoxHtmlOptions=array();
/**
* @var string the template to be used to control the layout of the header cell.
* The token "{item}" is recognized and it will be replaced with a "check all" checkbox.
* By default if in multiple checking mode, the header cell will display an additional checkbox,
* clicking on which will check or uncheck all of the checkboxes in the data cells.
* See {@link selectableRows} for more details.
* @since 1.1.11
*/
public $headerTemplate='{item}';
public $updateUrl; public $updateUrl;
/**
* Initializes the column. public $name = 'selection';
* This method registers necessary client script for the checkbox column.
*/ public $checkboxOptions = [];
public $multiple = true;
public function init() public function init()
{ {
if(isset($this->checkBoxHtmlOptions['name'])) parent::init();
$name=$this->checkBoxHtmlOptions['name']; if (empty($this->name))
else {
throw new InvalidConfigException('The "name" property must be set.');
}
if (substr_compare($this->name, '[]', -2, 2))
{ {
$name=$this->id; $this->name .= '[]';
if(substr($name,-2)!=='[]') // $this->checkBoxOptions['name'] = $name;
$name.='[]';
$this->checkBoxHtmlOptions['name']=$name;
} }
$name=strtr($name,array('['=>"\\[",']'=>"\\]"));
// $name = strtr($name, ['['=>"\\[",']'=>"\\]"]);
$js=<<<CBALL
$(document).delegate('#{$this->id}_all','click',function() { $js = <<<EOD
$(document).delegate('.select-on-check-all','click',function() {
//групповой выбор/сброс //групповой выбор/сброс
var th = this, checked=this.checked, data = {}; var th = this, checked=this.checked, data = {};
th.disabled = true; th.disabled = true;
$("input[name='$name']:not(:disabled)").each(function() { $("input[name='{$this->name}']:not(:disabled)").each(function() {
data[this.value] =checked ? 1:0; data[this.value] =checked ? 1:0;
this.checked=checked; this.checked=checked;
this.disabled = true; this.disabled = true;
...@@ -80,7 +70,7 @@ $(document).delegate('#{$this->id}_all','click',function() { ...@@ -80,7 +70,7 @@ $(document).delegate('#{$this->id}_all','click',function() {
}, },
complete: function(){ complete: function(){
th.disabled = false; th.disabled = false;
$("input[name='$name']").each(function() { $("input[name='{$this->name}']").each(function() {
this.disabled = false; this.disabled = false;
}); });
} }
...@@ -88,10 +78,10 @@ $(document).delegate('#{$this->id}_all','click',function() { ...@@ -88,10 +78,10 @@ $(document).delegate('#{$this->id}_all','click',function() {
}); });
$(document).delegate("input[name='$name']", 'click',function() { $(document).delegate("input[name='$this->name']", 'click',function() {
var checked=this.checked, data = {}, th = this; var checked=this.checked, data = {}, th = this;
$('#{$this->id}_all').prop('checked', $("input[name='$name']").length==$("input[name='$name']:checked").length); $('.select-on-check-all').prop('checked', $("input[name='{$this->name}']").length==$("input[name='{$this->name}']:checked").length);
th.disabled = true; th.disabled = true;
data[this.value] =checked ? 1:0; data[this.value] =checked ? 1:0;
...@@ -115,66 +105,100 @@ $(document).delegate("input[name='$name']", 'click',function() { ...@@ -115,66 +105,100 @@ $(document).delegate("input[name='$name']", 'click',function() {
} }
}); });
}); });
$(document).delegate("#resetMarkup", 'click', function(){ $(document).delegate("#resetMarkup", 'click', function(){
$("#{$this->id}_all, input[name='$name']").prop('checked', false); $(".select-on-check-all, input[name='{$this->name}']").prop('checked', false);
$("#sendMarkup").hide(); $("#sendMarkup").hide();
$("#resetMarkup").hide(); $("#resetMarkup").hide();
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: {reset:true},
url: $(this).attr('href') url: $(this).attr('href')
}); });
return false; return false;
}); });
CBALL; EOD;
Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$this->id,$js); \Yii::$app->controller->view->registerJS($js, \yii\web\View::POS_END, __CLASS__);
} }
/**
* Renders the header cell content. // if(trim($this->headerTemplate)==='')
* This method will render a checkbox in the header when {@link selectableRows} is greater than 1 // {
* or in case {@link selectableRows} is null when {@link CGridView::selectableRows} is greater than 1. // //echo $this->grid->blankDisplay;
*/ // return;
// }
// $item = CHtml::checkBox($this->id.'_all',false);
// echo strtr($this->headerTemplate,array(
// '{item}'=>$item,
// ));
protected function renderHeaderCellContent() protected function renderHeaderCellContent()
{ {
if(trim($this->headerTemplate)==='') $name = $this->name;
if (substr_compare($name, '[]', -2, 2) === 0)
{
$name = substr($name, 0, -2);
}
if (substr_compare($name, ']', -1, 1) === 0)
{
$name = substr($name, 0, -1) . '_all]';
}
else
{ {
//echo $this->grid->blankDisplay; $name .= '_all';
return;
} }
$item = CHtml::checkBox($this->id.'_all',false); $id = $this->grid->options['id'];
echo strtr($this->headerTemplate,array( $options = json_encode([
'{item}'=>$item, 'name' => $this->name,
)); 'multiple' => $this->multiple,
'checkAll' => $name,
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
if ($this->header !== null || !$this->multiple)
{
return parent::renderHeaderCellContent();
}
else
{
return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
}
} }
/** protected function renderDataCellContent($model, $key, $index)
* Renders the data cell content. {
* This method renders a checkbox in the data cell. if ($this->checkboxOptions instanceof Closure)
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
*/
protected function renderDataCellContent($row,$data)
{ {
$value=$this->grid->dataProvider->keys[$row]; $options = call_user_func($this->checkboxOptions, $model, $key, $index, $this);
/* }
$checked = false; else
if($this->checked!==null) {
$checked=$this->evaluateExpression($this->checked,array('data'=>$data,'row'=>$row)); $options = $this->checkboxOptions;
*/ if (!isset($options['value']))
{
$marked = $this->grid->controller->getMarked(Yii::app()->request->getQuery('session')); $options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key;
$checked = in_array($data->id, $marked); }
$options=$this->checkBoxHtmlOptions; }
$name=$options['name'];
unset($options['name']); if(\Yii::$app->request->get('session'))
$options['value']=$value; {
$options['id']=$this->id.'_'.$row; $marked = \Yii::$app->controller->getMarked(\Yii::$app->request->get('session'));
echo CHtml::checkBox($name,$checked,$options); $checked = in_array($model->id, $marked);
return Html::checkbox($this->name, $checked, $options);
}
else
{
return Html::checkbox($this->name, !empty($options['checked']), $options);
}
} }
} }
\ No newline at end of file
<?php <?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\SearchTestingSendHistory;
class TestingSendHistoryAdminController extends AdminController class TestingSendHistoryAdminController extends AdminController
{ {
public static function actionsTitles() public static function actionsTitles()
{ {
return array( return array(
'Manage' => 'Управление пользователями', 'Manage' => 'Управление пользователями',
'ResendDublicates' => '', 'Resend-dublicates' => '',
); );
} }
public function actionManage() public function actionManage($session)
{
if(!Yii::app()->request->getQuery('session'))
{ {
$this->pageNotFound(); $searchModel = new SearchTestingSendHistory();
} $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$model=new TestingSendHistory('search'); Yii::$app->controller->page_title = 'История отправки дубликатов';
$model->unsetAttributes(); Yii::$app->controller->breadcrumbs = [
if(isset($_GET['TestingSendHistory'])) 'История отправки дубликатов',
{ ];
$model->attributes = $_GET['TestingSendHistory'];
}
$this->render('manage', array( return $this->render('manage', [
'model' => $model, 'searchModel' => $searchModel,
'session_id' => Yii::app()->request->getQuery('session') 'dataProvider' => $dataProvider,
)); 'session_id' => $session
]);
} }
public function actionResendDublicates() public function actionResendDublicates()
...@@ -83,23 +89,19 @@ class TestingSendHistoryAdminController extends AdminController ...@@ -83,23 +89,19 @@ class TestingSendHistoryAdminController extends AdminController
} }
public function loadModel($id) /**
* 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)
{ {
$model = TestingSendHistory::model()->findByPk((int) $id); if (($model = TestingUser::findOne($id)) !== null) {
if($model === null)
{
$this->pageNotFound();
}
return $model; return $model;
} } else {
throw new NotFoundHttpException('The requested page does not exist.');
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax'] === 'testing-sendhistory-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
} }
} }
} }
...@@ -17,9 +17,6 @@ use common\modules\testings\models\TestingAnswer; ...@@ -17,9 +17,6 @@ use common\modules\testings\models\TestingAnswer;
class TestingTestAdminController extends AdminController class TestingTestAdminController extends AdminController
{ {
public $errorSummaryCssClass = 'error-summary';
public $encodeErrorSummary;
public static function actionsTitles() public static function actionsTitles()
{ {
return array( return array(
...@@ -152,10 +149,8 @@ class TestingTestAdminController extends AdminController ...@@ -152,10 +149,8 @@ class TestingTestAdminController extends AdminController
$objPHPExcel = $objReader->load($model->file); $objPHPExcel = $objReader->load($model->file);
$sheet = $objPHPExcel->getSheet(0); $sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
for ($i = 3; $i <= $highestRow; $i++) for ($i = 3; $i <= $sheet->getHighestRow(); $i++)
{ {
// извлечение переменных из XLS // извлечение переменных из XLS
$theme_name = trim(preg_replace('/\s+/', ' ', $sheet->getCell('A' . $i)->getValue())); $theme_name = trim(preg_replace('/\s+/', ' ', $sheet->getCell('A' . $i)->getValue()));
......
...@@ -6,7 +6,8 @@ use Yii; ...@@ -6,7 +6,8 @@ use Yii;
use common\components\AdminController; use common\components\AdminController;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\Json;
use common\modules\testings\components\MarkBoxBehavior;
use common\modules\testings\models\TestingUser; use common\modules\testings\models\TestingUser;
use common\modules\testings\models\SearchTestingUser; use common\modules\testings\models\SearchTestingUser;
...@@ -14,8 +15,6 @@ use common\modules\testings\models\SearchTestingUserGroup; ...@@ -14,8 +15,6 @@ use common\modules\testings\models\SearchTestingUserGroup;
class TestingUserAdminController extends AdminController class TestingUserAdminController extends AdminController
{ {
private $_marked;
public static function actionsTitles() public static function actionsTitles()
{ {
return array( return array(
...@@ -25,8 +24,8 @@ class TestingUserAdminController extends AdminController ...@@ -25,8 +24,8 @@ class TestingUserAdminController extends AdminController
'Delete' => 'Удаление пользователя', 'Delete' => 'Удаление пользователя',
'Manage' => 'Управление пользователями', 'Manage' => 'Управление пользователями',
'Manage-group' => 'Управление группами', 'Manage-group' => 'Управление группами',
'UpdateMark' => 'Пометка пользователй', 'Update-mark' => 'Пометка пользователй',
'ResetMark' => 'Сброс пометок', 'Reset-mark' => 'Сброс пометок',
); );
} }
...@@ -39,6 +38,19 @@ class TestingUserAdminController extends AdminController ...@@ -39,6 +38,19 @@ class TestingUserAdminController extends AdminController
'delete' => ['post'], 'delete' => ['post'],
], ],
], ],
'marked' => [
'class' => MarkBoxBehavior::className(),
'session_key' => 'user-admin',
]
];
}
public function actions()
{
return [
'update-mark' => [
'class' => \common\modules\testings\components\MarkBoxAction::className(),
]
]; ];
} }
...@@ -151,102 +163,6 @@ class TestingUserAdminController extends AdminController ...@@ -151,102 +163,6 @@ class TestingUserAdminController extends AdminController
]); ]);
} }
public function getMarked($session)
{
$session = intval($session);
if(!isset($this->_marked[$session]))
{
$session_key = 'notify_session_'.$session;
if(isset(Yii::$app->session[$session_key]))
{
$data = unserialize(Yii::$app->session[$session_key]);
if($data === FALSE)
{
$data = [];
}
}
else
{
$data = [];
}
$this->_marked[$session] = $data;
}
return $this->_marked[$session];
}
public function setMarked($session, $data)
{
$session = intval($session);
$session_key = 'notify_session_'.$session;
$this->_marked[$session] = $data;
Yii::$app->session[$session_key] = serialize($data);
}
public function checkMark($data, $row)
{
return in_array($data->id, $this->getMarked());
}
public function actionUpdateMark($session)
{
if(!isset($_POST['data']) || !is_array($_POST['data']))
{
return;
}
$toggle = $_POST['data'];
$data = $this->getMarked($session);
$remove = []; $append = [];
foreach($toggle as $key => $value)
{
if($value)
{
$append[] = $key;
}
else
{
$remove[] = $key;
}
}
if(!empty($append))
{
$data = array_merge($data, $append);
}
$data = array_unique($data);
if(!empty($remove))
{
$data = array_diff($data, $remove);
}
$this->setMarked($session, $data);
$qty = count($data);
echo Json::encode([
'qty' => $qty,
'title' => "Разослать выделенным ($qty)",
]);
}
public function actionResetMark($session)
{
$this->setMarked($session, []);
echo Json::encode(array(
'qty' => 0,
'title' => "Разослать выделенным",
));
}
/** /**
* Finds the Faq model based on its primary key value. * Finds the Faq model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
......
<?php
namespace common\modules\testings\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingSendHistory;
class SearchTestingSendHistory extends TestingSendHistory
{
/**
* @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 = TestingSendHistory::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
...@@ -5,12 +5,13 @@ namespace common\modules\testings\models; ...@@ -5,12 +5,13 @@ namespace common\modules\testings\models;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use yii\db\Expression; use yii\db\Expression;
use yii\helpers\Url;
class TestingSendHistory extends \common\components\ActiveRecordModel class TestingSendHistory extends \common\components\ActiveRecordModel
{ {
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
const FOLDER_PATH = '/upload/dublicates/'; const FOLDER_PATH = '/uploads/dublicates/';
const OFFSET_EXCEL_ROWS = 3; const OFFSET_EXCEL_ROWS = 3;
...@@ -152,12 +153,12 @@ class TestingSendHistory extends \common\components\ActiveRecordModel ...@@ -152,12 +153,12 @@ class TestingSendHistory extends \common\components\ActiveRecordModel
public function getFilePath() public function getFilePath()
{ {
return Yii::getPathOfAlias('webroot') . self::FOLDER_PATH . $this->file; return Yii::getAlias('@webroot') . self::FOLDER_PATH . $this->file;
} }
public function getFileUrl() public function getFileUrl()
{ {
return Yii::app()->getBaseUrl(true) . self::FOLDER_PATH . $this->file; return Url::to([self::FOLDER_PATH . $this->file]);
} }
public function generateFile($users, $session_id) public function generateFile($users, $session_id)
......
...@@ -16,6 +16,11 @@ class TestingSession extends \common\components\ActiveRecordModel ...@@ -16,6 +16,11 @@ class TestingSession extends \common\components\ActiveRecordModel
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
public $csv_file; public $csv_file;
public $file;
const TEMP_FOLDER = '/uploads/temp/';
const SCENARIO_UPLOAD = 'upload';
const IS_PRESENT = 0; const IS_PRESENT = 0;
const IS_PAST = 1; const IS_PAST = 1;
...@@ -55,8 +60,9 @@ class TestingSession extends \common\components\ActiveRecordModel ...@@ -55,8 +60,9 @@ class TestingSession extends \common\components\ActiveRecordModel
public function rules() public function rules()
{ {
return [ return [
[['name', 'start_date', 'end_date'], 'required'], [['name', 'start_date', 'end_date'], 'required', 'except' => self::SCENARIO_UPLOAD],
[['name'], 'string', 'max' => 80], [['name'], 'string', 'max' => 80, 'except' => self::SCENARIO_UPLOAD],
[['csv_file'], 'file', 'skipOnEmpty' => false, 'extensions' => 'xls, xlsx', 'on' => self::SCENARIO_UPLOAD],
]; ];
} }
...@@ -152,6 +158,38 @@ class TestingSession extends \common\components\ActiveRecordModel ...@@ -152,6 +158,38 @@ class TestingSession extends \common\components\ActiveRecordModel
return $query->all(); return $query->all();
} }
private function getPath()
{
return Yii::getAlias('@webroot') . self::TEMP_FOLDER;
}
public function upload()
{
if($this->validate())
{
if(!file_exists($this->getPath()))
{
mkdir($this->getPath(), 0777, true);
}
$this->file = $this->getPath() . date('dmYHis-') . uniqid() . '.' . $this->csv_file->extension;
$this->csv_file->saveAs($this->file);
return true;
}
else
{
return false;
}
}
public function deleteFile()
{
if(file_exists($this->file))
{
unlink($this->file);
}
}
public function sendMailByList($users) public function sendMailByList($users)
{ {
for ($i = 0; $i < count($users); $i++) for ($i = 0; $i < count($users); $i++)
......
...@@ -22,6 +22,13 @@ class TestingTest extends \common\components\ActiveRecordModel ...@@ -22,6 +22,13 @@ class TestingTest extends \common\components\ActiveRecordModel
public $csv_file; public $csv_file;
public $file; public $file;
public static $mix_test_titles = [
'Комбинированный тест',
'комбинированный тест',
'Комбинированный',
'комбинированный'
];
/** /**
* @inheritdoc * @inheritdoc
*/ */
......
...@@ -64,8 +64,6 @@ class TestingUser extends \common\components\ActiveRecordModel ...@@ -64,8 +64,6 @@ class TestingUser extends \common\components\ActiveRecordModel
'password' => 'Пароль', 'password' => 'Пароль',
'email' => 'Email', 'email' => 'Email',
'manager_id' => 'Ответственный менеджер', 'manager_id' => 'Ответственный менеджер',
'tki' => 'ТКИ',
'region' => 'Регион',
'create_date' => 'Время создания', 'create_date' => 'Время создания',
]; ];
} }
...@@ -78,11 +76,8 @@ class TestingUser extends \common\components\ActiveRecordModel ...@@ -78,11 +76,8 @@ class TestingUser extends \common\components\ActiveRecordModel
[['first_name', 'patronymic', 'last_name'], 'string', 'max' => 50], [['first_name', 'patronymic', 'last_name'], 'string', 'max' => 50],
[['company_name'], 'string', 'max' => 250], [['company_name'], 'string', 'max' => 250],
[['email'], 'string', 'max' => 150], [['email'], 'string', 'max' => 150],
[['tki', 'city', 'region'], 'string', 'max' => 100], [['city'], 'string', 'max' => 100],
[['manager_id'], 'string', 'max' => 11], [['manager_id'], 'string', 'max' => 11],
[['pass_date', 'pass_date_start', 'attempt'], 'safe'],
[['end_date'], 'required', 'on' => 'extend'],
]; ];
} }
......
...@@ -18,7 +18,7 @@ class TestingUserGroup extends \common\components\ActiveRecordModel ...@@ -18,7 +18,7 @@ class TestingUserGroup extends \common\components\ActiveRecordModel
return [ return [
[ [
'class' => TimestampBehavior::className(), 'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'create_date', 'createdAtAttribute' => 'created',
'updatedAtAttribute' => null, 'updatedAtAttribute' => null,
'value' => new Expression('NOW()'), 'value' => new Expression('NOW()'),
], ],
......
...@@ -57,7 +57,6 @@ if ($question) ...@@ -57,7 +57,6 @@ if ($question)
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{view} {update}', 'template' => '{view} {update}',
'contentOptions' => ['style' => 'width:60px;', 'align' => 'center'],
], ],
], ],
]); ?> ]); ?>
......
...@@ -131,7 +131,6 @@ use common\modules\testings\models\TestingPassing; ...@@ -131,7 +131,6 @@ use common\modules\testings\models\TestingPassing;
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{view} {delete}', 'template' => '{view} {delete}',
'contentOptions' => ['style' => 'width:60px;', 'align' => 'center'],
], ],
], ],
]); ?> ]); ?>
...@@ -205,7 +205,6 @@ use common\modules\testings\models\TestingPassing; ...@@ -205,7 +205,6 @@ use common\modules\testings\models\TestingPassing;
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{view} {delete}', 'template' => '{view} {delete}',
'contentOptions' => ['style' => 'width:60px;', 'align' => 'center'],
], ],
], ],
]); ?> ]); ?>
\ No newline at end of file
...@@ -155,7 +155,6 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info'); ...@@ -155,7 +155,6 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{view} {update}', 'template' => '{view} {update}',
'contentOptions' => ['style' => 'width:60px;', 'align' => 'center'],
], ],
], ],
]); ?> ]); ?>
\ No newline at end of file
<?php
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use yii\helpers\Url;
use common\modules\testings\models\TestingSendHistory;
/* @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 TestingSendHistory::getStatusTitle($model->unisender_status);
},
'filter' => TestingSendHistory::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/testing-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 <?php
$this->tabs = array(
'просмотреть сессию' => $this->createUrl('/testings/testingPassingAdmin/manage',array('session'=>$model->id)),
);
$this->page_title = 'Импорт пользователей из CSV-файла'; use yii\widgets\ActiveForm;
use yii\helpers\Html;
$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 if (\Yii::$app->session->hasFlash('flash')): ?>
<?php echo $this->msg(Yii::app()->user->getFlash('flash'), 'ok'); ?> <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 endif ?>
<?php if (isset($log)) : ?> <?php if (isset($log)) : ?>
<?php $this->tabs['загрузить ещё пользователей из CSV-файла'] = $this->createUrl('/testings/testingSessionAdmin/importCSV',array('id'=>$model->id)); ?>
<div><?php echo $log; ?></div> <div id="log_box"><?php echo $log; ?></div>
<hr>
<script type="text/javascript"> <script type="text/javascript">
jQuery('#log_box p').each(function(){ jQuery('#log_box p').each(function(){
var str = $(this).text(); var str = $(this).text();
var reg = /Ошибка/gi; var reg = /Ошибка/gi;
if (str.match(reg)) { if (str.match(reg)) {
$(this).css('background-color','#ccc').css('color','red'); $(this).css('color','red');
} }
}); });
</script> </script>
...@@ -35,43 +33,23 @@ $this->crumbs = array( ...@@ -35,43 +33,23 @@ $this->crumbs = array(
<div> <div>
Для загрузки реестра пользователей на сайт необходимо: Для загрузки реестра пользователей на сайт необходимо:
<ol> <ol>
<li>Заполнить <a href="/upload/users/Users_example_table.xls">шаблон</a> в формате MS Excel. Поля для назначения тестов имеют формат "да/нет".</li> <li>Заполнить <a href="/uploads/templates/Users_example_table.xlsx">шаблон</a> в формате MS Excel. Поля для назначения тестов имеют формат "да/нет".</li>
<li>ВАЖНО! Список тестов в сессии необходимо создать заранее! Порядок создания тестов в сессии определяет порядок столбцов в файле!</li> <li>ВАЖНО! Список тестов в сессии необходимо создать заранее! Порядок создания тестов в сессии определяет порядок столбцов в файле!</li>
<li>Сохранить файл как CSV (разделители-запятые).</li> <li>Сохранить файл как XLS.</li>
<li>Загрузить файл на сайт c помощью кнопки ниже.</li> <li>Загрузить файл на сайт c помощью кнопки ниже.</li>
</ol> </ol>
<span style="color: red;">Важно!</span> Не используйте клавишу ENTER для перевода строки при заполнении шаблона. Если это необходимо, пользуйтесь вместо этого тегом <strong><span style="color: red">&lt;br&gt;</span></strong>. <span style="color: red;">Важно!</span> Не используйте клавишу ENTER для перевода строки при заполнении шаблона. Если это необходимо, пользуйтесь вместо этого тегом <strong><span style="color: red">&lt;br&gt;</span></strong>.
<div class="message info">Внимание! Для правильной работы модуля CSV-импорта необходимо корректно заполнять шаблон. Любое отхождение от шаблона (пустая строка, добавленный столбец) может нарушить работу данной системы.</div>
<?php $form = $this->beginWidget('CActiveForm', array( <div class="message info">Внимание! Для правильной работы модуля CSV-импорта необходимо корректно заполнять шаблон. Любое отхождение от шаблона (пустая строка, добавленный столбец) может нарушить работу данной системы.</div>
'id'=>'import-csv-form',
'htmlOptions' => array(
'enctype' => 'multipart/form-data'
)
)); ?>
<dl class="text"> <hr>
<dd>
<?=$form->label($group, 'name')?>
<?=$form->textField($group, 'name', array(
'class' => 'text'
));?>
<?=$form->error($group, 'name');?>
</dd>
</dl>
<dl class="file"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<dd>
<?=$form->label($model, 'csv_file')?>
<?=$form->fileField($model, 'csv_file');?>
<?=$form->error($model, 'csv_file');?>
</dd>
</dl>
<div class="row buttons"> <?= $form->field($group, 'name')->textInput() ?>
<?=CHtml::submitButton('Загрузить', array(
'class' => 'submit mid' <?= $form->field($model, 'csv_file')->fileInput() ?>
))?>
</div> <?= Html::submitButton('Загрузить', ['class' => 'btn btn-success']); ?>
<?php $this->endWidget(); ?> <?php ActiveForm::end() ?>
\ No newline at end of file
...@@ -93,7 +93,6 @@ use \common\components\zii\AdminGrid; ...@@ -93,7 +93,6 @@ use \common\components\zii\AdminGrid;
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{view} {update}', 'template' => '{view} {update}',
'contentOptions' => ['style' => 'width:60px;', 'align' => 'center'],
], ],
], ],
]); ?> ]); ?>
\ No newline at end of file
...@@ -6,7 +6,6 @@ use \common\components\zii\AdminGrid; ...@@ -6,7 +6,6 @@ use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingSession; use common\modules\testings\models\TestingSession;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel common\modules\faq\models\SearchFaq */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$session_id = null; $session_id = null;
...@@ -75,7 +74,6 @@ if($session) ...@@ -75,7 +74,6 @@ if($session)
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{view} {update}', 'template' => '{view} {update}',
'contentOptions' => ['style' => 'width:60px;', 'align' => 'center'],
], ],
], ],
]); ?> ]); ?>
......
...@@ -13,10 +13,21 @@ use common\modules\testings\models\TestingPassing; ...@@ -13,10 +13,21 @@ use common\modules\testings\models\TestingPassing;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$session = null;
if (\Yii::$app->request->get('session'))
{
$session = TestingSession::findOne(\Yii::$app->request->get('session'));
}
?> ?>
<p> <p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?php if($session) : ?>
<?= Html::a('Разослать уведомления всем', ['/testings/testing-session-admin/send-message-to-all', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('История отправки дубликатов', ['/testings/testing-send-history-admin/manage', 'session' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('Импорт пользователей из XLS', ['/testings/testing-session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?php endif; ?>
</p> </p>
<?php if (\Yii::$app->session->hasFlash('flash')) : ?> <?php if (\Yii::$app->session->hasFlash('flash')) : ?>
...@@ -99,11 +110,8 @@ $columns = [ ...@@ -99,11 +110,8 @@ $columns = [
$link = ''; $link = '';
if (\Yii::$app->request->get('session')) if ($session)
{ {
$session = TestingSession::findOne(\Yii::$app->request->get('session'));
if ($session)
{
$marked = \Yii::$app->controller->getMarked($session->id); $marked = \Yii::$app->controller->getMarked($session->id);
$qty = count($marked); $qty = count($marked);
...@@ -111,24 +119,26 @@ if (\Yii::$app->request->get('session')) ...@@ -111,24 +119,26 @@ if (\Yii::$app->request->get('session'))
$style = ($qty) ? '' : 'display:none;'; $style = ($qty) ? '' : 'display:none;';
$send = Html::a("Разослать выделенным ($qty)", $send = Html::a("Разослать выделенным ($qty)",
['/testings/testing-session-admin/send-message-to-marked', 'id' => $session->id], ['testings/testing-session-admin/send-message-to-marked', 'id' => $session->id],
['style' => $style, 'id' => 'sendMarkup'] ['style' => $style, 'id' => 'sendMarkup']
); );
$clear = Html::a("[сброс]", $clear = Html::a("[сброс]",
['resetMark', 'session' => $session->id], ['update-mark', 'session' => $session->id],
['style' => $style, 'id' => 'resetMarkup'] ['style' => $style, 'id' => 'resetMarkup']
); );
$link = $send . ' ' . $clear; $link = $send . ' ' . $clear . '<br><br>';
// array_unshift( echo $link;
// $columns,
// [ array_unshift(
// 'class' => 'MarkBoxColumn', $columns,
// 'update_url' => Url::to(['update-mark', 'session' => $session->id]), [
// ] 'class' => 'common\modules\testings\components\MarkBoxColumn',
// ); 'updateUrl' => Url::to(['update-mark', 'session' => $session->id]),
]
);
foreach($session->tests as $test) foreach($session->tests as $test)
{ {
...@@ -159,44 +169,29 @@ if (\Yii::$app->request->get('session')) ...@@ -159,44 +169,29 @@ if (\Yii::$app->request->get('session'))
); );
} }
// $this->tabs = array( $buttons = [
// 'разослать уведомления всем' => $this->createUrl('/testings/testingSessionAdmin/sendMessageToAll',array('id'=>$session->id)), [
// 'история отправки дубликатов' => $this->createUrl('/testings/testingSendHistoryAdmin/manage', array('session'=>$session->id)), 'class' => \common\components\ColorActionColumn::className(),
// 'импорт пользователей из CSV' => $this->createUrl( 'template' => '{send} {view} {update}',
// '/testings/testingSessionAdmin/importPassings', 'buttons' => [
// array('id'=>$session->id) 'send' => function ($url, $model, $key) use($session)
// ), {
// ); return Html::a('<i class="fa fa-envelope fa-lg"></i>', Url::to(['testings/testing-session-admin/send-message', 'id' => $session->id, 'user' => $model->id]), [
'title' => 'Уведомить о тестировании',
// $buttons = array( 'data-toggle' => 'tooltip',
// 'class' => 'CButtonColumn', 'data-pjax' => '0',
// 'template' => '{sendEmail}{view}{update}', ]);
// 'buttons' => array( },
// 'sendEmail' => array( ]
// 'url' => 'array("/testings/testingSessionAdmin/sendMessage","id"=>'.$session->id.',"user"=>$data->id)', ]
// 'imageUrl' => '/images/icons/mail.png', ];
// 'options' => array(
// 'title' => 'Уведомить о тестировании', $columns = ArrayHelper::merge($columns, $buttons);
// ),
// ),
// ),
// );
}
} }
echo AdminGrid::widget([ echo AdminGrid::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'filterModel' => $searchModel, 'filterModel' => $searchModel,
'columns' => $columns 'columns' => $columns,
]); ]);
\ No newline at end of file
// $this->widget('AdminGrid', array(
// 'id' => 'testing-user-grid',
// 'dataProvider' => $model->search(),
// 'filter' => $model,
// 'columns' => $columns,
// 'template' => "$link {pagerSelect}{summary}<br/>{pager}<br/>{items}<br/>{pager}",
// ));
\ No newline at end of file
<?php
$this->tabs = array(
'список назначений тестов пользователям' => $this->createUrl('/testings/testingUserAdmin/manage', array('session' => $session_id)),
);
$this->page_title = 'История отправок дубликатов';
$this->widget('AdminGrid', array(
'id' => 'testing-sendhistory-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'email',
array(
'name' => 'sended',
'value' => 'date("d.m.Y H:i:s", $data->sended)',
),
array(
'name' => 'unisender_status',
'value' => 'TestingSendHistory::getStatusTitle($data->unisender_status)',
'filter' => TestingSendHistory::getStatusTitle(),
'headerHtmlOptions' => array(
'style' => 'width: 360px;'
)
),
array(
'header' => '',
'type' => 'raw',
'value' => function($data) {
if($data->file && file_exists($data->getFilePath()))
{
$send = CHtml::link(CHtml::image('/images/icons/mail.png', 'Повторить отправку', array('title' => 'Повторить отправку')), '#', array(
'data-id' => $data->id,
'data-email' => $data->email,
'id' => "resend"
));
$file = CHtml::link(CHtml::image('/img/excel_bg.png', 'Скачать список доступов', array('title' => 'Скачать список доступов')), $data->getFileUrl());
return $send . ' ' . $file;
}
}
)
),
'template' => "{pagerSelect}{summary}<br/>{pager}<br/>{items}<br/>{pager}",
));
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