Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 301 Rev 302
Línea 94... Línea 94...
94
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
94
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
Línea 95... Línea 95...
95
 
95
 
Línea 96... Línea 96...
96
                $queryMapper = QueryMapper::getInstance($this->adapter);
96
                $queryMapper = QueryMapper::getInstance($this->adapter);
97
 
97
 
98
                $select = $queryMapper->getSql()->select();
98
                $select = $queryMapper->getSql()->select();
99
                $select->columns(['uuid','status','user_id']);
99
                $select->columns(['uuid', 'status', 'user_id']);
100
                $select->from(['test' => CompanySelfEvaluationTestMapper::_TABLE]);
100
                $select->from(['test' => CompanySelfEvaluationTestMapper::_TABLE]);
Línea 101... Línea 101...
101
                $select->join(['form' => CompanySelfEvaluationFormMapper::_TABLE], 'test.form_id = form.id', ['name','language']);
101
                $select->join(['form' => CompanySelfEvaluationFormMapper::_TABLE], 'test.form_id = form.id', ['name', 'language']);
102
                $select->join(['user' => UserMapper::_TABLE], 'test.user_id = user.id', ['first_name','last_name'], Select::JOIN_LEFT_OUTER);
102
                $select->join(['user' => UserMapper::_TABLE], 'test.user_id = user.id', ['first_name', 'last_name'], Select::JOIN_LEFT_OUTER);
Línea -... Línea 103...
-
 
103
 
-
 
104
                $select->where->equalTo('form.status', CompanySelfEvaluationForm::STATUS_ACTIVE);
103
 
105
                $select->where->notEqualTo('test.status', CompanySelfEvaluationTest::STATUS_DRAFT);
104
                $select->where->equalTo('form.status', CompanySelfEvaluationForm::STATUS_ACTIVE);
106
 
105
                $select->where->notEqualTo('test.status', CompanySelfEvaluationTest::STATUS_DRAFT);
107
 
106
 
108
                //Search items
107
                if ($search) {
109
                if ($search) {
108
                    $select->where->NEST->like('name', '%' . $search . '%')
110
                    $select->where->NEST->like('name', '%' . $search . '%')
109
                    ->OR
111
                                    ->OR
110
                    ->like('first_name', '%' . $search . '%')
-
 
111
                    ->OR
112
                                    ->like('first_name', '%' . $search . '%')
112
                    ->like('last_name', '%' . $search . '%')
113
                                    ->OR
Línea 113... Línea 114...
113
->UNNEST;
114
                                    ->like('last_name', '%' . $search . '%')
114
                
115
                            ->UNNEST;
Línea 133... Línea 134...
133
                            break;
134
                            break;
134
                    }
135
                    }
Línea 135... Línea 136...
135
 
136
 
Línea 136... Línea -...
136
                    switch ($record['status']) {
-
 
137
 
137
                    switch ($record['status']) {
138
            
138
 
139
                        case CompanySelfEvaluationTest::STATUS_COMPLETED :
139
                        case CompanySelfEvaluationTest::STATUS_COMPLETED :
Línea 140... Línea 140...
140
                            $status = 'LABEL_COMPLETED';
140
                            $status = 'LABEL_COMPLETED';
Línea 152... Línea 152...
152
                        default :
152
                        default :
153
                            $status = 'LABEL_AVAILABLE';
153
                            $status = 'LABEL_AVAILABLE';
154
                            break;
154
                            break;
155
                    }
155
                    }
Línea 156... Línea -...
156
 
-
 
157
 
156
 
158
                    $item = [
157
                    $item = [
159
                        'name' => $record['name'],
158
                        'name' => $record['name'],
160
                        'user' => $record['first_name'].' '.$record['last_name'],
159
                        'user' => $record['first_name'] . ' ' . $record['last_name'],
161
                        'language' => $language,
160
                        'language' => $language,
162
                        'status' => $status,
161
                        'status' => $status,
163
                        'link_edit' => $this->url()->fromRoute('self-evaluation/reviews/edit', ['id' => $record['uuid']]),
162
                        'link_edit' => $this->url()->fromRoute('self-evaluation/reviews/edit', ['id' => $record['uuid']]),
Línea 164... Línea 163...
164
                    ];
163
                    ];
165
 
164
 
Línea 166... Línea -...
166
                    array_push($items, $item);
-
 
167
                }
-
 
168
 
165
                    array_push($items, $item);
169
            
166
                }
170
 
167
 
171
                return new JsonModel([
168
                return new JsonModel([
172
                    'success' => true,
169
                    'success' => true,
Línea 191... Línea 188...
191
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
188
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
192
            ]);
189
            ]);
193
            ;
190
            ;
194
        }
191
        }
195
    }
192
    }
196
    
193
 
