/** * 棚卸調整マスタの保存が成功したかJSON形式で返す * @access public * @see Admin_ActionClass::perform() */ function perform() { // get request params $chousei_date = $this->af->get('chousei_date'); $chousei = $this->af->get('chousei'); $biko = $this->af->get('biko'); // get session params $company_id = $this->session->get('company_id'); $s_user_id = $this->session->get('user_id'); // dao $zaikoChoseiDDao = DaoFactory::ZaikoChouseiD(); $zaikoChouseiMDDao = DaoFactory::ZaikoChouseiMD(); $warehouseDao = DaoFactory::WarehouseMst(); $productDao = DaoFactory::ProductMst(); try { // begin $zaikoChoseiDDao->BeginTransaction(); // print_r($chousei); if (!empty($chousei)) { foreach ($chousei as $warehouseId => $val) { // shop_cd 存在チェック $warehouse = $warehouseDao->Retrieve(' company_id = ? AND warehouse_id = ? ', array('company_id' => $company_id, 'warehouse_id' => $warehouseId)); if (empty($warehouse)) { throw new Exception("入力された 倉庫ID: {$warehouseId} は登録されていません"); } // 枝番号初期化 $edaban = 0; foreach ($val as $product_id => $chousei_num) { // chousei_num 空、0チェック if (!$chousei_num) { continue; } // ゼロ、空文字であればスルー // 調整NOの最大値を取得 $chousei_no = intval($zaikoChoseiDDao->maxByColumn('CHOUSEI_NO', " company_id = ? AND terminal_id = '-' AND warehouse_id = ? ", array('company_id' => $company_id, 'warehouse_id' => $warehouseId))); $chousei_no += 1; // D に insert $params = array('company_id' => $company_id, 'terminal_id' => '-', 'chousei_no' => $chousei_no, 'bc_bunrui' => '0', 'warehouse_id' => $warehouseId, 'chousei_date' => array('value' => $chousei_date, 'type' => 'date'), 'nyushutsu_kbn' => '1', 'soshin_flg' => '0', 'zaiko_koshin_flg' => '0', 'biko' => $biko, 'UID' => $s_user_id, 'PGM' => get_class()); // print_r($params); $zaikoChoseiDDao->Insert($params); // MD に insert $edaban += 1; $params = array('company_id' => $company_id, 'terminal_id' => '-', 'chousei_no' => $chousei_no, 'warehouse_id' => $warehouseId, 'edaban' => $edaban, 'bc_1' => '', 'stock_update_flg' => '0', 'product_id' => $product_id, 'suryo' => $chousei_num, 'UID' => $s_user_id, 'PGM' => get_class()); $zaikoChouseiMDDao->Insert($params); } } } DaoFactory::ZaikoBatchPkg()->batch_zaiko_chousei_d(array('company_id' => $company_id, 'upd_uid' => $s_user_id, 'upd_pgm' => get_class())); // commit $zaikoChoseiDDao->CommitTransaction(); } catch (Exception $e) { // rollback // print_r($e); $zaikoChoseiDDao->AbortTransaction(); $this->logger->log(LOG_DEBUG, $e->getTraceAsString()); return array(500, $e->getMessage()); } exit; }