Code Duplication    Length = 30-30 lines in 2 locations

src/Eccube/Controller/Admin/AdminController.php 2 locations

@@ 200-229 (lines=30) @@
197
        return $orderArray;
198
    }
199
200
    protected function getSalesByMonth($em, $dateTime, array $excludes)
201
    {
202
        // concat... for pgsql
203
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
204
        $dql = 'SELECT
205
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
206
                  SUM(o.payment_total) AS order_amount,
207
                  COUNT(o) AS order_count
208
                FROM
209
                  Eccube\Entity\Order o
210
                WHERE
211
                    o.del_flg = 0
212
                    AND o.OrderStatus NOT IN (:excludes)
213
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
214
                GROUP BY
215
                  order_month';
216
217
        $q = $em
218
            ->createQuery($dql)
219
            ->setParameter(':excludes', $excludes)
220
            ->setParameter(':targetDate', $dateTime);
221
222
        $result = array();
223
        try {
224
            $result = $q->getSingleResult();
225
        } catch (NoResultException $e) {
226
            // 結果がない場合は空の配列を返す.
227
        }
228
        return $result;
229
    }
230
231
    protected function getSalesByDay($em, $dateTime, array $excludes)
232
    {
@@ 231-260 (lines=30) @@
228
        return $result;
229
    }
230
231
    protected function getSalesByDay($em, $dateTime, array $excludes)
232
    {
233
        // concat... for pgsql
234
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
235
        $dql = 'SELECT
236
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day,
237
                  SUM(o.payment_total) AS order_amount,
238
                  COUNT(o) AS order_count
239
                FROM
240
                  Eccube\Entity\Order o
241
                WHERE
242
                    o.del_flg = 0
243
                    AND o.OrderStatus NOT IN (:excludes)
244
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10)
245
                GROUP BY
246
                  order_day';
247
248
        $q = $em
249
            ->createQuery($dql)
250
            ->setParameter(':excludes', $excludes)
251
            ->setParameter(':targetDate', $dateTime);
252
253
        $result = array();
254
        try {
255
            $result = $q->getSingleResult();
256
        } catch (NoResultException $e) {
257
            // 結果がない場合は空の配列を返す.
258
        }
259
        return $result;
260
    }
261
262
    protected function countNonStockProducts($em)
263
    {