Beispiel #1
0
		<h4 class="panel-title">
			<tr>
				<th><a class="if($c == 1){}else{echo 'collapsed'; ?>" role="button" data-toggle="collapse" href="#collapse<?php echo $c; ?>" aria-expanded="true" aria-controls="collapse<?php echo $c; ?>"><i class="fa fa-plus btn btn-primary"></i></a></th>
				<th>Leer</th>
				<th>Crear</th>
				<th>Actualizar</th>
				<th>Borrar</th>
			</tr>
    	</h4>
    	</thead>
		  	<tbody>	
			  	<div class="row">
				  	<tr>
				  	<?php 
				  	if(TipoTramitesRoles::find()->where('tipoTramiteId = :ttid and roleId = :rolid',['ttid'=>$tt->id,'rolid'=>$rol->id])->exists()){
				  		$ttr = TipoTramitesRoles::find()->where('tipoTramiteId = :ttid and roleId = :rolid',['ttid'=>$tt->id,'rolid'=>$rol->id])->one();?>
				  		<input type="hidden" name="permisos[<?php echo $c; ?>][id]" value="<?php echo $ttr->id ?>">
				  		<?php }else{
				  			$ttr = new TipoTramitesRoles;
				  		} ?>
				  	<td class="col-lg-3"><?= $tt->nombre ?></td>
				  	<input type="hidden" name="permisos[<?php echo $c; ?>][rolid]" value="<?php echo $rol->id ?>">
				  	<input type="hidden" name="permisos[<?php echo $c; ?>][ttid]" value="<?php echo $tt->id ?>">
				  	<td class="col-lg-2">
				  		<input type="checkbox" id="<?php $check++; echo $check;?>" class="css-checkbox lrg vlad" name="permisos[<?php echo $c; ?>][leer]"<?php if($ttr->leer == true)echo 'checked';?>>
				  		<label for="<?php echo $check;?>" name="<?php echo $check;?>_lbl" class="css-label lrg vlad"></label>
				  	</td>
				  	<td class="col-lg-2">
				  		<input type="checkbox" id="<?php $check++; echo $check;?>" class="css-checkbox lrg vlad" name="permisos[<?php echo $c; ?>][crear]"<?php if($ttr->crear == true)echo 'checked';?>>
				  		<label for="<?php echo $check;?>" name="<?php echo $check;?>_lbl" class="css-label lrg vlad"></label>
				  	</td>
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTipoTramitesRoles()
 {
     return $this->hasMany(TipoTramitesRoles::className(), ['roleId' => 'id']);
 }
Beispiel #3
0
 public function actionTramiteroles($id)
 {
     if (isset($_POST['permisos'])) {
         $c = 1;
         foreach ($_POST['permisos'] as $permiso) {
             if (isset($permiso['id'])) {
                 $modelttr = TipoTramitesRoles::find()->where('id = :id', ['id' => $permiso['id']])->one();
             } else {
                 $modelttr = new TipoTramitesRoles();
             }
             $modelttr->roleId = $permiso['rolid'];
             $modelttr->tipoTramiteId = $permiso['ttid'];
             if (isset($permiso['leer'])) {
                 $modelttr->leer = 1;
             } else {
                 $modelttr->leer = 0;
             }
             if (isset($permiso['crear'])) {
                 $modelttr->crear = 1;
             } else {
                 $modelttr->crear = 0;
             }
             if (isset($permiso['actualizar'])) {
                 $modelttr->actualizar = 1;
             } else {
                 $modelttr->actualizar = 0;
             }
             if (isset($permiso['borrar'])) {
                 $modelttr->borrar = 1;
             } else {
                 $modelttr->borrar = 0;
             }
             $modelttr->save();
             //echo "<pre>";print_r($permiso['ppt']);echo "</pre>";exit;
             if (isset($permiso['ppt'])) {
                 foreach ($permiso['ppt'] as $ppt) {
                     if (isset($ppt['leer']) or isset($ppt['crear']) or isset($ppt['actualizar']) or isset($ppt['borrar'])) {
                         if (isset($ppt['id'])) {
                             $modelppt = PermisosPasoTramite::find()->where('id = :id', ['id' => $ppt['id']])->one();
                         } else {
                             $modelppt = new PermisosPasoTramite();
                         }
                         $modelppt->pasoTramiteId = $ppt['ptid'];
                         $modelppt->tipoTramiteRoleId = $modelttr->id;
                         if (isset($ppt['leer'])) {
                             $modelppt->leer = 1;
                         } else {
                             $modelppt->leer = 0;
                         }
                         if (isset($ppt['crear'])) {
                             $modelppt->crear = 1;
                         } else {
                             $modelppt->crear = 0;
                         }
                         if (isset($ppt['actualizar'])) {
                             $modelppt->actualizar = 1;
                         } else {
                             $modelppt->actualizar = 0;
                         }
                         if (isset($ppt['borrar'])) {
                             $modelppt->borrar = 1;
                         } else {
                             $modelppt->borrar = 0;
                         }
                         $modelppt->save();
                     }
                 }
             }
             $c++;
         }
     }
     $rol = Roles::find()->where('id = :id', ['id' => $id])->one();
     $tiposTramite = TiposTramite::find()->all();
     $pasosTramite = PasosTramite::find()->all();
     return $this->render('tramiteroles', ['tiposTramite' => $tiposTramite, 'rol' => $rol, 'pasosTramite' => $pasosTramite]);
 }
Beispiel #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTipoTramiteRole()
 {
     return $this->hasOne(TipoTramitesRoles::className(), ['id' => 'tipoTramiteRoleId']);
 }