Posted in HTML, Javascript, PHP, SQL

Javascript – Building arrays for Chart.js from JSON data

function getPerformanceinfo (){

var myLabelarray = [];
var myActualarray = [];

$.post(‘inl_sev_078_J_vrs.php’, {“UNIQUENO” : myReportref }, function(response) {

for(var i=0; i<response.length; i++) {

myLabelarray[i] = response[i]._TAK;

myActualarray[i] = response[i]._PERCENTAGE;

}

$(“#_UNIQUENUMBER”).prop(“disabled”, true);

myChartjs (myLabelarray, myActualarray);

}, ‘json’)

}


 

// — Parameters input ——————————————————–

$uniqueno = (isset($_REQUEST[‘UNIQUENO’])) ? $_REQUEST[‘UNIQUENO’] : ”;

// — Define containers ——————————————————-

$terugvoer = array();
$tmp = array();

// — Extract the category names and weights ——————————

$sql = “SELECT _QUESTIONNAIRE, _VERSION, _TAK, _PERCENTAGE FROM performance WHERE _UNIQUENO = ‘$uniqueno’ “;

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

foreach ($selectStatus as $row) {

$tmp[‘_TAK’] = $row[‘_TAK’];
$tmp[‘_PERCENTAGE’] = $row[‘_PERCENTAGE’];

$terugvoer[] = $tmp;

}

// echo ‘<pre>’;
// print_r($terugvoer);
// echo ‘</pre>’;

echo json_encode($terugvoer);

Posted in HTML, PHP

PHP – Hyperlinks and images

foreach ($myArray as $key => $value) {

$myURL = substr($myArray[$key][‘path’], 5);
$mySafeURL = str_replace(‘ ‘, ‘%20’, $myURL);
$mysrc = $myEnv . $mySafeURL;

if (substr($mysrc, -3) == ‘pdf’ || substr($mysrc, -3) == ‘PDF’) {

// — PDF Document —————————————–
echo “<a href=” . $mysrc . “>PDF Dokument / Document</a>”;

} else {

// — JPG or PNG ——————————————-
echo “<img width=’30% height=’30%’ src=” . $mysrc . ” onclick=window.open(this.src)>”;

}

echo “<hr>”;

}

Posted in HTML, Javascript

Javascript – Validating input

function Validate(txt) {

txt.value = txt.value.replace(/[^a-zA-Z 0-9\n\r]+/g, ”);

}

 

<td><textarea rows=”2″ name=_CANCOMMENT’ + item.quest_id + ‘ id=_CANCOMMENT’ + item.quest_id + ‘ onkeyup = “Validate(this)” ‘ + ‘ onblur = “updateDetail(‘ + item.quest_id + ‘,’ + item._ACTUALPOINTS + ‘)” ‘ + ‘” class=”input-field control form-control” style=”width:400px”>’ + item._CANCOMMENT + ‘</textarea> </td>

Posted in Font awesome, HTML, PHP

Info icon

echo ‘<i style=”float:right; color:#AFAFAF;padding-right: 10px;” title=”Program inl_sev_064_Z_ver.php, Template inl_sev_065_T_ver.php, JSON inl_sev_066_J_ver.php” class=”fa fa-info-circle”></i>’;

echo ‘<br>’;

Posted in Bootstrap, Font awesome, HTML, PHP

The button bar

ButtonBar

// — btnDocupload ——————————————————————–

$obj = $form->add(‘button’, ‘btnDocupload’,'<i class=”fa fa fa-save” ></i>&nbsp’ . ‘CESUpload’);

$obj->set_attributes(array(
‘class’ => ‘btn btn-success’,
‘onclick’ => ‘docUpload()’,
‘type’ => ‘button’
));

// — btnDocview ——————————————————————–

$obj = $form->add(‘button’, ‘btnDocview’,'<i class=”fa fa fa-info-circle” ></i>&nbsp’ . ‘CESViewdocs’);

$obj->set_attributes(array(
‘class’ => ‘btn btn-info’,
‘onclick’ => ‘docView()’,
‘type’ => ‘button’
));

// — btnEvaluasiestaat —————————————————————

$obj = $form->add(‘button’, ‘btnEvaluasiestaat’,'<i class=”fa fa fa-info-circle” ></i>&nbsp’ . ‘CESStaat’);

$obj->set_attributes(array(
‘class’ => ‘btn btn-info’,
‘onclick’ => ‘statementEvaluation()’,
‘type’ => ‘button’
));

// — btnPrintMyPDF ——————————————————————-

$obj = $form->add(‘button’, ‘btnPrintMyPDF’,'<i class=”fa fa fa-print” ></i>&nbsp’ . ‘CESPrintmypdf’);

$obj->set_attributes(array(
‘class’ => ‘btn btn-info’,
‘type’ => ‘button’,
‘onclick’ => ‘printPage()’,
));


 

The template

ButtonBarTemplate

Posted in HTML, Javascript

Javascript – Validating text input

</td><td><textarea rows=”2″ name=_CANCOMMENT’ + item.quest_id + ‘ id=_CANCOMMENT’ + item.quest_id + ‘ onkeyup = “Validate(this)” ‘ + ‘ onblur = “updateDetail(‘ + item.quest_id + ‘,’ + item._ACTUALPOINTS + ‘)” ‘ + ‘” class=”input-field control form-control” style=”width:400px”>’ + item._CANCOMMENT + ‘</textarea> </td>’

 


 

function Validate(txt) {

txt.value = txt.value.replace(/[^a-zA-Z 0-9\n\r]+/g, ”);

}

Posted in HTML, Javascript

Textarea – Input

<td><textarea rows=”2″ name=_CANCOMMENT’ + item.quest_id + ‘ id=_CANCOMMENT’ + item.quest_id + ‘ onkeyup = “Validate(this)” ‘ + ‘ onblur = “updateDetail(‘ + item.quest_id + ‘,’ + item._ACTUALPOINTS + ‘)” ‘ + ‘” class=”input-field control form-control” style=”width:400px”>’ + item._CANCOMMENT + ‘</textarea> </td>’


 

function updateDetail (isn, outof) {

var cancommenttextarea = “_CANCOMMENT” + isn;

var cancomment = $(‘textarea[name=’ + cancommenttextarea + ‘]’).val(); 

Posted in EasyUI, HTML, PHP, SQL

PHP – unserialise and JSON data for EasyUI

After034_E

require_once($_SERVER[‘DOCUMENT_ROOT’].’/xyz/db/MysqliDb.php’);

// — Parameters input ——————————————————–

$dept = (isset($_REQUEST[‘DEPT’])) ? $_REQUEST[‘DEPT’] : ”;
$template = (isset($_REQUEST[‘TEMPLATE’])) ? $_REQUEST[‘TEMPLATE’] : ”;

// — Define containers ——————————————————-

$terugvoer = array();
$tmp = array();

// — Retrieve the present list of questions ———————————-

$sql = “SELECT _QUESTION, _YN, _COMMENTONLY FROM questions WHERE _DEPT = ‘$dept'”;

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

if ($selectStatus > 0) {

foreach ($selectStatus as $row) {

$questionArray[] = $row[‘_QUESTION’];
$ynArray[] = $row[‘_YN’];
$commentonlyArray[] = $row[‘_COMMENTONLY’];

}

}

// — Retrieve the list of categories —————————————–

$sql = “SELECT _CATEGORY, _SUBCATEGORY FROM categories WHERE _DEPT = ‘$dept'”;

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

if ($selectStatus > 0) {

foreach ($selectStatus as $row) {

$categoryArray[] = $row[‘_CATEGORY’];
$subcategoryArray[] = $row[‘_SUBCATEGORY’];

}

}

// — Retrieve the TEMPLATE selection data ————————————

$sql = “SELECT _TEMPLATE, _UPTO30CAT, _UPTO30CATW FROM templates WHERE _TEMPLATE = ‘$template'”;

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

if ($selectStatus > 0) {

foreach ($selectStatus as $row) { // Only one row ….. [0]

$tmp[‘_TEMPLATE’] = $row[‘_TEMPLATE’];
$tmp[‘_UPTO30CAT’] = unserialize($row[‘_UPTO30CAT’]);
$tmp[‘_UPTO30CATW’] = unserialize($row[‘_UPTO30CATW’]);

foreach ($tmp[‘_UPTO30CAT’] as $key=>$value) {

if ($value != ”) {

$tmp[‘_CATEGORY’] = $categoryArray[$value];
$tmp[‘_SUBCATEGORY’] = $subcategoryArray[$value];

$tmp[‘_CWEIGHT’] = $tmp[‘_UPTO30CATW’][$key];

$searchVal = $tmp[‘_CATEGORY’];

$sql = “SELECT _CATEGORY, _SUBCATEGORY, _UPTO15QSUBHEADING, _UPTO15QUES, _UPTO15PUNT, _UPTO15WEIGHTS FROM categories WHERE _CATEGORY = ‘$searchVal'”;

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

if ($selectStatus > 0) {

foreach ($selectStatus as $row) {

// — Store questions as HTML representation ——————–

foreach (unserialize($row[‘_UPTO15QUES’]) as $key=>$value) {

if ($value != ”) {

$tmp[‘myHeadingsArray’] = unserialize($row[‘_UPTO15QSUBHEADING’]);

$tmp[‘_QSUBHEADING’] = $tmp[‘myHeadingsArray’][$key];

$tmp[‘myPointsArray’] = unserialize($row[‘_UPTO15PUNT’]);

$tmp[‘_QWEIGHT’] = $tmp[‘myPointsArray’][$key];

$tmp[‘_QUESTION’] = $questionArray[$value];

$terugvoer[] = $tmp;

// ————————————
$tmp[‘_CATEGORY’] = ”;
$tmp[‘_SUBCATEGORY’] = ”;
$tmp[‘_CWEIGHT’] = ”;
// ————————————

} // End if

} // End store questions as HTML representation

} // End while

} // End of Question code

}

}

}

}

echo json_encode($terugvoer);

?>

 

Posted in DOM, HTML, Javascript

Accumulating data for charts.js / Dynamic tables

document.getElementById(“categorysummary”).innerHTML = “”;

var newTable = “<table border=’1′ width=’99%’>”;

newTable += “<tr><th width=150px><b>” + cat + “</b></th><th width=200px><b>” + sub + “</b></th><th width=20px><b>” + actual + “</b></th><th width=20px><b>” + max + “</b></th><th width=20px><b>” + weight + “</b></th></tr>”;

 

for(var i=0; i<response.length; i++) {

myLabelarray[i] = response[i]._SUBCATEGORY;

cattofive = response[i]._CATTOFIVE;
myActualarray[i] = response[i]._CATTOFIVE;

catpoints = response[i]._CATPOINTS;
myMaxarray[i] = response[i]._CATPOINTS;

cat = response[i]._CAT;

catcalc = (cattofive / catpoints) * cat / 1;
catcalctot = catcalctot + catcalc;

catcalctot = round(catcalctot, 2);

newTable += “<tr><td>” + response[i]._CATEGORY + “</td><td>” + response[i]._SUBCATEGORY + “</td><td align=’right’>” + response[i]._CATTOFIVE + “</td><td align=’right’>” + response[i]._CATPOINTS + “</td><td align=’right’>” + response[i]._CAT + “</td></tr>”;

$(“#_OVERALLPERCENTAGE”).val(response[i]._OVERALL);
$(“#_WEIGHTEDPERCENTAGE”).val(catcalctot);

}

newTable += “</table>”;

document.getElementById(“categorysummary”).innerHTML = newTable;
myChartjs (myLabelarray, myMaxarray, myActualarray);

$(“#chart1”).hide();
$(“#chart2”).hide();