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.

73 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. * @inheritdoc
  21. */
  22. public static function tableName() {
  23. return 'facture';
  24. }
  25. /**
  26. * @inheritdoc
  27. */
  28. public function rules() {
  29. return [
  30. [['id_etablissement', 'paye'], 'integer'],
  31. [['date', 'date_paiement'], 'safe'],
  32. [['texte'], 'string'],
  33. [['montant_ht', 'ca'], 'number'],
  34. [['reference', 'libelle', 'methode_paiement'], 'string', 'max' => 255],
  35. ];
  36. }
  37. public function getEtablissement() {
  38. return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']);
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function attributeLabels() {
  44. return [
  45. 'id' => 'ID',
  46. 'id_etablissement' => 'Id Etablissement',
  47. 'date' => 'Date',
  48. 'reference' => 'Reference',
  49. 'libelle' => 'Libelle',
  50. 'texte' => 'Texte',
  51. 'montant_ht' => 'Montant Ht',
  52. 'paye' => 'Paye',
  53. 'date_paiement' => 'Date Paiement',
  54. 'methode_paiement' => 'Methode Paiement',
  55. 'ca' => 'CA'
  56. ];
  57. }
  58. public static function getLastFacture() {
  59. return Facture::find()
  60. ->orderBy('reference DESC')
  61. ->one();
  62. }
  63. }