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.

98 lines
2.3KB

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