foreach (MotivationCostsItem::getWriteOffsItems() as $key) {
if ($key == WriteOffsErp::WRITE_OFFS_TYPE_DELIVERY_BRAK) {
- if ($store_id == 4) {
+ if ($store_id == 4 /* Аэродромная */ ) {
$writeOffsResult = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.price'])
->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
->where(['between', 'wo.date', $weekStart, $weekEnd])
}
foreach (MotivationCostsItem::writeOffsToMotivationItemArray() as $key => $motivationItemType) {
+ if ($key == WriteOffsErp::WRITE_OFFS_TYPE_DELIVERY_BRAK) {
+ if ($store_id == 4 /* Аэродромная */) {
+ $writeOffsResult = $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.price'])
+ ->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
+ ->where(['between', 'wo.date', $monthStart, $monthEnd])
+ ->asArray()->all();
+ } else {
+ $writeOffsResult = [];
+ }
+ } else {
+ $writeOffsResult = $writeOffs;
+ }
+
$sum = 0;
- foreach($writeOffs as $data) {
+ foreach($writeOffsResult as $data) {
if (($data['type'] ?? '') == $key) {
$value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0)
* ($data['quantity'] ?? 0);