MPDF {PAGENO} not working in codeigniter in showing page number in pdf

I was working with a existing CodeIgniner Project and it is deals with MDPF to generate pdf file. Now, I am trying to put a page number in the top-right of the pdf page. Here is my code based on https://mpdf.github.io/paging/page-numbering.html

$  data = [ .. some data here ..]; $  sheet_summary = $  this->load->view('pdf/sheet', $  data, true); $  pdf2 = $  this->m_pdf->load(['defaultPageNumStyle' => '1']);  $  pdfFilePath_2 = "sheet-summary-".date('Ymd')".pdf"; $  pdf2->mirrorMargins = 1; $  pdf2->setHeader('||{PAGENO}');  $  pdf2->AddPage('','','','','on');  $  pdf2->WriteHTML($  sheet_summary); $  pdf2->Output("./uploads/".$  pdfFilePath_2, "F"); 

Hacer dos Jquerys en un controlador con Codeigniter

estoy intentando hacer dos consultas desde el controlador con codeigniter, os paso el codigo

$ municipio_recogido = $ _GET[‘value’];

$ fecha_Recogida = $ _GET[‘fechita’];

$ datoss= $ this->db->query(“CALL spMostrarPeliculas2(‘$ fecha_Recogida’,’$ municipio_recogido’)”); echo json_encode($ datoss->result());

Mi pregunta es, como hago otra consulta en el mismo controlador, necesito sacar una lista de peliculas y otra de conciertos…

Saludos

Erro Include PHP Codeigniter

Pessoal estou com uma dúvida, como faço corretamente o include no php codeigniter

segue abaixo o script…quando retiro os scripts em php funciona corretamente.

<?php include('includes/header.inc.php'); ?>  <body> <div id="header" class="container">     <?php include('includes/navigation.inc.php'); ?> </div> <div id="banner-wrapper2">     <div id="banner" class="container">         <div class="boxD">             <h3>Quem somos</h3>          </p>         </div>     </div> </div>  <?php include('includes/footer.inc.php'); ?> 

Já com o include, dá o erro abaixo:

A PHP Error was encountered Severity: Warning

Message: include(includes/header.inc.php): failed to open stream: No such file or directory

Filename: pages/quemsomos.php

Line Number: 1

Backtrace:

File: /home/site.com.br/application/views/frontend/pages/quemsomos.php Line: 1 Function: _error_handler

File: /home/site.com.br/application/views/frontend/pages/quemsomos.php Line: 1 Function: include

File: /home/buscadefornecedores.com.br/application/libraries/Template.php Line: 29 Function: view

File: /home/site.com.br/application/controllers/Pages.php Line: 23 Function: load

File: /home/site.com.br/public/index.php Line: 315 Function: require_once

este é o arquivo routes.php está na web no diretorio: /application/config/routes.php

$ route[‘/includes/’] = ‘includes/header.inc’; $ route[‘/includes/’] = ‘includes/navigation.inc’; $ route[‘/includes/’] = ‘includes/footer.inc’;

os includes na pasta: /application/includes/

na pasta public tenho somente a pasta assets e o index.php

Se alguém puder me ajudar com essa dúvida…

Obrigado

Passar um timestamp do SQL para um timespan do tempo atual no CodeIgniter

Eu tenho um sistema de notificações no meu website e queria mostrar ao utilizador à quanto tempo ele tinha recebido a notificação na view.

Aqui está a tabela notificacoes: Imagem da tabela notificacoes:

Como podem ver no campo data eu guardo a data como um timestamp. Como é que eu consigo converter o timestamp para um timespan que me permitiria mostrar o tempo que passou desde que recebeu a notificação por exemplo assim, 1 hora e 20 minutos.

Obrigado.

Passar variável pelo método POST para um controller através de AJAX/JQUERY no Codeigniter

Boas, estou a aprender AJAX e estou a tentar aceder a um controller enviando uma variável através de ajax. A minha ideia é que ao clicar no botao, ele envie um dado valor para o controller e este o imprima. Da maneira como tenho o código, nada acontece e não percebo o porquê.

