| 997 | 
           nelberth | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           declare(strict_types=1);
  | 
        
        
            | 
            | 
           4 | 
              | 
        
        
            | 
            | 
           5 | 
           namespace LeadersLinked\Mapper;
  | 
        
        
            | 
            | 
           6 | 
              | 
        
        
            | 
            | 
           7 | 
           use LeadersLinked\Model\PlanningObjectivesAndGoalsObjectives;
  | 
        
        
            | 
            | 
           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 | 
              | 
        
        
            | 
            | 
           15 | 
              | 
        
        
            | 
            | 
           16 | 
           class PlanningObjectivesAndGoalsObjectivesMapper extends MapperCommon{
  | 
        
        
            | 
            | 
           17 | 
               const _TABLE = 'tbl_planning_objectives_and_goals_objectives';
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
               /**
  | 
        
        
            | 
            | 
           20 | 
                *
  | 
        
        
            | 
            | 
           21 | 
                * @var PlanningObjectivesAndGoalsObjectivesMapper
  | 
        
        
            | 
            | 
           22 | 
                */
  | 
        
        
            | 
            | 
           23 | 
               private static $_instance;
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
               /**
  | 
        
        
            | 
            | 
           26 | 
                *
  | 
        
        
            | 
            | 
           27 | 
                * @param AdapterInterface $adapter
  | 
        
        
            | 
            | 
           28 | 
                */
  | 
        
        
            | 
            | 
           29 | 
               private function __construct($adapter)
  | 
        
        
            | 
            | 
           30 | 
               {
  | 
        
        
            | 
            | 
           31 | 
                   parent::__construct($adapter);
  | 
        
        
            | 
            | 
           32 | 
               }
  | 
        
        
            | 
            | 
           33 | 
              | 
        
        
            | 
            | 
           34 | 
               /**
  | 
        
        
            | 
            | 
           35 | 
                *
  | 
        
        
            | 
            | 
           36 | 
                * @param AdapterInterface $adapter
  | 
        
        
            | 
            | 
           37 | 
                * @return \LeadersLinked\Mapper\PlanningObjectivesAndGoalsObjectivesMapper
  | 
        
        
            | 
            | 
           38 | 
                */
  | 
        
        
            | 
            | 
           39 | 
               public static function getInstance($adapter)
  | 
        
        
            | 
            | 
           40 | 
               {
  | 
        
        
            | 
            | 
           41 | 
                   if(self::$_instance == null) {
  | 
        
        
            | 
            | 
           42 | 
                       self::$_instance = new PlanningObjectivesAndGoalsObjectivesMapper($adapter);
  | 
        
        
            | 
            | 
           43 | 
                   }
  | 
        
        
            | 
            | 
           44 | 
                   return self::$_instance;
  | 
        
        
            | 
            | 
           45 | 
               }
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
            | 
            | 
           47 | 
              | 
        
        
            | 
            | 
           48 | 
              | 
        
        
           | 1445 | 
           efrain | 
           49 | 
               public function fetchAllDataTable($search, $page = 1, $records_per_page = 10, $order_field= 'title', $order_direction = 'ASC', $company_id)
  | 
        
        
           | 997 | 
           nelberth | 
           50 | 
               {
  | 
        
        
            | 
            | 
           51 | 
                   $prototype = new PlanningObjectivesAndGoalsObjectives();
  | 
        
        
            | 
            | 
           52 | 
                   $select = $this->sql->select(self::_TABLE);
  | 
        
        
           | 1606 | 
           nelberth | 
           53 | 
                   $select->where->equalTo('company_id', $company_id);
  | 
        
        
           | 997 | 
           nelberth | 
           54 | 
                   $select->where->notEqualTo('status', PlanningObjectivesAndGoalsObjectives::STATUS_DELETE);
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
              | 
        
        
            | 
            | 
           57 | 
                   if($search) {
  | 
        
        
            | 
            | 
           58 | 
                       $select->where->like('title', '%' . $search . '%');
  | 
        
        
            | 
            | 
           59 | 
                   }
  | 
        
        
            | 
            | 
           60 | 
                   $select->order($order_field . ' ' . $order_direction);
  | 
        
        
            | 
            | 
           61 | 
              | 
        
        
            | 
            | 
           62 | 
              | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
                   $hydrator   = new ObjectPropertyHydrator();
  | 
        
        
            | 
            | 
           65 | 
                   $resultset  = new HydratingResultSet($hydrator, $prototype);
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
                   $adapter = new DbSelect($select, $this->sql, $resultset);
  | 
        
        
            | 
            | 
           68 | 
                   $paginator = new Paginator($adapter);
  | 
        
        
            | 
            | 
           69 | 
                   $paginator->setItemCountPerPage($records_per_page);
  | 
        
        
            | 
            | 
           70 | 
                   $paginator->setCurrentPageNumber($page);
  | 
        
        
            | 
            | 
           71 | 
              | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
                   return $paginator;
  | 
        
        
            | 
            | 
           74 | 
               }
  | 
        
        
           | 2159 | 
           nelberth | 
           75 | 
               public function fetchAllDataTableHptg($search, $page = 1, $records_per_page = 10, $order_field= 'title', $order_direction = 'ASC', $company_id, $high_performance_team_group_id)
  | 
        
        
            | 
            | 
           76 | 
               {
  | 
        
        
            | 
            | 
           77 | 
                   $prototype = new PlanningObjectivesAndGoalsObjectives();
  | 
        
        
            | 
            | 
           78 | 
                   $select = $this->sql->select(self::_TABLE);
  | 
        
        
            | 
            | 
           79 | 
                   $select->where->equalTo('company_id', $company_id);
  | 
        
        
            | 
            | 
           80 | 
                   $select->where->equalTo('high_performance_team_group_id', $high_performance_team_group_id);
  | 
        
        
            | 
            | 
           81 | 
                   $select->where->notEqualTo('status', PlanningObjectivesAndGoalsObjectives::STATUS_DELETE);
  | 
        
        
            | 
            | 
           82 | 
              | 
        
        
            | 
            | 
           83 | 
              | 
        
        
            | 
            | 
           84 | 
                   if($search) {
  | 
        
        
            | 
            | 
           85 | 
                       $select->where->like('title', '%' . $search . '%');
  | 
        
        
            | 
            | 
           86 | 
                   }
  | 
        
        
            | 
            | 
           87 | 
                   $select->order($order_field . ' ' . $order_direction);
  | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
              | 
        
        
            | 
            | 
           90 | 
              | 
        
        
            | 
            | 
           91 | 
                   $hydrator   = new ObjectPropertyHydrator();
  | 
        
        
            | 
            | 
           92 | 
                   $resultset  = new HydratingResultSet($hydrator, $prototype);
  | 
        
        
            | 
            | 
           93 | 
              | 
        
        
            | 
            | 
           94 | 
                   $adapter = new DbSelect($select, $this->sql, $resultset);
  | 
        
        
            | 
            | 
           95 | 
                   $paginator = new Paginator($adapter);
  | 
        
        
            | 
            | 
           96 | 
                   $paginator->setItemCountPerPage($records_per_page);
  | 
        
        
            | 
            | 
           97 | 
                   $paginator->setCurrentPageNumber($page);
  | 
        
        
            | 
            | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
              | 
        
        
            | 
            | 
           100 | 
                   return $paginator;
  | 
        
        
            | 
            | 
           101 | 
               }
  | 
        
        
           | 1445 | 
           efrain | 
           102 | 
               public function fetchAll($company_id)
  | 
        
        
           | 1201 | 
           nelberth | 
           103 | 
               {
  | 
        
        
            | 
            | 
           104 | 
                   $prototype = new PlanningObjectivesAndGoalsObjectives();
  | 
        
        
            | 
            | 
           105 | 
                   $select = $this->sql->select(self::_TABLE);
  | 
        
        
           | 1445 | 
           efrain | 
           106 | 
                   $select->where->equalTo('company_id', $company_id)->equalTo('status', 'a');
  | 
        
        
           | 1201 | 
           nelberth | 
           107 | 
                   $select->where->notEqualTo('status', PlanningObjectivesAndGoalsObjectives::STATUS_DELETE);
  | 
        
        
           | 1214 | 
           nelberth | 
           108 | 
                   return $this->executeFetchAllObject($select, $prototype);
  | 
        
        
           | 1201 | 
           nelberth | 
           109 | 
               }
  | 
        
        
           | 2161 | 
           nelberth | 
           110 | 
               public function fetchAllHptg($company_id, $high_performance_team_group_id)
  | 
        
        
            | 
            | 
           111 | 
               {
  | 
        
        
            | 
            | 
           112 | 
                   $prototype = new PlanningObjectivesAndGoalsObjectives();
  | 
        
        
            | 
            | 
           113 | 
                   $select = $this->sql->select(self::_TABLE);
  | 
        
        
            | 
            | 
           114 | 
                   $select->where->equalTo('company_id', $company_id);
  | 
        
        
            | 
            | 
           115 | 
                   $select->where->equalTo('status', PlanningObjectivesAndGoalsObjectives::STATUS_ACTIVE);
  | 
        
        
            | 
            | 
           116 | 
                   $select->where->equalTo('high_performance_team_group_id', $high_performance_team_group_id);
  | 
        
        
            | 
            | 
           117 | 
                   return $this->executeFetchAllObject($select, $prototype);
  | 
        
        
            | 
            | 
           118 | 
               }
  | 
        
        
           | 997 | 
           nelberth | 
           119 | 
               public function insert($datos)
  | 
        
        
            | 
            | 
           120 | 
               {
  | 
        
        
            | 
            | 
           121 | 
                   $hydrator = new ObjectPropertyHydrator();
  | 
        
        
            | 
            | 
           122 | 
                   $values = $hydrator->extract($datos);
  | 
        
        
            | 
            | 
           123 | 
                   $values = $this->removeEmpty($values);
  | 
        
        
            | 
            | 
           124 | 
                   $insert = $this->sql->insert(self::_TABLE);
  | 
        
        
            | 
            | 
           125 | 
                   $insert->values($values);
  | 
        
        
            | 
            | 
           126 | 
              | 
        
        
            | 
            | 
           127 | 
              | 
        
        
            | 
            | 
           128 | 
                   $result = $this->executeInsert($insert);
  | 
        
        
            | 
            | 
           129 | 
                   if($result) {
  | 
        
        
            | 
            | 
           130 | 
                       $datos->id = $this->lastInsertId;
  | 
        
        
            | 
            | 
           131 | 
                   }
  | 
        
        
            | 
            | 
           132 | 
              | 
        
        
            | 
            | 
           133 | 
                   return $result;
  | 
        
        
            | 
            | 
           134 | 
              | 
        
        
            | 
            | 
           135 | 
               }
  | 
        
        
            | 
            | 
           136 | 
              | 
        
        
            | 
            | 
           137 | 
               public function update($form)
  | 
        
        
            | 
            | 
           138 | 
               {
  | 
        
        
            | 
            | 
           139 | 
                   $hydrator = new ObjectPropertyHydrator();
  | 
        
        
            | 
            | 
           140 | 
                   $values = $hydrator->extract($form);
  | 
        
        
            | 
            | 
           141 | 
                   $values = $this->removeEmpty($values);
  | 
        
        
            | 
            | 
           142 | 
              | 
        
        
            | 
            | 
           143 | 
                   $update = $this->sql->update(self::_TABLE);
  | 
        
        
            | 
            | 
           144 | 
                   $update->set($values);
  | 
        
        
            | 
            | 
           145 | 
                   $update->where->equalTo('id', $form->id);
  | 
        
        
            | 
            | 
           146 | 
                   return $this->executeUpdate($update);
  | 
        
        
            | 
            | 
           147 | 
               }
  | 
        
        
            | 
            | 
           148 | 
              | 
        
        
            | 
            | 
           149 | 
               public function delete($form_id)
  | 
        
        
            | 
            | 
           150 | 
               {
  | 
        
        
            | 
            | 
           151 | 
                   $delete = $this->sql->delete(self::_TABLE);
  | 
        
        
            | 
            | 
           152 | 
                   $delete->where->equalTo('id', $form_id);
  | 
        
        
            | 
            | 
           153 | 
              | 
        
        
            | 
            | 
           154 | 
                   return $this->executeDelete($delete);
  | 
        
        
            | 
            | 
           155 | 
               }
  | 
        
        
            | 
            | 
           156 | 
              | 
        
        
            | 
            | 
           157 | 
               public function fetchOneByUuid($uuid)
  | 
        
        
            | 
            | 
           158 | 
               {
  | 
        
        
            | 
            | 
           159 | 
                   $prototype = new PlanningObjectivesAndGoalsObjectives();
  | 
        
        
            | 
            | 
           160 | 
                   $select = $this->sql->select(self::_TABLE);
  | 
        
        
            | 
            | 
           161 | 
                   $select->where->equalTo('uuid', $uuid);
  | 
        
        
            | 
            | 
           162 | 
              | 
        
        
            | 
            | 
           163 | 
                   return $this->executeFetchOneObject($select, $prototype);
  | 
        
        
            | 
            | 
           164 | 
               }
  | 
        
        
            | 
            | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
              | 
        
        
            | 
            | 
           167 | 
              | 
        
        
            | 
            | 
           168 | 
           }
  |