/** * DB更新 */ public function Result_AdminReportSalesSalesEdit_update(&$newObjectArray, &$rawDetailArray, $status) { $db =& $this->_core->getDBForUpdate(); //-------------------------- // 案件別売上テーブル //-------------------------- // 完了画面の表示に使うため、複製を利用 $salesObject = clone $newObjectArray['sales']; $loginId = $this->_core->getLoginLoginId(); $loginName = $this->_core->getLoginName(); $now = date('Y-m-d H:i:s'); // ステータスのフラグと変更者、変更時刻 if ($status == ENUM_SALES_GENKA_REPORT_STATUS_INPUTTED) { $salesObject->getField('shime_upd_user_id')->setValue($loginId); $salesObject->getField('shime_upd_user_name')->setValue($loginName); $salesObject->getField('shime_upd_time')->setValue($now); $salesObject->getField('last_save_type')->setValue(ENUM_SALES_GENKA_REPORT_SAVE_TYPE_SAVE); } else { if ($status == ENUM_SALES_GENKA_REPORT_STATUS_FIXED) { $salesObject->getField('fixed_flg')->setValue('1'); $salesObject->getField('fixed_user_id')->setValue($loginId); $salesObject->getField('fixed_user_name')->setValue($loginName); $salesObject->getField('fixed_time')->setValue($now); $salesObject->getField('status')->setValue(ENUM_SALES_GENKA_REPORT_STATUS_FIXED); // 表示用の売上データのステータスも更新 $newObjectArray['sales']->getField('status')->setValue(ENUM_SALES_GENKA_REPORT_STATUS_FIXED); } else { if ($status == ENUM_SALES_GENKA_REPORT_STATUS_CANCEL_FIXED) { $salesObject->getField('fixed_flg')->setValue('0'); $salesObject->getField('status')->setValue(ENUM_SALES_GENKA_REPORT_STATUS_INPUTTED); // 表示用の売上データのステータスも更新 $newObjectArray['sales']->getField('status')->setValue(ENUM_SALES_GENKA_REPORT_STATUS_INPUTTED); } } } //-------------------------- // DB更新の前にログを出力 // 確定時は登録するデータ、それ以外は案件別売上IDをデータとして保存する // ↓ログ出力処理ここから //-------------------------- // ステータス $enumStatus = new SalesGenkaReportStatusEnum(); // ログ作成用のオブジェクトを作成 $logObjectArray = array(); if ($status == ENUM_SALES_GENKA_REPORT_STATUS_FIXED) { $logObjectArray['sales'] = clone $newObjectArray['sales']; foreach ($newObjectArray['detail_list'] as $newDetail) { $logObjectArray['detail_list'][] = clone $newDetail; } } else { $logObjectArray["anken_sales_id"] = $newObjectArray['sales']->getField('anken_sales_id')->getValue(); } // ステータス情報 $statusInfo = $enumStatus->getValue($status); // ステータスが入力中のときは保存種別も追加 if ($status == ENUM_SALES_GENKA_REPORT_STATUS_INPUTTED) { // 最終保存ステータス $enumLastSaveStatus = new SalesGenkaReportSaveTypeEnum(); $lastSaveStatus = $enumLastSaveStatus->getValue(ENUM_SALES_GENKA_REPORT_SAVE_TYPE_SAVE); $statusInfo .= "({$lastSaveStatus})"; } // ログを出力 $action = "売上更新"; $data = $logObjectArray; $userId = $this->_core->getLoginLoginId(); $userName = $this->_core->getLoginName(); OperationHistory::writeOperationHistory($db, $action, $statusInfo, $data, $userId, $userName); unset($logObjectArray); //-------------------------- // ↑ログ出力処理ここまで //-------------------------- // 値に変更が無い場合でも更新日時が変更されるように設定 $salesObject->getField('upd_time')->setValue($now); parent::update($salesObject); // 確定または保存ボタン押下時は売上明細を更新 if ($status == ENUM_SALES_GENKA_REPORT_STATUS_INPUTTED || $status == ENUM_SALES_GENKA_REPORT_STATUS_FIXED) { //-------------------------- // 案件別売上明細テーブルと請求発行確認テーブル // いったん該当する案件別売上IDに紐づくレコードをすべて削除して、 // 新しくすべてのレコードを登録する //-------------------------- // 明細の削除 $onlyAffiliate = false; $this->Result_AdminReportSalesSalesEdit_deleteDetail($newObjectArray['sales']->getField('anken_sales_id')->getValue(), $onlyAffiliate, $db); // すべての明細レコードの登録 foreach ($newObjectArray['detail_list'] as $detail) { // 完了画面の表示に使うため、複製を利用 $detailClone = clone $detail; // 発行申請中、または発行確認済みの請求発行確認情報が存在する場合は取得 $billIssue = new DataReportSalesSalesBillIssue(); if ($detailClone->getField('bill_issue_status')->getValue() == ENUM_BILL_ISSUE_STATUS_APPLIED || $detailClone->getField('bill_issue_status')->getValue() == ENUM_BILL_ISSUE_STATUS_APPROVED) { // 該当データをDataObjectにセット $billIssue->getField('bill_issue_status')->setValue($detailClone->getField('bill_issue_status')->getValue()); $billIssue->getField('bill_issue_operation')->setValue($detailClone->getField('bill_issue_operation')->getValue()); $billIssue->getField('upd_user_id')->setValue($detailClone->getField('bill_issue_upd_user_id')->getValue()); $billIssue->getField('upd_time')->setValue($detailClone->getField('bill_issue_upd_time')->getValue()); } //-------------------------- // 案件別売上明細テーブル //-------------------------- // 請求発行確認テーブルの項目を外す $detailClone->removeField('bill_issue_status'); $detailClone->removeField('bill_issue_operation'); $detailClone->removeField('bill_issue_upd_user_id'); $detailClone->removeField('bill_issue_upd_time'); parent::insert($detailClone); $ankenSalesDetailId = mysql_insert_id(); //-------------------------- // 請求発行確認テーブル //-------------------------- // 請求発行確認情報が存在する場合は登録 if (0 < $billIssue->getChangedCount()) { // 上で登録した案件メディア企業別原価明細IDを設定 $billIssue->getField('anken_sales_detail_id')->setValue($ankenSalesDetailId); parent::insert($billIssue); } } // 確定ボタン押下時は、生データから集計したデータをログとして保存する if ($status == ENUM_SALES_GENKA_REPORT_STATUS_FIXED) { // 明細ログの削除 $this->Result_AdminReportSalesSalesEdit_deleteDetailLog($newObjectArray['sales']->getField('anken_sales_id')->getValue(), $db); foreach ($rawDetailArray as $rawDetail) { // 完了画面の表示に使うため、複製を利用 $detailClone = clone $rawDetail; //-------------------------- // 案件別売上明細ログテーブル //-------------------------- parent::insert($detailClone); } } } }
/** * DB更新 */ public function Anken_PriceReserveEdit_update(&$o, $anken) { $priceTypeCd = $anken['price_type_cd']; $useOptionPrice = $anken['use_option_price']; $db =& $this->_core->getDBForUpdate(); $m = clone $o; // ID別売上・原価設定 $priceList = array(); if ($priceTypeCd == "1" && $useOptionPrice == "1") { // 金額項目取得・削除 $m =& $this->Anken_PriceReserveEdit_removePriceItemsFromPriceReserveObject($m); } else { $m->removeField('price'); $m->removeField('oroshi'); //↓↓===========nm90008 start=================================== // 単価2、卸値2 $m->removeField('extra_price'); $m->removeField('extra_oroshi'); //↑↑===========nm90008 end===================================== } //---------------------------------------------- // 予約単価情報更新 //---------------------------------------------- if ($m->getChangedCount() > 0) { parent::update($m); } //---------------------------------------------- // 予約単価更新 //---------------------------------------------- // 予約ID $reserveId = $o->getField('reserve_id')->getValue(); // ID別売上・原価設定 if ($priceTypeCd == "1" && $useOptionPrice == "1") { // 金額情報を削除 $this->Anken_PriceReserveEdit_deletePriceReservePrice($reserveId); // オブジェクトの金額項目を取得する $priceList =& $this->Anken_PriceReserveEdit_getPriceListFromPriceReserveObject($o); // 金額情報を登録 $this->Anken_PriceReserveEdit_insertPriceReservePrice($reserveId, $priceList); } else { $price = $o->getField('price')->getValue(); $oroshi = $o->getField('oroshi')->getValue(); // 予約単価テーブル $sql = <<<SQL update ald_price_reserve_price set price=?, oroshi=? where reserve_id=? and order_id=1 SQL; $param = array($price, $oroshi, $reserveId); $db->execute($sql, $param); //↓↓===========nm90008 start=================================== // 売上2、原価2情報設定 $extraPrice = $o->getField('extra_price')->getValue(); $extraOroshi = $o->getField('extra_oroshi')->getValue(); //↑↑===========nm90008 end===================================== $sql = <<<SQL update ald_price_reserve_price set price=?, oroshi=? where reserve_id=? and order_id=2 SQL; $param = array($extraPrice, $extraOroshi, $reserveId); $db->execute($sql, $param); } }