You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 line
2.0KB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use common\models\Etablissement ;
  5. /**
  6. * This is the model class for table "developpement_priorite".
  7. *
  8. * @property integer $id_user
  9. * @property integer $id_developpement
  10. */
  11. class DeveloppementPriorite extends \yii\db\ActiveRecord {
  12. const PRIORITE_HAUTE = 'haute' ;
  13. const PRIORITE_NORMALE = 'normale' ;
  14. const PRIORITE_BASSE = 'basse' ;
  15. /**
  16. * @inheritdoc
  17. */
  18. public static function tableName() {
  19. return 'developpement_priorite';
  20. }
  21. /**
  22. * @inheritdoc
  23. */
  24. public function rules() {
  25. return [
  26. [['id_etablissement', 'id_developpement'], 'required'],
  27. [['id_etablissement', 'id_developpement'], 'integer'],
  28. [['priorite'], 'string'],
  29. ];
  30. }
  31. public function getEtablissement() {
  32. return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']) ;
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function attributeLabels() {
  38. return [
  39. 'id_etablissement' => 'Établissement',
  40. 'id_developpement' => 'Développement',
  41. 'priorite' => 'Priorité'
  42. ];
  43. }
  44. public function getStrPriorite()
  45. {
  46. switch($this->priorite)
  47. {
  48. case self::PRIORITE_BASSE : return 'Basse' ; break ;
  49. case self::PRIORITE_NORMALE : return 'Normale' ; break ;
  50. case self::PRIORITE_HAUTE : return 'Haute' ; break ;
  51. default: return 'Non définie' ; break ;
  52. }
  53. }
  54. public function getClassCssStyleBouton() {
  55. $style_bouton = 'default' ;
  56. if($this->priorite == DeveloppementPriorite::PRIORITE_BASSE)
  57. $style_bouton = 'info' ;
  58. elseif($this->priorite == DeveloppementPriorite::PRIORITE_NORMALE)
  59. $style_bouton = 'warning' ;
  60. elseif($this->priorite == DeveloppementPriorite::PRIORITE_HAUTE)
  61. $style_bouton = 'danger' ;
  62. return $style_bouton ;
  63. }
  64. }