/**
  * 納品書の設定画面表示.
  *
  * @param Application $app
  * @param Request     $request
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  *
  * @throws NotFoundHttpException
  */
 public function index(Application $app, Request $request)
 {
     // requestから受注番号IDの一覧を取得する.
     $ids = $this->getIds($request);
     if (count($ids) == 0) {
         $app->addError('admin.plugin.order_pdf.parameter.notfound', 'admin');
         log_info('The Order cannot found!');
         return $app->redirect($app->url('admin_order'));
     }
     /* @var OrderPdfRepository $repos */
     $repos = $app['orderpdf.repository.order_pdf'];
     $OrderPdf = $repos->find($app->user());
     if (EntityUtil::isEmpty($OrderPdf)) {
         $OrderPdf = new OrderPdf();
         $OrderPdf->setTitle($app->trans('admin.plugin.order_pdf.title.default'))->setMessage1($app->trans('admin.plugin.order_pdf.message1.default'))->setMessage2($app->trans('admin.plugin.order_pdf.message2.default'))->setMessage3($app->trans('admin.plugin.order_pdf.message3.default'));
     }
     /**
      * @var FormBuilder $builder
      */
     $builder = $app['form.factory']->createBuilder('admin_order_pdf', $OrderPdf);
     /* @var Form $form */
     $form = $builder->getForm();
     // Formへの設定
     $form->get('ids')->setData(implode(',', $ids));
     return $app->render('OrderPdf/Resource/template/admin/order_pdf.twig', array('form' => $form->createView()));
 }
예제 #2
0
 public function getMaker()
 {
     if (EntityUtil::isEmpty($this->Maker)) {
         return null;
     }
     return $this->Maker;
 }
예제 #3
0
파일: Order.php 프로젝트: geany-y/LikeNiko
 /**
  * Get Payment
  *
  * @return \Eccube\Entity\Payment
  */
 public function getPayment()
 {
     if (EntityUtil::isEmpty($this->Payment)) {
         return null;
     }
     return $this->Payment;
 }
예제 #4
0
 /**
  * CSV出力項目と比較し, 合致するデータを返す.
  *
  * @param \Eccube\Entity\Csv $Csv
  * @param $entity
  * @return mixed|null|string|void
  */
 public function getData(\Eccube\Entity\Csv $Csv, $entity)
 {
     // エンティティ名が一致するかどうかチェック.
     $csvEntityName = str_replace('\\\\', '\\', $Csv->getEntityName());
     $entityName = str_replace('\\\\', '\\', get_class($entity));
     if ($csvEntityName !== $entityName) {
         return null;
     }
     // カラム名がエンティティに存在するかどうかをチェック.
     if (!$entity->offsetExists($Csv->getFieldName())) {
         return null;
     }
     // データを取得.
     $data = $entity->offsetGet($Csv->getFieldName());
     // one to one の場合は, dtb_csv.referece_field_nameと比較し, 合致する結果を取得する.
     if ($data instanceof \Eccube\Entity\AbstractEntity) {
         if (EntityUtil::isNotEmpty($data)) {
             return $data->offsetGet($Csv->getReferenceFieldName());
         }
     } elseif ($data instanceof \Doctrine\Common\Collections\Collection) {
         // one to manyの場合は, カンマ区切りに変換する.
         $array = array();
         foreach ($data as $elem) {
             if (EntityUtil::isNotEmpty($elem)) {
                 $array[] = $elem->offsetGet($Csv->getReferenceFieldName());
             }
         }
         return implode($this->config['csv_export_multidata_separator'], $array);
     } elseif ($data instanceof \DateTime) {
         // datetimeの場合は文字列に変換する.
         return $data->format($this->config['csv_export_date_format']);
     } else {
         // スカラ値の場合はそのまま.
         return $data;
     }
     return null;
 }
예제 #5
0
 /**
  * Get DeliveryFee
  *
  * @return \Eccube\Entity\DeliveryFee 
  */
 public function getDeliveryFee()
 {
     if (EntityUtil::isEmpty($this->DeliveryFee)) {
         return null;
     }
     return $this->DeliveryFee;
 }
