82 lines
2.5 KiB
PHP
82 lines
2.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Example PHP implementation used for the index.html example
|
|
*/
|
|
|
|
// DataTables PHP library
|
|
include("editor/lib/DataTables.php");
|
|
|
|
// Alias Editor classes so they are easy to use
|
|
use
|
|
DataTables\Editor,
|
|
DataTables\Editor\Field,
|
|
DataTables\Editor\Format,
|
|
DataTables\Editor\Mjoin,
|
|
DataTables\Editor\Options,
|
|
DataTables\Editor\Upload,
|
|
DataTables\Editor\Validate,
|
|
DataTables\Editor\ValidateOptions;
|
|
// if (isset($_POST['type'])) {
|
|
// $type = $_POST['type'];
|
|
// } else {
|
|
// $type = '%';
|
|
// }
|
|
// if ($_POST['status']>6) {
|
|
// if ($_POST['role']=$arole){
|
|
// $status1 = 2;
|
|
// };
|
|
|
|
// } else {
|
|
// $status1 = $_POST['status'];
|
|
// $status2 = $_POST['status'];
|
|
// }
|
|
|
|
// Build our Editor instance and process the data coming from _POST
|
|
Editor::inst($db, 'request')
|
|
->where('request.status', $_POST['status'])
|
|
// ->where( function ( $q ) use ($status1,) {
|
|
// $q
|
|
// ->where('request.status', $status1 );
|
|
// // ->or_where('request.status', $status2 );
|
|
// } )
|
|
->fields(
|
|
Field::inst('request.id'),
|
|
Field::inst('request.type'),
|
|
Field::inst('request.reason'),
|
|
Field::inst('request.status')
|
|
->options(
|
|
Options::inst()
|
|
->table('status')
|
|
->value('id')
|
|
->label('name')
|
|
)
|
|
->validator(Validate::dbValues()),
|
|
Field::inst('documents.number'),
|
|
Field::inst('type.name'),
|
|
Field::inst('documents.description'),
|
|
Field::inst('status.name'),
|
|
Field::inst('request.document')
|
|
->options(
|
|
Options::inst()
|
|
->table('documents')
|
|
->value('id')
|
|
->label('description')
|
|
)
|
|
->validator(Validate::dbValues()),
|
|
Field::inst('request.user_id'),
|
|
Field::inst('request.name'),
|
|
Field::inst('request.date'),
|
|
Field::inst('request.company'),
|
|
Field::inst('company2.name'),
|
|
Field::inst('documents.company'),
|
|
Field::inst('company.name'),
|
|
)
|
|
->leftJoin('status', 'status.id', '=', 'request.status')
|
|
->leftJoin('documents', 'documents.id', '=', 'request.document')
|
|
->leftJoin('type', 'type.id', '=', 'documents.type')
|
|
->leftJoin('company', 'company.id', '=', 'documents.company')
|
|
->leftJoin('company AS company2', 'company2.id', '=', 'request.company')
|
|
->process($_POST)
|
|
->json();
|