From f0e3fd8f8ce4f843901744b9b17e901a4785e1d2 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Wed, 13 Dec 2023 06:24:10 +0200 Subject: [PATCH] Fixed escrow script not logging BRDA in DB --- automation/escrow.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/automation/escrow.php b/automation/escrow.php index fb877b9..3d37d9a 100644 --- a/automation/escrow.php +++ b/automation/escrow.php @@ -977,6 +977,39 @@ try { } } } + + $depositDate = date('Y-m-d'); + $fileName = $c['escrow_deposit_path'] . "/" . $baseFileNameBrda . ".ryde"; + $fileFormat = 'XML'; + $encryptionMethod = 'GnuPG'; + $depositType = 'BRDA'; + $status = 'Deposited'; + $verificationStatus = 'Pending'; + + // Prepare the INSERT statement + $stmt = $dbh->prepare("INSERT INTO rde_escrow_deposits (deposit_id, deposit_date, file_name, file_format, encryption_method, deposit_type, status, verification_status, revision) VALUES (:deposit_id, :deposit_date, :file_name, :file_format, :encryption_method, :deposit_type, :status, :verification_status, :revision)"); + + $previousDayFormatted = date('Ymd'); + $paddedFinalDepositId = str_pad($finalDepositId, 3, '0', STR_PAD_LEFT); + $depositId = $previousDayFormatted . $paddedFinalDepositId; + + // Bind the parameters + $stmt->bindParam(':deposit_id', $depositId); + $stmt->bindParam(':deposit_date', $depositDate); + $stmt->bindParam(':file_name', $fileName); + $stmt->bindParam(':file_format', $fileFormat); + $stmt->bindParam(':encryption_method', $encryptionMethod); + $stmt->bindParam(':deposit_type', $depositType); + $stmt->bindParam(':status', $status); + $stmt->bindParam(':verification_status', $verificationStatus); + $stmt->bindParam(':revision', $finalDepositId, PDO::PARAM_INT); + + // Execute the statement + if (!$stmt->execute()) { + // Handle error here + $errorInfo = $stmt->errorInfo(); + $log->error('Database error: ' . $errorInfo[2]); + } } $depositDate = date('Y-m-d');