Forum


Replies: 7   Views: 4083
Xml warnings
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by liam.whan  · 11-04-2013 - 12:13

[code]
<?php

require 'phpdocx_pro/classes/CreateDocx.inc';
include 'loggedin_header.php';
include 'app_frame.php';
require_once 'config.php';
require_once 'MailClass.inc';

if (isset($_SESSION)) {
//collect session variables
$user_id = $_SESSION['user_id'];
$user_data_id = $_SESSION['user_data_id'];
$name = get_employee_name($user_id, $mysqli);
$username = $_SESSION['username'];
$employee_id = strval($_SESSION['employee_id']);
$org_unit = get_org_unit($user_data_id, $cfmysqli);
$manager = get_manager_id($user_data_id, $cfmysqli);
$manager_email = get_manager_email($user_data_id, $cfmysqli);
$position_title = get_position_title($user_data_id, $cfmysqli);
$long_names = get_long_names_array($cfmysqli);
$dev_long_names = get_dev_long_names_array($user_data_id, $cfmysqli);
$sig_dev_long = get_sig_dev_array($user_data_id, $cfmysqli);
$conf_array = get_conf_array($user_data_id, $cfmysqli);
$some_dev_long = get_some_dev_array($user_data_id, $cfmysqli);
$vak_array = get_vak($user_data_id, $cfmysqli);
$learn_array = get_learn_array($user_data_id, $cfmysqli);
$top_five_array = get_top_five_array($user_data_id, $cfmysqli);
$top = "<p style='font-family: Trebuchet MS; font-size: 23px; color: #144C99;'>";
$element = get_element_level_array($cfmysqli);
$mgmt_element = get_mgmt_element_level_array($cfmysqli);
$behaviour = get_behavioural_array($cfmysqli);
$mgmt_behaviour = get_mgmt_behavioural_array($cfmysqli);
$cap_info_array = get_cap_info_array($cfmysqli);
$last_parent = "";
foreach ($conf_array as $key => $value) {

if ($cap_info_array[$key]['parent'] != $last_parent) {
$a_parent_key = $cap_info_array[$key]['parent'];
$t_values[$a_parent_key]['conf'][$key] = $value;
} else {
$t_values[$a_parent_key]['conf'][$key] = $value;
}
$last_parent = $cap_info_array[$key]['parent'];
}

foreach ($some_dev_long as $key => $value) {
$parentKey = $key . "_parent";
if ($dev_long_names[$parentKey] != $last_parent) {
//$a_parent_key = strtolower(str_replace(" ", "_", $dev_long_names[$parentKey]));
$a_parent_key = $dev_long_names[$parentKey];
$t_values[$a_parent_key]['some_dev'][$key] = $value;
} else {
$t_values[$a_parent_key]['some_dev'][$key] = $value;
}
$last_parent = $dev_long_names[$parentKey];
}



$last_parent = "";
foreach ($sig_dev_long as $key => $value) {
$parentKey = $key . "_parent";
if ($dev_long_names[$parentKey] != $last_parent) {
//$a_parent_key = strtolower(str_replace(" ", "_", $dev_long_names[$parentKey]));
$a_parent_key = $dev_long_names[$parentKey];
$t_values[$a_parent_key]['sig_dev'][$key] = $value;
} else {
$t_values[$a_parent_key]['sig_dev'][$key] = $value;
}
$last_parent = $dev_long_names[$parentKey];
}


foreach ($t_values as $key => $array) {
$parent_count[$key] = count($array['conf']) + count($array['sig_dev']) + count($array['some_dev']);
}


$table = "<table style='width:1050px; border: #ffffff 1px solid;'>
<tr>
<th style='background-color: #144c99;color: #ffffff;border: #ffffff 1px solid;font-size: 20px;'>Capability</th>
<th style='background-color: #144c99;color: #ffffff;border: #ffffff 1px solid;font-size: 20px;'>Confident</th>
<th style='background-color: #144c99;color: #ffffff;border: #ffffff 1px solid;font-size: 20px;'>Needs Some Development</th>
<th style='background-color: #144c99;color: #ffffff;border: #ffffff 1px solid;font-size: 20px;'>Needs Significant Development</th>
</tr>";
$count = 1;
$last_parent = "";
foreach ($t_values as $key => $array) {
if (isEven($count)) {
$td_style = " style='background-color: #144c99;color: #ffffff;border: #ffffff 1px solid;'";
$p_style = " style='background-color: #144c99;color: #ffffff;border: #ffffff 1px solid;font-size: 20px;'";
} else {
$td_style = " style='background-color: #6BA9ff;color: #ffffff;border: #ffffff 1px solid;'";
$p_style = " style='background-color: #6BA9ff;color: #ffffff;border: #ffffff 1px solid;font-size: 20px;'";
}

if ($key != $last_parent) {
$rowspan = $parent_count[$key];

$table .= "<tr>";
$table .= "<td" . $p_style . ">$key</td>";
$table .= "<td" . $td_style . ">";

if (isset($array['conf'])) {
foreach ($array['conf'] as $confvalue) {
$table .= "• " . $confvalue . "<br/>";
}
}
$table .="</td>";
$table .= "<td" . $td_style . ">";
if (isset($array['some_dev'])) {
foreach ($array['some_dev'] as $somevalue) {
$table .= "• " . $somevalue . "<br/>";
}
}
$table .= "</td>";
$table .= "<td" . $td_style . ">";
if (isset($array['sig_dev'])) {
foreach ($array['sig_dev'] as $sigvalue) {
$table .= "• " . $sigvalue . "<br/>";
}
}
$table .="</td>";
$table .= "</tr>";
}
$count++;
}
$table .= "</table>";

$i = 1;

foreach ($top_five_array as $key => $value) {
$levelKey = $key . "_level";
$detailsKey = "top" . $i;
$parentKey = $key . "_parent";
$topinner['short_name'] = $key;
$topinner['parent'] = "<p style='font-size:16px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>" . $dev_long_names[$parentKey] . "</p>";
$level = $dev_long_names[$levelKey];
$topinner['long_name'] = "<p style='font-size:18px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>" . strtoupper($value) . "<br/> Level $level</p>";
if (!is_mgmt_level($key, $mgmt_element)) {
$eleLevel = "level" . $level;
$topinner['level'] = "<p style='font-size:16px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>" . $level . "</p>";
$topinner['summary'] = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>" . $element[$key][$eleLevel] . "</p>";
$topinner['behaviour'] = explode(".", substr($behaviour[$key][$eleLevel], 0, strlen($behaviour[$key][$eleLevel]) - 1));
} else {
$eleLevel = strtolower($level);
$topinner['level'] = "<p style='font-size:16px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>" . $level . "</p>";
$topinner['summary'] = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>" . $mgmt_element[$key][$eleLevel] . "</p>";
$topinner['behaviour'] = explode(".", substr($mgmt_behaviour[$key][$eleLevel], 0, strlen($mgmt_behaviour[$key][$eleLevel]) - 1));
}



$j = 0;
foreach ($topinner['behaviour'] as $innervalue) {
$topinner['behaviour'][$j] = str_replace("?", "", $innervalue);
$j++;
}
$topdetails[$detailsKey] = $topinner;
$top .= $i . ". $value<br/>";
$i++;
}
$top .= "</p>";
$sig_dev_array = get_sig_dev_array($user_data_id, $cfmysqli);
$sig_dev = "<p style='font-size:14px; color: #144C99;font-family: Trebuchet MS; line-height: 1.9em; text-align: center;'>";

$lastParent = "";
foreach ($sig_dev_array as $key => $value) {
$parentKey = $key . "_parent";
if ($dev_long_names[$parentKey] != $lastParent) {

}

$sig_dev .= "• $value<br />";
}
$sig_dev .= "</p>";

$some_dev_array = get_some_dev_array($user_data_id, $cfmysqli);
$some_dev = "<p style='font-size:14px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($some_dev_array as $value) {
$some_dev .= "• $value<br />";
}
$some_dev .= "</p>";

