Ejemplo n.º 1
0
 /**
  * 区分マスタのデータをJSON形式で返す
  * @access public
  * @return array 区分マスタ
  * @see Admin_ActionClass::perform()
  */
 public function perform()
 {
     // get request params ( search )
     $buyer_cd = $this->af->get('buyer_cd');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     try {
         // DAO パラメータ定義
         $params = array('company_id' => $company_id, 'buyer_cd' => $buyer_cd);
         // 詳細を取得
         $detail = DaoFactory::BuyerMst()->getBuyerByKeys($params);
         $detail['TERMINAL_ID'] = DaoFactory::BuyerMst()->GetAllTerminalsByBuyerCD($params);
         $detail['USER_ID'] = DaoFactory::BuyerMst()->GetAllUsersByBuyerCD($params);
         // output にセット
         $output['totalData'] = array();
         $output['listData'] = $detail;
         $output['pagerData'] = array();
     } catch (Exception $e) {
         // 致命的なエラーが発生
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array('500', $e->getMessage());
     }
     return array('json', $output);
 }
Ejemplo n.º 2
0
 /**
  * 区分マスタCSVを出力
  * @access public
  * @see Admin_ActionClass::perform()
  */
 function perform()
 {
     set_time_limit(DEFAULT_CSV_PROCESS_TIME_LIMIT);
     // get request params
     $buyer_cd = $this->af->get('buyer_cd');
     $buyer_name = $this->af->get('buyer_name');
     $keyword = $this->af->get('keyword');
     $record_arr = $this->af->get('record_arr');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     // pager setting
     $order = $this->af->get('order');
     // default asc
     $column = $this->af->get('column');
     // default warehouse_id
     try {
         // 一覧を取得
         if (!empty($record_arr)) {
             $params = array('company_id' => $company_id, 'record_arr' => $record_arr, 'csv' => true);
         } else {
             $params = array('company_id' => $company_id, 'buyer_cd' => $buyer_cd, 'user_id' => $user_id, 'buyer_name' => $buyer_name, 'keyword' => $keyword, 'order' => $order, 'column' => $column, 'csv' => true);
         }
         $dao = DaoFactory::BuyerMst();
         $sth = $dao->getBuyerList($params);
         // 書き込みクラスを生成
         require_once 'csv/BuyerMstCsvWriter.class.php';
         $writer = new BuyerMstCsvWriter();
     } catch (Exception $e) {
         // 致命的なエラーが発生
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array('500', $e->getMessage());
     }
     return array('csv', $writer, $sth, 'KbnMst' . date('YmdHis') . '.csv');
 }
Ejemplo n.º 3
0
 /**
  * 区分マスタの保存が成功したかJSON形式で返す
  * @access public
  * @see Admin_ActionClass::perform()
  */
 function perform()
 {
     // get request params
     $buyer_cd = $this->af->get('buyer_cd');
     $buyer_name = $this->af->get('buyer_name');
     $buyer_abbr = $this->af->get('buyer_abbr');
     $zip_cd = $this->af->get('zip_cd');
     $address1 = $this->af->get('address1');
     $address2 = $this->af->get('address2');
     $address3 = $this->af->get('address3');
     $tel = $this->af->get('tel');
     $fax = $this->af->get('fax');
     $user_groups = $this->af->get('user_groups');
     $terminal_groups = $this->af->get('terminal_groups');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     // dao
     $buyerDao = DaoFactory::BuyerMst();
     try {
         // begin
         $buyerDao->BeginTransaction();
         // cd exists
         $params = array('company_id' => $company_id, 'buyer_name' => $buyer_name, 'buyer_cd' => $buyer_cd, 'buyer_abbr' => $buyer_abbr, 'zip_cd' => $zip_cd, 'address1' => $address1, 'address2' => $address2, 'address3' => $address3, 'tel' => $tel, 'fax' => $fax, 'UID' => $user_id, 'PGM' => get_class());
         $buyerDao->Insert($params);
         //USER_BUYER
         if ($user_groups != '') {
             $user_groups = explode(',', $user_groups);
             foreach ($user_groups as $user_id) {
                 $params = array('company_id' => $company_id, 'user_id' => $user_id, 'buyer_cd' => $buyer_cd, 'UID' => $user_id, 'PGM' => get_class());
                 $buyerDao->Insert_UserBuyer($params);
             }
         }
         //TERMINAL_BUYER
         if ($terminal_groups != '') {
             $terminal_groups = explode(',', $terminal_groups);
             foreach ($terminal_groups as $terminal_id) {
                 $params = array('company_id' => $company_id, 'terminal_id' => $terminal_id, 'buyer_cd' => $buyer_cd, 'UID' => $user_id, 'PGM' => get_class());
                 $buyerDao->Insert_TerminalBuyer($params);
             }
         }
         // commit
         $buyerDao->CommitTransaction();
     } catch (Exception $e) {
         $buyerDao->AbortTransaction();
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array(500, $e->getMessage());
     }
     exit;
 }
