Exemplo n.º 1
0
 /**
  * 退会画面.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     $builder = $app->form();
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         switch ($request->get('mode')) {
             case 'confirm':
                 return $app->render('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
             case 'complete':
                 /* @var $Customer \Eccube\Entity\Customer */
                 $Customer = $app->user();
                 // 会員削除
                 $email = $Customer->getEmail();
                 // メールアドレスにダミーをセット
                 $Customer->setEmail(Str::random(60) . '@dummy.dummy');
                 $Customer->setDelFlg(Constant::ENABLED);
                 $app['orm.em']->flush();
                 $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event);
                 // メール送信
                 $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
                 // ログアウト
                 $this->getSecurity($app)->setToken(null);
                 return $app->redirect($app->url('mypage_withdraw_complete'));
         }
     }
     return $app->render('Mypage/withdraw.twig', array('form' => $form->createView()));
 }
Exemplo n.º 2
0
 /**
  * Index
  *
  * @param  Application $app
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function index(Application $app, Request $request)
 {
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $app->form()->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             switch ($request->get('mode')) {
                 case 'confirm':
                     return $app->renderView('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
                 case 'complete':
                     /* @var $Customer \Eccube\Entity\Customer */
                     $Customer = $app->user();
                     // 会員削除
                     $email = $Customer->getEmail();
                     // メールアドレスにダミーをセット
                     $Customer->setEmail(Str::random(60) . '@dummy.dummy');
                     $Customer->setDelFlg(Constant::ENABLED);
                     $app['orm.em']->flush();
                     // メール送信
                     $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
                     // ログアウト
                     $this->getSecurity($app)->setToken(null);
                     return $app->redirect($app->url('mypage_withdraw_complete'));
             }
         }
     }
     return $app->renderView('Mypage/withdraw.twig', array('form' => $form->createView()));
 }
Exemplo n.º 3
0
 public function edit(Application $app, Request $request, $id = null)
 {
     $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     $PageLayout = $app['eccube.repository.page_layout']->findOrCreate($id, $DeviceType);
     $editable = true;
     $builder = $app['form.factory']->createBuilder('main_edit', $PageLayout);
     $event = new EventArgs(array('builder' => $builder, 'DeviceType' => $DeviceType, 'PageLayout' => $PageLayout), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_EDIT_INITIALIZE, $event);
     $form = $builder->getForm();
     // 更新時
     $fileName = null;
     if ($id) {
         // 編集不可ページはURL、ページ名、ファイル名を保持
         if ($PageLayout->getEditFlg() == PageLayout::EDIT_FLG_DEFAULT) {
             $editable = false;
             $PrevPageLayout = clone $PageLayout;
         }
         // テンプレートファイルの取得
         $file = $app['eccube.repository.page_layout']->getReadTemplateFile($PageLayout->getFileName(), $editable);
         $form->get('tpl_data')->setData($file['tpl_data']);
         $fileName = $PageLayout->getFileName();
     }
     if ('POST' === $app['request']->getMethod()) {
         $form->handleRequest($app['request']);
         if ($form->isValid()) {
             $PageLayout = $form->getData();
             if (!$editable) {
                 $PageLayout->setUrl($PrevPageLayout->getUrl())->setFileName($PrevPageLayout->getFileName())->setName($PrevPageLayout->getName());
             }
             // DB登録
             $app['orm.em']->persist($PageLayout);
             $app['orm.em']->flush();
             // ファイル生成・更新
             $templatePath = $app['eccube.repository.page_layout']->getWriteTemplatePath($editable);
             $filePath = $templatePath . '/' . $PageLayout->getFileName() . '.twig';
             $fs = new Filesystem();
             $pageData = $form->get('tpl_data')->getData();
             $pageData = Str::convertLineFeed($pageData);
             $fs->dumpFile($filePath, $pageData);
             // 更新でファイル名を変更した場合、以前のファイルを削除
             if ($PageLayout->getFileName() != $fileName && !is_null($fileName)) {
                 $oldFilePath = $templatePath . '/' . $fileName . '.twig';
                 if ($fs->exists($oldFilePath)) {
                     $fs->remove($oldFilePath);
                 }
             }
             $event = new EventArgs(array('form' => $form, 'PageLayout' => $PageLayout, 'templatePath' => $templatePath, 'filePath' => $filePath), $request);
             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_EDIT_COMPLETE, $event);
             $app->addSuccess('admin.register.complete', 'admin');
             // twig キャッシュの削除.
             $finder = Finder::create()->in($app['config']['root_dir'] . '/app/cache/twig');
             $fs->remove($finder);
             return $app->redirect($app->url('admin_content_page_edit', array('id' => $PageLayout->getId())));
         }
     }
     $templatePath = $app['eccube.repository.page_layout']->getWriteTemplatePath($editable);
     return $app->render('Content/page_edit.twig', array('form' => $form->createView(), 'page_id' => $PageLayout->getId(), 'editable' => $editable, 'template_path' => $templatePath));
 }
Exemplo n.º 4
0
 public function createTempDir()
 {
     @mkdir($this->app['config']['plugin_temp_realdir']);
     $d = $this->app['config']['plugin_temp_realdir'] . '/' . sha1(Str::random(16));
     if (!mkdir($d, 0777)) {
         throw new PluginException($php_errormsg . $d);
     }
     return $d;
 }
Exemplo n.º 5
0
 public function edit(Application $app, Request $request, $id = null)
 {
     $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     $Block = $app['eccube.repository.block']->findOrCreate($id, $DeviceType);
     if (!$Block) {
         throw new NotFoundHttpException();
     }
     $builder = $app['form.factory']->createBuilder('block', $Block);
     $html = '';
     $previous_filename = null;
     $deletable = $Block->getDeletableFlg();
     if ($id) {
         // テンプレートファイルの取得
         $previous_filename = $Block->getFileName();
         $file = $app['eccube.repository.block']->getReadTemplateFile($previous_filename, $deletable);
         $html = $file['tpl_data'];
     }
     $event = new EventArgs(array('builder' => $builder, 'DeviceType' => $DeviceType, 'Block' => $Block, 'html' => $html), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_BLOCK_EDIT_INITIALIZE, $event);
     $html = $event->getArgument('html');
     $form = $builder->getForm();
     $form->get('block_html')->setData($html);
     if ($app['request']->getMethod() === 'POST') {
         $form->handleRequest($app['request']);
         if ($form->isValid()) {
             $Block = $form->getData();
             // DB登録
             $app['orm.em']->persist($Block);
             $app['orm.em']->flush();
             // ファイル生成・更新
             $tplDir = $app['config']['block_realdir'];
             $filePath = $tplDir . '/' . $Block->getFileName() . '.twig';
             $fs = new Filesystem();
             $blockData = $form->get('block_html')->getData();
             $blockData = Str::convertLineFeed($blockData);
             $fs->dumpFile($filePath, $blockData);
             // 更新でファイル名を変更した場合、以前のファイルを削除
             if ($Block->getFileName() != $previous_filename && !is_null($previous_filename)) {
                 $oldFilePath = $tplDir . '/' . $previous_filename . '.twig';
                 if ($fs->exists($oldFilePath)) {
                     $fs->remove($oldFilePath);
                 }
             }
             \Eccube\Util\Cache::clear($app, false);
             $event = new EventArgs(array('form' => $form, 'Block' => $Block), $request);
             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_BLOCK_EDIT_COMPLETE, $event);
             $app->addSuccess('admin.register.complete', 'admin');
             return $app->redirect($app->url('admin_content_block_edit', array('id' => $Block->getId())));
         }
     }
     return $app->render('Content/block_edit.twig', array('form' => $form->createView(), 'block_id' => $id, 'deletable' => $deletable));
 }
 public function testCountCouponByCd()
 {
     $Coupon = $this->getCoupon();
     $discount = 200;
     $preOrderId = sha1(Str::random(32));
     $CouponOrder = $this->getCouponOrder($Coupon, $discount, $preOrderId);
     $CouponOrder->setOrderDate(new \DateTime());
     $this->app['eccube.plugin.coupon.repository.coupon_order']->save($CouponOrder);
     $count = $this->app['eccube.plugin.coupon.repository.coupon_order']->countCouponByCd($Coupon->getCouponCd());
     $this->actual = $count['1'];
     $this->expected = 1;
     $this->verify();
 }