예제 #6
0
 /**
  * Get Product.
  *
  * @return \Eccube\Entity\Product|null
  */
 public function getProduct()
 {
     if (EntityUtil::isEmpty($this->Product)) {
         return null;
     }
     return $this->Product;
 }
 /**
  * period sale report.
  *
  * @param array $data
  *
  * @return array
  */
 private function convertByTerm($data)
 {
     $start = new \DateTime($this->termStart);
     $end = new \DateTime($this->termEnd);
     $raw = array();
     $price = array();
     $orderNumber = 0;
     $format = $this->formatUnit();
     // Sort date in week
     if ($this->unit == 'byWeekDay') {
         $raw = array('Sun' => '', 'Mon' => '', 'Tue' => '', 'Wed' => '', 'Thu' => '', 'Fri' => '', 'Sat' => '');
         $price = $raw;
     }
     for ($term = $start; $term < $end; $term = $term->modify('+ 1 Hour')) {
         $date = $term->format($format);
         $raw[$date] = array('price' => 0, 'time' => 0, 'male' => 0, 'female' => 0, 'other' => 0, 'member_male' => 0, 'nonmember_male' => 0, 'member_female' => 0, 'nonmember_female' => 0);
         $price[$date] = 0;
     }
     /* @var $entityManager EntityManager */
     $entityManager = $this->app['orm.em'];
     $sql = 'Select o.customer_id From dtb_order o Where o.order_id = :order_id';
     $stmt = $entityManager->getConnection()->prepare($sql);
     foreach ($data as $Order) {
         /* @var $Order \Eccube\Entity\Order */
         $orderDate = $Order->getOrderDate()->format($format);
         $price[$orderDate] += $Order->getPaymentTotal();
         $raw[$orderDate]['price'] += $Order->getPaymentTotal();
         ++$raw[$orderDate]['time'];
         // Get sex
         $Sex = $Order->getSex();
         $sex = 0;
         if (EntityUtil::isNotEmpty($Sex)) {
             $sex = $Order->getSex()->getId();
         } else {
             $raw[$orderDate]['other'] += 1;
         }
         $raw[$orderDate]['male'] += $sex == self::MALE;
         $raw[$orderDate]['female'] += $sex == self::FEMALE;
         // Get customer id
         $params['order_id'] = $Order->getId();
         $stmt->execute($params);
         $customerId = $stmt->fetch(\PDO::FETCH_COLUMN);
         if ($customerId) {
             $raw[$orderDate]['member_male'] += $sex == self::MALE;
             $raw[$orderDate]['member_female'] += $sex == self::FEMALE;
         } else {
             $raw[$orderDate]['nonmember_male'] += $sex == self::MALE;
             $raw[$orderDate]['nonmember_female'] += $sex == self::FEMALE;
         }
         ++$orderNumber;
     }
     log_info('SalesReport Plugin : term report ', array('result count' => $orderNumber));
     // Return null and not display in screen
     if ($orderNumber == 0) {
         return array('raw' => null, 'graph' => null);
     }
     $graph = array('labels' => array_keys($price), 'datasets' => array('label' => '購入合計', 'data' => array_values($price), 'lineTension' => 0.1, 'backgroundColor' => 'rgba(75,192,192,0.4)', 'borderColor' => 'rgba(75,192,192,1)', 'borderCapStyle' => 'butt', 'borderDash' => array(), 'borderDashOffset' => 0.0, 'borderJoinStyle' => 'miter', 'pointBorderColor' => 'rgba(75,192,192,1)', 'pointBackgroundColor' => '#fff', 'pointBorderWidth' => 1, 'pointHoverRadius' => 5, 'pointHoverBackgroundColor' => 'rgba(75,192,192,1)', 'pointHoverBorderColor' => 'rgba(220,220,220,1)', 'pointHoverBorderWidth' => 2, 'pointRadius' => 1, 'pointHitRadius' => 10, 'spanGaps' => false, 'borderWidth' => 1));
     return array('raw' => $raw, 'graph' => $graph);
 }
 public function testIsNotEmpty()
 {
     // migration で追加されるサンプル商品
     $Product = self::$app['eccube.repository.product']->find(1);
     // migration で追加されるダミーの Member
     $Member = $Product->getCreator();
     /*
      * member.del_flg = 1 になっているので、soft_delete filter が適用され
      * LAZY loading しようとすると Entity was not found のエラーとなる
      */
     $this->assertFalse(EntityUtil::isNotEmpty($Member));
 }
예제 #9
0
 public function testDumpToArray()
 {
     $arrProps = array('field1' => 1, 'field2' => 2, 'field3' => 3);
     $entity = new TestEntity($arrProps);
     $arrProps['testField4'] = 'Doctrine\\Common\\Collections\\ArrayCollection';
     $this->expected = $arrProps;
     $this->actual = EntityUtil::dumpToArray($entity);
     $this->verify();
 }