Browse Source

Crédit pain : migrations + classe CreditHistorique

Ajout des champs nécessaires à la mise en place des crédits pain.
Création du modèle CreditHistorique.
prodstable
keun 8 years ago
parent
commit
092341385a
4 changed files with 117 additions and 1 deletions
  1. +68
    -0
      common/models/CreditHistorique.php
  2. +3
    -1
      common/models/Etablissement.php
  3. +2
    -0
      common/models/UserEtablissement.php
  4. +44
    -0
      console/migrations/m161208_084531_add_champs_credits_pain.php

+ 68
- 0
common/models/CreditHistorique.php View File

@@ -0,0 +1,68 @@
<?php

namespace common\models;

use Yii;
use yii\db\ActiveRecord ;

/**
* This is the model class for table "credit_historique".
*
* @property integer $id
* @property integer $id_user
* @property integer $id_commande
* @property string $date
* @property double $montant
* @property string $type
* @property integer $id_etablissement
* @property string $moyen_paiement
*/
class CreditHistorique extends ActiveRecord
{
const TYPE_CREDIT_INITIAL = 'credit' ;
const TYPE_CREDIT = 'credit' ;
const TYPE_PAIEMENT_COMMANDE = 'paiement-commande' ;
const MOYEN_CB = 'cb' ;
const MOYEN_ESPECES = 'especes' ;
const MOYEN_CHEQUE = 'cheque' ;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'credit_historique';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_user', 'type'], 'required'],
[['id_user', 'id_commande', 'id_etablissement'], 'integer'],
[['date'], 'safe'],
[['montant'], 'number'],
[['type', 'moyen_paiement'], 'string', 'max' => 255],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'id_user' => 'Utilisateur',
'id_commande' => 'Commande',
'date' => 'Date',
'montant' => 'Montant',
'type' => 'Type',
'id_etablissement' => 'Établissement',
'moyen_paiement' => 'Moyen de paiement',
];
}
}

+ 3
- 1
common/models/Etablissement.php View File

@@ -55,6 +55,7 @@ class Etablissement extends \yii\db\ActiveRecord
}
}],
[['description'], 'string'],
[['solde_negatif'], 'boolean'],
[['nom', 'siret', 'logo', 'photo', 'code_postal', 'ville','code'], 'string', 'max' => 255],
];
}
@@ -75,7 +76,8 @@ class Etablissement extends \yii\db\ActiveRecord
'ville' => 'Ville',
'code' => 'Code',
'heure_limite_commande' => 'Heure limite de commande',
'delai_commande' => 'Délai de commande'
'delai_commande' => 'Délai de commande',
'solde_negatif' => 'Solde négatif',
];
}

+ 2
- 0
common/models/UserEtablissement.php View File

@@ -26,6 +26,8 @@ class UserEtablissement extends \yii\db\ActiveRecord {
return [
[['id_user', 'id_etablissement'], 'required'],
[['id_user', 'id_etablissement'], 'integer'],
[['actif'], 'boolean'],
[['credit'],'double'],
];
}


+ 44
- 0
console/migrations/m161208_084531_add_champs_credits_pain.php View File

@@ -0,0 +1,44 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

class m161208_084531_add_champs_credits_pain extends Migration
{
public function up()
{
$this->addColumn('etablissement', 'solde_negatif', Schema::TYPE_BOOLEAN) ;
$this->addColumn('credit_historique', 'id_etablissement', Schema::TYPE_INTEGER) ;
$this->addColumn('credit_historique', 'moyen_paiement', Schema::TYPE_STRING) ;
$this->addColumn('user_etablissement', 'credit', Schema::TYPE_FLOAT.' DEFAULT 0') ;
$this->addColumn('user_etablissement', 'actif', Schema::TYPE_BOOLEAN.' DEFAULT 1') ;
$this->dropColumn('user', 'credit') ;
}

public function down()
{
$this->dropColumn('etablissement', 'solde_negatif') ;
$this->dropColumn('credit_historique', 'id_etablissement') ;
$this->dropColumn('credit_historique', 'moyen_paiement') ;
$this->dropColumn('user_etablissement', 'credit') ;
$this->dropColumn('user_etablissement', 'actif') ;
$this->addColumn('user', 'credit', Schema::TYPE_FLOAT) ;
}

/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}

public function safeDown()
{
}
*/
}

Loading…
Cancel
Save