/**
  * onRenderProductListBefore.
  *
  * @param FilterResponseEvent $event
  */
 public function onRenderProductListBefore(FilterResponseEvent $event)
 {
     log_info('CategoryContent eccube.event.render.product_list.before start');
     $app = $this->app;
     $request = $event->getRequest();
     $response = $event->getResponse();
     $id = $request->query->get('category_id');
     // category_idがない場合、レンダリングを変更しない
     if (!$id) {
         return;
     }
     $CategoryContent = $app['eccube.plugin.category_content.repository.category_content']->find($id);
     // 登録がない、もしくは空で登録されている場合、レンダリングを変更しない
     if (!$CategoryContent || !$CategoryContent->getContent()) {
         log_info('CategoryContent eccube.event.render.product_list.before  not content end');
         return;
     }
     // twigから挿入するhtmlを生成する
     $snipet = $this->app->renderView('CategoryContent/Resource/template/default/category_content.twig', array('PluginCategoryContent' => $CategoryContent));
     // htmlの挿入処理
     $html = $response->getContent();
     $search = self::CATEGORY_CONTENT_TAG;
     if (strpos($html, $search)) {
         // タグの位置に挿入する場合
         log_info('Render category content with ', array('CATEGORY_CONTENT_TAG' => $search));
         $replace = $search . $snipet;
         $newHtml = str_replace($search, $replace, $html);
         $response->setContent($newHtml);
     } else {
         // Elementを探して挿入する場合
         libxml_use_internal_errors(true);
         $dom = new \DOMDocument();
         $dom->loadHTML('<?xml encoding="UTF-8">' . $html);
         $dom->encoding = 'UTF-8';
         $dom->formatOutput = true;
         // 基準となるElementを取得
         $navElement = $dom->getElementById('topicpath');
         if (!$navElement instanceof \DOMElement) {
             log_info('CategoryContent eccube.event.render.product_list.before  not have dom end');
             return;
         }
         // 挿入するNodeを生成
         $template = $dom->createDocumentFragment();
         $template->appendXML(htmlspecialchars($snipet));
         $node = $dom->importNode($template, true);
         // 基準となるElementの直後にNodeを挿入し、Responsを書き換え
         $navElement->parentNode->insertBefore($node, $navElement->nextSibling);
         $newHtml = html_entity_decode($dom->saveHTML(), ENT_NOQUOTES, 'UTF-8');
         $response->setContent($newHtml);
     }
     $event->setResponse($response);
     log_info('CategoryContent eccube.event.render.product_list.before end');
 }
Exemplo n.º 2
0
 /**
  *
  *
  * @param FilterResponseEvent $event
  */
 public function onRenderOembedAdminProductDetailEditBefore(FilterResponseEvent $event)
 {
     $request = $event->getRequest();
     $response = $event->getResponse();
     $parts_btn = $this->app->renderView('Oembed/Resource/template/admin/embed-button.twig', array());
     $parts_modal = $this->app->renderView('Oembed/Resource/template/admin/embed-modal.twig', array());
     $crawler = new HtmlPageCrawler($response->getContent());
     $crawler->filter('#admin_product_free_area')->before($parts_btn);
     $crawler->filter('body')->append($parts_modal);
     //        $html = $this->getHtml($crawler);
     $html = $crawler->html();
     $html = html_entity_decode($html, ENT_NOQUOTES, 'UTF-8');
     $response->setContent($html);
     $event->setResponse($response);
 }
 public function searchProduct(Application $app, Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         $searchData = array('id' => $request->get('id'));
         if ($categoryId = $request->get('category_id')) {
             $Category = $app['eccube.repository.category']->find($categoryId);
             $searchData['category_id'] = $Category;
         }
         /** @var $Products \Eccube\Entity\Product[] */
         $Products = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData)->getQuery()->getResult();
         // 表示されている商品は検索結果に含めない
         $productId = $request->get('product_id');
         $ProductsData = array();
         $count = count($Products);
         $i = 0;
         for ($i = 0; $i < $count; $i++) {
             $Product = $Products[$i];
             if ($Product->getId() != $productId) {
                 $ProductsData[] = $Product;
             }
             if ($i >= 10) {
                 break;
             }
         }
         $message = '';
         if ($count > $i) {
             $message = '検索結果の上限を超えています。検索条件を設定してください。';
         }
         return $app->renderView('RelatedProduct/Resource/template/Admin/modal_result.twig', array('Products' => $ProductsData, 'message' => $message));
     }
 }
