update lists splitting tel

This commit is contained in:
Flatlogic Bot 2026-04-23 04:43:40 +00:00
parent 0590b5d747
commit 9b5e175eec
7 changed files with 70 additions and 27 deletions

View File

@ -172,6 +172,7 @@ require_once 'includes/header.php';
<tr>
<th><?= h(tr('رقم الفاتورة', 'Receipt No')) ?></th>
<th><?= h(tr('العميل', 'Customer')) ?></th>
<th><?= h(tr('الهاتف', 'Phone')) ?></th>
<th><?= h(tr('التاريخ', 'Date')) ?></th>
<th><?= h(tr('الإجمالي', 'Total')) ?></th>
<th><?= h(tr('المدفوع', 'Paid')) ?></th>
@ -183,7 +184,7 @@ require_once 'includes/header.php';
<tbody>
<?php if (empty($unpaidSales)): ?>
<tr>
<td colspan="8" class="text-center py-4 text-muted"><?= h(tr('لا توجد فواتير غير مدفوعة أو جزئية.', 'No unpaid or partial invoices.')) ?></td>
<td colspan="9" class="text-center py-4 text-muted"><?= h(tr('لا توجد فواتير غير مدفوعة أو جزئية.', 'No unpaid or partial invoices.')) ?></td>
</tr>
<?php else: ?>
<?php foreach ($unpaidSales as $sale): ?>
@ -194,7 +195,27 @@ require_once 'includes/header.php';
<?= h($sale['receipt_no']) ?>
</a>
</td>
<td><?= h($sale['c_name'] ?: $sale['customer_name'] ?: '-') ?></td>
<?php
$rawCustomerName = (string) ($sale['c_name'] ?: $sale['customer_name'] ?: '-');
$displayPhone = '';
if (str_contains($rawCustomerName, ' - ')) {
$parts = explode(' - ', $rawCustomerName);
$lastPart = trim(end($parts));
if (preg_match('/^[0-9+\s]+$/', $lastPart)) {
$displayPhone = $lastPart;
array_pop($parts);
$rawCustomerName = trim(implode(' - ', $parts));
}
}
$displayPhone = ltrim(preg_replace('/[^0-9]/', '', $displayPhone), '0');
if ($displayPhone !== '') {
if (str_starts_with($displayPhone, '968') && strlen($displayPhone) > 8) {
$displayPhone = substr($displayPhone, 3);
}
}
?>
<td><?= h($rawCustomerName) ?></td>
<td dir="ltr"><?= h($displayPhone ?: '-') ?></td>
<td><?= h(date('Y-m-d', strtotime((string)$sale['sale_date']))) ?></td>
<td class="fw-semibold"><?= h(currency((float)$sale['total_amount'])) ?></td>
<td class="text-primary"><?= h(currency((float)$paymentSummary['paid_amount'])) ?></td>

View File

@ -430,8 +430,8 @@ require __DIR__ . '/includes/header.php';
<?php
$phone = ltrim(preg_replace('/[^0-9]/', '', $displayPhone), '0');
if ($phone !== '') {
if (!str_starts_with($phone, '968')) {
$phone = '968' . $phone;
if (str_starts_with($phone, '968') && strlen($phone) > 8) {
$phone = substr($phone, 3);
}
echo h($phone);
} else {

View File

@ -295,7 +295,7 @@ function phone_display(?string $value): string
}
$local = normalize_oman_phone($raw);
return $local !== '' ? ('968 ' . $local) : $raw;
return $local !== '' ? $local : $raw;
}
function wablas_parse_phone_list(string $value): array

View File

