Code Duplication    Length = 30-30 lines in 2 locations

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

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