Commit 69da9aa2 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fixed payment

parent fd764d71
......@@ -15,17 +15,41 @@
</div>
</div>
<?php
$totalIn = '0.00';
$totalOut = '0.00';
foreach ($movements as $m) {
if (($m['direction'] ?? '') === 'in') $totalIn = bcadd($totalIn, $m['amount'] ?? '0', 2);
else $totalOut = bcadd($totalOut, $m['amount'] ?? '0', 2);
}
$net = bcsub($totalIn, $totalOut, 2);
?>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;margin-bottom:20px;">
<div class="card" style="padding:15px;text-align:center;border-right:4px solid #059669;">
<div style="font-size:13px;color:#6B7280;">إجمالي الوارد</div>
<div style="font-size:22px;font-weight:700;color:#059669;"><?= money($totalIn) ?></div>
</div>
<div class="card" style="padding:15px;text-align:center;border-right:4px solid #DC2626;">
<div style="font-size:13px;color:#6B7280;">إجمالي الصادر</div>
<div style="font-size:22px;font-weight:700;color:#DC2626;"><?= money($totalOut) ?></div>
</div>
<div class="card" style="padding:15px;text-align:center;border-right:4px solid #0D7377;">
<div style="font-size:13px;color:#6B7280;">صافي الحركة</div>
<div style="font-size:22px;font-weight:700;color:#0D7377;"><?= money($net) ?></div>
</div>
</div>
<div class="card">
<div class="card-header"><h3 style="margin:0;font-size:16px;">حركات <?= e($date) ?></h3></div>
<div class="card-header"><h3 style="margin:0;font-size:16px;">حركات <?= e($date) ?> (<?= count($movements) ?> حركة)</h3></div>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>الحساب البنكي / الخزينة</th>
<th>البيان</th>
<th>النوع</th>
<th>وارد</th>
<th>صادر</th>
<th>الرصيد</th>
<th>ملاحظات</th>
<th>المرجع</th>
</tr>
</thead>
<tbody>
......@@ -33,12 +57,16 @@
<tr><td colspan="5" style="text-align:center;color:#6B7280;">لا توجد حركات في هذا التاريخ</td></tr>
<?php else: ?>
<?php foreach ($movements as $m): ?>
<?php
$isIn = ($m['direction'] ?? '') === 'in';
$typeLabels = ['sale' => 'مبيعات', 'collection' => 'تحصيل', 'disbursement' => 'صرف'];
?>
<tr>
<td><?= e($m['description'] ?? '—') ?></td>
<td style="color:#059669;"><?= number_format((float)($m['cash_in'] ?? 0), 2) ?></td>
<td style="color:#DC2626;"><?= number_format((float)($m['cash_out'] ?? 0), 2) ?></td>
<td style="font-weight:600;"><?= number_format((float)($m['balance'] ?? 0), 2) ?></td>
<td style="font-size:12px;color:#6B7280;"><?= e($m['notes'] ?? '') ?></td>
<td><span style="background:<?= $isIn ? '#D1FAE5' : '#FEE2E2' ?>;color:<?= $isIn ? '#065F46' : '#991B1B' ?>;padding:2px 8px;border-radius:10px;font-size:11px;"><?= e($typeLabels[$m['movement_type'] ?? ''] ?? ($m['movement_type'] ?? '—')) ?></span></td>
<td style="color:#059669;font-weight:600;"><?= $isIn ? money($m['amount'] ?? '0') : '—' ?></td>
<td style="color:#DC2626;font-weight:600;"><?= !$isIn ? money($m['amount'] ?? '0') : '—' ?></td>
<td style="font-size:12px;color:#6B7280;"><?= e(($m['reference_type'] ?? '') . ($m['reference_id'] ? ' #' . $m['reference_id'] : '')) ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
......
<?php
declare(strict_types=1);
return [
'up' => "
ALTER TABLE `daily_cash_movements` ADD COLUMN `movement_type` VARCHAR(50) NULL AFTER `movement_date`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `direction` ENUM('in','out') NULL AFTER `movement_type`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `direction`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `description` VARCHAR(500) NULL AFTER `amount`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `reference_type` VARCHAR(100) NULL AFTER `description`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `reference_id` INT UNSIGNED NULL AFTER `reference_type`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `uk_date_bank`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `uk_date_safe`;
ALTER TABLE `daily_cash_movements` ADD INDEX `idx_movement_date` (`movement_date`);
ALTER TABLE `daily_cash_movements` ADD INDEX `idx_movement_type` (`movement_type`);
ALTER TABLE `daily_cash_movements` ADD INDEX `idx_direction` (`direction`)",
'down' => "
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `idx_direction`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `idx_movement_type`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `idx_movement_date`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `reference_id`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `reference_type`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `description`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `amount`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `direction`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `movement_type`;
ALTER TABLE `daily_cash_movements` ADD UNIQUE KEY `uk_date_bank` (`movement_date`, `bank_account_id`);
ALTER TABLE `daily_cash_movements` ADD UNIQUE KEY `uk_date_safe` (`movement_date`, `safe_id`)",
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment