Ajout des champs nécessaires à la mise en place des crédits pain. Création du modèle CreditHistorique.prodstable
@@ -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', | |||
]; | |||
} | |||
} |
@@ -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', | |||
]; | |||
} | |||
@@ -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'], | |||
]; | |||
} | |||
@@ -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() | |||
{ | |||
} | |||
*/ | |||
} |