add backend transfer list changes

This commit is contained in:
2015-10-13 09:27:56 +02:00
parent fda450b801
commit b04cbda645
20 changed files with 677 additions and 222 deletions

View File

@@ -9,6 +9,39 @@ use yii\helpers\ArrayHelper;
class HtmlHelper{
/**
* Mehtod used in reception widgets to render card dependent buttons
*
* @see ReceptionCardNumberTicketsWidget
* @see ReceptionCardNumberWidget
* @see ReceptionMenuWidget
* */
public static function mkReceptionCardBtn($card, $label,$route = null ){
$url = null;
$classes = 'btn btn-primary btn-reception';
if ( $card == null ){
$classes .= ' disabled';
}
if ( isset($route)){
$url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )];
}
return Html::a( $label , $url, ['class' => $classes ] );
}
public static function mkReceptionBtn($card, $label,$route = null ){
$url = null;
$classes = 'btn btn-primary btn-reception';
if ( isset($route)){
$url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )];
}
return Html::a( $label , $url, ['class' => $classes ] );
}
public static function mkOptions( $models, $key, $value = 'name' ){
$result = [];
$result = ArrayHelper::map( $models, $key, $value );

View File

@@ -0,0 +1,24 @@
<?php
namespace frontend\components;
use yii\base\Widget;
class ReceptionCardNumberTicketsWidget extends Widget{
public $number;
public $route;
public $customer;
public $card;
public $tickets;
public $viewFile = '//common/_card_number_tickets';
public function run(){
echo $this->render($this->viewFile,[ 'tickets' => $this->tickets, 'card' => $this->card, 'customer' =>$this->customer , 'route' => $this->route ]);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace frontend\components;
use yii\base\Widget;
class ReceptionWidget extends Widget{
public $form;
public $number;
public $route;
public $customer;
public $card;
public $tickets;
public $viewFile = '//common/_reception';
public function init(){
parent::init();
if ( isset($this->form)){
$this->card = $this->form->card;
$this->customer = $this->form->customer;
$this->tickets = $this->form->tickets;
}
}
public function run(){
echo $this->render($this->viewFile,['card' => $this->card, 'customer' =>$this->customer, 'tickets' => $this->tickets ]);
}
}

View File

@@ -39,6 +39,18 @@ class ProductController extends Controller
'delete' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className(),
'only' => [ 'sale','clear-list', 'lookup'],
'rules' => [
// allow authenticated users
[
'allow' => true,
'roles' => ['@'],
],
// everything else is denied
],
],
];
}
@@ -126,82 +138,8 @@ class ProductController extends Controller
}
/**
* Lists all Product models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Product model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_product]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Product 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_product]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Product 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']);
}
/**
*/
@@ -250,4 +188,86 @@ class ProductController extends Controller
}
/**
* Lists all Product models.
* @return mixed
*/
/*
public function actionIndex()
{
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
*/
/**
* Displays a single Product model.
* @param integer $id
* @return mixed
*/
/*
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
*/
/**
* Updates an existing Product 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_product]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
*/
/**
* Deletes an existing Product 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']);
}
*/
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
/*
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_product]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
*/
}

View File

@@ -31,6 +31,18 @@ class TicketController extends Controller
'delete' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className(),
'only' => ['create', 'index' ],
'rules' => [
// allow authenticated users
[
'allow' => true,
'roles' => ['@'],
],
// everything else is denied
],
],
];
}
@@ -59,18 +71,6 @@ class TicketController extends Controller
]);
}
/**
* Displays a single Ticket model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Ticket model.
* If creation is successful, the browser will be redirected to the 'view' page.
@@ -123,38 +123,6 @@ class TicketController extends Controller
}
}
/**
* Updates an existing Ticket 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_ticket]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Ticket 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']);
}
/**
* Finds the Ticket model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
@@ -170,4 +138,51 @@ class TicketController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Displays a single Ticket model.
* @param integer $id
* @return mixed
*/
/*
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
*/
/**
* Deletes an existing Ticket 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']);
}
*/
/**
* Updates an existing Ticket 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_ticket]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
*/
}

View File

