Add contract parts
add procurement create prevent enter to product field
This commit is contained in:
parent
a00331ce7c
commit
7b4fe04229
29
backend/assets/ProcurementCreateAsset.php
Normal file
29
backend/assets/ProcurementCreateAsset.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace backend\assets;
|
||||||
|
|
||||||
|
use yii\web\AssetBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
class ProcurementCreateAsset extends AssetBundle
|
||||||
|
{
|
||||||
|
public $basePath = '@webroot';
|
||||||
|
public $baseUrl = '@web';
|
||||||
|
public $css = [
|
||||||
|
];
|
||||||
|
public $js = [
|
||||||
|
'js/app.js',
|
||||||
|
'js/procurement.create.js',
|
||||||
|
];
|
||||||
|
public $depends = [
|
||||||
|
'backend\assets\AppAsset',
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -10,6 +10,8 @@ use yii\web\NotFoundHttpException;
|
|||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use backend\models\ContractCustomerSearch;
|
use backend\models\ContractCustomerSearch;
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
|
use yii\db\Query;
|
||||||
|
use backend\models\ContractRequestSearch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContractController implements the CRUD actions for Contract model.
|
* ContractController implements the CRUD actions for Contract model.
|
||||||
@ -125,6 +127,31 @@ class ContractController extends Controller
|
|||||||
return $this->redirect(['index']);
|
return $this->redirect(['index']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function actionDetails( $id )
|
||||||
|
{
|
||||||
|
$contract = Contract::findOne($id);
|
||||||
|
//ticket_installment_request
|
||||||
|
|
||||||
|
|
||||||
|
if ( !isset($contract)){
|
||||||
|
throw new NotFoundHttpException('The requested page does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$searchModel = new ContractRequestSearch(
|
||||||
|
['contract' => $contract]
|
||||||
|
);
|
||||||
|
|
||||||
|
// $searchModel->contract = $contract;
|
||||||
|
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
return $this->render('details', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the Contract model based on its primary key value.
|
* Finds the Contract model based on its primary key value.
|
||||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
|||||||
58
backend/models/ContractRequestSearch.php
Normal file
58
backend/models/ContractRequestSearch.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use common\models\TicketInstallmentRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TicketInstallmentRequestSearch represents the model behind the search form about `common\models\TicketInstallmentRequest`.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @property common\models\Contract $contract
|
||||||
|
*/
|
||||||
|
class ContractRequestSearch extends TicketInstallmentRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
public $contract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[[ 'id_contract', 'id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type','id_ugiro'], 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 = TicketInstallmentRequest::find();
|
||||||
|
|
||||||
|
$query->andWhere( ['ticket_installment_request.id_contract' => $this->contract->id_contract ]);
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $query,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
||||||
36
backend/views/contract/details.php
Normal file
36
backend/views/contract/details.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use common\models\TicketInstallmentRequest;
|
||||||
|
?>
|
||||||
|
Részletek
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
echo GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => 'id_ticket_installment_request' ,
|
||||||
|
'label' => 'Részlet azonosító'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'request_target_time_at' ,
|
||||||
|
'label' => 'Esedékességi dátum',
|
||||||
|
'format' => 'date'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'priority' ,
|
||||||
|
'label' => 'Sorszám'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'status' ,
|
||||||
|
'label' => 'Státusz',
|
||||||
|
'value' => function ($model, $key, $index, $column){
|
||||||
|
return TicketInstallmentRequest::toStatusName($model->status);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
?>
|
||||||
@ -3,6 +3,7 @@
|
|||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
use common\models\Contract;
|
use common\models\Contract;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\models\ContractSearch */
|
/* @var $searchModel backend\models\ContractSearch */
|
||||||
@ -79,6 +80,23 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'label' =>'Lejárat',
|
'label' =>'Lejárat',
|
||||||
'format' => 'date'
|
'format' => 'date'
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'class' => 'yii\grid\ActionColumn',
|
||||||
|
'template' =>'{details}',
|
||||||
|
'urlCreator' => function ($action, $model, $key, $index){
|
||||||
|
$result = "";
|
||||||
|
if ( $action == 'details' ){
|
||||||
|
$result = Url::toRoute(['contract/details','id' => $model['contract_id_contract']]);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
},
|
||||||
|
'buttons' => [
|
||||||
|
'details' => function ($url, $model, $key) {
|
||||||
|
return Html::a('Részletek', $url , ['class' => 'btn btn-primary btn-xs' ]) ;
|
||||||
|
},
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
use backend\assets\ProcurementCreateAsset;
|
||||||
|
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
@ -10,6 +11,11 @@ use yii\helpers\Html;
|
|||||||
$this->title = Yii::t('common/procurement', 'Create Procurement');
|
$this->title = Yii::t('common/procurement', 'Create Procurement');
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/procurement', 'Procurements'), 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/procurement', 'Procurements'), 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
|
||||||
|
ProcurementCreateAsset::register($this);
|
||||||
|
|
||||||
|
$this->registerJs(' new ProcurementCreate( { } );');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="procurement-create">
|
<div class="procurement-create">
|
||||||
|
|
||||||
|
|||||||
26
backend/web/js/app.js
Normal file
26
backend/web/js/app.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function doPreventSubmit($selector){
|
||||||
|
$($selector).keydown(function(e) {
|
||||||
|
if(e.keyCode == 13) { // enter key was pressed
|
||||||
|
e.preventDefault();
|
||||||
|
// run own code
|
||||||
|
return false; // prevent execution of rest of the script + event propagation / event bubbling + prevent default behaviour
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$($selector).keyup(function(e) {
|
||||||
|
if(e.keyCode == 13) { // enter key was pressed
|
||||||
|
e.preventDefault();
|
||||||
|
// run own code
|
||||||
|
return false; // prevent execution of rest of the script + event propagation / event bubbling + prevent default behaviour
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$($selector).keypress(function(e) {
|
||||||
|
if(e.keyCode == 13) { // enter key was pressed
|
||||||
|
e.preventDefault();
|
||||||
|
// run own code
|
||||||
|
return false; // prevent execution of rest of the script + event propagation / event bubbling + prevent default behaviour
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
25
backend/web/js/procurement.create.js
Normal file
25
backend/web/js/procurement.create.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
|
||||||
|
function ProcurementCreate(o){
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
'selector_product' : '#procurement-productidentifier',
|
||||||
|
};
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
defaults = $.extend(defaults,o);
|
||||||
|
console.info(defaults);
|
||||||
|
addPreventEnterToProduct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addPreventEnterToProduct(){
|
||||||
|
doPreventSubmit($(defaults.selector_product));
|
||||||
|
console.info('event handler added');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user