From a12b87d3bea32ce27b295394b06d733268548952 Mon Sep 17 00:00:00 2001
From: Roland Schneider
Date: Wed, 30 Mar 2016 20:04:49 +0200
Subject: [PATCH 1/2] add inventory admin fix, add procurement update
---
backend/controllers/InventoryController.php | 25 +-
.../controllers/InventoryItemController.php | 7 +-
backend/controllers/ProcurementController.php | 26 +-
backend/controllers/TransferController.php | 33 +-
backend/controllers/UgiroController.php | 436 ++++++++++--------
backend/models/InventoryItemForm.php | 2 +
backend/models/ProcurementUpdate.php | 49 ++
backend/models/TransferLaterSearch.php | 22 +-
backend/views/inventory-item/index.php | 57 ++-
backend/views/inventory/index.php | 3 +-
backend/views/procurement/_form_update.php | 34 ++
backend/views/procurement/index.php | 10 +-
backend/views/procurement/update.php | 39 +-
backend/views/transfer/_pdf_payment_later.php | 112 +++++
backend/views/transfer/payment_later.php | 15 +-
backend/views/ugiro/_view_pdf.php | 128 +++++
backend/views/ugiro/view.php | 1 +
common/models/Inventory.php | 32 +-
common/models/InventoryItem.php | 31 +-
common/models/Log.php | 4 +-
.../m160329_195454_add_inventory_status.php | 30 ++
frontend/components/FrontendMenuStructure.php | 2 +-
22 files changed, 853 insertions(+), 245 deletions(-)
create mode 100644 backend/models/ProcurementUpdate.php
create mode 100644 backend/views/procurement/_form_update.php
create mode 100644 backend/views/transfer/_pdf_payment_later.php
create mode 100644 backend/views/ugiro/_view_pdf.php
create mode 100644 console/migrations/m160329_195454_add_inventory_status.php
diff --git a/backend/controllers/InventoryController.php b/backend/controllers/InventoryController.php
index 308384f..4b9712e 100644
--- a/backend/controllers/InventoryController.php
+++ b/backend/controllers/InventoryController.php
@@ -11,6 +11,8 @@ use yii\filters\VerbFilter;
use common\models\User;
use yii\db\Query;
use backend\models\InventoryItemSearch;
+use common\models\InventoryItem;
+use common\components\Helper;
/**
* InventoryController implements the CRUD actions for Inventory model.
@@ -23,7 +25,7 @@ class InventoryController extends Controller
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
- 'delete' => ['post'],
+ 'close' => ['post'],
],
],
];
@@ -55,12 +57,13 @@ class InventoryController extends Controller
$model = new Inventory();
$user = User::findOne(\Yii::$app->user->id);
-
+ $model->status = Inventory::$STATUS_OPEN;
+
$model->name = 'Leltár_'.date('Ymd_His') .'_' . $user->username;
$model->id_user = \Yii::$app->user->id;
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 {
}
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.
diff --git a/backend/controllers/InventoryItemController.php b/backend/controllers/InventoryItemController.php
index 1091b42..166c642 100644
--- a/backend/controllers/InventoryItemController.php
+++ b/backend/controllers/InventoryItemController.php
@@ -12,6 +12,7 @@ use backend\models\InventoryItemForm;
use common\models\Inventory;
use yii\helpers\Url;
use common\models\Product;
+use yii\web\NotAcceptableHttpException;
/**
* InventoryItemController implements the CRUD actions for InventoryItem model.
@@ -177,7 +178,11 @@ class InventoryItemController extends Controller
{
$model = $this->findModel($id);
$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()) {
$prev = Url::previous("inventory-item-index");
diff --git a/backend/controllers/ProcurementController.php b/backend/controllers/ProcurementController.php
index c6e07c2..62c4cb4 100644
--- a/backend/controllers/ProcurementController.php
+++ b/backend/controllers/ProcurementController.php
@@ -14,6 +14,7 @@ use common\models\User;
use common\components\Helper;
use common\models\Account;
use yii\helpers\Url;
+use backend\models\ProcurementUpdate;
/**
* ProcurementController implements the CRUD actions for Procurement model.
@@ -30,7 +31,7 @@ class ProcurementController extends \backend\controllers\BackendController
'rules' => [
// allow authenticated users
[
- 'actions' => ['create','index','view', 'create-product'],
+ 'actions' => ['create','index','view', 'create-product','update'],
'allow' => true,
'roles' => ['@'],
],
@@ -79,11 +80,34 @@ class ProcurementController extends \backend\controllers\BackendController
*/
public function actionView($id)
{
+
+
return $this->render('view', [
'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.
* If creation is successful, the browser will be redirected to the 'view' page.
diff --git a/backend/controllers/TransferController.php b/backend/controllers/TransferController.php
index 1ae6b34..0c7145f 100644
--- a/backend/controllers/TransferController.php
+++ b/backend/controllers/TransferController.php
@@ -62,9 +62,14 @@ class TransferController extends \backend\controllers\BackendController
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ echo "output:".$searchModel->output;
+
+ if ( $searchModel->output =='pdf'){
+ $this->downloadPaymentLater($dataProvider);
+ }
+
$accounts = Account::read();
-
-
$users = User::read();
Url::remember("payment_later",Url::current());
@@ -76,6 +81,30 @@ class TransferController extends \backend\controllers\BackendController
'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.
diff --git a/backend/controllers/UgiroController.php b/backend/controllers/UgiroController.php
index ce034ee..63869bd 100644
--- a/backend/controllers/UgiroController.php
+++ b/backend/controllers/UgiroController.php
@@ -11,200 +11,254 @@ use yii\filters\VerbFilter;
use common\components\DetStatProcessor;
use backend\models\DestaUploadForm;
use yii\web\UploadedFile;
+use yii\data\ArrayDataProvider;
+use yii\db\Query;
+use yii\data\ActiveDataProvider;
/**
* UgiroController implements the CRUD actions for Ugiro model.
* TODO: FIX ACCESS
*/
-class UgiroController extends Controller
-{
- public function behaviors()
- {
- return [
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['post'],
- ],
- ],
- 'access' => [
- 'class' => \yii\filters\AccessControl::className (),
- 'rules' => [
- // allow authenticated users
- [
- 'actions' => [],
- 'allow' => true,
- 'roles' => [
- 'admin',
- 'employee',
- 'reception'
- ]
- ]
- ]
- // everything else is denied
-
- ]
- ];
- }
-
- /**
- * Lists all Ugiro models.
- * @return mixed
- */
- public function actionIndex()
- {
- $searchModel = new UgiroSearch();
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
- /**
- * Lists all Ugiro models.
- * @return mixed
- */
- public function actionItems($id)
- {
- $searchModel = new UgiroSearch();
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- public function actionActivate(){
-
- }
-
- /**
- * Displays a single Ugiro model.
- * @param integer $id
- * @return mixed
- */
- public function actionView($id)
- {
- $model = $this->findModel($id);
- if (Yii::$app->request->isPost) {
- if ($model->status == Ugiro::$STATUS_RECIEVED){
- set_time_limit(1200);//20 perc
- $processor = new DetStatProcessor(
- ['koteg' => $model]
- );
- $processor->run();
- }else{
- \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 );
- }
- }
-
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
- }
-
- /**
- * Creates a new Ugiro model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @return mixed
- */
- public function actionCreate()
- {
- $model = new Ugiro();
-
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->id_ugiro]);
- } else {
- return $this->render('create', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Updates an existing Ugiro model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param integer $id
- * @return mixed
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
-
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->id_ugiro]);
- } else {
- return $this->render('update', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Deletes an existing Ugiro model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param integer $id
- * @return mixed
- */
- 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.');
- }
- }
+class UgiroController extends Controller {
+ public function behaviors() {
+ return [
+ 'verbs' => [
+ 'class' => VerbFilter::className (),
+ 'actions' => [
+ 'delete' => [
+ 'post'
+ ]
+ ]
+ ],
+ 'access' => [
+ 'class' => \yii\filters\AccessControl::className (),
+ 'rules' => [
+ // allow authenticated users
+ [
+ 'actions' => [ ],
+ 'allow' => true,
+ 'roles' => [
+ 'admin',
+ 'employee',
+ 'reception'
+ ]
+ ]
+ ]
+ ]
+ // everything else is denied
+
+
+ ];
+ }
+
+ /**
+ * Lists all Ugiro models.
+ *
+ * @return mixed
+ */
+ public function actionIndex() {
+ $searchModel = new UgiroSearch ();
+ $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
+
+ return $this->render ( 'index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider
+ ] );
+ }
+ /**
+ * Lists all Ugiro models.
+ *
+ * @return mixed
+ */
+ public function actionItems($id) {
+ $searchModel = new UgiroSearch ();
+ $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
+
+ return $this->render ( 'index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider
+ ] );
+ }
+ public function actionActivate() {
+ }
+
+ /**
+ * Displays a single Ugiro model.
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionView($id) {
+ $model = $this->findModel ( $id );
+ if (Yii::$app->request->isPost) {
+ if ($model->status == Ugiro::$STATUS_RECIEVED) {
+ set_time_limit ( 1200 ); // 20 perc
+ $processor = new DetStatProcessor ( [
+ 'koteg' => $model
+ ] );
+ $processor->run ();
+ } else {
+ \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 );
+ }
+ } else {
+ if (isset ( $_GET ['output'] )) {
+ $output = $_GET ['output'];
+
+ if ($output == 'pdf') {
+ $this->downloadUgiro ( $model );
+ }
+ }
+ }
+
+ return $this->render ( 'view', [
+ 'model' => $this->findModel ( $id )
+ ] );
+ }
+ protected function downloadUgiro($model) {
+
+// $mpdf = new \mPDF ( 'utf-8', 'A4' );
+ $mpdf = new \mPDF ( 'utf-8', 'A4-L' );
+ $fn = "köteg.". $model->id_ugiro . ".pdf";
+
+ $mpdf->useSubstitutions = false;
+ $mpdf->simpleTables = true;
+ $mpdf->SetHeader ( "" );
+ $mpdf->setFooter ( '{PAGENO} / {nb}' );
+
+ $query = new Query();
+ $query->select([
+ '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',
+ ]);
+ $query->from('ticket_installment_request');
+ $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');
+ $query->andWhere(['ugiro_request_assignment.id_ugiro' => $model->id_ugiro]);
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ 'sort' => false,
+ 'pagination' => false
+ ]
+ );
+
+ $stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css
+ $mpdf->WriteHTML ( $stylesheet, 1 );
+
+ $mpdf->WriteHTML ( $this->renderPartial ( '_view_pdf.php', [
+ 'model' => $model,
+ 'dataProvider' => $dataProvider
+ ] ) );
+ $mpdf->Output ( $fn, 'D' );
+ exit ();
+
+ }
+
+ /**
+ * Creates a new Ugiro model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ *
+ * @return mixed
+ */
+ public function actionCreate() {
+ $model = new Ugiro ();
+
+ if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
+ return $this->redirect ( [
+ 'view',
+ 'id' => $model->id_ugiro
+ ] );
+ } else {
+ return $this->render ( 'create', [
+ 'model' => $model
+ ] );
+ }
+ }
+
+ /**
+ * Updates an existing Ugiro model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionUpdate($id) {
+ $model = $this->findModel ( $id );
+
+ if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
+ return $this->redirect ( [
+ 'view',
+ 'id' => $model->id_ugiro
+ ] );
+ } else {
+ return $this->render ( 'update', [
+ 'model' => $model
+ ] );
+ }
+ }
+
+ /**
+ * Deletes an existing Ugiro model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ 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.' );
+ }
+ }
}
diff --git a/backend/models/InventoryItemForm.php b/backend/models/InventoryItemForm.php
index 6e53108..d818c48 100644
--- a/backend/models/InventoryItemForm.php
+++ b/backend/models/InventoryItemForm.php
@@ -119,9 +119,11 @@ class InventoryItemForm extends Model{
$item->id_user = \Yii::$app->user->id;
if ( $this->type == 'product'){
+ $item->type = InventoryItem::$TYPE_PRODUCT;
$item->id_product = $this->product->id_product;
}else{
$item->id_inventory_group = $this->inventoryGroup->id_inventory_group;
+ $item->type = InventoryItem::$TYPE_INVENTORY_GROUP;
}
$item->id_inventory = $this->inventory->id_inventory;
diff --git a/backend/models/ProcurementUpdate.php b/backend/models/ProcurementUpdate.php
new file mode 100644
index 0000000..1199ee2
--- /dev/null
+++ b/backend/models/ProcurementUpdate.php
@@ -0,0 +1,49 @@
+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,
+ ]);
+ }
+
+
+}
\ No newline at end of file
diff --git a/backend/models/TransferLaterSearch.php b/backend/models/TransferLaterSearch.php
index 0ae56f2..587fdee 100644
--- a/backend/models/TransferLaterSearch.php
+++ b/backend/models/TransferLaterSearch.php
@@ -33,12 +33,15 @@ class TransferLaterSearch extends Transfer
public $total_money;
+ public $output;
+
/**
* @inheritdoc
*/
public function rules()
{
return [
+ [['output' ] ,'safe'],
[[ 'id_ticket_type','id_user'], 'integer'],
[[ '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' ],
@@ -72,11 +75,13 @@ class TransferLaterSearch extends Transfer
'transfer.money as transfer_money',
'transfer.status as transfer_status',
'user.username as user_username',
+ 'customer.id_customer as customer_id_customer',
'customer.name as customer_name',
'ticket_type.name as ticket_type_name',
'product.name as product_name',
'ticket.start as ticket_start',
'ticket.end as ticket_end',
+ 'ticket.comment as ticket_comment',
]);
$query->from("transfer");
$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.status' => Transfer::STATUS_NOT_PAID]);
-
+
+ $this->load($params);
+
+ $valid = $this->validate();
+
$dataProvider = new ActiveDataProvider([
'query' => $query,
- 'sort' =>[
+ 'pagination' => $this->output == 'pdf' ? false : [],
+ 'sort' => [
'defaultOrder' =>[
'transfer_created_at' => SORT_DESC
],
@@ -106,22 +116,18 @@ class TransferLaterSearch extends Transfer
['product_name'],
['ticket_start'],
['ticket_end'],
+ ['ticket_comment'],
])
]
]);
-// $query->addSelect( ['*' ]);
-
- $this->load($params);
-
- if (!$this->validate()) {
+ if (!$valid) {
// uncomment the following line if you do not want to return any records when validation fails
$query->where('0=1');
return $dataProvider;
}
-
$query->andFilterWhere([
diff --git a/backend/views/inventory-item/index.php b/backend/views/inventory-item/index.php
index 614f907..71df795 100644
--- a/backend/views/inventory-item/index.php
+++ b/backend/views/inventory-item/index.php
@@ -33,14 +33,24 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'name',
['attribute'=>'id_user',
'value'=>$model->userName
- ],
+ ],
['attribute'=>'id_account',
'value'=>$model->accountName
],
+ ['attribute'=>'status',
+ 'value'=>$model->getStatusHuman(),
+ 'label' => "Állapot"
+ ],
'created_at:datetime',
],
]) ?>
+ isOpen()){
+ echo Html::a("Lezárás",['inventory/close' , 'id' => $model->id_inventory ] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
+ }
+ ?>
+
render('_search', ['model' => $searchModel]); ?>
@@ -74,9 +84,8 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
$dataProvider,
- 'columns' =>[
+
+ $columns = [
[
'attribute' => 'item_created_at',
'label' => 'Létrehozva',
@@ -96,6 +105,16 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'attribute' => 'inventory_prev_name',
'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',
@@ -111,24 +130,20 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'attribute' => 'item_count_sold',
'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',
'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){
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
]);
?>
diff --git a/backend/views/inventory/index.php b/backend/views/inventory/index.php
index 75dfff2..8c508ec 100644
--- a/backend/views/inventory/index.php
+++ b/backend/views/inventory/index.php
@@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
render('_search', ['model' => $searchModel]); ?>
- 'btn btn-success']) ?>
+ 'btn btn-success']) ?>
= GridView::widget([
@@ -28,6 +28,7 @@ $this->params['breadcrumbs'][] = $this->title;
'name',
[ 'attribute' => 'id_user', "value" =>"userName" ],
'created_at:datetime',
+ [ 'attribute' => 'status', "value" =>"statusHuman" ],
['class' => 'yii\grid\ActionColumn',
'template' => '{view}',
diff --git a/backend/views/procurement/_form_update.php b/backend/views/procurement/_form_update.php
new file mode 100644
index 0000000..cdaae4c
--- /dev/null
+++ b/backend/views/procurement/_form_update.php
@@ -0,0 +1,34 @@
+
+
+
diff --git a/backend/views/procurement/index.php b/backend/views/procurement/index.php
index 4581096..2312d82 100644
--- a/backend/views/procurement/index.php
+++ b/backend/views/procurement/index.php
@@ -48,7 +48,15 @@ $this->params['breadcrumbs'][] = $this->title;
[
'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' ]);
+ }
+ ]
],
],
]); ?>
diff --git a/backend/views/procurement/update.php b/backend/views/procurement/update.php
index 6e0d44e..0532c99 100644
--- a/backend/views/procurement/update.php
+++ b/backend/views/procurement/update.php
@@ -1,13 +1,12 @@
title = Yii::t('common/procurement', 'Update {modelClass}: ', [
- 'modelClass' => 'Procurement',
-]) . ' ' . $model->id_procurement;
+$this->title = Yii::t('common/procurement', 'Beszerzés módosítása' );
$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'][] = Yii::t('common/procurement', 'Update');
@@ -15,8 +14,40 @@ $this->params['breadcrumbs'][] = Yii::t('common/procurement', 'Update');
= Html::encode($this->title) ?>
+
+
+ = 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,
]) ?>
diff --git a/backend/views/transfer/_pdf_payment_later.php b/backend/views/transfer/_pdf_payment_later.php
new file mode 100644
index 0000000..e4c11fb
--- /dev/null
+++ b/backend/views/transfer/_pdf_payment_later.php
@@ -0,0 +1,112 @@
+
+
+
+
+
Fizetendő tételek
+ = 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'],
+ ],
+ ],
+ ]); ?>
\ No newline at end of file
diff --git a/backend/views/transfer/payment_later.php b/backend/views/transfer/payment_later.php
index cf265b0..a029bec 100644
--- a/backend/views/transfer/payment_later.php
+++ b/backend/views/transfer/payment_later.php
@@ -36,6 +36,11 @@ $this->params['breadcrumbs'][] = $this->title;
= Html::encode($this->title) ?>
render('_search_payment_later', ['model' => $searchModel, ]); ?>
+
+'pdf']), ['class' => 'btn btn-primary' ]);
+?>
+
'btn btn-primary deselect-all',
'label' => 'Összeg'
],
[
- 'attribute' => 'transfer_status',
- 'label' => 'Státusz',
- 'value' => function ($model, $key, $index, $column){
+ 'attribute' => 'transfer_status',
+ 'label' => 'Státusz',
+ 'value' => function ($model, $key, $index, $column){
return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],'');
},
],
+ [
+ 'attribute' => 'ticket_comment',
+ 'label' => 'Megjegyzés'
+ ],
],
]); ?>
diff --git a/backend/views/ugiro/_view_pdf.php b/backend/views/ugiro/_view_pdf.php
new file mode 100644
index 0000000..b9d6aa0
--- /dev/null
+++ b/backend/views/ugiro/_view_pdf.php
@@ -0,0 +1,128 @@
+
+
+
+
+ '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'
+ ],
+
+ ];
+
+
+
+
+ ?>
+
+
Csoportos beszedés
+
+ = DetailView::widget([
+ 'options' => ['class' => 'table table-striped table-bordered detail-view table-ugiro'],
+ 'model' => $model,
+ 'attributes' => $attributes,
+ ]) ?>
+
+ ['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' ]
+ ]
+ ]
+ ]);
+
+ ?>
+
\ No newline at end of file
diff --git a/backend/views/ugiro/view.php b/backend/views/ugiro/view.php
index 3839296..3aff5d5 100644
--- a/backend/views/ugiro/view.php
+++ b/backend/views/ugiro/view.php
@@ -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("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;
if ( isset($detstaMessage)){
diff --git a/common/models/Inventory.php b/common/models/Inventory.php
index c809adf..4e3c196 100644
--- a/common/models/Inventory.php
+++ b/common/models/Inventory.php
@@ -8,6 +8,7 @@ use yii\helpers\ArrayHelper;
use yii\db\Query;
use backend\models\InventoryItemForm;
use common\components\AccountAwareBehavior;
+use common\components\Helper;
/**
* This is the model class for table "inventory".
@@ -15,6 +16,7 @@ use common\components\AccountAwareBehavior;
* @property integer $id_inventory
* @property integer $id_user
* @property integer $id_account
+ * @property integer $status
* @property string $name
* @property string $created_at
* @property string $updated_at
@@ -22,6 +24,9 @@ use common\components\AccountAwareBehavior;
class Inventory extends \common\models\BaseFitnessActiveRecord
{
+ public static $STATUS_OPEN = 10;
+ public static $STATUS_CLOSED = 20;
+
/**
* @inheritdoc
@@ -40,6 +45,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return [
[['name'], 'string'],
[['id_account'], 'integer'],
+ [['name'], 'validateOnlyClosed'],
];
}
@@ -51,6 +57,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return [
'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'),
'name' => Yii::t('common/inventory', 'Megnevezés'),
+ 'status' => Yii::t('common/inventory', 'Státusz'),
'id_user' => Yii::t('common/inventory', 'Felhasználó'),
'id_account' => Yii::t('common/inventory', 'Kassza'),
'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
*/
@@ -85,7 +100,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
// $query->andWhere("product.id_inventory_group is null");
$products = $query->all();
- echo "Products found: " . count($products);
+ //echo "Products found: " . count($products);
$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;
+ }
+
}
diff --git a/common/models/InventoryItem.php b/common/models/InventoryItem.php
index 34c961c..80060c1 100644
--- a/common/models/InventoryItem.php
+++ b/common/models/InventoryItem.php
@@ -32,6 +32,21 @@ class InventoryItem extends BaseFitnessActiveRecord
public static $TYPE_PRODUCT = 10;
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
*/
@@ -142,14 +157,14 @@ class InventoryItem extends BaseFitnessActiveRecord
public function afterSave($insert, $changedAttributes){
if ( !$insert ){
- if ( $this->type == 'product'){
- $product = $this->product;
- $product->stock = $this->count;
- if ( !$product->save(false) ){
- \Yii::error("Failed to save product stock");
- throw new \Exception("A leltár elem mentése nem sikerült");
- }
- }
+// if ( $this->type == 'product'){
+// $product = $this->product;
+// $product->stock = $this->count;
+// if ( !$product->save(false) ){
+// \Yii::error("Failed to save product stock");
+// throw new \Exception("A leltár elem mentése nem sikerült");
+// }
+// }
}
}
diff --git a/common/models/Log.php b/common/models/Log.php
index aefa0c6..e82bf08 100644
--- a/common/models/Log.php
+++ b/common/models/Log.php
@@ -39,6 +39,7 @@ class Log extends BaseFitnessActiveRecord
public static $TYPE_LOGIN = 50;
public static $TYPE_DEFAULT_ACCOUNT= 60;
public static $TYPE_CREATE_CUSTOMER= 70;
+ public static $TYPE_PROCUREMENT_UPDATE = 80;
/**
* @inheritdoc
*/
@@ -90,12 +91,11 @@ class Log extends BaseFitnessActiveRecord
self::log(['type' =>self::$TYPE_INFO, 'message' => $message]);
}
public static function log( $config ){
- \Yii::info( "Log :" . VarDumper::dump( $config) ) ;
$model = new Log($config);
$model->app = \Yii::$app->name;
$model->url = Url::canonical();
$model->id_user = \Yii::$app->user->id;
- $model->save();
+ $model->save(false);
}
}
diff --git a/console/migrations/m160329_195454_add_inventory_status.php b/console/migrations/m160329_195454_add_inventory_status.php
new file mode 100644
index 0000000..4dbaa59
--- /dev/null
+++ b/console/migrations/m160329_195454_add_inventory_status.php
@@ -0,0 +1,30 @@
+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()
+ {
+ }
+ */
+}
diff --git a/frontend/components/FrontendMenuStructure.php b/frontend/components/FrontendMenuStructure.php
index 1c69b35..9bdfd3c 100644
--- a/frontend/components/FrontendMenuStructure.php
+++ b/frontend/components/FrontendMenuStructure.php
@@ -89,7 +89,7 @@ class FrontendMenuStructure{
$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' => [ '/inventory/index' ] ];
+// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ];
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),
From bd5406f8bee5a6990481bf35620d7053e3f1b097 Mon Sep 17 00:00:00 2001
From: Roland Schneider
Date: Wed, 30 Mar 2016 21:24:44 +0200
Subject: [PATCH 2/2] change version to v.0.056
---
changelog.txt | 4 ++++
common/config/params.php | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/changelog.txt b/changelog.txt
index 886f0b2..079ac71 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,7 @@
+-0.0.56
+ - inventory to admin
+ - update procurement
+ - export payment later on admin
-0.0.55
- new type transfer later
-0.0.54
diff --git a/common/config/params.php b/common/config/params.php
index aa94d6c..4a188ef 100644
--- a/common/config/params.php
+++ b/common/config/params.php
@@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
- 'version' => 'v0.0.55',
+ 'version' => 'v0.0.56',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global