Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
Last active March 14, 2023 18:53
Show Gist options
  • Save bryanwillis/5c1c4f5ce5a4294ea35c689e3c975a78 to your computer and use it in GitHub Desktop.
Save bryanwillis/5c1c4f5ce5a4294ea35c689e3c975a78 to your computer and use it in GitHub Desktop.
<?php
// This will need to use code/variables from here...
// https://gist.github.com/bryanwillis/5c1c4f5ce5a4294ea35c689e3c975a78#file-results-php-L230-L274
// Map Marker positioned above numbers
$result .= '<div class="steps-container">';
// Line with numbers
$result .= '<img src="https://assessment.globalcoachcenter.com/you.png" class="mapmark ' . $total_0 . $total_1 . $total_2 . $total_3 . $total_4 . $total_5 . '"><div class="line"></div>';
// New number scale with countries below - This is what I need help with
$result .= '<ul class="steps"><li></li><li></li><li></li><li></li><li></li><li></li></ul></div>';
$result .= '</div>';
<?php
function generate_pdf_shortcode() {
session_start();
$team_user_id = (isset($_GET['report_type']) && $_GET['report_type'] == 'team') ? $_GET['userresult'] : 0;
$_SESSION['c_user_id'] = ($team_user_id) ? $team_user_id : get_current_user_id();
$result .= '<style>
@page { margin: 100px 50px; }
.page_break { page-break-before: always; }
#footer ul{margin:0; padding: 0;}
#footer ul li{list-style: none;margin: 0 0 0 0;text-align:center;font-size:15px}
#footer {display: inline-block; position: fixed; left: 0px; bottom: -100px; right: 0px; height: 50px;}
.left_text{color: white; float: left; font-size: 20px; width: 60%; padding: 35px 0 0 50px;}
.logo_right{float: right; width: 20%}
#header {display: inline-block; position: fixed; left: -50px; top: -100px; right: -40px; height: 65px; width: 105%;}
.left_right{width: 100%; display: inline-block; clear:both; margin: 5px 0 0 0; height: 30px;}
.left_right .left{width: 50%; float: left; text-align:left;}
.left_right .right{width: 40%; float: right; text-align:right; }
.good{color: red}
.question_no h1{font-size: 24px; margin-bottom:0;}
table{padding: 0 0 15px 0; width:100%; border-collapse: collapse;}
table, th, td {border: 1px solid #555; width: 13%;text-align: center; font-size: 10px; padding: 3px 0;}
td.active{background-color: #606060;}th.active{background-color: #0496e4;}
.question_description_box {
background-color: #ececec;
border-radius: 20px;
padding: 5px 20px 5px 20px;
font-size:12px;
}
</style>';
$result .= '<style>.question_content{font-size: 16px;}</style>';
$result .= '<div id="header" style="background: #0496e4; height: 90px;">
<div class="left_text">Your Individual Cultural Blueprint Indicator Report</div><div class="logo_right"><img style="padding-top: 16px;" src="https://assessment.globalcoachcenter.com/wp-content/themes/power/images/ICBI_Logo_White_Globe190.png" width="111" alt="ICBI"></div>
</div>
<div id="footer"><ul><li>Individual Cultural Blueprint Indicator™, All Rights Reserved</li></ul></div>
';
// Start of intro page
$user_info = get_userdata(($team_user_id) ? $team_user_id : get_current_user_id());
$first_name = $user_info->first_name;
$last_name = $user_info->last_name;
$result .= '<h1 style="margin-bottom: 20px; padding-top:50px; text-align:left; width: 100%; font-size: 28px;" class="result_title">Introduction</h1>';
$result .= '<p style="margin-bottom: 20px;">Your ICBI™(Individual Cultural Blueprint Indicator) report consists of 16 orientations of cultural differences. Based on your answers, your scores represent different points on a scale from 0 to 5 on each of the orientations. There are no right or wrong answers. The report will help you understand where you have gaps between other team members and countries you selected for comparison. </p>';
$result .= '<p style="margin-bottom: 20px;">Please note that your profile might be quite different from the typical profile of your home country. Please keep that difference in mind as you look at the other member and country profiles. While cultures and countries have a typical profile, individuals rarely have a typical profile. Use this report as a guideline for building self-awareness and other cultural awareness, but not as an absolute truth. The ICBI™ is designed to help individuals and teams to increase productivity, improve relationships, and promote efficient communications within multi-cultural environments.</p>';
$result .= '<p style="margin-bottom: 20px;">The preference of the majority of the people in the country (countries) you are comparing yourself to is plotted in the row(s) below your preference. Circle or note significant gaps between your personal cultural preferences and other preferences. With others or a coach/trainer, brainstorm strategies on how to bridge the gaps. </p>';
$result .= '<div style="height: 350px; width: 100%; display: block"></div>';
$result .= '<div class="page_break"></div>';
// End of intro page
$result .= '<div>&nbsp;</div><h2 style="margin-bottom: 20px; text-align:center; width: 100%; font-size: 18px;" >Personal Cultural Blueprint for ' . $user_info->first_name . ' ' . $user_info->last_name . '</h2>';
$result .= '<style>'
. '.f_first_last td{background-color: #fff;}.f_question_results td{background-color: #fff;}.f_question_results .active{background-color:#0496e4; color:white;}.yellow_bg .active{background-color: #282359 !important; color:white;}'
. ''
. '</style>';
global $wpdb;
$table_questions = $wpdb->prefix . "questions";
$query = "SELECT * FROM $table_questions ORDER BY id DESC";
$get_data = $wpdb->get_results("SELECT * FROM $table_questions ORDER BY id DESC");
// first table start
$result .= '<div class="question_ans_box">';
$result .= '<table class="f_question_ans_box" style="width:100%">';
foreach ($get_data as $k => $data) {
$k = $k + 1;
$c_user = ($team_user_id) ? $team_user_id : get_current_user_id();
$table_question_answers = $wpdb->prefix . "question_answers";
$query = "SELECT * FROM $table_question_answers ORDER BY id DESC";
$question_answers = $wpdb->get_results("SELECT * FROM $table_question_answers WHERE question_id=$data->id");
$correct = 0;
foreach ($question_answers as $question_answer) {
$table_user_quiz = $wpdb->prefix . "user_quiz";
$user_quiz = $wpdb->get_row("SELECT * FROM $table_user_quiz WHERE question_ans_id = $question_answer->id AND user_id=$c_user ORDER BY id DESC");
if ($user_quiz) {
if ($user_quiz->answer == 1 && $question_answer->ane_true == 1) {
$correct = $correct + 1;
} else if ($user_quiz->answer == 0 && $question_answer->ane_true == 0) {
$correct = $correct + 1;
}
} else {
// echo 'not found';
}
}
$total_0 = '';
$total_1 = '';
$total_2 = '';
$total_3 = '';
$total_4 = '';
$total_5 = '';
if ($correct == 0) {
$total_0 = 'active';
} else if ($correct == 1) {
$total_1 = 'active';
} else if ($correct == 2) {
$total_2 = 'active';
} else if ($correct == 3) {
$total_3 = 'active';
} else if ($correct == 4) {
$total_4 = 'active';
} else if ($correct == 5) {
$total_5 = 'active';
} else {
$total_0 = 'active';
}
$result .= '<style>'
. '.f_first_last td{background-color: #fff;}.f_question_results td{background-color: #fff;}.f_question_results .active{background-color:#0496e4; color:white;}'
. ''
. '</style>';
$result .= '<tr class="f_veriable">';
$result .= '<td colspan="6" style="text-align:left; font-weight: 700; padding: 1px 0 1px 10px; background-color: #e4e4e4;"><a style="text-decoration: none; color: #000000; display: block;" href="#' . str_replace(' ', '', strtolower($data->veriable)) . '"><div>' . $k . '. <span style="text-decoration: underline; color: #0496e4;">' . $data->veriable . '</span></div></a></td>';
$result .= '</tr>';
$result .= '<tr class="f_first_last">';
$result .= '<td colspan="3" style="text-align: left; padding: 1px 0 1px 10px">' . $data->first_text . '</td>';
$result .= '<td colspan="3" style="text-align: right; padding: 1px 10px 1px 0px">' . $data->last_text . '</td>';
$result .= '</tr>';
$result .= '<tr class="f_question_results">';
$result .= '<td class="' . $total_0 . '" style="padding: 1px 10px 1px 0px">0</td>';
$result .= '<td class="' . $total_1 . '" style="padding: 1px 10px 1px 0px">1</td>';
$result .= '<td class="' . $total_2 . '" style="padding: 1px 10px 1px 0px">2</td>';
$result .= '<td class="' . $total_3 . '" style="padding: 1px 10px 1px 0px">3</td>';
$result .= '<td class="' . $total_4 . '" style="padding: 1px 10px 1px 0px">4</td>';
$result .= '<td class="' . $total_5 . '" style="padding: 1px 10px 1px 0px">5</td>';
$result .= '</tr>';
}
$result .= '</table>';
$result .= '</div><div class="page_break"></div>';
// first table end
// start of question description and results table
$total_count = count($get_data);
foreach ($get_data as $k => $data) {
$k = $k + 1;
$c_user = ($team_user_id) ? $team_user_id : get_current_user_id();
$table_question_answers = $wpdb->prefix . "question_answers";
$query = "SELECT * FROM $table_question_answers ORDER BY id DESC";
$question_answers = $wpdb->get_results("SELECT * FROM $table_question_answers WHERE question_id=$data->id");
$correct = 0;
foreach ($question_answers as $question_answer) {
$table_user_quiz = $wpdb->prefix . "user_quiz";
$user_quiz = $wpdb->get_row("SELECT * FROM $table_user_quiz WHERE question_ans_id = $question_answer->id AND user_id=$c_user ORDER BY id DESC");
if ($user_quiz) {
if ($user_quiz->answer == 1 && $question_answer->ane_true == 1) {
$correct = $correct + 1;
} else if ($user_quiz->answer == 0 && $question_answer->ane_true == 0) {
$correct = $correct + 1;
}
} else {
// echo 'not found';
}
}
$total_0 = '';
$total_1 = '';
$total_2 = '';
$total_3 = '';
$total_4 = '';
$total_5 = '';
if ($correct == 0) {
$total_0 = 'active';
} else if ($correct == 1) {
$total_1 = 'active';
} else if ($correct == 2) {
$total_2 = 'active';
} else if ($correct == 3) {
$total_3 = 'active';
} else if ($correct == 4) {
$total_4 = 'active';
} else if ($correct == 5) {
$total_5 = 'active';
} else {
$total_0 = 'active';
}
$result .= '<style>'
. '.question_content > table:first-child {width: 100%;border: 0px solid #ffffff;border-collapse: collapse;padding: 5px;}.question_content > table:first-child th {border: 0px solid #ffffff;padding: 5px;background: #0496e4;color: #ffffff;font-size: 17px;vertical-align: middle;height: 25px;}.question_content > table:first-child td {border: 0px solid #ffffff;text-align: left;padding: 5px;background: #ffffff;color: #313030;font-size: 15px;}div.question_content > table:nth-child(2) {width: 100%;border-collapse: collapse;border-style: hidden;padding: 5px;font-size: 17px;vertical-align: middle;}div.question_content > table:nth-child(2) thead, div.question_content > table:nth-child(2) thead > tr, div.question_content > table:nth-child(2) thead > tr td {vertical-align: middle !important;}div.question_content > table:nth-child(2) th {border: 8px solid #ffffff;background: #0496e4;color: #ffffff;font-size: 17px;vertical-align: middle;height: 25px;padding: 0px 5px 5px 5px;}div.question_content > table:nth-child(2) td {border: 8px solid #ffffff;text-align: left;padding: 5px;background: #ffffff;color: #313030;font-size: 15px;vertical-align: text-top;}'
. '</style>';
$result .= '<div class="question_ans_box">';
$result .= '<div class="question_no">';
$result .= '<h1 style="font-size: 20px" id="' . str_replace(' ', '', strtolower($data->veriable)) . '"><strong>' . $k . '. </strong>' . $data->veriable . '</h1>';
$result .= '<div>&nbsp;</div><div class="question_content">' . $data->description . '</div>';
$result .= '</div>';
$result .= '<table style="width:100%">';
$result .= '<tbody>';
$result .= '<tr class="f_veriable">';
$result .= '<td colspan="7" style="text-align:left; font-weight: 700; padding: 1px 0 1px 10px; background-color: #e4e4e4">' . $k . '. ' . $data->veriable . '</td>';
$result .= '</tr>';
$result .= '<tr class="f_first_last">';
$result .= '<td></td>';
$result .= '<td colspan="3" style="text-align: left; padding: 1px 0 1px 10px">' . $data->first_text . '</td>';
$result .= '<td colspan="3" style="text-align: right; padding: 1px 10px 1px 0px">' . $data->last_text . '</td>';
$result .= '</tr>';
$result .= '</tbody>';
$result .= '<thead>';
$result .= '<tr>';
$result .= '<th class="country" style="padding: 1px 10px 1px 0px">' . $user_info->first_name . ' ' . $user_info->last_name . '</th>';
$result .= '<th class="' . $total_0 . '" style="padding: 1px 10px 1px 0px">0</th>';
$result .= '<th class="' . $total_1 . '" style="padding: 1px 10px 1px 0px">1</th>';
$result .= '<th class="' . $total_2 . '" style="padding: 1px 10px 1px 0px">2</th>';
$result .= '<th class="' . $total_3 . '" style="padding: 1px 10px 1px 0px">3</th>';
$result .= '<th class="' . $total_4 . '" style="padding: 1px 10px 1px 0px">4</th>';
$result .= '<th class="' . $total_5 . '" style="padding: 1px 10px 1px 0px">5</th>';
$result .= '</tr>';
$result .= '</thead>';
/*Start Team*/
/*Team end*/
global $wpdb;
$table_name = $wpdb->prefix . "country_answer";
$query = "SELECT * FROM $table_name ORDER BY id DESC";
if (isset($_GET['country'])) {
$country_list = $_GET['country'];
$get_data = $wpdb->get_results("SELECT * FROM $table_name WHERE question_id=$data->id AND country_name IN ( '" . implode("', '", $country_list) . "' ) ORDER BY id DESC");
foreach ($get_data as $data) {
$total_0 = '';
$total_1 = '';
$total_2 = '';
$total_3 = '';
$total_4 = '';
$total_5 = '';
if ($data->total == 0) {
$total_0 = 'active';
} else if ($data->total == 1) {
$total_1 = 'active';
} else if ($data->total == 2) {
$total_2 = 'active';
} else if ($data->total == 3) {
$total_3 = 'active';
} else if ($data->total == 4) {
$total_4 = 'active';
} else if ($data->total == 5) {
$total_5 = 'active';
} else {
$total_0 = 'active';
}
$result .= '<tbody>';
$result .= '<tr>';
if ($data->country_name == "United Arab Emirates") {
$country_name = 'UAE';
} else {
$country_name = $data->country_name;
}
$result .= '<td class="country" style="padding: 1px 10px 1px 0px">' . $country_name . '</td>';
$result .= '<td class="' . $total_0 . '" style="padding: 1px 10px 1px 0px">0</td>';
$result .= '<td class="' . $total_1 . '" style="padding: 1px 10px 1px 0px">1</td>';
$result .= '<td class="' . $total_2 . '" style="padding: 1px 10px 1px 0px">2</td>';
$result .= '<td class="' . $total_3 . '" style="padding: 1px 10px 1px 0px">3</td>';
$result .= '<td class="' . $total_4 . '" style="padding: 1px 10px 1px 0px">4</td>';
$result .= '<td class="' . $total_5 . '" style="padding: 1px 10px 1px 0px">5</td>';
$result .= '</tr>';
$result .= '</tbody>';
}
}
$result .= '</table>';
$result .= '</div>';
if ($k < $total_count) {
$result .= '<div class="page_break"></div>';
}
}
return $result;
}
add_shortcode('generate_pdf_shortcode', 'generate_pdf_shortcode');
<?php
global $wpdb;
$table_name = $wpdb->prefix . "country_answer";
$query = "SELECT * FROM $table_name ORDER BY id DESC";
if (isset($_GET['country'])) {
$country_list = $_GET['country'];
$get_data = $wpdb->get_results("SELECT * FROM $table_name WHERE question_id=$data->id AND country_name IN ( '" . implode("', '", $country_list) . "' ) ORDER BY id DESC");
foreach ($get_data as $data) {
$total_0 = '';
$total_1 = '';
$total_2 = '';
$total_3 = '';
$total_4 = '';
$total_5 = '';
if ($data->country_name == "United Arab Emirates") {
$country_name = 'UAE';
} else {
$country_name = $data->country_name;
}
if ($data->total == 0) {
$total_0 = $country_name;
} else if ($data->total == 1) {
$total_1 = $country_name;
} else if ($data->total == 2) {
$total_2 = $country_name;
} else if ($data->total == 3) {
$total_3 = $country_name;
} else if ($data->total == 4) {
$total_4 = $country_name;
} else if ($data->total == 5) {
$total_5 = $country_name;
} else {
$total_0 = $country_name;
}
}
}
$result .= '<table style="width:100%">';
$result .= '<tbody>';
$result .= '<tr class="f_veriable">';
$result .= '<td colspan="7" style="text-align:left; font-weight: 700; padding: 1px 0 1px 10px; background-color: #e4e4e4">' . $k . '. ' . $data->veriable . '</td>';
$result .= '</tr>';
$result .= '<tr class="f_first_last">';
$result .= '<td></td>';
$result .= '<td colspan="3" style="text-align: left; padding: 1px 0 1px 10px">' . $data->first_text . '</td>';
$result .= '<td colspan="3" style="text-align: right; padding: 1px 10px 1px 0px">' . $data->last_text . '</td>';
$result .= '</tr>';
$result .= '</tbody>';
$result .= '<thead>';
$result .= '<tr>';
$result .= '<th class="country" style="padding: 1px 10px 1px 0px">' . $user_info->first_name . ' ' . $user_info->last_name . '</th>';
$result .= '<th class="' . $total_0 . '" style="padding: 1px 10px 1px 0px">0</th>';
$result .= '<th class="' . $total_1 . '" style="padding: 1px 10px 1px 0px">1</th>';
$result .= '<th class="' . $total_2 . '" style="padding: 1px 10px 1px 0px">2</th>';
$result .= '<th class="' . $total_3 . '" style="padding: 1px 10px 1px 0px">3</th>';
$result .= '<th class="' . $total_4 . '" style="padding: 1px 10px 1px 0px">4</th>';
$result .= '<th class="' . $total_5 . '" style="padding: 1px 10px 1px 0px">5</th>';
$result .= '</tr>';
$result .= '</thead>';
}
}
$result .= '</table>';
$result .= '</div>';
if ($k < $total_count) {
$result .= '<div class="page_break"></div>';
}
}
return $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment