Skip to content

Commit 493883f

Browse files
committed
Remove js demos
Db connection to mysql Site Contoller Check Access
1 parent e002550 commit 493883f

35 files changed

+14761
-6042
lines changed

Readme.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Como desplegar la aplicación
2+
3+
1- Instalar Sql Sever, recomendamos una version superior o igual a 2008
4+
2- Instalar el xampp-win32-7.2.4-0-VC15
5+
3- Descargar los driver de sql server para php
6+
php_sqlsrv_72_ts_x86
7+
php_pdo_sqlsrv_72_ts_x86
8+
4- Configurar los driver anteriormente descargados como extension de php.
9+
- Ir al C:\xampp\php\php.ini y copiar lo siguiente:
10+
extension=php_sqlsrv_72_ts_x86
11+
extension=php_pdo_sqlsrv_72_ts_x86
12+
5- Copiar el projecto en: C:\xampp\htdocs\
13+
6- Crear la base datos sgt
14+
7- Correr el scritp sql que esta en la carpeta sql del proyecto
15+
8- Configurar la conección de la base datos en la aplicación: C:\xampp\htdocs\sgt\config\db.php

assets/CalendarAsset.php

+6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ class CalendarAsset extends AssetBundle
1616
public $baseUrl = '@web';
1717
public $css = [
1818
'plugins/fullcalendar/fullcalendar.css',
19+
'plugins/bootstrap-select/bootstrap-select.min.css',
1920
];
2021
public $js = [
22+
'plugins/fullcalendar/lib/moment.min.js',
2123
'plugins/fullcalendar/fullcalendar.js',
24+
'plugins/fullcalendar/lang/es.js',
25+
'plugins/bootstrap-datepicker/js/locales/bootstrap-datepicker.es.js',
26+
'plugins/bootstrap-select/bootstrap-select.min.js',
27+
2228
];
2329
public $depends = [
2430
'app\assets\SystemAsset',

assets/FormAsset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FormAsset extends AssetBundle
2525
public $js = [
2626
'plugins/switchery/switchery.min.js',
2727
//'js/form-slider-switcher.demo.min.js',
28-
'js/form-slider-switcher.demo.js',
28+
'js/form-slider-switcher.js',
2929
'plugins/bootstrap-select/bootstrap-select.min.js',
3030
"plugins/select2/dist/js/select2.min.js"
3131
];

config/db.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
'class' => 'yii\db\Connection',
88
// 'dsn' => 'mssql:host=localhost;dbname=sgt',
99
//'dsn'=>'sqlsrv:Server=DESKTOP-JH5RE76\SQLEXPRESS;Database=sgt',
10-
'dsn'=>'sqlsrv:Server=PEDRO-PC\SQLEXPRESS;Database=sgt',
10+
// 'dsn'=>'sqlsrv:Server=PEDRO-PC\SQLEXPRESS;Database=sgt',
1111
// 'dsn'=>'sqlsrv:Server=127.0.0.1;Database=sgt',
12-
'username' => '',
12+
'dsn' => 'mysql:host=localhost;dbname=sgt',
13+
'username' => 'root',
1314
'password' => '', //Root*2018
1415
'charset' => 'utf8',
1516

config/web.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115
// $config['bootstrap'][] = 'debug';
116116
// $config['modules']['debug'] = [
117117
// 'class' => 'yii\debug\Module',
118-
// uncomment the following to add your IP if you are not connecting from localhost.
119-
//'allowedIPs' => ['127.0.0.1', '::1'],
118+
// // uncomment the following to add your IP if you are not connecting from localhost.
119+
// //'allowedIPs' => ['127.0.0.1', '::1'],
120120
// ];
121121

122122
$config['bootstrap'][] = 'gii';

controllers/SiteController.php

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use app\modules\rd\models\Reception;
77
use app\modules\rd\models\ReceptionSearch;
88
use app\modules\rd\models\ReceptionTransaction;
9+
use app\modules\rd\models\UserAgency;
10+
use app\modules\rd\models\UserTranscompany;
911
use Yii;
1012
use yii\filters\AccessControl;
1113
use yii\helpers\Url;
@@ -72,21 +74,24 @@ public function actionIndex()
7274

7375
// if($user)
7476

75-
77+
$params = Yii::$app->request->queryParams;
78+
// var_dump($params);die;
7679
if($user && $user->hasRol('Agencia'))
7780
{
78-
var_dump("Tiene el rol");
81+
$userAgency = UserAgency::findOne(['user_id'=>$user->id]);
82+
if($userAgency)
83+
$params['agency_id'] = $userAgency->agency->name;
7984
}
80-
else {
81-
var_dump("No Tiene el rol");
85+
else if ($user && $user->hasRol('Cia_transporte')){
86+
$userCiaTrans = UserTranscompany::findOne(['user_id'=>$user->id]);
87+
if($userCiaTrans)
88+
$params['trans_company_id'] = $userCiaTrans->transcompany->name;
8289
}
8390

84-
// die;
85-
8691
$searchModel = new ReceptionSearch();
8792

88-
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
89-
$receptionCount = $searchModel->search(Yii::$app->request->queryParams)->totalCount;
93+
$dataProvider = $searchModel->search($params);
94+
$receptionCount = $searchModel->search($params)->totalCount;
9095

9196
return $this->render('index', [
9297
'searchModel' => $searchModel,

modules/administracion/Administracion.php

-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ public function beforeAction($action)
3737
return Yii::$app->controller->redirect( Url::to(['/site/login']) );
3838
}
3939

40-
/*
41-
else if(!\Yii::$app->user->can('Admin_mod') || !\Yii::$app->user->can('User_update'))
42-
{
43-
throw new ForbiddenHttpException('Acceso denegado');
44-
//return \Yii::$app->controller->redirect(\Yii::$app->homeUrl . '/site/login');
45-
}
46-
*/
4740
return true;
4841
}
4942

modules/administracion/controllers/UserController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function behaviors()
5555
*/
5656
public function actionIndex()
5757
{
58-
if ( \Yii::$app->user->can('User_list')) {
58+
if ( \Yii::$app->user->can('user_list')) {
5959

6060
$searchModel = new UserSearch();
6161
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
@@ -66,7 +66,7 @@ public function actionIndex()
6666
'dataProvider' => $dataProvider,
6767
]);
6868
}else{
69-
return $this->redirect(['/site/index']);
69+
throw new ForbiddenHttpException('Acceso denegado');
7070
}
7171
}
7272

modules/administracion/models/AdmUser.php

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function attributes()
9696
{
9797
$attr = parent::attributes();
9898
$attr[] = 'passwordConfirm';
99+
$attr[] = 'item_name';
99100
return $attr;
100101
}
101102

@@ -121,6 +122,7 @@ public function attributeLabels()
121122
'created_at' => 'Creado',
122123
'updated_at' => 'Modificado',
123124
'passwordConfirm' => 'Confirmar Contraseña',
125+
'item_name'=>'Rol'
124126
];
125127
}
126128