foreach ($some_dev_array as $value) {

}




$conf_array = get_conf_array($user_data_id, $cfmysqli);
$conf = "<p style='font-size:14px; color: #144C99;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($conf_array as $value) {
$conf .= "• $value<br />";
}
$conf .= "</p>";
$vak_result = "<span style='font-size:22px; font-family: Trebuchet MS; color: #144C99;'>" . $vak_array['name'] . "</span>";
$vak_summary = "<p style='font-size: 20px; font-family: Trebuchet MS; color: #6BA9FF;'>";
$vak_summary .= $vak_array['summary'] . "</p>";
$vak_text = "<span style='font-size:14px; font-family: Trebuchet MS;color: #144C99;'>" . $vak_array['desc'] . "</span><br/>";
$vak_longtext = "<span style='font-size:14px; font-family: Trebuchet MS;color: #144C99;'>" . $vak_array['long_text'] . "</span>";
$alresult = "<p style='font-size:20px; font-family: Trebuchet MS; color: #144C99;'>" . $learn_array['long_name'] . "</p>";
$alsummary = "<p style='font-size: 20px; font-family: Trebuchet MS; color: #6BA9FF;'>" . $learn_array['summary'] . "</p>";
$bullets_array = explode(',', $learn_array['bullet']);
$albullet1 = "<ul style='font-size:14px; color: #144C99;font-family: Trebuchet MS;'>";
$albullet2 = "<ul style='font-size:14px; color: #144C99;font-family: Trebuchet MS;'>";
$count = 1;
foreach ($bullets_array as $value) {
if ($count < 8) {
$albullet1 .= "<li>$value</li>";
} else {
$albullet2 .= "<li>$value</li>";
}
$count++;
}
if ($count <= 8) {
$albullet2 = "";
}
$dir = "./plans/";
$docx = new CreateDocx();
$date = date("d-m-Y");
$doctitle = $username . "_" . $date;
$docName = $dir . $doctitle;
$docx->addTemplate('header.docx');

