Code Duplication    Length = 30-30 lines in 2 locations

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

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