Jelajahi Sumber

fleat: status

igb 3 minggu lalu
induk
melakukan
5039aae58b
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      statistics_customers.php

+ 4 - 4
statistics_customers.php

@@ -347,12 +347,12 @@ function renderNewVsReturningCustomersChart($new_vs_returning) {
                 <div class="stat-item">
                     <span class="stat-label">新客户:</span>
                     <span class="stat-value"><?php echo number_format($new_vs_returning['new_customers']); ?> 
-                    (<?php echo number_format(($new_vs_returning['new_customers'] / $new_vs_returning['total_customers']) * 100, 1); ?>%)</span>
+                    (<?php echo ($new_vs_returning['total_customers'] > 0) ? number_format(($new_vs_returning['new_customers'] / $new_vs_returning['total_customers']) * 100, 1) : '0'; ?>%)</span>
                 </div>
                 <div class="stat-item">
                     <span class="stat-label">老客户:</span>
                     <span class="stat-value"><?php echo number_format($new_vs_returning['returning_customers']); ?> 
-                    (<?php echo number_format(($new_vs_returning['returning_customers'] / $new_vs_returning['total_customers']) * 100, 1); ?>%)</span>
+                    (<?php echo ($new_vs_returning['total_customers'] > 0) ? number_format(($new_vs_returning['returning_customers'] / $new_vs_returning['total_customers']) * 100, 1) : '0'; ?>%)</span>
                 </div>
             </div>
             <div class="stats-row">
@@ -363,12 +363,12 @@ function renderNewVsReturningCustomersChart($new_vs_returning) {
                 <div class="stat-item">
                     <span class="stat-label">新客户销售额:</span>
                     <span class="stat-value">¥<?php echo number_format($new_vs_returning['new_customer_amount'], 2); ?> 
-                    (<?php echo number_format(($new_vs_returning['new_customer_amount'] / $new_vs_returning['total_amount']) * 100, 1); ?>%)</span>
+                    (<?php echo ($new_vs_returning['total_amount'] > 0) ? number_format(($new_vs_returning['new_customer_amount'] / $new_vs_returning['total_amount']) * 100, 1) : '0'; ?>%)</span>
                 </div>
                 <div class="stat-item">
                     <span class="stat-label">老客户销售额:</span>
                     <span class="stat-value">¥<?php echo number_format($new_vs_returning['returning_customer_amount'], 2); ?> 
-                    (<?php echo number_format(($new_vs_returning['returning_customer_amount'] / $new_vs_returning['total_amount']) * 100, 1); ?>%)</span>
+                    (<?php echo ($new_vs_returning['total_amount'] > 0) ? number_format(($new_vs_returning['returning_customer_amount'] / $new_vs_returning['total_amount']) * 100, 1) : '0'; ?>%)</span>
                 </div>
             </div>
         </div>