Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16129 | Rev 16301 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16129 Rev 16130
Línea 84... Línea 84...
84
 
84
 
85
        $companyMapper = CompanyMapper::getInstance($this->adapter);
85
        $companyMapper = CompanyMapper::getInstance($this->adapter);
Línea 86... Línea 86...
86
        $company = $companyMapper->fetchDefaultForNetworkByNetworkId($currentNetwork->id);
86
        $company = $companyMapper->fetchDefaultForNetworkByNetworkId($currentNetwork->id);
87
 
87
 
Línea 88... Línea 88...
88
        $request = $this->getRequest();
88
        $request = $this->getRequest();
Línea 89... Línea 89...
89
        //if ($request->isGet()) {
89
        if ($request->isGet()) {
90
 
90
 
91
        $headers  = $request->getHeaders();
91
            $headers  = $request->getHeaders();
Línea 92... Línea 92...
92
 
92
 
Línea 93... Línea 93...
93
        $isJson = false;
93
            $isJson = false;
94
        if ($headers->has('Accept')) {
94
            if ($headers->has('Accept')) {
Línea 95... Línea 95...
95
            $accept = $headers->get('Accept');
95
                $accept = $headers->get('Accept');
96
 
96
 
-
 
97
                $prioritized = $accept->getPrioritized();
97
            $prioritized = $accept->getPrioritized();
98
 
98
 
99
                foreach ($prioritized as $key => $value) {
99
            foreach ($prioritized as $key => $value) {
-
 
Línea 100... Línea 100...
100
                $raw = trim($value->getRaw());
100
                    $raw = trim($value->getRaw());
Línea 101... Línea 101...
101
 
101
 
102
                if (!$isJson) {
102
                    if (!$isJson) {
103
                    $isJson = strpos($raw, 'json');
103
                        $isJson = strpos($raw, 'json');
104
                }
104
                    }
Línea 105... Línea 105...
105
            }
105
                }
106
        }
106
            }
107
 
107
 
108
 
108
 
Línea 109... Línea 109...
109
        //if ($isJson) {
109
            if ($isJson) {
110
 
110
 
Línea 111... Línea 111...
111
        $startDate = $this->params()->fromQuery('startDate');
111
                $startDate = $this->params()->fromQuery('startDate');
112
        if (empty($startDate)) {
112
                if (empty($startDate)) {
Línea 113... Línea 113...
113
            $startDate = date('Y-m-d');
113
                    $startDate = date('Y-m-d');
114
        }
114
                }
115
 
115
 
116
 
116
 
-
 
117
                $endDate = $this->params()->fromQuery('endDate');
-
 
118
                if (empty($endDate)) {
-
 
119
                    $endDate = date('Y-m-d');
-
 
120
                }
-
 
121
 
-
 
122
                $startDate = '2023-03-01';
Línea 117... Línea 123...
117
        $endDate = $this->params()->fromQuery('endDate');
123
                $endDate = '2023-03-19';
118
        if (empty($endDate)) {
124
 
119
            $endDate = date('Y-m-d');
-
 
120
        }
-
 
121
 
-
 
Línea 122... Línea -...
122
        $startDate = '2023-03-01';
-
 
123
        $endDate = '2023-03-19';
125
                $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
Línea 124... Línea -...
124
 
-
 
Línea -... Línea 126...
-
 
126
                $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
127
 
-
 
128
                if (!$dtStartDate || !$dtEndDate) {
-
 
129
                    $startDate = date('Y-m-d');
-
 
130
                    $endDate = date('Y-m-d');
-
 
131
                } else {
-
 
132
 
-
 
133
                    if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
134
                        $startDate = date('Y-m-d');
-
 
135
                        $endDate = date('Y-m-d');
-
 
136
                    }
-
 
137
                }
-
 
138
 
-
 
139
                $dailyPulseRecordMapper = DailyPulseRecordMapper::getInstance($this->adapter);
-
 
140
                $how_are_you_feel = $dailyPulseRecordMapper->fetchAllDataChartOrExcelByCompanyIdAndTypeAndDateRange($company->id, DailyPulseRecord::TYPE_HOW_ARE_YOU_FEEL, $startDate, $endDate);
-
 
141
 
-
 
142
                $climate_on_your_organization = $dailyPulseRecordMapper->fetchAllDataChartOrExcelByCompanyIdAndTypeAndDateRange($company->id, DailyPulseRecord::TYPE_CLIMATE_ON_YOUR_ORGANIZATION, $startDate, $endDate);
-
 
143
 
-
 
144
 
-
 
145
 
-
 
146
                $data = [
-
 
147
                    'labels'             => [],
Línea 125... Línea -...
125
        $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
-
 
126
        $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
127
 
-
 
128
        if (!$dtStartDate || !$dtEndDate) {
-
 
129
            $startDate = date('Y-m-d');
-
 
130
            $endDate = date('Y-m-d');
-
 
131
        } else {
-
 
132
 
-
 
133
            if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
134
                $startDate = date('Y-m-d');
-
 
135
                $endDate = date('Y-m-d');
-
 
136
            }
-
 
137
        }
-
 
138
 
-
 
139
        $dailyPulseRecordMapper = DailyPulseRecordMapper::getInstance($this->adapter);
-
 
140
        $how_are_you_feel = $dailyPulseRecordMapper->fetchAllDataChartOrExcelByCompanyIdAndTypeAndDateRange($company->id, DailyPulseRecord::TYPE_HOW_ARE_YOU_FEEL, $startDate, $endDate);
-
 
141
 
-
 
142
        $climate_on_your_organization = $dailyPulseRecordMapper->fetchAllDataChartOrExcelByCompanyIdAndTypeAndDateRange($company->id, DailyPulseRecord::TYPE_CLIMATE_ON_YOUR_ORGANIZATION, $startDate, $endDate);
-
 
143
 
-
 
144
 
-
 
145
 
-
 
146
        $data = [
-
 
Línea -... Línea 148...
-
 
148
                    'users' => [
Línea 147... Línea -...
147
            'labels'             => [],
-
 
Línea -... Línea 149...
-
 
149
                        'how_are_you_feel' => [],
-
 
150
                        'climate_on_your_organization' => [],
Línea 148... Línea 151...
148
            'users' => [
151
                    ],
149
                'how_are_you_feel' => [],
152
                    'points' => [
Línea 150... Línea -...
150
                'climate_on_your_organization' => [],
-
 
151
            ],
153
                        'how_are_you_feel' => [],
Línea 152... Línea -...
152
            'points' => [
-
 
Línea -... Línea 154...
-
 
154
                        'climate_on_your_organization' => [],
-
 
155
                    ],
-
 
156
                    'average' => [
-
 
157
                        'how_are_you_feel' => [],
-
 
158
                        'climate_on_your_organization' => [],
Línea 153... Línea -...
153
                'how_are_you_feel' => [],
-
 
154
                'climate_on_your_organization' => [],
-
 
155
            ],
-
 
156
            'average' => [
159
                    ],
157
                'how_are_you_feel' => [],
-
 
Línea 158... Línea -...
158
                'climate_on_your_organization' => [],
-
 
Línea -... Línea 160...
-
 
160
                    'how_are_you_feel' => [
-
 
161
                        'average_points'     => 0,
-
 
162
                        'average_users'      => 0,
-
 
163
                    ],
-
 
164
                    'climate_on_your_organization' => [
-
 
165
                        'average_points'    => 0,
-
 
166
                        'average_users'     => 0,
-
 
167
                    ]
Línea 159... Línea -...
159
            ],
-
 
160
            'how_are_you_feel' => [
-
 
161
                'average_points'     => 0,
-
 
162
                'average_users'      => 0,
-
 
163
            ],
-
 
164
            'climate_on_your_organization' => [
-
 
165
                'average_points'    => 0,
-
 
166
                'average_users'     => 0,
-
 
Línea -... Línea 168...
-
 
168
 
-
 
169
 
-
 
170
                ];
Línea 167... Línea -...
167
            ]
-
 
168
 
-
 
169
 
-
 
Línea -... Línea 171...
-
 
171
 
-
 
172
 
Línea 170... Línea -...
170
        ];