Exemplo n.º 7
0
 public function update(Application $app, $id)
 {
     $Plugin = $app['eccube.repository.plugin']->find($id);
     $form = $app['form.factory']->createNamedBuilder('form' . $id, 'plugin_management', null, array('plugin_id' => null, 'enable' => null))->getForm();
     $form->handleRequest($app['request']);
     $tmpDir = $app['eccube.service.plugin']->createTempDir();
     $tmpFile = sha1(Str::random(32)) . ".tar";
     $form['plugin_archive']->getData()->move($tmpDir, $tmpFile);
     $app['eccube.service.plugin']->update($Plugin, $tmpDir . '/' . $tmpFile);
     $app->addSuccess('admin.plugin.update.complete', 'admin');
     $fs = new Filesystem();
     $fs->remove($tmpDir . '/' . $tmpFile);
     return $app->redirect($app->url('admin_setting_store_plugin'));
 }
Exemplo n.º 8
0
 private function createConfigYamlFile($data)
 {
     $fs = new Filesystem();
     $config_file = $this->config_path . '/config.yml';
     if ($fs->exists($config_file)) {
         $fs->remove($config_file);
     }
     $auth_magic = Str::random(32);
     $allowHost = Str::convertLineFeed($data['admin_allow_hosts']);
     if (empty($allowHost)) {
         $adminAllowHosts = array();
     } else {
         $adminAllowHosts = explode("\n", $allowHost);
     }
     $target = array('${AUTH_MAGIC}', '${SHOP_NAME}', '${ECCUBE_INSTALL}', '${FORCE_SSL}');
     $replace = array($auth_magic, $data['shop_name'], '0', $data['admin_force_ssl']);
     $fs = new Filesystem();
     $content = str_replace($target, $replace, file_get_contents($this->dist_path . '/config.yml.dist'));
     $fs->dumpFile($config_file, $content);
     $config = Yaml::Parse($config_file);
     $config['admin_allow_host'] = $adminAllowHosts;
     $yml = Yaml::dump($config);
     file_put_contents($config_file, $yml);
     return $this;
 }
