Finish version/v.0.0.56

This commit is contained in:
Roland Schneider 2016-03-30 21:25:28 +02:00
commit 0cb47bb09b
24 changed files with 858 additions and 246 deletions

View File

@ -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.

View File

@ -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.
@ -178,6 +179,10 @@ 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");

View File

@ -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.

View File

@ -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());
@ -77,6 +82,30 @@ class TransferController extends \backend\controllers\BackendController
]);
}
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.
* @return mixed

View File

@ -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]
);
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
return $this->render('detsta', [
'model' => $model,
]);
}
];
}
public function actionUpload(){
$model = new DestaUploadForm();
/**
* Lists all Ugiro models.
*
* @return mixed
*/
public function actionIndex() {
$searchModel = new UgiroSearch ();
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
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 ( '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('upload', ['model' => $model]);
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 );
}
}
}
public function actionGenerateDetsta(){
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 );
/**
* 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.');
}
}
$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.' );
}
}
}

View File

@ -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;

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 $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");
@ -90,9 +95,14 @@ class TransferLaterSearch extends Transfer
$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,24 +116,20 @@ 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([
'ticket_type.id_ticket_type' => $this->id_ticket_type,
'transfer.id_user' => $this->id_user,

View File

@ -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',
],
]) ?>
<?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]); ?>
@ -74,9 +84,8 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
</p>
<?php
echo GridView::widget( [
'dataProvider' => $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
]);
?>

View File

@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<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>
<?= 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}',

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',
'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
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Procurement */
$this->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');
@ -16,7 +15,39 @@ $this->params['breadcrumbs'][] = Yii::t('common/procurement', 'Update');
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
<?= 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_update', [
'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>
<?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;">
<?php
@ -108,12 +113,16 @@ echo Html::a("Egyiket sem",null, ['class' => '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'
],
],
]); ?>

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("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)){

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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");
// }
// }
}
}

View File

@ -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);
}
}

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','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'),