| @@ 40-186 (lines=147) @@ | ||
| 37 | class OrderController extends AbstractController |
|
| 38 | { |
|
| 39 | ||
| 40 | public function index(Application $app, Request $request, $page_no = null) |
|
| 41 | { |
|
| 42 | ||
| 43 | $session = $request->getSession(); |
|
| 44 | ||
| 45 | $builder = $app['form.factory'] |
|
| 46 | ->createBuilder(SearchOrderType::class); |
|
| 47 | ||
| 48 | $event = new EventArgs( |
|
| 49 | array( |
|
| 50 | 'builder' => $builder, |
|
| 51 | ), |
|
| 52 | $request |
|
| 53 | ); |
|
| 54 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_INITIALIZE, $event); |
|
| 55 | ||
| 56 | $searchForm = $builder->getForm(); |
|
| 57 | ||
| 58 | $pagination = array(); |
|
| 59 | ||
| 60 | $disps = $app['eccube.repository.master.disp']->findAll(); |
|
| 61 | $pageMaxis = $app['eccube.repository.master.page_max']->findAll(); |
|
| 62 | $page_count = $app['config']['default_page_count']; |
|
| 63 | $page_status = null; |
|
| 64 | $active = false; |
|
| 65 | ||
| 66 | if ('POST' === $request->getMethod()) { |
|
| 67 | ||
| 68 | $searchForm->handleRequest($request); |
|
| 69 | ||
| 70 | if ($searchForm->isValid()) { |
|
| 71 | $searchData = $searchForm->getData(); |
|
| 72 | ||
| 73 | // paginator |
|
| 74 | $qb = $app['eccube.repository.order']->getQueryBuilderBySearchDataForAdmin($searchData); |
|
| 75 | ||
| 76 | $event = new EventArgs( |
|
| 77 | array( |
|
| 78 | 'form' => $searchForm, |
|
| 79 | 'qb' => $qb, |
|
| 80 | ), |
|
| 81 | $request |
|
| 82 | ); |
|
| 83 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event); |
|
| 84 | ||
| 85 | $page_no = 1; |
|
| 86 | $pagination = $app['paginator']()->paginate( |
|
| 87 | $qb, |
|
| 88 | $page_no, |
|
| 89 | $page_count |
|
| 90 | ); |
|
| 91 | ||
| 92 | // sessionのデータ保持 |
|
| 93 | $session->set('eccube.admin.order.search', $searchData); |
|
| 94 | $session->set('eccube.admin.order.search.page_no', $page_no); |
|
| 95 | } |
|
| 96 | } else { |
|
| 97 | if (is_null($page_no) && $request->get('resume') != Constant::ENABLED) { |
|
| 98 | // sessionを削除 |
|
| 99 | $session->remove('eccube.admin.order.search'); |
|
| 100 | $session->remove('eccube.admin.order.search.page_no'); |
|
| 101 | } else { |
|
| 102 | // pagingなどの処理 |
|
| 103 | $searchData = $session->get('eccube.admin.order.search'); |
|
| 104 | if (is_null($page_no)) { |
|
| 105 | $page_no = intval($session->get('eccube.admin.order.search.page_no')); |
|
| 106 | } else { |
|
| 107 | $session->set('eccube.admin.order.search.page_no', $page_no); |
|
| 108 | } |
|
| 109 | ||
| 110 | if (!is_null($searchData)) { |
|
| 111 | ||
| 112 | // 公開ステータス |
|
| 113 | $status = $request->get('status'); |
|
| 114 | if (!empty($status)) { |
|
| 115 | if ($status != $app['config']['admin_product_stock_status']) { |
|
| 116 | $searchData['status']->clear(); |
|
| 117 | $searchData['status']->add($status); |
|
| 118 | } else { |
|
| 119 | $searchData['stock_status'] = $app['config']['disabled']; |
|
| 120 | } |
|
| 121 | $page_status = $status; |
|
| 122 | } |
|
| 123 | // 表示件数 |
|
| 124 | $pcount = $request->get('page_count'); |
|
| 125 | ||
| 126 | $page_count = empty($pcount) ? $page_count : $pcount; |
|
| 127 | ||
| 128 | $qb = $app['eccube.repository.order']->getQueryBuilderBySearchDataForAdmin($searchData); |
|
| 129 | ||
| 130 | $event = new EventArgs( |
|
| 131 | array( |
|
| 132 | 'form' => $searchForm, |
|
| 133 | 'qb' => $qb, |
|
| 134 | ), |
|
| 135 | $request |
|
| 136 | ); |
|
| 137 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event); |
|
| 138 | ||
| 139 | $pagination = $app['paginator']()->paginate( |
|
| 140 | $qb, |
|
| 141 | $page_no, |
|
| 142 | $page_count |
|
| 143 | ); |
|
| 144 | ||
| 145 | // セッションから検索条件を復元 |
|
| 146 | if (!empty($searchData['status'])) { |
|
| 147 | $searchData['status'] = $app['eccube.repository.master.order_status']->find($searchData['status']); |
|
| 148 | } |
|
| 149 | if (count($searchData['multi_status']) > 0) { |
|
| 150 | $statusIds = array(); |
|
| 151 | foreach ($searchData['multi_status'] as $Status) { |
|
| 152 | $statusIds[] = $Status->getId(); |
|
| 153 | } |
|
| 154 | $searchData['multi_status'] = $app['eccube.repository.master.order_status']->findBy(array('id' => $statusIds)); |
|
| 155 | } |
|
| 156 | if (count($searchData['sex']) > 0) { |
|
| 157 | $sex_ids = array(); |
|
| 158 | foreach ($searchData['sex'] as $Sex) { |
|
| 159 | $sex_ids[] = $Sex->getId(); |
|
| 160 | } |
|
| 161 | $searchData['sex'] = $app['eccube.repository.master.sex']->findBy(array('id' => $sex_ids)); |
|
| 162 | } |
|
| 163 | if (count($searchData['payment']) > 0) { |
|
| 164 | $payment_ids = array(); |
|
| 165 | foreach ($searchData['payment'] as $Payment) { |
|
| 166 | $payment_ids[] = $Payment->getId(); |
|
| 167 | } |
|
| 168 | $searchData['payment'] = $app['eccube.repository.payment']->findBy(array('id' => $payment_ids)); |
|
| 169 | } |
|
| 170 | $searchForm->setData($searchData); |
|
| 171 | } |
|
| 172 | } |
|
| 173 | } |
|
| 174 | ||
| 175 | return $app->render('Order/index.twig', array( |
|
| 176 | 'searchForm' => $searchForm->createView(), |
|
| 177 | 'pagination' => $pagination, |
|
| 178 | 'disps' => $disps, |
|
| 179 | 'pageMaxis' => $pageMaxis, |
|
| 180 | 'page_no' => $page_no, |
|
| 181 | 'page_status' => $page_status, |
|
| 182 | 'page_count' => $page_count, |
|
| 183 | 'active' => $active, |
|
| 184 | )); |
|
| 185 | ||
| 186 | } |
|
| 187 | ||
| 188 | public function delete(Application $app, Request $request, $id) |
|
| 189 | { |
|
| @@ 42-186 (lines=145) @@ | ||
| 39 | * @param Application $app |
|
| 40 | * @return \Symfony\Component\HttpFoundation\Response |
|
| 41 | */ |
|
| 42 | public function index(Application $app, Request $request, $page_no = null) |
|
| 43 | { |
|
| 44 | $session = $request->getSession(); |
|
| 45 | ||
| 46 | $builder = $app['form.factory'] |
|
| 47 | ->createBuilder(SearchOrderType::class); |
|
| 48 | ||
| 49 | $event = new EventArgs( |
|
| 50 | array( |
|
| 51 | 'builder' => $builder, |
|
| 52 | ), |
|
| 53 | $request |
|
| 54 | ); |
|
| 55 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_INITIALIZE, $event); |
|
| 56 | ||
| 57 | $searchForm = $builder->getForm(); |
|
| 58 | ||
| 59 | $pagination = array(); |
|
| 60 | ||
| 61 | $disps = $app['eccube.repository.master.disp']->findAll(); |
|
| 62 | $pageMaxis = $app['eccube.repository.master.page_max']->findAll(); |
|
| 63 | $page_count = $app['config']['default_page_count']; |
|
| 64 | $page_status = null; |
|
| 65 | $active = false; |
|
| 66 | ||
| 67 | if ('POST' === $request->getMethod()) { |
|
| 68 | ||
| 69 | $searchForm->handleRequest($request); |
|
| 70 | ||
| 71 | if ($searchForm->isValid()) { |
|
| 72 | $searchData = $searchForm->getData(); |
|
| 73 | ||
| 74 | // paginator |
|
| 75 | $qb = $app['eccube.repository.shipping']->getQueryBuilderBySearchDataForAdmin($searchData); |
|
| 76 | ||
| 77 | $event = new EventArgs( |
|
| 78 | array( |
|
| 79 | 'form' => $searchForm, |
|
| 80 | 'qb' => $qb, |
|
| 81 | ), |
|
| 82 | $request |
|
| 83 | ); |
|
| 84 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event); |
|
| 85 | ||
| 86 | $page_no = 1; |
|
| 87 | $pagination = $app['paginator']()->paginate( |
|
| 88 | $qb, |
|
| 89 | $page_no, |
|
| 90 | $page_count |
|
| 91 | ); |
|
| 92 | ||
| 93 | // sessionのデータ保持 |
|
| 94 | $session->set('eccube.admin.shipping.search', $searchData); |
|
| 95 | $session->set('eccube.admin.shipping.search.page_no', $page_no); |
|
| 96 | } |
|
| 97 | } else { |
|
| 98 | if (is_null($page_no) && $request->get('resume') != Constant::ENABLED) { |
|
| 99 | // sessionを削除 |
|
| 100 | $session->remove('eccube.admin.shipping.search'); |
|
| 101 | $session->remove('eccube.admin.shipping.search.page_no'); |
|
| 102 | } else { |
|
| 103 | // pagingなどの処理 |
|
| 104 | $searchData = $session->get('eccube.admin.shipping.search'); |
|
| 105 | if (is_null($page_no)) { |
|
| 106 | $page_no = intval($session->get('eccube.admin.shipping.search.page_no')); |
|
| 107 | } else { |
|
| 108 | $session->set('eccube.admin.shipping.search.page_no', $page_no); |
|
| 109 | } |
|
| 110 | ||
| 111 | if (!is_null($searchData)) { |
|
| 112 | ||
| 113 | // 公開ステータス |
|
| 114 | $status = $request->get('status'); |
|
| 115 | if (!empty($status)) { |
|
| 116 | if ($status != $app['config']['admin_product_stock_status']) { |
|
| 117 | $searchData['status']->clear(); |
|
| 118 | $searchData['status']->add($status); |
|
| 119 | } else { |
|
| 120 | $searchData['stock_status'] = $app['config']['disabled']; |
|
| 121 | } |
|
| 122 | $page_status = $status; |
|
| 123 | } |
|
| 124 | // 表示件数 |
|
| 125 | $pcount = $request->get('page_count'); |
|
| 126 | ||
| 127 | $page_count = empty($pcount) ? $page_count : $pcount; |
|
| 128 | ||
| 129 | $qb = $app['eccube.repository.shipping']->getQueryBuilderBySearchDataForAdmin($searchData); |
|
| 130 | ||
| 131 | $event = new EventArgs( |
|
| 132 | array( |
|
| 133 | 'form' => $searchForm, |
|
| 134 | 'qb' => $qb, |
|
| 135 | ), |
|
| 136 | $request |
|
| 137 | ); |
|
| 138 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event); |
|
| 139 | ||
| 140 | $pagination = $app['paginator']()->paginate( |
|
| 141 | $qb, |
|
| 142 | $page_no, |
|
| 143 | $page_count |
|
| 144 | ); |
|
| 145 | ||
| 146 | // セッションから検索条件を復元 |
|
| 147 | if (!empty($searchData['status'])) { |
|
| 148 | $searchData['status'] = $app['eccube.repository.master.order_status']->find($searchData['status']); |
|
| 149 | } |
|
| 150 | if (count($searchData['multi_status']) > 0) { |
|
| 151 | $statusIds = array(); |
|
| 152 | foreach ($searchData['multi_status'] as $Status) { |
|
| 153 | $statusIds[] = $Status->getId(); |
|
| 154 | } |
|
| 155 | $searchData['multi_status'] = $app['eccube.repository.master.order_status']->findBy(array('id' => $statusIds)); |
|
| 156 | } |
|
| 157 | if (count($searchData['sex']) > 0) { |
|
| 158 | $sex_ids = array(); |
|
| 159 | foreach ($searchData['sex'] as $Sex) { |
|
| 160 | $sex_ids[] = $Sex->getId(); |
|
| 161 | } |
|
| 162 | $searchData['sex'] = $app['eccube.repository.master.sex']->findBy(array('id' => $sex_ids)); |
|
| 163 | } |
|
| 164 | if (count($searchData['payment']) > 0) { |
|
| 165 | $payment_ids = array(); |
|
| 166 | foreach ($searchData['payment'] as $Payment) { |
|
| 167 | $payment_ids[] = $Payment->getId(); |
|
| 168 | } |
|
| 169 | $searchData['payment'] = $app['eccube.repository.payment']->findBy(array('id' => $payment_ids)); |
|
| 170 | } |
|
| 171 | $searchForm->setData($searchData); |
|
| 172 | } |
|
| 173 | } |
|
| 174 | } |
|
| 175 | ||
| 176 | return [ |
|
| 177 | 'searchForm' => $searchForm->createView(), |
|
| 178 | 'pagination' => $pagination, |
|
| 179 | 'disps' => $disps, |
|
| 180 | 'pageMaxis' => $pageMaxis, |
|
| 181 | 'page_no' => $page_no, |
|
| 182 | 'page_status' => $page_status, |
|
| 183 | 'page_count' => $page_count, |
|
| 184 | 'active' => $active, |
|
| 185 | ]; |
|
| 186 | } |
|
| 187 | } |
|
| 188 | ||