فهرست منبع

Monthly calculation on server index

1day2die 2 سال پیش
والد
کامیت
9da53bd02f
2فایلهای تغییر یافته به همراه25 افزوده شده و 4 حذف شده
  1. 20 2
      app/Models/Product.php
  2. 5 2
      themes/default/views/servers/index.blade.php

+ 20 - 2
app/Models/Product.php

@@ -64,9 +64,27 @@ class Product extends Model
         }
         }
     }
     }
 
 
-    public function getDailyPrice()
+    public function getMonthlyPrice()
     {
     {
-        return $this->price / 30;
+        // calculate the hourly price with the billing period
+        switch($this->billing_period) {
+            case 'hourly':
+                return $this->price * 24 * 30;
+            case 'daily':
+                return $this->price * 30;
+            case 'weekly':
+                return $this->price * 4;
+            case 'monthly':
+                return $this->price;
+            case 'quarterly':
+                return $this->price / 3;
+            case 'half-annually':
+                return $this->price / 6;
+            case 'annually':
+                return $this->price / 12;
+            default:
+                return $this->price;
+        }
     }
     }
 
 
     public function getWeeklyPrice()
     public function getWeeklyPrice()

+ 5 - 2
themes/default/views/servers/index.blade.php

@@ -62,8 +62,8 @@
                                         </a>
                                         </a>
                                         <div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
                                         <div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
                                             aria-labelledby="dropdownMenuLink">
                                             aria-labelledby="dropdownMenuLink">
-                                            @if (!empty(config('SETTINGS::MISC:PHPMYADMIN:URL')))
-                                                <a href="{{ config('SETTINGS::MISC:PHPMYADMIN:URL') }}"
+                                            @if (!empty($phpmyadmin_url)))
+                                                <a href="{{ $phpmyadmin_url }}"
                                                     class="dropdown-item text-info" target="__blank"><i title="manage"
                                                     class="dropdown-item text-info" target="__blank"><i title="manage"
                                                         class="fas fa-database mr-2"></i><span>{{ __('Database') }}</span></a>
                                                         class="fas fa-database mr-2"></i><span>{{ __('Database') }}</span></a>
                                             @endif
                                             @endif
@@ -194,6 +194,9 @@
                                         @elseif($server->product->billing_period == 'hourly')
                                         @elseif($server->product->billing_period == 'hourly')
                                             {{ __('per Hour') }}
                                             {{ __('per Hour') }}
                                         @endif
                                         @endif
+                                            <i data-toggle="popover" data-trigger="hover"
+                                               data-content="{{ __('Your') ." " . $credits_display_name . " ". __('are reduced') ." ". $server->product->billing_period . ". " . __("This however calculates to ") . number_format($server->product->getMonthlyPrice(),2,",",".") . " ". $credits_display_name . " ". __('per Month')}}"
+                                               class="fas fa-info-circle"></i>
                                             </div>
                                             </div>
                                         <span>
                                         <span>
                                             {{ $server->product->price == round($server->product->price) ? round($server->product->price) : $server->product->price }}
                                             {{ $server->product->price == round($server->product->price) ? round($server->product->price) : $server->product->price }}