Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

77 lines
1.7KB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "facture".
  6. *
  7. * @property integer $id
  8. * @property integer $id_etablissement
  9. * @property string $date
  10. * @property string $reference
  11. * @property string $libelle
  12. * @property string $texte
  13. * @property double $montant_ht
  14. * @property integer $paye
  15. * @property string $date_paiement
  16. * @property string $methode_paiement
  17. */
  18. class Facture extends \yii\db\ActiveRecord
  19. {
  20. /**
  21. * @inheritdoc
  22. */
  23. public static function tableName()
  24. {
  25. return 'facture';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['id_etablissement', 'paye'], 'integer'],
  34. [['date', 'date_paiement'], 'safe'],
  35. [['texte'], 'string'],
  36. [['montant_ht','ca'], 'number'],
  37. [['reference', 'libelle', 'methode_paiement'], 'string', 'max' => 255],
  38. ];
  39. }
  40. public function getEtablissement()
  41. {
  42. return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']) ;
  43. }
  44. /**
  45. * @inheritdoc
  46. */
  47. public function attributeLabels()
  48. {
  49. return [
  50. 'id' => 'ID',
  51. 'id_etablissement' => 'Id Etablissement',
  52. 'date' => 'Date',
  53. 'reference' => 'Reference',
  54. 'libelle' => 'Libelle',
  55. 'texte' => 'Texte',
  56. 'montant_ht' => 'Montant Ht',
  57. 'paye' => 'Paye',
  58. 'date_paiement' => 'Date Paiement',
  59. 'methode_paiement' => 'Methode Paiement',
  60. 'ca' => 'CA'
  61. ];
  62. }
  63. public static function getLastFacture()
  64. {
  65. return Facture::find()
  66. ->orderBy('reference DESC')
  67. ->one() ;
  68. }
  69. }