add city, customer and card model + crud

This commit is contained in:
rocho 2015-09-27 21:35:31 +02:00
parent 8ee256314b
commit 7df9800fec
42 changed files with 6765 additions and 2 deletions

View File

@ -42,6 +42,8 @@ class AdminMenuStructure{
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
if ( count($items) > 0 ){
$userMainMenu = ['label' => 'Beállítások', 'url' => null,

View File

@ -0,0 +1,159 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Card;
use backend\models\CardSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use common\models\Customer;
use yii\helpers\Json;
/**
* CardController implements the CRUD actions for Card model.
*/
class CardController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Card models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CardSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Card model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Card model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Card();
$model->status = Card::STATUS_ACTIVE;
$model->type = Card::TYPE_RFID;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_card]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Card 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_card]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Card 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 Card model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Card the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Card::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Your controller action to fetch the list
*/
public function actionList($search = null) {
$query = new Query();
$query->select ( [
'card.number as number',
'customer.name as name',
"concat( card.number , case when customer.name is null then '' else customer.name end ) as txt ",
] )->from (Card::tableName() )->join("left join", Customer::tableName(), 'card.id_card = customer.id_customer_card')->where ( ' lower(number) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'number' ) ;
if ( isset($_GET['onlyFree']) && $_GET['onlyFree'] == '1'){
$query->andWhere( 'customer.id_customer is null' );
}
$command = $query->createCommand ();
$data = $command->queryAll ();
$out = [ ];
foreach ( $data as $d ) {
$out [] = [
'number' => $d ['number'],
'name' => $d ['name'],
'txt' => $d ['txt'],
];
}
echo Json::encode ( $out );
}
}

View File

@ -0,0 +1,172 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\City;
use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\Json;
/**
* CityController implements the CRUD actions for City model.
*/
class CityController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all City models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CitySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single City model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new City model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new City();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_city]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing City 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_city]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing City 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 City model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return City the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = City::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Your controller action to fetch the list
*/
public function actionNameList($search = null) {
$query = new Query();
$query->select ( [
'name',
'min(zip) as zip',
'concat( zip, \' \', name) as fullname'
] )->from (City::tableName() )->where ( ' lower(name) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'name' )->groupBy('name')->limit(20);
$command = $query->createCommand ();
$data = $command->queryAll ();
$out = [ ];
foreach ( $data as $d ) {
$out [] = [
'name' => $d ['name'],
'zip' => $d ['zip'],
'fullname' => $d ['fullname'],
];
}
echo Json::encode ( $out );
}
/**
* Your controller action to fetch the list
*/
public function actionZipList($search = null) {
$query = new Query();
$query->select ( [
'name',
'min(zip) as zip',
'concat( zip, \' \', name) as fullname'
] )->from (City::tableName() )->where ( ' lower(zip) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'name' )->groupBy('name')->limit(20);
$command = $query->createCommand ();
$data = $command->queryAll ();
$out = [ ];
foreach ( $data as $d ) {
$out [] = [
'name' => $d ['name'],
'zip' => $d ['zip'],
'fullname' => $d ['fullname'],
];
}
echo Json::encode ( $out );
}
}

View File

@ -0,0 +1,131 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Customer;
use backend\models\CustomerSearch;
use backend\models\CustomerCreate;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use backend\models\CustomerUpdate;
/**
* CustomerController implements the CRUD actions for Customer model.
*/
class CustomerController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Customer models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CustomerSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Customer model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Customer model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new CustomerCreate();
$model->country = "Magyarország";
$model->id_user = Yii::$app->user->id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_customer]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Customer model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
if (($model = CustomerUpdate::findOne($id)) == null) {
throw new NotFoundHttpException('The requested page does not exist.');
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_customer]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Customer 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 Customer model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Customer the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Customer::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Card;
use common\models\Customer;
/**
* CardSearch represents the model behind the search form about `common\models\Card`.
*/
class CardSearch extends Card
{
public $searchCustomerName;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_card', 'status', 'type'], 'integer'],
[[ 'searchCustomerName', '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 = Card::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$dataProvider->sort ->attributes['customerName'] =[
'asc' => ['customer.name' => SORT_ASC ],
'desc' => ['customer.name' => SORT_DESC ],
];
$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->leftJoin(Customer::tableName(), 'customer.id_customer_card = card.id_card');
$query->andFilterWhere([
'card.status' => $this->status,
'card.type' => $this->type,
]);
$query->andFilterWhere(['like', 'card.number', $this->number]);
$query->andFilterWhere(['like', 'customer.name', $this->searchCustomerName]);
return $dataProvider;
}
public function attributeLabels(){
$result = parent::attributeLabels();
$result +=[
'searchCustomerName' => Yii::t('common/card','Customer')
];
return $result;
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\City;
/**
* CitySearch represents the model behind the search form about `common\models\City`.
*/
class CitySearch extends City
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_city', 'cso_code', 'rig_id', 'population', 'homes'], 'integer'],
[['zip', 'name', 'city_code'], 'safe'],
[['latitude', 'longitude', 'range'], 'number'],
];
}
/**
* @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 = City::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_city' => $this->id_city,
'latitude' => $this->latitude,
'longitude' => $this->longitude,
'cso_code' => $this->cso_code,
'rig_id' => $this->rig_id,
'range' => $this->range,
'population' => $this->population,
'homes' => $this->homes,
]);
$query->andFilterWhere(['like', 'zip', $this->zip])
->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'city_code', $this->city_code]);
return $dataProvider;
}
}

View File

@ -0,0 +1,117 @@
<?php
namespace backend\models;
use Yii;
use common\models\Customer;
use common\models\Card;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property string $cardNumber
*/
class CustomerCreate extends \common\models\Customer
{
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cardNumber'], 'required' ],
[['cardNumber'], 'string', 'max' => 10],
[['cardNumber'], 'validateCustomerCard' ],
[['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ],
[['name'], 'required' ],
[['name'], 'string', 'max' => 128],
[['email'], 'string', 'max' => 255],
[['email'], 'email' ],
[['email'], 'unique' ],
[['password_plain','password_repeat'], 'string', 'max' => 32],
[['sex'], 'integer'],
[[ 'birthdate', ], 'date' ],
[[ 'date_stundent_card_expire', ], 'date' ],
[[ 'description', 'address'], 'string', 'max' => 255],
[['phone', 'tax_number', 'country'], 'string', 'max' => 20],
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30]
];
}
public function validateCustomerCard($a,$p){
$card = null;
if ( !empty($this->cardNumber)){
$card = Card::readCard($this->cardNumber,true);
}
if ( $card == null ){
$this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám"));
}else{
$this->id_customer_card = $card->id_card;
}
// $this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám"));
}
public function validatePartnerCard($a,$p){
if ( !empty($this->partnerCardNumber) ){
$card = Card::readCard($this->partnerCardNumber,true);
if ( $card == null ){
$this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám"));
}else{
$this->id_partner_card = $card->id_card;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Customer;
use common\models\Card;
/**
* CustomerSearch represents the model behind the search form about `common\models\Customer`.
*/
class CustomerSearch extends Customer
{
public $cardNumber;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cardNumber', 'name', 'email'] ,'safe']
// [['id_customer', 'id_customer_card', 'id_user', 'id_partner_card', 'id_proposer', 'sex'], 'integer'],
// [['name', 'email', 'password', 'phone', 'date_stundent_card_expire', 'birthdate', 'image', 'description', 'tax_number', 'country', 'zip', 'city', 'address', '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 = Customer::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$dataProvider->sort ->attributes['customerCardNumber'] =[
'asc' => ['card.number' => SORT_ASC ],
'desc' => ['card.number' => SORT_DESC ],
];
$dataProvider->sort->defaultOrder = [
'name' => SORT_ASC,
];
// $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);
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->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])
->andFilterWhere(['like', 'card.number', $this->cardNumber])
->andFilterWhere(['like', 'address', $this->address]);
return $dataProvider;
}
public function attributeLabels( ) {
$labels = parent::attributeLabels();
return $labels;
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace backend\models;
use Yii;
use common\models\Customer;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property string $cardNumber
*/
class CustomerUpdate extends \common\models\Customer
{
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
// [['cardNumber'], 'required' ],
// [['cardNumber'], 'string', 'max' => 10],
// [['cardNumber'], 'validateCustomerCard' ],
[['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ],
[['name'], 'required' ],
[['name'], 'string', 'max' => 128],
[['email'], 'string', 'max' => 255],
[['email'], 'email' ],
[['email'], 'unique' ],
[['password_plain','password_repeat'], 'string', 'max' => 32],
[['sex'], 'integer'],
[[ 'birthdate', ], 'date' ],
[[ 'date_stundent_card_expire', ], 'date' ],
[[ 'description', 'address'], 'string', 'max' => 255],
[['phone', 'tax_number', 'country'], 'string', 'max' => 20],
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30]
];
}
public function validateCustomerCard($a,$p){
// Customer::find()->andWhere( [$this->cardNumber )
}
public function validatePartnerCard($a,$p){
// Customer::find()->andWhere( [$this->cardNumber )
}
}

