Proyectos de Subversion LeadersLinked - Services

Rev

Rev 621 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 621 Rev 626
Línea 14... Línea 14...
14
 
14
 
15
 
15
 
16
class MicrolearningCapsuleMapper extends MapperCommon
16
class MicrolearningCapsuleMapper extends MapperCommon
17
{
17
{
18
    const _TABLE = 'tbl_microlearning_capsules';
18
    const _TABLE = 'tbl_microlearning_capsules';
19
    
19
 
20
    /**
20
    /**
21
     *
21
     *
22
     * @var MicrolearningCapsuleMapper
22
     * @var MicrolearningCapsuleMapper
-
 
23
     */
23
     */
24
    private static $_instance;
24
    private static $_instance;
25
 
25
    /**
26
    /**
26
     *
27
     *
27
     * @param AdapterInterface $adapter
28
     * @param AdapterInterface $adapter
Línea 63... Línea 64...
63
    /**
64
    /**
64
     *
65
     *
65
     * @param int $company_id
66
     * @param int $company_id
66
     * @return int
67
     * @return int
67
     */
68
     */
68
    public function fetchTotalCountAllActiveByCompanyId($company_id)
69
    public function fetchTotalCountAllByCompanyId($company_id)
69
    {
70
    {
70
        $select = $this->sql->select();
71
        $select = $this->sql->select();
71
        $select->columns(['total' => new Expression('COUNT(*)')]);
72
        $select->columns(['total' => new Expression('COUNT(*)')]);
72
        $select->from(self::_TABLE);
73
        $select->from(self::_TABLE);
73
        $select->where->equalTo('company_id', $company_id);
74
        $select->where->equalTo('company_id', $company_id);
74
        $select->where->equalTo('status', MicrolearningCapsule::STATUS_ACTIVE);
-
 
Línea 75... Línea 75...
75
        
75
        
76
        $record = $this->executeFetchOneArray($select);
76
        $record = $this->executeFetchOneArray($select);
77
        return $record['total'];
77
        return $record['total'];
Línea 118... Línea 118...
118
        $select->where->equalTo('id', $id);
118
        $select->where->equalTo('id', $id);
Línea 119... Línea 119...
119
        
119
        
120
        return $this->executeFetchOneObject($select, $prototype);
120
        return $this->executeFetchOneObject($select, $prototype);
Línea 121... Línea -...
121
    }
-
 
122
    
-
 
123
    
-
 
124
    /**
-
 
125
     * 
-
 
126
     * @param int $company_id
-
 
127
     * @param int $company_id
-
 
128
     * @return MicrolearningCapsule[]
-
 
129
     */
-
 
130
    public function fetchAllActiveByCompanyId($company_id)
-
 
131
    {
-
 
132
        $prototype = new MicrolearningCapsule();
-
 
133
        
-
 
134
        $select = $this->sql->select(self::_TABLE);
-
 
135
        $select->where->equalTo('company_id', $company_id);
-
 
136
        $select->where->equalTo('status', MicrolearningCapsule::STATUS_ACTIVE);
-
 
137
        $select->order(['name']);
-
 
138
        
-
 
139
        return $this->executeFetchAllObject($select, $prototype);
-
 
140
    }
121
    }
141
    
122
    
142
    /**
123
    /**
143
     *
124
     *
144
     * @param int $company_id
125
     * @param int $company_id
Línea 150... Línea 131...
150
        
131
        
151
        $select = $this->sql->select(self::_TABLE);
132
        $select = $this->sql->select(self::_TABLE);
152
        $select->where->equalTo('company_id', $company_id);
133
        $select->where->equalTo('company_id', $company_id);
Línea 153... Línea -...
153
        $select->order(['name']);
-
 
154
        
-
 
155
        //echo $select->getSqlString($this->adapter->platform); exit;
134
        $select->order(['name']);
156
        
135
        
Línea 157... Línea 136...
157
        return $this->executeFetchAllObject($select, $prototype);
136
        return $this->executeFetchAllObject($select, $prototype);
158
    }
137
    }
Línea 193... Línea 172...
193
        $record = $this->executeFetchOneArray($select);
172
        $record = $this->executeFetchOneArray($select);
194
        return $record['total'];
173
        return $record['total'];
Línea 195... Línea 174...
195
        
174
        
Línea 196... Línea -...
196
    }
-
 
197
    
-
 
198
    
-
 
199
    
-
 
200
    
-
 
201
    /**
-
 
202
     *
-
 
203
 
-
 
204
     * @return MicrolearningCapsule[]
-
 
205
     */
-
 
206
    public function fetchAllActiveAndPublic()
-
 
207
    {
-
 
208
        $prototype = new MicrolearningCapsule();
-
 
209
        
-
 
210
        $select = $this->sql->select(self::_TABLE);
-
 
211
 
-
 
212
        $select->where->equalTo('status', MicrolearningCapsule::STATUS_ACTIVE);
-
 
213
        $select->where->equalTo('privacy', MicrolearningCapsule::PRIVACY_PUBLIC);
-
 
214
        $select->where->equalTo('type', MicrolearningCapsule::TYPE_FREE);
-
 
215
        
-
 
216
        $select->order(['order', 'name']);
-
 
217
        
-
 
218
        return $this->executeFetchAllObject($select, $prototype);
-
 
219
    }
-
 
220
    
-
 
221
    
-
 
222
    /**
-
 
223
     *
-
 
224
     
-
 
225
     * @return MicrolearningCapsule[]
-
 
226
     */
-
 
227
    public function fetchAllActive()
-
 
228
    {
-
 
229
        $prototype = new MicrolearningCapsule();
-
 
230
        
-
 
231
        $select = $this->sql->select(self::_TABLE);
-
 
232
        $select->where->equalTo('status', MicrolearningCapsule::STATUS_ACTIVE);
-
 
233
        $select->order(['name']);
-
 
234
        
-
 
235
        return $this->executeFetchAllObject($select, $prototype);
-
 
236
    }
-
 
237
    
175
    }
238
    
176
    
Línea 239... Línea 177...
239
    /**
177
    /**
240
     *
178
     *
Línea 249... Línea 187...
249
        $select->order(['name']);
187
        $select->order(['name']);
Línea 250... Línea 188...
250
        
188
        
251
        return $this->executeFetchAllObject($select, $prototype);
189
        return $this->executeFetchAllObject($select, $prototype);
Línea 252... Línea -...
252
    }
-
 
253
    
190
    }
254
    
191
    
255
    /**
192
    /**
256
     *
193
     *
257
     * @param int $companyId
194
     * @param int $companyId
Línea 285... Línea 222...
285
        $paginator->setCurrentPageNumber($page);
222
        $paginator->setCurrentPageNumber($page);
Línea 286... Línea 223...
286
        
223
        
287
        
224
        
288
        return $paginator;
-
 
289
    }
225
        return $paginator;
290
    
226
    }
291
    
227
     
292
    /**
228
    /**
293
     *
229
     *
294
     * @param MicrolearningCapsule $capsule
230
     * @param MicrolearningCapsule $capsule
Línea 339... Línea 275...
339
        $delete = $this->sql->delete(self::_TABLE);
275
        $delete = $this->sql->delete(self::_TABLE);
340
        $delete->where->equalTo('id', $capsule->id);
276
        $delete->where->equalTo('id', $capsule->id);
Línea 341... Línea 277...
341
        
277
        
342
        return $this->executeDelete($delete);
278
        return $this->executeDelete($delete);
343
    }
-
 
344
    
-
 
345
 
-
 
346
    
279
    }
347
}
280
}