$vak_count = get_vak_count($user_data_id, $cfmysqli);

$vak_legend = array(
'legend' => array('Visual', 'Auditory', 'Kinaesthetic'),
'VAK Score' => array($vak_count['vak_visual'], $vak_count['vak_kin'], $vak_count['vak_auditory'])
);

$vak_paramsChart = array(
'data' => $vak_legend,
'type' => 'bar3DChart',
'title' => 'VAK Learning Style Overview',
'legendpos' => 'b',
'legendoverlay' => 1,
'border' => 1,
'cornerX' => 20,
'cornerY' => 20,
'cornerP' => 30,
'color' => 2,
'textWrap' => 0,
'sizeX' => 12,
'sizeY' => 10,
'hgrid' => 0,
'vgrid' => 0,
'jc' => 'center',
'showPercent' => 1,
'font' => 'Trebuchet MS'
);

$al_count = get_learn_count($user_data_id, $cfmysqli);

$al_legends =
array(
'legend' => array('Why', 'What', 'How', 'What If'),
'Score' => array($al_count['why'], $al_count['what'], $al_count['how'], $al_count['what_if'])
);

$al_paramsChart = array(
'data' => $al_legends,
'type' => 'col3DChart',
'title' => 'Adult Learning Styles Overview',
'legendpos' => 'b',
'legendoverlay' => 1,
'border' => 1,
'cornerX' => 20,
'cornerY' => 20,
'cornerP' => 30,
'color' => 2,
'textWrap' => 0,
'sizeX' => 12,
'sizeY' => 11,
'hgrid' => 0,
'vgrid' => 0,
'jc' => 'center',
'showPercent' => 1,
'font' => 'Trebuchet MS'
);


$conf_count = cap_count($user_data_id, $cfmysqli);
$needs_some_count = cap_count($user_data_id, $cfmysqli, "some");
$needs_sig_count = cap_count($user_data_id, $cfmysqli, "sig");
$legends = array(
'Confident' => array($conf_count),
'Some Development' => array($needs_some_count),
'Significant Development' => array($needs_sig_count)
);
$paramsChart =
array(
'data' => $legends,
'type' => 'pie3DChart',
'title' => 'Capability Overview',
'legendpos' => 'b',
'legendoverlay' => 0,
'border' => 1,
'cornerX' => 20,
'cornerY' => 20,
'cornerP' => 30,
'color' => 2,
'textWrap' => 0,
'sizeX' => 12,
'sizeY' => 10,
'jc' => 'center',
'showPercent' => 0,
'font' => 'Trebuchet MS'
);