Exemplo n.º 9
0
 /**
  *
  * @param  array        $searchData
  * @return QueryBuilder
  */
 public function getQueryBuilderBySearchDataForAdmin($searchData)
 {
     $qb = $this->createQueryBuilder('o');
     // order_id_start
     if (isset($searchData['order_id_start']) && Str::isNotBlank($searchData['order_id_start'])) {
         $qb->andWhere('o.id >= :order_id_start')->setParameter('order_id_start', $searchData['order_id_start']);
     }
     // multi
     if (isset($searchData['multi']) && Str::isNotBlank($searchData['multi'])) {
         $multi = preg_match('/^\\d+$/', $searchData['multi']) ? $searchData['multi'] : null;
         $qb->andWhere('o.id = :multi OR o.name01 LIKE :likemulti OR o.name02 LIKE :likemulti OR ' . 'o.kana01 LIKE :likemulti OR o.kana02 LIKE :likemulti OR o.company_name LIKE :likemulti')->setParameter('multi', $multi)->setParameter('likemulti', '%' . $searchData['multi'] . '%');
     }
     // order_id_end
     if (isset($searchData['order_id_end']) && Str::isNotBlank($searchData['order_id_end'])) {
         $qb->andWhere('o.id <= :order_id_end')->setParameter('order_id_end', $searchData['order_id_end']);
     }
     // status
     $filterStatus = false;
     if (!empty($searchData['status']) && $searchData['status']) {
         $qb->andWhere('o.OrderStatus = :status')->setParameter('status', $searchData['status']);
         $filterStatus = true;
     }
     if (!empty($searchData['multi_status']) && count($searchData['multi_status'])) {
         $qb->andWhere($qb->expr()->in('o.OrderStatus', ':multi_status'))->setParameter('multi_status', $searchData['multi_status']->toArray());
         $filterStatus = true;
     }
     if (!$filterStatus) {
         // 購入処理中は検索対象から除外
         $OrderStatuses = $this->getEntityManager()->getRepository('Eccube\\Entity\\Master\\OrderStatus')->findNotContainsBy(array('id' => $this->app['config']['order_processing']));
         $qb->andWhere($qb->expr()->in('o.OrderStatus', ':status'))->setParameter('status', $OrderStatuses);
     }
     // name
     if (isset($searchData['name']) && Str::isNotBlank($searchData['name'])) {
         $qb->andWhere('CONCAT(o.name01, o.name02) LIKE :name')->setParameter('name', '%' . $searchData['name'] . '%');
     }
     // kana
     if (isset($searchData['kana']) && Str::isNotBlank($searchData['kana'])) {
         $qb->andWhere('CONCAT(o.kana01, o.kana02) LIKE :kana')->setParameter('kana', '%' . $searchData['kana'] . '%');
     }
     // email
     if (isset($searchData['email']) && Str::isNotBlank($searchData['email'])) {
         $qb->andWhere('o.email like :email')->setParameter('email', '%' . $searchData['email'] . '%');
     }
     // tel
     if (isset($searchData['tel']) && Str::isNotBlank($searchData['tel'])) {
         $qb->andWhere('CONCAT(o.tel01, o.tel02, o.tel03) LIKE :tel')->setParameter('tel', '%' . $searchData['tel'] . '%');
     }
     // sex
     if (!empty($searchData['sex']) && count($searchData['sex']) > 0) {
         $qb->andWhere($qb->expr()->in('o.Sex', ':sex'))->setParameter('sex', $searchData['sex']->toArray());
     }
     // payment
     if (!empty($searchData['payment']) && count($searchData['payment'])) {
         $payments = array();
         foreach ($searchData['payment'] as $payment) {
             $payments[] = $payment->getId();
         }
         $qb->leftJoin('o.Payment', 'p')->andWhere($qb->expr()->in('p.id', ':payments'))->setParameter('payments', $payments);
     }
     // oreder_date
     if (!empty($searchData['order_date_start']) && $searchData['order_date_start']) {
         $date = $searchData['order_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('o.order_date >= :order_date_start')->setParameter('order_date_start', $date);
     }
     if (!empty($searchData['order_date_end']) && $searchData['order_date_end']) {
         $date = clone $searchData['order_date_end'];
         $date = $date->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('o.order_date < :order_date_end')->setParameter('order_date_end', $date);
     }
     // payment_date
     if (!empty($searchData['payment_date_start']) && $searchData['payment_date_start']) {
         $date = $searchData['payment_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('o.payment_date >= :payment_date_start')->setParameter('payment_date_start', $date);
     }
     if (!empty($searchData['payment_date_end']) && $searchData['payment_date_end']) {
         $date = clone $searchData['payment_date_end'];
         $date = $date->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('o.payment_date < :payment_date_end')->setParameter('payment_date_end', $date);
     }
     // commit_date
     if (!empty($searchData['commit_date_start']) && $searchData['commit_date_start']) {
         $date = $searchData['commit_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('o.commit_date >= :commit_date_start')->setParameter('commit_date_start', $date);
     }
     if (!empty($searchData['commit_date_end']) && $searchData['commit_date_end']) {
         $date = clone $searchData['commit_date_end'];
         $date = $date->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('o.commit_date < :commit_date_end')->setParameter('commit_date_end', $date);
     }
     // update_date
     if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) {
         $date = $searchData['update_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('o.update_date >= :update_date_start')->setParameter('update_date_start', $date);
     }
     if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) {
         $date = clone $searchData['update_date_end'];
         $date = $date->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('o.update_date < :update_date_end')->setParameter('update_date_end', $date);
     }
     // payment_total
     if (isset($searchData['payment_total_start']) && Str::isNotBlank($searchData['payment_total_start'])) {
         $qb->andWhere('o.payment_total >= :payment_total_start')->setParameter('payment_total_start', $searchData['payment_total_start']);
     }
     if (isset($searchData['payment_total_end']) && Str::isNotBlank($searchData['payment_total_end'])) {
         $qb->andWhere('o.payment_total <= :payment_total_end')->setParameter('payment_total_end', $searchData['payment_total_end']);
     }
     // buy_product_name
     if (isset($searchData['buy_product_name']) && Str::isNotBlank($searchData['buy_product_name'])) {
         $qb->leftJoin('o.OrderDetails', 'od')->andWhere('od.product_name LIKE :buy_product_name')->setParameter('buy_product_name', '%' . $searchData['buy_product_name'] . '%');
     }
     // Order By
     $qb->addOrderBy('o.update_date', 'DESC');
     return $qb;
 }
Exemplo n.º 10
0
 public function getResetPassword()
 {
     return Str::random(8);
 }
Exemplo n.º 11
0
 public function add(Application $app, Request $request)
 {
     /** @var $Template \Eccube\Entity\Template */
     $Template = new \Eccube\Entity\Template();
     $form = $app['form.factory']->createBuilder('admin_template', $Template)->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             /** @var $Template \Eccube\Entity\Template */
             $tem = $app['eccube.repository.template']->findByCode($form['code']->getData());
             // テンプレートコードの重複チェック.
             if ($tem) {
                 $form['code']->addError(new FormError('すでに登録されているテンプレートコードです。'));
                 return false;
             }
             // 該当テンプレートのディレクトリ
             $config = $app['config'];
             $templateCode = $Template->getCode();
             $targetRealDir = $config['root_dir'] . '/app/template/' . $templateCode;
             $targetHtmlRealDir = $config['root_dir'] . '/html/template/' . $templateCode;
             // 一時ディレクトリ
             $uniqId = sha1(Str::random(32));
             $tmpDir = $config['template_temp_realdir'] . '/' . $uniqId;
             $appDir = $tmpDir . '/app';
             $htmlDir = $tmpDir . '/html';
             $formFile = $form['file']->getData();
             // ファイル名
             $archive = $templateCode . '.' . $formFile->getClientOriginalExtension();
             // ファイルを一時ディレクトリへ移動.
             $formFile->move($tmpDir, $archive);
             // 一時ディレクトリへ解凍する.
             try {
                 if ($formFile->getClientOriginalExtension() == 'zip') {
                     $zip = new \ZipArchive();
                     $zip->open($tmpDir . '/' . $archive);
                     $zip->extractTo($tmpDir);
                     $zip->close();
                 } else {
                     $phar = new \PharData($tmpDir . '/' . $archive);
                     $phar->extractTo($tmpDir, null, true);
                 }
             } catch (\Exception $e) {
                 $form['file']->addError(new FormError('アップロードに失敗しました。圧縮ファイルを確認してください。'));
                 return $app->render('Store/template_add.twig', array('form' => $form->createView()));
             }
             // appディレクトリの存在チェック.
             if (!file_exists($appDir)) {
                 $form['file']->addError(new FormError('appディレクトリが見つかりません。ファイルの形式を確認してください。'));
                 if (file_exists($tmpDir)) {
                     $fs = new Filesystem();
                     $fs->remove($tmpDir);
                 }
                 return $app->render('Store/template_add.twig', array('form' => $form->createView()));
             }
             // htmlディレクトリの存在チェック.
             if (!file_exists($htmlDir)) {
                 $form['file']->addError(new FormError('htmlディレクトリが見つかりません。ファイルの形式を確認してください。'));
                 if (file_exists($tmpDir)) {
                     $fs = new Filesystem();
                     $fs->remove($tmpDir);
                 }
                 return $app->render('Store/template_add.twig', array('form' => $form->createView()));
             }
             // 一時ディレクトリから該当テンプレートのディレクトリへコピーする.
             $fs = new Filesystem();
             $fs->mirror($appDir, $targetRealDir);
             $fs->mirror($htmlDir, $targetHtmlRealDir);
             // 一時ディレクトリを削除.
             $fs->remove($tmpDir);
             $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
             $Template->setDeviceType($DeviceType);
             $app['orm.em']->persist($Template);
             $app['orm.em']->flush();
             $app->addSuccess('admin.content.template.add.complete', 'admin');
             return $app->redirect($app->url('admin_store_template'));
         }
     }
     return $app->render('Store/template_add.twig', array('form' => $form->createView()));
 }
 /**
  * 検索条件での検索を行う。
  * s
  * @param unknown $searchData
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getQueryBuilderBySearchData($searchData)
 {
     // メルマガを受け取るカスタマーのIDを取得する
     $mailmagaCustomerIds = $this->getMailmagaCustomerIds();
     $qb = $this->createQueryBuilder('c')->select('c')->andWhere('c.del_flg = 0');
     // メルマガを受け取るカスタマーのみに絞る
     if (count($mailmagaCustomerIds) > 0) {
         // メルマガ送付カスタマーがいれば対象カスタマーのみ対象とする
         $qb->andWhere($qb->expr()->in('c.id', $mailmagaCustomerIds));
     } else {
         // メルマガ送付カスタマーがいなければ強制的に非表示にする条件を追加する
         $qb->andWhere('c.id < 0');
     }
     if (isset($searchData['multi']) && Str::isNotBlank($searchData['multi'])) {
         //スペース除去
         $clean_key_multi = preg_replace('/\\s+|[ ]+/u', '', $searchData['multi']);
         if (preg_match('/^\\d+$/', $clean_key_multi)) {
             $qb->andWhere('c.id = :customer_id')->setParameter('customer_id', $clean_key_multi);
         } else {
             $qb->andWhere('CONCAT(c.name01, c.name02) LIKE :name OR CONCAT(c.kana01, c.kana02) LIKE :kana OR c.email LIKE :email')->setParameter('name', '%' . $clean_key_multi . '%')->setParameter('kana', '%' . $clean_key_multi . '%')->setParameter('email', '%' . $clean_key_multi . '%');
         }
     }
     // Pref
     if (!empty($searchData['pref']) && $searchData['pref']) {
         $qb->andWhere('c.Pref = :pref')->setParameter('pref', $searchData['pref']->getId());
     }
     // sex
     if (!empty($searchData['sex']) && count($searchData['sex']) > 0) {
         $sexs = array();
         foreach ($searchData['sex'] as $sex) {
             $sexs[] = $sex->getId();
         }
         $qb->andWhere($qb->expr()->in('c.Sex', ':sexs'))->setParameter('sexs', $sexs);
     }
     // birth_month
     if (is_int($searchData['birth_month'])) {
         //Birth month start from 0 so we need plus 1.
         $searchData['birth_month']++;
         $birthMonth = $searchData['birth_month'];
         if ($searchData['birth_month'] < 10) {
             $birthMonth = '0' . $searchData['birth_month'];
         }
         //because can not use SUBSTRING with timestamp field. Use concat for convert to date => String(can not use convert func in doctrine)
         $qb->andWhere("SUBSTRING(CONCAT(c.birth, '0'), 6, 2) = :birth_month")->setParameter('birth_month', $birthMonth);
     }
     // birth
     if (!empty($searchData['birth_start']) && $searchData['birth_start']) {
         $date = $searchData['birth_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.birth >= :birth_start')->setParameter('birth_start', $date);
     }
     if (!empty($searchData['birth_end']) && $searchData['birth_end']) {
         $date = $searchData['birth_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.birth < :birth_end')->setParameter('birth_end', $date);
     }
     // tel
     if (!empty($searchData['tel01']) && $searchData['tel01']) {
         $qb->andWhere('c.tel01 = :tel01')->setParameter('tel01', $searchData['tel01']);
     }
     if (!empty($searchData['tel02']) && $searchData['tel02']) {
         $qb->andWhere('c.tel02 = :tel02')->setParameter('tel02', $searchData['tel02']);
     }
     if (!empty($searchData['tel03']) && $searchData['tel03']) {
         $qb->andWhere('c.tel03 = :tel03')->setParameter('tel03', $searchData['tel03']);
     }
     // buy_total
     if (!empty($searchData['buy_total_start']) && $searchData['buy_total_start']) {
         $qb->andWhere('c.buy_total >= :buy_total_start')->setParameter('buy_total_start', $searchData['buy_total_start']);
     }
     if (!empty($searchData['buy_total_end']) && $searchData['buy_total_end']) {
         $qb->andWhere('c.buy_total <= :buy_total_end')->setParameter('buy_total_end', $searchData['buy_total_end']);
     }
     // buy_times
     if (!empty($searchData['buy_times_start']) && $searchData['buy_times_start']) {
         $qb->andWhere('c.buy_times >= :buy_times_start')->setParameter('buy_times_start', $searchData['buy_times_start']);
     }
     if (!empty($searchData['buy_times_end']) && $searchData['buy_times_end']) {
         $qb->andWhere('c.buy_times <= :buy_times_end')->setParameter('buy_times_end', $searchData['buy_times_end']);
     }
     // create_date
     if (!empty($searchData['create_date_start']) && $searchData['create_date_start']) {
         $date = $searchData['create_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.create_date >= :create_date_start')->setParameter('create_date_start', $date);
     }
     if (!empty($searchData['create_date_end']) && $searchData['create_date_end']) {
         $date = $searchData['create_date_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.create_date < :create_date_end')->setParameter('create_date_end', $date);
     }
     // update_date
     if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) {
         $date = $searchData['update_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.update_date >= :update_date_start')->setParameter('update_date_start', $date);
     }
     if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) {
         $date = $searchData['update_date_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.update_date < :update_date_end')->setParameter('update_date_end', $date);
     }
     // last_buy
     if (!empty($searchData['last_buy_start']) && $searchData['last_buy_start']) {
         $date = $searchData['last_buy_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.last_buy_date >= :last_buy_start')->setParameter('last_buy_start', $date);
     }
     if (!empty($searchData['last_buy_end']) && $searchData['last_buy_end']) {
         $date = $searchData['last_buy_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.last_buy_date < :last_buy_end')->setParameter('last_buy_end', $date);
     }
     // status
     if (!empty($searchData['customer_status']) && count($searchData['customer_status']) > 0) {
         $customerStatus = array();
         foreach ($searchData['customer_status'] as $val) {
             $customerStatus[] = $val->getId();
         }
         $qb->andWhere($qb->expr()->in('c.Status', ':statuses'))->setParameter('statuses', $customerStatus);
     }
     // buy_product_name、buy_product_code
     if (!empty($searchData['buy_product_code']) && $searchData['buy_product_code']) {
         $qb->leftJoin('c.Orders', 'o')->leftJoin('o.OrderDetails', 'od')->andWhere('od.product_name LIKE :buy_product_name OR od.product_code LIKE :buy_product_name')->setParameter('buy_product_name', '%' . $searchData['buy_product_code'] . '%');
     }
     // Order By
     $qb->addOrderBy('c.update_date', 'DESC');
     return $qb;
 }
Exemplo n.º 13
0
 public function index(Application $app, Request $request)
 {
     $builder = $app['form.factory']->createBuilder('admin_security');
     $form = $builder->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             // 現在のセキュリティ情報を更新
             $adminRoot = $app['config']['admin_route'];
             $configFile = $app['config']['root_dir'] . '/app/config/eccube/config.yml';
             $config = Yaml::parse(file_get_contents($configFile));
             // trim処理
             $allowHost = Str::convertLineFeed($data['admin_allow_host']);
             if (empty($allowHost)) {
                 $config['admin_allow_host'] = null;
             } else {
                 $config['admin_allow_host'] = explode("\n", $allowHost);
             }
             if ($data['force_ssl']) {
                 // SSL制限にチェックをいれた場合、https経由で接続されたか確認
                 if ($request->isSecure()) {
                     // httpsでアクセスされたらSSL制限をチェック
                     $config['force_ssl'] = Constant::ENABLED;
                 } else {
                     // httpから変更されたらfalseのまま
                     $config['force_ssl'] = Constant::DISABLED;
                     $data['force_ssl'] = (bool) Constant::DISABLED;
                 }
             } else {
                 $config['force_ssl'] = Constant::DISABLED;
             }
             $form = $builder->getForm();
             $form->setData($data);
             file_put_contents($configFile, Yaml::dump($config));
             if ($adminRoot != $data['admin_route_dir']) {
                 // admin_routeが変更されればpath.ymlを更新
                 $pathFile = $app['config']['root_dir'] . '/app/config/eccube/path.yml';
                 $config = Yaml::parse(file_get_contents($pathFile));
                 $config['admin_route'] = $data['admin_route_dir'];
                 file_put_contents($pathFile, Yaml::dump($config));
                 $app->addSuccess('admin.system.security.route.dir.complete', 'admin');
                 // ログアウト
                 $this->getSecurity($app)->setToken(null);
                 // 管理者画面へ再ログイン
                 return $app->redirect($request->getBaseUrl() . '/' . $config['admin_route']);
             }
             $app->addSuccess('admin.system.security.save.complete', 'admin');
         }
     } else {
         // セキュリティ情報の取得
         $form->get('admin_route_dir')->setData($app['config']['admin_route']);
         $allowHost = $app['config']['admin_allow_host'];
         if (count($allowHost) > 0) {
             $form->get('admin_allow_host')->setData(Str::convertLineFeed(implode("\n", $allowHost)));
         }
         $form->get('force_ssl')->setData((bool) $app['config']['force_ssl']);
     }
     return $app->render('Setting/System/security.twig', array('form' => $form->createView()));
 }
Exemplo n.º 14
0
 /**
  * オーナーズブラグインインストール、アップデート
  *
  * @param Application $app
  * @param Request $request
  * @param $action
  * @param $id
  * @param $version
  */
 public function upgrade(Application $app, Request $request, $action, $id, $version)
 {
     $BaseInfo = $app['eccube.repository.base_info']->get();
     $authKey = $BaseInfo->getAuthenticationKey();
     $message = '';
     if (!is_null($authKey)) {
         // オーナーズストア通信
         $url = $app['config']['owners_store_url'] . '?method=download&product_id=' . $id;
         list($json, $httpHeader) = $this->getRequestApi($request, $authKey, $url);
         if ($json === false) {
             // 接続失敗時
             $message = $this->getResponseErrorMessage($httpHeader);
         } else {
             // 接続成功時
             $data = json_decode($json, true);
             if (isset($data['success'])) {
                 $success = $data['success'];
                 if ($success == '1') {
                     $tmpDir = null;
                     try {
                         $service = $app['eccube.service.plugin'];
                         $item = $data['item'];
                         $file = base64_decode($item['data']);
                         $extension = pathinfo($item['file_name'], PATHINFO_EXTENSION);
                         $tmpDir = $service->createTempDir();
                         $tmpFile = sha1(Str::random(32)) . '.' . $extension;
                         // ファイル作成
                         $fs = new Filesystem();
                         $fs->dumpFile($tmpDir . '/' . $tmpFile, $file);
                         if ($action == 'install') {
                             $service->install($tmpDir . '/' . $tmpFile, $id);
                             $app->addSuccess('admin.plugin.install.complete', 'admin');
                         } else {
                             if ($action == 'update') {
                                 $Plugin = $app['eccube.repository.plugin']->findOneBy(array('source' => $id));
                                 $service->update($Plugin, $tmpDir . '/' . $tmpFile);
                                 $app->addSuccess('admin.plugin.update.complete', 'admin');
                                 Cache::clear($app, false);
                             }
                         }
                         $fs = new Filesystem();
                         $fs->remove($tmpDir);
                         // ダウンロード完了通知処理(正常終了時)
                         $url = $app['config']['owners_store_url'] . '?method=commit&product_id=' . $id . '&status=1&version=' . $version;
                         $this->getRequestApi($request, $authKey, $url);
                         return $app->redirect($app->url('admin_store_plugin'));
                     } catch (PluginException $e) {
                         if (!empty($tmpDir) && file_exists($tmpDir)) {
                             $fs = new Filesystem();
                             $fs->remove($tmpDir);
                         }
                         $message = $e->getMessage();
                     }
                 } else {
                     $message = $data['error_code'] . ' : ' . $data['error_message'];
                 }
             } else {
                 $message = "EC-CUBEオーナーズストアにエラーが発生しています。";
             }
         }
     }
     // ダウンロード完了通知処理(エラー発生時)
     $url = $app['config']['owners_store_url'] . '?method=commit&product_id=' . $id . '&status=0&version=' . $version . '&message=' . urlencode($message);
     $this->getRequestApi($request, $authKey, $url);
     $app->addError($message, 'admin');
     return $app->redirect($app->url('admin_store_plugin_owners_install'));
 }
