Code Duplication    Length = 30-30 lines in 2 locations

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

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