O meu código é o seguinte:

$  ( document ).ready(function() {     $  ('#notifications').click(function(){       $  .ajax({         url: '<?=base_url("notificacoes")?>',         type: 'POST',         data: {           key: 'olá'         },         dataType: 'json',         success: function(data) {           console.log(data);         }       });     });      }); 

Controller :

<?php  defined('BASEPATH') OR exit('No direct script access allowed');  class Notificacoes extends CI_Controller {     public function index(){         echo $  this->input->post('key');     } } 

Botão :

<button class="btn btn-secondary pr-2" type="button" id="notifications" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">                         <i class="fa fa-bell" aria-hidden="true"></i>                     <span class="badge">0</span>                     </button> 

Se alguem puder ajudar agradecia!

Пользовательский поиск в codeigniter

У меня есть сайт в codeigniter. в Сайте есть пользовательский поиск, но поиск не работает. Причина сам гугл апи.

‘https://www.googleapis.com/customsearch/v1?key={мой ключ там будет}&cx=cs_id_там написано&q=query

это мой контроллер

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');   class Search extends CI_Controller {      // --------------------------------------------------------------------      public function __construct()     {         parent::__construct();          $  this->load->library('front');     }      // --------------------------------------------------------------------      public function index()     {         $  query = $  this->input->get('q');          $  this->front->title = strip_tags($  query);          $  page = $  this->input->get('page');          if( ! empty($  query))         {             $  responce_result = FALSE;              $  query = urlencode(strip_tags($  query));              $  google_search_url = 'https://www.googleapis.com/customsearch/v1?key=AIzaSyAgkSqr_vAZaMgT6nnBXsksi3CuLCgaP6A&cx=016216714388208243941:roopgcuc9dc&q=query';              $  result_json = file_get_contents($  google_search_url);              $  result = json_decode($  result_json);              if (isset($  result->responseData->cursor->pages) AND 0 < $  pages = count($  result->responseData->cursor->pages))             {                 for($  i = 0; $  i <= $  pages; $  i++)                 {                     $  start = $  i * 8;                      $  google_search_url = 'https://www.googleapis.com/customsearch/v1?key{my_key}=&cx={my_id}:roopgcuc9dc&q=query';                      $  result = json_decode(file_get_contents($  google_search_url));                      if (isset($  result->responseData->results) AND 0 < count($  result->responseData->results))                     {                         foreach ($  result->responseData->results as $  r)                         {                             $  responce_result[] = array(                                                      'url' => $  r->url,                                                      'title' => $  r->title,                                                      'content' => $  r->content,                                 );                         }                     }                 }             }              $  this->front->responce_result = $  responce_result;         }         else         {             $  this->load->library('user_agent');              if($  this->agent->is_referral())             {                 redirect($  this->agent->referrer());             }             else             {                 redirect(base_url());             }         }          // Adding Special Stylesheets into page         $  this->view->add_css('front/search');          $  this->load->library('widgets');          $  this->widgets->informations();          // Right Sidebar Widgets         $  right_widgets = array('about-country', 'banner', 'other-information');          // Loading View of Tour page         $  this->front->sidebar('search/index', $  right_widgets);     }      // --------------------------------------------------------------------  }      <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');   class Search extends CI_Controller {      // --------------------------------------------------------------------      public function __construct()     {         parent::__construct();          $  this->load->library('front');     }      // --------------------------------------------------------------------      public function index()     {         $  query = $  this->input->get('q');          $  this->front->title = strip_tags($  query);          $  page = $  this->input->get('page');          if( ! empty($  query))         {             $  responce_result = FALSE;              $  query = urlencode(strip_tags($  query));              $  google_search_url = 'https://www.googleapis.com/customsearch/v1?key=AIzaSyAgkSqr_vAZaMgT6nnBXsksi3CuLCgaP6A&cx=016216714388208243941:roopgcuc9dc&q=query';              $  result_json = file_get_contents($  google_search_url);              $  result = json_decode($  result_json);              if (isset($  result->responseData->cursor->pages) AND 0 < $  pages = count($  result->responseData->cursor->pages))             {                 for($  i = 0; $  i <= $  pages; $  i++)                 {                     $  start = $  i * 8;                      $  google_search_url = 'https://www.googleapis.com/customsearch/v1?key{my_key}=&cx={my_id}:roopgcuc9dc&q=query';                      $  result = json_decode(file_get_contents($  google_search_url));                      if (isset($  result->responseData->results) AND 0 < count($  result->responseData->results))                     {                         foreach ($  result->responseData->results as $  r)                         {                             $  responce_result[] = array(                                                      'url' => $  r->url,                                                      'title' => $  r->title,                                                      'content' => $  r->content,                                 );                         }                     }                 }             }              $  this->front->responce_result = $  responce_result;         }         else         {             $  this->load->library('user_agent');              if($  this->agent->is_referral())             {                 redirect($  this->agent->referrer());             }             else             {                 redirect(base_url());             }         }          // Adding Special Stylesheets into page         $  this->view->add_css('front/search');          $  this->load->library('widgets');          $  this->widgets->informations();          // Right Sidebar Widgets         $  right_widgets = array('about-country', 'banner', 'other-information');          // Loading View of Tour page         $  this->front->sidebar('search/index', $  right_widgets);     }      // --------------------------------------------------------------------  } 