Exemplo n.º 15
0
 /**
  * 文字列の先頭から指定した文字数を切り出す
  * 改行コードは削除する。
  * @param $text
  * @param int $count 切り出す文字数
  * @return string
  */
 public static function clipText($text, $count)
 {
     return Str::convertLineFeed(mb_substr($text, 0, $count, 'UTF-8'), '');
 }
Exemplo n.º 16
0
 /**
  * 商品規格情報を更新
  */
 protected function updateProductClass($row, Product $Product, ProductClass $ProductClass, $app, $data)
 {
     $ProductClass->setProduct($Product);
     if ($row['商品種別(ID)'] == '') {
         $this->addErrors($data->key() + 1 . '行目の商品種別(ID)が設定されていません。');
     } else {
         if (preg_match('/^\\d+$/', $row['商品種別(ID)'])) {
             $ProductType = $app['eccube.repository.master.product_type']->find($row['商品種別(ID)']);
             if (!$ProductType) {
                 $this->addErrors($data->key() + 1 . '行目の商品種別(ID)が存在しません。');
             } else {
                 $ProductClass->setProductType($ProductType);
             }
         } else {
             $this->addErrors($data->key() + 1 . '行目の商品種別(ID)が存在しません。');
         }
     }
     // 規格分類1、2をそれぞれセットし作成
     if ($row['規格分類1(ID)'] != '') {
         if (preg_match('/^\\d+$/', $row['規格分類1(ID)'])) {
             $ClassCategory = $app['eccube.repository.class_category']->find($row['規格分類1(ID)']);
             if (!$ClassCategory) {
                 $this->addErrors($data->key() + 1 . '行目の規格分類1(ID)が存在しません。');
             } else {
                 $ProductClass->setClassCategory1($ClassCategory);
             }
         } else {
             $this->addErrors($data->key() + 1 . '行目の規格分類1(ID)が存在しません。');
         }
     }
     if ($row['規格分類2(ID)'] != '') {
         if (preg_match('/^\\d+$/', $row['規格分類2(ID)'])) {
             $ClassCategory = $app['eccube.repository.class_category']->find($row['規格分類2(ID)']);
             if (!$ClassCategory) {
                 $this->addErrors($data->key() + 1 . '行目の規格分類2(ID)が存在しません。');
             } else {
                 $ProductClass->setClassCategory2($ClassCategory);
             }
         } else {
             $this->addErrors($data->key() + 1 . '行目の規格分類2(ID)が存在しません。');
         }
     }
     if ($row['発送日目安(ID)'] != '') {
         if (preg_match('/^\\d+$/', $row['発送日目安(ID)'])) {
             $DeliveryDate = $app['eccube.repository.delivery_date']->find($row['発送日目安(ID)']);
             if (!$DeliveryDate) {
                 $this->addErrors($data->key() + 1 . '行目の発送日目安(ID)が存在しません。');
             } else {
                 $ProductClass->setDeliveryDate($DeliveryDate);
             }
         } else {
             $this->addErrors($data->key() + 1 . '行目の発送日目安(ID)が存在しません。');
         }
     }
     if (Str::isNotBlank($row['商品コード'])) {
         $ProductClass->setCode(Str::trimAll($row['商品コード']));
     } else {
         $ProductClass->setCode(null);
     }
     if ($row['在庫数無制限フラグ'] == '') {
         $this->addErrors($data->key() + 1 . '行目の在庫数無制限フラグが設定されていません。');
     } else {
         if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
             $ProductClass->setStockUnlimited(Constant::DISABLED);
             // 在庫数が設定されていなければエラー
             if ($row['在庫数'] == '') {
                 $this->addErrors($data->key() + 1 . '行目の在庫数が設定されていません。');
             } else {
                 $stock = str_replace(',', '', $row['在庫数']);
                 if (preg_match('/^\\d+$/', $stock) && $stock >= 0) {
                     $ProductClass->setStock($row['在庫数']);
                 } else {
                     $this->addErrors($data->key() + 1 . '行目の在庫数は0以上の数値を設定してください。');
                 }
             }
         } else {
             if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
                 $ProductClass->setStockUnlimited(Constant::ENABLED);
                 $ProductClass->setStock(null);
             } else {
                 $this->addErrors($data->key() + 1 . '行目の在庫数無制限フラグが設定されていません。');
             }
         }
     }
     if ($row['販売制限数'] != '') {
         $saleLimit = str_replace(',', '', $row['販売制限数']);
         if (preg_match('/^\\d+$/', $saleLimit) && $saleLimit >= 0) {
             $ProductClass->setSaleLimit($saleLimit);
         } else {
             $this->addErrors($data->key() + 1 . '行目の販売制限数は0以上の数値を設定してください。');
         }
     }
     if ($row['通常価格'] != '') {
         $price01 = str_replace(',', '', $row['通常価格']);
         if (preg_match('/^\\d+$/', $price01) && $price01 >= 0) {
             $ProductClass->setPrice01($price01);
         } else {
             $this->addErrors($data->key() + 1 . '行目の通常価格は0以上の数値を設定してください。');
         }
     }
     if ($row['販売価格'] == '') {
         $this->addErrors($data->key() + 1 . '行目の販売価格が設定されていません。');
     } else {
         $price02 = str_replace(',', '', $row['販売価格']);
         if (preg_match('/^\\d+$/', $price02) && $price02 >= 0) {
             $ProductClass->setPrice02($price02);
         } else {
             $this->addErrors($data->key() + 1 . '行目の販売価格は0以上の数値を設定してください。');
         }
     }
     if ($row['商品規格削除フラグ'] == '') {
         $ProductClass->setDelFlg(Constant::DISABLED);
     } else {
         if ($row['商品規格削除フラグ'] == (string) Constant::DISABLED || $row['商品規格削除フラグ'] == (string) Constant::ENABLED) {
             $ProductClass->setDelFlg($row['商品規格削除フラグ']);
         } else {
             $this->addErrors($data->key() + 1 . '行目の商品規格削除フラグが設定されていません。');
         }
     }
     $ProductStock = $ProductClass->getProductStock();
     if (!$ProductClass->getStockUnlimited()) {
         $ProductStock->setStock($ProductClass->getStock());
     } else {
         // 在庫無制限時はnullを設定
         $ProductStock->setStock(null);
     }
     return $ProductClass;
 }
