Add contract parts

add procurement create prevent enter to product field
This commit is contained in:
Roland Schneider 2016-01-30 11:48:39 +01:00
parent a00331ce7c
commit 7b4fe04229
8 changed files with 225 additions and 0 deletions

View 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',
];
}

View File

@ -10,6 +10,8 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use backend\models\ContractCustomerSearch;
use common\models\Customer;
use yii\db\Query;
use backend\models\ContractRequestSearch;
/**
* ContractController implements the CRUD actions for Contract model.
@ -124,6 +126,31 @@ class ContractController extends Controller
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.

View 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;
}
}

View 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);
}
],
]
]);
?>

View File

@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Contract;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ContractSearch */
@ -79,6 +80,23 @@ $this->params['breadcrumbs'][] = $this->title;
'label' =>'Lejárat',
'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' ]) ;
},
],
],
],
]); ?>

View File

@ -1,6 +1,7 @@
<?php
use yii\helpers\Html;
use backend\assets\ProcurementCreateAsset;
/* @var $this yii\web\View */
@ -10,6 +11,11 @@ use yii\helpers\Html;
$this->title = Yii::t('common/procurement', 'Create Procurement');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/procurement', 'Procurements'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
ProcurementCreateAsset::register($this);
$this->registerJs(' new ProcurementCreate( { } );');
?>
<div class="procurement-create">

26
backend/web/js/app.js Normal file
View 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
}
});
}

View 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');
}
}