Exemplo n.º 4
0
 /**
  * Send password reset notification mail.
  *
  * @param $Customer 会員情報
  */
 public function sendPasswordResetCompleteMail(\Eccube\Entity\Customer $Customer, $password)
 {
     $body = $this->app->renderView('Mail/reset_complete_mail.twig', array('Customer' => $Customer, 'password' => $password));
     $message = \Swift_Message::newInstance()->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のお知らせ')->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))->setTo(array($Customer->getEmail()))->setBcc($this->BaseInfo->getEmail01())->setReplyTo($this->BaseInfo->getEmail03())->setReturnPath($this->BaseInfo->getEmail04())->setBody($body);
     $event = new EventArgs(array('message' => $message, 'Customer' => $Customer, 'BaseInfo' => $this->BaseInfo, 'password' => $password), null);
     $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_PASSWORD_RESET_COMPLETE, $event);
     $this->app->mail($message);
 }
 public function searchProduct(Application $app, Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         $searchData = array('id' => $request->get('id'));
         if ($categoryId = $request->get('category_id')) {
             $Category = $app['eccube.repository.category']->find($categoryId);
             $searchData['category_id'] = $Category;
         }
         /** @var $Products \Eccube\Entity\Product[] */
         $Products = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData)->getQuery()->getResult();
         return $app->renderView('RelatedProduct/Resource/template/Admin/modal_result.twig', array('Products' => $Products));
     }
 }
 /**
  * HTMLの加工
  *
  * @param Request $request
  * @param Response $response
  * @return string
  */
 private function getHtmlWrapping($request, $response)
 {
     $crawler = new Crawler($response->getContent());
     $html = $this->getHtml($crawler);
     /** @var FormFactory $formFactory */
     //        $formFactory = $this->app['form.factory'];
     //        $form = $formFactory->createBuilder('shopping')->getForm();
     //
     $parts = $this->app->renderView('ListingAdCsv\\Resource\\template\\Admin\\dropdown_parts.twig');
     // TODO 挿入位置の指定方法、もっとよい方法ないのか?
     try {
         $crawler = $crawler->filter('ul.sort-dd');
         if ($crawler->count() != 0) {
             $oldHtml = $crawler->last()->html();
             $newHtml = $oldHtml . $parts;
             $html = str_replace($oldHtml, $newHtml, $html);
         }
     } catch (\InvalidArgumentException $e) {
         // ignore
     }
     return $html;
 }
