Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- if (sfContext::getInstance()->getUser()->hasCredential('SUPER USUARIO'))
- {
- $c = new Criteria();
- }else{
- $c = new Criteria();
- $usuario = sfContext::getInstance()->getUser()->getUsuarioData();
- $empresa = $usuario->getEmpresaId();
- $c->add(EmpresaPeer::ID,$empresa);
- }
- $this->setWidgets(array(
- 'empresa' => new sfWidgetFormPropelChoice(array('model' => 'Empresa', 'add_empty' => false, 'criteria'=> $c)),
- // 'mes' => new sfWidgetFormSelect(array('choices' => $meses)),
- // 'anio' => new sfWidgetFormSelect(array('choices' => $anios)),
- 'tituloDocumento' => new sfWidgetFormInputText()
- ));
- $this->widgetSchema['mes_periodo'] = new sfWidgetFormPropelDependentSelect(array(
- 'model' => 'PeriodoFacturado',
- 'depends' => 'Empresa',
- 'add_empty' => 'Selecccione el mes',
- ));
- $this->widgetSchema['anio_periodo'] = new sfWidgetFormPropelDependentSelect(array(
- 'model' => 'PeriodoFacturado',
- 'depends' => 'Empresa',
- 'add_empty' => 'Selecccione el año',
- ));
- // always the selects order has to be according to the dependency.
- // ich means: country > state > city
- $this->widgetSchema->moveField('empresa', 'mes_periodo');
- $this->widgetSchema->moveField('empresa', 'anio_periodo');
- // validators
- $this->validatorSchema['mes_periodo'] = new sfValidatorDoctrineChoice(array(
- 'model' => 'PeriodoFacturado',
- ));
- $this->validatorSchema['anio_periodo'] = new sfValidatorDoctrineChoice(array(
- 'model' => 'PeriodoFacturado',
- ));
- ?>
Add Comment
Please, Sign In to add comment