Example #1
0
 public function __construct($organisationId)
 {
     parent::__construct($organisationId);
     $this->bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId);
     $this->bandwidthMonth = ModelActivity::getBandwidthByDate($organisationId, date('01-m-Y'));
     $this->bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId);
     $this->bandwidthToday = ModelActivity::getBandwidthByDate($organisationId, Date::toDate());
     $this->bandwidthMonth = ModelActivity::getBandwidthByDate($organisationId, date('01-m-Y'));
     $this->bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId);
     $this->masterImagesToday = ModelActivity::getMasterImagesBydate($organisationId, Date::toDate());
     $this->masterImagesMonth = ModelActivity::getMasterImagesBydate($organisationId, date('01-m-Y'));
     $this->masterImagesTotal = ModelActivity::getMasterImagesBydate($organisationId);
     $this->rendersToday = ModelActivity::getRendersByDate($organisationId, Date::toDate());
     $this->rendersMonth = ModelActivity::getRendersByDate($organisationId, date('01-m-Y'), date('01-m-Y'));
     $this->rendersTotal = ModelActivity::getRendersByDate($organisationId);
     if ($this->isPostBack()) {
         $action = strtolower($this->input('action'));
         if ($action === 'delete') {
             $this->organisation->deleted = !$this->organisation->deleted;
         }
         if ($action === 'disable') {
             $this->organisation->disabled = !$this->organisation->disabled;
         }
         $this->organisation->update();
         $this->setMessage(lang('Organisation updated'), 'success');
         response()->refresh();
     }
 }
 public function index()
 {
     $organisationId = request()->organisation->id;
     $bandwidthToday = ModelActivity::getBandwidthByDate($organisationId, Date::toDate());
     $bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId);
     $masterImagesToday = ModelActivity::getMasterImagesBydate($organisationId, Date::toDate());
     $masterImagesTotal = ModelActivity::getMasterImagesBydate($organisationId);
     $rendersToday = ModelActivity::getRendersByDate($organisationId, Date::toDate());
     $rendersTotal = ModelActivity::getRendersByDate($organisationId);
     response()->json(['bandwidth_today' => $bandwidthToday, 'bandwidth_total' => $bandwidthTotal, 'masterimages_today' => $masterImagesToday, 'masterimages_total' => $masterImagesTotal, 'renders_today' => $rendersToday, 'renders_total' => $rendersTotal]);
 }
Example #3
0
function calculatePrices(\NinjaImg\Model\ModelOrganisation $organisation)
{
    $firstDayPreviousMonth = date('01-m-y', strtotime('-1 month'));
    $lastDayPreviousMonth = date('t-m-y', strtotime('-1 month'));
    $masterImages = \NinjaImg\Model\ModelActivity::getMasterImagesByDate($organisation->id, $firstDayPreviousMonth, $lastDayPreviousMonth);
    $bandwidth = \NinjaImg\Model\ModelActivity::getBandwidthByDate($organisation->id, $firstDayPreviousMonth, $lastDayPreviousMonth);
    $masterImages = $masterImages ? (int) $masterImages : 0;
    $bandwidth = $bandwidth ? (int) $bandwidth : 0;
    $masterImagesPrice = (double) \NinjaImg\Model\ModelSettings::getInstance()->getPriceMasterImage() * $masterImages;
    $bandwidthPrice = (double) \NinjaImg\Model\ModelSettings::getInstance()->getPriceBandwidthGB() / 1024 * $bandwidth;
    return number_format($masterImagesPrice + $bandwidthPrice, 2);
}
Example #4
0
 protected function getTotalBandwidth()
 {
     $total = ModelActivity::getTotalBandwidth($this->organisationId, $this->startDate, $this->endDate, $this->sourceId, $this->masterImagesOnly);
     $name = 'KB';
     if ($total > 1024) {
         $total = $total / 1024;
         $name = 'MB';
         if ($total > 1024) {
             $total = $total / 1024;
             $name = 'GB';
             if ($total > 1024) {
                 $total = $total / 1024;
                 $name = 'TB';
             }
         }
     }
     return number_format($total, 2) . $name;
 }
Example #5
0
 public function getBandwidth()
 {
     return ModelActivity::getBandwidthByDate($this->organisation->id, $this->startDate, $this->endDate);
 }