197
    public function editAction() {
194
    public function editAction() {
198
        $request = $this->getRequest();
195
        $request = $this->getRequest();
199
        $currentUserPlugin = $this->plugin('currentUserPlugin');
196
        $currentUserPlugin = $this->plugin('currentUserPlugin');
200
        $currentCompany = $currentUserPlugin->getCompany();
197
        $currentCompany = $currentUserPlugin->getCompany();
201
        $currentUser = $currentUserPlugin->getUser();
198
        $currentUser = $currentUserPlugin->getUser();
Línea 211... Línea 208...
211
            ];
208
            ];
Línea 212... Línea 209...
212
 
209
 
213
            return new JsonModel($data);
210
            return new JsonModel($data);
Línea 214... Línea 211...
214
        }
211
        }
215
 
212
 
216
        $companySelfEvaluationMapper = CompanySelfEvaluationFormMapper::getInstance($this->adapter);
213
        $companySelfEvaluationTestMapper = CompanySelfEvaluationTestMapper::getInstance($this->adapter);
217
        $companySelfEvaluation = $companySelfEvaluationMapper->fetchOneByUuid($uuid);
214
        $testMapper = $companySelfEvaluationTestMapper->fetchOneByUuid($uuid);
218
        if (!$companySelfEvaluation) {
215
        if (!$testMapper) {
219
            $data = [
216
            $data = [
220
                'success' => false,
217
                'success' => false,
Línea 221... Línea 218...
221
                'data' => 'ERROR_RECORD_NOT_FOUND'
218
                'data' => 'ERROR_RECORD_NOT_FOUND'
222
            ];
219
            ];
Línea 223... Línea -...
223
 
-
 
224
            return new JsonModel($data);
-
 
225
        }
-
 
226
 
-
 
227
        if ($companySelfEvaluation->company_id != $currentCompany->id) {
-
 
228
            return new JsonModel([
-
 
Línea 229... Línea 220...
229
                'success' => false,
220
 
230
                'data' => 'ERROR_UNAUTHORIZED'
221
            return new JsonModel($data);
231
            ]);
222
        }
Línea 247... Línea 238...
247
 
238
 
248
                if (!$companySelfEvaluation->status) {
239
                if (!$companySelfEvaluation->status) {
249
                    $companySelfEvaluation->status = CompanySelfEvaluationForm::STATUS_INACTIVE;
240
                    $companySelfEvaluation->status = CompanySelfEvaluationForm::STATUS_INACTIVE;
Línea 250... Línea 241...
250
                }
241
                }
Línea 251... Línea 242...
251
 
242
 
252
                $result = $companySelfEvaluationMapper->update($companySelfEvaluation);
243
                $result = $companySelfEvaluationTestMapper->update($companySelfEvaluation);
253
 
244
 
254
                if ($result) {
245
                if ($result) {
Línea 260... Línea 251...
260
                        'data' => 'LABEL_RECORD_UPDATED'
251
                        'data' => 'LABEL_RECORD_UPDATED'
261
                    ];
252
                    ];
262
                } else {
253
                } else {
263
                    $data = [
254
                    $data = [
264
                        'success' => false,
255
                        'success' => false,
265
                        'data' => $companySelfEvaluationMapper->getError()
256
                        'data' => $companySelfEvaluationTestMapper->getError()
266
                    ];
257
                    ];
267
                }
258
                }
Línea 268... Línea 259...
268
 
259
 
269
                return new JsonModel($data);
260
                return new JsonModel($data);
Línea 283... Línea 274...
283
            $hydrator = new ObjectPropertyHydrator();
274
            $hydrator = new ObjectPropertyHydrator();
Línea 284... Línea 275...
284
 
275
 
285
            $data = [
276
            $data = [
286
                'success' => true,
277
                'success' => true,
287
                'data' => [
278
                'data' => [
288
                    'id' => $companySelfEvaluation->uuid,
-
 
289
                    'name' => $companySelfEvaluation->name,
-
 
290
                    'description' => $companySelfEvaluation->description,
-
 
291
                    'text' => $companySelfEvaluation->text,
-
 
292
                    'language' => $companySelfEvaluation->language,
279
                    'id' => $testMapper->uuid,
293
                    'status' => $companySelfEvaluation->status,
280
                    'status' => $testMapper->status,
294
                    'content' => $companySelfEvaluation->content ? json_decode($companySelfEvaluation->content) : [],
281
                    'content' => json_decode($testMapper->content),
295
                ]
282
                ]
Línea 296... Línea 283...
296
            ];
283
            ];
297
 
284
 
Línea 306... Línea 293...
306
        }
293
        }
Línea 307... Línea 294...
307
 
294
 
308
        return new JsonModel($data);
295
        return new JsonModel($data);
Línea 309... Línea -...
309
    }
-
 
310
 
-
 
311
 
296
    }