示例#1
0
文件: Funciones.php 项目: cicb/tpc
 public static function insertar($eventoId)
 {
     //Genera una funcion minima
     $ret = array('estado' => false, 'modelo' => null);
     $evento = Evento::model()->with('foro', 'configurl')->findByPk($eventoId);
     $model = new Funciones('insert');
     if (is_object($evento)) {
         // Si el id del evento es valido
         $model->EventoId = $evento->EventoId;
         $maximo = Funciones::maxId($eventoId);
         $model->FuncionesId = $maximo + 1;
         $anterior = Funciones::model()->findByPk(array('EventoId' => $model->EventoId, 'FuncionesId' => $maximo));
         //$model->ForoMapIntId=$anterior->ForoMapIntId;
         $model->FuncionesFecIni = date('Y-m-d H:i:s');
         $model->FuncionesFecHor = date('Y-m-d H:i:s');
         $model->FuncPuntosventaId = $evento->PuntosventaId;
         $model->FuncionesNomDia = date('l');
         $model->ForoId = $evento->ForoId;
         $model->funcionesTexto = strtoupper(strftime('%A %d - %b - %Y %H:%M HRS'));
         $model->FuncionesSta = 'ALTA';
         if ($model->save()) {
             if (isset($evento->configurl) and is_object($model->configurl)) {
                 // Si existe el configurl ...
                 $mapagrande = new ConfigurlFuncionesMapaGrande();
                 $mapagrande->configurl_Id = $evento->configurl->ConfigurlId;
                 $mapagrande->EventoId = $model->EventoId;
                 $mapagrande->FuncionId = $model->FuncionesId;
                 $mapagrande->nombre_imagen = "no_image.png";
                 $mapagrande->save();
             }
             return $model;
         }
     }
     return false;
 }
示例#2
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
         }
     }
 }