View File

@ -0,0 +1,29 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Card;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="card-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'number')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(Card::statuses()) ?>
<?= $form->field($model, 'type')->dropDownList(Card::types()) ?>
<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']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,60 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Card;
/* @var $this yii\web\View */
/* @var $model backend\models\CardSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
function mkOptions($options){
$all = ['' => Yii::t('common/product','All' ) ];
$o = $all + $options;
return $o;
}
$typeOptions = mkOptions(Card::types());
$statusOptions = mkOptions(Card::statuses());
?>
<div class="card-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'number') ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'status')->dropDownList($statusOptions) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'type')->dropDownList($typeOptions) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'searchCustomerName')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/card', 'Search'), ['class' => 'btn btn-primary']) ?>
</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\Card */
$this->title = Yii::t('common/card', 'Create Card');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="card-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,52 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CardSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/card', 'Cards');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="card-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/card', 'Create Card'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'number',
'value' => 'number'
],
[
'attribute' => 'status',
'value' => 'statusHuman'
],
[
'attribute' => 'type',
'value' => 'typeHuman'
],
[
'attribute' => 'customerName',
'value' => 'customerName'
],
'updated_at:datetime',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}{update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @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->params['breadcrumbs'][] = Yii::t('common/card', 'Update');
?>
<div class="card-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,32 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Card */
$this->title = Yii::t('common/card','Card: ').$model->number;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="card-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/card', 'Update'), ['update', 'id' => $model->id_card], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'number',
['attribute' => 'status', 'value' => $model->statusHuman],
['attribute' => 'type', 'value' => $model->typeHuman],
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

View File

@ -0,0 +1,41 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\City */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="city-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'zip')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'city_code')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'latitude')->textInput() ?>
<?= $form->field($model, 'longitude')->textInput() ?>
<?= $form->field($model, 'cso_code')->textInput() ?>
<?= $form->field($model, 'rig_id')->textInput() ?>
<?= $form->field($model, 'range')->textInput() ?>
<?= $form->field($model, 'population')->textInput() ?>
<?= $form->field($model, 'homes')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/city', 'Create') : Yii::t('common/city', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\CitySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="city-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_city') ?>
<?= $form->field($model, 'zip') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'city_code') ?>
<?= $form->field($model, 'latitude') ?>
<?php // echo $form->field($model, 'longitude') ?>
<?php // echo $form->field($model, 'cso_code') ?>
<?php // echo $form->field($model, 'rig_id') ?>
<?php // echo $form->field($model, 'range') ?>
<?php // echo $form->field($model, 'population') ?>
<?php // echo $form->field($model, 'homes') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/city', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('common/city', '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\City */
$this->title = Yii::t('common/city', 'Create City');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="city-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/city', 'Cities');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="city-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/city', 'Create City'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id_city',
'zip',
'name',
'city_code',
'latitude',
// 'longitude',
// 'cso_code',
// 'rig_id',
// 'range',
// 'population',
// 'homes',
['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\City */
$this->title = Yii::t('common/city', 'Update {modelClass}: ', [
'modelClass' => 'City',
]) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_city]];
$this->params['breadcrumbs'][] = Yii::t('common/city', 'Update');
?>
<div class="city-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,45 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\City */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/city', 'Cities'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="city-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/city', 'Update'), ['update', 'id' => $model->id_city], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('common/city', 'Delete'), ['delete', 'id' => $model->id_city], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('common/city', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_city',
'zip',
'name',
'city_code',
'latitude',
'longitude',
'cso_code',
'rig_id',
'range',
'population',
'homes',
],
]) ?>
</div>

