File indexing completed on 2024-12-22 05:33:57

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  *
0022  * Created: 31.07.2017
0023  */
0024 
0025 class Statistics_DataController extends Zend_Controller_Action
0026 {
0027 
0028     /** @var  Zend_Config */
0029     protected $db_config;
0030 
0031     public function init()
0032     {
0033         $contextSwitch = $this->_helper->getHelper('contextSwitch');
0034         $contextSwitch->setDefaultContext('json');
0035         $this->db_config = Zend_Registry::get('config')->settings->dwh;
0036     }
0037 
0038     public function projectAction()
0039     {
0040         $modelData = new Statistics_Model_Data($this->db_config->toArray());
0041         $id = (int) $this->getParam('p');
0042         try {
0043             $result = $modelData->getProject($id);
0044         } catch (Exception $e) {
0045             Zend_Registry::get('logger')->error($e->getMessage());
0046             return $this->_helper->json->sendJson(array(
0047                 'status' => 'error',
0048                 'msg' => 'error while processing request',
0049                 'data' => ''
0050             ));
0051         }
0052         if ($result) {
0053             $msg = array(
0054                 'status' => 'ok',
0055                 'msg' => '',
0056                 'data' => $result
0057             );
0058             return $this->_helper->json->sendJson($msg);
0059         }
0060         return $this->_helper->json->sendJson(array(
0061             'status' => 'not found',
0062             'msg' => 'data with given id could not be found.',
0063             'data' => ''
0064         ));
0065     }
0066 
0067     public function projectsAction()
0068     {
0069         /*
0070         $modelData = new Statistics_Model_Data($this->db_config->toArray());
0071         $limit = (int) $this->getParam('l');
0072         try {
0073             $result = $modelData->getProjects($limit);
0074         } catch (Exception $e) {
0075             Zend_Registry::get('logger')->error($e->getMessage());
0076             return $this->_helper->json->sendJson(array(
0077                 'status' => 'error',
0078                 'msg' => 'error while processing request',
0079                 'data' => ''
0080             ));
0081         }
0082         if ($result) {
0083             $msg = array(
0084                 'status' => 'ok',
0085                 'msg' => '',
0086                 'data' => $result
0087             );
0088             return $this->_helper->json->sendJson($msg);
0089         }
0090         return $this->_helper->json->sendJson(array(
0091             'status' => 'not found',
0092             'msg' => 'data with given id could not be found.',
0093             'data' => ''
0094         ));
0095         */
0096         $result = array();
0097         $result[] = array('memberdate'=>'07-26', 'daycount'=>'88');
0098         $result[] = array('memberdate'=>'07-27', 'daycount'=>'84');
0099         $result[] = array('memberdate'=>'07-28', 'daycount'=>'101');
0100         $result[] = array('memberdate'=>'07-29', 'daycount'=>'96');
0101         $result[] = array('memberdate'=>'07-30', 'daycount'=>'66');
0102         $result[] = array('memberdate'=>'07-31', 'daycount'=>'110');
0103         $result[] = array('memberdate'=>'08-01', 'daycount'=>'90');
0104         $result[] = array('memberdate'=>'08-02', 'daycount'=>'81');
0105         $result[] = array('memberdate'=>'08-03', 'daycount'=>'81');
0106         $result[] = array('memberdate'=>'08-04', 'daycount'=>'85');
0107         $result[] = array('memberdate'=>'08-05', 'daycount'=>'72');
0108         $result[] = array('memberdate'=>'08-06', 'daycount'=>'61');
0109         $result[] = array('memberdate'=>'08-07', 'daycount'=>'64');
0110         $result[] = array('memberdate'=>'08-08', 'daycount'=>'84');   
0111         $result[] = array('memberdate'=>'08-09', 'daycount'=>'81');      
0112         $result[] = array('memberdate'=>'08-10', 'daycount'=>'86');   
0113         $result[] = array('memberdate'=>'08-11', 'daycount'=>'86');   
0114         $result[] = array('memberdate'=>'08-12', 'daycount'=>'82');   
0115         $result[] = array('memberdate'=>'08-13', 'daycount'=>'64');   
0116         
0117         return $this->_helper->json->sendJson($result);
0118     }
0119 
0120     public function memberAction()
0121     {
0122         $result = array();
0123         $result[] = array("projectdate"=>"July 26th","daycount"=>"29");
0124         $result[] = array("projectdate"=>"July 27th","daycount"=>"34");
0125         $result[] = array("projectdate"=>"July 28th","daycount"=>"32");
0126         $result[] = array("projectdate"=>"July 29th","daycount"=>"26");
0127         $result[] = array("projectdate"=>"July 30th","daycount"=>"13");
0128         $result[] = array("projectdate"=>"July 31st","daycount"=>"33");
0129         $result[] = array("projectdate"=>"August 1st","daycount"=>"25");
0130         $result[] = array("projectdate"=>"August 2nd","daycount"=>"30");
0131         $result[] = array("projectdate"=>"August 3rd","daycount"=>"31");
0132         $result[] = array("projectdate"=>"August 4th","daycount"=>"31");
0133         $result[] = array("projectdate"=>"August 5th","daycount"=>"22");
0134         $result[] = array("projectdate"=>"August 6th","daycount"=>"12");
0135         $result[] = array("projectdate"=>"August 7th","daycount"=>"13");
0136         $result[] = array("projectdate"=>"August 8th","daycount"=>"35");   
0137         $result[] = array("projectdate"=>"August 9th","daycount"=>"31");      
0138         $result[] = array("projectdate"=>"August 10th","daycount"=>"25");     
0139         $result[] = array("projectdate"=>"August 11th","daycount"=>"43");     
0140         $result[] = array("projectdate"=>"August 12th","daycount"=>"26");     
0141         $result[] = array("projectdate"=>"August 13th","daycount"=>"15");     
0142       
0143         return $this->_helper->json->sendJson($result);
0144 
0145         /*
0146         $modelData = new Statistics_Model_Data($this->db_config->toArray());
0147         $id = (int) $this->getParam('m');
0148         try {
0149             $result = $modelData->getMember($id);
0150         } catch (Exception $e) {
0151             Zend_Registry::get('logger')->error($e->getMessage());
0152             return $this->_helper->json->sendJson(array(
0153                 'status' => 'error',
0154                 'msg' => 'error while processing request',
0155                 'data' => ''
0156             ));
0157         }
0158         if ($result) {
0159             $msg = array(
0160                 'status' => 'ok',
0161                 'msg' => '',
0162                 'data' => $result
0163             );
0164             return $this->_helper->json->sendJson($msg);
0165         }
0166         return $this->_helper->json->sendJson(array(
0167             'status' => 'not found',
0168             'msg' => 'data with given id could not be found.',
0169             'data' => ''
0170         ));
0171         */
0172     }
0173 
0174     public function membersAction()
0175     {
0176         $modelData = new Statistics_Model_Data($this->db_config->toArray());
0177         $limit = (int) $this->getParam('l');
0178         try {
0179             $result = $modelData->getMembers($limit);
0180         } catch (Exception $e) {
0181             Zend_Registry::get('logger')->error($e->getMessage());
0182             return $this->_helper->json->sendJson(array(
0183                 'status' => 'error',
0184                 'msg' => 'error while processing request',
0185                 'data' => ''
0186             ));
0187         }
0188         if ($result) {
0189             $msg = array(
0190                 'status' => 'ok',
0191                 'msg' => '',
0192                 'data' => $result
0193             );
0194             return $this->_helper->json->sendJson($msg);
0195         }
0196         return $this->_helper->json->sendJson(array(
0197             'status' => 'not found',
0198             'msg' => 'data with given id could not be found.',
0199             'data' => ''
0200         ));
0201     }
0202 
0203     public function newprojectsstatAction()
0204     {
0205         // last two year for example
0206             $result=array(100,200,50,60,80,70,100,200,50,60,80,70);
0207            $msg = array(
0208                 'status' => 'ok',
0209                 'msg' => '',
0210                 'data' => $result
0211             );
0212             return $this->_helper->json->sendJson($msg);
0213     }
0214 }