add inventory admin fix, add procurement update

This commit is contained in:
Roland Schneider 2016-03-30 20:04:49 +02:00
parent 19761cb0cc
commit a12b87d3be
22 changed files with 853 additions and 245 deletions

View File

@ -11,6 +11,8 @@ use yii\filters\VerbFilter;
use common\models\User; use common\models\User;
use yii\db\Query; use yii\db\Query;
use backend\models\InventoryItemSearch; use backend\models\InventoryItemSearch;
use common\models\InventoryItem;
use common\components\Helper;
/** /**
* InventoryController implements the CRUD actions for Inventory model. * InventoryController implements the CRUD actions for Inventory model.
@ -23,7 +25,7 @@ class InventoryController extends Controller
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::className(),
'actions' => [ 'actions' => [
'delete' => ['post'], 'close' => ['post'],
], ],
], ],
]; ];
@ -55,12 +57,13 @@ class InventoryController extends Controller
$model = new Inventory(); $model = new Inventory();
$user = User::findOne(\Yii::$app->user->id); $user = User::findOne(\Yii::$app->user->id);
$model->status = Inventory::$STATUS_OPEN;
$model->name = 'Leltár_'.date('Ymd_His') .'_' . $user->username; $model->name = 'Leltár_'.date('Ymd_His') .'_' . $user->username;
$model->id_user = \Yii::$app->user->id; $model->id_user = \Yii::$app->user->id;
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_inventory]); return $this->redirect(['inventory-item/index', 'id' => $model->id_inventory]);
} else { } else {
} }
return $this->render('create', [ return $this->render('create', [
@ -69,6 +72,22 @@ class InventoryController extends Controller
} }
public function actionClose($id){
$model = $this->findModel($id);
$model->status = Inventory::$STATUS_CLOSED;
$model->save(false);
$db = \Yii::$app->db;
$command = $db->createCommand(InventoryItem::$UPDATE_COUNT,[':id_inventory' => $id]);
$command->execute();
Helper::flash("success", "Leltár lezárva, leltározott termékek darabszáma felülírva!");
return $this->redirect(['inventory-item/index','id' => $model->id_inventory]);
}
/** /**
* Finds the Inventory model based on its primary key value. * Finds the Inventory model based on its primary key value.

View File

@ -12,6 +12,7 @@ use backend\models\InventoryItemForm;
use common\models\Inventory; use common\models\Inventory;
use yii\helpers\Url; use yii\helpers\Url;
use common\models\Product; use common\models\Product;
use yii\web\NotAcceptableHttpException;
/** /**
* InventoryItemController implements the CRUD actions for InventoryItem model. * InventoryItemController implements the CRUD actions for InventoryItem model.
@ -177,7 +178,11 @@ class InventoryItemController extends Controller
{ {
$model = $this->findModel($id); $model = $this->findModel($id);
$inventory = Inventory::findOne($model->id_inventory); $inventory = Inventory::findOne($model->id_inventory);
if ( !$inventory->isOpen()){
throw new NotAcceptableHttpException("A leltár elem nem található");
}
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
$prev = Url::previous("inventory-item-index"); $prev = Url::previous("inventory-item-index");

View File

@ -14,6 +14,7 @@ use common\models\User;
use common\components\Helper; use common\components\Helper;
use common\models\Account; use common\models\Account;
use yii\helpers\Url; use yii\helpers\Url;
use backend\models\ProcurementUpdate;
/** /**
* ProcurementController implements the CRUD actions for Procurement model. * ProcurementController implements the CRUD actions for Procurement model.
@ -30,7 +31,7 @@ class ProcurementController extends \backend\controllers\BackendController
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[ [
'actions' => ['create','index','view', 'create-product'], 'actions' => ['create','index','view', 'create-product','update'],
'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
], ],
@ -79,11 +80,34 @@ class ProcurementController extends \backend\controllers\BackendController
*/ */
public function actionView($id) public function actionView($id)
{ {
return $this->render('view', [ return $this->render('view', [
'model' => $this->findModel($id), 'model' => $this->findModel($id),
]); ]);
} }
/**
* Update procurement
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = ProcurementUpdate::findOne($id);
if ( !isset($model)){
throw new NotFoundHttpException("Az oldal nem található");
}
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->save();
}
return $this->render('update', [
'model' => $model
]);
}
/** /**
* Creates a new Procurement model. * Creates a new Procurement model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.

View File

@ -62,9 +62,14 @@ class TransferController extends \backend\controllers\BackendController
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
echo "output:".$searchModel->output;
if ( $searchModel->output =='pdf'){
$this->downloadPaymentLater($dataProvider);
}
$accounts = Account::read(); $accounts = Account::read();
$users = User::read(); $users = User::read();
Url::remember("payment_later",Url::current()); Url::remember("payment_later",Url::current());
@ -76,6 +81,30 @@ class TransferController extends \backend\controllers\BackendController
'users' => $users, 'users' => $users,
]); ]);
} }
protected function downloadPaymentLater($dataProvider) {
// $mpdf = new \mPDF ( 'utf-8', 'A4' );
$mpdf = new \mPDF ( 'utf-8', 'A4-L' );
$fn = "utolagos_fizetesek.pdf";
$mpdf->useSubstitutions = false;
$mpdf->simpleTables = true;
$mpdf->SetHeader ( "" );
$mpdf->setFooter ( '{PAGENO} / {nb}' );
$stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css
$mpdf->WriteHTML ( $stylesheet, 1 );
$mpdf->WriteHTML ( $this->renderPartial ( '_pdf_payment_later.php', [
'dataProvider' => $dataProvider
] ) );
$mpdf->Output ( $fn, 'D' );
exit ();
}
/** /**
* Lists all Transfer models. * Lists all Transfer models.

View File

@ -11,200 +11,254 @@ use yii\filters\VerbFilter;
use common\components\DetStatProcessor; use common\components\DetStatProcessor;
use backend\models\DestaUploadForm; use backend\models\DestaUploadForm;
use yii\web\UploadedFile; use yii\web\UploadedFile;
use yii\data\ArrayDataProvider;
use yii\db\Query;
use yii\data\ActiveDataProvider;
/** /**
* UgiroController implements the CRUD actions for Ugiro model. * UgiroController implements the CRUD actions for Ugiro model.
* TODO: FIX ACCESS * TODO: FIX ACCESS
*/ */
class UgiroController extends Controller class UgiroController extends Controller {
{ public function behaviors() {
public function behaviors() return [
{ 'verbs' => [
return [ 'class' => VerbFilter::className (),
'verbs' => [ 'actions' => [
'class' => VerbFilter::className(), 'delete' => [
'actions' => [ 'post'
'delete' => ['post'], ]
], ]
], ],
'access' => [ 'access' => [
'class' => \yii\filters\AccessControl::className (), 'class' => \yii\filters\AccessControl::className (),
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[ [
'actions' => [], 'actions' => [ ],
'allow' => true, 'allow' => true,
'roles' => [ 'roles' => [
'admin', 'admin',
'employee', 'employee',
'reception' 'reception'
] ]
] ]
] ]
// everything else is denied ]
// everything else is denied
]
];
} ];
}
/**
* Lists all Ugiro models. /**
* @return mixed * Lists all Ugiro models.
*/ *
public function actionIndex() * @return mixed
{ */
$searchModel = new UgiroSearch(); public function actionIndex() {
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $searchModel = new UgiroSearch ();
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render('index', [
'searchModel' => $searchModel, return $this->render ( 'index', [
'dataProvider' => $dataProvider, 'searchModel' => $searchModel,
]); 'dataProvider' => $dataProvider
} ] );
/** }
* Lists all Ugiro models. /**
* @return mixed * Lists all Ugiro models.
*/ *
public function actionItems($id) * @return mixed
{ */
$searchModel = new UgiroSearch(); public function actionItems($id) {
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $searchModel = new UgiroSearch ();
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render('index', [
'searchModel' => $searchModel, return $this->render ( 'index', [
'dataProvider' => $dataProvider, 'searchModel' => $searchModel,
]); 'dataProvider' => $dataProvider
} ] );
}
public function actionActivate(){ public function actionActivate() {
}
}
/**
/** * Displays a single Ugiro model.
* Displays a single Ugiro model. *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionView($id) public function actionView($id) {
{ $model = $this->findModel ( $id );
$model = $this->findModel($id); if (Yii::$app->request->isPost) {
if (Yii::$app->request->isPost) { if ($model->status == Ugiro::$STATUS_RECIEVED) {
if ($model->status == Ugiro::$STATUS_RECIEVED){ set_time_limit ( 1200 ); // 20 perc
set_time_limit(1200);//20 perc $processor = new DetStatProcessor ( [
$processor = new DetStatProcessor( 'koteg' => $model
['koteg' => $model] ] );
); $processor->run ();
$processor->run(); } else {
}else{ \Yii::$app->session->setFlash ( 'danger', 'Nem lehet futtatni a fájlt' );
\Yii::$app->session->setFlash('danger','Nem lehet futtatni a fájlt'); \Yii::error ( "a koteg státusza nem STATUS_RECIEVED. A koteg azonosíótja:" . $model->id_ugiro );
\Yii::error("a koteg státusza nem STATUS_RECIEVED. A koteg azonosíótja:" . $model->id_ugiro ); }
} } else {
} if (isset ( $_GET ['output'] )) {
$output = $_GET ['output'];
return $this->render('view', [
'model' => $this->findModel($id), if ($output == 'pdf') {
]); $this->downloadUgiro ( $model );
} }
}
/** }
* Creates a new Ugiro model.
* If creation is successful, the browser will be redirected to the 'view' page. return $this->render ( 'view', [
* @return mixed 'model' => $this->findModel ( $id )
*/ ] );
public function actionCreate() }
{ protected function downloadUgiro($model) {
$model = new Ugiro();
// $mpdf = new \mPDF ( 'utf-8', 'A4' );
if ($model->load(Yii::$app->request->post()) && $model->save()) { $mpdf = new \mPDF ( 'utf-8', 'A4-L' );
return $this->redirect(['view', 'id' => $model->id_ugiro]); $fn = "köteg.". $model->id_ugiro . ".pdf";
} else {
return $this->render('create', [ $mpdf->useSubstitutions = false;
'model' => $model, $mpdf->simpleTables = true;
]); $mpdf->SetHeader ( "" );
} $mpdf->setFooter ( '{PAGENO} / {nb}' );
}
$query = new Query();
/** $query->select([
* Updates an existing Ugiro model. 'customer.id_customer as customer_id_customer',
* If update is successful, the browser will be redirected to the 'view' page. 'customer.name as customer_name',
* @param integer $id 'customer.bank_account as customer_bank_account',
* @return mixed 'ticket_installment_request.money as request_money',
*/ 'ticket_installment_request.request_target_time_at as request_request_target_time_at',
public function actionUpdate($id) ]);
{ $query->from('ticket_installment_request');
$model = $this->findModel($id); $query->innerJoin('ugiro_request_assignment','ticket_installment_request.id_ticket_installment_request = ugiro_request_assignment.id_request');
$query->innerJoin('customer','customer.id_customer = ticket_installment_request.id_customer');
if ($model->load(Yii::$app->request->post()) && $model->save()) { $query->andWhere(['ugiro_request_assignment.id_ugiro' => $model->id_ugiro]);
return $this->redirect(['view', 'id' => $model->id_ugiro]); $dataProvider = new ActiveDataProvider(
} else { [
return $this->render('update', [ 'query' => $query,
'model' => $model, 'sort' => false,
]); 'pagination' => false
} ]
} );
/** $stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css
* Deletes an existing Ugiro model. $mpdf->WriteHTML ( $stylesheet, 1 );
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id $mpdf->WriteHTML ( $this->renderPartial ( '_view_pdf.php', [
* @return mixed 'model' => $model,
*/ 'dataProvider' => $dataProvider
public function actionDelete($id) ] ) );
{ $mpdf->Output ( $fn, 'D' );
$this->findModel($id)->delete(); exit ();
return $this->redirect(['index']); }
}
/**
public function actionDetsta(){ * Creates a new Ugiro model.
* If creation is successful, the browser will be redirected to the 'view' page.
$ugiro = Ugiro::findOne(31); *
$model = new DetStatProcessor( * @return mixed
['koteg' => $ugiro] */
); public function actionCreate() {
$model = new Ugiro ();
return $this->render('detsta', [ if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
'model' => $model, return $this->redirect ( [
]); 'view',
} 'id' => $model->id_ugiro
] );
public function actionUpload(){ } else {
$model = new DestaUploadForm(); return $this->render ( 'create', [
'model' => $model
if (Yii::$app->request->isPost) { ] );
$model->destaFile = UploadedFile::getInstance($model, 'destaFile'); }
if ($model->upload()) { }
// file is uploaded successfully
return $this->redirect(['view', 'id' => $model->koteg->id_ugiro]); /**
} * Updates an existing Ugiro model.
} * If update is successful, the browser will be redirected to the 'view' page.
*
return $this->render('upload', ['model' => $model]); * @param integer $id
* @return mixed
} */
public function actionUpdate($id) {
$model = $this->findModel ( $id );
public function actionGenerateDetsta(){
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [
'view',
} 'id' => $model->id_ugiro
] );
} else {
/** return $this->render ( 'update', [
* Finds the Ugiro model based on its primary key value. 'model' => $model
* If the model is not found, a 404 HTTP exception will be thrown. ] );
* @param integer $id }
* @return Ugiro the loaded model }
* @throws NotFoundHttpException if the model cannot be found
*/ /**
protected function findModel($id) * Deletes an existing Ugiro model.
{ * If deletion is successful, the browser will be redirected to the 'index' page.
if (($model = Ugiro::findOne($id)) !== null) { *
return $model; * @param integer $id
} else { * @return mixed
throw new NotFoundHttpException('The requested page does not exist.'); */
} public function actionDelete($id) {
} $this->findModel ( $id )->delete ();
return $this->redirect ( [
'index'
] );
}
public function actionDetsta() {
$ugiro = Ugiro::findOne ( 31 );
$model = new DetStatProcessor ( [
'koteg' => $ugiro
] );
return $this->render ( 'detsta', [
'model' => $model
] );
}
public function actionUpload() {
$model = new DestaUploadForm ();
if (Yii::$app->request->isPost) {
$model->destaFile = UploadedFile::getInstance ( $model, 'destaFile' );
if ($model->upload ()) {
// file is uploaded successfully
return $this->redirect ( [
'view',
'id' => $model->koteg->id_ugiro
] );
}
}
return $this->render ( 'upload', [
'model' => $model
] );
}
public function actionGenerateDetsta() {
}
/**
* Finds the Ugiro model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @param integer $id
* @return Ugiro the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = Ugiro::findOne ( $id )) !== null) {
return $model;
} else {
throw new NotFoundHttpException ( 'The requested page does not exist.' );
}
}
} }

View File

@ -119,9 +119,11 @@ class InventoryItemForm extends Model{
$item->id_user = \Yii::$app->user->id; $item->id_user = \Yii::$app->user->id;
if ( $this->type == 'product'){ if ( $this->type == 'product'){
$item->type = InventoryItem::$TYPE_PRODUCT;
$item->id_product = $this->product->id_product; $item->id_product = $this->product->id_product;
}else{ }else{
$item->id_inventory_group = $this->inventoryGroup->id_inventory_group; $item->id_inventory_group = $this->inventoryGroup->id_inventory_group;
$item->type = InventoryItem::$TYPE_INVENTORY_GROUP;
} }
$item->id_inventory = $this->inventory->id_inventory; $item->id_inventory = $this->inventory->id_inventory;

View File

@ -0,0 +1,49 @@
<?php
namespace backend\models;
use common\models\Procurement;
use common\models\Product;
use yii\helpers\VarDumper;
use common\models\Log;
class ProcurementUpdate extends Procurement{
private $oldCount;
public function rules( ) {
return [
[ ['count', 'purchase_price' ], 'integer'],
[ ['count', 'purchase_price' ], 'required'],
];
}
public function beforeSave($insert){
if ( !$insert ){
$changed = $this->getOldAttribute('count');
// VarDumper::dump($changed);
// VarDumper::dump($this->getDirtyAttributes(['count']));
$this->oldCount = $this->getOldAttribute('count');
}
return true;
}
public function afterSave($insert, $changedAttributes){
$product = Product::findOne($this->id_product);
$product->stock = $product->stock - $this->oldCount + $this->count;
$product->save(false);
Log::log([
'id_product' => $this->product->id_product,
'type' =>Log::$TYPE_PROCUREMENT_UPDATE,
'message' => "Beszerzés(#".$this->id_procurement.") módosítva. Beszerzett mennyiség: " . $this->oldCount . " > " .$this->count,
]);
}
}

View File

@ -33,12 +33,15 @@ class TransferLaterSearch extends Transfer
public $total_money; public $total_money;
public $output;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() public function rules()
{ {
return [ return [
[['output' ] ,'safe'],
[[ 'id_ticket_type','id_user'], 'integer'], [[ 'id_ticket_type','id_user'], 'integer'],
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], [[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], [[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
@ -72,11 +75,13 @@ class TransferLaterSearch extends Transfer
'transfer.money as transfer_money', 'transfer.money as transfer_money',
'transfer.status as transfer_status', 'transfer.status as transfer_status',
'user.username as user_username', 'user.username as user_username',
'customer.id_customer as customer_id_customer',
'customer.name as customer_name', 'customer.name as customer_name',
'ticket_type.name as ticket_type_name', 'ticket_type.name as ticket_type_name',
'product.name as product_name', 'product.name as product_name',
'ticket.start as ticket_start', 'ticket.start as ticket_start',
'ticket.end as ticket_end', 'ticket.end as ticket_end',
'ticket.comment as ticket_comment',
]); ]);
$query->from("transfer"); $query->from("transfer");
$query->innerJoin('user', " user.id = transfer.id_user"); $query->innerJoin('user', " user.id = transfer.id_user");
@ -89,10 +94,15 @@ class TransferLaterSearch extends Transfer
$query->andWhere(["transfer.payment_method" => Transfer::PAYMENT_METHOD_TRANSFER_LATER ]); $query->andWhere(["transfer.payment_method" => Transfer::PAYMENT_METHOD_TRANSFER_LATER ]);
$query->andWhere(['transfer.status' => Transfer::STATUS_NOT_PAID]); $query->andWhere(['transfer.status' => Transfer::STATUS_NOT_PAID]);
$this->load($params);
$valid = $this->validate();
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,
'sort' =>[ 'pagination' => $this->output == 'pdf' ? false : [],
'sort' => [
'defaultOrder' =>[ 'defaultOrder' =>[
'transfer_created_at' => SORT_DESC 'transfer_created_at' => SORT_DESC
], ],
@ -106,22 +116,18 @@ class TransferLaterSearch extends Transfer
['product_name'], ['product_name'],
['ticket_start'], ['ticket_start'],
['ticket_end'], ['ticket_end'],
['ticket_comment'],
]) ])
] ]
]); ]);
// $query->addSelect( ['*' ]); if (!$valid) {
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails // uncomment the following line if you do not want to return any records when validation fails
$query->where('0=1'); $query->where('0=1');
return $dataProvider; return $dataProvider;
} }
$query->andFilterWhere([ $query->andFilterWhere([

View File

@ -33,14 +33,24 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'name', 'name',
['attribute'=>'id_user', ['attribute'=>'id_user',
'value'=>$model->userName 'value'=>$model->userName
], ],
['attribute'=>'id_account', ['attribute'=>'id_account',
'value'=>$model->accountName 'value'=>$model->accountName
], ],
['attribute'=>'status',
'value'=>$model->getStatusHuman(),
'label' => "Állapot"
],
'created_at:datetime', 'created_at:datetime',
], ],
]) ?> ]) ?>
<?php
if ( $model->isOpen()){
echo Html::a("Lezárás",['inventory/close' , 'id' => $model->id_inventory ] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
}
?>
<?php echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo $this->render('_search', ['model' => $searchModel]); ?>
@ -74,9 +84,8 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
</p> </p>
<?php <?php
echo GridView::widget( [
'dataProvider' => $dataProvider, $columns = [
'columns' =>[
[ [
'attribute' => 'item_created_at', 'attribute' => 'item_created_at',
'label' => 'Létrehozva', 'label' => 'Létrehozva',
@ -96,6 +105,16 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'attribute' => 'inventory_prev_name', 'attribute' => 'inventory_prev_name',
'label' => 'Utolsó leltár' 'label' => 'Utolsó leltár'
],
[
'attribute' => 'item_count_system',
'label' => 'Rendszer szerinti mennyiség (db)',
],
[
'attribute' => 'item_count',
'label' => 'Leltározott mennyiség (db)',
], ],
[ [
'attribute' => 'item_count_prev', 'attribute' => 'item_count_prev',
@ -111,24 +130,20 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'attribute' => 'item_count_sold', 'attribute' => 'item_count_sold',
'label' => 'Eladott mennyiség (db)', 'label' => 'Eladott mennyiség (db)',
],
[
'attribute' => 'item_count',
'label' => 'Leltározott mennyiség (db)',
],
[
'attribute' => 'item_count_system',
'label' => 'Rendszer szerinti mennyiség (db)',
], ],
[ [
'attribute' => 'item_difference', 'attribute' => 'item_difference',
'label' => 'Különbség (db)', 'label' => 'Különbség (db)',
], ],
['class' => 'yii\grid\ActionColumn',
'template' => '',
];
if ( $model->isOpen() ){
$columns[] = ['class' => 'yii\grid\ActionColumn',
'template' => '{update}',
'urlCreator' => function ($action, $model, $key, $index){ 'urlCreator' => function ($action, $model, $key, $index){
return Url::to(['inventory-item/update', 'id' => $model['item_id_inventory_item' ] ]) ; return Url::to(['inventory-item/update', 'id' => $model['item_id_inventory_item' ] ]) ;
}, },
@ -141,8 +156,14 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
} }
] ]
] ] ;
] }
echo GridView::widget( [
'dataProvider' => $dataProvider,
'columns' => $columns
]); ]);
?> ?>

View File

@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p> <p>
<?php //echo Html::a(Yii::t('common/inventory', 'Új leltár'), ['create'], ['class' => 'btn btn-success']) ?> <?php echo Html::a(Yii::t('common/inventory', 'Új leltár'), ['create'], ['class' => 'btn btn-success']) ?>
</p> </p>
<?= GridView::widget([ <?= GridView::widget([
@ -28,6 +28,7 @@ $this->params['breadcrumbs'][] = $this->title;
'name', 'name',
[ 'attribute' => 'id_user', "value" =>"userName" ], [ 'attribute' => 'id_user', "value" =>"userName" ],
'created_at:datetime', 'created_at:datetime',
[ 'attribute' => 'status', "value" =>"statusHuman" ],
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
'template' => '{view}', 'template' => '{view}',

View File

@ -0,0 +1,34 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model common\models\Procurement */
/* @var $warehouses common\models\Warehouse[] */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
?>
<div class="procurement-form">
<?php $form = ActiveForm::begin(); ?>
<?php // echo $form->field($model, 'id_account')->dropDownList($accountsOptions)->label('Kassza') ?>
<?= $form->field($model, 'count')->textInput() ?>
<?= $form->field($model, 'purchase_price')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/procurement', 'Create') : Yii::t('common/procurement', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -48,7 +48,15 @@ $this->params['breadcrumbs'][] = $this->title;
[ [
'class' => 'yii\grid\ActionColumn', 'class' => 'yii\grid\ActionColumn',
'template' => '{view}', 'template' => '{view} {update}',
'buttons' => [
'update' => function ($url, $model, $key) {
return Html::a('Módosít',$url, ['class' =>'btn btn-xs btn-primary' ]);
},
'view' => function ($url, $model, $key) {
return Html::a('Részletek',$url, ['class' =>'btn btn-xs btn-primary' ]);
}
]
], ],
], ],
]); ?> ]); ?>