Exemplo n.º 7
0
 public function index(Application $app, Request $request, $page_no = null)
 {
     $session = $request->getSession();
     $pagination = array();
     $searchForm = $app['form.factory']->createBuilder('admin_search_customer')->getForm();
     //アコーディオンの制御初期化( デフォルトでは閉じる )
     $active = false;
     $pageMaxis = $app['eccube.repository.master.page_max']->findAll();
     $page_count = $app['config']['default_page_count'];
     if ('POST' === $request->getMethod()) {
         $searchForm->handleRequest($request);
         if ($searchForm->isValid()) {
             $searchData = $searchForm->getData();
             // paginator
             $qb = $app['eccube.repository.customer']->getQueryBuilderBySearchData($searchData);
             $page_no = 1;
             $pagination = $app['paginator']()->paginate($qb, $page_no, $page_count);
             // sessionのデータ保持
             $session->set('eccube.admin.customer.search', $searchData);
         }
     } else {
         if (is_null($page_no)) {
             // sessionを削除
             $session->remove('eccube.admin.customer.search');
         } else {
             // pagingなどの処理
             $searchData = $session->get('eccube.admin.customer.search');
             if (!is_null($searchData)) {
                 // 表示件数
                 $pcount = $request->get('page_count');
                 $page_count = empty($pcount) ? $page_count : $pcount;
                 $qb = $app['eccube.repository.customer']->getQueryBuilderBySearchData($searchData);
                 $pagination = $app['paginator']()->paginate($qb, $page_no, $page_count);
                 // セッションから検索条件を復元
                 if (count($searchData['sex']) > 0) {
                     $sex_ids = array();
                     foreach ($searchData['sex'] as $Sex) {
                         $sex_ids[] = $Sex->getId();
                     }
                     $searchData['sex'] = $app['eccube.repository.master.sex']->findBy(array('id' => $sex_ids));
                 }
                 if (!is_null($searchData['pref'])) {
                     $searchData['pref'] = $app['eccube.repository.master.pref']->find($searchData['pref']->getId());
                 }
                 $searchForm->setData($searchData);
             }
         }
     }
     return $app->renderView('Customer/index.twig', array('searchForm' => $searchForm->createView(), 'pagination' => $pagination, 'pageMaxis' => $pageMaxis, 'page_no' => $page_no, 'page_count' => $page_count, 'active' => $active));
 }
Exemplo n.º 8
0
 /**
  * ご注文内容のご確認画面のHTMLを取得し、関連項目を書き込む
  * お支払方法の下に下記の項目を追加する.(id=confirm_main )
  * ・クーポンコードボタン
  * 送料のの下に下記の項目を追加する.(class=total_box total_amountの上)
  * ・値引き表示
  *
  * @param Request $request
  * @param Response $response
  * @param Order $Order
  * @return mixed|string
  */
 private function getHtmlShopping(Request $request, Response $response, Order $Order)
 {
     // HTMLを取得し、DOM化
     $crawler = new Crawler($response->getContent());
     $html = $this->getHtml($crawler);
     try {
         // クーポンが未入力でクーポン情報が存在すればクーポン情報を削除
         $CouponOrder = $this->app['eccube.plugin.coupon.service.coupon']->getCouponOrder($Order->getPreOrderId());
         $parts = $this->app->renderView('Coupon/View/coupon_shopping_item.twig', array('CouponOrder' => $CouponOrder));
         // このタグを前後に分割し、間に項目を入れ込む
         $beforeHtml = $crawler->filter('#confirm_main')->last()->html();
         $pos = strrpos($beforeHtml, '<h2 class="heading02">');
         if ($pos !== false) {
             $oldHtml = substr($beforeHtml, 0, $pos);
             $afterHtml = substr($beforeHtml, $pos);
             $newHtml = $oldHtml . $parts . $afterHtml;
             $html = str_replace($beforeHtml, $newHtml, $html);
         }
         if (!version_compare('3.0.10', Constant::VERSION, '<=')) {
             // 値引き項目を表示
             if ($CouponOrder) {
                 $total = $Order->getTotal() - $CouponOrder->getDiscount();
                 $Order->setTotal($total);
                 $Order->setPaymentTotal($total);
                 // 合計、値引きを再計算し、dtb_orderを更新する
                 $this->app['orm.em']->flush($Order);
                 // このタグを前後に分割し、間に項目を入れ込む
                 // 元の合計金額は書き込み済みのため再度書き込みを行う
                 $parts = $this->app->renderView('Coupon/View/discount_shopping_item.twig', array('Order' => $Order));
                 $form = $crawler->filter('#confirm_side .total_box')->last()->html();
                 $pos = strrpos($form, '</dl>');
                 if ($pos !== false) {
                     $oldHtml = substr($form, 0, $pos);
                     $newHtml = $oldHtml . $parts;
                     $html = str_replace($form, $newHtml, $html);
                 }
             }
         }
     } catch (\InvalidArgumentException $e) {
         // no-op
     }
     return $html;
 }
