58 lines
2.5 KiB
Python
58 lines
2.5 KiB
Python
import sys
|
|
|
|
with open()eid_orders.php', 'r') as f:
|
|
content = f.read()
|
|
|
|
search1 = """ <tr>
|
|
<td>
|
|
<div class="fw-semibold"><?= h($order['receipt_no']) ?></div>
|
|
</td>
|
|
<td>
|
|
<div class="fw-semibold"><?= h((string) ($order['customer_name'] ?: tr('عميل نقدن', 'Walk-in customer'))) ?></div>
|
|
</td>"""
|
|
|
|
replace1 = """ <?php
|
|
$cNameRaw = (string) ($order['customer_name'] ?: tr('عميل نہدق', 'Walk-in customer'));
|
|
$cName = $cNameRaw;
|
|
$cPhone = '';
|
|
if (strpos($cNameRaw, ' - ') !== false) {
|
|
$parts = explode(' - ', $cNameRaw, 2);
|
|
$cName = trim($parts[0]);
|
|
$rawPhone = trim($parts[1]);
|
|
if (preg_match('/^968\s*/', $rawPhone)) {
|
|
$cPhone = preg_replace('/^968\s*/', '968 ', $rawPhone);
|
|
} elseif (is_numeric(str_replace(' ', '', $rawPhone))) {
|
|
$cPhone = '968 ' . $rawPhone;
|
|
} else {
|
|
$cName = $cNameRaw;
|
|
}
|
|
}
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<div class="fw-semibold"><?= h($order['receipt_no']) ?></div>
|
|
</td>
|
|
<td>
|
|
<div class="fw-semibold"><?= h(${cName}) ?></div>
|
|
<?php if ($cPhone !== ''): ?>
|
|
<div class="small text-muted" dir="ltr"><?= h($cPhone) ?></div>
|
|
<?php endif; ?>
|
|
</td>"""
|
|
|
|
search2 = """ <td class="text-end fw-semibold"><?= h(number_format((float) ($order['total_amount'] ?? 0), 3)) ?></td>
|
|
<td>
|
|
<div class="d-flex justify-content-end gap-2">"""
|
|
|
|
replace2 = """ <td class="text-end fw-semibold"><?= h(number_format((float) ($order['total_amount'] ?? 0), 3)) ?></td>
|
|
<td>
|
|
<span class="badge <?= h(payment_status_badge_class((string) ($order['payment_status'] ?? 'paid'))) ?> px-2 py-1"><?= h(payment_status_label((string) ($order['payment_status'] ?? 'paid'))) ?></span>
|
|
</td>
|
|
<td>
|
|
<div class="d-flex justify-content-end gap-2">"""
|
|
|
|
content = content.replace(search1, replace1)
|
|
content = content.replace(search2, replace2)
|
|
|
|
with open()eid_orders.php', 'w') as f:
|
|
f.write(content)
|