modules/administracion/models/UserSearch.php

+28-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace app\modules\administracion\models;
44

5+
use vakata\database\Query;
56
use Yii;
67

78
use yii\data\ActiveDataProvider;
@@ -19,7 +20,7 @@ public function rules()
1920
{
2021
return [
2122
[['id', 'created_at', 'updated_at'], 'integer'],
22-
[['username', 'auth_key', 'password', 'email', 'nombre', 'apellidos', 'creado_por', 'password_reset_token', 'cedula','status'], 'safe'],
23+
[['username', 'auth_key', 'password', 'email', 'nombre', 'apellidos', 'creado_por', 'password_reset_token', 'cedula','status','item_name','id'], 'safe'],
2324
];
2425
}
2526

@@ -33,14 +34,23 @@ public function rules()
3334
*/
3435
public function search($params)
3536
{
36-
$query = AdmUser::find();
37+
38+
39+
$query = AdmUser::find()
40+
->innerJoin("auth_assignment","auth_assignment.user_id = adm_user.id")
41+
->select( 'id,username,nombre,apellidos,email,status,auth_assignment.item_name as item_name ,auth_assignment.user_id');
42+
43+
//var_dump($query);die;
44+
3745

3846
// add conditions that should always apply here
3947

4048
$dataProvider = new ActiveDataProvider([
4149
'query' => $query,
4250
]);
4351

52+
//var_dump($dataProvider->models);die;
53+
4454

4555
//var_dump($query);die;
4656

@@ -72,14 +82,29 @@ public function search($params)
7282

7383
}
7484

75-
$query->andFilterWhere(['like', 'username', $this->username])
85+
//$filter = AuthAssignment::find()->select('user_id')->where(['like','auth_assignment.user_id','adm_user.id']);
86+
7687

7788

7889

90+
91+
$query->andFilterWhere(['like', 'username', $this->username])
7992
->andFilterWhere(['like', 'email', $this->email])
8093
->andFilterWhere(['like', 'nombre', $this->nombre])
8194
->andFilterWhere(['like', 'apellidos', $this->apellidos]);
8295

96+
//$query->andFilterWhere([ 'item_name'=>$filter]);
97+
98+
/*
99+
//var_dump($this->id);die;
100+
if(isset($this->item_name)){
101+
102+
$filter = AuthAssignment::find()->select('item_name')->where(['like','user_id',$this->id]);
103+
$query->andFilterWhere(['item_name'=>$filter]);
104+
}*/
105+
106+
107+
83108

84109
return $dataProvider;
85110
}

modules/administracion/views/user/_form.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</div>
5454
<h4 class="panel-title"> <?= $this->title ?> </h4>
5555
</div>
56-
<div class="panel-body panel-form">
56+
<div class="panel-body panel-form" style="margin-top: 25px;">
5757

5858
<?php $form = ActiveForm::begin(
5959
[
@@ -62,7 +62,7 @@
6262
'options' =>
6363
[
6464
'enctype' => 'multipart/form-data',
65-
'class' => 'form-horizontal form-bordered',
65+
'class' => 'form-horizontal',
6666
'data-parsley-validate' => true
6767
],
6868
]

modules/administracion/views/user/index.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ class="fa fa-repeat"></i></a>
6969
'dataProvider' => $dataProvider,
7070
'filterModel' => $searchModel,
7171
'columns' => [
72-
['class' => 'yii\grid\SerialColumn'],
72+
//['class' => 'yii\grid\SerialColumn'],
7373
//'id',
7474
'username',
7575
'nombre',
7676
'apellidos',
7777
'email',
78+
'item_name',
7879

7980
[
8081
'attribute' => 'status',

0 commit comments

Comments
 (0)