Finish version/v.0.0.6

This commit is contained in:
Roland Schneider 2015-11-29 15:17:55 +01:00
commit ea24aa8dcc
20 changed files with 684 additions and 15 deletions

View File

@ -58,6 +58,7 @@ class AdminMenuStructure{
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
// $items[] = ['label' => 'Kulcsok', 'url' =>['/key/index']];
// $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
$this->menuItems[] = ['label' => 'Törszadatok', 'url' =>$this->emptyUrl,
'items' => $items
@ -119,4 +120,4 @@ class AdminMenuStructure{
}
}
}

View File

@ -17,7 +17,6 @@ return [
'request' => [
'csrfParam' => '_backendCSRF',
'csrfCookie' => [
'httpOnly' => true,
'path' => '/backend/web',
],
],
@ -26,8 +25,7 @@ return [
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendUser', // unique for backend
'path'=>'/backend/web', // correct path for the backend app.
'httpOnly' => true,
// 'path' => '/backend/web',
]
],
'session' => [

View File

@ -0,0 +1,122 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Key;
use backend\models\KeySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* KeyController implements the CRUD actions for Key model.
*/
class KeyController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Key models.
* @return mixed
*/
//http://localhost/fitness-web/backend/web/index.php?r=key/index erre ezt hívja meg elsőzör
public function actionIndex()
{
$searchModel = new KeySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
// backend/views/kex/index.php
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Key model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Key model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Key();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_key]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Key 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_key]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Key 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 Key model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Key the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Key::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,70 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Key;
/**
* KeySearch represents the model behind the search form about `common\models\Key`.
*/
class KeySearch extends Key
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_key', 'status', 'type'], 'integer'],
[['number', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Key::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id_key' => $this->id_key,
'status' => $this->status,
'type' => $this->type,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'number', $this->number]);
return $dataProvider;
}
}

View File

@ -20,7 +20,7 @@ class ProductSearch extends Product
{
return [
[[ 'id_product_category', 'id_account', 'status'], 'integer'],
[['product_number', 'barcode' ], 'safe'],
[['product_number', 'barcode' ,'name'], 'safe'],
];
}
@ -68,7 +68,8 @@ class ProductSearch extends Product
]);
$query->andFilterWhere(['like', 'product_number', $this->product_number])
->andFilterWhere(['like', 'barcode', $this->barcode]);
->andFilterWhere(['like', 'barcode', $this->barcode])
->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}

View File

@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Key */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="key-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'number')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->textInput() ?>
<?= $form->field($model, 'type')->textInput() ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend/key', 'Create') : Yii::t('backend/key', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\KeySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="key-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_key') ?>
<?= $form->field($model, 'number') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'type') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('backend/key', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('backend/key', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Key */
$this->title = Yii::t('backend/key', 'Create Key');
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/key', 'Keys'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="key-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\KeySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend/key', 'Keys');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="key-index">
asdf
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('backend/key', 'Create Key'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id_key',
'number',
'status',
'type',
'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Key */
$this->title = Yii::t('backend/key', 'Update {modelClass}: ', [
'modelClass' => 'Key',
]) . ' ' . $model->id_key;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/key', 'Keys'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_key, 'url' => ['view', 'id' => $model->id_key]];
$this->params['breadcrumbs'][] = Yii::t('backend/key', 'Update');
?>
<div class="key-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,40 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Key */
$this->title = $model->id_key;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/key', 'Keys'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="key-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('backend/key', 'Update'), ['update', 'id' => $model->id_key], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('backend/key', 'Delete'), ['delete', 'id' => $model->id_key], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('backend/key', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_key',
'number',
'status',
'type',
'created_at',
'updated_at',
],
]) ?>
</div>

View File

