"
. "| |
"
. "" . $selected_card["title"] . " |
"
. " " . $selected_card["description"] . " |
"
. "" . $selected_card["button1_text"] . "
|
"
. "
";
// print_r( $selected_card );
}
}
public function editcard()
{
$data = array();
$card_id = $this->input->get('card_id');
if ($card_id != '' && $card_id > 0) {
$mysql = "SELECT * FROM main_cards WHERE id = $card_id";
$query = $this->read_replica->query($mysql);
$selected_card = $query->row_array();
$data["images"] = array();
$data["form_button"] = "Update";
$this->load->model('combo_model');
$data['card_category_value'] = $selected_card['button1_action'];
$data['card_can_save_value'] = $selected_card['can_save'];
$data['card_pictures_value'] = $selected_card['background_picture'];
$data['card_status_value'] = $selected_card['status'];
$data['card_template_value'] = $selected_card['template'];
$data['card_canexpire_value'] = $selected_card['card_canexpire'];
$data['card_notify_value'] = $selected_card['notify'];
$data['card_country_value'] = $selected_card['card_country'];
$data['card_titleshow_value'] = $selected_card['titleshow'];
$data['card_category'] = $this->combo_model->getCardCategoryCombo('card_category', $data['card_category_value']);
$data['card_can_save'] = $this->combo_model->getYesNoCombo('card_can_save', $data['card_can_save_value']);
$data['card_pictures'] = $this->combo_model->getCardPicturesCombo('card_pictures', $data['card_pictures_value']);
$data['card_status'] = $this->combo_model->getStatusCombo('card_status', $data['card_status_value']);
$data['card_template'] = $this->combo_model->getCardTemplateCombo('card_template', $data['card_template_value']);
$data['card_canexpire'] = $this->combo_model->getYesNoCombo('card_canexpire', $data['card_canexpire_value']);
$data['card_notify'] = $this->combo_model->getYesNoCombo('card_notify', $data['card_notify_value']);
$data['card_country'] = $this->combo_model->getCountryCombo('card_country', $data['card_country_value']);
$data['card_titleshow'] = $this->combo_model->getTitleShowCombo('card_titleshow', $data['card_titleshow_value']);
$data['card_name'] = $selected_card['name'];
$data['card_title'] = $selected_card['title'];
$data['short_title'] = $selected_card['short_title'];
$data['description'] = $selected_card['description'];
$data['background_picture'] = $selected_card['background_picture'];
$data['button1'] = $selected_card['button1'];
$data['button1_text'] = $selected_card['button1_text'];
$data['button1_action'] = $selected_card['button1_action'];
$data['card_expiration'] = $selected_card['card_expiration'];
$data['card_id'] = $card_id;
$this->load->view('admin/common/card_form', $data);
}
}
public function mytransport()
{
$data = array();
$data["images"] = array();
$this->renderAdminPage('view_mytransport', $data);
}
public function compare()
{
$this->load->library('table');
$this->table->set_template($this->template);
$show = false;
$data_from = 2; //"Marina Bay Sands, 10 Bayfront Ave, Singapore 018956";
$data_to = 3; //"97 Meyer Road, Singapore";
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$get_from = (int) $this->input->get('from');
$get_to = (int) $this->input->get('to');
if ($get_from > 0 && $get_to > 0) {
$data_from = $get_from;
$data_to = $get_to;
$_POST['from'] = $get_from;
$_POST['to'] = $get_to;
$_POST['all'] = 1;
$_POST['daterange'] = date("Y-m-1", strtotime("-2 months")) . ' - ' . date("Y-m-d");
$show = true;
}
}
$data = array();
$data["from"] = $data_from;
$data["to"] = $data_to;
$data["all"] = 1;
$data["date_from"] = date("Y-m-1", strtotime("-2 months"));
$data["date_to"] = date("Y-m-d");
if ($this->input->post() || $show) {
$data["from"] = $this->input->post('from');
$data["to"] = $this->input->post('to');
$data["all"] = (int) $this->input->post('all');
$dates = explode(' - ', $this->input->post('daterange'));
$data["date_from"] = date("Y-m-d", strtotime($dates[0]));
$data["date_to"] = date("Y-m-d", strtotime($dates[1]));
$db_from = (int) ($data["from"]);
$db_to = (int) ($data["to"]);
$q = "select distinct
a.travel_date AS \"Travel Date\",
a.travel_date_end \"Travel Date End\",
CASE WHEN a.cost IS NULL THEN a.cost_raw ELSE ROUND(a.cost,2)::TEXT END AS \"Cost\",
a.duration AS \"Duration\",
a.distance AS \"Distance\",
a.transport_provider_id as \"Transport\",
b.name as \"Provider Name\",
'No' as \"Prefil\"
from parsedemail_item a
left join transport_providers b on (b.id=a.transport_provider_id)
where a.dup_id is null and (a.cost>0 or a.cost_raw<>'') and
a.location_start_id='${db_from}' and a.location_end_id='${db_to}'";
if ($data["all"] != 1) {
$q .= " and a.travel_date between '" . $data["date_from"] . "' and '" . $data["date_to"] . "'";
}
$q .= " order by a.travel_date";
$query = $this->read_replica->query($q);
//$this->table->set_heading(array('data' => 'Count', 'style' => 'width:10px'), 'Start Location', 'End Location');
$data['past_trips'] = $this->table->generate($query);
$bulk_data = [];
$by_vendor = [];
$day_hour = [];
foreach ($query->result() as $row) {
$bulk_data[$row->{'Travel Date'}] = $row->{'Cost'};
$by_vendor[$row->{'Travel Date'}][$row->{'Transport'}] = $row->{'Cost'};
$hr = date("H", strtotime($row->{'Travel Date'}));
if (!isset($day_hour[$hr])) {
$day_hour[$hr] = [];
}
$day_hour[$hr][] = $row->{'Cost'};
}
$q = "select distinct
to_char(a.completed, 'yyyy-mm-dd HH24:MI:SS') AS \"Quote Date\",
to_char(a.created, 'yyyy-mm-dd HH24:MI:SS') \"Request Date\",
ROUND(a.cost,2) AS \"Cost\",
'N/A' AS \"Duration\",
'N/A' AS \"Distance\",
a.transport_provider_id as \"Transport\",
d.name as \"Provider Name\",
CASE WHEN a.prefill='t' THEN 'Yes' ELSE 'No' END AS \"Prefill\"
from address b, address c, quotes a
left join transport_providers d on (d.id=a.transport_provider_id)
where a.cost>0 and a.completed is not null and
b.id=a.location_start_id and c.id=a.location_end_id and
b.id='${db_from}' and c.id='${db_to}'";
if ($data["all"] != 1) {
$q .= " and a.completed::date between '" . $data["date_from"] . "' and '" . $data["date_to"] . "'";
}
$q .= " order by \"Quote Date\"";
$query = $this->read_replica->query($q);
$data['quotes'] = $this->table->generate($query);
foreach ($query->result() as $row) {
$bulk_data[$row->{'Quote Date'}] = $row->{'Cost'};
$by_vendor[$row->{'Quote Date'}][$row->{'Transport'}] = $row->{'Cost'};
$hr = date("H", strtotime($row->{'Quote Date'}));
if (!isset($day_hour[$hr])) {
$day_hour[$hr] = [];
}
$day_hour[$hr][] = $row->{'Cost'};
}
foreach ($day_hour as $hr => $val) {
asort($val);
$pk = null;
$pv = null;
foreach ($val as $k => $v) {
if ($v == $pv) {
unset($day_hour[$hr][$k]);
} else {
$pk = $k;
$pv = $v;
}
}
}
asort($day_hour);
$data["bulk_data"] = $bulk_data;
$data["by_vendor"] = $by_vendor;
$data["day_hour"] = $day_hour;
} else {
$data['past_trips'] = "";
$data['quotes'] = "";
$data["bulk_data"] = array();
$data["by_vendor"] = array();
$data["day_hour"] = array();
}
$q = "SELECT id,address FROM address ORDER BY address";
$query = $this->read_replica->query($q);
$address = [];
$address[0] = '<<All>>';
foreach ($query->result() as $row) {
$address[$row->{"id"}] = $row->{"address"} == '' ? 'Empty address' : $row->{"address"};
}
$data["address"] = $address;
$this->renderAdminPage('view_compare', $data);
}
public function country()
{
global $savvyext;
$data['storage'] = $savvyext->cfgReadChar('system.storage_url');
//echo "";
$data["message"] = "";
$search_text = "";
$whereQuery = "1=1";
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$page = is_numeric($page) ? $page : 0;
if ($this->input->post()) {
$data = $this->countryImageUpload($data);
$search_text = trim($this->input->post('search_text'));
$search_text = $this->read_replica->escape_like_str($search_text);
$whereQuery .= ' AND a.country ILIKE \'%' . $search_text . '%\'';
//$page =0;
}
$data["images"] = array();
$data["page_title"] = "Country";
$this->load->library('pagination');
$config = array();
$q = "SELECT * FROM country a LEFT JOIN card_images b ON (b.id=a.top_image) WHERE " . $whereQuery . " ORDER BY a.country";
//var_dump($q);
$query = $this->read_replica->query($q);
$config["total_rows"] = $query->num_rows();
$config["base_url"] = '/bkoadmin/country';
$config["per_page"] = 10;
$config["uri_segment"] = 3;
$config["num_links"] = 5;
$config['full_tag_open'] = "";
$config['num_tag_open'] = '