lib/EigyoBundle/src/Controller/TopController.php line 21

Open in your IDE?
  1. <?php
  2. namespace Times\EigyoBundle\Controller;
  3. //use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Times\EigyoBundle\Common\TimesStatic;
  5. use Times\EigyoBundle\Entity\Virtual\SalesResults;
  6. /**
  7.  * Description of TopController
  8.  *
  9.  * @author kawaguchi@kuzilla.co.jp
  10.  */
  11. class TopController extends BaseController
  12. {
  13.     /**
  14.      * index
  15.      * @return type
  16.      */
  17.     public function indexAction()
  18.     {
  19.         // 権限チェック
  20. //        $this->canUseCheck();
  21.         $em $this->getDoctrine()->getManager();
  22.         $isManager TimesStatic::getRoleManager()->isManager();
  23.         // ** 表示対象支店の一覧を取得
  24.         if ($isManager) {
  25.             $targetBranchIds TimesStatic::getRoleManager()->getManageBranchIds();
  26.         } else {
  27.             $targetBranchIds = array($this->getUser()->getBranchId());
  28.         }
  29.         // -- お知らせ --------------
  30.         // ** TODOチェック
  31.         $todoCheckList 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->findForTodoList($this->getUser(), $isManager);
  32.         // ** TODO: 人事お知らせ
  33.         // ** お知らせ
  34.         $news = array(
  35.             'etc' => array(), /* システム系などいろいろ */
  36. //            'todo' => $todoCheckList, /* TODOのチェック */
  37.             'jinji'  => TimesStatic::getJinjiKoukaApiManager()->getEmployeeAlertList($this->getUser()->getEmployeeId()), /* 人事考課のお知らせ */
  38.         );
  39.         // ** システム系のお知らせは共通
  40. //        $news['etc'] = array(
  41. //            'warn'=>"ワーニング",
  42. //            'danger' => 'でんじゃー',
  43. //            'info' => 'おしらせ',
  44. //        );
  45.         // ----- 新着・取引中案件一覧 -------------------------
  46.         // ** 新着情報
  47.         // 一般・管理者: 全社かつ24時間以内
  48.         // $newItems = 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->findForNewItemsList($this->getUser(), $isManager);
  49.         // 2016/12/27 sahara 呼び出し元を変更
  50.         $newItems 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewDealSales')->findForNewItemsList($this->getUser(), $isManager);
  51.         // 2017/1/23 hagio TOP画面 新着一覧・案件一覧に分配率を表示するように変更
  52.         $newItemDealIds = array();
  53.         foreach ($newItems as $item) {
  54.             $newViewItemWithDeal $item['view_item_with_deal'];
  55.             $newItemDeal $newViewItemWithDeal->getItemDeal();
  56.             $newItemDealIds[] = $newItemDeal->getId();
  57.         }
  58.         $tmpNewItemSalesList 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:Sales')->getEmployeeSalesByDealIds($newItemDealIds);
  59.  
  60.         $newSalesList = array();
  61.         foreach ($tmpNewItemSalesList as $sales) {
  62.             $newSalesList[$sales->getItemDealId()][$sales->getEmployeeId()] = $sales;
  63.         }
  64.         // * 取引中案件一覧
  65.         // $items = 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->findForProcessItemsList($this->getUser(), $isManager);
  66.         $items 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewDealSales')->findForProcessItemsList($this->getUser(), $isManager);
  67.         $itemDealIds = array();
  68.         foreach ($items as $item) {
  69.             $viewItemWithDeal $item['view_item_with_deal'];
  70.             $itemDeal $viewItemWithDeal->getItemDeal();
  71.             $itemDealIds[] = $itemDeal->getId();
  72.         }
  73.         $tmpItemSalesList 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:Sales')->getEmployeeSalesByDealIds($itemDealIds);
  74.         
  75.         $salesList = array();
  76.         foreach ($tmpItemSalesList as $sales) {
  77.             $salesList[$sales->getItemDealId()][$sales->getEmployeeId()] = $sales;
  78.         }
  79.         // key: branch_idの配列に整形 + 合計を取得
  80.         $itemList = array();
  81.         $branchItemsTotalSales = array();
  82.         foreach ($items as $item) {
  83.             $itemsBranchId $item['view_item_with_deal']->getEmployeeBranchId();
  84.             // 配列の整形
  85.             $itemList[$itemsBranchId][] = $item;
  86.             // 売上合計(or予定売上合計)を集計(~万円
  87.             if (!isset($branchItemsTotalSales[$itemsBranchId])) {
  88.                 $branchItemsTotalSales[$itemsBranchId] = 0;
  89.             }
  90.             $branchItemsTotalSales[$itemsBranchId] += \Kzl\ToolBundle\Calc\Round::jpFloorMan($item['view_item_with_deal']->getItemDeal()->getOrCalcTotalSales(), falsefalse);
  91.         }
  92.         // ------- 実績集計 --------------------------
  93.         // ** 実績集計
  94.         // 実績集計対象のID
  95.         $resultsTargetIds = array();
  96.         if ($isManager) {
  97.             $resultsTargetIds $targetBranchIds;
  98.         } else {
  99.             $resultsTargetIds = array($this->getUser()->getEmployeeId());
  100.         }
  101.         // 集計結果取得 key: branch_id
  102.         // 2016/12/27 sahara 処理の呼び出し元変更
  103.         // $yearResults = 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->getRankDataForTop(true, $isManager, $resultsTargetIds);
  104.         $yearResults 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewDealSales')->getRankDataForTop(true$isManager$resultsTargetIds);
  105.         // 2016/12/27 sahara 処理の呼び出し元変更
  106.         // $monthResults = 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->getRankDataForTop(false, $isManager, $resultsTargetIds);
  107.         $monthResults 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewDealSales')->getRankDataForTop(false$isManager$resultsTargetIds);
  108.         // 集計結果格納
  109.         $results = array(
  110.             'year' => $yearResults,
  111.             'month' => $monthResults
  112.         );
  113.         // * グラフ表示用 key:branch_id, [year_manage , month_sales ...]
  114.         // $yearGraphData = 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->getYearGraphDataForTop($resultsTargetIds, $isManager);
  115.         // $monthlyGraphData = 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewItemWithDeal')->getMonthlyGraphDataForTop($resultsTargetIds, $isManager);
  116.         // 2016/12/27 sahara 処理の呼び出し元を変更
  117.         $yearGraphData 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewDealSales')->getYearGraphDataForTop($resultsTargetIds$isManager);
  118.         $monthlyGraphData 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ViewDealSales')->getMonthlyGraphDataForTop($resultsTargetIds$isManager);
  119.         $graphDataList = array(
  120.             'year' => $yearGraphData,
  121.             'month' => $monthlyGraphData
  122.         );
  123.         $kimatsu \Times\EigyoBundle\Common\TimesStatic::getSystemManager()->getKimatsu();
  124.         $today \Kzl\ToolBundle\Util\DateTime::getDateToDay();
  125.         $interVal \Kzl\ToolBundle\Util\DateTime::getIntervalDays($today$kimatsu'%r%m');
  126.         // 小さいほうのグラフの系列最大idx
  127.         $graphMinEnd = array(
  128.             'year' => 5*1,
  129.             'month' => 12 $interVal 1
  130.         );
  131.         // ※ TODO項目名称の一覧を取得しておく
  132.         $itemNames 'Kzl\BaseBundle\Common\KzlStatic'::getKzlRepository('TimesEigyoBundle:ItemName')->getTodoItemNameList();
  133.         return $this->render('@TimesEigyo/Top/index.html.twig', array(
  134.                     'news' => $news,
  135.                     'todo_news_list' => $todoCheckList,
  136.                     'new_items' => $newItems,
  137.                     'results' => $results,
  138.                     'items' => $itemList,
  139.                     'target_branch_ids' => $targetBranchIds,
  140.                     'is_branch_admin' => $targetBranchIds !== false,
  141.                     'todo_item_name_list' => $itemNames,
  142.                     'branch_total_sales' => $branchItemsTotalSales,
  143.                     'graph_data_list' => $graphDataList,
  144.                     'graph_min_end' => $graphMinEnd,
  145.                     'new_sales_list' => $newSalesList,
  146.                     'sales_list' => $salesList,
  147.         ));
  148.     }
  149.     /**
  150.      * 実績の集計
  151.      * @param type $targetKind
  152.      * @param type $targetId
  153.      * @return \Times\EigyoBundle\Entity\Virtual\SalesResults
  154.      */
  155. //    private function summaryResults($targetKind, $targetId)
  156. //    {
  157. //        $results = array(
  158. //            'month'  => new SalesResults(),
  159. //            'year'  => new SalesResults(),
  160. //        );
  161. //        $results['month']->summary( SalesResults::KIND_MONTH, $targetKind, $targetId, true );
  162. //        $results['year']->summary( SalesResults::KIND_YEAR, $targetKind, $targetId, true );
  163. //
  164. //        return $results;
  165. //    }
  166.     /**
  167.      * 仮:資料用画面イメージ そのうち移植して本番開発へ
  168.      * @param type $param
  169.      * @return type
  170.      */
  171. //    public function dummyAction($param){
  172. //        if($param == 1){
  173. //            return $this->render('@TimesEigyo/Top/input_response_report.html.twig');
  174. //        }else{
  175. //            return $this->render('@TimesEigyo/Top/input_response_report.html.twig');
  176. //        }
  177. //    }
  178.     // ------ 15/4/16 mitsunaga ダミー画面表示用 ---------
  179.     /**
  180.      * ダミー画面表示アクション
  181.      * @param string $param
  182.      * @return \Symfony\Component\HttpFoundation\Response
  183.      */
  184.     public function showDummyViewsAction($param)
  185.     {
  186.         //$view = '';
  187.         $views = array(
  188.             '@todo' => 'TimesEigyo/Dummy/todo_index.html.twig',
  189.             '@hikitsugi' => 'TimesEigyo/Dummy/hikitsugi_index.html.twig',
  190.             '@item' => 'TimesEigyo/Dummy/item_index.html.twig',
  191.             '@nippou' => 'TimesEigyo/Dummy/nippou_index.html.twig',
  192.             '@hankyo' => 'TimesEigyo/Dummy/hankyo_index.html.twig',
  193.             '@hankyo_input' => 'TimesEigyo/Dummy/hankyo_input.html.twig',
  194.         );
  195.         return $this->render($views[$param]);
  196.     }
  197. }