From: Alexander Smirnov Date: Mon, 13 May 2024 15:21:14 +0000 (+0300) Subject: api3 report show fix X-Git-Tag: 1.1~34^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=cd3609e1ea5ac781967b9a22dbdc53e60529dc2f;p=erp24_rep%2Fyii-erp24%2F.git api3 report show fix --- diff --git a/erp24/api3/core/services/ReportService.php b/erp24/api3/core/services/ReportService.php index 3c9dc6ff..6d801d2a 100644 --- a/erp24/api3/core/services/ReportService.php +++ b/erp24/api3/core/services/ReportService.php @@ -80,10 +80,14 @@ class ReportService $date_start = $data->shift_type == 2 ? date("Y-m-d 20:00:00", strtotime($currentDate)) : - date("Y-m-d 08:00:00", strtotime($currentDate)); + ($data->shift_type == 1 ? + date("Y-m-d 08:00:00", strtotime($currentDate)) : + date("Y-m-d 00:00:00", strtotime($currentDate))); $date_end = $data->shift_type == 1 ? date("Y-m-d 20:00:00", strtotime($currentDate)) : - date("Y-m-d 08:00:00", strtotime("+1 day", strtotime($currentDate))); + ($data->shift_type == 2 ? + date("Y-m-d 08:00:00", strtotime("+1 day", strtotime($currentDate))) : + date("Y-m-d 00:00:00", strtotime("+1 day", strtotime($currentDate)))); $storeVisitorsQuery = StoreVisitors::find() ->select([ @@ -149,6 +153,7 @@ class ReportService ->leftJoin('users u', 'u.phone = s.phone::varchar(20) AND u.phone IN (\'' . implode('\',\'', ArrayHelper::getColumn($salesPhones, 'phone')) .'\')') ->where(['between', 's.date', $date_start, $date_end]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['s.store_id' => $data->stores]) ->groupBy(['s.store_id', 's.admin_id'])->asArray()->all(); @@ -159,6 +164,7 @@ class ReportService $salesReturn = Sales::find()->alias('s')->select(["COUNT(*) as cnt", "sum(s.summ) as total", "s.store_id", "s.admin_id"]) ->where(['operation' => Sales::OPERATION_RETURN]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['between', 's.date', $date_start, $date_end]) ->andWhere(['s.store_id' => $data->stores]) ->groupBy(['s.store_id', 's.admin_id'])->asArray()->all(); @@ -215,6 +221,7 @@ class ReportService 's.store_id', 's.admin_id']) ->leftJoin('sales_products p', 'p.check_id = s.id') ->where(['between', 's.date', $date_start, $date_end]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['operation' => Sales::OPERATION_SALE]) ->andWhere(['p.product_id' => array_keys($products1c)]) ->groupBy(['s.store_id', 's.admin_id']) @@ -499,6 +506,7 @@ class ReportService 'between', 'date', date("Y-m-01 00:00:00", strtotime($dateStartEnd[0])), date("Y-m-d 23:59:59", strtotime($dateStartEnd[1]))]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['s.store_id' => $data->stores]) ->groupBy(['store_id_1c']) ->indexBy('store_id_1c') @@ -515,10 +523,14 @@ class ReportService $date_start = $data->shift_type == 2 ? date("Y-m-d 20:00:00", strtotime($currentDate)) : - date("Y-m-d 08:00:00", strtotime($currentDate)); + ($data->shift_type == 1 ? + date("Y-m-d 08:00:00", strtotime($currentDate)) : + date("Y-m-d 00:00:00", strtotime($currentDate))); $date_end = $data->shift_type == 1 ? date("Y-m-d 20:00:00", strtotime($currentDate)) : - date("Y-m-d 08:00:00", strtotime("+1 day", strtotime($currentDate))); + ($data->shift_type == 2 ? + date("Y-m-d 08:00:00", strtotime("+1 day", strtotime($currentDate))) : + date("Y-m-d 00:00:00", strtotime("+1 day", strtotime($currentDate)))); // return [$adminPayrollDaysMonth, $adminPayrollDays]; $storeVisitorsQuery = StoreVisitors::find() @@ -589,6 +601,7 @@ class ReportService ->leftJoin('users u', 'u.phone = s.phone::varchar(20) AND u.phone IN (\'' . implode('\',\'', ArrayHelper::getColumn($salesPhones, 'phone')) .'\')') ->where(['between', 's.date', $date_start, $date_end]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['s.store_id' => $data->stores]) ->groupBy(['store_id_1c']) ->indexBy('store_id_1c') @@ -598,6 +611,7 @@ class ReportService $salesReturn = Sales::find()->alias('s')->select(["COUNT(*) as cnt", "sum(s.summ) as total", "store_id_1c"]) ->where(['operation' => Sales::OPERATION_RETURN]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['between', 's.date', $date_start, $date_end]) ->andWhere(['s.store_id' => $data->stores]) ->groupBy(['store_id_1c']) @@ -633,6 +647,7 @@ class ReportService 'store_id' ]) ->leftJoin('sales_products p', 'p.check_id = s.id') ->where(['between', 's.date', $date_start, $date_end]) + ->andWhere(['order_id' => ['', '0']]) ->andWhere(['operation' => Sales::OPERATION_SALE]) ->andWhere(['p.product_id' => array_keys($products1c)]) ->andWhere(['store_id' => $data->stores])