мой view

            <h1 class="margin-top-minus-20 search-page-h3"><span class="search-icon"></span>Search: <?=strip_tags($  this->input->get('q'))?></h1>               <!-- SEPERETOR START -->             <div class="middle-seperator"></div><!-- .seperator -->             <!-- SEPERATOR END -->               <!-- SEARCH PAGE START -->             <div class="search-page">  <div id='cse-search-form' style='width: 100%;'>Loading</div> <script src='//www.google.com/jsapi' type='text/javascript'></script> <script>   (function() {     var cx = '{my_id}:roopgcuc9dc';     var gcse = document.createElement('script');     gcse.type = 'text/javascript';     gcse.async = true;     gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;     var s = document.getElementsByTagName('script')[0];     s.parentNode.insertBefore(gcse, s);   })(); </script> <gcse:searchbox-only></gcse:searchbox-only>                 <!-- Code for search results --> <div id='cse' style='width: 100%;'></div>                </div><!-- .search-page -->              <?=get_instance()->load->view('front/blocks/social-networks'.EXT);?> 

How to display dynamic data using models and custom helpers in CodeIgniter?

I am creating a feature in my application where in I want to dynamically change the text of page headers, page header titles, and breadcrumbs based on the menu id and menu name from the table in my database in order for me not to code them manually each time there is an update. I already created a model and a custom helper in CodeIgniter and loaded the model in the helper using the $ CI =& get_instance function but I am quite stuck on how to dynamically call the names of the menu from the database using the model that I created in the custom helper that I wrote. Below are some of my codes in my model and the custom helper I created.

Model:

public function __construct() {     parent::__construct(); }  function get_page_menu_names($  menu_name) {     //$  this->db->where('menu_id', $  menu_id);      $  this->db->where('menu_name', $  menu_name);      $  query = $  this->db->get('menu_master');      return $  query->result(); } 

Custom Helper that I created and called the model and it’s function:

function __construct()     {         parent::__construct();         $  CI =& get_instance();         $  CI->load->model('Page_Header_model');         $  CI->Page_Header_model->get_page_menu_names();     }  function get_page_header_data($  page_type) {      $  project_title = 'Testing';      $  page_header_array['dashboard'] = array(             "page_title"  =>  'Dashboard',             "page_header_title" =>  'Dashboard : '.$  project_title          );      $  page_header_array['price_list'] = array(              "breadcrumbs" =>  array(                 array('title'=>'Home','url'=>base_url()),                 array('title'=>'Price List','is_active'=>TRUE),             ),             "page_title"  =>  'Price List',             "page_header_title" =>  'Price List : '.$  project_title          );      $  page_header_data = $  page_header_array[$  page_type];      return $  page_header_data; }