Exemplo n.º 9
0
 public function view(Application $app, Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         $id = $request->get('id');
         $MailHistory = $app['eccube.repository.mail_history']->find($id);
         if (is_null($MailHistory)) {
             throw new NotFoundHttpException('history not found.');
         }
         return $app->renderView('Order/mail_view.twig', array('subject' => $MailHistory->getSubject(), 'body' => $MailHistory->getMailBody()));
     }
 }
Exemplo n.º 10
0
 public function index(Application $app, Request $request, $page_no = null)
 {
     $session = $app['session'];
     $searchForm = $app['form.factory']->createBuilder('admin_search_product')->getForm();
     $pagination = array();
     $disps = $app['eccube.repository.master.disp']->findAll();
     $pageMaxis = $app['eccube.repository.master.page_max']->findAll();
     $page_count = $app['config']['default_page_count'];
     $page_status = null;
     $active = false;
     if ('POST' === $request->getMethod()) {
         $searchForm->handleRequest($request);
         if ($searchForm->isValid()) {
             $searchData = $searchForm->getData();
             // paginator
             $qb = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData);
             $page_no = 1;
             $pagination = $app['paginator']()->paginate($qb, $page_no, $page_count);
             // sessionのデータ保持
             $session->set('eccube.admin.product.search', $searchData);
             $active = true;
         }
     } else {
         if (is_null($page_no)) {
             // sessionを削除
             $session->remove('eccube.admin.product.search');
         } else {
             // pagingなどの処理
             $searchData = $session->get('eccube.admin.product.search');
             if (!is_null($searchData)) {
                 // 公開ステータス
                 $status = $request->get('status');
                 if (!empty($status)) {
                     if ($status != $app['config']['admin_product_stock_status']) {
                         $searchData['link_status'] = $app['eccube.repository.master.disp']->find($status);
                         $searchData['status'] = null;
                         $session->set('eccube.admin.product.search', $searchData);
                     } else {
                         $searchData['stock_status'] = Constant::DISABLED;
                     }
                     $page_status = $status;
                 } else {
                     $searchData['link_status'] = null;
                     $searchData['stock_status'] = null;
                 }
                 // 表示件数
                 $pcount = $request->get('page_count');
                 $page_count = empty($pcount) ? $page_count : $pcount;
                 $qb = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData);
                 $pagination = $app['paginator']()->paginate($qb, $page_no, $page_count);
                 // セッションから検索条件を復元
                 if (!empty($searchData['category_id'])) {
                     $searchData['category_id'] = $app['eccube.repository.category']->find($searchData['category_id']);
                 }
                 if (empty($status)) {
                     if (count($searchData['status']) > 0) {
                         $status_ids = array();
                         foreach ($searchData['status'] as $Status) {
                             $status_ids[] = $Status->getId();
                         }
                         $searchData['status'] = $app['eccube.repository.master.disp']->findBy(array('id' => $status_ids));
                     }
                     $searchData['link_status'] = null;
                     $searchData['stock_status'] = null;
                 }
                 /*
                 if (count($searchData['product_status']) > 0) {
                     $product_status_ids = array();
                     foreach ($searchData['product_status'] as $ProductStatus) {
                         $product_status_ids[] = $ProductStatus->getId();
                     }
                     $searchData['product_status'] = $app['eccube.repository.master.product_status']->findBy(array('id' => $product_status_ids));
                 }
                 */
                 $searchForm->setData($searchData);
                 $active = true;
             }
         }
     }
     return $app->renderView('Product/index.twig', array('searchForm' => $searchForm->createView(), 'pagination' => $pagination, 'disps' => $disps, 'pageMaxis' => $pageMaxis, 'page_no' => $page_no, 'page_status' => $page_status, 'page_count' => $page_count, 'active' => $active));
 }