View File

@ -0,0 +1,61 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_customer_card')->textInput() ?>
<?= $form->field($model, 'id_user')->textInput() ?>
<?= $form->field($model, 'id_partner_card')->textInput() ?>
<?= $form->field($model, 'id_proposer')->textInput() ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sex')->textInput() ?>
<?= $form->field($model, 'date_stundent_card_expire')->textInput() ?>
<?= $form->field($model, 'birthdate')->textInput() ?>
<?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'zip')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'city')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,128 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Customer;
use common\components\CityNameTypeahead;
use common\components\CityZipTypeahead;
use common\components\CardNumberTypeahead;
use kartik\widgets\DatePicker;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<div class='row'>
<div class='col-md-3'>
<?php echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'partnerCardNumber')->textInput() ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-2'>
<?= $form->field($model, 'zip')->widget(CityZipTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-city').typeahead( 'val', b.name );
}",]
])?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'city')->widget(CityNameTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-zip').typeahead( 'val', b.zip );
}",]
])?>
</div>
</div>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,132 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Customer;
use common\components\CityNameTypeahead;
use common\components\CityZipTypeahead;
use common\components\CardNumberTypeahead;
use kartik\widgets\DatePicker;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<div class='row'>
<div class='col-md-3'>
<?php //echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
<label><?php echo $model->getAttributeLabel('id_customer_card')?></label>
<div>
<?php echo $model->customerCardNumber ?>
</div>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'partnerCardNumber')->textInput() ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-2'>
<?= $form->field($model, 'zip')->widget(CityZipTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-city').typeahead( 'val', b.name );
}",]
])?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'city')->widget(CityNameTypeahead::className(),[
'pluginEvents' =>[
"typeahead:select" => "function(a,b) {
$('#customercreate-zip').typeahead( 'val', b.zip );
}",]
])?>
</div>
</div>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\CustomerSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="customer-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class='row'>
<div class='col-md-4'>
<?= $form->field($model, 'cardNumber') ?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'name') ?>
</div>
<div class='col-md-4'>
<?php echo $form->field($model, 'email') ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/customer', 'Search'), ['class' => 'btn btn-primary']) ?>
</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\Customer */
$this->title = Yii::t('common/customer', 'Create Customer');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_create', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,56 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CustomerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/customer', 'Customers');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/customer', 'Create Customer'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'customerCardNumber' ,
// 'value' => 'customerCardNumber'
],
// 'id_user',
// 'id_partner_card',
// 'id_proposer',
'name',
'email:email',
// 'password',
'phone',
// 'sex',
// 'date_stundent_card_expire',
// 'birthdate',
// 'image',
// 'description',
// 'tax_number',
// 'country',
// 'zip',
// 'city',
// 'address',
'created_at:datetime',
// 'updated_at',
['class' => 'yii\grid\ActionColumn',
'template' =>'{view}{update}'
],
],
]); ?>
</div>

