src/Controller/PageHistoricController.php
public function getPageHistoricDataAction()
    {
        $melisPageHistoricTable = $this->getServiceLocator()->get('MelisPagehistoricTable');
        $melisUserTable = $this->serviceLocator->get('MelisCoreTableUser');
        
        $translator = $this->getServiceLocator()->get('translator');
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $melisTool->setMelisToolKey(self::PLUGIN_INDEX, self::TOOL_KEY);

        $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');
        $container = new Container('meliscore');
        $locale = $container['melis-lang-locale'];
        
        $colId = array();
        $dataCount = 0;
        $draw = 0;
        $tableData = array();
        if ($this->getRequest()->isPost()) {
            $pageId = (int) $this->getRequest()->getPost('pageId');
            $userName = $this->getRequest()->getPost('user_name', null);
            $action = $this->getRequest()->getPost('action', null);

            $colId = array_keys($melisTool->getColumns());
            $selCol = $this->getRequest()->getPost('order');
            $selCol = $colId[$selCol[0]['column']];

            $startDate = $this->getRequest()->getPost('startDate');
            $endDate = $this->getRequest()->getPost('endDate');

            if ($selCol != 'hist_id') {
                $sortOrder = $this->getRequest()->getPost('order');
                $sortOrder = $sortOrder[0]['dir'];
            }
            else {
                $sortOrder = 'desc';
            }
        
            $draw = $this->getRequest()->getPost('draw');
            $start = $this->getRequest()->getPost('start');
            $length =  $this->getRequest()->getPost('length');

            $dataCount = $melisPageHistoricTable->getTotalData('hist_page_id',$pageId);

            $option = array(
                'where' => array(
                    'key' => 'hist_page_id',
                    'value' => $pageId,
                ),
                // fixed order, since page historic is sorting descendingly using history ID
                'order' => array(
                    'key' => 'hist_id',
                    'dir' => 'desc',
                ),
                'start' => $start,
                'limit' => $length,
                'columns' => $melisTool->getSearchableColumns(),
                'date_filter' => array(

                ),
            );

            if ($startDate != NULL && $endDate != NULL) {
                $option['date_filter'] = [
                    'key' => 'hist_date',
                    'startDate' => date('Y-m-d', strtotime($startDate)),
                    'endDate' => date('Y-m-d', strtotime($endDate))
                ];
            }

            $getData = $melisPageHistoricTable->getPageHistoricData($option, null, $userName, $action);

        
            // store fetched Object Data into array so we can apply any string modifications
            foreach($getData as $key => $values)
            {
                $tableData[$key] = (array) $values;
            }

            for($ctr = 0; $ctr < count($tableData); $ctr++)
            {
                // Initialize as Deleted User As Default
                $histUserId = $tableData[$ctr]['hist_user_id'];
                $tableData[$ctr]['hist_user_id'] = $translator->translate('tr_meliscore_user_deleted').' ('.$tableData[$ctr]['hist_user_id'].')';
                
                $histUserData = $melisUserTable->getEntryById($histUserId);
                
                if (!empty($histUserData)){
                    $histUserData = $histUserData->current();
                    if(!empty($histUserData)) {
                        $tableData[$ctr]['hist_user_id'] = ucfirst(mb_strtolower($histUserData->usr_firstname, 'UTF-8')).' '.ucfirst(mb_strtolower($histUserData->usr_lastname, 'UTF-8'));
                    }
                }
                
                $tableData[$ctr]['DT_RowId'] = $tableData[$ctr]['hist_id'];
                $tableData[$ctr]['hist_action'] = $translator->translate('tr_melispagehistoric_action_text_'.$tableData[$ctr]['hist_action']);
                $tableData[$ctr]['hist_date'] = strftime($melisTranslation->getDateFormatByLocate($locale), strtotime($tableData[$ctr]['hist_date']));
                $tableData[$ctr]['hist_description'] =$translator->translate($tableData[$ctr]['hist_description']);
            }
        }
      
        return new JsonModel(array(
            'draw' => (int) $draw,
            'recordsTotal' => $dataCount,
            'recordsFiltered' =>  $melisPageHistoricTable->getTotalFiltered(),
            'data' => $tableData,
        ));
    }