@@ -6,6 +6,7 @@ use Yii;
use yii\base\Model;
use common\models\Card;
use common\models\Customer;
use common\models\Ticket;
/**
* ContactForm is the model behind the contact form.
@@ -15,6 +16,7 @@ class ReceptionForm extends Model
public $number;
public $card;
public $customer;
public $tickets;
/**
@@ -39,10 +41,18 @@ class ReceptionForm extends Model
}
public function readCard(){
$this->card = Card::findOne(['number' => $this->number]);
if ( $this->card != null ){
$this->customer = $this->card->customer;
$this->readValidTickets();
}
}
public function readValidTickets(){
$this->tickets = Ticket::readActive($this->card);
}
}

View File

@@ -45,7 +45,7 @@ class TicketSearch extends Ticket
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['end'=>SORT_DESC]]
'sort'=> ['defaultOrder' => ['created_at'=>SORT_DESC]]
]);

View File

@@ -0,0 +1,41 @@
<?php
use yii\base\Object;
use common\models\Ticket;
?>
<style>
.reception-tickets-container{
max-height: 300px;
overflow-y: auto;
}
</style>
<div class="reception-tickets-container">
<table class="table table-bordered table-striped">
<?php $model = new Ticket() ;?>
<thead>
<tr>
<th><?php echo $model->getAttributeLabel('id_ticket_type') ?></th>
<th><?php echo $model->getAttributeLabel('start') ?></th>
<th><?php echo $model->getAttributeLabel('end') ?></th>
</tr>
</thead>
<?php if (isset($tickets) && count($tickets) ) {?>
<tbody>
<?php foreach ($tickets as $ticket){ ?>
<tr>
<td>
<?php echo $ticket->ticketTypeName ?>
</td>
<td>
<?php echo Yii::$app->formatter->asDate( $ticket->start ) ?>
</td>
<td>
<?php echo Yii::$app->formatter->asDate( $ticket->end ) ?>
</td>
</tr>
<?php }?>
</tbody>
<?php }?>
</table>
</div>

View File

@@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
use frontend\components\HtmlHelper;
/* @var $this yii\web\View */
/* @var $card common\models\Card */
@@ -25,7 +26,7 @@ if ( isset($customer ) ){
$customername = $customer->name;
}
/*
function mkCustomerBtn($card, $label,$route = null ){
$url = null;
@@ -38,7 +39,6 @@ function mkCustomerBtn($card, $label,$route = null ){
}
return Html::a( $label , $url, ['class' => $classes ] );
}
function mkBtn($card, $label,$route = null ){
$url = null;
@@ -50,12 +50,13 @@ function mkBtn($card, $label,$route = null ){
return Html::a( $label , $url, ['class' => $classes ] );
}
*/
?>
<div class='row'>
<div class='col-md-8'>
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Adatlap') , 'customer/update' ); ?>
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Yii::t( 'frontend/customer' , 'Adatlap') , 'customer/update' ); ?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , Url::toRoute('customer/create') , ['class' => 'btn btn-primary btn-reception'] )?>
@@ -63,15 +64,15 @@ function mkBtn($card, $label,$route = null ){
</div>
<div class='row'>
<div class='col-md-8'>
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
</div>
<div class='col-md-4'>
<?php echo mkCustomerBtn( $card, Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?>
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<?php echo mkBtn($card, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
<?php echo HtmlHelper::mkReceptionBtn($card, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
</div>
</div>

View File

@@ -0,0 +1,18 @@
<?php
use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionMenuWidget;
use frontend\models\ReceptionForm;
use frontend\components\ReceptionCardNumberTicketsWidget;
use yii\base\Widget;
?>
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberTicketsWidget::widget([ 'tickets' => $tickets, 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] ) ?>
</div>
</div>

View File

@@ -78,7 +78,7 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
</div>
<div class="row">
<div class='col-md-12'>
<?php echo $form->field($model,'id_currency')->dropDownList($currencyOptions) ?>
<?php //echo $form->field($model,'id_currency')->dropDownList($currencyOptions) ?>
</div>
</div>
<div class="row">

View File

@@ -4,6 +4,8 @@ use yii\helpers\Html;
use yii\grid\GridView;
use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionWidget;
use yii\base\Widget;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\TicketSearch */
@@ -18,16 +20,8 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="ticket-index">
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
</div>
</div>
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<h1><?= Html::encode($this->title) ?></h1>
@@ -57,16 +51,19 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'id_user',
'value' => 'userName'
],
/*
[
'attribute' => 'id_discount',
'value' => 'discountName'
],
*/
'price_brutto',
'created_at:datetime',
/*
['class' => 'yii\grid\ActionColumn',
'template' =>'{view} {update}',
],
*/
],
]); ?>