View File

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

View File

@ -0,0 +1,56 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/customer', 'Update'), ['update', 'id' => $model->id_customer], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'id_customer_card',
'value' => $model->customerCardNumber
],
[
'attribute' => 'id_user',
'value' => $model->username
],
'id_partner_card',
'id_proposer',
'name',
'email:email',
'password',
'phone',
[
'attribute' => 'sex',
'value' => $model->sexHuman
],
'date_stundent_card_expire',
'birthdate:date',
'image',
'description',
'tax_number',
'country',
'zip',
'city',
'address',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

View File

@ -0,0 +1,52 @@
<?php
namespace common\components;
use Yii;
use kartik\widgets\Typeahead;
use yii\helpers\Url;
use yii\web\JsExpression;
class CardNumberTypeahead extends Typeahead{
public $item_template = '<div><p class="">{{txt}}</p></div>';
public $options = ['placeholder' => 'Válassz bérletkártyát!'];
public $pluginOptions = ['highlight'=>true , 'minLength' => 3 ];
public $scrollable = true;
public $display = 'number';
public $pluginEvents = [ "typeahead:select" => "function(a,b) { }",];
public $onlyFreeCards = true;
public function init(){
parent::init();
$this->dataset = $this->createDefaultDataset();
}
protected function createDefaultDataset(){
return [
[
'limit' => 20,
'remote' => [
'ttl' => 1,
'url' => Url::to(['card/list']) . '&onlyFree='.($this->onlyFreeCards ? '1' :'0').'&search=%QUERY&' . rand(0, 100000000),
'wildcard' => '%QUERY'
],
'limit' => 10,
'display' => $this->display,
'templates' => [
'notFound' => '<div class="text-danger" style="padding:0 8px">Unable to find number for selected query.</div>',
'suggestion' => new JsExpression("Handlebars.compile('{$this->item_template}')")
]
]
];
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace common\components;
use Yii;
use kartik\widgets\Typeahead;
use yii\helpers\Url;
use yii\web\JsExpression;
class CityNameTypeahead extends Typeahead{
public $item_template = '<div><p class="">{{fullname}}</p></div>';
public $options = ['placeholder' => 'Válassz várost'];
public $pluginOptions = ['highlight'=>true];
public $scrollable = true;
public $display = 'name';
public $pluginEvents = [ "typeahead:select" => "function(a,b) { }",];
public function init(){
parent::init();
$this->dataset = $this->createDefaultDataset();
}
protected function createDefaultDataset(){
return [
[
'limit' => 20,
'remote' => [
'ttl' => 1,
'url' => Url::to(['city/name-list']) . '&search=%QUERY&' . rand(0, 100000000),
'wildcard' => '%QUERY'
],
'limit' => 10,
'display' => $this->display,
'templates' => [
'notFound' => '<div class="text-danger" style="padding:0 8px">Unable to find repositories for selected query.</div>',
'suggestion' => new JsExpression("Handlebars.compile('{$this->item_template}')")
]
]
];
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace common\components;
use Yii;
use kartik\widgets\Typeahead;
use yii\helpers\Url;
use yii\web\JsExpression;
class CityZipTypeahead extends Typeahead{
public $item_template = '<div><p class="">{{fullname}}</p></div>';
public $options = ['placeholder' => 'Válassz irányítószám'];
public $pluginOptions = ['highlight'=>true];
public $scrollable = true;
public $display = 'zip';
public $pluginEvents = [ "typeahead:select" => "function(a,b) { }",];
public function init(){
parent::init();
$this->dataset = $this->createDefaultDataset();
}
protected function createDefaultDataset(){
return [
[
'limit' => 20,
'remote' => [
'ttl' => 1,
'url' => Url::to(['city/zip-list']) . '&search=%QUERY&' . rand(0, 100000000),
'wildcard' => '%QUERY'
],
'limit' => 10,
'display' => $this->display,
'templates' => [
'notFound' => '<div class="text-danger" style="padding:0 8px">Unable to find repositories for selected query.</div>',
'suggestion' => new JsExpression("Handlebars.compile('{$this->item_template}')")
]
]
];
}
}

4154
common/data/telepulesek.txt Normal file

File diff suppressed because it is too large Load Diff

137
common/models/Card.php Normal file
View File

@ -0,0 +1,137 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "card".
*
* @property integer $id_card
* @property string $number
* @property integer $status
* @property integer $type
* @property string $created_at
* @property string $updated_at
*/
class Card extends \common\models\BaseFitnessActiveRecord
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
const TYPE_RFID = 10;
const TYPE_QRCODE = 20;
const TYPE_BARCODE = 30;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'card';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['number', 'type','status'], 'required'],
[['status', 'type'], 'integer'],
[['number'], 'string', 'max' => 20],
[['number'], 'unique' ]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_card' => Yii::t('common/card', 'Id Card'),
'number' => Yii::t('common/card', 'Number'),
'status' => Yii::t('common/card', 'Status'),
'type' => Yii::t('common/card', 'Type'),
'created_at' => Yii::t('common/card', 'Created At'),
'updated_at' => Yii::t('common/card', 'Updated At'),
];
}
static function statuses() {
return [
self::STATUS_ACTIVE => Yii::t('common/card', 'Active'),
self::STATUS_DELETED => Yii::t('common/card', 'Inactive'),
];
}
public function getStatusHuman(){
$result = null;
$s = self::statuses($this->status);
if ( array_key_exists($this->status, $s)){
$result = $s[$this->status];
}
return $result;
}
static function types() {
return [
self::TYPE_RFID => Yii::t('common/card', 'RFID'),
self::TYPE_QRCODE => Yii::t('common/card', 'QRCODE'),
self::TYPE_BARCODE => Yii::t('common/card', 'BARCODE'),
];
}
public function getTypeHuman(){
$result = null;
$s = self::types($this->type);
if ( array_key_exists($this->type, $s)){
$result = $s[$this->type];
}
return $result;
}
public function isInactive(){
return $this->status == self::STATUS_DELETED;
}
public static function readCard($number,$free = null){
$card = null;
$query = Card::find()
->leftJoin(Customer::tableName(), 'card.id_card = customer.id_customer_card ' )
->andWhere(['number'=>$number ]);
if ( isset($free) ){
if ( $free == true){
$query->andWhere('customer.id_customer is null');
}else{
$query->andWhere('customer.id_customer is not null');
}
}
$cards = $query->all();
if ( count($cards) == 1){
$card = $cards[0];
}
return $card;
}
public function getCustomer(){
return $this->hasOne(Customer::className(), ['id_customer_card' => 'id_card']);
}
public function getCustomerName(){
$name = null;
$customer = $this->customer;
if ( $this->customer != null){
$name = $this->customer->name;
}
return $name;
}
}

