2022-02-23 14:46:44 +01:00
|
|
|
<html>
|
|
|
|
<head>
|
2022-07-19 08:22:20 +02:00
|
|
|
<link rel="stylesheet" href="../bootstrap-5.1.3-dist/css/bootstrap.min.css">
|
2022-02-23 14:46:44 +01:00
|
|
|
<title>Table example</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<?php
|
2022-07-24 11:10:43 +02:00
|
|
|
include "../phpxpress/Table.php";
|
2022-02-23 14:46:44 +01:00
|
|
|
|
|
|
|
class Employee{
|
|
|
|
public $name;
|
|
|
|
public $surname;
|
|
|
|
public $dateOfBirth;
|
|
|
|
public $ssn;
|
|
|
|
}
|
|
|
|
|
|
|
|
$employee1 = new Employee;
|
|
|
|
$employee2 = new Employee;
|
|
|
|
$employee3 = new Employee;
|
|
|
|
|
|
|
|
$employee1->name = 'Christopher';
|
|
|
|
$employee1->surname = 'Anderson';
|
|
|
|
$employee1->dateOfBirth = "01-01-1970";
|
|
|
|
$employee1->ssn = "12345";
|
|
|
|
|
|
|
|
$employee2->name = 'Catherine';
|
|
|
|
$employee2->surname = 'Johnstone';
|
|
|
|
$employee2->dateOfBirth = "02-04-1988";
|
|
|
|
$employee2->ssn = "56789";
|
2022-07-24 11:10:43 +02:00
|
|
|
|
2022-02-23 14:46:44 +01:00
|
|
|
$employee3->name = 'Anna';
|
|
|
|
$employee3->surname = 'Brenson';
|
|
|
|
$employee3->dateOfBirth = "10-08-1998";
|
|
|
|
$employee3->ssn = "13579";
|
|
|
|
|
|
|
|
$employees = array($employee1,$employee2,$employee3);
|
|
|
|
|
2022-07-24 11:10:43 +02:00
|
|
|
$table = new PhpXpress\Table;
|
2022-03-09 00:36:24 +01:00
|
|
|
$table->addColumn("Extra");
|
2022-04-12 17:42:45 +02:00
|
|
|
$table->setDataSource($employees);
|
|
|
|
$table->setCustomCaptions(array("Extra" , "Name", "Surname", "Date of Birth", "Social Security Number"));
|
|
|
|
$table->addColumn("Extra2");
|
2022-07-24 11:10:43 +02:00
|
|
|
|
2022-03-09 00:36:24 +01:00
|
|
|
|
|
|
|
$table->onValueDisplaying("onValueDisplaying");
|
|
|
|
|
2022-02-23 14:46:44 +01:00
|
|
|
$table->setStripedRows(true);
|
|
|
|
$table->setBordered(true);
|
|
|
|
$table->setHoverAnimation(true);
|
2022-03-09 00:00:56 +01:00
|
|
|
|
2022-02-23 14:46:44 +01:00
|
|
|
$table->draw();
|
|
|
|
|
2022-03-09 00:36:24 +01:00
|
|
|
function onValueDisplaying($caption, &$value, $row){
|
2022-03-09 00:00:56 +01:00
|
|
|
if($caption == "ssn"){
|
2022-03-09 00:36:24 +01:00
|
|
|
if($row["ssn"] != "12345"){
|
|
|
|
$value = "SSN not shown for privacy reasons";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$value = $row["name"] . " " . $row["surname"] . " agreed to share their ssn (12345)" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if($caption == "Extra"){
|
|
|
|
$value = "This column did not exist in the datasource";
|
2022-03-09 00:00:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-23 14:46:44 +01:00
|
|
|
?>
|
|
|
|
</body>
|
2022-07-24 11:10:43 +02:00
|
|
|
</html>
|