| 1490 | nelberth | 1 | <?php
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | declare(strict_types=1);
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 | namespace LeadersLinked\Mapper;
 | 
        
           |  |  | 6 |   | 
        
           | 1491 | nelberth | 7 | use LeadersLinked\Model\PlanningObjectivesAndGoalsTaskMembers;
 | 
        
           | 1490 | nelberth | 8 | use LeadersLinked\Mapper\Common\MapperCommon;
 | 
        
           |  |  | 9 | use Laminas\Db\Adapter\AdapterInterface;
 | 
        
           |  |  | 10 | use LeadersLinked\Hydrator\ObjectPropertyHydrator;
 | 
        
           |  |  | 11 | use Laminas\Db\ResultSet\HydratingResultSet;
 | 
        
           |  |  | 12 | use Laminas\Paginator\Adapter\DbSelect;
 | 
        
           |  |  | 13 | use Laminas\Paginator\Paginator;
 | 
        
           |  |  | 14 | use Laminas\Db\Adapter\Driver\ResultInterface;
 | 
        
           |  |  | 15 |   | 
        
           |  |  | 16 |   | 
        
           | 1491 | nelberth | 17 | class PlanningObjectivesAndGoalsTaskMembersMapper extends MapperCommon{
 | 
        
           | 1490 | nelberth | 18 |     const _TABLE = 'tbl_planning_objectives_and_goals_task_members';
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 |     /**
 | 
        
           |  |  | 21 |      *
 | 
        
           | 1491 | nelberth | 22 |      * @var PlanningObjectivesAndGoalsTaskMembersMapper
 | 
        
           | 1490 | nelberth | 23 |      */
 | 
        
           |  |  | 24 |     private static $_instance;
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 |     /**
 | 
        
           |  |  | 27 |      *
 | 
        
           |  |  | 28 |      * @param AdapterInterface $adapter
 | 
        
           |  |  | 29 |      */
 | 
        
           |  |  | 30 |     private function __construct($adapter)
 | 
        
           |  |  | 31 |     {
 | 
        
           |  |  | 32 |         parent::__construct($adapter);
 | 
        
           |  |  | 33 |     }
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 |     /**
 | 
        
           |  |  | 36 |      *
 | 
        
           |  |  | 37 |      * @param AdapterInterface $adapter
 | 
        
           | 1491 | nelberth | 38 |      * @return \LeadersLinked\Mapper\PlanningObjectivesAndGoalsTaskMembersMapper
 | 
        
           | 1490 | nelberth | 39 |      */
 | 
        
           |  |  | 40 |     public static function getInstance($adapter)
 | 
        
           |  |  | 41 |     {
 | 
        
           |  |  | 42 |         if(self::$_instance == null) {
 | 
        
           | 1491 | nelberth | 43 |             self::$_instance = new PlanningObjectivesAndGoalsTaskMembersMapper($adapter);
 | 
        
           | 1490 | nelberth | 44 |         }
 | 
        
           |  |  | 45 |         return self::$_instance;
 | 
        
           |  |  | 46 |     }
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |   | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 |     public function fetchAll($task_id)
 | 
        
           |  |  | 52 |     {
 | 
        
           | 1491 | nelberth | 53 |         $prototype = new PlanningObjectivesAndGoalsTaskMembers();
 | 
        
           | 1490 | nelberth | 54 |         $select = $this->sql->select(self::_TABLE);
 | 
        
           |  |  | 55 |         $select->where->equalTo('task_id', $task_id)->equalTo('status', 'a');
 | 
        
           | 1491 | nelberth | 56 |         $select->where->notEqualTo('status', PlanningObjectivesAndGoalsTaskMembers::STATUS_DELETE);
 | 
        
           | 1490 | nelberth | 57 |         return $this->executeFetchAllObject($select, $prototype);
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 |     }
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |     public function insert($datos)
 | 
        
           |  |  | 62 |     {
 | 
        
           |  |  | 63 |         $hydrator = new ObjectPropertyHydrator();
 | 
        
           |  |  | 64 |         $values = $hydrator->extract($datos);
 | 
        
           |  |  | 65 |         $values = $this->removeEmpty($values);
 | 
        
           |  |  | 66 |         $insert = $this->sql->insert(self::_TABLE);
 | 
        
           |  |  | 67 |         $insert->values($values);
 | 
        
           |  |  | 68 |   | 
        
           |  |  | 69 |   | 
        
           |  |  | 70 |         $result = $this->executeInsert($insert);
 | 
        
           |  |  | 71 |         if($result) {
 | 
        
           |  |  | 72 |             $datos->id = $this->lastInsertId;
 | 
        
           |  |  | 73 |         }
 | 
        
           |  |  | 74 |   | 
        
           |  |  | 75 |         return $result;
 | 
        
           |  |  | 76 |   | 
        
           |  |  | 77 |     }
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 |     public function update($form)
 | 
        
           |  |  | 80 |     {
 | 
        
           |  |  | 81 |         $hydrator = new ObjectPropertyHydrator();
 | 
        
           |  |  | 82 |         $values = $hydrator->extract($form);
 | 
        
           |  |  | 83 |         $values = $this->removeEmpty($values);
 | 
        
           |  |  | 84 |   | 
        
           |  |  | 85 |         $update = $this->sql->update(self::_TABLE);
 | 
        
           |  |  | 86 |         $update->set($values);
 | 
        
           |  |  | 87 |         $update->where->equalTo('id', $form->id);
 | 
        
           |  |  | 88 |         return $this->executeUpdate($update);
 | 
        
           |  |  | 89 |     }
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 |     public function delete($form_id)
 | 
        
           |  |  | 92 |     {
 | 
        
           |  |  | 93 |         $delete = $this->sql->delete(self::_TABLE);
 | 
        
           |  |  | 94 |         $delete->where->equalTo('id', $form_id);
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 |         return $this->executeDelete($delete);
 | 
        
           |  |  | 97 |     }
 | 
        
           |  |  | 98 |   | 
        
           | 1493 | nelberth | 99 |     public function dissableMembersTask($task_id)
 | 
        
           |  |  | 100 |     {
 | 
        
           |  |  | 101 |         $dissable = $this->sql->delete(self::_TABLE);
 | 
        
           |  |  | 102 |         $dissable->where->equalTo('task_id', $task_id);
 | 
        
           |  |  | 103 |   | 
        
           |  |  | 104 |         return $this->executeDelete($dissable);
 | 
        
           |  |  | 105 |     }
 | 
        
           |  |  | 106 |   | 
        
           | 1490 | nelberth | 107 |     public function fetchOneByUuid($uuid)
 | 
        
           |  |  | 108 |     {
 | 
        
           | 1491 | nelberth | 109 |         $prototype = new PlanningObjectivesAndGoalsTaskMembers();
 | 
        
           | 1490 | nelberth | 110 |         $select = $this->sql->select(self::_TABLE);
 | 
        
           |  |  | 111 |         $select->where->equalTo('uuid', $uuid);
 | 
        
           |  |  | 112 |   | 
        
           |  |  | 113 |         return $this->executeFetchOneObject($select, $prototype);
 | 
        
           |  |  | 114 |     }
 | 
        
           |  |  | 115 |   | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 |   | 
        
           |  |  | 118 | }
 |