Finish version/v.0.0.86
This commit is contained in:
commit
eb59cf9424
@ -202,14 +202,26 @@ class InventoryItemController extends Controller
|
|||||||
|
|
||||||
$model->save(false);
|
$model->save(false);
|
||||||
|
|
||||||
$prev = Url::previous("inventory-item-index");
|
\Yii::$app->session->setFlash('success', "Mennyiség elmentve: " . $model->productName . ' - ' .$model->count . ' db');
|
||||||
|
|
||||||
if (isset($prev)) {
|
// $prev = Url::previous("inventory-item-index");
|
||||||
return $this->redirect($prev);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
|
// if (isset($prev)) {
|
||||||
|
// return $this->redirect($prev);
|
||||||
|
// } else {
|
||||||
|
// return $this->redirect(['index', 'id' => $inventory->id_inventory]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
$next = InventoryItem::findNextItemAlphabetical($model->id_inventory_item);
|
||||||
|
if ( isset($next)){
|
||||||
|
return $this->redirect(['inventory-item/update', 'id' => $next]);
|
||||||
|
}else{
|
||||||
return $this->redirect(['index', 'id' => $inventory->id_inventory]);
|
return $this->redirect(['index', 'id' => $inventory->id_inventory]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return $this->render('update', [
|
return $this->render('update', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
|||||||
@ -2,27 +2,17 @@
|
|||||||
|
|
||||||
namespace backend\controllers;
|
namespace backend\controllers;
|
||||||
|
|
||||||
use common\models\City;
|
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use backend\models\GiroBeszedForm;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CityController implements the CRUD actions for City model.
|
* CityController implements the CRUD actions for City model.
|
||||||
*/
|
*/
|
||||||
class TestController extends Controller
|
class TestController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function actionIndex(){
|
||||||
|
|
||||||
public function actionCreateBeszed(){
|
return "ok";
|
||||||
|
|
||||||
$model = new GiroBeszedForm();
|
|
||||||
|
|
||||||
if ($model->load(\Yii::$app->request->post()) ) {
|
|
||||||
$model->run();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render("_create_beszed",['model' => $model]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,18 +2,15 @@
|
|||||||
|
|
||||||
namespace backend\models;
|
namespace backend\models;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use common\models\Card;
|
|
||||||
use common\models\Customer;
|
|
||||||
use common\models\Ticket;
|
|
||||||
use common\models\Account;
|
|
||||||
use yii\web\UploadedFile;
|
|
||||||
use common\models\Inventory;
|
use common\models\Inventory;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use common\models\Product;
|
use common\models\Product;
|
||||||
use common\models\InventoryGroup;
|
use common\models\InventoryGroup;
|
||||||
use common\models\InventoryItem;
|
use common\models\InventoryItem;
|
||||||
|
use yii\db\Expression;
|
||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
use common\models\Procurement;
|
use common\models\Procurement;
|
||||||
use common\models\Transfer;
|
use common\models\Transfer;
|
||||||
@ -51,7 +48,9 @@ class InventoryItemForm extends Model{
|
|||||||
public $product_stock;
|
public $product_stock;
|
||||||
public $last_inventory_item;
|
public $last_inventory_item;
|
||||||
public $inventory_item;
|
public $inventory_item;
|
||||||
|
|
||||||
|
public $next_item_index;
|
||||||
|
|
||||||
public function rules(){
|
public function rules(){
|
||||||
return [
|
return [
|
||||||
[[ 'name', 'count'], 'required'],
|
[[ 'name', 'count'], 'required'],
|
||||||
@ -63,14 +62,16 @@ class InventoryItemForm extends Model{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateType($attribute,$params){
|
public function validateType(/** @noinspection PhpUnusedParameterInspection */
|
||||||
|
$attribute, $params){
|
||||||
if ( array_search($this->type, ['product','group']) === false ){
|
if ( array_search($this->type, ['product','group']) === false ){
|
||||||
\Yii::error("Típus nem megfelelő: " . $this->type);
|
\Yii::error("Típus nem megfelelő: " . $this->type);
|
||||||
$this->addError("name","Nincs termék vagy termék csoport kiválasztva");
|
$this->addError("name","Nincs termék vagy termék csoport kiválasztva");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateId($attribute,$params){
|
public function validateId(/** @noinspection PhpUnusedParameterInspection */
|
||||||
|
$attribute, $params){
|
||||||
if ( !$this->hasErrors('type')){
|
if ( !$this->hasErrors('type')){
|
||||||
if ( $this->type == 'group'){
|
if ( $this->type == 'group'){
|
||||||
$this->inventoryGroup = InventoryGroup::findOne($this->id_product);
|
$this->inventoryGroup = InventoryGroup::findOne($this->id_product);
|
||||||
@ -150,7 +151,10 @@ class InventoryItemForm extends Model{
|
|||||||
if ( isset($this->last_inventory_item ) ){
|
if ( isset($this->last_inventory_item ) ){
|
||||||
$query->andWhere([ '>', 'procurement.created_at' ,$this->last_inventory_item->created_at]);
|
$query->andWhere([ '>', 'procurement.created_at' ,$this->last_inventory_item->created_at]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//$query->andWhere([ '>', 'procurement.created_at' ,$this->inventory->created_at]);
|
||||||
|
|
||||||
|
|
||||||
if ( $this->type == 'product') {
|
if ( $this->type == 'product') {
|
||||||
$query->andWhere(['product.id_product' => $this->product->id_product]);
|
$query->andWhere(['product.id_product' => $this->product->id_product]);
|
||||||
}else{
|
}else{
|
||||||
@ -170,6 +174,10 @@ class InventoryItemForm extends Model{
|
|||||||
$query->innerJoin(Product::tableName(),"product.id_product = sale.id_product ");
|
$query->innerJoin(Product::tableName(),"product.id_product = sale.id_product ");
|
||||||
$query->andWhere(['in', 'transfer.status' ,[Transfer::STATUS_PAID ,Transfer::STATUS_NOT_PAID ] ]);
|
$query->andWhere(['in', 'transfer.status' ,[Transfer::STATUS_PAID ,Transfer::STATUS_NOT_PAID ] ]);
|
||||||
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||||
|
|
||||||
|
if ( isset($this->last_inventory_item ) ){
|
||||||
|
$query->andWhere([ '>', 'transfer.created_at' ,$this->last_inventory_item->created_at]);
|
||||||
|
}
|
||||||
|
|
||||||
if ( $this->type == 'product') {
|
if ( $this->type == 'product') {
|
||||||
$query->andWhere(['product.id_product' => $this->product->id_product]);
|
$query->andWhere(['product.id_product' => $this->product->id_product]);
|
||||||
@ -275,16 +283,14 @@ class InventoryItemForm extends Model{
|
|||||||
|
|
||||||
foreach ($this->products as $product ){
|
foreach ($this->products as $product ){
|
||||||
$this->productOptions[]= [ 'type' =>'product', 'id' => $product->id_product ,'name' => $product->name . " (Termék/" .$product->productCategoryName ."/" . $product->accountName .")" ];
|
$this->productOptions[]= [ 'type' =>'product', 'id' => $product->id_product ,'name' => $product->name . " (Termék/" .$product->productCategoryName ."/" . $product->accountName .")" ];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->inventoryGroups as $inventoryGroup ){
|
foreach ($this->inventoryGroups as $inventoryGroup ){
|
||||||
$this->productOptions[] = ['type' =>'group', 'id' =>$inventoryGroup->id_inventory_group ,'name' =>$inventoryGroup->name ."/Termékcsoport" ];
|
$this->productOptions[] = ['type' =>'group', 'id' =>$inventoryGroup->id_inventory_group ,'name' =>$inventoryGroup->name ."/Termékcsoport" ];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attributeLabels()
|
public function attributeLabels()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -293,5 +299,7 @@ class InventoryItemForm extends Model{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ $options = [];
|
|||||||
$options['products'] = $model->productOptions;
|
$options['products'] = $model->productOptions;
|
||||||
$options['url_product_find'] = Url::toRoute(['product/find']);
|
$options['url_product_find'] = Url::toRoute(['product/find']);
|
||||||
|
|
||||||
$this->registerJs('inventoryItemCreate.init( '. json_encode($options) .' );');
|
$this-> registerJs('inventoryItemCreate.init( '. json_encode($options) .' );');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="inventory-item-create">
|
<div class="inventory-item-create">
|
||||||
|
|||||||
@ -24,6 +24,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!--suppress CssUnusedSymbol -->
|
||||||
<style>
|
<style>
|
||||||
.table th {
|
.table th {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
@ -38,6 +39,19 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.col-b{
|
||||||
|
/*background-color: #00a157;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-striped > tbody > tr:nth-of-type(even) td.col-b {
|
||||||
|
background-color: #DFE3E8;
|
||||||
|
/*background-color: #D3D7DC;*/
|
||||||
|
}
|
||||||
|
.table-striped > tbody > tr:nth-of-type(odd) td.col-b {
|
||||||
|
/*background-color: #E0E0E0;*/
|
||||||
|
background-color: #ECECEC;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<div class="inventory-item-index">
|
<div class="inventory-item-index">
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
@ -65,7 +79,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
<p>
|
<div>
|
||||||
Magyarázat:
|
Magyarázat:
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
@ -87,7 +101,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
Különbség: = "Leltározott mennyiség - ( "Előző leltár" + "Beszerzett mennyiség" - "Eladott mennyiség" )
|
Különbség: = "Leltározott mennyiség - ( "Előző leltár" + "Beszerzett mennyiség" - "Eladott mennyiség" )
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<?php echo Html::a("XLS letöltése", Url::current(['InventoryItemSearch[output]' => 'xls']), ['class' => 'btn btn-primary']) ?>
|
<?php echo Html::a("XLS letöltése", Url::current(['InventoryItemSearch[output]' => 'xls']), ['class' => 'btn btn-primary']) ?>
|
||||||
</p>
|
</p>
|
||||||
@ -100,7 +114,8 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'inventory_prev_name',
|
'attribute' => 'inventory_prev_name',
|
||||||
'label' => 'Utolsó leltár'
|
'label' => 'Utolsó leltár',
|
||||||
|
'contentOptions' => ['class' => 'col-b']
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'item_count_system',
|
'attribute' => 'item_count_system',
|
||||||
@ -111,7 +126,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
[
|
[
|
||||||
'attribute' => 'item_count',
|
'attribute' => 'item_count',
|
||||||
'label' => 'Leltározott mennyiség (db)',
|
'label' => 'Leltározott mennyiség (db)',
|
||||||
'contentOptions' => ['class' => 'numeric']
|
'contentOptions' => ['class' => 'numeric col-b']
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -123,7 +138,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
[
|
[
|
||||||
'attribute' => 'item_count_in',
|
'attribute' => 'item_count_in',
|
||||||
'label' => 'Beszerzett mennyiség (db)',
|
'label' => 'Beszerzett mennyiség (db)',
|
||||||
'contentOptions' => ['class' => 'numeric']
|
'contentOptions' => ['class' => 'numeric col-b' ]
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -135,7 +150,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
[
|
[
|
||||||
'attribute' => 'item_difference',
|
'attribute' => 'item_difference',
|
||||||
'label' => 'Különbség (db)',
|
'label' => 'Különbség (db)',
|
||||||
'contentOptions' => ['class' => 'numeric']
|
'contentOptions' => ['class' => 'numeric col-b']
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -146,7 +161,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
[
|
[
|
||||||
'attribute' => 'item_total_price_brutto',
|
'attribute' => 'item_total_price_brutto',
|
||||||
'label' => 'Összeg (Ft)',
|
'label' => 'Összeg (Ft)',
|
||||||
'contentOptions' => ['class' => 'numeric']
|
'contentOptions' => ['class' => 'numeric col-b']
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
@ -165,7 +180,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
|
|||||||
'urlCreator' => function ($action, $model) {
|
'urlCreator' => function ($action, $model) {
|
||||||
$result = "";
|
$result = "";
|
||||||
if ($action == 'update') {
|
if ($action == 'update') {
|
||||||
$result = Url::toRoute(['update-item', 'id' => $model['item_id_inventory_item']]);
|
$result = Url::toRoute(['update', 'id' => $model['item_id_inventory_item']]);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,11 @@ use yii\widgets\DetailView;
|
|||||||
/* @var $model common\models\InventoryItem */
|
/* @var $model common\models\InventoryItem */
|
||||||
|
|
||||||
$this->title = Yii::t('common/inventory-item', 'Leltár termék');
|
$this->title = Yii::t('common/inventory-item', 'Leltár termék');
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory-item', 'Inventory Items'), 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => 'Leltár termékek', 'url' => ['index', 'id' => $model->id_inventory]];
|
||||||
$this->params['breadcrumbs'][] = ['label' => $model->id_inventory_item, 'url' => ['view', 'id' => $model->id_inventory_item]];
|
$this->params['breadcrumbs'][] = ['label' => $model->id_inventory_item, 'url' => ['view', 'id' => $model->id_inventory_item]];
|
||||||
$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Update');
|
$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Update');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="inventory-item-update">
|
<div class="inventory-item-update">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
-0.0.86
|
||||||
|
- add inventory "load sold count" for item fix
|
||||||
|
- Detstat file > transfer type cash on failed
|
||||||
|
- add ticket installment dateutal/addDay changes
|
||||||
-0.0.85
|
-0.0.85
|
||||||
- add key assign/unassign log
|
- add key assign/unassign log
|
||||||
-0.0.84
|
-0.0.84
|
||||||
|
|||||||
68
common/components/DateUtil.php
Normal file
68
common/components/DateUtil.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: rocho
|
||||||
|
* Date: 2016. 09. 08.
|
||||||
|
* Time: 7:01
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace common\components;
|
||||||
|
|
||||||
|
use yii\i18n\Formatter;
|
||||||
|
|
||||||
|
class DateUtil
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function addMonth($timestamp, $monthCount = 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($timestamp instanceof \DateTime) {
|
||||||
|
$d1 = $timestamp;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$d1 = new \DateTime();
|
||||||
|
|
||||||
|
if (isset($timestamp)) {
|
||||||
|
$d1->setTimestamp($timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$monthToAdd = $monthCount;
|
||||||
|
|
||||||
|
|
||||||
|
$year = $d1->format('Y');
|
||||||
|
$month = $d1->format('n');
|
||||||
|
$day = $d1->format('d');
|
||||||
|
|
||||||
|
$year += floor($monthToAdd / 12);
|
||||||
|
$monthToAdd = $monthToAdd % 12;
|
||||||
|
$month += $monthToAdd;
|
||||||
|
if ($month > 12) {
|
||||||
|
$year++;
|
||||||
|
$month = $month % 12;
|
||||||
|
if ($month === 0)
|
||||||
|
$month = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkdate($month, $day, $year)) {
|
||||||
|
$d2 = \DateTime::createFromFormat('Y-n-j', $year . '-' . $month . '-1');
|
||||||
|
$d2->modify('last day of');
|
||||||
|
} else {
|
||||||
|
$d2 = \DateTime::createFromFormat('Y-n-d', $year . '-' . $month . '-' . $day);
|
||||||
|
}
|
||||||
|
$d2->setTime(0, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
return $d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function formatUtc($dateTimeObject)
|
||||||
|
{
|
||||||
|
$formatter = new Formatter;
|
||||||
|
$formatter->datetimeFormat = 'php:Y-m-d H:i:s';
|
||||||
|
$formatter->timeZone = 'UTC';
|
||||||
|
return $formatter->asDatetime($dateTimeObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -149,7 +149,8 @@ class DetStatTetelProcessor extends Object {
|
|||||||
'discount'=> $discount,
|
'discount'=> $discount,
|
||||||
'contract'=> $this->contract,
|
'contract'=> $this->contract,
|
||||||
'ticketInstallmentRequest' => $megbizas,
|
'ticketInstallmentRequest' => $megbizas,
|
||||||
'transferStatus' => Transfer::STATUS_NOT_PAID
|
'transferStatus' => Transfer::STATUS_NOT_PAID,
|
||||||
|
'paymentMethod' => Transfer::PAYMENT_METHOD_CASH
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -219,7 +220,7 @@ class DetStatTetelProcessor extends Object {
|
|||||||
* Szerződés módosítása, ha a detsta üzenetben a megbízás el lett fogadva
|
* Szerződés módosítása, ha a detsta üzenetben a megbízás el lett fogadva
|
||||||
* */
|
* */
|
||||||
protected function updateContractOnSuccess(){
|
protected function updateContractOnSuccess(){
|
||||||
\Yii::info('Szerződés frissítése - megbizás elfogadva ' );
|
\Yii::info('Szerződés frissítése - megbízás elfogadva ' );
|
||||||
$this->incRequiredParts();
|
$this->incRequiredParts();
|
||||||
$this->contract->part_paid = $this->contract->part_paid +1;
|
$this->contract->part_paid = $this->contract->part_paid +1;
|
||||||
$this->updateContractPaidStatus();
|
$this->updateContractPaidStatus();
|
||||||
@ -232,7 +233,7 @@ class DetStatTetelProcessor extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function updateContractOnFail(){
|
protected function updateContractOnFail(){
|
||||||
\Yii::info('Szerződés frissítése - megbizás visszautasítva ' );
|
\Yii::info('Szerződés frissítése - megbízás visszautasítva ' );
|
||||||
$this->incRequiredParts();
|
$this->incRequiredParts();
|
||||||
$this->updateContractPaidStatus();
|
$this->updateContractPaidStatus();
|
||||||
// $this->contract->status = Contract::$STATUS_NOT_PAID;
|
// $this->contract->status = Contract::$STATUS_NOT_PAID;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.85',
|
'version' => 'v0.0.86',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
|
|||||||
@ -20,6 +20,8 @@ use common\components\Helper;
|
|||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
|
* @property mixed userName
|
||||||
|
* @property mixed accountName
|
||||||
*/
|
*/
|
||||||
class Inventory extends \common\models\BaseFitnessActiveRecord
|
class Inventory extends \common\models\BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
|
use yii\db\Expression;
|
||||||
|
use yii\db\Query;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use common\components\UserAwareBehavior;
|
use common\components\UserAwareBehavior;
|
||||||
use common\components\Helper;
|
|
||||||
use common\components\ProductAwareBehavior;
|
use common\components\ProductAwareBehavior;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +30,7 @@ use common\components\ProductAwareBehavior;
|
|||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property mixed productName
|
* @property mixed productName
|
||||||
|
* @property mixed product
|
||||||
*/
|
*/
|
||||||
class InventoryItem extends BaseFitnessActiveRecord
|
class InventoryItem extends BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
@ -36,7 +39,8 @@ class InventoryItem extends BaseFitnessActiveRecord
|
|||||||
public static $TYPE_INVENTORY_GROUP = 20;
|
public static $TYPE_INVENTORY_GROUP = 20;
|
||||||
|
|
||||||
|
|
||||||
public static $UPDATE_COUNT = "
|
public static /** @noinspection SqlResolve */
|
||||||
|
$UPDATE_COUNT = "
|
||||||
UPDATE product as p1
|
UPDATE product as p1
|
||||||
inner JOIN ( select inventory_item.id_product as id_product , inventory_item.count as count
|
inner JOIN ( select inventory_item.id_product as id_product , inventory_item.count as count
|
||||||
from inventory_item
|
from inventory_item
|
||||||
@ -113,7 +117,11 @@ class InventoryItem extends BaseFitnessActiveRecord
|
|||||||
public function getInventoryGroup(){
|
public function getInventoryGroup(){
|
||||||
return $this->hasOne( Product::className() , [ 'id_inventory_group' => 'id_inventory_group' ]);
|
return $this->hasOne( Product::className() , [ 'id_inventory_group' => 'id_inventory_group' ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getInventoryItemPrev(){
|
||||||
|
return $this->hasOne( InventoryItem::className(),['id_inventory_item' => 'id_inventory_item_prev'] );
|
||||||
|
}
|
||||||
|
|
||||||
public function getProductName(){
|
public function getProductName(){
|
||||||
$result = "";
|
$result = "";
|
||||||
|
|
||||||
@ -136,10 +144,12 @@ class InventoryItem extends BaseFitnessActiveRecord
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
/**
|
||||||
$name = "";
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(){
|
||||||
|
|
||||||
if ( isset($this->id_product )){
|
if ( isset($this->id_product )){
|
||||||
$name = $this->getProductName();
|
$name = $this->getProductName();
|
||||||
}else{
|
}else{
|
||||||
@ -170,7 +180,54 @@ class InventoryItem extends BaseFitnessActiveRecord
|
|||||||
|
|
||||||
$this->total_price_brutto = $price * $diff;
|
$this->total_price_brutto = $price * $diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function findNextItemAlphabetical($id_inventory_item){
|
||||||
|
|
||||||
|
$inventoryItem = InventoryItem::findOne($id_inventory_item);
|
||||||
|
$id_inventory = $inventoryItem->id_inventory;
|
||||||
|
$currentItemId = $id_inventory_item;
|
||||||
|
|
||||||
|
$query = new Query();
|
||||||
|
$query->select([
|
||||||
|
'inventory_item.id_inventory_item as inventory_item_id_inventory',
|
||||||
|
new Expression(
|
||||||
|
"case when inventory_item.type = " .InventoryItem::$TYPE_PRODUCT . " then product.name else inventory_group.name end as name"
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->from('inventory_item');
|
||||||
|
$query->leftJoin("product", 'product.id_product = inventory_item.id_product and inventory_item.type =' .InventoryItem::$TYPE_PRODUCT);
|
||||||
|
$query->leftJoin("inventory_group", 'inventory_group.id_inventory_group = inventory_item.id_product and inventory_item.type =' .InventoryItem::$TYPE_INVENTORY_GROUP);
|
||||||
|
$query->andWhere(['id_inventory' => $id_inventory]);
|
||||||
|
$query->orderBy("name");
|
||||||
|
$result = $query->all();
|
||||||
|
|
||||||
|
$currentItemIndex = null;
|
||||||
|
$size = count($result);
|
||||||
|
for ( $i = 0; $i < $size; $i++ ){
|
||||||
|
$item = $result[$i];
|
||||||
|
$id = $item['inventory_item_id_inventory'];
|
||||||
|
if ( $id == $currentItemId ){
|
||||||
|
$currentItemIndex = $i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $currentItemIndex ) ){
|
||||||
|
$next = ($currentItemIndex +1 );
|
||||||
|
if ($size > $next){
|
||||||
|
return $result[$next]['inventory_item_id_inventory'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function afterSave($insert, $changedAttributes){
|
public function afterSave($insert, $changedAttributes){
|
||||||
if ( !$insert ){
|
if ( !$insert ){
|
||||||
// if ( $this->type == 'product'){
|
// if ( $this->type == 'product'){
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use common\components\DateUtil;
|
||||||
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\behaviors\TimestampBehavior;
|
use yii\behaviors\TimestampBehavior;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
@ -32,6 +34,9 @@ use common\components\Helper;
|
|||||||
* @property \common\models\Contract contract
|
* @property \common\models\Contract contract
|
||||||
* @property \common\models\Customer customer
|
* @property \common\models\Customer customer
|
||||||
* @property string number
|
* @property string number
|
||||||
|
* @property mixed ticket
|
||||||
|
* @property integer id_contract
|
||||||
|
* @property mixed ugiro
|
||||||
*/
|
*/
|
||||||
class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@ -125,9 +130,21 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getTicketExpirationDate(){
|
public function getTicketExpirationDate(){
|
||||||
$date = \DateTime::createFromFormat("Y-m-d H:i:s", $this->request_target_time_at, new \DateTimeZone( 'UTC'));
|
$contract = $this->contract;
|
||||||
$date->modify("+1 month");
|
|
||||||
$date->modify("-1 day");
|
|
||||||
|
$started_at = $contract->started_at;
|
||||||
|
$date = \DateTime::createFromFormat("Y-m-d H:i:s", $started_at, new \DateTimeZone( 'UTC'));
|
||||||
|
$date = DateUtil::addMonth( $date,$this->priority + 1 );
|
||||||
|
// $date = \DateTime::createFromFormat("Y-m-d H:i:s", $this->request_target_time_at, new \DateTimeZone( 'UTC'));
|
||||||
|
// $date = DateUtil::addMonth( $date, 1 );
|
||||||
|
// $date->modify("+1 month");
|
||||||
|
// $date->modify("-1 day");
|
||||||
|
|
||||||
|
// $date = \DateTime::createFromFormat("Y-m-d H:i:s", $this->request_target_time_at, new \DateTimeZone( 'UTC'));
|
||||||
|
// $date->modify("+1 month");
|
||||||
|
// $date->modify("-1 day");
|
||||||
|
|
||||||
$date->setTime(0, 0, 0);
|
$date->setTime(0, 0, 0);
|
||||||
|
|
||||||
return $date->getTimestamp();
|
return $date->getTimestamp();
|
||||||
@ -153,8 +170,11 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
public function isStatusSent(){
|
public function isStatusSent(){
|
||||||
return $this->status == static::$STATUS_SENT ;
|
return $this->status == static::$STATUS_SENT ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdGiro(){
|
/**
|
||||||
|
* @return \common\models\Ugiro
|
||||||
|
*/
|
||||||
|
public function getIdGiro(){
|
||||||
$result = null;
|
$result = null;
|
||||||
$giro = $this->ugiro;
|
$giro = $this->ugiro;
|
||||||
if ( isset($giro) ){
|
if ( isset($giro) ){
|
||||||
@ -162,15 +182,21 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Megbízás státuszának beállítása
|
* Megbízás státuszának beállítása
|
||||||
*
|
*
|
||||||
* Létrehozza a szükséges ticket/transfer objectumokat
|
* Létrehozza a szükséges ticket/transfer objectumokat
|
||||||
*
|
*
|
||||||
* @param boolean $partRequired ha igaz, a bérleten a part mezőt változtatjuk
|
* @param $status
|
||||||
* */
|
* @param boolean $partRequired ha igaz, a bérleten a part mezőt változtatjuk
|
||||||
public function applyStatus($status, $partRequired = false, $visszajelzes = "", $comment = ""){
|
*
|
||||||
|
* @param string $visszajelzes
|
||||||
|
* @param string $comment
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function applyStatus($status, /** @noinspection PhpUnusedParameterInspection */
|
||||||
|
$partRequired = false, $visszajelzes = "", $comment = ""){
|
||||||
$contract = $this->contract;
|
$contract = $this->contract;
|
||||||
$contract->part_required = $contract->part_required +1;
|
$contract->part_required = $contract->part_required +1;
|
||||||
if ( $status == static::$STATUS_ACCEPTED || $status == static::$STATUS_ACCEPTED_MANUAL){
|
if ( $status == static::$STATUS_ACCEPTED || $status == static::$STATUS_ACCEPTED_MANUAL){
|
||||||
@ -218,36 +244,44 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
// $this->ticket->applyTicketInstallmentRequest($this);
|
// $this->ticket->applyTicketInstallmentRequest($this);
|
||||||
// $this->ticket->save(false);
|
// $this->ticket->save(false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
protected function addTransfer(){
|
/**
|
||||||
|
* @return Transfer
|
||||||
$account = Account::findOne($this->ticket->id_account);
|
*/
|
||||||
|
protected function addTransfer(){
|
||||||
|
|
||||||
|
/** @var \common\models\Account $account */
|
||||||
|
$account = Account::findOne($this->ticket->id_account);
|
||||||
$discount = null;
|
$discount = null;
|
||||||
if ( isset($this->ticket->id_account)){
|
if ( isset($this->ticket->id_account)){
|
||||||
$discount = Discount::findOne( $this->ticket->id_discount );
|
$discount = Discount::findOne( $this->ticket->id_discount );
|
||||||
}
|
}
|
||||||
|
|
||||||
$transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket);
|
/** @var \common\models\Account $account */
|
||||||
|
/** @noinspection PhpParamsInspection */
|
||||||
|
$transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket);
|
||||||
|
|
||||||
$transfer->status = Transfer::STATUS_PAID;
|
$transfer->status = Transfer::STATUS_PAID;
|
||||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||||
$transfer->paid_by = \Yii::$app->user->id;
|
$transfer->paid_by = \Yii::$app->user->id;
|
||||||
$transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
|
$transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
|
||||||
$transfer->money = $this->money;
|
$transfer->money = $this->money;
|
||||||
$transfer->comment = "Csoportos beszedes";
|
$transfer->comment = "Csoportos beszedés";
|
||||||
$transfer->id_user = \Yii::$app->user->id;
|
$transfer->id_user = \Yii::$app->user->id;
|
||||||
$transfer->id_customer = $this->ticket->card->customer->id_customer;
|
$transfer->id_customer = $this->ticket->card->customer->id_customer;
|
||||||
$transfer->save(false);
|
$transfer->save(false);
|
||||||
return $transfer;
|
return $transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \common\models\Ticket $ticket
|
* @param \common\models\Ticket $ticket
|
||||||
* @param \common\models\TicketType $type
|
* @param \common\models\TicketType $type
|
||||||
* @return \common\models\TicketInstallmentRequest[]
|
* @param $customer
|
||||||
* */
|
* @param $contract
|
||||||
|
* @return TicketInstallmentRequest[]
|
||||||
|
*/
|
||||||
public static function createInstallments($ticket,$type,$customer,$contract){
|
public static function createInstallments($ticket,$type,$customer,$contract){
|
||||||
$result = [];
|
$result = [];
|
||||||
if ( $type->isInstallment() ){
|
if ( $type->isInstallment() ){
|
||||||
@ -257,26 +291,35 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
if ( isset( $discount ) ){
|
if ( isset( $discount ) ){
|
||||||
$money = Discount::applyDiscount( $money, $discount );
|
$money = Discount::applyDiscount( $money, $discount );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ( $i = 1; $i <= $count; $i++){
|
for ( $i = 1; $i <= $count; $i++){
|
||||||
$request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $contract, $money, null, $i);
|
$request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $contract, $money, null, $i);
|
||||||
$result[] = $request;
|
$result[] = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createInstallment($ticket,$type,$customer,$contract,$money,$ticketCreated,$index){
|
/**
|
||||||
|
* @param $ticket
|
||||||
|
* @param $type
|
||||||
|
* @param $customer
|
||||||
|
* @param $contract
|
||||||
|
* @param $money
|
||||||
|
* @param $ticketCreated
|
||||||
|
* @param $index
|
||||||
|
* @return TicketInstallmentRequest
|
||||||
|
*/
|
||||||
|
public static function createInstallment(/** @noinspection PhpUnusedParameterInspection */
|
||||||
|
$ticket, $type, $customer, $contract, $money, $ticketCreated, $index){
|
||||||
$request = new TicketInstallmentRequest();
|
$request = new TicketInstallmentRequest();
|
||||||
// $request->id_ticket = $ticket->id_ticket;
|
// $request->id_ticket = $ticket->id_ticket;
|
||||||
$request->id_customer = $customer->id_customer;
|
$request->id_customer = $customer->id_customer;
|
||||||
$request->status = TicketInstallmentRequest::$STATUS_PENDING;
|
$request->status = TicketInstallmentRequest::$STATUS_PENDING;
|
||||||
$request->priority = $index;
|
$request->priority = $index;
|
||||||
$date = \DateTime::createFromFormat("Y.m.d", $contract->started_at, new \DateTimeZone( 'UTC'));
|
$date = \DateTime::createFromFormat("Y.m.d", $contract->started_at, new \DateTimeZone( 'UTC'));
|
||||||
$date->modify("+$index month");
|
$date = DateUtil::addMonth($date->getTimestamp(),$index);
|
||||||
|
// $date->modify("+$index month");
|
||||||
$date->setTime(0, 0, 0);
|
$date->setTime(0, 0, 0);
|
||||||
$request->request_target_time_at = $date->format ( 'Y-m-d H:i:s' );
|
$request->request_target_time_at = $date->format ( 'Y-m-d H:i:s' );
|
||||||
$request->request_processed_at = null;
|
$request->request_processed_at = null;
|
||||||
|
|||||||
74
console/controllers/InventoryConsoleController.php
Normal file
74
console/controllers/InventoryConsoleController.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
namespace console\controllers;
|
||||||
|
|
||||||
|
use common\models\Inventory;
|
||||||
|
use common\models\InventoryItem;
|
||||||
|
use common\models\Product;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use yii\console\Controller;
|
||||||
|
use yii\db\Expression;
|
||||||
|
use yii\db\Query;
|
||||||
|
|
||||||
|
|
||||||
|
class InventoryConsoleController extends Controller{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idInventory
|
||||||
|
*/
|
||||||
|
public function actionFixSold($idInventory){
|
||||||
|
|
||||||
|
$inventory = Inventory::findOne($idInventory);
|
||||||
|
|
||||||
|
|
||||||
|
/** @var /common/models/InventoryItem[] $items */
|
||||||
|
$items = InventoryItem::find()->andWhere(['id_inventory' => $inventory->id_inventory])->all();
|
||||||
|
|
||||||
|
/** @var /common/models/InventoryItem $item */
|
||||||
|
foreach ($items as $item ){
|
||||||
|
|
||||||
|
$prev = $item->inventoryItemPrev;
|
||||||
|
|
||||||
|
if ( !isset($prev)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$start = $prev->created_at;
|
||||||
|
$end = $item->created_at;
|
||||||
|
|
||||||
|
|
||||||
|
$query = new Query();
|
||||||
|
$query->select([
|
||||||
|
new Expression(" coalesce( sum( transfer.count ),0)")
|
||||||
|
]);
|
||||||
|
$query->from('transfer');
|
||||||
|
$query->innerJoin('sale','sale.id_sale = transfer.id_object');
|
||||||
|
$query->innerJoin('product','sale.id_product = product.id_product');
|
||||||
|
|
||||||
|
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||||
|
$query->andWhere(['in', 'transfer.status', [Transfer::STATUS_NOT_PAID, Transfer::STATUS_PAID]]);
|
||||||
|
$query->andWhere(['product.id_product' => $prev->id_product]);
|
||||||
|
|
||||||
|
$query->andWhere([ '>','transfer.created_at',$start ]);
|
||||||
|
$query->andWhere([ '<','transfer.created_at',$end ]);
|
||||||
|
|
||||||
|
$products = $query->scalar();
|
||||||
|
|
||||||
|
$item->count_sold = $products;
|
||||||
|
|
||||||
|
$item->recalculateTotalPriceBrutto();
|
||||||
|
|
||||||
|
echo $item->price_brutto . " - ". $item->productName ."\n";
|
||||||
|
|
||||||
|
$item->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -228,20 +228,20 @@ function TicketSell(o){
|
|||||||
units = app.defaults.ticket_type.time_unit_count;
|
units = app.defaults.ticket_type.time_unit_count;
|
||||||
app.defaults.end_date = moment(app.defaults.start_date);
|
app.defaults.end_date = moment(app.defaults.start_date);
|
||||||
switch(app.defaults.ticket_type.time_unit_type){
|
switch(app.defaults.ticket_type.time_unit_type){
|
||||||
case app.defaults.time_unit_day:
|
case app.defaults.time_unit_day:
|
||||||
app.defaults.end_date.add( units, 'days');
|
app.defaults.end_date.add( units, 'days');
|
||||||
app.defaults.end_date.subtract( 1, 'days');
|
app.defaults.end_date.subtract( 1, 'days');
|
||||||
break;
|
break;
|
||||||
case app.defaults.time_unit_month:
|
case app.defaults.time_unit_month:
|
||||||
app.defaults.end_date.add( units, 'month');
|
app.defaults.end_date.add( units, 'month');
|
||||||
app.defaults.end_date.subtract( 1, 'days');
|
app.defaults.end_date.subtract( 1, 'days');
|
||||||
break;
|
break;
|
||||||
case app.defaults.time_unit_month_reference:
|
case app.defaults.time_unit_month_reference:
|
||||||
if ( units > 1){
|
if ( units > 1){
|
||||||
app.defaults.end_date.add( units -1, 'month');
|
app.defaults.end_date.add( units -1, 'month');
|
||||||
}
|
}
|
||||||
app.defaults.end_date.endOf('month');
|
app.defaults.end_date.endOf('month');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user