@ -283,7 +283,7 @@ require __DIR__ . '/includes/header.php';
function viewOrder(order) {
const modal = bootstrap.Modal.getOrCreateInstance(document.getElementById('orderModal'));
document.getElementById('vName').innerText = order.name;
document.getElementById('vPhone').innerText = order.phone ? ('968 ' + String(order.phone).replace(/^((00968)|(968))/, '')) : '';
document.getElementById('vPhone').innerText = order.phone ? String(order.phone).replace(/^((00968)|(968))/, '') : '';
document.getElementById('vAddress').innerText = order.address;
document.getElementById('vPaymentMethod').innerText = order.payment_method || '';
document.getElementById('vPaymentStatus').innerText = order.payment_status || '';

View File

@ -1,18 +0,0 @@
import re
with open('eid_orders.php', 'r') as f:
content = f.read()
colors = ['bg-primary-subtle', 'bg-info-subtle', 'bg-warning-subtle', 'bg-success-subtle']
parts = content.split('<div class="card border-0 p-2 bg-primary-subtle">')
if len(parts) == 5:
new_content = parts[0]
for i in range(4):
new_content += f'<div class="card border-0 p-3 {colors[i]}">' + parts[i+1]
with open('eid_orders.php', 'w') as f:
f.write(new_content)
print("Patched successfully")
else:
print(f"Found {len(parts)} parts, expected 5.")

View File

@ -525,8 +525,27 @@ require __DIR__ . '/includes/header.php';
<tr>
<td><?= h(date('Y-m-d H:i', strtotime((string)$sale['sale_date']))) ?></td>
<td><?= h((string)$sale['receipt_no']) ?></td>
<td><?= h((string)($sale['customer_name'] ?: '-')) ?></td>
<td dir="ltr"><?= h((string)($sale['customer_phone'] ? phone_display($sale['customer_phone']) : '-')) ?></td>
<?php
$rawCustomerName = (string) ($sale['customer_name'] ?: '-');
$displayPhone = (string) ($sale['customer_phone'] ?? '');
if ($displayPhone === '' && str_contains($rawCustomerName, ' - ')) {
$parts = explode(' - ', $rawCustomerName);
$lastPart = trim(end($parts));
if (preg_match('/^[0-9+\s]+$/', $lastPart)) {
$displayPhone = $lastPart;
array_pop($parts);
$rawCustomerName = trim(implode(' - ', $parts));
}
}
$displayPhone = ltrim(preg_replace('/[^0-9]/', '', $displayPhone), '0');
if ($displayPhone !== '') {
if (str_starts_with($displayPhone, '968') && strlen($displayPhone) > 8) {
$displayPhone = substr($displayPhone, 3);
}
}
?>
<td><?= h($rawCustomerName) ?></td>
<td dir="ltr"><?= h($displayPhone !== '' ? $displayPhone : '-') ?></td>
<td><?= h(branch_label((string)$sale['branch_code'])) ?></td>
<td class="text-end fw-bold text-danger"><?= h(currency((float)$sale['total_amount'])) ?></td>
<td class="d-print-none text-end">

View File

@ -156,6 +156,7 @@ require __DIR__ . '/includes/header.php';
<th><?= h(tr('النوع', 'Type')) ?></th>
<th><?= h(tr('الكاشير', 'Cashier')) ?></th>
<th><?= h(tr('العميل', 'Customer')) ?></th>
<th><?= h(tr('الهاتف', 'Phone')) ?></th>
<th><?= h(tr('المجموع', 'Subtotal')) ?></th>
<th><?= h(tr('الضريبة', 'VAT')) ?></th>
<th><?= h(tr('الإجمالي', 'Total')) ?></th>
@ -177,7 +178,27 @@ require __DIR__ . '/includes/header.php';
<td><?= h(branch_label((string) $sale['branch_code'])) ?></td>
<td><span class="badge text-bg-light border"><?= h(sale_mode_label((string) $sale['sale_mode'])) ?></span></td>
<td><?= h((string) $sale['cashier_name']) ?></td>
<td><?= h((string) ($sale['customer_name'] ?: '-')) ?></td>
<?php
$rawCustomerName = (string) ($sale['customer_name'] ?: '-');
$displayPhone = '';
if (str_contains($rawCustomerName, ' - ')) {
$parts = explode(' - ', $rawCustomerName);
$lastPart = trim(end($parts));
if (preg_match('/^[0-9+\s]+$/', $lastPart)) {
$displayPhone = $lastPart;
array_pop($parts);
$rawCustomerName = trim(implode(' - ', $parts));
}
}
$displayPhone = ltrim(preg_replace('/[^0-9]/', '', $displayPhone), '0');
if ($displayPhone !== '') {
if (str_starts_with($displayPhone, '968') && strlen($displayPhone) > 8) {
$displayPhone = substr($displayPhone, 3);
}
}
?>
<td><?= h($rawCustomerName) ?></td>
<td dir="ltr"><?= h($displayPhone ?: '-') ?></td>
<td class="text-muted"><?= h(currency((float) $sale['total_amount'] - (float) ($sale['vat_amount'] ?? 0))) ?></td>
<td class="text-muted text-danger"><?= h(currency((float) $sale['vat_amount'])) ?></td>
<td class="fw-bold text-success"><?= h(currency((float) $sale['total_amount'])) ?></td>