Exemplo n.º 1
0
 public function getCamposFormularioOrdenadosAlcancetablas($id_tabla = null, $solo_en_lista = false)
 {
     $c = new Criteria();
     $c->addJoin(CampoPeer::ID_CAMPO, RelCampoTablaPeer::ID_CAMPO, Criteria::JOIN);
     $c->addJoin(RelCampoTablaPeer::ID_TABLA, TablaPeer::ID_TABLA, Criteria::JOIN);
     $c->addAnd(TablaPeer::ID_EMPRESA, $this->getIdEmpresa(), Criteria::EQUAL);
     //$c->addAnd(CampoPeer::ES_GENERAL , true);
     $c->addAscendingOrderByColumn(CampoPeer::ORDEN);
     $c->setDistinct();
     $campos = CampoPeer::doSelect($c);
     //el siguiente ódigo es bastante ineficiente. Podría conseguirse una SQL que obtuviera todos los campos accesibles de la promotra
     $tablaes = TablaPeer::doSelect(TablaPeer::getCriterioAlcance());
     $accesible = array();
     foreach ($tablaes as $tab) {
         $accesible[$tab->getIdTabla()] = 1;
     }
     if ($id_tabla != null) {
         if (isset($accesible[$id_tabla])) {
             //Si viene que solo queremos los datos de una tabla y esta es accesible => solo obtenemos los campos de esa tabla.
             unset($accesible);
             $accesible[$id_tabla] = 1;
         } else {
             //la tabla no es accesible => devolver que no tiene campos
             return array();
         }
     }
     $resultado = array();
     foreach ($campos as $campo) {
         if (!$campo->getEsGeneral()) {
             $rels = $campo->getRelCampoTablas();
             //print_r($rels);
             foreach ($rels as $rel) {
                 if (isset($accesible[$rel->getIdTabla()])) {
                     if ($solo_en_lista) {
                         if ($campo->getEnLista()) {
                             $resultado[] = $campo;
                         }
                     } else {
                         $resultado[] = $campo;
                     }
                     break;
                     //sale del if o del for?
                 }
             }
         } else {
             $resultado[] = $campo;
         }
     }
     return $resultado;
 }
Exemplo n.º 2
0
<?php

use_helper('Text');
use_helper('Date');
use_helper('I18N');
?>

<?php 
$usuario = Usuario::getUsuarioActual();
?>

<?php 
$id_empresa_sel = sfContext::getInstance()->getUser()->getAttribute('idempresa', null);
$c = TablaPeer::getCriterioAlcance(true);
$c->add(TablaPeer::ID_EMPRESA, $id_empresa_sel);
$tablas = TablaPeer::doSelect($c);
?>

<div id="sf_admin_content" style="width:100%;">
<div class="grid2col" style="width: 100%; position: relative; top: -90px">
  <div class="column first" style="width: 35%; padding-top: 120px; border-right: 1px solid grey;">
    <div>

        <?php 
include_partial('mensajes', array('pager' => $mensajes, 'labels' => $labels));
?>
      
        <div style="clear:both"><!-- ie bugfix --></div>

        <div style="width: 95%; border-bottom: 1px dotted black; font-weight: bold; font-size: 15px;">
        <?php 
Exemplo n.º 3
0
 public function executeSubir()
 {
     $id_tabla = $this->getRequestParameter('id_tabla');
     $c = new Criteria();
     $c->addAscendingOrderByColumn(TablaPeer::ORDEN);
     $tablas = TablaPeer::doSelect($c);
     //Restableciendo el orden
     for ($i = 0; $i < sizeof($tablas); $i++) {
         $tablas[$i]->setOrden($i);
         $tablas[$i]->save();
     }
     for ($i = 0; $i < sizeof($tablas); $i++) {
         $tabla = $tablas[$i];
         if ($tabla->getIdTabla() == $id_tabla) {
             if (isset($tablas[$i - 1])) {
                 $tabla_down = $tablas[$i - 1];
                 $tabla->swapWith($tabla_down);
                 break;
             }
         }
     }
     return $this->redirect('tablas/list');
 }
