assign('SECTION', 'index'); $D_ROWS = $CFG['public_rows_pag']; $cond_lang = ''; if ($_SESSION['lang'] != 'es') { $cond_lang = '_'.$_SESSION['lang']; } // FICHA ACTIVIDAD if (!empty($_GET['idact'])) { $tpl->assign('SECTION','ficha_act'); $id = (int)$_GET['idact']; $obj = new DB_Actividades(); $table = $obj->__table; $prov = new DB_Provincias(); $pob = new DB_Poblaciones(); $rec = new DB_Recintos(); $tact = new DB_Actividades_t(); $org = new DB_Organizaciones(); $sorg = new DB_Suborganizaciones(); $cic = new DB_Actividades_ciclos(); $sobj = new DB_Actividades_sesiones(); $obj->activo = '1'; $obj->id = (int)$_GET['idact']; $obj->joinAdd($prov,'LEFT','prov'); $obj->joinAdd($pob ,'LEFT','pob'); $obj->joinAdd($rec ,'LEFT','re'); $obj->joinAdd($tact,'LEFT','ta'); $obj->joinAdd($org ,'LEFT','org'); $obj->joinAdd($sorg,'LEFT','sorg'); $obj->joinAdd($cic ,'LEFT','ci'); $obj->joinAdd($sobj,'LEFT','se'); $table = $obj->__table; $obj->selectAdd($table.".* "); $obj->selectAdd("if(COALESCE(prov.nombre{$cond_lang},'')<>'',prov.nombre{$cond_lang},prov.nombre) as prov"); $obj->selectAdd("if(COALESCE(pob.nombre{$cond_lang},'')<>'',pob.nombre{$cond_lang},pob.nombre) as pob"); $obj->selectAdd("re.imagen as rec_img"); $obj->selectAdd("if(COALESCE(re.nombre{$cond_lang},'')<>'',re.nombre{$cond_lang},re.nombre) as rec_nombre"); $obj->selectAdd("if(COALESCE(re.descrip{$cond_lang},'')<>'',re.descrip{$cond_lang},re.descrip) as rec_descrip"); $obj->selectAdd("if(COALESCE(ta.titulo{$cond_lang},'')<>'',ta.titulo{$cond_lang},ta.titulo) as tact"); $obj->selectAdd("if(COALESCE(org.nombre{$cond_lang},'')<>'',org.nombre{$cond_lang},org.nombre) as org"); $obj->selectAdd("if(COALESCE(sorg.nombre{$cond_lang},'')<>'',sorg.nombre{$cond_lang},sorg.nombre) as sorg"); $obj->selectAdd("if(COALESCE(ci.nombre{$cond_lang},'')<>'',ci.nombre{$cond_lang},ci.nombre) as ciclo"); $obj->selectAdd("date_format(se.fecha, '%d-%m-%Y %H:%i') as sesion"); $obj->selectAdd("date_format(se.fecha_hasta, '%d-%m-%Y %H:%i') as sesion_hasta"); $obj->selectAdd("se.precio"); $obj->orderBy("se.fecha"); // Datos de la actividad if ($obj && $obj->find()) { $datos = array(); $obj->find(); while ($obj->fetch()) { if (!isset($datos['act'])) { $datos['act'] = $obj->toArray(); } $datos['sesiones'][] = array( 'fecha' => $obj->sesion, 'fecha_hasta' => $obj->sesion_hasta, 'precio' => $obj->precio ); } // Ficheros de la actividad $fic = new DB_Ficheros(); $tfic = new DB_Ficheros_t(); $fic->joinAdd($tfic, 'INNER', 't'); $fic->idact = $id; $table = $fic->__table; $fic->selectAdd($table.'.*'); $fic->selectAdd("if(COALESCE($table.titulo{$cond_lang},'')<>'',$table.titulo{$cond_lang},$table.titulo) as titulo"); $fic->selectAdd("if(COALESCE($table.descrip{$cond_lang},'')<>'',$table.descrip{$cond_lang},$table.descrip) as descrip"); $fic->selectAdd("if(COALESCE(t.nombre{$cond_lang},'')<>'',t.nombre{$cond_lang},t.nombre) as tfic"); $fic->orderBy($table.'.idtipo, '.$table.'.del_evento, '.$table.'.id'); if ($fic->find()) { $tficheros = array(); while ($fic->fetch()) { $tfichero = $fic->tfic.'(s)'; if ($fic->del_evento == '1') { $tfichero .= ' '._("DEL ACTO"); } $tficheros[$tfichero][] = $fic->toArray(); } $datos['tficheros'] = $tficheros; } if ($_SESSION['lang'] != 'es') { if (!empty($datos['act']['titulo'.$cond_lang])) { $datos['act']['titulo'] = $datos['act']['titulo'.$cond_lang]; } if (!empty($datos['act']['descrip'.$cond_lang])) { $datos['act']['descrip'] = $datos['act']['descrip'.$cond_lang]; } } $tpl->assign('row', $datos); } if (!empty($_GET['idfile'])) { $idfile = (int)$_GET['idfile']; $fic = new DB_Ficheros(); if (!$fic->get($idfile)) { include '404.php'; exit; } if (in_array($fic->idtipo, array(1, 2))) { if ($_SESSION['lang'] != 'es') { $name = 'titulo'.$cond_lang; if (!empty($fic->$name)) { $fic->titulo = $fic->$name; } $name = 'descrip'.$cond_lang; if (!empty($fic->$name)) { $fic->descrip = $fic->$name; } } $tpl->assign('fichero', $fic->toArray()); } else { $file = $CFG['web_url'].'/'.$CFG['base_folder'].'/'.$CFG['ficheros_folder'].'/'.$fic->idtipo.'/'.$fic->idact.'/'.$fic->fichero; header("Location: $file"); exit; } } $keywords = array(); if ($datos['act']['org']) { $keywords[] = html_entity_decode($datos['act']['org']); } if ($datos['act']['sorg']) { $keywords[] = html_entity_decode($datos['act']['sorg']); } if ($datos['act']['tact']) { $keywords[] = html_entity_decode($datos['act']['tact']); } if ($datos['act']['ciclo']) { $keywords[] = html_entity_decode($datos['act']['ciclo']); } if ($datos['act']['rec_nombre']) { $keywords[] = html_entity_decode($datos['act']['rec_nombre']); } $meta = array( 'meta_title' => html_entity_decode($datos['act']['titulo']), 'meta_keywords' => implode(',', array_unique($keywords)), 'meta_description' => trim(ereg_replace('[ ]+',' ',str_replace("\n",'',str_replace("\r", '', html_entity_decode(strip_tags($datos['act']['descrip'])))))) ); $tpl->assign_by_ref('meta', $meta); $tpl->display('general.tpl'); exit; // FICHA NOTICIA } elseif (!empty($_GET['idnot'])) { require_once 'G_Noticias.php'; $tpl->assign('SECTION','ficha_not'); $id = (int)$_GET['idnot']; $obj = new DB_Noticias(); $obj->activo = '1'; $obj->id = (int)$_GET['idnot']; $obj->selectAdd("if(COALESCE(titulo{$cond_lang},'')<>'',titulo{$cond_lang},titulo) as titulo"); $obj->selectAdd("if(COALESCE(descrip{$cond_lang},'')<>'',descrip{$cond_lang},descrip) as descrip"); // Datos de la actividad if ($obj->find(true)) { $tpl->assign_by_ref('row', $obj->toArray()); // Ficheros $fobj = new DB_Noticias_ficheros(); $fobj->idnot = $id; if ($fobj->find()) { $ficheros = array(); while ($fobj->fetch()) { $ficheros[] = $fobj->toArray(); } $tpl->assign('baseurl', $CFG['base_folder'].'/'.$CFG['noticias_folder']); $tpl->assign_by_ref('ficheros', $ficheros); } } $meta = array( 'meta_title' => html_entity_decode($obj->titulo), 'meta_keywords' => html_entity_decode($obj->titulo), 'meta_description' => trim(ereg_replace('[ ]+',' ',str_replace("\n",'',str_replace("\r", '', html_entity_decode(strip_tags($obj->descrip)))))) ); $tpl->assign_by_ref('meta', $meta); $tpl->display('general.tpl'); exit; // FICHA DE LA ORGANIZACION } elseif (!empty($_GET['idorg'])) { $tpl->assign('SECTION','ficha_org'); $id = (int)$_GET['idorg']; $obj = new DB_Organizaciones(); if ($obj->get($id)) { $name = 'nombre'.$cond_lang; if (!empty($obj->$name)) { $obj->nombre = $obj->$name; } $name = 'descrip'.$cond_lang; if (!empty($obj->$name)) { $obj->descrip = $obj->$name; } $tpl->assign('row', $obj->toArray()); $sorg = new DB_Suborganizaciones(); $sorg->idorg = $id; $sorgs = array(); if ($sorg->find()) { while ($sorg->fetch()) { $name = 'nombre'.$cond_lang; if (!empty($sobj->$name)) { $sobj->nombre = $sobj->$name; } $name = 'descrip'.$cond_lang; if (!empty($sobj->$name)) { $sobj->descrip = $sobj->$name; } $sorgs[] = $sorg->toArray(); } $tpl->assign_by_ref('sorgs', $sorgs); } $meta = array( 'meta_title' => html_entity_decode($obj->nombre), 'meta_keywords' => html_entity_decode($obj->nombre), 'meta_description' => trim(ereg_replace('[ ]+',' ',str_replace("\n",'',str_replace("\r", '', html_entity_decode(strip_tags($obj->descrip)))))) ); $tpl->assign_by_ref('meta', $meta); } $tpl->display('general.tpl'); exit; // FICHA DE LA SUBORGANIZACION } elseif (!empty($_GET['idsuborg'])) { $tpl->assign('SECTION','ficha_suborg'); $id = (int)$_GET['idsuborg']; $obj = new DB_Suborganizaciones(); $oobj = new DB_Organizaciones(); $obj->joinAdd($oobj,'INNER','o'); $table = $obj->__table; $obj->selectAdd($table.".* "); $obj->selectAdd("if(COALESCE($table.nombre{$cond_lang},'')<>'',$table.nombre{$cond_lang},$table.nombre) as nombre"); $obj->selectAdd("if(COALESCE($table.descrip{$cond_lang},'')<>'',$table.descrip{$cond_lang},$table.descrip) as descrip"); $obj->selectAdd("if(COALESCE(o.nombre{$cond_lang},'')<>'',o.nombre{$cond_lang},o.nombre) as org"); if ($obj->get($id)) { $tpl->assign('row', $obj->toArray()); $meta = array( 'meta_title' => html_entity_decode($obj->org).': '.html_entity_decode($obj->nombre), 'meta_keywords' => html_entity_decode($obj->org).', '.html_entity_decode($obj->nombre), 'meta_description' => trim(ereg_replace('[ ]+',' ',str_replace("\n",'',str_replace("\r", '', html_entity_decode(strip_tags($obj->descrip)))))) ); $tpl->assign_by_ref('meta', $meta); } $tpl->display('general.tpl'); exit; // FICHA DEL CICLO } elseif (!empty($_GET['idciclo'])) { $tpl->assign('SECTION','ficha_ciclo'); $id = (int)$_GET['idciclo']; $obj = new DB_Actividades_ciclos(); if ($obj->get($id)) { $name = 'nombre'.$cond_lang; if (!empty($obj->$name)) { $obj->nombre = $obj->$name; } $name = 'descrip'.$cond_lang; if (!empty($obj->$name)) { $obj->descrip = $obj->$name; } $tpl->assign('row', $obj->toArray()); $meta = array( 'meta_title' => html_entity_decode($obj->nombre), 'meta_keywords' => html_entity_decode($obj->nombre), 'meta_description' => trim(ereg_replace('[ ]+',' ',str_replace("\n",'',str_replace("\r", '', html_entity_decode(strip_tags($obj->descrip)))))) ); $tpl->assign_by_ref('meta', $meta); } $tpl->display('general.tpl'); exit; // FICHA DEL RECINTO } elseif (!empty($_GET['idrec'])) { $tpl->assign('SECTION','ficha_recinto'); $id = (int)$_GET['idrec']; $obj = new DB_Recintos(); if ($obj->get($id)) { $name = 'nombre'.$cond_lang; if (!empty($obj->$name)) { $obj->nombre = $obj->$name; } $name = 'descrip'.$cond_lang; if (!empty($obj->$name)) { $obj->descrip = $obj->$name; } $tpl->assign('row', $obj->toArray()); $meta = array( 'meta_title' => html_entity_decode($obj->nombre), 'meta_keywords' => html_entity_decode($obj->nombre), 'meta_description' => trim(ereg_replace('[ ]+',' ',str_replace("\n",'',str_replace("\r", '', html_entity_decode(strip_tags($obj->descrip)))))) ); $tpl->assign_by_ref('meta', $meta); } $tpl->display('general.tpl'); exit; // CUANDO SE PASA FECHA } elseif (!empty($_GET['fecha'])) { $obj = new DB_Actividades(); $table = $obj->__table; $prov = new DB_Provincias(); $pob = new DB_Poblaciones(); $rec = new DB_Recintos(); $tact = new DB_Actividades_t(); $org = new DB_Organizaciones(); $sorg = new DB_Suborganizaciones(); $cic = new DB_Actividades_ciclos(); $sobj = new DB_Actividades_sesiones(); $obj->activo = '1'; list($format,$fecha) = getFormat($_GET['fecha']); $obj->whereAdd("(date_format(se.fecha,'$format')='$fecha' OR (date_format(se.fecha,'$format') <= '$fecha' AND date_format(se.fecha_hasta,'$format') >= '$fecha' ))"); if (!empty($_GET['idtact'])) { $obj->idtact = (int)$_GET['idtact']; } $obj->joinAdd($rec ,'LEFT','re'); $obj->joinAdd($tact,'LEFT','ta'); $obj->joinAdd($org ,'LEFT','org'); $obj->joinAdd($sorg,'LEFT','sorg'); $obj->joinAdd($cic ,'LEFT','ci'); $obj->joinAdd($sobj,'LEFT','se'); // Otras webs if (!$main_domain) { if (!@empty($filtros['idprov'])) { $obj->idprov = (int)$filtros['idprov']; } if (!@empty($filtros['idpob'])) { $obj->idpob= (int)$filtros['idpob']; } if (!@empty($filtros['idrec'])) { $obj->idrec = (int)$filtros['idrec']; } if (!@empty($filtros['idtact'])) { $obj->idtact = (int)$filtros['idtact']; } if (!@empty($filtros['idorg'])) { $obj->idorg = (int)$filtros['idorg']; } if (!@empty($filtros['idsuborg'])) { $obj->idsuborg = (int)$filtros['idsuborg']; } if (!@empty($filtros['idciclo'])) { $obj->idciclo = (int)$filtros['idciclo']; } } // Nuevo filtro para actividad por sub/dominio if (!@empty($filtros['id'])) { $obj->whereAdd("(COALESCE($table.iddom,0)=0 OR $table.iddom = '".$filtros['id']."')"); } $table = $obj->__table; $obj->selectAdd($table.".* "); $obj->selectAdd("if(COALESCE($table.titulo{$cond_lang},'')<>'',$table.titulo{$cond_lang},$table.titulo) as titulo"); $obj->selectAdd("if(COALESCE($table.descrip{$cond_lang},'')<>'',$table.descrip{$cond_lang},$table.descrip) as descrip"); $obj->selectAdd("if(COALESCE(re.nombre{$cond_lang},'')<>'',re.nombre{$cond_lang},re.nombre) as rec"); $obj->selectAdd("re.imagen as recimg"); $obj->selectAdd("if(COALESCE(ta.titulo{$cond_lang},'')<>'',ta.titulo{$cond_lang},ta.titulo) as tact"); $obj->selectAdd("if(COALESCE(org.nombre{$cond_lang},'')<>'',org.nombre{$cond_lang},org.nombre) as org"); $obj->selectAdd("if(COALESCE(ci.nombre{$cond_lang},'')<>'',ci.nombre{$cond_lang},ci.nombre) as ciclo"); $obj->selectAdd("date_format(se.fecha, '%d-%m-%Y %H:%i') as sesion"); $obj->selectAdd("date_format(se.fecha_hasta, '%d-%m-%Y %H:%i') as sesion_hasta"); $obj->selectAdd("se.precio"); $obj->orderBy("se.fecha, $table.titulo{$cond_lang}, $table.titulo"); // Historico } elseif (!empty($_GET['historico'])) { $obj = new DB_Actividades(); $table = $obj->__table; $prov = new DB_Provincias(); $pob = new DB_Poblaciones(); $rec = new DB_Recintos(); $tact = new DB_Actividades_t(); $org = new DB_Organizaciones(); $sorg = new DB_Suborganizaciones(); $cic = new DB_Actividades_ciclos(); $sobj = new DB_Actividades_sesiones(); $obj->activo = '1'; $obj->whereAdd("se.fecha < NOW()"); $obj->joinAdd($rec ,'LEFT','re'); $obj->joinAdd($tact,'LEFT','ta'); $obj->joinAdd($org ,'LEFT','org'); $obj->joinAdd($sorg,'LEFT','sorg'); $obj->joinAdd($cic ,'LEFT','ci'); $obj->joinAdd($sobj,'LEFT','se'); // Otras webs if (!$main_domain) { if (!@empty($filtros['idprov'])) { $obj->idprov = (int)$filtros['idprov']; } if (!@empty($filtros['idpob'])) { $obj->idpob= (int)$filtros['idpob']; } if (!@empty($filtros['idrec'])) { $obj->idrec = (int)$filtros['idrec']; } if (!@empty($filtros['idtact'])) { $obj->idtact = (int)$filtros['idtact']; } if (!@empty($filtros['idorg'])) { $obj->idorg = (int)$filtros['idorg']; } if (!@empty($filtros['idsuborg'])) { $obj->idsuborg = (int)$filtros['idsuborg']; } if (!@empty($filtros['idciclo'])) { $obj->idciclo = (int)$filtros['idciclo']; } } // Nuevo filtro para actividad por sub/dominio if (!@empty($filtros['id'])) { $obj->whereAdd("(COALESCE($table.iddom,0)=0 OR $table.iddom = '".$filtros['id']."')"); } $table = $obj->__table; $obj->selectAdd($table.".* "); $obj->selectAdd("if(COALESCE($table.titulo{$cond_lang},'')<>'',$table.titulo{$cond_lang},$table.titulo) as titulo"); $obj->selectAdd("if(COALESCE($table.descrip{$cond_lang},'')<>'',$table.descrip{$cond_lang},$table.descrip) as descrip"); $obj->selectAdd("if(COALESCE(re.nombre{$cond_lang},'')<>'',re.nombre{$cond_lang},re.nombre) as rec"); $obj->selectAdd("re.imagen as recimg"); $obj->selectAdd("if(COALESCE(ta.titulo{$cond_lang},'')<>'',ta.titulo{$cond_lang},ta.titulo) as tact"); $obj->selectAdd("if(COALESCE(org.nombre{$cond_lang},'')<>'',org.nombre{$cond_lang},org.nombre) as org"); $obj->selectAdd("if(COALESCE(ci.nombre{$cond_lang},'')<>'',ci.nombre{$cond_lang},ci.nombre) as ciclo"); $obj->selectAdd("date_format(se.fecha, '%d-%m-%Y %H:%i') as sesion"); $obj->selectAdd("date_format(se.fecha_hasta, '%d-%m-%Y %H:%i') as sesion_hasta"); $obj->selectAdd("se.precio"); $obj->orderBy("se.fecha DESC, $table.titulo{$cond_lang}"); // Noticias } elseif (!empty($_GET['noticias'])) { require_once 'G_Noticias.php'; if (count($_POST)) { $_SESSION['sql_not'] = $_POST; } elseif (!empty($_GET['p'])) { $_POST = $_SESSION['sql_not']; } $obj = new DB_Noticias(); $table = $obj->__table; $obj->activo = '1'; // Otras webs if (!$main_domain) { if (!@empty($filtros['idprov'])) { $obj->idprov = (int)$filtros['idprov']; } if (!@empty($filtros['idpob'])) { $obj->idpob= (int)$filtros['idpob']; } if (!@empty($filtros['idrec'])) { $obj->idrec = (int)$filtros['idrec']; } if (!@empty($filtros['idtact'])) { $obj->idtact = (int)$filtros['idtact']; } if (!@empty($filtros['idorg'])) { $obj->idorg = (int)$filtros['idorg']; } if (!@empty($filtros['idsuborg'])) { $obj->idsuborg = (int)$filtros['idsuborg']; } if (!@empty($filtros['idciclo'])) { $obj->idciclo = (int)$filtros['idciclo']; } } // A�adimos los filtros del buscador if (count($_POST)) { if (!empty($_POST['idprov'])) { $obj->idprov = (int)$_POST['idprov']; } if (!empty($_POST['idpob'])) { $obj->idpob = (int)$_POST['idpob']; } if (!empty($_POST['idrec'])) { $obj->idrec = (int)$_POST['idrec']; } if (!empty($_POST['idorg'])) { $obj->idorg = (int)$_POST['idorg']; } if (!empty($_POST['idsuborg'])) { $obj->idsuborg = (int)$_POST['idsuborg']; } if (!empty($_POST['idtact'])) { $obj->idtact = (int)$_POST['idtact']; } if (!empty($_POST['idtnot'])) { $obj->idtnot = (int)$_POST['idtnot']; } if (!empty($_POST['idciclo'])) { $obj->idciclo = (int)$_POST['idciclo']; } if (!empty($_POST['titulo'])) { $obj->whereAdd('('.$table.".titulo{$cond_lang} like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%' OR ".$table.".titulo like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%' OR ". $table.".descrip{$cond_lang} like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%' OR ".$table.".descrip like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%')"); } $fecha = ''; if (!empty($_POST['year'])) { $fecha .= sprintf("%4d",(int)$_POST['year']); } if (!empty($_POST['month'])) { $fecha .= '-'.sprintf("%02d",(int)$_POST['month']); } if (!empty($_POST['day'])) { $fecha .= '-'.sprintf("%02d",(int)$_POST['day']); } $fecha_hasta = ''; if (!empty($_POST['hyear'])) { $fecha_hasta .= sprintf("%4d",(int)$_POST['hyear']); } if (!empty($_POST['hmonth'])) { $fecha_hasta .= '-'.sprintf("%02d",(int)$_POST['hmonth']); } if (!empty($_POST['hday'])) { $fecha_hasta .= '-'.sprintf("%02d",(int)$_POST['hday']); } if (!empty($fecha) && !empty($fecha_hasta)) { list($format,$fecha) = getFormat($fecha); list($format_hasta,$fecha_hasta) = getFormat($fecha_hasta); $obj->whereAdd("(date_format(fecha,'$format')>='$fecha' AND date_format(fecha,'$format_hasta')<='$fecha_hasta')"); } elseif (!empty($fecha)) { list($format,$fecha) = getFormat($fecha); $obj->whereAdd("date_format(fecha,'$format')>='$fecha'"); } elseif (!empty($fecha_hasta)) { list($format,$fecha_hasta) = getFormat($fecha_hasta); $obj->whereAdd("(date_format(fecha,'$format')<='$fecha_hasta')"); } } $obj->selectAdd("if(COALESCE(titulo{$cond_lang},'')<>'',titulo{$cond_lang},titulo) as titulo"); $obj->selectAdd("if(COALESCE(descrip{$cond_lang},'')<>'',descrip{$cond_lang},descrip) as descrip"); $obj->orderBy("fecha DESC"); // Paginacion if ($obj && $total = $obj->find()) { $pages = (int)ceil($total/$D_ROWS); $page = !@empty($_GET['p']) ? (int)$_GET['p'] : 1; if ($page < 1 || $page > $pages) { include '404.php'; exit; } $from = ($page - 1) * $D_ROWS; $obj->limit($from, $D_ROWS); $obj->find(); $datos = array(); while ($obj->fetch()) { $datos[] = $obj->toArray(); } $tpl->assign('pag', array( 'pages' => $pages, 'prev' => $page - 1, 'curr' => $page, 'next' => $page + 1 )); $tpl->assign_by_ref('rows', $datos); } $tpl->display('general.tpl'); exit; // Buscador } else { // Poblacion if ($_GET['idpob']) { $_POST['idpob'] = (int)$_GET['idpob']; } if (count($_POST)) { $_SESSION['sql_index'] = $_POST; } elseif (!empty($_GET['p'])) { $_POST = $_SESSION['sql_index']; } if (count($_POST)) { $obj = new DB_Actividades(); $table = $obj->__table; $prov = new DB_Provincias(); $pob = new DB_Poblaciones(); $rec = new DB_Recintos(); $tact = new DB_Actividades_t(); $org = new DB_Organizaciones(); $sorg = new DB_Suborganizaciones(); $cic = new DB_Actividades_ciclos(); $sobj = new DB_Actividades_sesiones(); $obj->activo = '1'; // Filtros del sub/dominio (Otras webs) if (!$_GET['idpob'] && !$_SESSION['sql_index']['idpob'] && !$main_domain) { if (!@empty($filtros['idprov'])) { $_POST['idprov'] = (int)$filtros['idprov']; } if (!@empty($filtros['idpob'])) { $_POST['idpob'] = (int)$filtros['idpob']; } if (!@empty($filtros['idrec'])) { $_POST['idrec'] = (int)$filtros['idrec']; } if (!@empty($filtros['idtact'])) { $_POST['idtact'] = (int)$filtros['idtact']; } if (!@empty($filtros['idorg'])) { $_POST['idorg'] = (int)$filtros['idorg']; } if (!@empty($filtros['idsuborg'])) { $_POST['idsuborg'] = (int)$filtros['idsuborg']; } if (!@empty($filtros['idciclo'])) { $_POST['idciclo'] = (int)$filtros['idciclo']; } } // Nuevo filtro para actividad por sub/dominio if (!@empty($filtros['id'])) { $obj->whereAdd("(COALESCE($table.iddom,0)=0 OR $table.iddom = '".$filtros['id']."')"); } // A�adimos los filtros del buscador if (!empty($_POST['idprov'])) { $obj->idprov = (int)$_POST['idprov']; } if (!empty($_POST['idpob'])) { $obj->idpob = (int)$_POST['idpob']; } if (!empty($_POST['idrec'])) { $obj->idrec = (int)$_POST['idrec']; } if (!empty($_POST['idorg'])) { $obj->idorg = (int)$_POST['idorg']; } if (!empty($_POST['idsuborg'])) { $obj->idsuborg = (int)$_POST['idsuborg']; } if (!empty($_POST['idtact'])) { $obj->idtact = (int)$_POST['idtact']; } if (!empty($_POST['idfra'])) { $sobj->idfra = (int)$_POST['idfra']; } if (!empty($_POST['idciclo'])) { $obj->idciclo = (int)$_POST['idciclo']; } if (!empty($_POST['titulo'])) { $obj->whereAdd('('.$table.".titulo{$cond_lang} like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%' OR ".$table.".titulo like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%' OR ". $table.".descrip{$cond_lang} like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%' OR ".$table.".descrip like '%".trim(htmlentities(strip_tags(stripslashes($_POST['titulo']))))."%')"); } $fecha = ''; if (!empty($_POST['year'])) { $fecha .= sprintf("%4d",(int)$_POST['year']); } if (!empty($_POST['month'])) { $fecha .= '-'.sprintf("%02d",(int)$_POST['month']); } if (!empty($_POST['day'])) { $fecha .= '-'.sprintf("%02d",(int)$_POST['day']); } $fecha_hasta = ''; if (!empty($_POST['hyear'])) { $fecha_hasta .= sprintf("%4d",(int)$_POST['hyear']); } if (!empty($_POST['hmonth'])) { $fecha_hasta .= '-'.sprintf("%02d",(int)$_POST['hmonth']); } if (!empty($_POST['hday'])) { $fecha_hasta .= '-'.sprintf("%02d",(int)$_POST['hday']); } if (!empty($fecha) && !empty($fecha_hasta)) { list($format,$fecha) = getFormat($fecha); list($format_hasta,$fecha_hasta) = getFormat($fecha_hasta); $obj->whereAdd("((date_format(se.fecha,'$format')<='$fecha' AND (date_format(se.fecha_hasta,'$format_hasta')>='$fecha_hasta')) OR ". "(date_format(se.fecha,'$format')>='$fecha' AND date_format(se.fecha,'$format_hasta')<='$fecha_hasta' AND COALESCE(se.fecha_hasta,'')=''))"); } elseif (!empty($fecha)) { list($format,$fecha) = getFormat($fecha); $obj->whereAdd("date_format(se.fecha,'$format')>='$fecha'"); } elseif (!empty($fecha_hasta)) { list($format,$fecha_hasta) = getFormat($fecha_hasta); $obj->whereAdd("(date_format(se.fecha,'$format')<='$fecha_hasta' OR COALESCE(se.fecha_hasta,'')='')"); } else { $obj->whereAdd("se.fecha > NOW()"); } $obj->joinAdd($rec ,'LEFT','re'); $obj->joinAdd($tact,'LEFT','ta'); $obj->joinAdd($org ,'LEFT','org'); $obj->joinAdd($sorg,'LEFT','sorg'); $obj->joinAdd($cic ,'LEFT','ci'); $obj->joinAdd($sobj,'LEFT','se'); $table = $obj->__table; $obj->selectAdd($table.".* "); $obj->selectAdd("if(COALESCE($table.titulo{$cond_lang},'')<>'',$table.titulo{$cond_lang},$table.titulo) as titulo"); $obj->selectAdd("if(COALESCE($table.descrip{$cond_lang},'')<>'',$table.descrip{$cond_lang},$table.descrip) as descrip"); $obj->selectAdd("if(COALESCE(re.nombre{$cond_lang},'')<>'',re.nombre{$cond_lang},re.nombre) as rec"); $obj->selectAdd("re.imagen as recimg"); $obj->selectAdd("if(COALESCE(ta.titulo{$cond_lang},'')<>'',ta.titulo{$cond_lang},ta.titulo) as tact"); $obj->selectAdd("if(COALESCE(org.nombre{$cond_lang},'')<>'',org.nombre{$cond_lang},org.nombre) as org"); $obj->selectAdd("if(COALESCE(ci.nombre{$cond_lang},'')<>'',ci.nombre{$cond_lang},ci.nombre) as ciclo"); $obj->selectAdd("date_format(se.fecha, '%d-%m-%Y %H:%i') as sesion"); $obj->selectAdd("date_format(se.fecha_hasta, '%d-%m-%Y %H:%i') as sesion_hasta"); $obj->selectAdd("se.precio"); $obj->orderBy("se.fecha, $table.titulo{$cond_lang}"); } } // Paginacion if ($obj && $obj->find()) { $datos = array(); while ($obj->fetch()) { if (!isset($datos[$obj->idact]['data'])) { $datos[$obj->idact]['data'] = $obj->toArray(); } if (!empty($obj->sesion)) { $datos[$obj->idact]['sesiones'][] = array( 'sesion' => $obj->sesion, 'sesion_hasta' => $obj->sesion_hasta, 'precio' => $obj->precio ); } } // Una vez agrupado es cuando podemos paginar $total = count($datos); $pages = (int)ceil($total/$D_ROWS); $page = !@empty($_GET['p']) ? (int)$_GET['p'] : 1; if ($page < 1 || $page > $pages) { include '404.php'; exit; } $from = ($page - 1) * $D_ROWS; $datos = array_slice($datos, $from, $D_ROWS); $tpl->assign('pag', array( 'pages' => $pages, 'prev' => $page - 1, 'curr' => $page, 'next' => $page + 1 )); $tpl->assign_by_ref('rows', $datos); } $tpl->display('general.tpl'); ?>