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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use common\models\DeveloppementPriorite;
  5. /**
  6. * This is the model class for table "developpement".
  7. *
  8. * @property integer $id
  9. * @property string $objet
  10. * @property string $description
  11. * @property string $date
  12. * @property integer $avancement
  13. * @property string $statut
  14. * @property double $estimation_temps
  15. */
  16. class Developpement extends \yii\db\ActiveRecord {
  17. const STATUT_OPEN = 'open';
  18. const STATUT_CLOSED = 'closed';
  19. const TYPE_EVOLUTION = 'evolution';
  20. const TYPE_BUG = 'bug';
  21. /**
  22. * @inheritdoc
  23. */
  24. public static function tableName() {
  25. return 'developpement';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules() {
  31. return [
  32. [['objet', 'date'], 'required'],
  33. [['id', 'avancement'], 'integer'],
  34. [['description'], 'string'],
  35. [['date', 'date_livraison'], 'safe'],
  36. [['estimation_temps'], 'number'],
  37. [['objet', 'statut', 'type'], 'string', 'max' => 255],
  38. ];
  39. }
  40. public function getDeveloppementPriorite() {
  41. return $this->hasMany(DeveloppementPriorite::className(), ['id_developpement' => 'id'])->with('etablissement');
  42. }
  43. public function getDeveloppementPrioriteCurrentEtablissement() {
  44. return $this->hasOne(DeveloppementPriorite::className(), ['id_developpement' => 'id'])->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])->with('etablissement');
  45. }
  46. /**
  47. * @inheritdoc
  48. */
  49. public function attributeLabels() {
  50. return [
  51. 'id' => 'ID',
  52. 'objet' => 'Sujet',
  53. 'description' => 'Description',
  54. 'date' => 'Date',
  55. 'avancement' => 'Avancement',
  56. 'statut' => 'Statut',
  57. 'estimation_temps' => 'Estimation temps',
  58. 'type' => 'Type',
  59. 'date_livraison' => 'Date de livraison'
  60. ];
  61. }
  62. public function setDateLivraison($date = '') {
  63. if (strlen($date))
  64. $this->date_livraison = $date;
  65. if (strlen($this->date_livraison))
  66. $this->date_livraison = date('Y-m-d', strtotime($this->date_livraison));
  67. }
  68. }