Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
eac79345
Commit
eac79345
authored
Jan 25, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix UserAdmin and SendHistory
parent
0d6586b6
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
597 additions
and
451 deletions
+597
-451
common/components/ColorActionColumn.php
common/components/ColorActionColumn.php
+3
-1
common/modules/testings/components/MarkBoxAction.php
common/modules/testings/components/MarkBoxAction.php
+64
-0
common/modules/testings/components/MarkBoxBehavior.php
common/modules/testings/components/MarkBoxBehavior.php
+54
-0
common/modules/testings/components/MarkBoxColumn.php
common/modules/testings/components/MarkBoxColumn.php
+190
-166
common/modules/testings/controllers/TestingSendHistoryAdminController.php
...estings/controllers/TestingSendHistoryAdminController.php
+36
-34
common/modules/testings/controllers/TestingUserAdminController.php
...dules/testings/controllers/TestingUserAdminController.php
+18
-102
common/modules/testings/models/SearchTestingSendHistory.php
common/modules/testings/models/SearchTestingSendHistory.php
+77
-0
common/modules/testings/models/TestingSendHistory.php
common/modules/testings/models/TestingSendHistory.php
+4
-3
common/modules/testings/views/testing-answer-admin/manage.php
...on/modules/testings/views/testing-answer-admin/manage.php
+0
-1
common/modules/testings/views/testing-passing-admin/manage.php
...n/modules/testings/views/testing-passing-admin/manage.php
+0
-1
common/modules/testings/views/testing-passing-admin/statistics.php
...dules/testings/views/testing-passing-admin/statistics.php
+0
-1
common/modules/testings/views/testing-question-admin/manage.php
.../modules/testings/views/testing-question-admin/manage.php
+0
-1
common/modules/testings/views/testing-send-history-admin/manage.php
...ules/testings/views/testing-send-history-admin/manage.php
+65
-0
common/modules/testings/views/testing-session-admin/manage.php
...n/modules/testings/views/testing-session-admin/manage.php
+0
-1
common/modules/testings/views/testing-test-admin/manage.php
common/modules/testings/views/testing-test-admin/manage.php
+0
-2
common/modules/testings/views/testing-user-admin/manage.php
common/modules/testings/views/testing-user-admin/manage.php
+86
-91
common/modules/testings/views/testingSendHistoryAdmin/manage.php
...modules/testings/views/testingSendHistoryAdmin/manage.php
+0
-47
No files found.
common/components/ColorActionColumn.php
View file @
eac79345
...
...
@@ -10,7 +10,9 @@ use yii\grid;
class
ColorActionColumn
extends
\yii\grid\ActionColumn
{
public
$contentOptions
=
[
'class'
=>
'color-column'
'class'
=>
'color-column'
,
'style'
=>
'white-space: nowrap;'
,
'align'
=>
'center'
];
protected
function
initDefaultButtons
()
...
...
common/modules/testings/components/MarkBoxAction.php
0 → 100644
View file @
eac79345
<?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
common/modules/testings/components/MarkBoxBehavior.php
0 → 100644
View file @
eac79345
<?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
common/modules/testings/components/MarkBoxColumn.php
View file @
eac79345
<?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
;
/**
* @var array the HTML options for the data cell tags.
*/
public
$htmlOptions
=
array
(
'class'
=>
'checkbox-column'
);
/**
* @var array the HTML options for the header cell tag.
*/
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
$contentOptions
=
[
'class'
=>
'checkbox-column'
];
public
$headerOptions
=
[
'class'
=>
'checkbox-column'
];
public
$footerOptions
=
[
'class'
=>
'checkbox-column'
];
public
$updateUrl
;
/**
* Initializes the column.
* This method registers necessary client script for the checkbox column.
*/
public
$name
=
'selection'
;
public
$checkboxOptions
=
[];
public
$multiple
=
true
;
public
function
init
()
{
if
(
isset
(
$this
->
checkBoxHtmlOptions
[
'name'
]))
$name
=
$this
->
checkBoxHtmlOptions
[
'name'
];
else
parent
::
init
();
if
(
empty
(
$this
->
name
))
{
throw
new
InvalidConfigException
(
'The "name" property must be set.'
);
}
if
(
substr_compare
(
$this
->
name
,
'[]'
,
-
2
,
2
))
{
$name
=
$this
->
id
;
if
(
substr
(
$name
,
-
2
)
!==
'[]'
)
$name
.=
'[]'
;
$this
->
checkBoxHtmlOptions
[
'name'
]
=
$name
;
$this
->
name
.=
'[]'
;
// $this->checkBoxOptions['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 = {};
th.disabled = true;
$
(
"input[name='
$name
']:not(:disabled)"
)
.
each
(
function
()
{
$("input[name='{$this->name}
']:not(:disabled)").each(function() {
data[this.value] =checked ? 1:0;
this.checked=checked;
this.disabled = true;
...
...
@@ -80,7 +70,7 @@ $(document).delegate('#{$this->id}_all','click',function() {
},
complete: function(){
th.disabled = false;
$
(
"input[name='
$name
']"
)
.
each
(
function
()
{
$("input[name='{$this->name}
']").each(function() {
this.disabled = false;
});
}
...
...
@@ -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;
$
(
'#{$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;
data[this.value] =checked ? 1:0;
...
...
@@ -115,66 +105,100 @@ $(document).delegate("input[name='$name']", 'click',function() {
}
});
});
});
$
(
document
)
.
delegate
(
"#resetMarkup"
,
'click'
,
function
(){
$
(
"#
{
$this
->
id
}
_all, input[name='
$name
']"
)
.
prop
(
'checked'
,
false
);
$(document).delegate("#resetMarkup", 'click', function(){
$(".select-on-check-all, input[name='{$this->name}
']").prop('checked', false);
$("#sendMarkup").hide();
$("#resetMarkup").hide();
$.ajax({
type: 'POST',
data: {reset:true},
url: $(this).attr('href')
});
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.
* 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.
*/
// if(trim($this->headerTemplate)==='')
// {
// //echo $this->grid->blankDisplay;
// return;
// }
// $item = CHtml::checkBox($this->id.'_all',false);
// echo strtr($this->headerTemplate,array(
// '{item}'=>$item,
// ));
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;
return
;
$name
.=
'_all'
;
}
$item
=
CHtml
::
checkBox
(
$this
->
id
.
'_all'
,
false
)
;
$id
=
$this
->
grid
->
options
[
'id'
]
;
echo
strtr
(
$this
->
headerTemplate
,
array
(
'{item}'
=>
$item
,
));
$options
=
json_encode
([
'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'
]);
}
}
/**
* Renders the data cell content.
* This method renders a checkbox in the data cell.
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
*/
protected
function
renderDataCellContent
(
$row
,
$data
)
protected
function
renderDataCellContent
(
$model
,
$key
,
$index
)
{
if
(
$this
->
checkboxOptions
instanceof
Closure
)
{
$value
=
$this
->
grid
->
dataProvider
->
keys
[
$row
];
/*
$checked = false;
if($this->checked!==null)
$checked=$this->evaluateExpression($this->checked,array('data'=>$data,'row'=>$row));
*/
$marked
=
$this
->
grid
->
controller
->
getMarked
(
Yii
::
app
()
->
request
->
getQuery
(
'session'
));
$checked
=
in_array
(
$data
->
id
,
$marked
);
$options
=
$this
->
checkBoxHtmlOptions
;
$name
=
$options
[
'name'
];
unset
(
$options
[
'name'
]);
$options
[
'value'
]
=
$value
;
$options
[
'id'
]
=
$this
->
id
.
'_'
.
$row
;
echo
CHtml
::
checkBox
(
$name
,
$checked
,
$options
);
$options
=
call_user_func
(
$this
->
checkboxOptions
,
$model
,
$key
,
$index
,
$this
);
}
else
{
$options
=
$this
->
checkboxOptions
;
if
(
!
isset
(
$options
[
'value'
]))
{
$options
[
'value'
]
=
is_array
(
$key
)
?
json_encode
(
$key
,
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
)
:
$key
;
}
}
if
(
\Yii
::
$app
->
request
->
get
(
'session'
))
{
$marked
=
\Yii
::
$app
->
controller
->
getMarked
(
\Yii
::
$app
->
request
->
get
(
'session'
));
$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
common/modules/testings/controllers/TestingSendHistoryAdminController.php
View file @
eac79345
<?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
{
public
static
function
actionsTitles
()
{
return
array
(
'Manage'
=>
'Управление пользователями'
,
'Resend
D
ublicates'
=>
''
,
'Resend
-d
ublicates'
=>
''
,
);
}
public
function
actionManage
()
{
if
(
!
Yii
::
app
()
->
request
->
getQuery
(
'session'
))
public
function
actionManage
(
$session
)
{
$this
->
pageNotFound
();
}
$searchModel
=
new
SearchTestingSendHistory
();
$dataProvider
=
$searchModel
->
search
(
Yii
::
$app
->
request
->
queryParams
);
$model
=
new
TestingSendHistory
(
'search'
);
$model
->
unsetAttributes
();
if
(
isset
(
$_GET
[
'TestingSendHistory'
]))
{
$model
->
attributes
=
$_GET
[
'TestingSendHistory'
];
}
Yii
::
$app
->
controller
->
page_title
=
'История отправки дубликатов'
;
Yii
::
$app
->
controller
->
breadcrumbs
=
[
'История отправки дубликатов'
,
];
$this
->
render
(
'manage'
,
array
(
'model'
=>
$model
,
'session_id'
=>
Yii
::
app
()
->
request
->
getQuery
(
'session'
)
));
return
$this
->
render
(
'manage'
,
[
'searchModel'
=>
$searchModel
,
'dataProvider'
=>
$dataProvider
,
'session_id'
=>
$session
]);
}
public
function
actionResendDublicates
()
...
...
@@ -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
===
null
)
{
$this
->
pageNotFound
();
}
if
((
$model
=
TestingUser
::
findOne
(
$id
))
!==
null
)
{
return
$model
;
}
protected
function
performAjaxValidation
(
$model
)
{
if
(
isset
(
$_POST
[
'ajax'
])
&&
$_POST
[
'ajax'
]
===
'testing-sendhistory-form'
)
{
echo
CActiveForm
::
validate
(
$model
);
Yii
::
app
()
->
end
();
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
}
common/modules/testings/controllers/TestingUserAdminController.php
View file @
eac79345
...
...
@@ -6,7 +6,8 @@ use Yii;
use
common\components\AdminController
;
use
yii\web\NotFoundHttpException
;
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\SearchTestingUser
;
...
...
@@ -14,8 +15,6 @@ use common\modules\testings\models\SearchTestingUserGroup;
class
TestingUserAdminController
extends
AdminController
{
private
$_marked
;
public
static
function
actionsTitles
()
{
return
array
(
...
...
@@ -25,8 +24,8 @@ class TestingUserAdminController extends AdminController
'Delete'
=>
'Удаление пользователя'
,
'Manage'
=>
'Управление пользователями'
,
'Manage-group'
=>
'Управление группами'
,
'Update
M
ark'
=>
'Пометка пользователй'
,
'Reset
M
ark'
=>
'Сброс пометок'
,
'Update
-m
ark'
=>
'Пометка пользователй'
,
'Reset
-m
ark'
=>
'Сброс пометок'
,
);
}
...
...
@@ -39,6 +38,19 @@ class TestingUserAdminController extends AdminController
'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
]);
}
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.
* If the model is not found, a 404 HTTP exception will be thrown.
...
...
common/modules/testings/models/SearchTestingSendHistory.php
0 → 100644
View file @
eac79345
<?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
common/modules/testings/models/TestingSendHistory.php
View file @
eac79345
...
...
@@ -5,12 +5,13 @@ namespace common\modules\testings\models;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\Expression
;
use
yii\helpers\Url
;
class
TestingSendHistory
extends
\common\components\ActiveRecordModel
{
const
PAGE_SIZE
=
10
;
const
FOLDER_PATH
=
'/upload/dublicates/'
;
const
FOLDER_PATH
=
'/upload
s
/dublicates/'
;
const
OFFSET_EXCEL_ROWS
=
3
;
...
...
@@ -152,12 +153,12 @@ class TestingSendHistory extends \common\components\ActiveRecordModel
public
function
getFilePath
()
{
return
Yii
::
get
PathOfAlias
(
'
webroot'
)
.
self
::
FOLDER_PATH
.
$this
->
file
;
return
Yii
::
get
Alias
(
'@
webroot'
)
.
self
::
FOLDER_PATH
.
$this
->
file
;
}
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
)
...
...
common/modules/testings/views/testing-answer-admin/manage.php
View file @
eac79345
...
...
@@ -57,7 +57,6 @@ if ($question)
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{view} {update}'
,
'contentOptions'
=>
[
'style'
=>
'width:60px;'
,
'align'
=>
'center'
],
],
],
]);
?>
...
...
common/modules/testings/views/testing-passing-admin/manage.php
View file @
eac79345
...
...
@@ -131,7 +131,6 @@ use common\modules\testings\models\TestingPassing;
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{view} {delete}'
,
'contentOptions'
=>
[
'style'
=>
'width:60px;'
,
'align'
=>
'center'
],
],
],
]);
?>
common/modules/testings/views/testing-passing-admin/statistics.php
View file @
eac79345
...
...
@@ -205,7 +205,6 @@ use common\modules\testings\models\TestingPassing;
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{view} {delete}'
,
'contentOptions'
=>
[
'style'
=>
'width:60px;'
,
'align'
=>
'center'
],
],
],
]);
?>
\ No newline at end of file
common/modules/testings/views/testing-question-admin/manage.php
View file @
eac79345
...
...
@@ -155,7 +155,6 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{view} {update}'
,
'contentOptions'
=>
[
'style'
=>
'width:60px;'
,
'align'
=>
'center'
],
],
],
]);
?>
\ No newline at end of file
common/modules/testings/views/testing-send-history-admin/manage.php
0 → 100644
View file @
eac79345
<?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
common/modules/testings/views/testing-session-admin/manage.php
View file @
eac79345
...
...
@@ -93,7 +93,6 @@ use \common\components\zii\AdminGrid;
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{view} {update}'
,
'contentOptions'
=>
[
'style'
=>
'width:60px;'
,
'align'
=>
'center'
],
],
],
]);
?>
\ No newline at end of file
common/modules/testings/views/testing-test-admin/manage.php
View file @
eac79345
...
...
@@ -6,7 +6,6 @@ use \common\components\zii\AdminGrid;
use
common\modules\testings\models\TestingSession
;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\faq\models\SearchFaq */
/* @var $dataProvider yii\data\ActiveDataProvider */
$session_id
=
null
;
...
...
@@ -75,7 +74,6 @@ if($session)
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{view} {update}'
,
'contentOptions'
=>
[
'style'
=>
'width:60px;'
,
'align'
=>
'center'
],
],
],
]);
?>
...
...
common/modules/testings/views/testing-user-admin/manage.php
View file @
eac79345
...
...
@@ -13,10 +13,21 @@ use common\modules\testings\models\TestingPassing;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$session
=
null
;
if
(
\Yii
::
$app
->
request
->
get
(
'session'
))
{
$session
=
TestingSession
::
findOne
(
\Yii
::
$app
->
request
->
get
(
'session'
));
}
?>
<p>
<?=
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>
<?php
if
(
\Yii
::
$app
->
session
->
hasFlash
(
'flash'
))
:
?>
...
...
@@ -99,11 +110,8 @@ $columns = [
$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
);
$qty
=
count
(
$marked
);
...
...
@@ -111,24 +119,26 @@ if (\Yii::$app->request->get('session'))
$style
=
(
$qty
)
?
''
:
'display:none;'
;
$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'
]
);
$clear
=
Html
::
a
(
"[сброс]"
,
[
'resetM
ark'
,
'session'
=>
$session
->
id
],
[
'update-m
ark'
,
'session'
=>
$session
->
id
],
[
'style'
=>
$style
,
'id'
=>
'resetMarkup'
]
);
$link
=
$send
.
' '
.
$clear
;
$link
=
$send
.
' '
.
$clear
.
'<br><br>'
;
// array_unshift(
// $columns,
// [
// 'class' => 'MarkBoxColumn',
// 'update_url' => Url::to(['update-mark', 'session' => $session->id]),
// ]
// );
echo
$link
;
array_unshift
(
$columns
,
[
'class'
=>
'common\modules\testings\components\MarkBoxColumn'
,
'updateUrl'
=>
Url
::
to
([
'update-mark'
,
'session'
=>
$session
->
id
]),
]
);
foreach
(
$session
->
tests
as
$test
)
{
...
...
@@ -159,44 +169,29 @@ if (\Yii::$app->request->get('session'))
);
}
// $this->tabs = array(
// 'разослать уведомления всем' => $this->createUrl('/testings/testingSessionAdmin/sendMessageToAll',array('id'=>$session->id)),
// 'история отправки дубликатов' => $this->createUrl('/testings/testingSendHistoryAdmin/manage', array('session'=>$session->id)),
// 'импорт пользователей из CSV' => $this->createUrl(
// '/testings/testingSessionAdmin/importPassings',
// array('id'=>$session->id)
// ),
// );
// $buttons = array(
// 'class' => 'CButtonColumn',
// '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' => 'Уведомить о тестировании',
// ),
// ),
// ),
// );
}
$buttons
=
[
[
'class'
=>
\common\components\ColorActionColumn
::
className
(),
'template'
=>
'{send} {view} {update}'
,
'buttons'
=>
[
'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'
=>
'Уведомить о тестировании'
,
'data-toggle'
=>
'tooltip'
,
'data-pjax'
=>
'0'
,
]);
},
]
]
];
$columns
=
ArrayHelper
::
merge
(
$columns
,
$buttons
);
}
echo
AdminGrid
::
widget
([
'dataProvider'
=>
$dataProvider
,
'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
common/modules/testings/views/testingSendHistoryAdmin/manage.php
deleted
100644 → 0
View file @
0d6586b6
<?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
}
"
,
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment