コード例 #1
0
ファイル: core.php プロジェクト: carriercomm/Nuance
 public function getData()
 {
     global $mysqlTimeDateFormat, $sessionId;
     $data = array("total" => 0, "scratchcard" => 0, "adminpay" => array("total" => 0, "byadmin" => array()));
     $masterTable = new table('master');
     $master = $masterTable->loadById($sessionId);
     $permittedCities = $master['city'];
     $permittedStreets = $master['street'];
     $permittedGroups = $master['usergroup'];
     $admins = $masterTable->load();
     for ($i = 0; $i < count($admins); $i++) {
         $data['adminpay']['byadmin'][$admins[$i]['id']] = 0;
     }
     $currentTime = new DateTime();
     $moneyflowTable = new table('moneyflow');
     $startDate = clone $this->month;
     $endDate = clone $this->month;
     $endDate->modify('1 month');
     $endDate->modify('-1 second');
     $offsetDays = configgetvalue('system', 'statistics', null, 'paymentsOffset');
     $startDate->modify($offsetDays . ' day');
     $endDate->modify($offsetDays . ' day');
     $condition = "WHERE `date`>='" . $startDate->format($mysqlTimeDateFormat) . "' AND `date`<='" . $endDate->format($mysqlTimeDateFormat) . "' AND (`detailsname`='adminpay' OR `detailsname`='scratchcard') AND `sum`>0";
     if (pluginExists('grouprestrict') && $permittedGroups) {
         $condition .= " AND ( `user` IN (SELECT `id` FROM `user` WHERE `usergroup` IN (" . join($permittedGroups, ",") . ") ) )";
     }
     $rows = $moneyflowTable->load($condition);
     foreach ($rows as $row) {
         $sum = $row['sum'];
         $data['total'] += $sum;
         if ($row['detailsname'] === 'adminpay') {
             $data['adminpay']['total'] += $sum;
             if (!isset($data['adminpay']['byadmin'][$row['detailsid']])) {
                 $data['adminpay']['byadmin'][$row['detailsid']] = 0;
             }
             $data['adminpay']['byadmin'][$row['detailsid']] += $sum;
         } else {
             $data['scratchcard'] += $sum;
         }
     }
     $lastRow = end($rows);
     configsetvalue('var', 'cache', null, 'int', $this->fileName, $lastRow['id']);
     return json_encode($data);
 }
コード例 #2
0
ファイル: ajax.php プロジェクト: carriercomm/Nuance
     $type = $_GET['type'];
     if (checkPermission($sessionId, array('preference', $type)) || $type === 'user') {
         switch ($type) {
             case 'system':
                 $ownerid = 0;
                 break;
             case 'user':
                 $ownerid = $sessionId;
                 break;
             case 'router':
             case 'subscriber':
                 $ownerid = $_GET['ownerid'];
                 break;
         }
         $vartype = isset($_POST['vartype']) ? $_POST['vartype'] : 'string';
         configsetvalue($type, $_POST['path'], $ownerid, $vartype, $_POST['name'], $_POST['value']);
         $response->data = array($type => array($ownerid => array($_POST['path'] => array($_POST['name'] => $_POST['value']))));
         $response->success = true;
     }
     break;
 case 'addtranslationline':
     appendtranslation($_GET['line']);
     $response->success = true;
     break;
 case 'gettimezone':
     $tzlist = array();
     $assocTzlist = array();
     $regions = array('Africa' => DateTimeZone::AFRICA, 'America' => DateTimeZone::AMERICA, 'Antarctica' => DateTimeZone::ANTARCTICA, 'Asia' => DateTimeZone::ASIA, 'Atlantic' => DateTimeZone::ATLANTIC, 'Australia' => DateTimeZone::AUSTRALIA, 'Europe' => DateTimeZone::EUROPE, 'Indian' => DateTimeZone::INDIAN, 'Pacific' => DateTimeZone::PACIFIC);
     foreach ($regions as $name => $mask) {
         $tzlist = array_merge($tzlist, DateTimeZone::listIdentifiers($mask));
     }