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.

99 lines
2.3KB

  1. <?php
  2. namespace common\models;
  3. use common\components\ActiveRecordCommon;
  4. use Yii;
  5. /**
  6. * This is the model class for table "delivery_note".
  7. *
  8. * @property integer $id
  9. * @property string $name
  10. * @property string $reference
  11. * @property string $date
  12. * @property string $comment
  13. * @property integer $id_point_sale_distribution
  14. * @property integer $id_user
  15. * @property string $address
  16. * @property string $city
  17. * @property string $postcode
  18. */
  19. class DeliveryNote extends ActiveRecordCommon
  20. {
  21. /**
  22. * @inheritdoc
  23. */
  24. public static function tableName()
  25. {
  26. return 'delivery_note';
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['date'], 'safe'],
  35. [['comment', 'address'], 'string'],
  36. [['id_point_sale', 'id_distribution', 'id_user'], 'integer'],
  37. [['name', 'reference', 'city', 'postcode'], 'string', 'max' => 255],
  38. ];
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'name' => 'Nom',
  48. 'reference' => 'Référence',
  49. 'date' => 'Date',
  50. 'comment' => 'Commentaire',
  51. 'id_point_sale' => 'Point de vente',
  52. 'id_distribution' => 'Distribution',
  53. 'id_user' => 'Utilisateur',
  54. 'address' => 'Adresse',
  55. 'city' => 'Ville',
  56. 'postcode' => 'Code postale',
  57. ];
  58. }
  59. /*
  60. * Relations
  61. */
  62. public function getUser()
  63. {
  64. return $this->hasOne(User::className(), ['id' => 'id_user']);
  65. }
  66. public function getPointSaleDistribution()
  67. {
  68. return $this->hasOne(PointSaleDistribution::className(), ['id_point_sale' => 'id_point_sale'])
  69. ->andOnCondition(['id_distribution' => 'id_distribution']) ;
  70. }
  71. public function getOrder()
  72. {
  73. return $this->hasOne(Order::className(), ['id' => 'id_delivery_note']);
  74. }
  75. /**
  76. * Retourne les options de base nécessaires à la fonction de recherche.
  77. *
  78. * @return array
  79. */
  80. public static function defaultOptionsSearch() {
  81. return [
  82. 'with' => [],
  83. 'join_with' => ['user', 'pointSaleDistribution', 'order'],
  84. 'orderby' => 'date ASC',
  85. 'attribute_id_producer' => ''
  86. ] ;
  87. }
  88. }