66
common/models/City.php Normal file
View File

@ -0,0 +1,66 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "city".
*
* @property integer $id_city
* @property string $zip
* @property string $name
* @property string $city_code
* @property double $latitude
* @property double $longitude
* @property integer $cso_code
* @property integer $rig_id
* @property double $range
* @property integer $population
* @property integer $homes
*/
class City extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'city';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['zip', 'name', 'city_code'], 'required'],
[['latitude', 'longitude', 'range'], 'number'],
[['cso_code', 'rig_id', 'population', 'homes'], 'integer'],
[['zip'], 'string', 'max' => 8],
[['name'], 'string', 'max' => 64],
[['city_code'], 'string', 'max' => 2]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_city' => Yii::t('common/city', 'Id City'),
'zip' => Yii::t('common/city', 'Zip'),
'name' => Yii::t('common/city', 'Name'),
'city_code' => Yii::t('common/city', 'City Code'),
'latitude' => Yii::t('common/city', 'Latitude'),
'longitude' => Yii::t('common/city', 'Longitude'),
'cso_code' => Yii::t('common/city', 'Cso Code'),
'rig_id' => Yii::t('common/city', 'Rig ID'),
'range' => Yii::t('common/city', 'Range'),
'population' => Yii::t('common/city', 'Population'),
'homes' => Yii::t('common/city', 'Homes'),
];
}
}