$topb1 = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($topdetails['top1']['behaviour'] as $bullet) {
$topb1 .= "• " . $bullet . "<br/><br/>";
}
$topb1 .= "</p>";
$topb2 = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($topdetails['top2']['behaviour'] as $bullet) {
$topb2 .= "• " . $bullet . "<br/><br/>";
}
$topb2 .= "</p>";
$topb3 = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($topdetails['top3']['behaviour'] as $bullet) {
$topb3 .= "• " . $bullet . "<br/><br/>";
}
$topb3 .= "</p>";
$topb4 = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($topdetails['top4']['behaviour'] as $bullet) {
$topb4 .= "• " . $bullet . "<br/><br/>";
}
$topb4 .= "</p>";
$topb5 = "<p style='font-size:12px; color: #ffffff;font-family: Trebuchet MS;line-height: 1.9em; text-align: center;'>";
foreach ($topdetails['top5']['behaviour'] as $bullet) {
$topb5 .= "• " . $bullet . "<br/><br/>";
}
$topb5 .= "</p>";

$prep = "Prepared for " . $name;

$docx->addTemplateChart('CHART', $paramsChart);
$docx->addTemplateChart('ALCHART', $al_paramsChart);
$docx->addTemplateChart('VAKCHART', $vak_paramsChart);
$docx->addTemplateVariable('NAME', $name);
$docx->addTemplateVariable('EMP', $employee_id);
$docx->addTemplateVariable('POS', $position_title);
$docx->addTemplateVariable('ORGUNIT', $org_unit);
$docx->addTemplateVariable('DATE', $date);
$docx->addTemplateVariable('PREP', $prep);
$docx->replaceTemplateVariableByHTML('TOP', 'block', $top);
$docx->replaceTemplateVariableByHTML('TABLE1', 'block', $table);
$docx->replaceTemplateVariableByHTML('TOPUPPER1', 'inline', $topdetails['top1']['parent']);
$docx->replaceTemplateVariableByHTML('TOP1', 'inline', $topdetails['top1']['long_name']);
$docx->replaceTemplateVariableByHTML('TOPLEVEL1', 'inline', $topdetails['top1']['level']);
$docx->replaceTemplateVariableByHTML('TOPSUMM1', 'inline', $topdetails['top1']['summary']);
$docx->replaceTemplateVariableByHTML('TOPBEHAV1', 'inline', $topb1);
$docx->replaceTemplateVariableByHTML('TOPUPPER2', 'inline', $topdetails['top2']['parent']);
$docx->replaceTemplateVariableByHTML('TOP2', 'inline', $topdetails['top2']['long_name']);
$docx->replaceTemplateVariableByHTML('TOPLEVEL2', 'inline', $topdetails['top2']['level']);
$docx->replaceTemplateVariableByHTML('TOPSUMM2', 'inline', $topdetails['top2']['summary']);
$docx->replaceTemplateVariableByHTML('TOPBEHAV2', 'inline', $topb2);
$docx->replaceTemplateVariableByHTML('TOPUPPER3', 'inline', $topdetails['top3']['parent']);
$docx->replaceTemplateVariableByHTML('TOP3', 'inline', $topdetails['top3']['long_name']);
$docx->replaceTemplateVariableByHTML('TOPLEVEL3', 'inline', $topdetails['top3']['level']);
$docx->replaceTemplateVariableByHTML('TOPSUMM3', 'inline', $topdetails['top3']['summary']);
$docx->replaceTemplateVariableByHTML('TOPBEHAV3', 'inline', $topb3);
$docx->replaceTemplateVariableByHTML('TOPUPPER4', 'inline', $topdetails['top4']['parent']);
$docx->replaceTemplateVariableByHTML('TOP4', 'inline', $topdetails['top4']['long_name']);
$docx->replaceTemplateVariableByHTML('TOPLEVEL4', 'inline', $topdetails['top4']['level']);
$docx->replaceTemplateVariableByHTML('TOPSUMM4', 'inline', $topdetails['top4']['summary']);
$docx->replaceTemplateVariableByHTML('TOPBEHAV4', 'inline', $topb4);
$docx->replaceTemplateVariableByHTML('TOPUPPER5', 'inline', $topdetails['top5']['parent']);
$docx->replaceTemplateVariableByHTML('TOP5', 'inline', $topdetails['top5']['long_name']);
$docx->replaceTemplateVariableByHTML('TOPLEVEL5', 'inline', $topdetails['top5']['level']);
$docx->replaceTemplateVariableByHTML('TOPSUMM5', 'inline', $topdetails['top5']['summary']);
$docx->replaceTemplateVariableByHTML('TOPBEHAV5', 'inline', $topb5);
$docx->replaceTemplateVariableByHTML('VAKRESULT', 'block', $vak_result);
$docx->replaceTemplateVariableByHTML('VAKSUMMARY', 'inline', $vak_summary);
$docx->replaceTemplateVariableByHTML('VAKTEXT', 'inline', $vak_text);
$docx->replaceTemplateVariableByHTML('VAKLONGTEXT', 'inline', $vak_longtext);
$docx->replaceTemplateVariableByHTML('ALRESULT', 'inline', $alresult);
$docx->replaceTemplateVariableByHTML('ALSUMMARY', 'inline', $alsummary);
$docx->replaceTemplateVariableByHTML('ALBULLET1', 'block', $albullet1);
$docx->replaceTemplateVariableByHTML('ALBULLET2', 'block', $albullet2);
$docx->replaceTemplateVariableByHTML('CONF', 'block', $conf);
$docx->replaceTemplateVariableByHTML('SOMEDEV', 'block', $some_dev);
$docx->replaceTemplateVariableByHTML('SIGDEV', 'block', $sig_dev);
$docx->createDocx($docName);
$_SESSION['document_name'] = $docName . ".docx";
$self_add = substr($docName, 1) . ".docx";
$root = 'https://myadhclearningplan.com.au';
$self_assess = 1;
$self_address = $root . $self_add;
if ($stmt = $cfmysqli->prepare("UPDATE user_data SET self_assess=?,self_file_address=? WHERE id=?")) {
$stmt->bind_param("isi", $self_assess, $self_address, $user_data_id);
if ($stmt->execute()) {
$stmt->close();
} else {
echo 'executefailed ' . $cfmysqli->error;
}
}

