Guest User

Untitled

a guest
Oct 16th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?
  2.  
  3. if (sfContext::getInstance()->getUser()->hasCredential('SUPER USUARIO'))
  4. {
  5. $c = new Criteria();
  6. }else{
  7. $c = new Criteria();
  8. $usuario = sfContext::getInstance()->getUser()->getUsuarioData();
  9. $empresa = $usuario->getEmpresaId();
  10. $c->add(EmpresaPeer::ID,$empresa);
  11. }
  12. $this->setWidgets(array(
  13. 'empresa' => new sfWidgetFormPropelChoice(array('model' => 'Empresa', 'add_empty' => false, 'criteria'=> $c)),
  14. // 'mes' => new sfWidgetFormSelect(array('choices' => $meses)),
  15. // 'anio' => new sfWidgetFormSelect(array('choices' => $anios)),
  16. 'tituloDocumento' => new sfWidgetFormInputText()
  17. ));
  18.  
  19.  
  20. $this->widgetSchema['mes_periodo'] = new sfWidgetFormPropelDependentSelect(array(
  21. 'model' => 'PeriodoFacturado',
  22. 'depends' => 'Empresa',
  23. 'add_empty' => 'Selecccione el mes',
  24. ));
  25.  
  26. $this->widgetSchema['anio_periodo'] = new sfWidgetFormPropelDependentSelect(array(
  27. 'model' => 'PeriodoFacturado',
  28. 'depends' => 'Empresa',
  29. 'add_empty' => 'Selecccione el año',
  30. ));
  31.  
  32. // always the selects order has to be according to the dependency.
  33. // ich means: country > state > city
  34. $this->widgetSchema->moveField('empresa', 'mes_periodo');
  35. $this->widgetSchema->moveField('empresa', 'anio_periodo');
  36.  
  37. // validators
  38.  
  39. $this->validatorSchema['mes_periodo'] = new sfValidatorDoctrineChoice(array(
  40. 'model' => 'PeriodoFacturado',
  41. ));
  42.  
  43. $this->validatorSchema['anio_periodo'] = new sfValidatorDoctrineChoice(array(
  44. 'model' => 'PeriodoFacturado',
  45. ));
  46.  
  47.  
  48. ?>
Add Comment
Please, Sign In to add comment