File indexing completed on 2025-05-04 05:29:33
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 * 0023 * Created: 31.07.2017 0024 */ 0025 0026 class Statistics_Model_Data 0027 { 0028 0029 const DEFAULT_STORE_ID = 22; //opendesktop 0030 0031 /** @var Zend_Db_Adapter_Pdo_Abstract */ 0032 protected $_db; 0033 0034 public function __construct($options) 0035 { 0036 if (isset($options['db'])) { 0037 $this->initDbAdapter($options['db']); 0038 } else { 0039 throw new Exception('configuration parameter for database connection needed'); 0040 } 0041 } 0042 0043 private function initDbAdapter($db) 0044 { 0045 $adapter = $db['adapter']; 0046 $params = $db['params']; 0047 //$default = (int)(isset($params['isDefaultTableAdapter']) && $params['isDefaultTableAdapter'] 0048 // || isset($params['default']) && $params['default']); 0049 unset($params['adapter'], $params['default'], $params['isDefaultTableAdapter']); 0050 $adapter = Zend_Db::factory($adapter, $params); 0051 $this->_db = $adapter; 0052 } 0053 0054 0055 0056 0057 public function getPayoutgroupbyamountProduct() 0058 { 0059 $sql = "select gm as x 0060 , count(1) as y 0061 from 0062 ( 0063 select 0064 m.project_id, 0065 round(sum(m.credits_plings)/100,2) AS probably_payout_amount, 0066 floor(sum(m.credits_plings/100)/10)*10 gm 0067 from micro_payout m 0068 where m.paypal_mail is not null and m.paypal_mail <> '' and (m.paypal_mail regexp '^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$') 0069 and m.yearmonth = DATE_FORMAT(CURRENT_DATE() - INTERVAL 4 MONTH, '%Y%m') and m.is_license_missing = 0 and m.is_source_missing=0 and m.is_pling_excluded = 0 0070 and m.is_member_pling_excluded=0 0071 GROUP BY m.project_id 0072 ) t 0073 where t.probably_payout_amount >1 0074 group by gm 0075 order by gm asc 0076 "; 0077 $result = $this->_db->fetchAll($sql); 0078 return $result; 0079 } 0080 0081 0082 public function getPayoutgroupbyamountMember() 0083 { 0084 $sql = "select gm as x 0085 , count(1) as y 0086 from 0087 ( 0088 select 0089 m.member_id, 0090 round(sum(m.credits_plings)/100,2) AS probably_payout_amount, 0091 floor(sum(m.credits_plings/100)/10)*10 gm 0092 from micro_payout m 0093 where m.paypal_mail is not null and m.paypal_mail <> '' and (m.paypal_mail regexp '^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$') 0094 and m.yearmonth = DATE_FORMAT(CURRENT_DATE() - INTERVAL 4 MONTH, '%Y%m') and m.is_license_missing = 0 and m.is_source_missing=0 and m.is_pling_excluded = 0 0095 and m.is_member_pling_excluded=0 0096 GROUP BY m.member_id 0097 ) t 0098 where t.probably_payout_amount >1 0099 group by gm 0100 order by gm asc 0101 "; 0102 $result = $this->_db->fetchAll($sql); 0103 return $result; 0104 } 0105 0106 public function getNewmemberstats() 0107 { 0108 $sql = "SELECT DATE(`created_at`) as memberdate , count(*) as daycount FROM dwh.ods_member_v group by memberdate order by memberdate desc limit 30"; 0109 $result = $this->_db->fetchAll($sql); 0110 return $result; 0111 } 0112 0113 public function getNewprojectstats() 0114 { 0115 $sql = "SELECT DATE(`created_at`) as projectdate , count(*) as daycount FROM dwh.ods_project_v where status>=40 group by projectdate order by projectdate desc limit 30"; 0116 $result = $this->_db->fetchAll($sql); 0117 return $result; 0118 } 0119 0120 public function getNewprojectWeeklystats() 0121 { 0122 $sql = "SELECT YEARWEEK(`created_at`) as yyyykw , count(*) as amount 0123 FROM project p 0124 join stat_cat_tree t on p.project_category_id = t.project_category_id 0125 where status=100 and type_id = 1 0126 group by yyyykw 0127 order by yyyykw 0128 desc limit 60"; 0129 $result = $this->_db->fetchAll($sql); 0130 return $result; 0131 } 0132 public function getNewprojectWeeklystatsWithoutWallpapers() 0133 { 0134 0135 $tmpsql = "select lft, rgt from stat_cat_tree where project_category_id=295"; 0136 $wal = $this->_db->fetchRow($tmpsql); 0137 $lft = $wal['lft']; 0138 $rgt = $wal['rgt']; 0139 0140 $sql = "SELECT YEARWEEK(`created_at`) as yyyykw , count(*) as amount 0141 FROM project p 0142 join stat_cat_tree t on p.project_category_id = t.project_category_id 0143 where status=100 and type_id = 1 0144 and (t.lft<" . $lft . " or t.rgt>" . $rgt . " ) 0145 group by yyyykw 0146 order by yyyykw 0147 desc limit 60"; 0148 $result = $this->_db->fetchAll($sql); 0149 return $result; 0150 } 0151 0152 public function getNewprojectWeeklystatsWallpapers() 0153 { 0154 0155 $tmpsql = "select lft, rgt from stat_cat_tree where project_category_id=295"; 0156 $wal = $this->_db->fetchRow($tmpsql); 0157 $lft = $wal['lft']; 0158 $rgt = $wal['rgt']; 0159 0160 $sql = "SELECT YEARWEEK(`created_at`) as yyyykw , count(*) as amount 0161 FROM project p 0162 join stat_cat_tree t on p.project_category_id = t.project_category_id 0163 where status=100 and type_id = 1 0164 and (t.lft>" . $lft . " and t.rgt<" . $rgt . " ) 0165 group by yyyykw 0166 order by yyyykw 0167 desc limit 60"; 0168 $result = $this->_db->fetchAll($sql); 0169 return $result; 0170 } 0171 0172 public function getPayout($yyyymm) 0173 { 0174 0175 $sql = "SELECT * , 0176 (select username from member m where m.member_id = p.member_id) username 0177 FROM dwh.member_payout p where yearmonth = :yyyymm order by amount desc"; 0178 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm)); 0179 return $result; 0180 } 0181 0182 public function getPayoutMemberPerCategory($yyyymm, $catid) 0183 { 0184 0185 $modelProjectCategories = new Default_Model_DbTable_ProjectCategory(); 0186 $ids = $modelProjectCategories->fetchChildIds($catid); 0187 array_push($ids, $catid); 0188 $idstring = implode(',', $ids); 0189 0190 $sql = " 0191 select * from 0192 ( 0193 select 0194 member_id 0195 ,(select username from member m where m.member_id = v.member_id) username 0196 ,round(sum(probably_payout_amount)) as amount 0197 from member_dl_plings_v as v 0198 where project_category_id IN (" . $idstring . ") and v.yearmonth= :yyyymm 0199 group by v.member_id 0200 order by amount desc 0201 ) tmp where amount>0 0202 "; 0203 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm)); 0204 return $result; 0205 } 0206 0207 public function getNewcomer($yyyymm) 0208 { 0209 $yyyymm_vor = $this->getLastYearMonth($yyyymm); 0210 $sql = "SELECT member_id 0211 , (select username from member m where m.member_id = member_payout.member_id) as username 0212 , paypal_mail,round(amount,2) as amount FROM member_payout WHERE yearmonth =:yyyymm 0213 and member_id not in (select member_id from member_payout where yearmonth =:yyyymm_vor) 0214 order by amount desc 0215 "; 0216 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm, "yyyymm_vor" => $yyyymm_vor)); 0217 return $result; 0218 } 0219 0220 public function getNewloser($yyyymm) 0221 { 0222 $yyyymm_vor = $this->getLastYearMonth($yyyymm); 0223 $sql = "SELECT member_id 0224 , (select username from member m where m.member_id = member_payout.member_id) as username 0225 , paypal_mail,round(amount,2) as amount FROM member_payout WHERE yearmonth =:yyyymm_vor 0226 and member_id not in (select member_id from member_payout where yearmonth =:yyyymm) 0227 order by amount desc 0228 "; 0229 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm, "yyyymm_vor" => $yyyymm_vor)); 0230 return $result; 0231 } 0232 0233 public function getMonthDiff($yyyymm) 0234 { 0235 $yyyymm_vor = $this->getLastYearMonth($yyyymm); 0236 $sql = " 0237 select akt.member_id 0238 , (select username from member m where m.member_id = akt.member_id) as username 0239 , akt.amount as am_akt 0240 , let.amount as am_let 0241 , round(akt.amount-let.amount) as am_diff 0242 , akt.yearmonth ym_akt 0243 , let.yearmonth ym_let 0244 from 0245 (select member_id, amount,yearmonth from member_payout where yearmonth = :yyyymm) akt, 0246 (select member_id, amount,yearmonth from member_payout where yearmonth = :yyyymm_vor) let 0247 where akt.member_id = let.member_id 0248 order by am_diff desc 0249 "; 0250 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm, "yyyymm_vor" => $yyyymm_vor)); 0251 0252 return $result; 0253 } 0254 0255 /* 0256 public function getDownloadsDaily($numofmonthback){ 0257 $sql = " 0258 select 0259 SUBSTR(d.date_yyyymmdd,1,6) as symbol 0260 ,SUBSTR(d.date_yyyymmdd,7,8)*1 as date 0261 ,d.count as price 0262 from dwh.files_downloads_daily as d 0263 where STR_TO_DATE(date_yyyymmdd,'%Y%m%d' ) >= (DATE_FORMAT(CURDATE(), '%Y-%m-01')- INTERVAL :numofmonthback MONTH) 0264 and STR_TO_DATE(date_yyyymmdd,'%Y%m%d' )< CURDATE() 0265 order by date_yyyymmdd asc 0266 "; 0267 $result = $this->_db->fetchAll($sql,array("numofmonthback"=>$numofmonthback)); 0268 return $result; 0269 } 0270 */ 0271 0272 public function getDownloadsDaily($numofmonthback) 0273 { 0274 $sql = " 0275 select 0276 SUBSTR(d.date_yyyymmdd,1,6) as symbol 0277 ,SUBSTR(d.date_yyyymmdd,7,8)*1 as date 0278 ,d.count as price 0279 from dwh.files_downloads_daily as d 0280 where STR_TO_DATE(date_yyyymmdd,'%Y%m%d' ) >= (DATE_FORMAT(CURDATE(), '%Y-%m-01')- INTERVAL :numofmonthback MONTH) 0281 and STR_TO_DATE(date_yyyymmdd,'%Y%m%d' )< CURDATE() 0282 union 0283 0284 select 0285 concat(SUBSTR(d.date_yyyymmdd,1,6),' payout') as symbol 0286 ,SUBSTR(d.date_yyyymmdd,7,8)*1 as date 0287 ,d.count as price 0288 from dwh.payout_daily as d 0289 where STR_TO_DATE(date_yyyymmdd,'%Y%m%d' ) >= (DATE_FORMAT(CURDATE(), '%Y-%m-01')- INTERVAL :numofmonthback MONTH) 0290 and STR_TO_DATE(date_yyyymmdd,'%Y%m%d' )< CURDATE() 0291 0292 "; 0293 $result = $this->_db->fetchAll($sql, array("numofmonthback" => $numofmonthback)); 0294 return $result; 0295 } 0296 0297 public function getDownloadsUndPayoutsDaily($yyyymm) 0298 { 0299 $sql = " 0300 select 0301 concat(SUBSTR(d.date_yyyymmdd,1,6),' downloads') as symbol 0302 ,SUBSTR(d.date_yyyymmdd,7,8)*1 as date 0303 ,d.count as price 0304 from dwh.files_downloads_daily as d 0305 where SUBSTR(d.date_yyyymmdd,1,6)=:yyyymm 0306 union 0307 select 0308 concat(SUBSTR(d.date_yyyymmdd,1,6),' payouts') as symbol 0309 ,SUBSTR(d.date_yyyymmdd,7,8)*1 as date 0310 ,d.count as price 0311 from dwh.payout_daily as d 0312 where SUBSTR(d.date_yyyymmdd,1,6)=:yyyymm 0313 0314 "; 0315 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm)); 0316 return $result; 0317 } 0318 0319 0320 /** 0321 ,(select count(1) from dwh.files_downloads dd where dd.project_id = d.project_id 0322 and dd.downloaded_timestamp between :date_start and :date_end 0323 and dd.referer like 'https://www.google%') as cntGoogle 0324 */ 0325 0326 public function getTopDownloadsPerDate($date) 0327 { 0328 $date_start = $date . ' 00:00:00'; 0329 $date_end = $date . ' 23:59:59'; 0330 $sql = " 0331 select d.project_id 0332 , count(1) as cnt 0333 ,(select p.title from project p where p.project_id = d.project_id) as ptitle 0334 ,(select p.created_at from project p where p.project_id = d.project_id) as pcreated_at 0335 ,(select c.title from category c, project p where p.project_id = d.project_id and p.project_category_id=c.project_category_id) as ctitle 0336 ,(select username from member m , project p where m.member_id = p.member_id and p.project_id = d.project_id) as username 0337 from dwh.files_downloads d 0338 where d.downloaded_timestamp between :date_start and :date_end 0339 group by d.project_id 0340 order by cnt desc 0341 limit 50 0342 "; 0343 0344 $result = $this->_db->fetchAll($sql, array("date_start" => $date_start, "date_end" => $date_end)); 0345 return $result; 0346 } 0347 0348 public function getTopDownloadsPerMonth($month, $catid) 0349 { 0350 0351 $sd = $month . '-01'; 0352 $date_start = date('Y-m-01', strtotime($sd)) . ' 00:00:00'; 0353 $date_end = date('Y-m-t', strtotime($sd)) . ' 23:59:59'; 0354 0355 if ($catid == 0) { 0356 0357 // $sql = " 0358 // select d.project_id 0359 // , count(1) as cnt 0360 // ,(select p.title from project p where p.project_id = d.project_id) as ptitle 0361 // ,(select p.created_at from project p where p.project_id = d.project_id) as pcreated_at 0362 // ,(select c.title from category c where d.project_category_id=c.project_category_id) as ctitle 0363 // ,(select username from member m where m.member_id = d.member_id) as username 0364 // from dwh.files_downloads d 0365 // where d.yyyymm = :month 0366 // group by d.project_id,project_category_id,member_id 0367 // order by cnt desc 0368 // limit 50 0369 // "; 0370 $sql = "select d.project_id 0371 , sum(d.count) as cnt 0372 ,p.title as ptitle 0373 ,p.created_at as pcreated_at 0374 ,(select c.title from category c where d.project_category_id=c.project_category_id) as ctitle 0375 ,(select username from member m where m.member_id = p.member_id) as username 0376 from dwh.files_downloads_project_daily d 0377 join project p on d.project_id = p.project_id 0378 where d.yyyymm = :month 0379 group by d.project_id,d.project_category_id,p.member_id 0380 order by cnt desc 0381 limit 50"; 0382 } else { 0383 $modelProjectCategories = new Default_Model_DbTable_ProjectCategory(); 0384 $ids = $modelProjectCategories->fetchChildIds($catid); 0385 array_push($ids, $catid); 0386 $idstring = implode(',', $ids); 0387 // $sql = ' 0388 // select d.project_id 0389 // , count(1) as cnt 0390 // ,(select p.title from project p where p.project_id = d.project_id) as ptitle 0391 // ,(select p.created_at from project p where p.project_id = d.project_id) as pcreated_at 0392 // ,(select c.title from category c where d.project_category_id=c.project_category_id) as ctitle 0393 // ,(select username from member m where m.member_id = d.member_id) as username 0394 // from dwh.files_downloads d 0395 // where d.yyyymm = :month 0396 // and d.project_category_id in ('.$idstring.') 0397 // group by d.project_id,project_category_id,member_id 0398 // order by cnt desc 0399 // limit 50 0400 // '; 0401 $sql = 'select d.project_id 0402 , sum(d.count) as cnt 0403 ,p.title as ptitle 0404 ,p.created_at as pcreated_at 0405 ,(select c.title from category c where d.project_category_id=c.project_category_id) as ctitle 0406 ,(select username from member m where m.member_id = p.member_id) as username 0407 from dwh.files_downloads_project_daily d 0408 join project p on d.project_id = p.project_id 0409 where d.yyyymm = :month 0410 and d.project_category_id in (' . $idstring . ') 0411 group by d.project_id,d.project_category_id,p.member_id 0412 order by cnt desc 0413 limit 50'; 0414 } 0415 0416 $result = $this->_db->fetchAll($sql, array("month" => $month)); 0417 return $result; 0418 } 0419 0420 public function getProductMonthly($project_id) 0421 { 0422 $sql = " 0423 select 0424 yyyymm as yearmonth 0425 ,sum(count) as amount 0426 from dwh.files_downloads_project_daily 0427 where project_id = :project_id 0428 group by yyyymm 0429 limit 100 0430 "; 0431 $result = $this->_db->fetchAll($sql, array("project_id" => $project_id)); 0432 return $result; 0433 } 0434 0435 public function getProductDayly($project_id) 0436 { 0437 $sql = " 0438 select yyyymmdd as yearmonth,count as amount 0439 from dwh.files_downloads_project_daily 0440 where project_id = :project_id 0441 order by yyyymmdd desc 0442 limit 1000 0443 "; 0444 $result = $this->_db->fetchAll($sql, array("project_id" => $project_id)); 0445 return array_reverse($result); 0446 } 0447 0448 0449 public function getDownloadsDomainStati($begin, $end) 0450 { 0451 $date_start = $begin . ' 00:00:00'; 0452 $date_end = $end . ' 23:59:59'; 0453 $sql = " 0454 select count(1) as cnt 0455 ,d.referer_domain 0456 ,is_from_own_domain 0457 from dwh.files_downloads d 0458 where d.downloaded_timestamp between :date_start and :date_end 0459 group by d.referer_domain,is_from_own_domain 0460 order by is_from_own_domain desc, cnt desc 0461 "; 0462 $result = $this->_db->fetchAll($sql, array("date_start" => $date_start, "date_end" => $date_end)); 0463 return $result; 0464 } 0465 0466 0467 public function getPayoutCategoryMonthly($yyyymm) 0468 { 0469 $sql = " 0470 select * from 0471 ( 0472 select project_category_id 0473 ,(select title from category as c where c.project_category_id = v.project_category_id) as title 0474 ,round(sum(probably_payout_amount)) as amount 0475 ,sum(v.num_downloads) as num_downloads 0476 from member_dl_plings_v as v 0477 where yearmonth =:yyyymm 0478 group by v.project_category_id 0479 order by amount desc 0480 ) tmp where amount>0 0481 "; 0482 $result = $this->_db->fetchAll($sql, array("yyyymm" => $yyyymm)); 0483 return $result; 0484 } 0485 0486 0487 0488 private function getPayoutCategorySingle($catid) 0489 { 0490 0491 $modelProjectCategories = new Default_Model_DbTable_ProjectCategory(); 0492 $ids = $modelProjectCategories->fetchChildIds($catid); 0493 array_push($ids, $catid); 0494 $idstring = implode(',', $ids); 0495 // Zend_Registry::get('logger')->info(__METHOD__ . ' - ===================================' ); 0496 // Zend_Registry::get('logger')->info(__METHOD__ . ' - ' . $idstring); 0497 $sql = " 0498 select * from 0499 ( 0500 select 0501 yearmonth 0502 ,(select title from category as c where c.project_category_id = " . $catid . ") as symbol 0503 ,round(sum(probably_payout_amount)) as amount 0504 from member_dl_plings_v as v 0505 where project_category_id IN (" . $idstring . ") 0506 group by v.yearmonth 0507 order by yearmonth asc 0508 ) tmp where amount>0 0509 "; 0510 $result = $this->_db->fetchAll($sql); 0511 return $result; 0512 } 0513 0514 public function getPayoutCategory_($catid) 0515 { 0516 0517 if ($catid == 0) { 0518 $pids = array(152, 233, 158, 148, 491, 445, 295); 0519 $sql = " 0520 select * from 0521 ( 0522 select 0523 'All' as symbol 0524 ,yearmonth 0525 ,round(sum(probably_payout_amount)) as amount 0526 from member_dl_plings_v as v 0527 group by v.yearmonth 0528 order by yearmonth asc 0529 ) tmp where amount>0 0530 "; 0531 $result = $this->_db->fetchAll($sql); 0532 foreach ($pids as $catid) { 0533 $t = self::getPayoutCategorySingle($catid); 0534 $result = array_merge($result, $t); 0535 } 0536 } else { 0537 $result = self::getPayoutCategorySingle($catid); 0538 } 0539 0540 return $result; 0541 } 0542 0543 public function getPayoutCategory($catid) 0544 { 0545 0546 if ($catid == 0) { 0547 // $pids = array(152, 233,158,404, 148,491,445,295); 0548 $modelCategoryStore = new Default_Model_DbTable_ConfigStoreCategory(); 0549 $pids = $modelCategoryStore->fetchCatIdsForStore(self::DEFAULT_STORE_ID); 0550 $sql = " 0551 select * from 0552 ( 0553 select 0554 'All' as symbol 0555 ,yearmonth 0556 ,round(sum(probably_payout_amount)) as amount 0557 from member_dl_plings_v as v 0558 group by v.yearmonth 0559 order by yearmonth asc 0560 ) tmp where amount>0 0561 "; 0562 $result = $this->_db->fetchAll($sql); 0563 foreach ($pids as $c) { 0564 $tmp = self::getPayoutCategorySingle($c); 0565 foreach ($result as &$row) { 0566 $row['amount' . $c] = 0; 0567 foreach ($tmp as $t) { 0568 if ($t['yearmonth'] == $row['yearmonth']) { 0569 $row['amount' . $c] = $t['amount']; 0570 break; 0571 } 0572 } 0573 } 0574 } 0575 } else { 0576 $result = self::getPayoutCategorySingle($catid); 0577 $modelCategoriesTable = new Default_Model_DbTable_ProjectCategory(); 0578 $pids = $modelCategoriesTable->fetchImmediateChildrenIds($catid); 0579 foreach ($pids as $c) { 0580 $tmp = self::getPayoutCategorySingle($c); 0581 foreach ($result as &$row) { 0582 $row['amount' . $c] = 0; 0583 foreach ($tmp as $t) { 0584 if ($t['yearmonth'] == $row['yearmonth']) { 0585 $row['amount' . $c] = $t['amount']; 0586 break; 0587 } 0588 } 0589 } 0590 } 0591 } 0592 0593 return $result; 0594 } 0595 0596 public function _getPayoutCategory($catid) 0597 { 0598 0599 if ($catid == 0) { 0600 $pids = array(152, 233, 158, 404, 148, 491, 445, 295); 0601 $sql = " 0602 select * from 0603 ( 0604 select 0605 'All' as symbol 0606 ,yearmonth 0607 ,round(sum(probably_payout_amount)) as amount 0608 from member_dl_plings_v as v 0609 group by v.yearmonth 0610 order by yearmonth asc 0611 ) tmp where amount>0 0612 "; 0613 $result = $this->_db->fetchAll($sql); 0614 foreach ($pids as $c) { 0615 $tmp = self::getPayoutCategorySingle($c); 0616 foreach ($result as &$row) { 0617 $row['amount' . $c] = 0; 0618 foreach ($tmp as $t) { 0619 if ($t['yearmonth'] == $row['yearmonth']) { 0620 $row['amount' . $c] = $t['amount']; 0621 break; 0622 } 0623 } 0624 } 0625 } 0626 } else { 0627 $result = self::getPayoutCategorySingle($catid); 0628 } 0629 0630 return $result; 0631 } 0632 0633 0634 public function getLastYearMonth($yyyymm) 0635 { 0636 $aktdate = strval($yyyymm) . '01'; 0637 $fmt = 'Ymd'; 0638 $d = DateTime::createFromFormat($fmt, $aktdate); 0639 $d->modify('last day of previous month'); 0640 return $d->format('Ym'); 0641 } 0642 0643 public function getPayoutyear() 0644 { 0645 $sql = "select round(sum(amount)) amount,yearmonth from dwh.member_payout group by yearmonth order by yearmonth"; 0646 $result = $this->_db->fetchAll($sql); 0647 return $result; 0648 } 0649 0650 0651 public function getPayoutOfMember($member_id) 0652 { 0653 //$sql = "select yearmonth, amount from dwh.member_payout where member_id = :member_id order by yearmonth asc"; 0654 $sql = "select yearmonth, amount from dwh.member_payout where member_id = :member_id order by yearmonth asc"; 0655 $result = $this->_db->fetchAll($sql, array("member_id" => $member_id)); 0656 return $result; 0657 } 0658 0659 public function getProject($project_id) 0660 { 0661 $sql = "SELECT * FROM ods_project_v WHERE project_id = :projectId"; 0662 $result = $this->_db->fetchAll($sql, array('projectId' => $project_id)); 0663 return $result; 0664 } 0665 0666 public function getProjects($limit = 50) 0667 { 0668 $limit = (int) $limit; 0669 $sql = "SELECT * FROM ods_project_v LIMIT {$limit}"; 0670 $result = $this->_db->fetchAll($sql); 0671 return $result; 0672 } 0673 0674 public function getMember($member_id) 0675 { 0676 $sql = "SELECT * FROM ods_member_v WHERE member_id = :memberId"; 0677 $result = $this->_db->fetchAll($sql, array('memberId' => (int) $member_id)); 0678 return $result; 0679 } 0680 0681 0682 public function getMembers($limit = 50) 0683 { 0684 $sql = "SELECT * FROM ods_member_v"; 0685 $sql = $this->_db->limit($sql, (int) $limit); 0686 $result = $this->_db->fetchAll($sql); 0687 return $result; 0688 } 0689 }