168
common/models/Customer.php Normal file
View File

@ -0,0 +1,168 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
*/
class Customer extends \yii\db\ActiveRecord
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
const SEX_UNKNOWN = 0;
const SEX_MAN = 10;
const SEX_WOMAN = 20;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_customer_card', 'id_user', 'id_partner_card', 'id_proposer', 'sex'], 'integer'],
[['date_stundent_card_expire', 'birthdate', 'created_at', 'updated_at'], 'safe'],
[['name'], 'string', 'max' => 128],
[['email', 'image', 'description', 'address'], 'string', 'max' => 255],
[['password'], 'string', 'max' => 32],
[['phone', 'tax_number', 'country'], 'string', 'max' => 20],
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_customer' => Yii::t('common/customer', 'Id Customer'),
'id_customer_card' => Yii::t('common/customer', 'Id Customer Card'),
'id_user' => Yii::t('common/customer', 'Id User'),
'id_partner_card' => Yii::t('common/customer', 'Id Partner Card'),
'id_proposer' => Yii::t('common/customer', 'Id Proposer'),
'name' => Yii::t('common/customer', 'Name'),
'email' => Yii::t('common/customer', 'Email'),
'password' => Yii::t('common/customer', 'Password'),
'phone' => Yii::t('common/customer', 'Phone'),
'sex' => Yii::t('common/customer', 'Sex'),
'date_stundent_card_expire' => Yii::t('common/customer', 'Date Stundent Card Expire'),
'birthdate' => Yii::t('common/customer', 'Birthdate'),
'image' => Yii::t('common/customer', 'Image'),
'description' => Yii::t('common/customer', 'Description'),
'tax_number' => Yii::t('common/customer', 'Tax Number'),
'country' => Yii::t('common/customer', 'Country'),
'zip' => Yii::t('common/customer', 'Zip'),
'city' => Yii::t('common/customer', 'City'),
'address' => Yii::t('common/customer', 'Address'),
'created_at' => Yii::t('common/customer', 'Created At'),
'updated_at' => Yii::t('common/customer', 'Updated At'),
'customerCardNumber' => Yii::t('common/customer', 'Card number'),
];
}
static function statuses() {
return [
self::STATUS_ACTIVE => Yii::t('common/account', 'Active'),
self::STATUS_DELETED => Yii::t('common/account', 'Inactive'),
];
}
public function getStatusHuman(){
$result = null;
$s = self::statuses($this->status);
if ( array_key_exists($this->status, $s)){
$result = $s[$this->status];
}
return $result;
}
static function sexes() {
return [
self::SEX_UNKNOWN => Yii::t('common/sex', 'Nincs megadva'),
self::SEX_MAN => Yii::t('common/sex', 'Férfi'),
self::SEX_WOMAN => Yii::t('common/sex', 'Nő'),
];
}
public function getSexHuman(){
$result = null;
$s = self::sexes( );
if ( array_key_exists($this->sex, $s)){
$result = $s[$this->sex];
}
return $result;
}
public function isInactive(){
return $this->status == self::STATUS_DELETED;
}
public function getCard(){
return $this->hasOne ( Card::className (), [
'id_card' => 'id_customer_card'
] );
}
public function getUser(){
return $this->hasOne ( User::className (), [
'id' => 'id_user'
] );
}
public function getCustomerCardNumber(){
$result = null;
$card = $this->card;
if ( $card != null) {
$result = $card->number;
}
return $result;
}
public function getUsername(){
$result = null;
$user = $this->user;
if ( $user != null) {
$result = $user->username;
}
return $result;
}
}

