Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1660 | Rev 3471 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
647 efrain 1
<?php
2
declare(strict_types=1);
3
 
4
namespace LeadersLinked\Mapper;
5
 
6
use LeadersLinked\Mapper\Common\MapperCommon;
7
use Laminas\Db\Adapter\AdapterInterface;
1265 eleazar 8
use LeadersLinked\Model\RecruitmentSelectionCandidate;
852 eleazar 9
use LeadersLinked\Model\RecruitmentSelectionVacancy;
1092 eleazar 10
use LeadersLinked\Model\RecruitmentSelectionInterview;
647 efrain 11
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
12
use Laminas\Paginator\Paginator;
13
use Laminas\Db\ResultSet\HydratingResultSet;
14
use Laminas\Paginator\Adapter\DbSelect;
15
 
16
 
17
class RecruitmentSelectionInterviewMapper extends MapperCommon
18
{
19
    const _TABLE = 'tbl_recruitment_selection_candidate_interviews';
20
 
21
    /**
22
     *
23
     * @var RecruitmentInterviewMapper
24
     */
25
    private static $_instance;
26
 
27
    /**
28
     *
29
     * @param AdapterInterface $adapter
30
     */
31
    private function __construct($adapter)
32
    {
33
        parent::__construct($adapter);
34
    }
35
 
36
    /**
37
     *
38
     * @param AdapterInterface $adapter
39
     * @return RecruitmentSelectionInterviewMapper
40
     */
41
    public static function getInstance($adapter)
42
    {
43
        if(self::$_instance == null) {
1065 eleazar 44
            self::$_instance = new RecruitmentSelectionInterviewMapper($adapter);
647 efrain 45
        }
46
        return self::$_instance;
47
    }
48
 
49
    /**
50
     *
51
     * @param int $id
1065 eleazar 52
     * @return RecruitmentSelectionInterview
647 efrain 53
     */
54
    public function fetchOne($id)
55
    {
1065 eleazar 56
        $prototype = new RecruitmentSelectionInterview();
647 efrain 57
 
58
        $select = $this->sql->select(self::_TABLE);
59
        $select->where->equalTo('id', $id);
60
 
61
        return $this->executeFetchOneObject($select, $prototype);
62
    }
63
 
64
 
65
    /**
66
     *
67
     * @param int $uuid
1065 eleazar 68
     * @return RecruitmentSelectionInterview
647 efrain 69
     */
70
    public function fetchOneByUuid($uuid)
71
    {
1065 eleazar 72
        $prototype = new RecruitmentSelectionInterview();
647 efrain 73
        $select = $this->sql->select(self::_TABLE);
74
        $select->where->equalTo('uuid', $uuid);
75
 
76
        return $this->executeFetchOneObject($select, $prototype);
77
    }
78
 
79
 
80
    /**
81
     *
82
     * @param int $company_id
1065 eleazar 83
     * @return RecruitmentSelectionInterview
647 efrain 84
     */
85
    public function fetchAllByCompanyId($company_id)
86
    {
1065 eleazar 87
        $prototype = new RecruitmentSelectionInterview();
647 efrain 88
 
89
        $select = $this->sql->select(self::_TABLE);
90
        $select->where->equalTo('company_id', $company_id);
91
        $select->order('name');
92
 
93
        return $this->executeFetchAllObject($select, $prototype);
94
    }
852 eleazar 95
 
96
     /**
97
     *
1202 eleazar 98
     * @param int $candidate_id
99
     * @return RecruitmentSelectionInterview
100
     */
1204 eleazar 101
    public function fetchAllByVacancyId($vacancy_id)
1202 eleazar 102
    {
103
        $prototype = new RecruitmentSelectionInterview();
104
 
105
        $select = $this->sql->select(self::_TABLE);
1204 eleazar 106
        $select->where->equalTo('vacancy_id', $vacancy_id);
1202 eleazar 107
        $select->order('first_name');
108
 
109
        return $this->executeFetchAllObject($select, $prototype);
110
    }
111
 
112
     /**
113
     *
852 eleazar 114
     * @param int $company_id
1065 eleazar 115
     * @return RecruitmentSelectionInterview
991 eleazar 116
     */
117
    public function fetchOneByCompanyId($company_id)
118
    {
1065 eleazar 119
        $prototype = new RecruitmentSelectionInterview();
991 eleazar 120
 
121
        $select = $this->sql->select(self::_TABLE);
122
        $select->where->equalTo('company_id', $company_id);
123
        $select->order('name');
124
 
125
        return $this->executeFetchOneObject($select, $prototype);
126
    }
127
 
128
     /**
129
     *
130
     * @param int $company_id
852 eleazar 131
     * @param int $topic_id
132
     * @return RecruitmentSelectionVacancy[]
133
     */
134
    public function fetchAllByCompanyIdAndVacancyId($company_id, $vancacy_id)
135
    {
863 eleazar 136
        $prototype = new RecruitmentSelectionVacancy();
852 eleazar 137
 
138
        $select = $this->sql->select(self::_TABLE);
139
        $select->where->equalTo('company_id', $company_id);
1121 eleazar 140
        $select->where->equalTo('vacancy_id', $vacancy_id);
141
        $select->order(['name']);
852 eleazar 142
 
143
        //echo $select->getSqlString($this->adapter->platform); exit;
144
 
145
        return $this->executeFetchAllObject($select, $prototype);
146
    }
647 efrain 147
 
1121 eleazar 148
    /**
149
     * @param int $vacancy_id
150
     * @param int $candidate_id
1127 eleazar 151
     * @return RecruitmentSelectionInterview
1121 eleazar 152
     */
153
    public function fetchOneByCandidateIdAndVacancyId($candidate_id, $vacancy_id)
154
    {
155
        $prototype = new RecruitmentSelectionInterview();
156
 
157
        $select = $this->sql->select(self::_TABLE);
158
        $select->where->equalTo('candidate_id', $candidate_id);
159
        $select->where->equalTo('vacancy_id', $vacancy_id);
160
        $select->order(['uuid']);
161
 
162
        return $this->executeFetchOneObject($select, $prototype);
163
    }
1255 eleazar 164
 
165
        /**
166
     * @param int $vacancy_id
167
     * @param int $candidate_id
168
     * @return RecruitmentSelectionInterview
169
     */
170
    public function fetchAllByCandidateIdAndVacancyId($candidate_id, $vacancy_id)
171
    {
172
        $prototype = new RecruitmentSelectionInterview();
173
 
174
        $select = $this->sql->select(self::_TABLE);
175
        $select->where->equalTo('candidate_id', $candidate_id);
176
        $select->where->equalTo('vacancy_id', $vacancy_id);
177
        $select->order(['uuid']);
178
 
179
        return $this->executeFetchAllObject($select, $prototype);
180
    }
647 efrain 181
 
182
    /**
183
     *
1065 eleazar 184
     * @param RecruitmentSelectionInterview $form
647 efrain 185
     * @return boolean
186
     */
187
    public function insert($form)
188
    {
189
        $hydrator = new ObjectPropertyHydrator();
190
        $values = $hydrator->extract($form);
191
        $values = $this->removeEmpty($values);
192
 
193
        $insert = $this->sql->insert(self::_TABLE);
194
        $insert->values($values);
1064 eleazar 195
 
1661 eleazar 196
       // echo $insert->getSqlString($this->adapter->platform); exit;
647 efrain 197
 
198
        $result = $this->executeInsert($insert);
199
        if($result) {
200
            $form->id = $this->lastInsertId;
201
        }
202
        return $result;
203
    }
204
 
205
    /**
206
     *
207
     * @param RecruitmentInterview $form
208
     * @return boolean
209
     */
210
    public function update($form)
211
    {
212
        $hydrator = new ObjectPropertyHydrator();
213
        $values = $hydrator->extract($form);
214
        $values = $this->removeEmpty($values);
215
 
216
        $update = $this->sql->update(self::_TABLE);
217
        $update->set($values);
218
        $update->where->equalTo('id', $form->id);
219
 
220
        return $this->executeUpdate($update);
221
    }
222
 
223
    /**
224
     *
225
     * @param int $form_id
226
     * @return boolean
227
     */
228
    public function delete($form_id)
229
    {
230
        $delete = $this->sql->delete(self::_TABLE);
231
        $delete->where->equalTo('id', $form_id);
232
 
233
        return $this->executeDelete($delete);
234
    }
235
 
236
 
237
    /**
238
     *
239
     * @param int $companyId
240
     * @param string $search
241
     * @param int $page
242
     * @param int $records_per_page
243
     * @param string $order_field
244
     * @param string $order_direction
245
     * @return Paginator
246
     */
247
    public function fetchAllDataTableByCompanyId($companyId, $search, $page = 1, $records_per_page = 10, $order_field= 'name', $order_direction = 'ASC')
248
    {
1246 eleazar 249
        $prototype = new RecruitmentSelectionCandidate();
250
        $select = $this->sql->select(self::_TABLE);
251
        $select->where->equalTo('company_id', $companyId);
647 efrain 252
 
253
        if($search) {
1246 eleazar 254
            $select->where->like('name', '%' . $search . '%');
647 efrain 255
        }
256
        $select->order($order_field . ' ' . $order_direction);
257
 
258
        //echo $select->getSqlString($this->adapter->platform); exit;
259
 
260
        $hydrator   = new ObjectPropertyHydrator();
261
        $resultset  = new HydratingResultSet($hydrator, $prototype);
262
 
263
        $adapter = new DbSelect($select, $this->sql, $resultset);
264
        $paginator = new Paginator($adapter);
265
        $paginator->setItemCountPerPage($records_per_page);
266
        $paginator->setCurrentPageNumber($page);
267
 
1246 eleazar 268
 
647 efrain 269
        return $paginator;
270
    }
271
 
272
 
273
}