Exemplo n.º 17
0
 /**
  * 複数配送処理がクリックされた場合の処理
  */
 public function shippingMultipleChange(Application $app, Request $request)
 {
     $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'));
     }
     $form = $app['eccube.service.shopping']->getShippingForm($Order);
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         $data = $form->getData();
         $message = Str::ellipsis($data['message'], 3000, '');
         $Order->setMessage($message);
         // 受注情報を更新
         $app['orm.em']->flush();
         // 複数配送設定へリダイレクト
         return $app->redirect($app->url('shopping_shipping_multiple'));
     }
     return $app->redirect($app->url('shopping'));
 }
Exemplo n.º 18
0
 public function createTempDir()
 {
     $base = __DIR__ . '/../../../app/cache/plugin';
     @mkdir($base);
     $d = $base . '/' . sha1(Str::random(16));
     if (!mkdir($d, 0777)) {
         throw new PluginException($php_errormsg . $d);
     }
     return $d;
 }
Exemplo n.º 19
0
 /**
  * Name of this extension
  *
  * @return string
  */
 public function getTimeAgo($date)
 {
     return Str::timeAgo($date);
 }
Exemplo n.º 20
0
 public function testSave()
 {
     $cartService = $this->app['eccube.service.cart'];
     $preOrderId = sha1(Str::random(32));
     $cartService->setPreOrderId($preOrderId);
     $cartService->save();
     $this->expected = $preOrderId;
     $this->actual = $this->app['session']->get('cart')->getPreOrderId();
     $this->verify();
 }
