|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace common\models; |
|
|
namespace common\models; |
|
|
|
|
|
|
|
|
use common\helpers\GlobalParam; |
|
|
|
|
|
use Yii; |
|
|
use Yii; |
|
|
use common\components\ActiveRecordCommon; |
|
|
|
|
|
|
|
|
use common\helpers\GlobalParam; |
|
|
use common\models\Order; |
|
|
use common\models\Order; |
|
|
use common\models\Distribution; |
|
|
|
|
|
|
|
|
use common\components\ActiveRecordCommon; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* This is the model class for table "production". |
|
|
* This is the model class for table "production". |
|
|
|
|
|
|
|
|
if(isset($product->$fieldQuantityMax) && $product->$fieldQuantityMax > 0) { |
|
|
if(isset($product->$fieldQuantityMax) && $product->$fieldQuantityMax > 0) { |
|
|
$productDistribution->quantity_max = $product->$fieldQuantityMax ; |
|
|
$productDistribution->quantity_max = $product->$fieldQuantityMax ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$productDistribution->save(); |
|
|
$productDistribution->save(); |
|
|
|
|
|
|
|
|
|
|
|
// update prices product order |
|
|
|
|
|
$ordersArray = Order::searchAll([ |
|
|
|
|
|
'distribution.date' => $this->date, |
|
|
|
|
|
'distribution.id_producer' => $this->id_producer |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
'conditions' => 'date_delete IS NULL AND origin != "user"' |
|
|
|
|
|
]); |
|
|
|
|
|
if($ordersArray) { |
|
|
|
|
|
foreach($ordersArray as $order) { |
|
|
|
|
|
foreach($order->productOrder as $productOrder) { |
|
|
|
|
|
$productOrder->price = $product->price ; |
|
|
|
|
|
$productOrder->save() ; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $productDistribution; |
|
|
return $productDistribution; |
|
|
} |
|
|
} |
|
|
|
|
|
|