示例#1
0
 public function actionGuardarCoordenadasMapaGrande()
 {
     if (Yii::app()->request->isAjaxRequest) {
         if (isset($_POST)) {
             $zonaId = $_POST['zona'];
             $subzonaId = $_POST['subzona'];
             $eventoId = $_POST['eventoId'];
             $funcionId = $_POST['funcionId'];
             $escenario = $_POST['escenario'];
             $query = "eventoId={$eventoId} AND FuncionId={$funcionId}";
             if ($escenario == "todas") {
                 $query = "eventoId={$eventoId}";
                 $configUrlMapaGrande = ConfigurlFuncionesMapaGrande::model()->findAll($query);
                 foreach ($configUrlMapaGrande as $key => $mapaGrande) {
                     $coordenadasMapaGrande = ConfigurlMapaGrandeCoordenadas::model()->find("configurl_funcion_mapa_grande_id={$mapaGrande->id} AND ZonasId={$zonaId} AND SubzonaId={$subzonaId}");
                     if (empty($coordenadasMapaGrande)) {
                         $nuevaCoordenada = new ConfigurlMapaGrandeCoordenadas();
                         $nuevaCoordenada->configurl_funcion_mapa_grande_id = $mapaGrande->id;
                         $nuevaCoordenada->ZonasId = $zonaId;
                         $nuevaCoordenada->SubzonaId = $subzonaId;
                         $nuevaCoordenada->save(false);
                     }
                 }
             } else {
                 $configUrlMapaGrande = ConfigurlFuncionesMapaGrande::model()->find($query);
                 $coordenadasMapaGrande = ConfigurlMapaGrandeCoordenadas::model()->find("configurl_funcion_mapa_grande_id={$configUrlMapaGrande->id} AND ZonasId={$zonaId} AND SubzonaId={$subzonaId}");
                 if (empty($coordenadasMapaGrande)) {
                     $nuevaCoordenada = new ConfigurlMapaGrandeCoordenadas();
                     $nuevaCoordenada->configurl_funcion_mapa_grande_id = $configUrlMapaGrande->id;
                     $nuevaCoordenada->ZonasId = $zonaId;
                     $nuevaCoordenada->SubzonaId = $subzonaId;
                     $nuevaCoordenada->save(false);
                 }
             }
             $mapa_grande = MapaGrande::model()->findAll($query);
             foreach ($mapa_grande as $key => $mapa) {
                 $coords = array();
                 for ($i = 1; $i < 15; $i++) {
                     $coords['x' . $i] = empty($_POST['x' . $i]) ? null : $_POST['x' . $i];
                     $coords['y' . $i] = empty($_POST['y' . $i]) ? null : $_POST['y' . $i];
                 }
                 $coordenada = Yii::app()->db->createCommand()->update('configurl_mapa_grande_coordenadas', $coords, 'configurl_funcion_mapa_grande_id= :id AND ZonasId=:ZonasId AND SubzonaId=:SubzonaId', array(':id' => $mapa->id, ':ZonasId' => $zonaId, 'SubzonaId' => $subzonaId));
             }
             echo json_encode(array('update' => true));
         }
     }
 }
示例#2
0
文件: Funciones.php 项目: cicb/tpc
 public function eliminarDistribucion()
 {
     $identificador = array('EventoId' => $this->EventoId);
     $nfunciones = Funciones::model()->countByAttributes($identificador);
     if ($nfunciones > 1) {
         // Si no se esta tratando de eliminar la unica funcion.
         $identHijos = array('EventoId' => $this->EventoId, 'FuncionesId' => $this->FuncionesId);
         $this->deleteConfpvfuncion();
         Zonas::model()->deleteAllByAttributes($identHijos);
         Subzona::model()->deleteAllByAttributes($identHijos);
         Filas::model()->deleteAllByAttributes($identHijos);
         Lugares::model()->deleteAllByAttributes($identHijos);
         $mapagrande = ConfigurlFuncionesMapaGrande::model()->findByAttributes(array('EventoId' => $this->EventoId, 'FuncionId' => $this->FuncionesId));
         if (is_object($mapagrande)) {
             // Si tiene un mapa grande se eliminan primero sus coordenadas para que no de restriccion de llaves foraneas
             ConfigurlMapaGrandeCoordenadas::model()->deleteAllByAttributes(array('configurl_funcion_mapa_grande_id' => $mapagrande->id));
             $mapagrande->delete();
         }
         $this->ForoMapIntId = 0;
         $this->save();
         return true;
     } else {
         return false;
     }
 }