Exemplo n.º 21
0
 /**
  * 受注情報を作成
  *
  * @param $Customer
  * @return \Eccube\Entity\Order
  */
 public function createOrder($Customer)
 {
     // ランダムなpre_order_idを作成
     $preOrderId = sha1(Str::random(32));
     // 受注情報、受注明細情報、お届け先情報、配送商品情報を作成
     $Order = $this->registerPreOrder($Customer, $preOrderId);
     $this->cartService->setPreOrderId($preOrderId);
     $this->cartService->save();
     return $Order;
 }
Exemplo n.º 22
0
 /**
  * get query builder.
  *
  * @param  array $searchData
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getQueryBuilderBySearchDataForAdmin($searchData)
 {
     $qb = $this->createQueryBuilder('p')->innerJoin('p.ProductClasses', 'pc');
     // id
     if (isset($searchData['id']) && Str::isNotBlank($searchData['id'])) {
         $id = preg_match('/^\\d+$/', $searchData['id']) ? $searchData['id'] : null;
         $qb->andWhere('p.id = :id OR p.name LIKE :likeid OR pc.code LIKE :likeid')->setParameter('id', $id)->setParameter('likeid', '%' . $searchData['id'] . '%');
     }
     // code
     /*
      if (!empty($searchData['code']) && $searchData['code']) {
          $qb
              ->innerJoin('p.ProductClasses', 'pc')
              ->andWhere('pc.code LIKE :code')
              ->setParameter('code', '%' . $searchData['code'] . '%');
      }
     
      // name
      if (!empty($searchData['name']) && $searchData['name']) {
          $keywords = preg_split('/[\s ]+/u', $searchData['name'], -1, PREG_SPLIT_NO_EMPTY);
          foreach ($keywords as $keyword) {
              $qb
                  ->andWhere('p.name LIKE :name')
                  ->setParameter('name', '%' . $keyword . '%');
          }
      }
     */
     // category
     if (!empty($searchData['category_id']) && $searchData['category_id']) {
         $Categories = $searchData['category_id']->getSelfAndDescendants();
         if ($Categories) {
             $qb->innerJoin('p.ProductCategories', 'pct')->innerJoin('pct.Category', 'c')->andWhere($qb->expr()->in('pct.Category', ':Categories'))->setParameter('Categories', $Categories);
         }
     }
     // status
     if (!empty($searchData['status']) && $searchData['status']->toArray()) {
         $qb->andWhere($qb->expr()->in('p.Status', ':Status'))->setParameter('Status', $searchData['status']->toArray());
     }
     // link_status
     if (isset($searchData['link_status'])) {
         $qb->andWhere($qb->expr()->in('p.Status', ':Status'))->setParameter('Status', $searchData['link_status']);
     }
     // stock status
     if (isset($searchData['stock_status'])) {
         $qb->andWhere('pc.stock_unlimited = :StockUnlimited AND pc.stock = 0')->setParameter('StockUnlimited', $searchData['stock_status']);
     }
     // crate_date
     if (!empty($searchData['create_date_start']) && $searchData['create_date_start']) {
         $date = $searchData['create_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('p.create_date >= :create_date_start')->setParameter('create_date_start', $date);
     }
     if (!empty($searchData['create_date_end']) && $searchData['create_date_end']) {
         $date = clone $searchData['create_date_end'];
         $date = $date->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('p.create_date < :create_date_end')->setParameter('create_date_end', $date);
     }
     // update_date
     if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) {
         $date = $searchData['update_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('p.update_date >= :update_date_start')->setParameter('update_date_start', $date);
     }
     if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) {
         $date = clone $searchData['update_date_end'];
         $date = $date->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('p.update_date < :update_date_end')->setParameter('update_date_end', $date);
     }
     // Order By
     $qb->orderBy('p.update_date', 'DESC');
     return $qb;
 }