Exemplo n.º 11
0
 /**
  * 購入処理
  */
 public function confirm(Application $app, Request $request)
 {
     $cartService = $app['eccube.service.cart'];
     // カートチェック
     if (!$cartService->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
     if (!$Order) {
         $app->addError('front.shopping.order.error');
         return $app->redirect($app->url('shopping_error'));
     }
     if ('POST' !== $request->getMethod()) {
         return $app->redirect($app->url('cart'));
     }
     // form作成
     $form = $app['eccube.service.shopping']->getShippingForm($Order);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getData();
         // トランザクション制御
         $em = $app['orm.em'];
         $em->getConnection()->beginTransaction();
         try {
             // 商品公開ステータスチェック、商品制限数チェック、在庫チェック
             $check = $app['eccube.service.shopping']->isOrderProduct($em, $Order);
             if (!$check) {
                 $em->getConnection()->rollback();
                 $app->addError('front.shopping.stock.error');
                 return $app->redirect($app->url('shopping_error'));
             }
             // 受注情報、配送情報を更新
             $app['eccube.service.shopping']->setOrderUpdate($Order, $data);
             // 在庫情報を更新
             $app['eccube.service.shopping']->setStockUpdate($em, $Order);
             if ($app->isGranted('ROLE_USER')) {
                 // 会員の場合、購入金額を更新
                 $app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user());
             }
             $em->flush();
             $em->getConnection()->commit();
         } catch (\Exception $e) {
             $em->getConnection()->rollback();
             $app->log($e);
             $app->addError('front.shopping.system.error');
             return $app->redirect($app->url('shopping_error'));
         }
         // カート削除
         $app['eccube.service.cart']->clear()->save();
         // メール送信
         $app['eccube.service.mail']->sendOrderMail($Order);
         // 受注IDをセッションにセット
         $app['session']->set($this->sessionOrderKey, $Order->getId());
         // 送信履歴を保存.
         $MailTemplate = $app['eccube.repository.mail_template']->find(1);
         $body = $app->renderView($MailTemplate->getFileName(), array('header' => $MailTemplate->getHeader(), 'footer' => $MailTemplate->getFooter(), 'Order' => $Order));
         $MailHistory = new MailHistory();
         $MailHistory->setSubject('[' . $app['eccube.repository.base_info']->get()->getShopName() . '] ' . $MailTemplate->getSubject())->setMailBody($body)->setMailTemplate($MailTemplate)->setSendDate(new \DateTime())->setOrder($Order);
         $app['orm.em']->persist($MailHistory);
         $app['orm.em']->flush($MailHistory);
         // 完了画面表示
         return $app->redirect($app->url('shopping_complete'));
     }
     return $app->render('Shopping/index.twig', array('form' => $form->createView(), 'Order' => $Order));
 }
Exemplo n.º 12
0
 /**
  * Complete
  *
  * @param  Application $app
  * @return mixed
  */
 public function complete(Application $app, Request $request)
 {
     return $app->renderView('Mypage/withdraw_complete.twig');
 }
Exemplo n.º 13
0
 /**
  * Send password reset notification mail.
  *
  * @param $Customer 会員情報
  */
 public function sendPasswordResetCompleteMail(\Eccube\Entity\Customer $Customer, $password)
 {
     $body = $this->app->renderView('Mail/reset_complete_mail.twig', array('Customer' => $Customer, 'password' => $password));
     $message = \Swift_Message::newInstance()->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のお知らせ')->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))->setTo(array($Customer->getEmail()))->setBcc($this->BaseInfo->getEmail01())->setReplyTo($this->BaseInfo->getEmail03())->setReturnPath($this->BaseInfo->getEmail04())->setBody($body);
     $this->app->mail($message);
 }
Exemplo n.º 14
0
 public function agreement(Application $app)
 {
     $Help = $app['eccube.repository.help']->get();
     return $app->renderView('Help/agreement.twig', array('help' => $Help));
 }