示例#3
0
文件: Forolevel1.php 项目: cicb/tpc
 public function asignarMapaGrande($EventoId, $FuncionesId)
 {
     // Copia el configurl_funciones_mapa_grande y sus coordenadas de la
     // funcion con la distribucion origen para la funcion que se le pasa como parametro
     $identificador = compact('EventoId', 'FuncionesId');
     $origen = Funciones::model()->with('mapagrande')->findByAttributes(array('ForoId' => $this->ForoId, 'ForoMapIntId' => $this->ForoMapIntId));
     $funcion = Funciones::model()->with('configurl')->findByPk($identificador);
     if (isset($origen) and is_object($origen) and isset($funcion->configurl)) {
         // Si la funcion origen existe y tiene mapa grande
         // y la funcion a aplicar tiene ya un configurl para su evento
         #Se eliminan todos los mapas grandes que puedan estar asignados a la funcion
         #Se eliminan todas sus coordenadas existentes
         ConfigurlFuncionesMapaGrande::model()->deleteAllByAttributes(array('EventoId' => $EventoId, 'FuncionId' => $FuncionesId));
         $mapa = new ConfigurlFuncionesMapaGrande();
         $mapa->configurl_Id = $funcion->configurl->ConfigurlId;
         $mapa->EventoId = $funcion->EventoId;
         $mapa->FuncionId = $funcion->FuncionesId;
         if ($origen->mapagrande) {
             $mapa->nombre_imagen = $origen->mapagrande->nombre_imagen;
         }
         if ($mapa->save()) {
             // Si se registro entonces se registran tambien sus coordenadas
             $conexion = Yii::app()->db;
             if (isset($origen->mapagrande)) {
                 $conexion->createCommand(sprintf("\n\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO configurl_mapa_grande_coordenadas \n\t\t\t\t\t\t\t\t\t\t\t( configurl_funcion_mapa_grande_id,ZonasId, SubzonaId, x1,y1, x2,y2, x3,y3,\n\t\t\t\t\t\t\t\t\t\t\tx4,y4, x5,y5, x6,y6, x7,y7, x8,y8, x9,y9, x10,y10,\n\t\t\t\t\t\t\t\t\t\t\tx11,y11, x12,y12, x13,y13, x14,y14 )\n\t\t\t\t\t\t\t\t\t\t\t(SELECT %d, ZonasId, SubzonaId, x1,y1, x2,y2, x3,y3,\n\t\t\t\t\t\t\t\t\t\t\tx4,y4, x5,y5, x6,y6, x7,y7, x8,y8, x9,y9, x10,y10,\n\t\t\t\t\t\t\t\t\t\t\tx11,y11, x12,y12, x13,y13, x14,y14 FROM configurl_mapa_grande_coordenadas\n\t\t\t\t\t\t\t\t\t\t\tWHERE configurl_funcion_mapa_grande_id = %d\n\t\t\t\t\t\t\t\t\t) ", $mapa->id, $origen->mapagrande->id))->execute();
             } else {
                 $conexion->createCommand(sprintf("\n\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO configurl_mapa_grande_coordenadas(\n\t\t\t\t\t\t\t\t\t\t\t\t\tconfigurl_funcion_mapa_grande_id,ZonasId,SubzonaId) \n\t\t\t\t\t\t\t\t\t\t\t(SELECT %d, ZonasId, SubzonaId FROM subzona\n\t\t\t\t\t\t\t\t\t\t\tWHERE EventoId=%d and FuncionesId=%d\n\t\t\t\t\t\t\t\t\t) ", $mapa->id, $funcion->EventoId, $funcion->FuncionesId))->execute();
             }
             //Se copian todas las coordenadas del mapa grande de la funcion origen a la funcion parametro
         }
     }
 }