dashboard.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace MGModule\DNSManager2\controllers\addon\admin;
  3. use \MGModule\DNSManager2 as main;
  4. use \MGModule\DNSManager2\mgLibs\custom\AjaxResponse;
  5. use \MGModule\DNSManager2\models\custom\notification;
  6. use \MGModule\DNSManager2\models\custom\zone;
  7. use MGModule\DNSManager2\models\custom\notification\helpers\RowFormatter;
  8. class dashboard extends main\mgLibs\process\abstractController{
  9. public function indexJSON($input, $vars = array()) {
  10. return AjaxResponse::I()->refreshPage($this->indexHTML($input, $vars))->toArray();
  11. }
  12. function indexHTML($input, $vars = array()){
  13. $vars['zones_used'] = zone\Repository::factory()->getServersZonesUsed();
  14. $vars['email_zone_created'] = notification\Repository::factory()->byName(notification\NotificationNameEnum::ZONE_CREATED_EMAIL)->count();
  15. $vars['email_zone_edited'] = notification\Repository::factory()->byName(notification\NotificationNameEnum::ZONE_EDITED_EMAIL)->count();
  16. $vars['email_zone_removed'] = notification\Repository::factory()->byName(notification\NotificationNameEnum::ZONED_REMOVED_EMAIL)->count();
  17. $vars['tutorial'] = main\models\custom\globalsetting\GlobalSetting::byKey(main\models\custom\globalsetting\GlobalSettingEnum::TUTORIAL_DISABLED)!='on'?true:false;
  18. return array(
  19. 'tpl' => 'main'
  20. ,'vars' => $vars
  21. );
  22. }
  23. function refreshNotificationTableJSON($input, $vars = array()) {
  24. $notifications = new notification\Repository();
  25. $helper = new main\mgLibs\custom\RepoTableHelper($notifications, $input);
  26. $vars = $helper->getDataTableArray();
  27. foreach($helper->get() as $notification)
  28. {
  29. //$notification = RowFormatter::format($notification);
  30. $vars['data'][] = $this->dataTablesParseRow('notification-row', ['notification' => $notification]);
  31. }
  32. return $vars;
  33. }
  34. function disableTutorialJSON($input, $vars = array()) {
  35. main\models\custom\globalsetting\GlobalSetting::set(main\models\custom\globalsetting\GlobalSettingEnum::TUTORIAL_DISABLED, 'on');
  36. return AjaxResponse::I()->refreshPage($this->indexHTML($input))->toArray();
  37. }
  38. }