-
 
171
 
-
 
172
 
-
 
173
 
173
 
174
        $how_are_you_feel_points = 0;
174
                $how_are_you_feel_points = 0;
175
        $how_are_you_feel_users = 0;
175
                $how_are_you_feel_users = 0;
176
 
176
 
177
        $climate_on_your_organization_points = 0;
177
                $climate_on_your_organization_points = 0;
178
        $climate_on_your_organization_users = 0;
178
                $climate_on_your_organization_users = 0;
179
 
179
 
180
        $count = 0;
180
                $count = 0;
Línea 181... Línea 181...
181
 
181
 
182
 
182
 
183
        $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
183
                $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
Línea 184... Línea 184...
184
        do {
184
                do {
185
            $count++;
185
                    $count++;
Línea 186... Línea 186...
186
            $date = $dt->format('Y-m-d');
186
                    $date = $dt->format('Y-m-d');
187
            $label = $dt->format('d/m/Y');
187
                    $label = $dt->format('d/m/Y');
Línea 188... Línea 188...
188
 
188
 
189
            array_push($data['labels'], $label);
189
                    array_push($data['labels'], $label);
Línea 190... Línea 190...
190
 
190
 
191
 
191
 
Línea 192... Línea 192...
192
            $points = 0;
192
                    $points = 0;
193
            $users = 0;
193
                    $users = 0;
194
            foreach ($how_are_you_feel as $record) {
194
                    foreach ($how_are_you_feel as $record) {
195
                if ($date == $record['date']) {
195
                        if ($date == $record['date']) {
196
                    $points = $record['points'];
196
                            $points = $record['points'];
197
                    $users = $record['users'];
197
                            $users = $record['users'];
198
                }
198
                        }
199
            }
199
                    }
200
 
200
 
201
 
201
 
202
 
202
 
Línea 203... Línea 203...
203
            array_push($data['points']['how_are_you_feel'], $points);
203
                    array_push($data['points']['how_are_you_feel'], $points);
204
            array_push($data['users']['how_are_you_feel'], $users);
204
                    array_push($data['users']['how_are_you_feel'], $users);
205
            array_push($data['average']['how_are_you_feel'], $users ?  $points / $users : 0);
205
                    array_push($data['average']['how_are_you_feel'], $users ?  $points / $users : 0);
206
 
206
 
207
 
207
 
208
            $how_are_you_feel_points += $points;
208
                    $how_are_you_feel_points += $points;
Línea 209... Línea 209...
209
            $how_are_you_feel_users += $users;
209
                    $how_are_you_feel_users += $users;
210
 
210
 
211
            $points = 0;
211
                    $points = 0;