Exemplo n.º 4
0
 /**
  * Gets an array of Tabla objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this Usuario has previously been saved, it will retrieve
  * related Tablas from storage. If this Usuario is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array Tabla[]
  * @throws     PropelException
  */
 public function getTablas($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UsuarioPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collTablas === null) {
         if ($this->isNew()) {
             $this->collTablas = array();
         } else {
             $criteria->add(TablaPeer::ID_USUARIO, $this->id_usuario);
             TablaPeer::addSelectColumns($criteria);
             $this->collTablas = TablaPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(TablaPeer::ID_USUARIO, $this->id_usuario);
             TablaPeer::addSelectColumns($criteria);
             if (!isset($this->lastTablaCriteria) || !$this->lastTablaCriteria->equals($criteria)) {
                 $this->collTablas = TablaPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastTablaCriteria = $criteria;
     return $this->collTablas;
 }
Exemplo n.º 5
0
 public function executeUpdate_select_tablas2()
 {
     $include_blank = $this->getRequestParameter('include_blank') == 'true' ? true : false;
     $c = $this->getCriterio();
     $id_empresa = $this->getRequestParameter('id_empresa');
     $empresa = null;
     if ($id_empresa) {
         $c->addAnd(EmpresaPeer::ID_EMPRESA, $id_empresa);
         $empresa = EmpresaPeer::doSelectOne($c);
         $this->forward404Unless($empresa);
     }
     $c1 = TablaPeer::getCriterioAlcance();
     if ($empresa instanceof Empresa) {
         $this->tablas = $empresa->getTablas($c1);
     } else {
         $this->tablas = TablaPeer::doSelect($c1);
     }
     //$this->control_name = $this->getRequestParameter('control_name' , 'tabla[id_tabla]');
     //$this->include_blank = $include_blank;// ? true : false;
 }
}
?>
">
  <?php 
if ($sf_request->hasError('campo{tipo_tabla}')) {
    ?>
    <?php 
    echo form_error('campo{tipo_tabla}', array('class' => 'form-error-msg'));
    ?>
  <?php 
}
?>
  <?php 
$crit_tabla = TablaPeer::getCriterioAlcance();
$crit_tabla->addAnd(TablaPeer::ID_EMPRESA, $campo->getIdEmpresa(), Criteria::EQUAL);
$lista_tablas = TablaPeer::doSelect($crit_tabla);
$opciones = objects_for_select($lista_tablas, 'getPrimaryKey', '__toString', $campo->getValorTabla(), array('include_blank' => true));
$value = select_tag('campo[tipo_tabla]', $opciones, array('control_name' => 'campo[tipo_tabla]'));
echo $value ? $value : '-';
?>
  <div class="sf_edit_help"><?php 
echo __('Indique la tabla a la que referencia');
?>
</div>
  </div>
  
  <?php 
if ($campo->getValorTabla() != null && $campo->getValorTabla() != "") {
    ?>
  <!-- VALOR DEFECTO TABLA -->
  <?php 
Exemplo n.º 7
0
 /**
  * It loads file YAML and it assigns the configuration to its respective variables
  * 
  * @access private
  * @param  string $name name of the file YAML
  * @return void
  */
 private function loadAndAssignConfig($name)
 {
     $yf = sfYaml::load(sfConfig::get('sf_csstabs_config_tabs') . $this->recognizeFile($name));
     $yf = $yf['cssTabs'];
     // recuperando la configuración principal
     $this->configTabs = $yf['configTabs'];
     // comprobando si existen pestañas
     if (!empty($yf['mainTabs'][0]['label'])) {
         $this->mainTabs = $yf['mainTabs'];
     }
     //CESAR=> COGEMOS EL CAMPO "REGISTROS" y LO SUBTITUIMOS POR LA LISTA DE TABLAS
     $tmp_mainTabs = array();
     foreach ($this->mainTabs as $tab) {
         if (trim(strtolower($tab['module'])) != "formularios") {
             $tmp_mainTabs[] = $tab;
         } else {
             $id_empresa_sel = sfContext::getInstance()->getUser()->getAttribute('idempresa', null);
             $c = TablaPeer::getCriterioAlcance(true);
             $c->add(TablaPeer::ID_EMPRESA, $id_empresa_sel);
             $tablas = TablaPeer::doSelect($c);
             foreach ($tablas as $tabla) {
                 $l_option = array('label' => strtoupper($tabla->getNombre()), 'otra_fila' => true, 'id_tabla' => $tabla->getIdTabla(), 'link' => true, 'module' => 'formularios', 'action' => 'list/?filters[id_empresa]=' . $id_empresa_sel . '&filters[id_tabla]=' . $tabla->getIdTabla() . '&filter=filter', 'tipo' => 0, 'linkOptions' => array());
                 $tmp_mainTabs[] = $l_option;
             }
         }
     }
     $this->mainTabs = $tmp_mainTabs;
     //CESAR=>
     // sub tabs
     if (!empty($yf['subTabs'][0]['label'])) {
         $this->setSubTabs($yf['subTabs']);
     }
 }
    ?>
 form-error<?php 
}
?>
">
  <?php 
if ($sf_request->hasError('alcance{id_tabla}')) {
    ?>
    <?php 
    echo form_error('alcance{id_tabla}', array('class' => 'form-error-msg'));
    ?>
  <?php 
}
?>
  
  <?php 
$c_tabla = TablaPeer::getCriterioAlcance();
$c_tabla->addAscendingOrderBycolumn(TablaPeer::ID_EMPRESA);
if ($alcance->getIdEmpresa()) {
    $c_tabla->add(TablaPeer::ID_EMPRESA, $alcance->getIdEmpresa());
}
$tablaes = TablaPeer::doSelect($c_tabla);
?>

  <?php 
$value = select_tag('alcance[id_tabla]', objects_for_select($tablaes, 'getIdTabla', 'getNombreyEmpresa', $alcance->getIdTabla(), array('include_custom' => " - " . __('Todas') . " - ")), array('control_name' => 'alcance[id_tabla]'));
echo $value ? $value : '&nbsp;';
?>
    </div>
</div>
Exemplo n.º 9
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(TablaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(TablaPeer::DATABASE_NAME);
         $criteria->add(TablaPeer::ID_TABLA, $pks, Criteria::IN);
         $objs = TablaPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 10
0
<fieldset id="filtros_formularios"  class="<?php 
echo $clase;
?>
">
<h2><?php 
echo __('filtros de datos');
?>
</h2>
<!-- Ana: 16-04-09
<div class="form-row">
  <?php 
echo label_for("filters[id_tabla]", __('Tabla') . ":");
?>
  <div class="content">
  <?php 
$tablas = TablaPeer::doSelect(TablaPeer::getCriterioAlcance());
$id_tabla = isset($filters['id_tabla']) ? $filters['id_tabla'] : null;
$value = select_tag('filters[id_tabla]', objects_for_select($tablas, 'getPrimaryKey', '__toString', $id_tabla, array('include_blank' => true)), array('control_name' => 'filters[id_tabla]'));
echo $value ? $value : '-';
//Ana: 16-04-09  echo input_hidden_tag('filters[id_empresa]' , $empresa->getPrimaryKey());
?>
  </div>
</div>
-->
<?php 
$id_tabla = isset($filters['id_tabla']) ? $filters['id_tabla'] : null;
$tabla = null;
if (isset($id_tabla) && $id_tabla != '') {
    $tabla = TablaPeer::retrievebypk($id_tabla);
    /*Ana: eins?? 16-04-09 foreach($tablas as $promo)
      {
Exemplo n.º 11
0
function _jscookmenu($arr, $name, $orientation, $theme)
{
    $arr2 = array();
    $id_empresa_sel = sfContext::getInstance()->getUser()->getAttribute('idempresa', null);
    $categorias = ParametroPeer::getCategorias();
    foreach ($categorias as $cat) {
        $tmp_array = array();
        $tmp_array["title"] = strtoupper($cat->getNombre());
        $c = TablaPeer::getCriterioAlcance(true);
        $c->addAnd(TablaPeer::ID_EMPRESA, $id_empresa_sel, Criteria::EQUAL);
        $c->addAnd(TablaPeer::ID_CATEGORIA, $cat->getIdParametro(), Criteria::EQUAL);
        $tablas = TablaPeer::doSelect($c);
        $cont = 1;
        if (sizeof($tablas) > 0) {
            $tmp_array["submenu"] = array();
        }
        foreach ($tablas as $tabla) {
            $tmp_array["submenu"]["menu0" . $cat->getIdParametro() . "." . $cont] = array("title" => $tabla->getNombre(), "url" => 'formularios/list', "after_url" => '/?filters[id_empresa]=' . $id_empresa_sel . '&filters[id_tabla]=' . $tabla->getIdTabla() . '&filter=filter');
            $cont++;
        }
        if (sizeof($tablas) > 0) {
            $arr2["menu0" . $cat->getIdParametro()] = $tmp_array;
        }
    }
    foreach ($arr as $key => $ar) {
        $arr2[$key] = $ar;
    }
    $arr = $arr2;
    _load_jscookmenu_resources($theme);
    $sf_user = sfContext::getInstance()->getUser();
    $js = "var {$name} = [";
    foreach ($arr as $item) {
        if (is_array($item)) {
            // check credentials
            $display = true;
            //if (isset($item['credentials']))
            // $display = $sf_user->hasCredential($item['credentials']);
            if (isset($item['url'])) {
                $actions = explode("/", $item['url']);
                if (!isset($actions[1])) {
                    $actions[1] = "index";
                }
                $display = Usuario::tienePermisos($actions[0], $actions[1]);
            }
            // if sf_user has credentials, display the menu item
            if ($display) {
                $js .= "[" . _get_item($item);
                if (isset($item['submenu'])) {
                    foreach ($item['submenu'] as $subitem) {
                        if (is_array($subitem)) {
                            // check credentials
                            $display = true;
                            if (isset($subitem['url'])) {
                                $actions = explode("/", $subitem['url']);
                                if (!isset($actions[1])) {
                                    $actions[1] = "index";
                                }
                                $display = Usuario::tienePermisos($actions[0], $actions[1]);
                            }
                            //if (isset($subitem['credentials']))
                            //$display = $sf_user->hasCredential($subitem['credentials']);
                            // if sf_user has credentials, display the menu item
                            if ($display) {
                                $js .= ", [" . _get_item($subitem);
                                if (isset($subitem['submenu'])) {
                                    foreach ($subitem['submenu'] as $subsubitem) {
                                        if (is_array($subsubitem)) {
                                            // check credentials
                                            $display = true;
                                            if (isset($subsubitem['url'])) {
                                                $actions = explode("/", $subsubitem['url']);
                                                if (!isset($actions[1])) {
                                                    $actions[1] = "index";
                                                }
                                                $display = Usuario::tienePermisos($actions[0], $actions[1]);
                                            }
                                            //if (isset($subsubitem['credentials']))
                                            //$display = $sf_user->hasCredential($subsubitem['credentials']);
                                            // if sf_user has credentials, display the menu item
                                            if ($display) {
                                                $js .= ", [" . _get_item($subsubitem) . "]";
                                            }
                                        } else {
                                            if ($subsubitem == '_cmSplit') {
                                                $js .= ", " . $subsubitem;
                                            }
                                        }
                                    }
                                }
                                $js .= "]";
                            }
                        } else {
                            if ($subitem == '_cmSplit') {
                                $js .= ', ' . $subitem;
                            }
                        }
                    }
                }
                $js .= "], ";
            }
        } else {
            if ($item == '_cmSplit') {
                $js .= $item . ', ';
            }
        }
    }
    $js = substr($js, 0, strlen($js) - 2);
    $js .= "];";
    $html = tag('div', array('id' => "{$name}"), true);
    $html .= tag('/div', array(), true);
    $js2 = "cmDraw('{$name}', {$name}, '{$orientation}', {$theme});";
    return javascript_tag($js) . $html . javascript_tag($js2);
}