View File

@ -1,13 +1,12 @@
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Procurement */ /* @var $model common\models\Procurement */
$this->title = Yii::t('common/procurement', 'Update {modelClass}: ', [ $this->title = Yii::t('common/procurement', 'Beszerzés módosítása' );
'modelClass' => 'Procurement',
]) . ' ' . $model->id_procurement;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/procurement', 'Procurements'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('common/procurement', 'Procurements'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_procurement, 'url' => ['view', 'id' => $model->id_procurement]]; $this->params['breadcrumbs'][] = ['label' => $model->id_procurement, 'url' => ['view', 'id' => $model->id_procurement]];
$this->params['breadcrumbs'][] = Yii::t('common/procurement', 'Update'); $this->params['breadcrumbs'][] = Yii::t('common/procurement', 'Update');
@ -15,8 +14,40 @@ $this->params['breadcrumbs'][] = Yii::t('common/procurement', 'Update');
<div class="procurement-update"> <div class="procurement-update">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_procurement',
[
'attribute' => 'id_warehouse',
'value' => $model->warehouseName,
],
[
'attribute' => 'id_user',
'value' => $model->userName,
],
[
'attribute' => 'id_product',
'value' => $model->productName,
],
'count',
'stock',
'purchase_price',
[
'attribute' => 'description',
'value' => nl2br($model->description),
'format' => 'raw'
],
'created_at:datetime',
],
]) ?>
<?= $this->render('_form', [ <?= $this->render('_form_update', [
'model' => $model, 'model' => $model,
]) ?> ]) ?>