//MANAGer EMAILS
if (user_exists($manager, $mysqli)) {
//the user exists get their id and user group
$man_members_id = get_other_user_id($manager, $mysqli);
$user_group = get_user_group($man_members_id, $mysqli);
//if the user is not a manager make the user a manager
if ($user_group != 2) {
if ($user_group != 1) {
if (!make_manager($man_members_id, $mysqli)) {
echo 'make manager failed ';
}
}
}
if ($add_staff_array = add_staff($manager, $_SESSION['employee_id'], $self_address, $cfmysqli, $mysqli)) {
$reason = "newstaff";
$man_staff_id = $add_staff_array['id'];
$confirmation = $add_staff_array['confirmation'];
//needs to be included here due to scope.
require_once('config.php');
require_once('MailClass.inc');
// if(!manager_email($manager,$reason,$user_id,$man_staff_id,$confirmation,$mysqli,$cfmysqli)) {
// echo "manager email failed ";
// die;
// }
} else {
echo 'add staff failed';
}
} else {
require_once('config.php');
require_once('MailClass.inc');
//the manager does not exist, create the user with manager user status and email the manager to let them know.
$new_user_id = create_new_user($manager, $cfmysqli, $mysqli);

if ($add_staff_array = add_staff($manager, $_SESSION['employee_id'], $self_address, $cfmysqli, $mysqli)) {
$reason = "newstaff";
$man_staff_id = $add_staff_array['id'];
$confirmation = $add_staff_array['confirmation'];
//needs to be included here due to scope.
require_once('config.php');
require_once('MailClass.inc');
if (!manager_email($manager, $reason, $user_id, $man_staff_id, $confirmation, $mysqli, $cfmysqli)) {
echo "manager email failed ";
die;
}
} else {
echo 'add staff failed';
}
}
$cfmysqli->close();
$_SESSION['doc_title'] = $doctitle;

echo "
<html>
<body>
<script type='text/javascript'>
window.onload = function() {
window.location.replace('$root/convert_plan.php');
};
</script></body></html>";
} else {
header('Location:./login.php');
}
?>
[/code]