예제 #1
0
 /**
  * action import
  * @return \yii\web\Response
  */
 public function actionImport()
 {
     $request = Yii::$app->request;
     if ($request->isPost && isset($_FILES['commodity'])) {
         $obj = new Sdptm05com();
         if (substr($_FILES['commodity']['name'], -4) == '.csv') {
             $file = utilities::convertUtf8($_FILES['commodity']['tmp_name']);
             $result = $obj->saveImport($file);
             $error = $result['error'];
         } else {
             $error[] = 'CSVのフォーマットが正しくありません';
         }
         if (empty($error) && $result['insert']) {
             Yii::$app->session->setFlash('success', 'success');
         } else {
             Yii::$app->session->setFlash('error', $error);
         }
         return $this->redirect(BaseUrl::base(true) . '/update-commodity');
     }
 }
예제 #2
0
 public function actionIndex()
 {
     $request = Yii::$app->request;
     if ($request->isAjax) {
         $obj = new Sdptm05com();
         $condition = $request->post('condition');
         $condition_1 = trim($request->post('condition_1'), ',');
         if ($condition_1) {
             $condition_1 = ',' . $condition_1 . ',';
         }
         $a_search = ['1' => '7,8', '2' => '1,2,3,4,5,6', '3' => '10', '4' => '24,25,26', '5' => '27', '6' => '21', '7' => '0'];
         $kind_com_search_in = '';
         $kind_com_search_not_in = '';
         foreach ($a_search as $key => $val) {
             if (substr_count($condition_1, ',' . $key . ',')) {
                 $kind_com_search_in .= $val . ',';
             } else {
                 $kind_com_search_not_in .= $val . ',';
             }
         }
         if (substr_count($condition_1, ',7,')) {
             if ($kind_com_search_not_in) {
                 $data['filters']['not_in'] = explode(',', trim($kind_com_search_not_in, ','));
             }
         } else {
             if ($kind_com_search_in) {
                 $data['filters']['in'] = explode(',', trim($kind_com_search_in, ','));
             }
         }
         $data['filters'][$condition] = $request->post('value');
         $data['count'] = $obj->coutData($data['filters']);
         $data['pagination'] = new Pagination(['totalCount' => $data['count'], 'defaultPageSize' => 10, 'page' => $request->post('page')]);
         $data['filters']['offset'] = $data['pagination']->offset;
         $data['filters']['limit'] = $data['pagination']->limit;
         $data['product'] = $obj->getData($data['filters']);
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return $data;
     }
 }
예제 #3
0
 public function getProduct($den_no)
 {
     $obj = new Sdptd05denpyocom();
     $product_info = $obj->getData(['D05_DEN_NO' => $den_no]);
     $product = [];
     foreach ($product_info as $k => $v) {
         $product[$k]['D05_SURYO'] = $v['D05_SURYO'];
         $product[$k]['D05_TANKA'] = $v['D05_TANKA'];
         $product[$k]['D05_KINGAKU'] = $v['D05_KINGAKU'];
         $product[$k]['D05_COM_CD'] = $v['D05_COM_CD'];
         $product[$k]['D05_NST_CD'] = $v['D05_NST_CD'];
         $obj_sdptm05com = Sdptm05com::findOne([$v['D05_COM_CD'], $v['D05_NST_CD']]);
         $product[$k]['M05_COM_NAMEN'] = $obj_sdptm05com['M05_COM_NAMEN'];
         $product[$k]['M05_LIST_PRICE'] = $obj_sdptm05com['M05_LIST_PRICE'];
     }
     return $product;
 }