- <?php
-
-
-
- namespace common\models;
-
- use Yii;
- use common\components\ActiveRecordCommon ;
-
-
- class Invoice extends ActiveRecordCommon
- {
-
-
-
- public static function tableName()
- {
- return 'invoice';
- }
-
-
-
- public function rules()
- {
- return [
- [['id_producer', 'paye'], 'integer'],
- [['date', 'date_payment'], 'safe'],
- [['texte'], 'string'],
- [['amount_without_tax', 'ca'], 'number'],
- [['reference', 'wording', 'mean_payment'], 'string', 'max' => 255],
- ];
- }
-
-
-
-
- public function getProducer()
- {
- return $this->hasOne(Producer::className(), ['id' => 'id_producer']);
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'id_producer' => 'Producteur',
- 'date' => 'Date',
- 'reference' => 'Reference',
- 'wording' => 'Libellé',
- 'text' => 'Texte',
- 'amount_without_tax' => 'Montant Ht',
- 'paid' => 'Paye',
- 'date_payment' => 'Date de paiement',
- 'means_payment' => 'Méthode payment',
- 'turnover' => 'CA'
- ];
- }
-
-
-
- public static function defaultOptionsSearch()
- {
- return [
- 'with' => [],
- 'join_with' => [],
- 'orderby' => self::tableName().'.date ASc',
- 'attribute_id_producer' => self::tableName().'.id_producer'
- ] ;
- }
-
-
-
- public static function getLastInvoice()
- {
- return self::searchOne([],['orderby'=>'reference DESC']) ;
- }
-
- }
|