@ -19,11 +19,11 @@ function mkOptions($options){
return $o;
}
$statusOptions = mkOptions( Product::statuses() );
$statusOptions = ['' => "Mind"] + ( Product::statuses() );
$productCategories = mkOptions( ArrayHelper::map( ProductCategory::read(null) ,'id_product_category','name') );
$productCategories = ['' => "Mind"] + ArrayHelper::map( ProductCategory::read(null) ,'id_product_category','name') ;
$accounts = mkOptions( ArrayHelper::map( Account::read(null) ,'id_account','name'));
$accounts = ['' => "Mind"] + ( ArrayHelper::map( Account::read(null) ,'id_account','name'));
?>
<div class="product-search">
@ -44,12 +44,13 @@ $accounts = mkOptions( ArrayHelper::map( Account::read(null) ,'id_account','nam
<?php echo $form->field($model, 'status')->dropDownList($statusOptions) ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'product_number') ?>
<?= $form->field($model, 'name') ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'barcode') ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'product_number') ?>
</div>
</div>

View File

@ -1,3 +1,8 @@
-0.0.6
csrf fixing
product - allow sale when count > stock
product - admin - allow search by name
account_state - auto sum up
-0.0.5
a backend csrf config változtatása
-0.0.4

View File

@ -3,5 +3,5 @@ return [
'adminEmail' => 'rocho02@gmail.com',
'supportEmail' => 'rocho02@gmail.com',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.5'
'version' => 'v0.0.6'
];

54
common/models/Key.php Normal file
View File

@ -0,0 +1,54 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "key".
*
* @property integer $id_key
* @property string $number
* @property integer $status
* @property integer $type
* @property string $created_at
* @property string $updated_at
*/
class Key extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'key';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['status', 'type'], 'integer'],
[['created_at', 'updated_at'], 'required'],
[['created_at', 'updated_at'], 'safe'],
[['number'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_key' => Yii::t('common/key', 'Id Key'),
'number' => Yii::t('common/key', 'Number'),
'status' => Yii::t('common/key', 'Status'),
'type' => Yii::t('common/key', 'Type'),
'created_at' => Yii::t('common/key', 'Created At'),
'updated_at' => Yii::t('common/key', 'Updated At'),
];
}
}

162
composer_kiement1.txt Normal file
View File