View File

@ -0,0 +1,112 @@
<?php
use yii\grid\GridView;
use common\components\Helper;
use common\models\Transfer;
?>
<?php
?>
<style>
.table td,.table th{
padding: 2px;
}
.table th{
text-align: center;
}
.table td.transfer_id_transfer{
width: 70px;
}
.table td.transfer_created_at{
width: 120px;
}
.table td.ticket_comment{
width: 150px;
}
.table td.customer_name{
/*width: 150px;*/
}
.table td.transfer_status{
width: 120px;
}
.table td.transfer_money{
width: 70px;
text-align: right;
}
</style>
<h2>Fizetendő tételek</h2>
<?= GridView::widget([
'tableOptions' => ['class' => 'table table-striped table-bordered table-transfer'],
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'transfer_id_transfer',
'label' => 'T.',
'enableSorting' => false,
'contentOptions' => ['class' => 'transfer_id_transfer'],
],
[
'attribute' => 'transfer_created_at',
'label' => 'Kiadva',
'format' => 'datetime',
'enableSorting' => false,
'contentOptions' => ['class' => 'transfer_created_at'],
],
/*
[
'attribute' => 'user_username',
'label' => 'Felhasználó',
'enableSorting' => false,
'contentOptions' => ['class' => 'user_username'],
],
*/
[
'attribute' => 'customer_name',
'label' => 'Vendég',
'enableSorting' => false,
'contentOptions' => ['class' => 'customer_name'],
],
[
'attribute' => 'ticket_start',
'label' => 'Bérlet',
// 'format' => 'date',
'enableSorting' => false,
'contentOptions' => ['class' => 'ticket_start'],
'value' => function ($model, $key, $index, $column){
$type = $model['ticket_type_name'];
$start = \Yii::$app->formatter->asDate($model['ticket_start']);
$end = \Yii::$app->formatter->asDate($model['ticket_end']);
return $type. " (" .$start . " - " .$end . ")";
//return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],'');
},
],
[
'attribute' => 'transfer_money',
'label' => 'Összeg',
'enableSorting' => false,
'contentOptions' => ['class' => 'transfer_money'],
],
/*[
'attribute' => 'transfer_status',
'enableSorting' => false,
'label' => 'Státusz',
'contentOptions' => ['class' => 'transfer_status'],
'value' => function ($model, $key, $index, $column){
return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],'');
},
],
*/
[
'attribute' => 'ticket_comment',
'label' => 'Megjegyzés',
'enableSorting' => false,
'contentOptions' => ['class' => 'ticket_comment'],
],
],
]); ?>

