124 lines
4.5 KiB
PHP
124 lines
4.5 KiB
PHP
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Agent_Controller extends AGT_Controller {
|
|
|
|
var $template = array(
|
|
'table_open' => "<table class='table table-striped table-hover table-bordered table-condensed'>",
|
|
'thead_open' => '<thead class=\'bg-indigo\'>',
|
|
'thead_close' => '</thead>',
|
|
'heading_row_start' => '<tr>',
|
|
'heading_row_end' => '</tr>',
|
|
'heading_cell_start' => '<th>',
|
|
'heading_cell_end' => '</th>',
|
|
'tbody_open' => '<tbody>',
|
|
'tbody_close' => '</tbody>',
|
|
'row_start' => '<tr>',
|
|
'row_end' => '</tr>',
|
|
'cell_start' => '<td>',
|
|
'cell_end' => '</td>',
|
|
'row_alt_start' => '<tr>',
|
|
'row_alt_end' => '</tr>',
|
|
'cell_alt_start' => '<td>',
|
|
'cell_alt_end' => '</td>',
|
|
'table_close' => '</table>'
|
|
);
|
|
public $data = array();
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
|
|
$out = array();
|
|
$in = array();
|
|
$ret = $this->medtrans_call_api(MEDTRANS_TRANSP_VERIFYSESSION, $in, $out);
|
|
|
|
// print_r($out);
|
|
|
|
if (!isset($_SESSION['agent_sessionid']) or $_SESSION['agent_sessionid'] == '' or $out['internal_return'] != 505 ) {
|
|
redirect('site');
|
|
}
|
|
}
|
|
|
|
// protected
|
|
|
|
protected function indexPageReal($data) {
|
|
$data['do_not_script'] = false;
|
|
$data['pageNumber'] = $this->input->get('pageNumber');
|
|
if ($data['pageNumber']=='' || $data['pageNumber']<1) $data['pageNumber'] = 1;
|
|
$in['agent_id'] = $_SESSION['agent_id'];
|
|
$in['limit'] = 30;
|
|
$in["transport_id"] = 0;
|
|
$in['action'] = MEDTRANS_USER_GET_TRANSLIST;
|
|
$out = array();
|
|
$ret = $this->medtrans_call_api(MEDTRANS_TRANSP_GET_TRANSLIST, $in, $out);
|
|
|
|
$data['result_per_page'] = 10;
|
|
$data['result_total'] = count($out['result_list']);
|
|
$data['result_list'] = $out['result_list'];
|
|
|
|
$pages = ceil(1.0*$data['result_total']/$data['result_per_page']);
|
|
if ($data['pageNumber']>$pages) $data['pageNumber'] = 1;
|
|
|
|
$offset = $data['result_per_page'] * ($data['pageNumber'] - 1);
|
|
$data['result_list'] = array_slice($out['result_list'],$offset,$data['result_per_page']);
|
|
return $data;
|
|
}
|
|
|
|
protected function returnAdminTable($tbq, $pgLink) {
|
|
|
|
$this->load->library('pagination');
|
|
$config = array();
|
|
$query = $this->db->query($tbq['count_query']);
|
|
$config["total_rows"] = $query->num_rows();
|
|
$config["base_url"] = base_url() . $pgLink;
|
|
$config["per_page"] = 5;
|
|
$config["uri_segment"] = 3;
|
|
$config["num_links"] = 5;
|
|
$config['full_tag_open'] = "<ul class='pagination'>";
|
|
$config['full_tag_close'] = "</ul>";
|
|
$config['num_tag_open'] = '<li>';
|
|
$config['num_tag_close'] = '</li>';
|
|
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
|
|
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
|
|
$config['next_tag_open'] = "<li>";
|
|
$config['next_tagl_close'] = "</li>";
|
|
$config['prev_tag_open'] = "<li>";
|
|
$config['prev_tagl_close'] = "</li>";
|
|
$config['first_tag_open'] = "<li>";
|
|
$config['first_tagl_close'] = "</li>";
|
|
$config['last_tag_open'] = "<li>";
|
|
$config['last_tagl_close'] = "</li>";
|
|
|
|
$this->pagination->initialize($config);
|
|
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
|
|
$page = is_numeric($page) ? $page : 0;
|
|
|
|
$mysql = $tbq['query'] . " LIMIT " . $config["per_page"] . " OFFSET " . $page;
|
|
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template);
|
|
$query = $this->db->query($mysql);
|
|
|
|
// $this->table->set_heading(array('data' => 'Added/ID', 'style' => 'width:100px'), 'Title', 'Client', array('data' => 'Action', 'style' => 'width:70px'));
|
|
|
|
|
|
$data['output_table'] = $this->table->generate($query);
|
|
$data["links"] = $this->pagination->create_links();
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function makeGoogleAddress($rect) {
|
|
//print_r($rect);
|
|
$data['directionsStart'] = $rect['to_street'] . "," . $rect['to_city'] . "," . $rect['to_state'] . " " . $rect['to_zipcode'] . ", USA";
|
|
$data['directionsEnd'] = $rect['from_street'] . "," . $rect['from_city'] . "," . $rect['from_state'] . " " . $rect['from_zipcode'] . ", USA";
|
|
|
|
return $data;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|