784 lines
27 KiB
PHP
784 lines
27 KiB
PHP
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Descision extends Admin_Controller {
|
|
|
|
var $template = array(
|
|
'table_open' => "<table style='background-color:aliceblue' class='table table-striped table-hover table-bordered table-condensed'>",
|
|
'thead_open' => '<thead class=\'bg-teal\'>',
|
|
'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 function index() {
|
|
|
|
}
|
|
|
|
protected function renderDescisionPage($page_name, $data) {
|
|
$this->load->view('admin/view_admin_header', $data);
|
|
$this->load->view('descision/' . $page_name, $data);
|
|
$this->load->view('admin/view_admin_footer', $data);
|
|
}
|
|
|
|
public function getValueOfDecisionLogic() {
|
|
return [
|
|
'logic' => trim($this->input->get('logic')),
|
|
'description' => trim($this->input->get('description')),
|
|
'status' => trim($this->input->get('card_status')
|
|
?? $this->input->get('status') ?? '-1'),
|
|
'survey' => trim($this->input->get('card_survey')
|
|
?? $this->input->get('survey') ?? '-1'),
|
|
'from_weight' => trim($this->input->get('from_weight')),
|
|
'to_weight' => trim($this->input->get('to_weight'))
|
|
];
|
|
}
|
|
|
|
public function setComboForDecisionLogic($params) {
|
|
$this->load->model('combo_model');
|
|
|
|
$combo['card_status'] = $this->combo_model->getStatusComboWithAll(
|
|
'card_status',
|
|
$params['status']
|
|
);
|
|
|
|
$combo['card_survey'] = $this->combo_model->getYesNoComboWithAll(
|
|
'card_survey',
|
|
$params['survey']
|
|
);
|
|
|
|
return $combo;
|
|
}
|
|
|
|
public function validateValueForDecisionLogic($params) {
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_data($params);
|
|
$this->setFormRuleForDecisionLogic();
|
|
|
|
$errors = [];
|
|
if ($this->form_validation->run() === FALSE) {
|
|
$errors = $this->form_validation->error_array();
|
|
}
|
|
return $errors;
|
|
}
|
|
|
|
public function setFormRuleForDecisionLogic() {
|
|
$this->form_validation->set_rules('survey', 'Survey', 'integer');
|
|
$this->form_validation->set_rules('from_weight', 'From Weight', 'integer');
|
|
$this->form_validation->set_rules('to_weight', 'To Weight', 'integer');
|
|
$this->form_validation->set_rules('status', 'Status', 'integer');
|
|
}
|
|
|
|
public function load_pagination($all_record, $params, $action) {
|
|
// pagination
|
|
$this->load->library('pagination');
|
|
$config["total_rows"] = count($all_record);
|
|
$config["base_url"] = base_url() . '/' . get_class($this) . '/' . $action;
|
|
$config["per_page"] = 10;
|
|
$config["uri_segment"] = 3;
|
|
$config["num_links"] = 5;
|
|
$config["suffix"] =
|
|
"?"
|
|
. http_build_query($params);
|
|
$config["first_url"] =
|
|
"/" . get_class($this) . "/{$action}/0?"
|
|
. http_build_query($params);
|
|
$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;
|
|
$offset = is_numeric($page) ? $page : 0;
|
|
|
|
return [
|
|
'link' => $this->pagination->create_links(),
|
|
'offset' => $offset,
|
|
'limit' => $config["per_page"]
|
|
];
|
|
}
|
|
|
|
public function getValueCombo($val) {
|
|
$status_value = range(0, 1);
|
|
return in_array($val, $status_value)
|
|
? $val
|
|
: '';
|
|
}
|
|
|
|
public function descisionlogic() {
|
|
$this->load->model('decision_model');
|
|
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template);
|
|
|
|
$this->table->set_heading([
|
|
'ID',
|
|
'Lorder',
|
|
'Logic',
|
|
'Description',
|
|
'Status',
|
|
'Survey',
|
|
'Weight',
|
|
'Update',
|
|
]);
|
|
|
|
$params = $this->getValueOfDecisionLogic();
|
|
|
|
$data = $this->setComboForDecisionLogic($params);
|
|
$data["page_title"] = "Descision Logic";
|
|
|
|
$params['status'] = $this->getValueCombo($params['status']);
|
|
$params['survey'] = $this->getValueCombo($params['survey']);
|
|
$params = array_filter($params, function($ele) {
|
|
return $ele !== "";
|
|
});
|
|
|
|
$errors = $this->validateValueForDecisionLogic($params);
|
|
$params = array_diff_key($params, $errors);
|
|
|
|
$data = array_merge(
|
|
$data,
|
|
$params,
|
|
$this->load_pagination(
|
|
$this->decision_model->get_decision_logic_records($params),
|
|
$params,
|
|
'descisionlogic'
|
|
)
|
|
);
|
|
$data['pos_table'] = $this->table->generate(
|
|
$this->decision_model->get_decision_logic_records(
|
|
$params,
|
|
$data['limit'],
|
|
$data['offset']
|
|
)
|
|
);
|
|
|
|
$this->renderDescisionPage('view_descisionlogic', $data);
|
|
}
|
|
|
|
public function updatelogic() {
|
|
$setting_value = (int) $this->input->get('setting_value');
|
|
$setting_id = (int) $this->input->get('setting_id');
|
|
$setting_key = (int) $this->input->get('setting_key');
|
|
if ($setting_value > 0 && $setting_id > 0 && $setting_key > 0) {
|
|
$q = "UPDATE group_decision_logic SET weight=$setting_value WHERE id = $setting_id AND decision_logic = $setting_key";
|
|
|
|
$r = $this->db->query($q);
|
|
echo 'Updated.';
|
|
}
|
|
}
|
|
|
|
public function configurenextaction() {
|
|
|
|
$data = array();
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template_small);
|
|
|
|
$decision_id = (int) $this->input->get('decision_id');
|
|
$id = (int) $this->input->get('id');
|
|
$proc = $this->input->get('proc');
|
|
|
|
$mysql = "SELECT d.id,d.target_key,g.description
|
|
FROM decision_group_action d
|
|
LEFT JOIN decision_group g ON d.target_key = g.dkey WHERE d.dkey=(SELECT dkey FROM decision_group WHERE id = $decision_id)";
|
|
$query = $this->read_replica->query($mysql);
|
|
//$this->table->set_heading( array('data' => 'ID', 'style' => 'width:10px'), 'Description', array('data' => 'ADD', 'style' => 'width:50px'));
|
|
$data['logic_list'] = $this->table->generate($query);
|
|
|
|
|
|
$data["decision_group_title"] = "A10AA01"; // based on selection
|
|
$data["card_category"] = "";
|
|
$data["decision_id"] = $decision_id;
|
|
|
|
|
|
|
|
$this->load->view('descision/view_next_action', $data);
|
|
return 0;
|
|
}
|
|
|
|
public function getValueOfMemberReport() {
|
|
return [
|
|
'decision_group' => trim($this->input->get('member')['decision_group']),
|
|
'description' => trim($this->input->get('member')['description']),
|
|
'from_count' => trim($this->input->get('member')['from_count']),
|
|
'to_count' => trim($this->input->get('member')['to_count'])
|
|
];
|
|
}
|
|
|
|
public function validateValueForMemberReport($params) {
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_data($params);
|
|
$this->setFormRuleForMemberReport();
|
|
|
|
$errors = [];
|
|
if ($this->form_validation->run() === FALSE) {
|
|
$errors = $this->form_validation->error_array();
|
|
}
|
|
return $errors;
|
|
}
|
|
|
|
public function setFormRuleForMemberReport() {
|
|
$this->form_validation->set_rules('from_count', 'From Count', 'integer');
|
|
$this->form_validation->set_rules('to_count', 'To Count', 'integer');
|
|
}
|
|
|
|
public function member_report(&$data) {
|
|
$this->load->model('decision_model');
|
|
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template);
|
|
|
|
$this->table->set_heading([
|
|
'Count',
|
|
'Decision_Group',
|
|
'Description',
|
|
]);
|
|
|
|
$params = $this->getValueOfMemberReport();
|
|
|
|
$params = array_filter($params, function($ele) {
|
|
return $ele !== "";
|
|
});
|
|
|
|
$errors = $this->validateValueForMemberReport($params);
|
|
$params = array_diff_key($params, $errors);
|
|
|
|
$data = array_merge(
|
|
$data,
|
|
$params,
|
|
$this->load_pagination(
|
|
$this->decision_model->get_member_report_records($params),
|
|
$params,
|
|
'descisionreport'
|
|
)
|
|
);
|
|
$data['member_report'] = $this->table->generate(
|
|
$this->decision_model->get_member_report_records(
|
|
$params,
|
|
$data['limit'],
|
|
$data['offset']
|
|
)
|
|
);
|
|
}
|
|
|
|
public function getValueOfRefreshReport() {
|
|
return [
|
|
'description' => trim($this->input->get('description')),
|
|
'from_count' => trim($this->input->get('from_count')),
|
|
'to_count' => trim($this->input->get('to_count'))
|
|
];
|
|
}
|
|
|
|
public function validateValueForRefreshReport($params) {
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_data($params);
|
|
$this->setFormRuleForfRefreshReport();
|
|
|
|
$errors = [];
|
|
if ($this->form_validation->run() === FALSE) {
|
|
$errors = $this->form_validation->error_array();
|
|
}
|
|
return $errors;
|
|
}
|
|
|
|
public function setFormRuleForfRefreshReport() {
|
|
$this->form_validation->set_rules('from_count', 'From Count', 'integer');
|
|
$this->form_validation->set_rules('to_count', 'To Count', 'integer');
|
|
}
|
|
|
|
public function refresh_report(&$data) {
|
|
$this->load->model('decision_model');
|
|
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template);
|
|
|
|
$this->table->set_heading([
|
|
'Description',
|
|
'Count',
|
|
]);
|
|
|
|
$params = $this->getValueOfRefreshReport();
|
|
|
|
$params = array_filter($params, function($ele) {
|
|
return $ele !== "";
|
|
});
|
|
|
|
$errors = $this->validateValueForRefreshReport($params);
|
|
$params = array_diff_key($params, $errors);
|
|
|
|
// $data = array_merge(
|
|
// $data,
|
|
// $params,
|
|
// $this->load_pagination(
|
|
// $this->decision_model->get_refresh_report_records($params),
|
|
// $params,
|
|
// 'descisionreport'
|
|
// )
|
|
// );
|
|
$data['refresh_report'] = $this->table->generate(
|
|
$this->decision_model->get_refresh_report_records(
|
|
$params,
|
|
$data['limit'],
|
|
$data['offset']
|
|
)
|
|
);
|
|
}
|
|
|
|
public function descisionreport() {
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template_small);
|
|
|
|
$data["page_title"] = "Descision Report";
|
|
$this->member_report($data);
|
|
$this->refresh_report($data);
|
|
|
|
$this->renderDescisionPage("view_descisionreport", $data);
|
|
}
|
|
|
|
/*
|
|
savvy=> select * from decision_group;
|
|
id | lorder | description | dkey | status | personality
|
|
----+--------+---------------------------+---------+--------+---------------------------
|
|
8 | 0 | New User no Data | A10AA01 | 1 | New User no Data
|
|
2 | 99 | Comfort Oriented | A300003 | 0 | Comfort Oriented
|
|
3 | 99 | Luxury Lover | A300004 | 0 | Luxury Lover
|
|
4 | 99 | Low Budget | A300005 | 0 | Low Budget
|
|
5 | 99 | Bike/Scooters Lover | A300006 | 0 | Bike/Scooters Lover
|
|
6 | 99 | Eco Friendly | A300007 | 0 | Eco Friendly
|
|
7 | 99 | Family/Group | A300008 | 0 | Family/Group
|
|
|
|
*/
|
|
|
|
public function updatePersonaltyName() {
|
|
// echo 'ameye-001';
|
|
///descision/updatePersonaltyName?id=" + id + "&pers_text=" + pers_text_value + "&dkey=" + dkey
|
|
$decision_group = $this->input->get('dkey');
|
|
$group_id = (int) $this->input->get('id');
|
|
$personality = trim($this->input->get('pers_text'));
|
|
$offers = (int)$this->input->get('pers_offers');
|
|
|
|
$update_query = 'UPDATE decision_group SET ';
|
|
|
|
if ($decision_group == '' || $group_id <= 0) {
|
|
|
|
echo "Error - Not updated";
|
|
return;
|
|
|
|
} else {
|
|
$update_query .= " personality='$personality'";
|
|
}
|
|
|
|
if ($offers <= 0) {
|
|
|
|
echo "Error - Offers must be a number greater than 0";
|
|
return;
|
|
|
|
} else {
|
|
$update_query .= " , offers_count=$offers";
|
|
}
|
|
|
|
$update_query .= " WHERE id=$group_id AND dkey='$decision_group'";
|
|
|
|
$this->db->query($update_query);
|
|
echo "Updated";
|
|
}
|
|
|
|
public function getValueOfPersonaltyCards() {
|
|
return [
|
|
'dkey' => trim($this->input->get('dkey')),
|
|
'description' => trim($this->input->get('description')),
|
|
'status' => trim($this->input->get('card_status')
|
|
?? $this->input->get('status') ?? '-1'),
|
|
'personality' => trim($this->input->get('personality'))
|
|
];
|
|
}
|
|
|
|
public function setComboForPersonaltyCards($params) {
|
|
$this->load->model('combo_model');
|
|
|
|
$combo['card_status'] = $this->combo_model->getStatusComboWithAll(
|
|
'card_status',
|
|
$params['status']
|
|
);
|
|
|
|
return $combo;
|
|
}
|
|
|
|
public function validateValueForPersonaltyCards($params) {
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_data($params);
|
|
$this->setFormRuleForPersonaltyCards();
|
|
|
|
$errors = [];
|
|
if ($this->form_validation->run() === FALSE) {
|
|
$errors = $this->form_validation->error_array();
|
|
}
|
|
return $errors;
|
|
}
|
|
|
|
public function setFormRuleForPersonaltyCards() {
|
|
$this->form_validation->set_rules('status', 'Status', 'integer');
|
|
}
|
|
|
|
public function personaltycards() {
|
|
$this->load->model('decision_model');
|
|
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template);
|
|
|
|
$this->table->set_heading([
|
|
'ID',
|
|
'Lorder',
|
|
'Dkey',
|
|
'Status',
|
|
'Description',
|
|
'Personality',
|
|
]);
|
|
|
|
$params = $this->getValueOfPersonaltyCards();
|
|
|
|
$data = $this->setComboForPersonaltyCards($params);
|
|
$data["page_title"] = "Personalty Cards";
|
|
|
|
$params['status'] = $this->getValueCombo($params['status']);
|
|
$params = array_filter($params, function($ele) {
|
|
return $ele !== "";
|
|
});
|
|
|
|
$errors = $this->validateValueForPersonaltyCards($params);
|
|
$params = array_diff_key($params, $errors);
|
|
|
|
$data = array_merge(
|
|
$data,
|
|
$params,
|
|
$this->load_pagination(
|
|
$this->decision_model->get_personalty_card_records($params),
|
|
$params,
|
|
'PersonaltyCards'
|
|
)
|
|
);
|
|
|
|
$data['pers_data'] =
|
|
$this->decision_model->get_personalty_card_records(
|
|
$params,
|
|
$data['limit'],
|
|
$data['offset']
|
|
);
|
|
|
|
$data['pers_data'] = array_map(function($ele) {
|
|
|
|
$this->table->set_heading(
|
|
"Card Title", array('data' => 'Country', 'style' => 'width:50px')
|
|
);
|
|
$ele['card_list'] =
|
|
$this->table->generate($this->decision_model->get_card_list_records($ele));
|
|
|
|
$this->table->set_heading(
|
|
"Card Title", array('data' => 'Country', 'style' => 'width:50px')
|
|
);
|
|
$ele['card_group'] =
|
|
$this->table->generate($this->decision_model->get_card_group_records($ele));
|
|
|
|
$this->table->set_heading(
|
|
"Card Title", array('data' => 'Country', 'style' => 'width:50px')
|
|
);
|
|
$ele['card_country'] =
|
|
$this->table->generate($this->decision_model->get_card_country_records($ele));
|
|
|
|
return $ele;
|
|
|
|
}, $data['pers_data']);
|
|
|
|
$this->renderDescisionPage('view_persnalitycards', $data);
|
|
}
|
|
|
|
function getCardList($dkey) {
|
|
$mysql = "SELECT c.name||' <b>'||c.button1_action||'</b><br>'||c.id||' - '|| c.title AS Card,c.card_country FROM decision_cards d LEFT JOIN main_cards c ON c.id=d.card_id WHERE d.decision_id=(SELECT id FROM decision_group WHERE dkey='$dkey') AND d.status=1 ";
|
|
$mysql .= " ORDER BY c.id DESC";
|
|
$query = $this->read_replica->query($mysql);
|
|
$this->table->set_heading( "Card Title", array('data' => 'Country', 'style' => 'width:50px'));
|
|
$data["card_list"] = $this->table->generate($query);
|
|
|
|
$mysql = "SELECT c.button1_action,count(c.id) FROM decision_cards d LEFT JOIN main_cards c ON c.id=d.card_id WHERE d.decision_id=(SELECT id FROM decision_group WHERE dkey='$dkey') AND d.status=1 ";
|
|
$mysql .= " GROUP BY c.button1_action";
|
|
$query = $this->read_replica->query($mysql);
|
|
$this->table->set_heading( "Card Title", array('data' => 'Country', 'style' => 'width:50px'));
|
|
$data["card_group"] = $this->table->generate($query);
|
|
|
|
|
|
$mysql = "SELECT c.card_country,count(c.id) FROM decision_cards d LEFT JOIN main_cards c ON c.id=d.card_id WHERE d.decision_id=(SELECT id FROM decision_group WHERE dkey='$dkey') AND d.status=1 ";
|
|
$mysql .= " GROUP BY c.card_country";
|
|
$query = $this->read_replica->query($mysql);
|
|
$this->table->set_heading( "Card Title", array('data' => 'Country', 'style' => 'width:50px'));
|
|
$data["card_country"] = $this->table->generate($query);
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getValueOfPersonaltyName() {
|
|
return [
|
|
'dkey' => trim($this->input->get('dkey')),
|
|
'description' => trim($this->input->get('description')),
|
|
'status' => trim($this->input->get('card_status')
|
|
?? $this->input->get('status') ?? '-1'),
|
|
'personality' => trim($this->input->get('personality')),
|
|
'from_offer' => trim($this->input->get('from_offer')),
|
|
'to_offer' => trim($this->input->get('to_offer'))
|
|
];
|
|
}
|
|
|
|
public function setComboForPersonaltyName($params) {
|
|
$this->load->model('combo_model');
|
|
|
|
$combo['card_status'] = $this->combo_model->getStatusComboWithAll(
|
|
'card_status',
|
|
$params['status']
|
|
);
|
|
|
|
return $combo;
|
|
}
|
|
|
|
public function validateValueForPersonaltyName($params) {
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_data($params);
|
|
$this->setFormRuleForPersonaltyName();
|
|
|
|
$errors = [];
|
|
if ($this->form_validation->run() === FALSE) {
|
|
$errors = $this->form_validation->error_array();
|
|
}
|
|
return $errors;
|
|
}
|
|
|
|
public function setFormRuleForPersonaltyName() {
|
|
$this->form_validation->set_rules('from_offer', 'From Offer', 'integer');
|
|
$this->form_validation->set_rules('to_offer', 'To Offer', 'integer');
|
|
$this->form_validation->set_rules('status', 'Status', 'integer');
|
|
}
|
|
|
|
public function personaltyname() {
|
|
|
|
$this->load->model('decision_model');
|
|
|
|
$this->load->library('table');
|
|
$this->table->set_template($this->template);
|
|
|
|
$this->table->set_heading([
|
|
'ID',
|
|
'Lorder',
|
|
'Dkey',
|
|
'Status',
|
|
'Description',
|
|
'Personality',
|
|
'Offers',
|
|
'Action'
|
|
]);
|
|
|
|
$params = $this->getValueOfPersonaltyName();
|
|
|
|
$data = $this->setComboForPersonaltyName($params);
|
|
$data["page_title"] = "Personalty Name";
|
|
|
|
$params['status'] = $this->getValueCombo($params['status']);
|
|
$params = array_filter($params, function($ele) {
|
|
return $ele !== "";
|
|
});
|
|
|
|
$errors = $this->validateValueForPersonaltyName($params);
|
|
$params = array_diff_key($params, $errors);
|
|
|
|
$data = array_merge(
|
|
$data,
|
|
$params,
|
|
$this->load_pagination(
|
|
$this->decision_model->get_personalty_name_records($params),
|
|
$params,
|
|
'personaltyname'
|
|
)
|
|
);
|
|
$data['pers_table'] = $this->table->generate(
|
|
$this->decision_model->get_personalty_name_records(
|
|
$params,
|
|
$data['limit'],
|
|
$data['offset']
|
|
)
|
|
);
|
|
|
|
$this->renderDescisionPage('view_persnalityname', $data);
|
|
}
|
|
|
|
public function addGPSTriggerLogic() {
|
|
// alert("/descision/addGPSTriggerLogic?decision_group=" + decision_group + "&address_id=" + address_id_value);
|
|
|
|
$decision_group = $this->input->get('decision_group');
|
|
$gps_address_id = (int) $this->input->get('gps_address_id');
|
|
|
|
if ($decision_group != '' && $gps_address_id != '' && $gps_address_id > 0) {
|
|
|
|
$in = array();
|
|
$in['action'] = SAVVY_BKO_GPSTRIGGER_LOGIC;
|
|
$in['decision_group'] = $decision_group;
|
|
$in['gps_address_id'] = $gps_address_id;
|
|
|
|
$out = array();
|
|
$ret = $this->savvy_api($in, $out);
|
|
$back_message = "<br> Result - " . isset($out["status_message"]) ? $out["status_message"] : '';
|
|
} else {
|
|
$back_message = "<br> Select address to add.";
|
|
}
|
|
echo $back_message;
|
|
}
|
|
|
|
public function addSurveyLogic() {
|
|
// url: "/descision/addSurveyLogic?decision_group=" + decision_group + "&survey_id_value="+survey_id_value+"&survey_ans_value=" + survey_ans_value
|
|
/*
|
|
* savvy=> SELECT * FROM group_decision_logic;
|
|
id | lorder | group_id | decision_logic | status | added | weight
|
|
----+--------+----------+----------------+--------+----------------------------+--------
|
|
3 | 0 | 2 | 3 | 1 | 2019-07-02 00:26:55.237707 | 10
|
|
1 | 0 | 8 | 1 | 0 | 2019-07-02 00:26:55.231772 | 10
|
|
6 | 0 | 8 | 3 | 0 | 2019-07-02 08:38:36.87994 | 10
|
|
5 | 0 | 8 | 1 | 0 | 2019-07-02 08:29:29.833282 | 10
|
|
|
|
*/
|
|
$back_message = '';
|
|
$decision_group = $this->input->get('decision_group');
|
|
$card_id = (int) $this->input->get('survey_id_value');
|
|
$survey_ans = $this->input->get('survey_ans_value');
|
|
|
|
if ($decision_group != '' && $card_id != '' && $survey_ans != '') {
|
|
$in = array();
|
|
$in['action'] = SAVVY_BKO_SURVEY_LOGIC;
|
|
$in['decision_group'] = $decision_group;
|
|
$in['card_id'] = $card_id;
|
|
$in['survey_ans'] = $survey_ans;
|
|
|
|
$out = array();
|
|
$ret = $this->savvy_api($in, $out);
|
|
// print_r($out);
|
|
$back_message = "<br> Result - " . isset($out["status_message"]) ? $out["status_message"] : '';
|
|
} else {
|
|
$back_message = "<br> Select Survey and Set Answer";
|
|
}
|
|
|
|
echo "Input: $decision_group $card_id $survey_ans ]" . $back_message;
|
|
}
|
|
|
|
public function descisiontree() {
|
|
$data = array();
|
|
|
|
// $this->load->library('table');
|
|
// $this->table->set_template($this->template);
|
|
// $this->load->model('combo_model');
|
|
//
|
|
// Prepare the head of the tree
|
|
$tree_data = array();
|
|
$mysql = "SELECT *,dkey AS name FROM decision_group WHERE dkey ='A10AA01'";
|
|
$query = $this->read_replica->query($mysql);
|
|
|
|
$row = $query->row_array();
|
|
|
|
if (isset($row)) {
|
|
$mysql2 = "SELECT *,dkey AS name FROM decision_group WHERE dkey IN ( SELECT target_key FROM decision_group_action WHERE dkey ='A10AA01' )";
|
|
$query2 = $this->read_replica->query($mysql2);
|
|
$dat['children'] = array();
|
|
$icc = 0;
|
|
foreach ($query2->result_array() as $row2) {
|
|
// echo $row['title'];
|
|
// echo $row['name'];
|
|
if ($icc == 0) {
|
|
$dat['children'] = $row2;
|
|
} else {
|
|
array_merge($dat['children'], $row2);
|
|
}
|
|
|
|
$icc++;
|
|
}
|
|
|
|
$row["children"] = $dat['children'];
|
|
$tree_data['A10AA01'] = $row;
|
|
} // if the root works first
|
|
|
|
$data['tree'] = $tree_data;
|
|
|
|
// print_r($data);
|
|
// foreach ($query->result_array() as $row)
|
|
// {
|
|
// echo $row['decision_group'];
|
|
// echo $row['description'];
|
|
// echo $row['body'];
|
|
// }
|
|
// $this->table->set_heading(array('data' => 'View', 'style' => 'width:50px'), 'Card', array('data' => 'Image', 'style' => 'width:120px'));
|
|
// $data["member_report"] = $this->table->generate($query);
|
|
|
|
|
|
|
|
|
|
|
|
$data["page_title"] = "Descision Tree";
|
|
|
|
|
|
$this->renderDescisionPage("view_descisiontree", $data);
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
savvy=> SELECT * FROM decision_group WHERE dkey ='dkey';
|
|
id | lorder | description | dkey | status
|
|
----+--------+-------------+------+--------
|
|
(0 rows)
|
|
|
|
savvy=> SELECT * FROM decision_group WHERE dkey ='A10AA01';
|
|
id | lorder | description | dkey | status
|
|
----+--------+------------------+---------+--------
|
|
8 | 0 | New User no Data | A10AA01 | 1
|
|
(1 row)
|
|
|
|
savvy=> SELECT * FROM decision_group_action WHERE dkey ='A10AA01';
|
|
id | dkey | target_key | status | added
|
|
----+---------+------------+--------+----------------------------
|
|
1 | A10AA01 | A10BB01 | 1 | 2019-10-20 02:01:41.079293
|
|
2 | A10AA01 | A100001 | 1 | 2019-10-20 02:01:41.085738
|
|
3 | A10AA01 | A1000A1 | 1 | 2019-10-20 02:01:41.95765
|
|
(3 rows)
|
|
|
|
savvy=> SELECT target_key FROM decision_group_action WHERE dkey ='A10AA01';
|
|
target_key
|
|
------------
|
|
A10BB01
|
|
A100001
|
|
A1000A1
|
|
(3 rows)
|
|
|
|
savvy=> SELECT target_key FROM decision_group_action WHERE dkey ='A10BB01';
|
|
target_key
|
|
------------
|
|
A1000A1
|
|
A100001
|
|
*/ |