add indexes, add messagedetsta
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "procurement".
|
||||
@@ -22,6 +23,7 @@ class Procurement extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
public $productIdentifier;
|
||||
public $id_account;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -38,8 +40,8 @@ class Procurement extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
return [
|
||||
[['id_warehouse', 'count', 'purchase_price' ], 'required'],
|
||||
[['id_warehouse', 'count', 'productIdentifier', 'purchase_price' ], 'required' , 'on' => 'create_general'],
|
||||
[['id_warehouse', 'id_user', 'id_product', 'count', 'stock', 'purchase_price'], 'integer'],
|
||||
[['id_warehouse', 'count', 'productIdentifier', 'purchase_price' ,'id_account'], 'required' , 'on' => 'create_general'],
|
||||
[['id_warehouse', 'id_user', 'id_product', 'count', 'stock', 'purchase_price','id_account'], 'integer'],
|
||||
[['description'], 'string', 'max' => 255],
|
||||
[['productIdentifier'], 'string', 'max' => 128],
|
||||
[['productIdentifier'] ,'validateProductIdentifier', 'on' => 'create_general']
|
||||
@@ -70,11 +72,17 @@ class Procurement extends \common\models\BaseFitnessActiveRecord
|
||||
$product = null;
|
||||
|
||||
if ( isset($this->productIdentifier)){
|
||||
$id = $this->productIdentifier;
|
||||
$conditionProductName = ['name' =>$id];
|
||||
$name = $this->productIdentifier;
|
||||
$id = Helper::fixAsciiChars( $this->productIdentifier );
|
||||
// $conditionProductName = ['name' =>$id];
|
||||
$conditionProductNumber = ['product_number' =>$id];
|
||||
$conditionBarcode= ['barcode' =>$id];
|
||||
$products = Product::find()->andWhere(['or', ['name' =>$id] , ['product_number' =>$id] ,['barcode' =>$id] ] )->all();
|
||||
$query = Product::find()
|
||||
->andWhere(['or', ['product_number' =>$id] ,['barcode' =>$id] ] );
|
||||
if ( Helper::isProductVisibilityAccount() ){
|
||||
$query->andWhere(['id_account' => $this->id_account]);
|
||||
}
|
||||
$products = $query->all();
|
||||
if ( count($products) == 1 ){
|
||||
$product = $products[0];
|
||||
$this->id_product = $product->id_product;
|
||||
|
||||
Reference in New Issue
Block a user