View File

@ -18,7 +18,8 @@
"yiisoft/yii2": ">=2.0.6",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"kartik-v/yii2-widgets": "^3.4"
"kartik-v/yii2-widgets": "^3.4",
"kartik-v/yii2-widget-typeahead": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",

2
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "123abf1f9516a179624bd311ea413a81",
"hash": "f2a471b84002daca5d3a31691f578c78",
"packages": [
{
"name": "bower-asset/bootstrap",

View File

@ -0,0 +1,48 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150925_194508_add__table__customer 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('{{%customer}}', [
'id_customer' => $this->primaryKey(),
'id_customer_card' => $this->integer(),
'id_user' => $this->integer(),
'id_partner_card' => $this->integer(),
'id_proposer' =>$this->integer(),
'name' => $this->string(128),
'email' => $this->string(255),
'password' => $this->string(32),
'phone' => $this->string(20),
'sex' => $this->smallInteger(),
'date_stundent_card_expire' => $this->date(),
'birthdate' => $this->date(),
'image' => $this->string(255),
'description' => $this->string(255),
'tax_number' => $this->string(20),
'country' => $this->string(20),
'zip' => $this->string(8),
'city' => $this->string(30),
'address' => $this->string(255),
'created_at' => $this->timestamp()->notNull(),
'updated_at' => $this->timestamp()->notNull(),
], $tableOptions);
}
public function down()
{
echo "m150925_194508_add__table__customer cannot be reverted.\n";
return false;
}
}

View File

@ -0,0 +1,43 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150925_201715_add__table__card 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('{{%card}}', [
'id_card' => $this->primaryKey(),
'number' => $this->string(20)->notNull(),
'status' => $this->smallInteger()->notNull()->defaultValue(10),
'type' => $this->integer(11)->notNull(),
'created_at' => $this->timestamp()->notNull(),
'updated_at' => $this->timestamp()->notNull(),
], $tableOptions);
}
public function down()
{
echo "m150925_201715_add__table__card cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -0,0 +1,59 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150926_123638_add__table__city 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('{{%city}}', [
'id_city' => $this->primaryKey(),
'zip' => $this->string(8)->notNull(),
'name' => $this->string(64)->notNull(),
'city_code' => $this->string(2)->notNull(),
'latitude' => $this->float(),
'longitude' => $this->float() ,
'cso_code' => $this->integer(11) ,
'rig_id' => $this->integer(11) ,
'range' => $this->float() ,
'population' =>$this->integer(11) ,
'homes' => $this->integer(11) ,
], $tableOptions);
}
public function down()
{
echo "m150926_123638_add__table__city cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
id_city
zip
name
city_code
latitude
longitude
cso_code
rig_id
cit_range
population
homes
}
public function safeDown()
{
}
*/
}

File diff suppressed because one or more lines are too long