View File

@ -36,6 +36,11 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search_payment_later', ['model' => $searchModel, ]); ?> <?php echo $this->render('_search_payment_later', ['model' => $searchModel, ]); ?>
<div style="margin-bottom: 6px;">
<?php
echo Html::a("PDF",Url::current(['TransferLaterSearch[output]'=>'pdf']), ['class' => 'btn btn-primary' ]);
?>
</div>
<div style="margin-bottom: 6px;"> <div style="margin-bottom: 6px;">
<?php <?php
@ -108,12 +113,16 @@ echo Html::a("Egyiket sem",null, ['class' => 'btn btn-primary deselect-all',
'label' => 'Összeg' 'label' => 'Összeg'
], ],
[ [
'attribute' => 'transfer_status', 'attribute' => 'transfer_status',
'label' => 'Státusz', 'label' => 'Státusz',
'value' => function ($model, $key, $index, $column){ 'value' => function ($model, $key, $index, $column){
return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],''); return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],'');
}, },
], ],
[
'attribute' => 'ticket_comment',
'label' => 'Megjegyzés'
],
], ],
]); ?> ]); ?>

View File

@ -0,0 +1,128 @@
<?php
use yii\widgets\DetailView;
use yii\grid\GridView;
?>
<style>
.table td, .table th{
padding: 3px;
}
.table-request thead th{
text-align: center;
}
.table tbody td.id_customer{
width: 100px;
}
.table tbody td.money{
width: 80px;
text-align: right;
}
.table tbody td.customer_bank_account{
width: 240px;
}
.table tbody td.request_request_target_time_at{
width: 130px;
}
.table-ugiro th{
width: 230px;
}
.table tbody td.comment{
width: 100px;
}
</style>
<?php
$attributes = [
[
'attribute' => 'id_ugiro',
'label' => 'Köteg azonosító',
],
[
'attribute' => 'datum',
'label' => 'Üzenet összeállítási dátum'
],
[
'attribute' => 'user.username',
'label' => 'Felhasználó'
],
[
'attribute' => 'statusName',
'label' => 'Státusz'
],
[
'attribute' => 'created_at',
'label' => 'Létrehozva',
'format' =>'datetime'
],
];
?>
<h1>Csoportos beszedés</h1>
<?= DetailView::widget([
'options' => ['class' => 'table table-striped table-bordered detail-view table-ugiro'],
'model' => $model,
'attributes' => $attributes,
]) ?>
<?php
/*
* customer.id_customer as customer_id_customer',
'customer.name as customer_name',
'customer.bank_account as customer_bank_account',
'ticket_installment_request.money as request_money',
'ticket_installment_request.request_target_time_at as request_request_target_time_at',
* **/
echo GridView::widget([
'tableOptions' => ['class' => 'table table-striped table-bordered table-request'],
'dataProvider' => $dataProvider,
'emptyCell' => '',
'columns' =>[
[
'attribute' => 'customer_id_customer' ,
'label' => 'Vendég azonosító',
'contentOptions' =>['class' => 'id_customer' ]
],
[
'attribute' => 'customer_name' ,
'label' => 'Vendég neve'
],
[
'attribute' => 'customer_bank_account' ,
'label' => 'Bankszámlaszám',
'contentOptions' =>['class' => 'customer_bank_account' ]
],
[
'attribute' => 'request_money' ,
'label' => 'Összeg',
'contentOptions' =>['class' => 'money' ]
],
[
'attribute' => 'request_request_target_time_at' ,
'label' => 'Esedékességi dátum',
'format' => 'datetime',
'contentOptions' =>['class' => 'request_request_target_time_at' ]
],
[
'value' => function (){
return "";
},
'label' => 'Megjegyzés',
'contentOptions' =>['class' => 'comment' ]
]
]
]);
?>

