/protected/models/CursoProfesor.php

https://github.com/camilo255423/gcad · PHP · 123 lines · 69 code · 10 blank · 44 comment · 1 complexity · f61a8af0c04b57986ea5278616a604dd MD5 · raw file

  1. <?php
  2. /**
  3. * This is the model class for table "cursoprofesor".
  4. *
  5. * The followings are the available columns in table 'cursoprofesor':
  6. * @property integer $codigoAsignatura
  7. * @property integer $grupo
  8. * @property string $documentoProfesor
  9. * @property integer $horasTutoria
  10. * @property integer $horasPreparacion
  11. * @property integer $horasEvaluacion
  12. *
  13. * The followings are the available model relations:
  14. * @property Profesor $documentoProfesor0
  15. * @property Curso $codigoAsignatura0
  16. * @property Curso $grupo0
  17. */
  18. class CursoProfesor extends CActiveRecord
  19. {
  20. /**
  21. * Returns the static model of the specified AR class.
  22. * @return CursoProfesor the static model class
  23. */
  24. public $compartido=false; //curso compartido
  25. private $errores=array();
  26. public static function model($className=__CLASS__)
  27. {
  28. return parent::model($className);
  29. }
  30. /**
  31. * @return string the associated database table name
  32. */
  33. public function tableName()
  34. {
  35. return 'cursoprofesor';
  36. }
  37. /**
  38. * @return array validation rules for model attributes.
  39. */
  40. public function rules()
  41. {
  42. // NOTE: you should only define rules for those attributes that
  43. // will receive user inputs.
  44. return array(
  45. array('codigoAsignatura, grupo, documentoProfesor, horasTutoria, horasPreparacion, horasEvaluacion', 'required'),
  46. array('codigoAsignatura, grupo, horasTutoria, horasPreparacion, horasEvaluacion', 'numerical', 'integerOnly'=>true),
  47. array('documentoProfesor', 'length', 'max'=>50),
  48. array('documentoProfesor', 'verificarHorario'),
  49. // The following rule is used by search().
  50. // Please remove those attributes that should not be searched.
  51. array('codigoAsignatura, grupo, documentoProfesor, horasTutoria, horasPreparacion, horasEvaluacion', 'safe', 'on'=>'search'),
  52. );
  53. }
  54. public function verificarHorario($attribute,$params)
  55. {
  56. if(count($this->errores)>0)
  57. $this->addError($attribute,$this->errores[0]);
  58. }
  59. /**
  60. * @return array relational rules.
  61. */
  62. public function relations()
  63. {
  64. // NOTE: you may need to adjust the relation name and the related
  65. // class name for the relations automatically generated below.
  66. return array(
  67. 'rprofesor' => array(self::BELONGS_TO, 'Profesor', 'documentoProfesor'),
  68. 'rcurso' => array(self::BELONGS_TO, 'Curso', 'codigoAsignatura'),
  69. 'rgrupo' => array(self::BELONGS_TO, 'Curso', 'grupo'),
  70. );
  71. }
  72. /**
  73. * @return array customized attribute labels (name=>label)
  74. */
  75. public function attributeLabels()
  76. {
  77. return array(
  78. 'codigoAsignatura' => 'Codigo Asignatura',
  79. 'grupo' => 'Grupo',
  80. 'documentoProfesor' => 'Documento Profesor',
  81. 'horasTutoria' => 'Horas Tutoria',
  82. 'horasPreparacion' => 'Horas Preparacion',
  83. 'horasEvaluacion' => 'Horas Evaluacion',
  84. );
  85. }
  86. /**
  87. * Retrieves a list of models based on the current search/filter conditions.
  88. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  89. */
  90. public function search()
  91. {
  92. // Warning: Please modify the following code to remove attributes that
  93. // should not be searched.
  94. $criteria=new CDbCriteria;
  95. $criteria->compare('codigoAsignatura',$this->codigoAsignatura);
  96. $criteria->compare('grupo',$this->grupo);
  97. $criteria->compare('documentoProfesor',$this->documentoProfesor,true);
  98. $criteria->compare('horasTutoria',$this->horasTutoria);
  99. $criteria->compare('horasPreparacion',$this->horasPreparacion);
  100. $criteria->compare('horasEvaluacion',$this->horasEvaluacion);
  101. return new CActiveDataProvider(get_class($this), array(
  102. 'criteria'=>$criteria,
  103. ));
  104. }
  105. public function addCustomError($error)
  106. {
  107. array_push($this->errores, $error);
  108. }
  109. public function numErrores()
  110. {
  111. return count($this->errores);
  112. }
  113. }