39038-vm/tmp_reg_edit.php
2026-03-07 18:26:14 +00:00

106 lines
5.2 KiB
PHP

<?php
$content = file_get_contents('register.php');
$s1 = " 'plate_no' => '',";
$r1 = " 'plate_no' => '',\n 'bank_account' => '',\n 'bank_name' => '',\n 'bank_branch' => '',";
$s2 = " 'plate_no' => trim(\"
$_POST['plate_no'] ?? ''\"),";
$r2 = " 'plate_no' => trim(\"
$_POST['plate_no'] ?? ''\"),\n 'bank_account' => trim(\"
$_POST['bank_account'] ?? ''\"),\n 'bank_name' => trim(\"
$_POST['bank_name'] ?? ''\"),\n 'bank_branch' => trim(\"
$_POST['bank_branch'] ?? ''\"),";
$s3 = " $plateNo = trim(\"
$_POST['plate_no'] ?? ''\");";
$r3 = " $plateNo = trim(\"
$_POST['plate_no'] ?? ''\");\n $bankAccount = trim(\"
$_POST['bank_account'] ?? ''\");\n $bankName = trim(\"
$_POST['bank_name'] ?? ''\");\n $bankBranch = trim(\"
$_POST['bank_branch'] ?? ''\");";
$s4 = " if ($truckType === '' || $loadCapacity === '' || $plateNo === '') {\n $errors[] = 'Please complete truck details.';\n } elseif (!is_numeric($loadCapacity) || (float)$loadCapacity <= 0) {";
$r4 = " if ($truckType === '' || $loadCapacity === '' || $plateNo === '') {\n $errors[] = 'Please complete truck details.';\n } elseif ($bankAccount === '' || $bankName === '' || $bankBranch === '') {\n $errors[] = 'Please complete bank account details.';\n } elseif (!is_numeric($loadCapacity) || (float)$loadCapacity <= 0) {";
$s5 = <<<PHP
$ownerStmt = $pdo->prepare(
"INSERT INTO truck_owner_profiles (user_id, phone, country_id, city_id, address_line, truck_type, load_capacity, plate_no, id_card_path, truck_pic_path, registration_path)"
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
$ownerStmt->execute([
$userId,
$phone,
$countryId,
$cityId,
$addressLine,
$truckType,
$loadCapacity,
$plateNo,
json_encode($idCardPaths, JSON_UNESCAPED_SLASHES),
$truckPic,
json_encode($regPaths, JSON_UNESCAPED_SLASHES),
]);
PHP;
$r5 = <<<PHP
$ownerStmt = $pdo->prepare(
"INSERT INTO truck_owner_profiles (user_id, phone, country_id, city_id, address_line, truck_type, load_capacity, plate_no, bank_account, bank_name, bank_branch, id_card_path, truck_pic_path, registration_path)"
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
$ownerStmt->execute([
$userId,
$phone,
$countryId,
$cityId,
$addressLine,
$truckType,
$loadCapacity,
$plateNo,
$bankAccount,
$bankName,
$bankBranch,
json_encode($idCardPaths, JSON_UNESCAPED_SLASHES),
$truckPic,
json_encode($regPaths, JSON_UNESCAPED_SLASHES),
]);
PHP;
$s7 = <<<HTML
<div class="col-md-4">
<label class="form-label" for="plate_no">Plate number</label>
<input type="text" name="plate_no" id="plate_no" class="form-control" value="<?= e($values['plate_no']) ?>">
</div>
HTML;
$r7 = <<<HTML
<div class="col-md-4">
<label class="form-label" for="plate_no">Plate number</label>
<input type="text" name="plate_no" id="plate_no" class="form-control" value="<?= e($values['plate_no']) ?>">
</div>
<h3 class="h6 mt-4 mb-2 w-100">Bank Details for Payouts</h3>
<div class="col-md-4 mt-2">
<label class="form-label" for="bank_account">Bank Account / IBAN</label>
<input type="text" name="bank_account" id="bank_account" class="form-control" value="<?= e($values['bank_account']) ?>">
</div>
<div class="col-md-4 mt-2">
<label class="form-label" for="bank_name">Bank Name</label>
<input type="text" name="bank_name" id="bank_name" class="form-control" value="<?= e($values['bank_name']) ?>">
</div>
<div class="col-md-4 mt-2">
<label class="form-label" for="bank_branch">Branch</label>
<input type="text" name="bank_branch" id="bank_branch" class="form-control" value="<?= e($values['bank_branch']) ?>">
</div>
HTML;
$content = str_replace($s1, $r1, $content);
$content = str_replace($s2, $r2, $content);
$content = str_replace($s3, $r3, $content);
$content = str_replace($s4, $r4, $content);
$content = str_replace($s5, $r5, $content);
$content = str_replace($s7, $r7, $content);
file_put_contents('register.php', $content);
echo "Replaced in register.php\n";