Ejemplo n.º 4
0
 /**
  * リクエストの店舗に紐づく優先グループの一覧を返す
  * @return array 優先グループ一覧
  */
 public function option_current_terminal_group()
 {
     if (empty($this->form_vars)) {
         $this->form_vars = array_merge($_GET, $_POST);
     }
     // 優先グループろ取得
     $params = array('company_id' => $this->backend->getSession()->get('company_id'), 'buyer_cd' => $this->form_vars['buyer_cd']);
     $list = DaoFactory::BuyerMst()->GetAllTerminalsByBuyerCD($params);
     // キーバリューの形に成形
     $options = array();
     foreach ($list as $record) {
         $options[$record['TERMINAL_ID']] = $record['TERMINAL_ID'] . " - " . $record['TERMINAL_NAME'];
     }
     return $options;
 }
Ejemplo n.º 5
0
 /**
  * 区分マスタの保存が成功したかJSON形式で返す
  * @access public
  * @see Admin_ActionClass::perform()
  */
 function perform()
 {
     // get request params
     $record_arr = $this->af->get('record_arr');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     // dao
     $buyerDao = DaoFactory::BuyerMst();
     try {
         // begin
         $buyerDao->BeginTransaction();
         $values = array('company_id' => $company_id, 'user_id' => $user_id);
         if ($_REQUEST['del'] == 'all') {
             $rst = DaoFactory::BuyerMst()->getBuyerCodesByKeys($values);
             $buyer_codes = '';
             foreach ($rst as $buyer_code) {
                 if ($buyer_codes != '') {
                     $buyer_codes = $buyer_codes . ',';
                 }
                 $buyer_codes = $buyer_codes . $buyer_code['BUYER_CD'];
             }
             if ($buyer_codes != '') {
                 $values['buyer_cd'] = $buyer_codes;
                 $buyerDao->Delete_AllTerminalBuyer($values);
                 $buyerDao->Delete_AllUserBuyer($values);
                 $buyerDao->Delete_AllBuyers($values);
             }
         } else {
             foreach ($record_arr as $key => $pk) {
                 $params['company_id'] = $company_id;
                 $params['buyer_cd'] = $pk['buyer_cd'];
                 $buyerDao->Delete_UserBuyerByKeys($params);
                 $buyerDao->Delete_TerminalBuyerByKeys($params);
                 $buyerDao->Delete(' company_id = ? AND buyer_cd = ? ', $params);
             }
         }
         $buyerDao->CommitTransaction();
     } catch (Exception $e) {
         $buyerDao->AbortTransaction();
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array(500, $e->getMessage());
     }
     exit;
 }
Ejemplo n.º 6
0
 /**
  * 商品マスタのCSVをインポートする
  * @access public
  * @see Admin_ActionClass::perform()
  */
 function perform()
 {
     //タイムアウト時間を設定
     set_time_limit(DEFAULT_CSV_PROCESS_TIME_LIMIT);
     // get request params
     $file = $this->af->get('file');
     $ignore = $this->af->get('ignore');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     // csv reader を生成
     require_once 'csv/BuyerMstCsvReader.class.php';
     $reader = new BuyerMstCsvReader($file['tmp_name']);
     $reader->ignore = $ignore;
     // dao
     $buyerDao = DaoFactory::BuyerMst();
     try {
         // start transaction
         $buyerDao->BeginTransaction();
         // ファイルから1行取得する
         while ($params = $reader->read()) {
             $cnt++;
             $nowrow = $cnt + $ignore;
             // 共通項目を設定する
             $params['company_id'] = $company_id;
             $params['UID'] = $user_id;
             $params['PGM'] = get_class();
             // insert or update ( merge )
             $buyerDao->BuyerMst_Import($params);
             $buyerDao->User_Buyer_Import($params);
         }
         // commit transaction
         $buyerDao->CommitTransaction();
     } catch (CsvReaderException $e) {
         // csv reader is exception
         $buyerDao->AbortTransaction();
         return array('400', $e->getMessage());
     } catch (Exception $e) {
         // dao is exception
         $buyerDao->AbortTransaction();
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array('500', $e->getMessage());
     }
     exit;
 }