Exemplo n.º 23
0
function initializeDatabase(\Eccube\Application $app)
{
    // Get an instance of your entity manager
    $entityManager = $app['orm.em'];
    $pdo = $entityManager->getConnection()->getWrappedConnection();
    // Clear Doctrine to be safe
    $entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
    $entityManager->clear();
    gc_collect_cycles();
    // Schema Tool to process our entities
    $tool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
    $classes = $entityManager->getMetaDataFactory()->getAllMetaData();
    // Drop all classes and re-build them for each test case
    out('Dropping database schema...', 'info');
    $tool->dropSchema($classes);
    out('Creating database schema...', 'info');
    $tool->createSchema($classes);
    out('Database schema created successfully!', 'success');
    $config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($app['db']);
    $config->setMigrationsNamespace('DoctrineMigrations');
    $migrationDir = __DIR__ . '/src/Eccube/Resource/doctrine/migration';
    $config->setMigrationsDirectory($migrationDir);
    $config->registerMigrationsFromDirectory($migrationDir);
    $migration = new \Doctrine\DBAL\Migrations\Migration($config);
    $migration->migrate();
    out('Database migration successfully!', 'success');
    $login_id = getenv('ADMIN_USER');
    $login_password = getenv('ADMIN_PASS');
    $passwordEncoder = new \Eccube\Security\Core\Encoder\PasswordEncoder($app['config']);
    $salt = \Eccube\Util\Str::random(32);
    $encodedPassword = $passwordEncoder->encodePassword($login_password, $salt);
    out('Creating admin accounts...', 'info');
    $sql = "INSERT INTO dtb_member (member_id, login_id, password, salt, work, del_flg, authority, creator_id, rank, update_date, create_date,name,department) VALUES (2, :login_id, :admin_pass , :salt , '1', '0', '0', '1', '1', current_timestamp, current_timestamp,'管理者', 'EC-CUBE SHOP');";
    $stmt = $pdo->prepare($sql);
    $stmt->execute(array(':login_id' => $login_id, ':admin_pass' => $encodedPassword, ':salt' => $salt));
    $stmt->closeCursor();
    $shop_name = getenv('SHOP_NAME');
    $admin_mail = getenv('ADMIN_MAIL');
    $sql = "INSERT INTO dtb_base_info (id, shop_name, email01, email02, email03, email04, update_date, option_product_tax_rule) VALUES (1, :shop_name, :admin_mail1, :admin_mail2, :admin_mail3, :admin_mail4, current_timestamp, 0)";
    $stmt = $pdo->prepare($sql);
    $stmt->execute(array(':shop_name' => $shop_name, ':admin_mail1' => $admin_mail, ':admin_mail2' => $admin_mail, ':admin_mail3' => $admin_mail, ':admin_mail4' => $admin_mail));
    $stmt->closeCursor();
}
Exemplo n.º 24
0
 /**
  * アップロードされたCSVファイルの行ごとの処理
  *
  * @param $formFile
  * @return CsvImportService
  */
 protected function getImportData($app, $formFile)
 {
     // アップロードされたCSVファイルを一時ディレクトリに保存
     $this->fileName = 'upload_' . Str::random() . '.' . $formFile->getClientOriginalExtension();
     $formFile->move($app['config']['csv_temp_realdir'], $this->fileName);
     $file = file_get_contents($app['config']['csv_temp_realdir'] . '/' . $this->fileName);
     // アップロードされたファイルがUTF-8以外は文字コード変換を行う
     $encode = Str::characterEncoding(substr($file, 0, 6));
     if ($encode != 'UTF-8') {
         $file = mb_convert_encoding($file, 'UTF-8', $encode);
     }
     $file = Str::convertLineFeed($file);
     $tmp = tmpfile();
     fwrite($tmp, $file);
     rewind($tmp);
     $meta = stream_get_meta_data($tmp);
     $file = new \SplFileObject($meta['uri']);
     set_time_limit(0);
     // アップロードされたCSVファイルを行ごとに取得
     $data = new CsvImportService($file, $app['config']['csv_import_delimiter'], $app['config']['csv_import_enclosure']);
     $data->setHeaderRowNumber(0);
     return $data;
 }
Exemplo n.º 25
0
 public function testTrimAll()
 {
     $text = '     a ';
     $this->expected = 'a';
     $this->actual = Str::trimAll($text);
     $this->assertEquals($this->expected, $this->actual);
     $text = '     a a ';
     $this->expected = 'a a';
     $this->actual = Str::trimAll($text);
     $this->assertEquals($this->expected, $this->actual);
     $text = '';
     $this->actual = Str::trimAll($text);
     $this->assertNotNull($this->actual);
     $this->assertEmpty($this->actual);
     $text = null;
     $this->actual = Str::trimAll($text);
     $this->assertNull($this->actual);
     $text = 0;
     $this->expected = 0;
     $this->actual = Str::trimAll($text);
     $this->assertTrue($this->expected === $this->actual);
     $text = '0';
     $this->expected = '0';
     $this->actual = Str::trimAll($text);
     $this->assertTrue($this->expected === $this->actual);
     $text = " 0\n0\r\n\t";
     $this->expected = "0\n0";
     $this->actual = Str::trimAll($text);
     $this->assertTrue($this->expected === $this->actual);
 }
