kingkay000 commited on
Commit
8dec958
·
verified ·
1 Parent(s): 1f2eea8

Update bank-credit-update/index.php

Browse files
Files changed (1) hide show
  1. bank-credit-update/index.php +12 -10
bank-credit-update/index.php CHANGED
@@ -1,13 +1,15 @@
1
  <?php
 
 
2
  // 1. Settings for a "Receiver" script
3
  header('Content-Type: application/json');
4
  set_time_limit(60);
5
 
6
  // 2. Database Configuration
7
- $dbHost = 'o2.service.oyster.cloud76.cc:3306';
8
- $dbUser = 'cs_admin';
9
- $dbPass = 'D55-system-2-beasts-jungle-sky-birth';
10
- $dbName = 'one_arps_aci';
11
 
12
  // 3. Capture the JSON from n8n
13
  $jsonRaw = file_get_contents('php://input');
@@ -21,11 +23,11 @@ if (!$data || !isset($data['amount'])) {
21
  }
22
 
23
  // 4. Connect to Database
24
- $conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
25
- if ($conn->connect_error) {
26
- http_response_code(500);
27
- die(json_encode(["status" => "error", "message" => "Database connection failed"]));
28
- }
29
 
30
  // 5. Prepare Variables from n8n Data
31
  $rawDate = $data['date']; // Format: YYYY-MM-DD
@@ -54,7 +56,7 @@ $newId = $idPrefix . "-" . str_pad($serial, 3, "0", STR_PAD_LEFT);
54
 
55
  // 7. Prevent Duplicate Insertion (Check by Reference)
56
  // Assuming reference is a reliable unique key from the bank
57
- $checkDup = "SELECT id FROM tb_account_bank_statements WHERE description LIKE '%$reference%'";
58
  $dupResult = $conn->query($checkDup);
59
 
60
  if ($dupResult->num_rows == 0) {
 
1
  <?php
2
+ require_once 'db_config.php';
3
+
4
  // 1. Settings for a "Receiver" script
5
  header('Content-Type: application/json');
6
  set_time_limit(60);
7
 
8
  // 2. Database Configuration
9
+ //$dbHost = 'o2.service.oyster.cloud76.cc:3306';
10
+ //$dbUser = 'cs_admin';
11
+ //$dbPass = 'D55-system-2-beasts-jungle-sky-birth';
12
+ //$dbName = 'one_arps_aci';
13
 
14
  // 3. Capture the JSON from n8n
15
  $jsonRaw = file_get_contents('php://input');
 
23
  }
24
 
25
  // 4. Connect to Database
26
+ //$conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
27
+ //if ($conn->connect_error) {
28
+ // http_response_code(500);
29
+ // die(json_encode(["status" => "error", "message" => "Database connection failed"]));
30
+ //}
31
 
32
  // 5. Prepare Variables from n8n Data
33
  $rawDate = $data['date']; // Format: YYYY-MM-DD
 
56
 
57
  // 7. Prevent Duplicate Insertion (Check by Reference)
58
  // Assuming reference is a reliable unique key from the bank
59
+ $checkDup = "SELECT id FROM tb_account_bank_statements WHERE description LIKE '%$description%'";
60
  $dupResult = $conn->query($checkDup);
61
 
62
  if ($dupResult->num_rows == 0) {