pivi_vault_system/toc.php

63 lines
1.9 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;
// Build our Editor instance and process the data coming from _POST
function logChange($db, $action, $id, &$values)
{
$db->insert('change_log', array(
'user' => $_POST['user'],
'table_' => 'documents',
'action' => $action,
'values' => json_encode($values),
'row' => $id
//'when' => date('c')
));
}
$docId = $_POST['doc_id'];
Editor::inst($db, 'table_of_content')
-> where('table_of_content.doc_id', $docId )
// ->where(function($q) use ($docId) {
// $q->where('table_of_content.doc_id', $docId);
// })
->fields(
Field::inst('table_of_content.id'),
Field::inst('table_of_content.document'),
Field::inst('table_of_content.number'),
Field::inst('table_of_content.doc_id'),
)
->on('postCreate', function ($editor, $id, &$values, &$row) {
logChange($editor->db(), 'create', $id, $values);
})
->on('postEdit', function ($editor, $id, &$values, &$row) {
logChange($editor->db(), 'edit', $id, $values);
})
// ->leftJoin('city', 'city.id', '=', 'documents.city')
// ->leftJoin('province', 'province.id', '=', 'documents.province')
// ->leftJoin('region', 'region.id', '=', 'documents.region')
// ->leftJoin('unit', 'unit.id', '=', 'documents.unit')
// ->leftJoin('department', 'department.id', '=', 'documents.department')
// ->leftJoin('company', 'company.id', '=', 'documents.company')
// ->leftJoin('type', 'type.id', '=', 'documents.type')
->process($_POST)
->json();