Finish version/v0.0.57

This commit is contained in:
Roland Schneider 2016-04-03 10:52:49 +02:00
commit a05c795dba
20 changed files with 207 additions and 65 deletions

View File

@ -14,6 +14,7 @@ use yii\web\UploadedFile;
use common\components\Helper;
use backend\models\CardInsertForm;
use common\models\Ticket;
use frontend\components\HtmlHelper;
/**
* CardController implements the CRUD actions for Card model.
@ -25,6 +26,16 @@ class CardController extends \backend\controllers\BackendController {
'class' => \yii\filters\AccessControl::className (),
'rules' => [
// allow authenticated users
[
'actions' => [
'clear',
],
'allow' => true,
'roles' => [
'admin'
]
],
[
'actions' => [
'create',
@ -40,7 +51,8 @@ class CardController extends \backend\controllers\BackendController {
'roles' => [
'@'
]
]
] ,
]
// everything else is denied
@ -48,6 +60,26 @@ class CardController extends \backend\controllers\BackendController {
];
}
public function actionClear($id){
$model = $this->findModel ( $id );
Ticket::updateAll(['id_card' => null],['id_card' => $model->id_card]);
$customer = $model->customer;
$customer->id_customer_card = null;
$customer->save(false);
Card::updateCardFlagTicket($model->id_card);
Helper::flash('success', "Vendég törölve a kártyáról");
$this->redirect(['card/update','id' =>$id]);
}
/**
* Lists all Card models.
*

View File

@ -33,7 +33,7 @@ class KeyController extends Controller {
'rules' => [
// allow authenticated users
[
'actions' => ['create','index','view','update','import'],
'actions' => ['create','index','view','update','import','index-customer'],
'allow' => true,
'roles' => ['admin','employee','reception'],
],

View File

@ -137,7 +137,7 @@ class TicketController extends \backend\controllers\BackendController {
$searchModel = new TicketSearchCustomer(['customer' => $customer]);
$searchModel->id_card = $customer->id_customer_card;
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
$searchModel->searchTotals ();
//$searchModel->searchTotals ();
$searchModel->users = User::read ();
$searchModel->accounts = Account::read ();

View File

@ -112,7 +112,7 @@ class TicketInstallmentRequestController extends Controller
{
$model = new GiroKotegForm();
if ($model->load(Yii::$app->request->post()) ) {
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
$model->createKoteg();
return $this->redirect(['ugiro/view', 'id' => $model->koteg->id_ugiro]);
}

View File

@ -63,7 +63,6 @@ class TransferController extends \backend\controllers\BackendController
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
echo "output:".$searchModel->output;
if ( $searchModel->output =='pdf'){
$this->downloadPaymentLater($dataProvider);

View File

@ -62,21 +62,6 @@ class CustomerSearch extends Customer
];
// $dataProvider->setSort(
// [
// 'attributes' => [
// 'id',
// 'fullName' => [
// 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC],
// 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC],
// 'label' => 'Full Name',
// 'default' => SORT_ASC
// ],
// 'country_id'
// ]
// ]);
$this->load($params);
@ -89,18 +74,7 @@ class CustomerSearch extends Customer
$query->leftJoin(Card::tableName(), " customer.id_customer_card = card.id_card" );
// $query->andFilterWhere([
// 'id_customer' => $this->id_customer,
// 'id_customer_card' => $this->id_customer_card,
// 'id_user' => $this->id_user,
// 'id_partner_card' => $this->id_partner_card,
// 'id_proposer' => $this->id_proposer,
// 'sex' => $this->sex,
// 'date_stundent_card_expire' => $this->date_stundent_card_expire,
// 'birthdate' => $this->birthdate,
// 'created_at' => $this->created_at,
// 'updated_at' => $this->updated_at,
// ]);
$query->andFilterWhere(['like', 'customer.name', $this->name])
->andFilterWhere(['like', 'customer.email', $this->email])

View File

@ -31,13 +31,45 @@ class GiroKotegForm extends Model{
public $koteg;
public $success;
public $timestamp_teljesites_datum;
public $teljesitesi_datum;
public function rules(){
return [
[['action'], 'safe']
[['action'], 'safe'] ,
[[ 'teljesitesi_datum', ], 'required'],
[[ 'teljesitesi_datum', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestamp_teljesites_datum' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ],
['teljesitesi_datum', "validateRequestCount"],
['teljesitesi_datum', "validateMaxPlusDay"],
];
}
public function validateRequestCount($a,$p){
$this->readRequests();
if ( count( $this->requests ) == 0 ){
$this->addError("teljesitesi_datum", "Megbízások száma 0!" );
}
}
/*
* A teljesítési dátum max 8 nappal lehet a létrehozás dátumán túl
* */
public function validateMaxPlusDay(){
$date = new \DateTime('now');
$date->add(new \DateInterval('P8D'));
$date->setTime(0,0,0);
$td = new \DateTime();
$td->setTimestamp( strtotime( $this->timestamp_teljesites_datum ) );
$date->setTime(0,0,0);
if ( $td > $date){
$this->addError( "teljesitesi_datum", "Érvénytelen terhelési dátum. A terhelési dátum max +8 nap lehet");
}
}
public function createKoteg(){
$this->readRequests();
@ -98,6 +130,7 @@ class GiroKotegForm extends Model{
$this->koteg->id_user = \Yii::$app->user->id;
$this->koteg->datum = date('Ymd');
$this->koteg->terhelesi_datum = $this->teljesitesi_datum;
$lastNumber = $this->loadLastNumber($this->koteg->datum);
$nextNumber = $lastNumber+1;
@ -120,7 +153,8 @@ class GiroKotegForm extends Model{
}
public function generateFileContent(){
$this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests);
$terhelesi_datum =\Yii::$app->formatter->asDate($this->timestamp_teljesites_datum, 'php:Ymd');
$this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests,$terhelesi_datum);
}
public function saveFile( ) {

View File

@ -11,9 +11,11 @@ use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
use yii\db\Query;
use common\models\Transfer;
use yii\helpers\VarDumper;
/**
* TicketSearch represents the model behind the search form about `common\models\Ticket`.
* @property commom\models\Customer $customer
*/
class TicketSearchCustomer extends Ticket
{
@ -32,7 +34,9 @@ class TicketSearchCustomer extends Ticket
public $statistics;
public $statisticsTotal;
public $customer;
public $customer; //constructor param
/**
@ -113,7 +117,8 @@ class TicketSearchCustomer extends Ticket
$query->innerJoin('user', 'user.id = transfer.id_user');
$query->leftJoin('user as paid_by', 'paid_by.id = transfer.paid_by');
$query->leftJoin('card', 'ticket.id_card = card.id_card');
$query->leftJoin('customer', 'customer.id_customer_card = card.id_card');
$query->leftJoin('customer', 'customer.id_customer= transfer.id_customer');
Helper::queryAccountConstraint($query, 'ticket.id_account');
@ -177,11 +182,12 @@ class TicketSearchCustomer extends Ticket
if (!$this->validate()) {
$query->where('0=1');
return $query;
}
$query->andWhere( ['transfer.id_customer' => $this->customer->id_customer ]);
$query->andFilterWhere([
'ticket.id_user' => $this->id_user,
'ticket.id_ticket_type' => $this->id_ticket_type,
@ -191,7 +197,7 @@ class TicketSearchCustomer extends Ticket
'ticket.status' => $this->status
]);
$query->andWhere(['customer.id_customer' => $this->customer->id_customer]);
// $query->andWhere(['customer.id_customer' => $this->customer->id_customer]);
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) )
@ -230,7 +236,8 @@ class TicketSearchCustomer extends Ticket
public function searchTotals(){
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd,$this->id_card);
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd);
$query->andWhere(["transfer.id_customer" => $this->id ]);
$this->statistics = $query->all();
$this->statisticsTotal =[

View File

@ -23,7 +23,7 @@ use common\models\Card;
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/card', 'Create') : Yii::t('common/card', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
<?= Html::submitButton( Yii::t('common/card', 'Create/Next') ,['class' => 'btn btn-primary','name'=>'create_next']) ?>
<?php //echo Html::submitButton( Yii::t('common/card', 'Create/Next') ,['class' => 'btn btn-primary','name'=>'create_next']) ?>
</div>
<?php ActiveForm::end(); ?>

View File

@ -1,23 +1,56 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\base\Widget;
use common\components\Helper;
use common\components\RoleDefinition;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
$this->title = Yii::t('common/card', 'Update {modelClass}: ', [
'modelClass' => 'Card',
]) . ' ' . $model->id_card;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->number, 'url' => ['view', 'id' => $model->id_card]];
$this->title = Yii::t ( 'common/card', 'Bérletkártya módosítása' );
$this->params ['breadcrumbs'] [] = [
'label' => Yii::t ( 'common/card', 'Cards' ),
'url' => [
'index'
]
];
$this->params ['breadcrumbs'] [] = [
'label' => $model->number,
'url' => [
'view',
'id' => $model->id_card
]
];
$this->params ['breadcrumbs'] [] = Yii::t ( 'common/card', 'Update' );
?>
<div class="card-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
<?php
$customer = $model->customer;
if (isset ( $customer )) {
echo DetailView::widget ( [
'model' => $model,
]) ?>
'attributes' => [
[
'label' => 'Vendég',
'value' => $model->customer->name
]
]
] );
if ( RoleDefinition::isAdmin() ){
echo Html::a ( "Vendég törlése a kártyáról!", ['card/clear','id' =>$model->id_card], [
'class' => 'btn btn-danger' ,
'data-confirm' => "Figyelem, a kártyához tartozó összes bérlet el fog veszni!",
'data-method' => 'post',
] );
}
}
?>
<?=$this->render ( '_form', [ 'model' => $model ] )?>
</div>

View File

@ -48,6 +48,6 @@ $items = [
<?php if ( !empty($title)) {?>
<h1><?php echo $title?></h1>
<p>Vendég: <?php echo $card->customer->name ?></p>
<p>Kártyaszám: <?php echo $card->number ?></p>
<p>Vendég: <?php echo $customer->name ?></p>
<p>Kártyaszám: <?php echo isset($card) ? $card->number : "Törölt kártya!" ?></p>
<?php }?>

View File

@ -7,6 +7,8 @@ use yii\base\Widget;
use kartik\widgets\ActiveForm;
use backend\assets\PendingRequestAsset;
use yii\helpers\Url;
use kartik\widgets\DateTimePicker;
use kartik\widgets\DatePicker;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\TicketInstallmentRequestSearch */
@ -23,6 +25,28 @@ PendingRequestAsset::register($this);
<h1><?= Html::encode($this->title) ?></h1>
<?php $form = ActiveForm::begin([
'action' => Url::current(),
'method' => 'post',
]); ?>
<?php echo $form->field($model, 'action')->hiddenInput()->label(false) ?>
<div class="row">
<div class="col-md-3">
<?= $form->field($model, 'teljesitesi_datum')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton("Köteg létrehozása", ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php
echo ListView::widget([
'dataProvider' => $dataProvider,
@ -30,15 +54,4 @@ PendingRequestAsset::register($this);
]);
?>
<?php $form = ActiveForm::begin([
'action' => Url::current(),
'method' => 'post',
]); ?>
<?php echo $form->field($model, 'action')->hiddenInput()->label(false) ?>
<div class="form-group">
<?= Html::submitButton("Köteg létrehozása", ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -6,6 +6,7 @@ use yii\helpers\ArrayHelper;
use yii\data\ArrayDataProvider;
use backend\components\AdminCustomerTabWidget;
use common\models\Ticket;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\TicketSearch */
@ -29,7 +30,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
<?php echo $this->render('_search_customer', ['model' => $searchModel]); ?>
<?php /*?>
<div class="panel panel-default">
<div class="panel-heading">Bérlet statisztika</div>
<div class="panel-body">
@ -80,7 +81,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
</div>
<?php */?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
@ -133,7 +134,13 @@ $this->params['breadcrumbs'][] = "Befizetések";
// 'usage_count',
['class' => 'yii\grid\ActionColumn',
'template' => '{view}'
'template' => '{view}' ,
'urlCreator' => function($action, $model, $key, $index){
if ( $action == 'view' ){
return Url::toRoute( [ 'ticket/view' , 'id' => $model['ticket_id_ticket' ] ] );
}
return null;
},
],
],
]); ?>

View File

@ -52,6 +52,11 @@ $attributes = [
'attribute' => 'created_at',
'label' => 'Létrehozva',
'format' =>'datetime'
],
[
'attribute' => 'terhelesi_datum',
'label' => 'Terhelési dátum',
'format' =>'datetime'
],
[
'attribute' => 'path',

3
backend/web/info.php Normal file
View File

@ -0,0 +1,3 @@
<?php
phpinfo();
?>

View File

@ -1,3 +1,6 @@
-0.0.57
- add feature clear card
- add changeable payment date to ugiro
-0.0.56
- inventory to admin
- update procurement

View File

@ -24,6 +24,7 @@ class GiroBeszed extends GiroBase {
if ( !isset($terhelesiDatum)){
$terhelesiDatum = date('Ymd' ,strtotime("+5 day"));
}
$s = self::createFej($number, $datum);
$s .= self::createTetelek($requests,$terhelesiDatum);
$s .= self::createLab($requests);

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.56',
'version' => 'v0.0.57',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global

View File

@ -17,6 +17,7 @@ use yii\helpers\ArrayHelper;
* @property integer $number
* @property string $created_at
* @property string $updated_at
* @property string $terhelesi_datum
*/
class Ugiro extends \yii\db\ActiveRecord
{

View File

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