Browse Source

Indentation + commentaires modèle CommandeAutoForm / CommandeAutoProduit

dev
Guillaume Bourgeois 6 years ago
parent
commit
d7348c86c0
2 changed files with 37 additions and 13 deletions
  1. +23
    -8
      common/models/CommandeAutoForm.php
  2. +14
    -5
      common/models/CommandeAutoProduit.php

+ 23
- 8
common/models/CommandeAutoForm.php View File

/** /**
* Login form * Login form
*/ */
class CommandeAutoForm extends Model {
class CommandeAutoForm extends Model
{


public $id; public $id;
public $id_user; public $id_user;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
[['id_etablissement', 'periodicite_semaine', 'id_point_vente'], 'integer'], [['id_etablissement', 'periodicite_semaine', 'id_point_vente'], 'integer'],
[['date_debut', 'date_fin'], 'date', 'format' => 'php:d/m/Y'], [['date_debut', 'date_fin'], 'date', 'format' => 'php:d/m/Y'],
]; ];
} }


public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'id' => 'ID', 'id' => 'ID',
'id_user' => 'Utilisateur', 'id_user' => 'Utilisateur',
]; ];
} }


public function save() {
/**
* Enregistre la CommandeAuto.
*
* @return boolean
*/
public function save()
{
if ($this->id) { if ($this->id) {
$commandeauto = CommandeAuto::findOne($this->id); $commandeauto = CommandeAuto::findOne($this->id);
} else {
}
else {
$commandeauto = new CommandeAuto; $commandeauto = new CommandeAuto;
} }


$commandeauto->username = $this->username; $commandeauto->username = $this->username;
$commandeauto->id_etablissement = $this->id_etablissement; $commandeauto->id_etablissement = $this->id_etablissement;
$commandeauto->id_point_vente = $this->id_point_vente; $commandeauto->id_point_vente = $this->id_point_vente;
$commandeauto->date_debut = date('Y-m-d', strtotime(str_replace('/', '-', $this->date_debut)));
$commandeauto->date_debut = date(
'Y-m-d',
strtotime(str_replace('/', '-', $this->date_debut)
));
if (strlen($this->date_fin)) { if (strlen($this->date_fin)) {
$commandeauto->date_fin = date('Y-m-d', strtotime(str_replace('/', '-', $this->date_fin)));
$commandeauto->date_fin = date(
'Y-m-d',
strtotime(str_replace('/', '-', $this->date_fin)
));
} }
$commandeauto->lundi = $this->lundi; $commandeauto->lundi = $this->lundi;
$commandeauto->mardi = $this->mardi; $commandeauto->mardi = $this->mardi;
} }
} }
} }

return true; return true;
} }



+ 14
- 5
common/models/CommandeAutoProduit.php View File

* @property integer $id_produit * @property integer $id_produit
* @property double $quantite * @property double $quantite
*/ */
class CommandeAutoProduit extends \yii\db\ActiveRecord {
class CommandeAutoProduit extends \yii\db\ActiveRecord
{


/** /**
* @inheritdoc * @inheritdoc
*/ */
public static function tableName() {
public static function tableName()
{
return 'commande_auto_produit'; return 'commande_auto_produit';
} }


/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
[['id_commande_auto', 'id_produit'], 'required'], [['id_commande_auto', 'id_produit'], 'required'],
[['id_commande_auto', 'id_produit'], 'integer'], [['id_commande_auto', 'id_produit'], 'integer'],
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'id' => 'ID', 'id' => 'ID',
'id_commande_auto' => 'Id Commande Auto', 'id_commande_auto' => 'Id Commande Auto',
]; ];
} }


public function getProduit() {
/*
* Relations
*/
public function getProduit()
{
return $this->hasOne(Produit::className(), ['id' => 'id_produit']); return $this->hasOne(Produit::className(), ['id' => 'id_produit']);
} }



Loading…
Cancel
Save