|
|
|
|
|
|
|
|
]) |
|
|
]) |
|
|
->one(); |
|
|
->one(); |
|
|
|
|
|
|
|
|
if (!$order) { |
|
|
|
|
|
|
|
|
if($order) { |
|
|
|
|
|
if($order->id_point_sale != $posts['Order']['id_point_sale']) { |
|
|
|
|
|
$order->id_point_sale = $posts['Order']['id_point_sale'] ; |
|
|
|
|
|
$order->date_update = date('Y-m-d H:i:s') ; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
$order = new Order; |
|
|
$order = new Order; |
|
|
$order->load(Yii::$app->request->post()); |
|
|
$order->load(Yii::$app->request->post()); |
|
|
$order->id_user = User::getCurrentId(); |
|
|
$order->id_user = User::getCurrentId(); |
|
|
|
|
|
|
|
|
$productOrder->id_order = $order->id; |
|
|
$productOrder->id_order = $order->id; |
|
|
$productOrder->id_product = $product->id; |
|
|
$productOrder->id_product = $product->id; |
|
|
|
|
|
|
|
|
$productOrder->price = $product->price; |
|
|
|
|
|
|
|
|
$productOrder->price = $product->getPrice([ |
|
|
|
|
|
'user' => User::getCurrent(), |
|
|
|
|
|
'user_producer' => $userProducer, |
|
|
|
|
|
'point_sale' => $pointSale |
|
|
|
|
|
]); |
|
|
$productOrder->id_tax_rate = $product->taxRate->id; |
|
|
$productOrder->id_tax_rate = $product->taxRate->id; |
|
|
|
|
|
|
|
|
$unit = (!is_null($order) && isset($unitsArray[$product->id])) ? $unitsArray[$product->id] : $product->unit; |
|
|
$unit = (!is_null($order) && isset($unitsArray[$product->id])) ? $unitsArray[$product->id] : $product->unit; |