<?
require_once('preheader.php');
#the code for the class
include ('classes/ajaxCRUD.class.php');
#this one line of code is how you implement the class
$table = new ajaxCRUD("Knowledgebase Article", "tblKB", "pkKBID");
//$table->defineRelationship("fkMenuID", "tblMenu", "pkMenuID", "fldName");
$table->omitPrimaryKey();
$table->displayAs("fldTitle", "Title");
$table->displayAs("fldFilename", "Filename");
$table->setCSSFile('cnc.css');
//$table->setTextareaHeight('fldLongField', 200);
//$table->omitField("fldDocHTML");
//$table->omitAddField("fldFilesize");
$table->setFileUpload("fldFilename", "d:\Customers\user1393729\www\Docs\\", "../Docs/");
$table->onFileUploadExecuteCallBackFunction("uploadDocument");
$table->onDeleteFileExecuteCallBackFunction("deleteDocument");
//$table->disallowEdit('fldUpdateDate');
//$table->disallowEdit('fldFilesize');
//$table->addValueOnInsert("fldUpdateDate", "NOW()");
//$table->addWhereClause("WHERE fldLevel > 1");
//$table->addOrderBy("ORDER BY fldLevel");
//$table->onAddExecuteCallBackFunction("createFileForSubMenu");
//$allowable_vals = array("Accounts Receivable", "Accounts Payable", "Point of Sale");
//$table->defineAllowableValues("fldCategory", $allowable_vals);
//$table->disallowDelete();
//$table->disallowAdd();
//$table->addButtonToRow("Map", "map_sl.php");
//$table->cellspacing=6;
//$table->setLimit(30);
//$table->addTableBorder();
//$table->addButton("Sort Submenu", "submenu_sorting.php");
#actually show to the table
$table->showTable();
function uploadDocument($array){
$id = $array[id];
$fileName = $array[fileName];
$fileSize = $array[fileSize];
$fileType = $array[fldType];
//update filesize
if ($fileName != ''){
$success = qr("UPDATE tblKB SET fldFilesize = '$fileSize', fldUpdateDate = NOW() WHERE pkKBID = $id");
}
$file_path = "../Docs/" . $fileName;
$ext = getExtention($file_path);
if ($ext == 'txt' || $ext == 'rtf'){
//update table with content
qr("UPDATE tblKB SET fldDocTEXT = \"$doc_text\", fldDocHTML = \"$doc_html\" WHERE pkKBID = $id");
}
}
function deleteDocument($array){
$id = $array[id];
$field = $array[field];
if ($id != ''){
$success = qr("UPDATE tblKB SET fldFilesize = '', fldDocTEXT = '', fldDocHTML= '' WHERE pkKBID = $id");
}
}
?>