/** * 端末マスタの保存が成功したかJSON形式で返す * @access public * @see Admin_ActionClass::perform() */ function perform() { // get request params $terminal_id = $this->af->get('terminal_id'); $terminal_name = $this->af->get('terminal_name'); $password = $this->af->get('password'); $warehouse_id = $this->af->get('warehouse_id'); // get session params $company_id = $this->session->get('company_id'); $s_user_id = $this->session->get('user_id'); $licenses = $this->af->get('license_id'); //add $oya_terminal_id = null; if (!is_null($oya_terminal_flg) && $mode_kbn == 1) { $oya_terminal_id = $terminal_id; } // dao $terminalDao = DaoFactory::TerminalMst(); try { // begin $terminalDao->BeginTransaction(); // // $wheresql = 'company_id=? ORDER BY UPD_DATE desc'; // $params = array( // 'company_id' => $company_id, // ); // $license = DaoFactory::LicenseD()->Retrieve($wheresql, $params); // if (DaoFactory::TerminalMst()->Column('COUNT(*)', 'company_id=?', $params) >= $license['MAX_TERMINAL']) { // return array('400', array('terminal_id' => '端末数が申込まれた端末数に達しています。新たに端末を追加するには削除するか端末数を増やす申請を行ってください')); // } // set params $params = array('terminal_id' => $terminal_id, 'terminal_name' => $terminal_name, 'status_flg' => '1', 'password' => md5($password), 'company_id' => $company_id, 'UID' => $s_user_id, 'PGM' => get_class()); //terminal insert $terminalDao->Insert($params); $TanmatsuLicenseDao = Daofactory::TanmatsuLicense(); //add $licenseDao = DaoFactory::LicenseMst(); //add //license //-- delete $params = array('company_id' => $company_id, 'terminal_id' => $terminal_id); $TanmatsuLicenseDao->Delete(' company_id = ? AND terminal_id = ? ', $params); if ($licenses != '') { $licenses = explode(',', $licenses); //terminal_license insert foreach ($licenses as $license_id) { //exists ( license_id ) $exist = $licenseDao->Retrieve(' company_id = ? AND license_id = ? ', array($company_id, $license_id)); if (empty($exist)) { $def1 = $this->af->getDef('license_id'); $err_msg = array('license_id_err' => "入力された" . $def1['name'] . "は登録されていません"); return array(400, $err_msg); } $params = array('company_id' => $company_id, 'terminal_id' => $terminal_id, 'license_id' => $license_id, 'UID' => $user_id, 'PGM' => get_class()); $TanmatsuLicenseDao->Insert($params); //if start_time is null $params = array('license_id' => $license_id, 'company_id' => $company_id); $result = $licenseDao->Column('START_YMD_HMS', ' LICENSE_ID = ? AND COMPANY_ID = ? ', $params); if (empty($result)) { $params = array('company_id' => $company_id, 'license_id' => $license_id, 'uid' => $s_user_id, 'pgm' => get_class()); //update start_date end_date of license_mst $licenseDao->UpdateLicense($params); } } } //endif license != '' // commit $terminalDao->CommitTransaction(); } catch (Exception $e) { $terminalDao->AbortTransaction(); $this->logger->log(LOG_DEBUG, $e->getTraceAsString()); return array(500, $e->getMessage()); } exit; }
/** * 端末マスタの保存が成功したかJSON形式で返す * @access public * @see Admin_ActionClass::perform() */ function perform() { // get request params $terminal_id = $this->af->get('terminal_id'); $terminal_name = $this->af->get('terminal_name'); $password = $this->af->get('password'); $warehouse_id = $this->af->get('warehouse_id'); // get session params $company_id = $this->session->get('company_id'); $s_user_id = $this->session->get('user_id'); $licenses = $this->af->get('license_id'); //add // dao $terminalDao = DaoFactory::TerminalMst(); $TanmatsuLicenseDao = Daofactory::TanmatsuLicense(); //add $licenseDao = DaoFactory::LicenseMst(); //add try { // begin $terminalDao->BeginTransaction(); // set params $params = array('terminal_name' => $terminal_name, 'status_flg' => '1', 'UID' => $s_user_id, 'PGM' => get_class()); // password がリクエストにあれば update に含める if ($password != '') { $params['password'] = md5($password); } // dao update $terminalDao->Update($params, ' company_id = ? AND terminal_id = ? ', array($company_id, $terminal_id)); //license //-- delete $params = array('company_id' => $company_id, 'terminal_id' => $terminal_id); $TanmatsuLicenseDao->Delete(' company_id = ? AND terminal_id = ? ', $params); if ($licenses != '') { $licenses = explode(',', $licenses); // insert foreach ($licenses as $license_id) { //exists ( license_id ) $exist = $licenseDao->Retrieve(' company_id = ? AND license_id = ? ', array($company_id, $license_id)); if (empty($exist)) { $def1 = $this->af->getDef('license_id'); $err_msg = array('license_id_err' => "入力された" . $def1['name'] . "は登録されていません"); return array(400, $err_msg); } $params = array('company_id' => $company_id, 'terminal_id' => $terminal_id, 'license_id' => $license_id, 'UID' => $s_user_id, 'PGM' => get_class()); $TanmatsuLicenseDao->Insert($params); //if start_time is null $params = array('license_id' => $license_id, 'company_id' => $company_id); $result = $licenseDao->Column('START_YMD_HMS', ' LICENSE_ID = ? AND COMPANY_ID = ? ', $params); if (empty($result)) { $params = array('company_id' => $company_id, 'license_id' => $license_id, 'uid' => $s_user_id, 'pgm' => get_class()); //update start_date end_date of license_mst $licenseDao->UpdateLicense($params); } } } //endif license != '' // commit $terminalDao->CommitTransaction(); } catch (Exception $e) { // rollback $terminalDao->AbortTransaction(); $this->logger->log(LOG_DEBUG, $e->getTraceAsString()); return array(500, $e->getMessage()); } exit; }