@ -0,0 +1,162 @@
sanya@sanyigep ~/public_html/fitness-web $ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing yiisoft/yii2-composer (2.0.3)
Loading from cache
- Installing bower-asset/accounting (v0.3.2)
Loading from cache
- Installing bower-asset/jquery (2.1.4)
Loading from cache
- Installing bower-asset/jquery.inputmask (3.1.63)
Loading from cache
- Installing bower-asset/moment (2.10.6)
Loading from cache
- Installing bower-asset/punycode (v1.3.2)
Loading from cache
- Installing bower-asset/bootstrap (v3.3.5)
Loading from cache
- Installing bower-asset/remarkable-bootstrap-notify (3.1.3)
Loading from cache
- Installing bower-asset/yii2-pjax (v2.0.4)
Loading from cache
- Installing cebe/markdown (1.1.0)
Loading from cache
- Installing ezyang/htmlpurifier (v4.6.0)
Loading from cache
- Installing yiisoft/yii2 (2.0.6)
Loading from cache
- Installing yiisoft/yii2-bootstrap (2.0.5)
Loading from cache
- Installing bower-asset/fontawesome (v4.4.0)
Loading from cache
- Installing rmrevin/yii2-fontawesome (2.12.2)
Loading from cache
- Installing cebe/yii2-gravatar (1.1)
Loading from cache
- Installing almasaeed2010/adminlte (v2.3.2)
Loading from cache
- Installing dmstr/yii2-adminlte-asset (2.2.4)
Loading from cache
- Installing kartik-v/bootstrap-fileinput (v4.2.7)
Loading from cache
- Installing kartik-v/bootstrap-star-rating (v3.5.4)
Loading from cache
- Installing kartik-v/dependent-dropdown (v1.4.3)
Loading from cache
- Installing kartik-v/yii2-krajee-base (v1.7.7)
Loading from cache
- Installing kartik-v/yii2-widget-typeahead (v1.0.1)
Loading from cache
- Installing kartik-v/yii2-widget-touchspin (v1.2.0)
Loading from cache
- Installing kartik-v/yii2-widget-timepicker (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-switchinput (v1.3.0)
Loading from cache
- Installing kartik-v/yii2-widget-spinner (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-sidenav (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-select2 (v2.0.3)
Loading from cache
- Installing kartik-v/yii2-widget-rating (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-rangeinput (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-growl (v1.1.1)
Loading from cache
- Installing kartik-v/yii2-widget-fileinput (v1.0.3)
Loading from cache
- Installing kartik-v/yii2-widget-depdrop (v1.0.2)
Loading from cache
- Installing kartik-v/yii2-widget-datetimepicker (v1.4.0)
Loading from cache
- Installing kartik-v/yii2-widget-datepicker (v1.3.3)
Loading from cache
- Installing kartik-v/yii2-widget-colorinput (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-alert (v1.1.0)
Loading from cache
- Installing kartik-v/yii2-widget-affix (v1.0.0)
Loading from cache
- Installing kartik-v/yii2-widget-activeform (v1.4.5)
Loading from cache
- Installing kartik-v/yii2-widgets (v3.4.0)
Loading from cache
- Installing bower-asset/jquery-ui (1.11.4)
Loading from cache
- Installing yiisoft/yii2-jui (2.0.4)
Loading from cache
- Installing swiftmailer/swiftmailer (v5.4.1)
Loading from cache
- Installing yiisoft/yii2-swiftmailer (2.0.4)
Loading from cache
- Installing yiisoft/yii2-codeception (2.0.4)
Loading from cache
- Installing yiisoft/yii2-debug (2.0.5)
Loading from cache
- Installing fzaninotto/faker (v1.5.0)
Loading from cache
- Installing yiisoft/yii2-faker (2.0.3)
Loading from cache
- Installing phpspec/php-diff (v1.0.2)
Loading from cache
- Installing bower-asset/typeahead.js (v0.10.5)
Loading from cache
- Installing yiisoft/yii2-gii (2.0.4)
Loading from cache
fzaninotto/faker suggests installing ext-intl (*)
Generating autoload files

View File

@ -0,0 +1,44 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m151129_101441_add_table_key extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%key}}', [
'id_key' => $this->primaryKey(),
'number' => $this->string(255),
'status' => $this->smallInteger(),
'type' => $this->smallInteger(),
'created_at' => $this->dateTime()->notNull(),
'updated_at' => $this->dateTime()->notNull(),
], $tableOptions);
}
public function down()
{
echo "m151129_101441_add_table_key cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -87,7 +87,7 @@ class ProductSaleForm extends Model
[['comment'], 'string' ,'max' => 255],
[['cart'], 'string' ,'max' => 20],
[['id_product' ], 'validateProduct'],
[['count' ], 'validateCount'],
// [['count' ], 'validateCount'],
[['id_currency' ], 'validateCurrency'],
[['id_account' ], 'validateAccount'],
[['id_discount' ], 'validateDiscount'],

View File

@ -28,7 +28,7 @@ function AccountState(o){
$.extend(app.defaults, o );
notes = $(app.defaults.notes);
moneyInput = $(app.defaults.selector_money);
notes.change(run);
notes.change(runNote);
moneyInput.change(run);
if ( app.defaults.open ){
ddAccount = $(app.defaults.selector_dd_account);
@ -40,8 +40,17 @@ function AccountState(o){
function run(){
function runNote(){
run("note");
}
function run(what ){
calcTotal();
if ( what == 'note' ){
setMoneyAsTotal();
}else{
readMoney();
}
calcDiff();
calcAccount();
calcLastDiff();
@ -51,6 +60,7 @@ function AccountState(o){
updateLastMoney();
updateLastDiff();
updatePrevState();
}
function calcAccount(){
@ -68,12 +78,21 @@ function AccountState(o){
app.diff = Math.abs(app.last_money - app.money );
}
function calcDiff(){
function setMoneyAsTotal(){
app.money = app.total;
}
function readMoney(){
app.money = 0;
app.money = +moneyInput.val();
if ( isNaN(money)){
app.money = 0;
}
}
function calcDiff(){
app.diff = Math.abs(app.total - app.money );
}
@ -103,6 +122,7 @@ function AccountState(o){
var money;
money = accounting.formatNumber(app.money, 0, " "); // 9 876 543.210
$('.money').html(money);
$('#accountstate-money').val(money);
}
function updateLastMoney(){

0
tests/codeception/bin/yii Normal file → Executable file
View File