return $this->render('index', compact('shiftTransfers', 'storeNameById', 'admins'));
}
- public function buildLoadDataShiftRemains($groups, $storeGuid)
+ public function buildLoadDataShiftRemains($groups, $storeGuid, $normal = true)
{
$productsClass = ProductsClass::find()->select(['category_id'])->where(['tip' => $groups])->column();
$products = ArrayHelper::map(Products1c::find()->alias('p')->select(['id', 'name'])->leftJoin('products_class pc', 'pc.category_id = p.parent_id')
if (isset($balance[$key]) && $balance[$key] > 0) {
$productGuids[$key] = $name . ' (' . $balance[$key] . ' шт.)';
}
-// else {
-// $productGuids[$key] = $name;
-// }
+ else {
+ if (!$normal) {
+ $productGuids[$key] = $name;
+ }
+ }
}
$price = ArrayHelper::map(Prices::find()->select(['product_id', 'price'])->where(['product_id' => array_keys($products)])->all(), 'product_id', 'price');
$storeEIT = ExportImportTable::find()->select(['entity_id'])->where(['entity' => 'city_store', 'export_val' => $storeGuid, 'export_id' => 1])->one();
$shiftTransfer->shiftRemainsCopy = $loadDataShiftRemains ?? $shiftTransfer->shiftRemains;
+ $data = self::buildLoadDataShiftRemains($shiftTransfer->groups2, $firstId, false);
+ $productGuidsUnnormal = $data['productGuids'];
+
$existingKeys = ArrayHelper::getColumn($shiftTransfer->shiftRemainsCopy, 'product_guid');
$productGuidsForRest = [];
- foreach ($productGuids as $key => $value) {
+ foreach ($productGuidsUnnormal as $key => $value) {
if (!in_array($key, $existingKeys)) {
$productGuidsForRest[$key] = $value;
}
$shiftTransfer->shiftRemainsCopy = $loadDataShiftRemains ?? $shiftTransfer->shiftRemains;
+ $data = self::buildLoadDataShiftRemains($shiftTransfer->groups2, $firstId, false);
+ $productGuidsUnnormal = $data['productGuids'];
+
$existingKeys = ArrayHelper::getColumn($shiftTransfer->shiftRemainsCopy, 'product_guid');
$productGuidsForRest = [];
- foreach ($productGuids as $key => $value) {
+ foreach ($productGuidsUnnormal as $key => $value) {
if (!in_array($key, $existingKeys)) {
$productGuidsForRest[$key] = $value;
}