Ejemplo n.º 7
0
 /**
  * 区分マスタのデータをJSON形式で返す
  * @access public
  * @return array 区分マスタ
  * @see Admin_ActionClass::perform()
  */
 public function perform()
 {
     // get request params
     $buyer_cd = $this->af->get('buyer_cd');
     $buyer_name = $this->af->get('buyer_name');
     $keyword = $this->af->get('keyword');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     // pager setting
     $limit = $this->af->get('limit');
     // default 50
     $page = $this->af->get('page');
     // default 1
     $order = $this->af->get('order');
     // default asc
     $column = $this->af->get('column');
     // default warehouse_id
     $start_page = ($page - 1) * $limit + 1;
     $end_page = ($page - 1) * $limit + $limit;
     try {
         // DAO パラメータ定義
         $params = array('company_id' => $company_id, 'user_id' => $user_id, 'buyer_cd' => $buyer_cd, 'buyer_name' => $buyer_name, 'keyword' => $keyword, 'limit' => $limit, 'page' => $page, 'order' => $order, 'column' => $column, 'company_id' => $company_id, 'start_page' => $start_page, 'end_page' => $end_page);
         // 一覧を取得
         $list = DaoFactory::BuyerMst()->getBuyerList($params);
         // ページ情報を設定
         $pager = array('result_page' => $page, 'result_start_num' => $start_page, 'result_end_num' => $end_page, 'result_all_count' => count($list) ? $list[0]['FOUND_ROWS'] : 0, 'result_get_count' => count($list), 'result_limit' => $limit);
         // output にセット
         $output['totalData'] = array();
         $output['listData'] = $list;
         $output['pagerData'] = $pager;
     } catch (Exception $e) {
         // 致命的なエラーが発生
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array('500', $e->getMessage());
     }
     return array('json', $output);
 }
Ejemplo n.º 8
0
 /**
  * 区分マスタの保存が成功したかJSON形式で返す
  * @access public
  * @see Admin_ActionClass::perform()
  */
 function perform()
 {
     // get request params
     $buyer_cd = $this->af->get('buyer_cd');
     $buyer_name = $this->af->get('buyer_name');
     $buyer_abbr = $this->af->get('buyer_abbr');
     $zip_cd = $this->af->get('zip_cd');
     $address1 = $this->af->get('address1');
     $address2 = $this->af->get('address2');
     $address3 = $this->af->get('address3');
     $tel = $this->af->get('tel');
     $fax = $this->af->get('fax');
     $user_groups = $this->af->get('user_groups');
     $terminal_groups = $this->af->get('terminal_groups');
     // get session params
     $company_id = $this->session->get('company_id');
     $user_id = $this->session->get('user_id');
     // dao
     $buyerDao = DaoFactory::BuyerMst();
     try {
         // begin
         $buyerDao->BeginTransaction();
         // ユーザー存在チェック
         $exist = $buyerDao->Retrieve(' company_id = ? AND buyer_cd = ?  ', array($company_id, $buyer_cd));
         if (!is_array($exist)) {
             $def1 = $this->af->getDef('buyer_cd');
             $err_msg = array('shop_cd' => $def1['name'] . "が登録されていません");
             return array(400, $err_msg);
         }
         // set params
         $params = array('buyer_name' => $buyer_name, 'buyer_abbr' => $buyer_abbr, 'zip_cd' => $zip_cd, 'address1' => $address1, 'address2' => $address2, 'address3' => $address3, 'tel' => $tel, 'fax' => $fax, 'UID' => $user_id, 'PGM' => get_class());
         // dao update
         $buyerDao->Update($params, ' company_id = ? AND buyer_cd = ? ', array($company_id, $buyer_cd));
         //
         $params = array('company_id' => $company_id, 'buyer_cd' => $buyer_cd);
         $buyerDao->Delete_UserBuyer($params);
         $buyerDao->Delete_TerminalBuyer($params);
         //USER_BUYER
         if ($user_groups != '') {
             $user_groups = explode(',', $user_groups);
             foreach ($user_groups as $user_id) {
                 $params = array('company_id' => $company_id, 'user_id' => $user_id, 'buyer_cd' => $buyer_cd, 'UID' => $user_id, 'PGM' => get_class());
                 $buyerDao->Insert_UserBuyer($params);
             }
         }
         if ($terminal_groups != '') {
             $terminal_groups = explode(',', $terminal_groups);
             foreach ($terminal_groups as $terminal_id) {
                 $params = array('company_id' => $company_id, 'terminal_id' => $terminal_id, 'buyer_cd' => $buyer_cd, 'UID' => $user_id, 'PGM' => get_class());
                 $buyerDao->Insert_TerminalBuyer($params);
             }
         }
         // commit
         $buyerDao->CommitTransaction();
     } catch (Exception $e) {
         // rollback
         $buyerDao->AbortTransaction();
         $this->logger->log(LOG_DEBUG, $e->getTraceAsString());
         return array(500, $e->getMessage());
     }
     exit;
 }