Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
skeeks
/
cms-module-shop
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Merge Requests
0
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d8f3add1
authored
Apr 13, 2015
by
semenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
b170adf9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
8 deletions
+122
-8
controllers/AdminShopOrderController.php
+1
-1
models/ShopOrder.php
+31
-0
views/admin-shop-order/index.php
+55
-7
widgets/orders/OrdersWidget.php
+35
-0
No files found.
controllers/AdminShopOrderController.php
View file @
d8f3add1
...
@@ -21,7 +21,7 @@ class AdminShopOrderController extends AdminModelEditorSmartController
...
@@ -21,7 +21,7 @@ class AdminShopOrderController extends AdminModelEditorSmartController
public
function
init
()
public
function
init
()
{
{
$this
->
_label
=
"Заказы"
;
$this
->
_label
=
"Заказы"
;
$this
->
_modelShowAttribute
=
"
name
"
;
$this
->
_modelShowAttribute
=
"
id
"
;
$this
->
_modelClassName
=
ShopOrder
::
className
();
$this
->
_modelClassName
=
ShopOrder
::
className
();
$this
->
modelValidate
=
true
;
$this
->
modelValidate
=
true
;
...
...
models/ShopOrder.php
View file @
d8f3add1
...
@@ -9,6 +9,8 @@ namespace skeeks\modules\cms\shop\models;
...
@@ -9,6 +9,8 @@ namespace skeeks\modules\cms\shop\models;
use
skeeks\cms\models\behaviors\HasStatus
;
use
skeeks\cms\models\behaviors\HasStatus
;
use
skeeks\cms\models\behaviors\HasStatusBoolean
;
use
skeeks\cms\models\behaviors\HasStatusBoolean
;
use
skeeks\cms\models\Core
;
use
skeeks\cms\models\Core
;
use
skeeks\modules\cms\money\Currency
;
use
skeeks\modules\cms\money\Money
;
use
\Yii
;
use
\Yii
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\ArrayHelper
;
...
@@ -186,4 +188,32 @@ class ShopOrder extends Core
...
@@ -186,4 +188,32 @@ class ShopOrder extends Core
}
}
/**
* @return Money
*/
public
function
price
()
{
if
(
$this
->
price
)
{
return
Money
::
fromString
((
string
)
$this
->
price
,
$this
->
currency
());
}
return
Money
::
fromString
((
string
)
0
,
$this
->
currency
());
}
/**
* @return Currency
*/
public
function
currency
()
{
if
(
$currency
=
$this
->
getAttribute
(
$this
->
currency
))
{
return
Currency
::
getInstance
(
$currency
);
}
return
Currency
::
getInstance
(
\Yii
::
$app
->
money
->
currency
);
}
}
}
\ No newline at end of file
views/admin-shop-order/index.php
View file @
d8f3add1
...
@@ -14,10 +14,7 @@ use skeeks\cms\modules\admin\widgets\GridView;
...
@@ -14,10 +14,7 @@ use skeeks\cms\modules\admin\widgets\GridView;
/* @var $searchModel common\models\searchs\Game */
/* @var $searchModel common\models\searchs\Game */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $dataProvider yii\data\ActiveDataProvider */
$dataProvider
->
sort
->
defaultOrder
=
[
$dataProvider
->
sort
->
defaultOrder
=
[
'id'
=>
SORT_DESC
];
'active'
=>
SORT_DESC
,
];
?>
?>
<?=
GridView
::
widget
([
<?=
GridView
::
widget
([
...
@@ -28,10 +25,61 @@ $dataProvider->sort->defaultOrder = [
...
@@ -28,10 +25,61 @@ $dataProvider->sort->defaultOrder = [
'class'
=>
\skeeks\cms\modules\admin\grid\ActionColumn
::
className
(),
'class'
=>
\skeeks\cms\modules\admin\grid\ActionColumn
::
className
(),
'controller'
=>
$controller
'controller'
=>
$controller
],
],
'name'
,
[
'class'
=>
\skeeks\cms\grid\CreatedAtColumn
::
className
(),
],
[
'class'
=>
\yii\grid\DataColumn
::
className
(),
'value'
=>
function
(
\skeeks\modules\cms\shop\models\ShopOrder
$model
)
{
return
"№"
.
$model
->
id
;
},
'label'
=>
'Номер заказа'
,
'attribute'
=>
'id'
,
//'filter' => \yii\helpers\Html::input(),
],
[
'class'
=>
\yii\grid\DataColumn
::
className
(),
'value'
=>
function
(
\skeeks\modules\cms\shop\models\ShopOrder
$model
)
{
$result
=
[];
foreach
(
$model
->
shopBaskets
as
$shopBasket
)
{
$result
[]
=
\yii\helpers\Html
::
a
(
"[
{
$shopBasket
->
product
->
id
}
] "
.
$shopBasket
->
product
->
name
.
" (
{
$shopBasket
->
quantity
}
шт.)"
,
$shopBasket
->
product
->
getPageUrl
(),
[
'data'
=>
[
'pjax'
=>
'0'
],
'target'
=>
'_blank'
,
'title'
=>
'Смотреть товар на сайте (откроется в новой вкладке)'
]);
}
return
implode
(
'<hr style="margin-top: 5px; margin-bottom: 5px;"/>'
,
$result
);
},
'label'
=>
'Позиции'
,
'format'
=>
'raw'
,
],
[
'class'
=>
\skeeks\cms\grid\UserColumnData
::
className
(),
'attribute'
=>
'user_id'
,
'label'
=>
'Покупатель'
],
[
[
'class'
=>
\skeeks\cms\grid\BooleanColumn
::
className
(),
'attribute'
=>
'price'
,
'attribute'
=>
'active'
'label'
=>
'Сумма'
,
'class'
=>
\yii\grid\DataColumn
::
className
(),
'value'
=>
function
(
\skeeks\modules\cms\shop\models\ShopOrder
$model
)
{
return
\Yii
::
$app
->
money
->
intlFormatter
()
->
format
(
$model
->
price
());
},
],
],
],
],
]);
?>
]);
?>
widgets/orders/OrdersWidget.php
0 → 100644
View file @
d8f3add1
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 03.04.2015
*/
namespace
skeeks\modules\cms\shop\widgets\orders
;
use
skeeks\cms\widgets\base\hasModelsSmart\WidgetHasModelsSmart
;
use
skeeks\cms\widgets\base\hasTemplate\WidgetHasTemplate
;
use
skeeks\modules\cms\shop\assets\ShopAsset
;
use
skeeks\modules\cms\shop\models\ShopOrder
;
use
yii\helpers\Json
;
/**
* Class OrdersWidget
* @package skeeks\modules\cms\shop\widgets
*/
class
OrdersWidget
extends
WidgetHasModelsSmart
{
public
$modelClassName
=
'\skeeks\modules\cms\shop\models\ShopOrder'
;
public
$title
=
''
;
public
function
rules
()
{
return
ArrayHelper
::
merge
(
parent
::
rules
(),
[
]);
}
public
function
attributeLabels
()
{
return
ArrayHelper
::
merge
(
parent
::
attributeLabels
(),
[
]);
}
}
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