Exemplo n.º 26
0
 /**
  * 受注情報を作成
  *
  * @param $Customer
  * @return \Eccube\Entity\Order
  */
 public function createOrder($Customer)
 {
     // ランダムなpre_order_idを作成
     do {
         $preOrderId = sha1(Str::random(32));
         $Order = $this->app['eccube.repository.order']->findOneBy(array('pre_order_id' => $preOrderId, 'OrderStatus' => $this->app['config']['order_processing']));
     } while ($Order);
     // 受注情報、受注明細情報、お届け先情報、配送商品情報を作成
     $Order = $this->registerPreOrder($Customer, $preOrderId);
     $this->cartService->setPreOrderId($preOrderId);
     $this->cartService->save();
     return $Order;
 }
 /**
  * 検索条件での検索を行う。
  * s
  * @param unknown $searchData
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getQueryBuilderBySearchData($searchData)
 {
     // メルマガを受け取るカスタマーのIDを取得する
     $mailmagaCustomerIds = $this->getMailmagaCustomerIds();
     $qb = $this->createQueryBuilder('c')->select('c')->andWhere('c.del_flg = 0');
     // メルマガを受け取るカスタマーのみに絞る
     if (count($mailmagaCustomerIds) > 0) {
         // メルマガ送付カスタマーがいれば対象カスタマーのみ対象とする
         $qb->andWhere($qb->expr()->in('c.id', $mailmagaCustomerIds));
     } else {
         // メルマガ送付カスタマーがいなければ強制的に非表示にする条件を追加する
         $qb->andWhere('c.id < 0');
     }
     if (isset($searchData['multi']) && Str::isNotBlank($searchData['multi'])) {
         //スペース除去
         $clean_key_multi = preg_replace('/\\s+|[ ]+/u', '', $searchData['multi']);
         if (preg_match('/^\\d+$/', $clean_key_multi)) {
             $qb->andWhere('c.id = :customer_id')->setParameter('customer_id', $clean_key_multi);
         } else {
             $qb->andWhere('CONCAT(c.name01, c.name02) LIKE :name OR CONCAT(c.kana01, c.kana02) LIKE :kana OR c.email LIKE :email')->setParameter('name', '%' . $clean_key_multi . '%')->setParameter('kana', '%' . $clean_key_multi . '%')->setParameter('email', '%' . $clean_key_multi . '%');
         }
     }
     // Pref
     if (!empty($searchData['pref']) && $searchData['pref']) {
         $qb->andWhere('c.Pref = :pref')->setParameter('pref', $searchData['pref']->getId());
     }
     // sex
     if (!empty($searchData['sex']) && count($searchData['sex']) > 0) {
         $sexs = array();
         foreach ($searchData['sex'] as $sex) {
             $sexs[] = $sex->getId();
         }
         $qb->andWhere($qb->expr()->in('c.Sex', ':sexs'))->setParameter('sexs', $sexs);
     }
     // birth_month
     if (!empty($searchData['birth_month']) && $searchData['birth_month']) {
         //            TODO: http://docs.symfony.gr.jp/symfony2/cookbook/doctrine/custom_dql_functions.html
         //            $qb
         //                ->andWhere('extract(month from c.birth) = :birth_month')
         //                ->setParameter('birth_month', $searchData['birth_month']);
     }
     // birth
     if (!empty($searchData['birth_start']) && $searchData['birth_start']) {
         $date = $searchData['birth_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.birth >= :birth_start')->setParameter('birth_start', $date);
     }
     if (!empty($searchData['birth_end']) && $searchData['birth_end']) {
         $date = $searchData['birth_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.birth < :birth_end')->setParameter('birth_end', $date);
     }
     // tel
     if (!empty($searchData['tel01']) && $searchData['tel01']) {
         $qb->andWhere('c.tel01 = :tel01')->setParameter('tel01', $searchData['tel01']);
     }
     if (!empty($searchData['tel02']) && $searchData['tel02']) {
         $qb->andWhere('c.tel02 = :tel02')->setParameter('tel02', $searchData['tel02']);
     }
     if (!empty($searchData['tel03']) && $searchData['tel03']) {
         $qb->andWhere('c.tel03 = :tel03')->setParameter('tel03', $searchData['tel03']);
     }
     // buy_total
     if (!empty($searchData['buy_total_start']) && $searchData['buy_total_start']) {
         $qb->andWhere('c.buy_total >= :buy_total_start')->setParameter('buy_total_start', $searchData['buy_total_start']);
     }
     if (!empty($searchData['buy_total_end']) && $searchData['buy_total_end']) {
         $qb->andWhere('c.buy_total <= :buy_total_end')->setParameter('buy_total_end', $searchData['buy_total_end']);
     }
     // buy_times
     if (!empty($searchData['buy_times_start']) && $searchData['buy_times_start']) {
         $qb->andWhere('c.buy_times >= :buy_times_start')->setParameter('buy_times_start', $searchData['buy_times_start']);
     }
     if (!empty($searchData['buy_times_end']) && $searchData['buy_times_end']) {
         $qb->andWhere('c.buy_times <= :buy_times_end')->setParameter('buy_times_end', $searchData['buy_times_end']);
     }
     // create_date
     if (!empty($searchData['create_date_start']) && $searchData['create_date_start']) {
         $date = $searchData['create_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.create_date >= :create_date_start')->setParameter('create_date_start', $date);
     }
     if (!empty($searchData['create_date_end']) && $searchData['create_date_end']) {
         $date = $searchData['create_date_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.create_date < :create_date_end')->setParameter('create_date_end', $date);
     }
     // update_date
     if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) {
         $date = $searchData['update_date_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.update_date >= :update_date_start')->setParameter('update_date_start', $date);
     }
     if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) {
         $date = $searchData['update_date_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.update_date < :update_date_end')->setParameter('update_date_end', $date);
     }
     // last_buy
     if (!empty($searchData['last_buy_start']) && $searchData['last_buy_start']) {
         $date = $searchData['last_buy_start']->format('Y-m-d H:i:s');
         $qb->andWhere('c.last_buy_date >= :last_buy_start')->setParameter('last_buy_start', $date);
     }
     if (!empty($searchData['last_buy_end']) && $searchData['last_buy_end']) {
         $date = $searchData['last_buy_end']->modify('+1 days')->format('Y-m-d H:i:s');
         $qb->andWhere('c.last_buy_date < :last_buy_end')->setParameter('last_buy_end', $date);
     }
     // status
     if (!empty($searchData['customer_status']) && count($searchData['customer_status']) > 0) {
         $customerStatus = array();
         foreach ($searchData['customer_status'] as $val) {
             $customerStatus[] = $val->getId();
         }
         $qb->andWhere($qb->expr()->in('c.Status', ':statuses'))->setParameter('statuses', $customerStatus);
     }
     // buy_product_name、buy_product_code
     if (!empty($searchData['buy_product_code']) && $searchData['buy_product_code']) {
         $qb->leftJoin('c.Orders', 'o')->leftJoin('o.OrderDetails', 'od')->andWhere('od.product_name LIKE :buy_product_name OR od.product_code LIKE :buy_product_name')->setParameter('buy_product_name', '%' . $searchData['buy_product_code'] . '%');
     }
     // Order By
     $qb->addOrderBy('c.update_date', 'DESC');
     return $qb;
 }