Code Duplication    Length = 30-30 lines in 2 locations

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

@@ 328-357 (lines=30) @@
325
        return $orderArray;
326
    }
327
328
    protected function getSalesByMonth($em, $dateTime, array $excludes)
329
    {
330
        // concat... for pgsql
331
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
332
        $dql = 'SELECT
333
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
334
                  SUM(o.payment_total) AS order_amount,
335
                  COUNT(o) AS order_count
336
                FROM
337
                  Eccube\Entity\Order o
338
                WHERE
339
                    o.del_flg = 0
340
                    AND o.OrderStatus NOT IN (:excludes)
341
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
342
                GROUP BY
343
                  order_month';
344
345
        $q = $em
346
            ->createQuery($dql)
347
            ->setParameter(':excludes', $excludes)
348
            ->setParameter(':targetDate', $dateTime);
349
350
        $result = array();
351
        try {
352
            $result = $q->getSingleResult();
353
        } catch (NoResultException $e) {
354
            // 結果がない場合は空の配列を返す.
355
        }
356
        return $result;
357
    }
358
359
    protected function getSalesByDay($em, $dateTime, array $excludes)
360
    {
@@ 359-388 (lines=30) @@
356
        return $result;
357
    }
358
359
    protected function getSalesByDay($em, $dateTime, array $excludes)
360
    {
361
        // concat... for pgsql
362
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
363
        $dql = 'SELECT
364
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day,
365
                  SUM(o.payment_total) AS order_amount,
366
                  COUNT(o) AS order_count
367
                FROM
368
                  Eccube\Entity\Order o
369
                WHERE
370
                    o.del_flg = 0
371
                    AND o.OrderStatus NOT IN (:excludes)
372
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10)
373
                GROUP BY
374
                  order_day';
375
376
        $q = $em
377
            ->createQuery($dql)
378
            ->setParameter(':excludes', $excludes)
379
            ->setParameter(':targetDate', $dateTime);
380
381
        $result = array();
382
        try {
383
            $result = $q->getSingleResult();
384
        } catch (NoResultException $e) {
385
            // 結果がない場合は空の配列を返す.
386
        }
387
        return $result;
388
    }
389
390
    protected function countNonStockProducts($em)
391
    {