public function getPageHistoricDataAction()
    {
        $melisPageHistoricTable = $this->getServiceLocator()->get('MelisPagehistoricTable');
        $melisUserTable = $this->serviceLocator->get('MelisCoreTableUser');
        
        $translator = $this->getServiceLocator()->get('translator');
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $melisTool->setMelisToolKey(self::PLUGIN_INDEX, self::TOOL_KEY);

        $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');
        $container = new Container('meliscore');
        $locale = $container['melis-lang-locale'];
        
        $colId = array();
        $dataCount = 0;
        $draw = 0;
        $tableData = array();
        if ($this->getRequest()->isPost()) {
            $pageId = (int) $this->getRequest()->getPost('pageId');
            $userName = $this->getRequest()->getPost('user_name', null);
            $action = $this->getRequest()->getPost('action', null);

            $colId = array_keys($melisTool->getColumns());
            $selCol = $this->getRequest()->getPost('order');
            $selCol = $colId[$selCol[0]['column']];

            $startDate = $this->getRequest()->getPost('startDate');
            $endDate = $this->getRequest()->getPost('endDate');

            if ($selCol != 'hist_id') {
                $sortOrder = $this->getRequest()->getPost('order');
                $sortOrder = $sortOrder[0]['dir'];
            }
            else {
                $sortOrder = 'desc';
            }
        
            $draw = $this->getRequest()->getPost('draw');
            $start = $this->getRequest()->getPost('start');
            $length =  $this->getRequest()->getPost('length');

            $dataCount = $melisPageHistoricTable->getTotalData('hist_page_id',$pageId);

            $option = array(
                'where' => array(
                    'key' => 'hist_page_id',
                    'value' => $pageId,
                ),
                // fixed order, since page historic is sorting descendingly using history ID
                'order' => array(
                    'key' => 'hist_id',
                    'dir' => 'desc',
                ),
                'start' => $start,
                'limit' => $length,
                'columns' => $melisTool->getSearchableColumns(),
                'date_filter' => array(

                ),
            );

            if ($startDate != NULL && $endDate != NULL) {
                $option['date_filter'] = [
                    'key' => 'hist_date',
                    'startDate' => date('Y-m-d', strtotime($startDate)),
                    'endDate' => date('Y-m-d', strtotime($endDate))
                ];
            }

            $getData = $melisPageHistoricTable->getPageHistoricData($option, null, $userName, $action);

        
            // store fetched Object Data into array so we can apply any string modifications
            foreach($getData as $key => $values)
            {
                $tableData[$key] = (array) $values;
            }

            for($ctr = 0; $ctr < count($tableData); $ctr++)
            {
                // Initialize as Deleted User As Default
                $histUserId = $tableData[$ctr]['hist_user_id'];
                $tableData[$ctr]['hist_user_id'] = $translator->translate('tr_meliscore_user_deleted').' ('.$tableData[$ctr]['hist_user_id'].')';
                
                $histUserData = $melisUserTable->getEntryById($histUserId);
                
                if (!empty($histUserData)){
                    $histUserData = $histUserData->current();
                    if(!empty($histUserData)) {
                        $tableData[$ctr]['hist_user_id'] = ucfirst(mb_strtolower($histUserData->usr_firstname, 'UTF-8')).' '.ucfirst(mb_strtolower($histUserData->usr_lastname, 'UTF-8'));
                    }
                }
                
                $tableData[$ctr]['DT_RowId'] = $tableData[$ctr]['hist_id'];
                $tableData[$ctr]['hist_action'] = $translator->translate('tr_melispagehistoric_action_text_'.$tableData[$ctr]['hist_action']);
                $tableData[$ctr]['hist_date'] = strftime($melisTranslation->getDateFormatByLocate($locale), strtotime($tableData[$ctr]['hist_date']));
                $tableData[$ctr]['hist_description'] =$translator->translate($tableData[$ctr]['hist_description']);
            }
        }
      
        return new JsonModel(array(
            'draw' => (int) $draw,
            'recordsTotal' => $dataCount,
            'recordsFiltered' =>  $melisPageHistoricTable->getTotalFiltered(),
            'data' => $tableData,
        ));
    }
Returns a JSON format of Page Historic Data from DB
@return \Zend\View\Model\JsonModel