add reception customer update changes

This commit is contained in:
2015-09-30 11:25:32 +02:00
parent 2b57f95b1e
commit 640d04cb76
20 changed files with 1185 additions and 15 deletions

View File

@@ -0,0 +1,117 @@
<?php
namespace frontend\models;
use Yii;
use common\models\Customer;
use common\models\Card;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property string $cardNumber
*/
class CustomerCreate extends \common\models\Customer
{
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cardNumber'], 'required' ],
[['cardNumber'], 'string', 'max' => 10],
[['cardNumber'], 'validateCustomerCard' ],
[['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ],
[['name'], 'required' ],
[['name'], 'string', 'max' => 128],
[['email'], 'string', 'max' => 255],
[['email'], 'email' ],
[['email'], 'unique' ],
[['password_plain','password_repeat'], 'string', 'max' => 32],
[['sex'], 'integer'],
[[ 'birthdate', ], 'date' ],
[[ 'date_stundent_card_expire', ], 'date' ],
[[ 'description', 'address'], 'string', 'max' => 255],
[['phone', 'tax_number', 'country'], 'string', 'max' => 20],
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30]
];
}
public function validateCustomerCard($a,$p){
$card = null;
if ( !empty($this->cardNumber)){
$card = Card::readCard($this->cardNumber,true);
}
if ( $card == null ){
$this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám"));
}else{
$this->id_customer_card = $card->id_card;
}
// $this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám"));
}
public function validatePartnerCard($a,$p){
if ( !empty($this->partnerCardNumber) ){
$card = Card::readCard($this->partnerCardNumber,true);
if ( $card == null ){
$this->addError($a,Yii::t('common/customer', "Bérlet kártya nem üres vagy hibás kártyaszám"));
}else{
$this->id_partner_card = $card->id_card;
}
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
namespace frontend\models;
use Yii;
use common\models\Customer;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property integer $id_customer_card
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property string $name
* @property string $email
* @property string $password
* @property string $phone
* @property integer $sex
* @property string $date_stundent_card_expire
* @property string $birthdate
* @property string $image
* @property string $description
* @property string $tax_number
* @property string $country
* @property string $zip
* @property string $city
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property string $cardNumber
*/
class CustomerUpdate extends \common\models\Customer
{
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
// [['cardNumber'], 'required' ],
// [['cardNumber'], 'string', 'max' => 10],
// [['cardNumber'], 'validateCustomerCard' ],
[['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ],
[['name'], 'required' ],
[['name'], 'string', 'max' => 128],
[['email'], 'string', 'max' => 255],
[['email'], 'email' ],
[['email'], 'unique' ],
[['password_plain','password_repeat'], 'string', 'max' => 32],
[['sex'], 'integer'],
[[ 'birthdate', ], 'date' ],
[[ 'date_stundent_card_expire', ], 'date' ],
[[ 'description', 'address'], 'string', 'max' => 255],
[['phone', 'tax_number', 'country'], 'string', 'max' => 20],
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30]
];
}
public function validateCustomerCard($a,$p){
// Customer::find()->andWhere( [$this->cardNumber )
}
public function validatePartnerCard($a,$p){
// Customer::find()->andWhere( [$this->cardNumber )
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Product;
/**
* ProductSearch represents the model behind the search form about `common\models\Product`.
*/
class ProductSearch extends Product
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_product', 'id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status', 'stock'], 'integer'],
[['product_number', 'barcode', 'description', 'created_at', 'updated_at', 'name'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Product::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id_product' => $this->id_product,
'id_product_category' => $this->id_product_category,
'id_account' => $this->id_account,
'purchase_price' => $this->purchase_price,
'sale_price' => $this->sale_price,
'profit_margins' => $this->profit_margins,
'status' => $this->status,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'stock' => $this->stock,
]);
$query->andFilterWhere(['like', 'product_number', $this->product_number])
->andFilterWhere(['like', 'barcode', $this->barcode])
->andFilterWhere(['like', 'description', $this->description])
->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}