Exemplo n.º 1
0
 public function keyword_cron_jobs_ajax($status = null, $page = 0)
 {
     $this->load->model('ranking_model');
     $page = (int) $page;
     $group_name = $this->input->post('group_name');
     $sortBy = $this->input->get('sort_by');
     if ($page > 0) {
         $page -= 1;
     } else {
         $page = 0;
     }
     $total = $this->ranking_model->getAllCronJobsTotal($status, $group_name);
     if ($page * $this->keyword_limit > $total) {
         $page = 0;
     }
     /*Issue #2370 Pagination*/
     $this->load->library('pagination');
     $offset = $page * $this->keyword_limit;
     $config['base_url'] = base_url('system/keyword_cron_jobs/');
     $config['total_rows'] = $total;
     $config['per_page'] = $this->keyword_limit;
     $config['use_page_numbers'] = TRUE;
     $config['uri_segment'] = 4;
     $config['anchor_class'] = ' class="keyword_pagination" ';
     $config['cur_tag_open'] = '<b class="cur_keyword_pagination">';
     $config['cur_tag_close'] = '</b>';
     $this->pagination->initialize($config);
     $keyword_pagination = $this->pagination->create_links(2);
     $cron_jobs = $this->ranking_model->getAllCronJobs($status, $this->keyword_limit, $offset, $group_name, $sortBy);
     //Issue #3519
     foreach ($cron_jobs as &$job) {
         $job->error_count = '';
         if ($job->status == 4 || $job->status == 5) {
             $error_count = $this->ranking_model->getErrorCount($job->id);
             if (!empty($error_count->idall)) {
                 $job->error_count = $error_count->iderr . '/' . $error_count->idall;
             }
         }
     }
     echo json_encode(array('jobs' => $cron_jobs, 'pagination' => $keyword_pagination));
     die;
 }