View File

@ -87,6 +87,7 @@ $attributes = [
echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']); echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
} }
echo Html::a("Megbízások a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->id_ugiro] ,[ 'class' => 'btn btn-primary']); echo Html::a("Megbízások a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->id_ugiro] ,[ 'class' => 'btn btn-primary']);
echo Html::a("PDF", Url::current(['output' => 'pdf']) ,[ 'class' => 'btn btn-primary']);
$detstaMessage = $model->messageDetsta; $detstaMessage = $model->messageDetsta;
if ( isset($detstaMessage)){ if ( isset($detstaMessage)){

View File

@ -8,6 +8,7 @@ use yii\helpers\ArrayHelper;
use yii\db\Query; use yii\db\Query;
use backend\models\InventoryItemForm; use backend\models\InventoryItemForm;
use common\components\AccountAwareBehavior; use common\components\AccountAwareBehavior;
use common\components\Helper;
/** /**
* This is the model class for table "inventory". * This is the model class for table "inventory".
@ -15,6 +16,7 @@ use common\components\AccountAwareBehavior;
* @property integer $id_inventory * @property integer $id_inventory
* @property integer $id_user * @property integer $id_user
* @property integer $id_account * @property integer $id_account
* @property integer $status
* @property string $name * @property string $name
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at
@ -22,6 +24,9 @@ use common\components\AccountAwareBehavior;
class Inventory extends \common\models\BaseFitnessActiveRecord class Inventory extends \common\models\BaseFitnessActiveRecord
{ {
public static $STATUS_OPEN = 10;
public static $STATUS_CLOSED = 20;
/** /**
* @inheritdoc * @inheritdoc
@ -40,6 +45,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return [ return [
[['name'], 'string'], [['name'], 'string'],
[['id_account'], 'integer'], [['id_account'], 'integer'],
[['name'], 'validateOnlyClosed'],
]; ];
} }
@ -51,6 +57,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return [ return [
'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'), 'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'),
'name' => Yii::t('common/inventory', 'Megnevezés'), 'name' => Yii::t('common/inventory', 'Megnevezés'),
'status' => Yii::t('common/inventory', 'Státusz'),
'id_user' => Yii::t('common/inventory', 'Felhasználó'), 'id_user' => Yii::t('common/inventory', 'Felhasználó'),
'id_account' => Yii::t('common/inventory', 'Kassza'), 'id_account' => Yii::t('common/inventory', 'Kassza'),
'created_at' => Yii::t('common/inventory', 'Létrehozás'), 'created_at' => Yii::t('common/inventory', 'Létrehozás'),
@ -58,6 +65,14 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
]; ];
} }
public function validateOnlyClosed($attribute,$params){
$opened = Inventory::find()->andWhere(['status' => Inventory::$STATUS_OPEN])->all();
if ( count($opened) > 0 ){
$this->addError("name","Kérem előbb zárjon le minden másik leltárt");
}
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
@ -85,7 +100,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
// $query->andWhere("product.id_inventory_group is null"); // $query->andWhere("product.id_inventory_group is null");
$products = $query->all(); $products = $query->all();
echo "Products found: " . count($products); //echo "Products found: " . count($products);
$inventoryGroups = InventoryGroup::find()->all(); $inventoryGroups = InventoryGroup::find()->all();
@ -120,5 +135,20 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
} }
public static function statuses(){
return [
Inventory::$STATUS_CLOSED => "Lezárva",
Inventory::$STATUS_OPEN => "Nyitva"
];
}
public function getStatusHuman(){
return Helper::getArrayValue(self::statuses(), $this->status, "NA");
}
public function isOpen(){
return $this->status == self::$STATUS_OPEN;
}
} }

View File

@ -32,6 +32,21 @@ class InventoryItem extends BaseFitnessActiveRecord
public static $TYPE_PRODUCT = 10; public static $TYPE_PRODUCT = 10;
public static $TYPE_INVENTORY_GROUP = 20; public static $TYPE_INVENTORY_GROUP = 20;
public static $UPDATE_COUNT = "
UPDATE product as p1
inner JOIN ( select inventory_item.id_product as id_product , inventory_item.count as count
from inventory_item
where inventory_item.type = 10
and inventory_item.id_inventory = :id_inventory
and inventory_item.count is not null
) as t
on t.id_product = p1.id_product
SET p1.stock = case when t.id_product is null then ( p1.stock ) else ( t.count ) end
";
/** /**
* @inheritdoc * @inheritdoc
*/ */
@ -142,14 +157,14 @@ class InventoryItem extends BaseFitnessActiveRecord
public function afterSave($insert, $changedAttributes){ public function afterSave($insert, $changedAttributes){
if ( !$insert ){ if ( !$insert ){
if ( $this->type == 'product'){ // if ( $this->type == 'product'){
$product = $this->product; // $product = $this->product;
$product->stock = $this->count; // $product->stock = $this->count;
if ( !$product->save(false) ){ // if ( !$product->save(false) ){
\Yii::error("Failed to save product stock"); // \Yii::error("Failed to save product stock");
throw new \Exception("A leltár elem mentése nem sikerült"); // throw new \Exception("A leltár elem mentése nem sikerült");
} // }
} // }
} }
} }

View File

@ -39,6 +39,7 @@ class Log extends BaseFitnessActiveRecord
public static $TYPE_LOGIN = 50; public static $TYPE_LOGIN = 50;
public static $TYPE_DEFAULT_ACCOUNT= 60; public static $TYPE_DEFAULT_ACCOUNT= 60;
public static $TYPE_CREATE_CUSTOMER= 70; public static $TYPE_CREATE_CUSTOMER= 70;
public static $TYPE_PROCUREMENT_UPDATE = 80;
/** /**
* @inheritdoc * @inheritdoc
*/ */
@ -90,12 +91,11 @@ class Log extends BaseFitnessActiveRecord
self::log(['type' =>self::$TYPE_INFO, 'message' => $message]); self::log(['type' =>self::$TYPE_INFO, 'message' => $message]);
} }
public static function log( $config ){ public static function log( $config ){
\Yii::info( "Log :" . VarDumper::dump( $config) ) ;
$model = new Log($config); $model = new Log($config);
$model->app = \Yii::$app->name; $model->app = \Yii::$app->name;
$model->url = Url::canonical(); $model->url = Url::canonical();
$model->id_user = \Yii::$app->user->id; $model->id_user = \Yii::$app->user->id;
$model->save(); $model->save(false);
} }
} }

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160329_195454_add_inventory_status extends Migration
{
public function up()
{
$this->addColumn("inventory", "status", "int");
}
public function down()
{
echo "m160329_195454_add_inventory_status cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -89,7 +89,7 @@ class FrontendMenuStructure{
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ]; $items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ]; // $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
$items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ]; // $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ];
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'), $this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),