<?php
################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- #
## --------------------------------------------------------------------------- #
## ApPHP AdminPanel Pro #
## Developed by: ApPHP <hide@address.com> #
## License: GNU LGPL v.3 #
## Site: http://www.apphp.com/php-adminpanel/ #
## Copyright: ApPHP AdminPanel (c) 2006-2011. All rights reserved. #
## #
################################################################################
// last changed: 25.07.2011
header("content-type: text/html; charset=utf-8");
// Initialize the session.
session_start();
require_once("../inc/classes/session.class.php");
require_once("../inc/checkAdminPagePermissions.php");
require_once("../inc/config.inc.php");
require_once("../inc/settings.inc.php");
require_once("../inc/languages/".$SETTINGS['site_language'].".php");
if(!page_access_allowed($_SERVER['SCRIPT_NAME'])) redirect_to("access_denied.php");
require_once("../modules/datagrid_wizard/include/functions.inc.php");
require_once("../modules/datagrid_wizard/include/fill_arrays.inc.php");
$config = new Config();
$debug = false;
$debug_msg = "";
$browser = set_browser_definitions();
if(strtolower($browser['browser']) == "MSIE"){
$fieldset_width = "900px";
$msg_width = "910px";
}else{
$fieldset_width = "930px";
$msg_width = "940px";
}
$dgpid = isset($_REQUEST['dgpid']) ? (int)$_REQUEST['dgpid'] : "0";
$dpid = isset($_REQUEST['dpid']) ? (int)$_REQUEST['dpid'] : "";
$msg = "";
$path = "../";
$act = isset($_POST['act']) ? prepare_input($_POST['act']) : "";
$filter_act = isset($_POST['filter_act']) ? prepare_input($_POST['filter_act']) : "";
$filter_act_id = isset($_POST['filter_act_id']) ? (int)$_POST['filter_act_id'] : "";
$foreign_keys_act = isset($_POST['foreign_keys_act']) ? prepare_input($_POST['foreign_keys_act']) : "";
$foreign_keys_act_id = isset($_POST['foreign_keys_act_id']) ? prepare_input($_POST['foreign_keys_act_id']) : "";
$foreign_keys_act_table = isset($_POST['foreign_keys_act_table']) ? prepare_input($_POST['foreign_keys_act_table']) : "";
$submit_act = isset($_POST['submit_act']) ? prepare_input($_POST['submit_act']) : "";
$file_name = isset($_POST['file_name']) ? prepare_input($_POST['file_name']) : "";
$system_tables = array(TABLE_ADMINS,
TABLE_CALENDAR,
TABLE_COUNTRIES,
TABLE_DG_WIZARD_FIELDS,
TABLE_DG_WIZARD_SETTINGS,
TABLE_DG_WIZARD_FILTERING,
TABLE_DG_WIZARD_FOREIGN_KEYS,
TABLE_DATAGRID_PAGES,
TABLE_DYNAMIC_PAGES,
TABLE_GALLERY_ALBUMS,
TABLE_GALLERY_IMAGES,
TABLE_EMAIL_TEMPLATES,
TABLE_EVENTS,
TABLE_SYSTEM_LOGS,
TABLE_FILE_TYPES,
TABLE_MENU,
TABLE_MENU_ACCESS_RIGHTS,
TABLE_MODULES,
TABLE_NEWS,
TABLE_SETTINGS,
TABLE_STATIC_PAGES,
TABLE_USERS,
TABLE_USERS_GROUPS);
// prepare list of allowed tables
$sql = "SHOW TABLES FROM ".$config->getDatabase();
$db->Query($sql);
$arrAllowedTables = array();
$arrAllowedFKTables = array();
while($row = $db->FetchArray()) {
if(preg_match("/"._DB_PREFIX."/i", $row[0]) && !in_array($row[0], $system_tables)){
$arrAllowedTables[] = $row[0];
$arrAllowedFKTables[] = $row[0];
}
}
if(!count($arrAllowedTables)){
$msg = draw_message("error", "There are no tables available for work with this Wizard! Please add at least one table to your database.", false, $msg_width, $path);
}
// for View Mode
$arrViewModeFields = array();
$selViewModeTable = isset($_POST['selViewModeTable']) ? prepare_input($_POST['selViewModeTable']) : "";
$selDefiningFieldsView = isset($_POST['selDefiningFieldsView']) ? prepare_input($_POST['selDefiningFieldsView']) : "all";
$vm_fields_primary_key = isset($_POST['vm_fields_primary_key']) ? prepare_input($_POST['vm_fields_primary_key']) : "";
$vm_table_width = isset($_POST['txtViewModeTableWidth']) ? prepare_input($_POST['txtViewModeTableWidth'], "custom", "[^0-9]") : "95";
$vm_table_width_units = isset($_POST['txtViewModeTableWidthUnits']) ? prepare_input($_POST['txtViewModeTableWidthUnits']) : "%";
// for Edit Mode
$arrEditModeFields = array();
$selEditModeTable = isset($_POST['selEditModeTable']) ? prepare_input($_POST['selEditModeTable']) : "";
$selDefiningFieldsEdit = isset($_POST['selDefiningFieldsEdit']) ? prepare_input($_POST['selDefiningFieldsEdit']) : "all";
$em_fields_primary_key = isset($_POST['em_fields_primary_key']) ? prepare_input($_POST['em_fields_primary_key']) : "";
$em_table_width = isset($_POST['txtEditModeTableWidth']) ? prepare_input($_POST['txtEditModeTableWidth'], "custom", "[^0-9]") : "80%";
$em_table_width_units = isset($_POST['txtEditModeTableWidthUnits']) ? prepare_input($_POST['txtEditModeTableWidthUnits']) : "%";
// for Filter Mode
$arrFilterModeFields = array("caption", "type", "table", "field", "operator", "sensitivity", "comparison");
$selFilterModeTable = $selViewModeTable;
// for Foreign Keys
$arrForeignKeysTableFields = array();
$arrForeignKeysFields = array("foreign_field", "table", "field_key", "field_name", "view_type", "order_type");
$selForeignKeysModeTable = $selEditModeTable;
$fkm_fields_0_foreign_field = isset($_POST["fkm_fields_0_foreign_field"]) ? $_POST["fkm_fields_0_foreign_field"] : "";
$fkm_fields_0_table = isset($_POST["fkm_fields_0_table"]) ? $_POST["fkm_fields_0_table"] : "";
$fkm_fields_0_field_key = isset($_POST["fkm_fields_0_field_key"]) ? $_POST["fkm_fields_0_field_key"] : "";
$fkm_fields_0_field_name = isset($_POST["fkm_fields_0_field_name"]) ? $_POST["fkm_fields_0_field_name"] : "";
$fkm_fields_0_view_type = isset($_POST["fkm_fields_0_view_type"]) ? $_POST["fkm_fields_0_view_type"] : "";
$fkm_fields_0_order_type = isset($_POST["fkm_fields_0_order_type"]) ? $_POST["fkm_fields_0_order_type"] : "";
// for FieldSets
$fsCreatingCalling_state = (isset($_COOKIE['fsCreatingCalling_state']) && $_COOKIE['fsCreatingCalling_state'] != "") ? $_COOKIE['fsCreatingCalling_state'] : "open";
$fsGeneralSettings_state = (isset($_COOKIE['fsGeneralSettings_state']) && $_COOKIE['fsGeneralSettings_state'] != "") ? $_COOKIE['fsGeneralSettings_state'] : "open";
$fsPrintingExporting_state = (isset($_COOKIE['fsPrintingExporting_state']) && $_COOKIE['fsPrintingExporting_state'] != "") ? $_COOKIE['fsPrintingExporting_state'] : "open";
$fsSortingPaging_state = (isset($_COOKIE['fsSortingPaging_state']) && $_COOKIE['fsSortingPaging_state'] != "") ? $_COOKIE['fsSortingPaging_state'] : "open";
$fsSortingPaging_state = (isset($_COOKIE['fsSortingPaging_state']) && $_COOKIE['fsSortingPaging_state'] != "") ? $_COOKIE['fsSortingPaging_state'] : "open";
$fsFiltering_state = (isset($_COOKIE['fsFiltering_state']) && $_COOKIE['fsFiltering_state'] != "") ? $_COOKIE['fsFiltering_state'] : "open";
$fsViewMode_state = (isset($_COOKIE['fsViewMode_state']) && $_COOKIE['fsViewMode_state'] != "") ? $_COOKIE['fsViewMode_state'] : "open";
$fsEditMode_state = (isset($_COOKIE['fsEditMode_state']) && $_COOKIE['fsEditMode_state'] != "") ? $_COOKIE['fsEditMode_state'] : "open";
$fsForeignKeys_state = (isset($_COOKIE['fsForeignKeys_state']) && $_COOKIE['fsForeignKeys_state'] != "") ? $_COOKIE['fsForeignKeys_state'] : "open";
$txtUniquePrefix = isset($_POST['txtUniquePrefix']) ? prepare_input($_POST['txtUniquePrefix']) : "";
$txtDebugMode = isset($_POST['txtDebugMode']) ? prepare_input($_POST['txtDebugMode']) : "false";
$selCssClass = isset($_POST['selCssClass']) ? prepare_input($_POST['selCssClass']) : $SETTINGS['datagrid_css_style'];
$selPrinting = isset($_POST['selPrinting']) ? prepare_input($_POST['selPrinting']) : "";
$selExporting = isset($_POST['selExporting']) ? prepare_input($_POST['selExporting']) : "";
$selExportAll = isset($_POST['selExportAll']) ? prepare_input($_POST['selExportAll']) : "";
$selSorting = isset($_POST['selSorting']) ? prepare_input($_POST['selSorting']) : "";
$selPaging = isset($_POST['selPaging']) ? prepare_input($_POST['selPaging']) : "";
$selFiltering = isset($_POST['selFiltering']) ? prepare_input($_POST['selFiltering']) : "";
$selLangName = isset($_POST['selLangName']) ? prepare_input($_POST['selLangName']) : $SETTINGS['site_language'];
$selLangCollation = isset($_POST['selLangCollation']) ? prepare_input($_POST['selLangCollation']) : "utf8_unicode_ci";
$chkOperationAdd = "true";
$chkOperationEdit = "true";
$chkOperationDetails = "true";
$chkOperationDelete = "true";
$chkMltOperations = "false";
$chkMltOperationEdit = "false";
$chkMltOperationDetails = "false";
$chkMltOperationDelete = "false";
$page_content = "";
$page_name = "";
$created = false;
// -------------------------------------------------------------------------
// retrive data from database
// -------------------------------------------------------------------------
if($dpid != ""){
$dgpid = $dpid;
$sql = "SELECT
id,
datagrid_page_id,
unique_pefix,
debug_mode,
allow_operation_add,
allow_operation_edit,
allow_operation_delete,
allow_operation_details,
allow_multi_operations,
allow_multi_operation_edit,
allow_multi_operation_details,
allow_multi_operation_delete,
language,
lang_collation,
css_class,
allow_printing,
allow_exporting,
export_all_records,
allow_sorting,
allow_paging,
allow_filtering,
vm_table_name,
vm_primary_key,
vm_table_width,
vm_table_width_units,
em_table_name,
em_primary_key,
em_table_width,
em_table_width_units
FROM ".TABLE_DG_WIZARD_SETTINGS."
WHERE datagrid_page_id = ".$dpid;
$db->Query($sql);
if($row = $db->FetchArray()){
$txtUniquePrefix = $row['unique_pefix'];
$txtDebugMode = $row['debug_mode'];
$chkOperationAdd = $row['allow_operation_add'];
$chkOperationEdit = $row['allow_operation_edit'];
$chkOperationDelete = $row['allow_operation_delete'];
$chkOperationDetails = $row['allow_operation_details'];
$chkMltOperations = $row['allow_multi_operations'];
$chkMltOperationEdit = $row['allow_multi_operation_edit'];
$chkMltOperationDetails = $row['allow_multi_operation_details'];
$chkMltOperationDelete = $row['allow_multi_operation_delete'];
$selCssClass = $row['css_class'];
$selPrinting = $row['allow_printing'];
$selExporting = $row['allow_exporting'];
$selExportAll = $row['export_all_records'];
$selSorting = $row['allow_sorting'];
$selPaging = $row['allow_paging'];
$selFiltering = $row['allow_filtering'];
$selLangName = $row['language'];
$selLangCollation = $row['lang_collation'];
$selViewModeTable = $row['vm_table_name'];
$vm_fields_primary_key = $row['vm_primary_key'];
$vm_table_width = $row['vm_table_width'];
$vm_table_width_units = $row['vm_table_width_units'];
$selEditModeTable = $row['em_table_name'];
$em_fields_primary_key = $row['em_primary_key'];
$em_table_width = $row['em_table_width'];
$em_table_width_units = $row['em_table_width_units'];
$arrViewModeFieldsAttributes = array();
$arrEditModeFieldsAttributes = array();
// set fields for View mode
$sql = "SELECT
id, datagrid_page_id,
field_name, field_header, field_visible, field_type, field_align, field_width,
field_wrap, field_case, field_text_length, field_tooltip
FROM ".TABLE_DG_WIZARD_FIELDS."
WHERE datagrid_page_id = ".$dpid. " AND mode = 0";
$db->Query($sql);
if($db->RowCount() > 1){
while($row = $db->FetchArray()){
$arrViewModeFieldsAttributes[$row['field_name']] = array();
$arrViewModeFieldsAttributes[$row['field_name']]['field_header'] = $row['field_header'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_visible'] = $row['field_visible'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_type'] = $row['field_type'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_align'] = $row['field_align'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_width'] = $row['field_width'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_wrap'] = $row['field_wrap'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_case'] = $row['field_case'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_text_length'] = $row['field_text_length'];
$arrViewModeFieldsAttributes[$row['field_name']]['field_tooltip'] = $row['field_tooltip'];
}
$selDefiningFieldsView = "by_one";
}else{
$selDefiningFieldsView = "all";
}
// set fields for Edit mode
$sql = "SELECT
id, datagrid_page_id,
field_name, field_header, field_visible, field_type, field_align, field_width,
field_req_type, field_req_subtype, field_readonly, field_unique, field_default,
field_edit_type, field_target_path
FROM ".TABLE_DG_WIZARD_FIELDS."
WHERE datagrid_page_id = ".$dpid. " AND mode = 1";
$db->Query($sql);
if($db->RowCount() > 1){
while($row = $db->FetchArray()){
$arrEditModeFieldsAttributes[$row['field_name']] = array();
$arrEditModeFieldsAttributes[$row['field_name']]['field_header'] = $row['field_header'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_visible'] = $row['field_visible'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_type'] = $row['field_type'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_align'] = $row['field_align'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_width'] = $row['field_width'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_req_type'] = $row['field_req_type'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_req_subtype'] = $row['field_req_subtype'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_readonly'] = $row['field_readonly'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_unique'] = $row['field_unique'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_default'] = $row['field_default'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_edit_type'] = $row['field_edit_type'];
$arrEditModeFieldsAttributes[$row['field_name']]['field_target_path'] = $row['field_target_path'];
}
$selDefiningFieldsEdit = "by_one";
}else{
$selDefiningFieldsEdit = "all";
}
$arrViewModeFields = array();
$arrEditModeFields = array();
if($selDefiningFieldsEdit == "by_one" && $selDefiningFieldsView == "all"){
// View Mode - do nothing
// Edit Mode - retrive
$act = "dont_retrive_view_mode_fields";
dont_retrive_view_mode_fields($arrEditModeFields, $selEditModeTable);
}else if($selDefiningFieldsEdit == "all" && $selDefiningFieldsView == "by_one"){
// Edit Mode - do nothing
// View Mode - retrive
$act = "dont_retrive_edit_mode_fields";
dont_retrive_edit_mode_fields($arrViewModeFields, $selViewModeTable);
}else if($selDefiningFieldsEdit == "by_one" && $selDefiningFieldsView == "by_one"){
// View Mode - retrive
// Edit Mode - retrive
$act = "retrive_view_edit_mode_fields";
retrive_view_edit_mode_fields($arrViewModeFields, $selViewModeTable, $arrEditModeFields, $selEditModeTable);
}else{
$act = "dont_retrive_view_edit_mode_fields";
// do nothing "dont_retrive_view_edit_mode_fields"
}
}else{
$msg = draw_message("normal", "This page was not saved in database yet!", false, $msg_width, $path);
}
}
// handle form submission
if($submit_act == "submit"){
$chkOperationAdd = isset($_POST['chkOperationAdd']) ? $_POST['chkOperationAdd'] : "false";
$chkOperationEdit = isset($_POST['chkOperationEdit']) ? $_POST['chkOperationEdit'] : "false";
$chkOperationDetails = isset($_POST['chkOperationDetails']) ? $_POST['chkOperationDetails'] : "false";
$chkOperationDelete = isset($_POST['chkOperationDelete']) ? $_POST['chkOperationDelete'] : "false";
$chkMltOperations = isset($_POST['chkMltOperations']) ? $_POST['chkMltOperations'] : "false";
$chkMltOperationEdit = isset($_POST['chkMltOperationEdit']) ? $_POST['chkMltOperationEdit'] : "false";
$chkMltOperationDetails = isset($_POST['chkMltOperationDetails']) ? $_POST['chkMltOperationDetails'] : "false";
$chkMltOperationDelete = isset($_POST['chkMltOperationDelete']) ? $_POST['chkMltOperationDelete'] : "false";
if(strtolower(_SITE_MODE) == "demo"){
$msg = draw_message("error", "This operation is blocked in demo version.", false, $msg_width, $path);
}else{
// check fields
if($selViewModeTable == ""){
$msg = draw_message("error", "View Mode table cannot be empty! Please select.", false, $msg_width, $path);
}else if($selEditModeTable == ""){
$msg = draw_message("error", "Edit Mode table cannot be empty! Please select.", false, $msg_width, $path);
}
if($msg == ""){
// write data to the file
@chmod($path."pages/".$file_name, 0755);
$fh = fopen($path."pages/".$file_name, 'w');
if(!$fh){
$msg = draw_message("error", "Can not open file: ".$file_name, false, $msg_width, $path);
}else{
$file_content = file_get_contents("templates/php_datagrid_file.tpl");
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling: |
## +---------------------------------------------------------------------------+
// define datagrid path
$file_content = str_replace("<DATAGRID_DIR>", "../modules/datagrid/", $file_content);
// set database connection parameters
$file_content = str_replace("<DB_USER>", $config->getUser(), $file_content);
$file_content = str_replace("<DB_PASS>", $config->getPassword(), $file_content);
$file_content = str_replace("<DB_HOST>", $config->getHost(), $file_content);
$file_content = str_replace("<DB_NAME>", $config->getDatabase(), $file_content);
$file_content = str_replace("<DB_TYPE>", $config->getDatabaseType(), $file_content);
// set View Mode SQL SELECT parameters
$file_content = str_replace("<VIEW_MODE_TABLE>", $selViewModeTable, $file_content);
// set View Mode table width
$file_content = str_replace("<VIEW_MODE_TABLE_WIDTH>", $vm_table_width.$vm_table_width_units, $file_content);
// set list of fields
$listViewModeFields = "*";
$sql = "SHOW COLUMNS FROM ".$selViewModeTable;
$db->Query($sql);
while($row = $db->FetchArray()){
$arrViewModeFields[] = $row['Field'];
}
if($selDefiningFieldsView == "all"){
// all fields - autocomplete
if(count($arrViewModeFields) > 0){
$listViewModeFields = implode(", ", $arrViewModeFields);
}
}else{
// specify by one
$listViewModeFields = $vm_fields_primary_key;
foreach($arrViewModeFields as $key => $val){
if(array_key_exists("vm_fields_".$val."_name", $_POST)){
if($val != $vm_fields_primary_key){
if($listViewModeFields != "") $listViewModeFields .= ", ";
$listViewModeFields .= $val;
}
}
}
}
$file_content = str_replace("<VIEW_MODE_FILEDS_LIST>", $listViewModeFields, $file_content);
$file_content = str_replace("<UNIQUE_PREFIX>", $txtUniquePrefix, $file_content);
$file_content = str_replace("<DEBUG_MODE>", $txtDebugMode, $file_content);
## +---------------------------------------------------------------------------+
## | 2. General Settings: |
## +---------------------------------------------------------------------------+
$file_content = str_replace("<CSS_CLASS>", $selCssClass, $file_content);
$file_content = str_replace("<LANG_NAME>", $selLangName, $file_content);
$collation_parts = explode("_", $selLangCollation);
$file_content = str_replace("<ENCODING>", (isset($collation_parts[0]) ? $collation_parts[0] : "utf8"), $file_content);
$file_content = str_replace("<COLLATION>", $selLangCollation, $file_content);
$file_content = str_replace("<VIEW_MODE_ADD>", $chkOperationAdd, $file_content);
$file_content = str_replace("<VIEW_MODE_EDIT>", $chkOperationEdit, $file_content);
$file_content = str_replace("<VIEW_MODE_DELETE>", $chkOperationDelete, $file_content);
$file_content = str_replace("<VIEW_MODE_DETAILS>", $chkOperationDetails, $file_content);
## +-- Multirow Operations ------------------------------------------------+
$file_content = str_replace("<MULTIROW_OPTION>", $chkMltOperations, $file_content);
$file_content = str_replace("<MULTIROW_EDIT>", $chkMltOperationEdit, $file_content);
$file_content = str_replace("<MULTIROW_DETAILS>", $chkMltOperationDetails, $file_content);
$file_content = str_replace("<MULTIROW_DELETE>", $chkMltOperationDelete, $file_content);
## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings: |
## +---------------------------------------------------------------------------+
$file_content = str_replace("<PRINTING_OPTION>", $selPrinting, $file_content);
$file_content = str_replace("<EXPORTING_OPTION>", $selExporting, $file_content);
$file_content = str_replace("<EXPORT_ALL>", $selExportAll, $file_content);
## +---------------------------------------------------------------------------+
## | 4. Sorting & Paging Settings: |
## +---------------------------------------------------------------------------+
$file_content = str_replace("<SORTING_OPTION>", $selSorting, $file_content);
$file_content = str_replace("<PAGING_OPTION>", $selPaging, $file_content);
## +---------------------------------------------------------------------------+
## | 5. Filter Settings: |
## +---------------------------------------------------------------------------+
$file_content = str_replace("<FILTERING_OPTION>", $selFiltering, $file_content);
$listFilterModeFields = "";
$listForeignKeysFields = "";
$sql = "SELECT * FROM ".TABLE_DG_WIZARD_FILTERING." WHERE datagrid_page_id = ".$dgpid;
$db->Query($sql);
while($row = $db->FetchArray()){
$listFilterModeFields .= "\"".$row['f_caption']."\"=>array(";
$listFilterModeFields .= "\"type\"=>\"".$row['f_type']."\",";
$listFilterModeFields .= "\"table\"=>\"".$row['f_table']."\",";
$listFilterModeFields .= "\"field\"=>\"".$row['f_field']."\",";
$listFilterModeFields .= "\"default_operator\"=>\"".$row['f_operator']."\",";
$listFilterModeFields .= "\"case_sensitive\"=>\"".$row['f_sensitivity']."\",";
$listFilterModeFields .= "\"comparison_type\"=>\"".$row['f_comparison']."\",";
$listFilterModeFields .= "),\n";
}
// last
if(isset($_POST["fm_fields_0_caption"]) && $_POST["fm_fields_0_caption"] != ""){
$listFilterModeFields .= "\"".$_POST['fm_fields_0_caption']."\"=>array(";
$listFilterModeFields .= "\"type\"=>\"".$_POST['fm_fields_0_type']."\",";
$listFilterModeFields .= "\"table\"=>\"".$_POST['fm_fields_0_table']."\",";
$listFilterModeFields .= "\"field\"=>\"".$_POST['fm_fields_0_field']."\",";
$listFilterModeFields .= "\"default_operator\"=>\"".$_POST['fm_fields_0_operator']."\",";
$listFilterModeFields .= "\"case_sensitive\"=>\"".$_POST['fm_fields_0_sensitivity']."\",";
$listFilterModeFields .= "\"comparison_type\"=>\"".$_POST['fm_fields_0_comparison']."\",";
$listFilterModeFields .= "),\n";
}
if($listFilterModeFields != ""){
$file_content = str_replace("<FILTER_MODE_COLUMNS>", $listFilterModeFields, $file_content);
$file_content = str_replace("//%//", "", $file_content);
}
## +---------------------------------------------------------------------------+
## | 6. View Mode Settings: |
## +---------------------------------------------------------------------------+
if($selDefiningFieldsView == "all"){
$file_content = str_replace("<AUTO_COLUMN_IN_VIEW_MODE>", "true", $file_content);
}else{
$file_content = str_replace("<AUTO_COLUMN_IN_VIEW_MODE>", "false", $file_content);
$listViewModeColumns = "";
foreach($arrViewModeFields as $key => $val){
if(array_key_exists("vm_fields_".$val."_name", $_POST)){
//if($vm_fields_primary_key != $_POST["vm_fields_".$val."_name"]){
$listViewModeColumns .= "\"".$val."\"=>array(";
$listViewModeColumns .= "\"header\"=>\"".$_POST["vm_fields_".$val."_header"]."\",";
$listViewModeColumns .= "\"visible\"=>\"".$_POST["vm_fields_".$val."_visible"]."\",";
$listViewModeColumns .= "\"type\"=>\"".$_POST["vm_fields_".$val."_type"]."\",";
$listViewModeColumns .= "\"align\"=>\"".$_POST["vm_fields_".$val."_align"]."\",";
$listViewModeColumns .= "\"width\"=>\"".$_POST["vm_fields_".$val."_width"]."\",";
$listViewModeColumns .= "\"wrap\"=>\"".$_POST["vm_fields_".$val."_wrap"]."\",";
$listViewModeColumns .= "\"case\"=>\"".$_POST["vm_fields_".$val."_case"]."\",";
$listViewModeColumns .= "\"text_length\"=>\"".$_POST["vm_fields_".$val."_text_length"]."\",";
$listViewModeColumns .= "\"tooltip\"=>\"".$_POST["vm_fields_".$val."_tooltip"]."\"";
$listViewModeColumns .= "),\n";
//}
}
}
if($listViewModeColumns != ""){
$file_content = str_replace("<VIEW_MODE_COLUMNS>", $listViewModeColumns, $file_content);
$file_content = str_replace("//&//", "", $file_content);
}
}
## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode Settings: |
## +---------------------------------------------------------------------------+
$file_content = str_replace("<EDIT_MODE_TABLE>", $selEditModeTable, $file_content);
// set Add/Edit/Details Mode table width
$file_content = str_replace("<EDIT_MODE_TABLE_WIDTH>", $em_table_width.$em_table_width_units, $file_content);
if($selDefiningFieldsEdit == "all"){
$file_content = str_replace("<AUTO_COLUMN_IN_EDIT_MODE>", "true", $file_content);
$sql = "SHOW COLUMNS FROM ".$selEditModeTable;
$db->Query($sql);
$fields_count = 0;
while($row = $db->FetchArray()){
if($fields_count == 0) $em_fields_primary_key = $row[0];
else if(strtolower($row['Key']) == "pri") $em_fields_primary_key = $row['Field'];
$fields_count++;
}
$file_content = str_replace("<EDIT_MODE_PRIMARY_KEY>", $em_fields_primary_key, $file_content);
}else{
$file_content = str_replace("<AUTO_COLUMN_IN_EDIT_MODE>", "false", $file_content);
// set list of fields
$listEditModeColumns = "";
$sql = "SHOW COLUMNS FROM ".$selEditModeTable;
$db->Query($sql);
while($row = $db->FetchArray()){
$arrEditModeFields[] = $row['Field'];
}
foreach($arrEditModeFields as $key => $val){
if(array_key_exists("em_fields_".$val."_name", $_POST)){
if($em_fields_primary_key != $_POST["em_fields_".$val."_name"]){
$listEditModeColumns .= "\"".$val."\"=>array(";
$listEditModeColumns .= "\"header\"=>\"".$_POST["em_fields_".$val."_header"]."\",";
$listEditModeColumns .= "\"visible\"=>\"".$_POST["em_fields_".$val."_visible"]."\",";
$listEditModeColumns .= "\"type\"=>\"".$_POST["em_fields_".$val."_type"]."\",";
$listEditModeColumns .= "\"align\"=>\"".$_POST["em_fields_".$val."_align"]."\",";
$listEditModeColumns .= "\"width\"=>\"".$_POST["em_fields_".$val."_width"]."\",";
if($_POST["em_fields_".$val."_type"] == "checkbox"){
$listEditModeColumns .= "\"req_type\"=>\"".$_POST["em_fields_".$val."_req_type"]."y\",";
$listEditModeColumns .= "\"true_value\"=>1, \"false_value\"=>0,";
}else{
$em_fields_req_subtype = isset($_POST["em_fields_".$val."_req_subtype"]) ? $_POST["em_fields_".$val."_req_subtype"] : "y";
$listEditModeColumns .= "\"req_type\"=>\"".$_POST["em_fields_".$val."_req_type"].$em_fields_req_subtype."\",";
}
$listEditModeColumns .= "\"readonly\"=>\"".$_POST["em_fields_".$val."_readonly"]."\",";
$listEditModeColumns .= "\"unique\"=>\"".$_POST["em_fields_".$val."_unique"]."\",";
$listEditModeColumns .= "\"default\"=>\"".$_POST["em_fields_".$val."_default"]."\",";
if($_POST["em_fields_".$val."_type"] == "textarea") $listEditModeColumns .= "\"edit_type\"=>\"".(isset($_POST["em_fields_".$val."_edit_type"]) ? $_POST["em_fields_".$val."_edit_type"] : "")."\",";
if($_POST["em_fields_".$val."_type"] == "file" || $_POST["em_fields_".$val."_type"] == "image") $listEditModeColumns .= "\"target_path\"=>\"".(isset($_POST["em_fields_".$val."_target_path"]) ? $_POST["em_fields_".$val."_target_path"] : "")."\"";
$listEditModeColumns .= "),\n";
}
}
}
$file_content = str_replace("<EDIT_MODE_PRIMARY_KEY>", $em_fields_primary_key, $file_content);
if($listEditModeColumns != ""){
$file_content = str_replace("<EDIT_MODE_COLUMNS>", $listEditModeColumns, $file_content);
$file_content = str_replace("//#//", "", $file_content);
}
}
## +-- Foreign Keys --------------------------------------------+
$listForeignKeysFields = "";
$sql = "SELECT * FROM ".TABLE_DG_WIZARD_FOREIGN_KEYS." WHERE datagrid_page_id = ".$dgpid;
$db->Query($sql);
while($row = $db->FetchArray()){
$listForeignKeysFields .= "\"".$row['f_foreign_field']."\"=>array(";
$listForeignKeysFields .= "\"table\"=>\"".$row['f_table']."\",";
$listForeignKeysFields .= "\"field_key\"=>\"".$row['f_field_key']."\",";
$listForeignKeysFields .= "\"field_name\"=>\"".$row['f_field_name']."\",";
$listForeignKeysFields .= "\"view_type\"=>\"".$row['f_view_type']."\",";
$listForeignKeysFields .= "\"order_type\"=>\"".$row['f_order_type']."\"";
$listForeignKeysFields .= "),\n";
}
// last
if($foreign_keys_act == "insert_foreign_keys_field" && $fkm_fields_0_foreign_field != ""){
$listForeignKeysFields .= "\"".$fkm_fields_0_foreign_field."\"=>array(";
$listForeignKeysFields .= "\"table\"=>\"".$fkm_fields_0_table."\",";
$listForeignKeysFields .= "\"field_key\"=>\"".$fkm_fields_0_field_key."\",";
$listForeignKeysFields .= "\"field_name\"=>\"".$fkm_fields_0_field_name."\",";
$listForeignKeysFields .= "\"view_type\"=>\"".$fkm_fields_0_view_type."\",";
$listForeignKeysFields .= "\"order_type\"=>\"".$fkm_fields_0_order_type."\"";
$listForeignKeysFields .= "),\n";
}
if($listForeignKeysFields != ""){
$file_content = str_replace("<FOREIGH_KEYS_COLUMNS>", $listForeignKeysFields, $file_content);
$file_content = str_replace("//+//", "", $file_content);
}
## +---------------------------------------------------------------------------+
// remove all unnecessary comments
$file_content = str_replace("//*//", "", $file_content);
$file_content = str_replace("<DATE_CREATED>", @date("M d, Y g:i A"), $file_content);
$file_content = str_replace("<FILE_NAME>", $page_name, $file_content);
fwrite($fh, $file_content);
fclose($fh);
$msg = draw_message("success", "The DataGrid page was successfully created!", false, $msg_width, $path);
$created = true;
// ---------------------------------------------------------
// save Add/Edit Mode parameters of datagrid in database
$sql = "SELECT * FROM ".TABLE_DG_WIZARD_SETTINGS." WHERE datagrid_page_id = ".$dgpid;
$db->Query($sql);
if($db->RowCount() > 0){
$sql = "UPDATE ".TABLE_DG_WIZARD_SETTINGS." SET
unique_pefix = '".$txtUniquePrefix."',
debug_mode = '".$txtDebugMode."',
allow_operation_add = '".$chkOperationAdd."',
allow_operation_edit = '".$chkOperationEdit."',
allow_operation_delete = '".$chkOperationDelete."',
allow_operation_details = '".$chkOperationDetails."',
allow_multi_operations = '".$chkMltOperations."',
allow_multi_operation_edit = '".$chkMltOperationEdit."',
allow_multi_operation_details = '".$chkMltOperationDetails."',
allow_multi_operation_delete = '".$chkMltOperationDelete."',
language = '".$selLangName."',
lang_collation = '".$selLangCollation."',
css_class = '".$selCssClass."',
allow_printing = '".$selPrinting."',
allow_exporting = '".$selExporting."',
export_all_records = '".$selExportAll."',
allow_sorting = '".$selSorting."',
allow_paging = '".$selPaging."',
allow_filtering = '".$selFiltering."',
vm_table_name = '".$selViewModeTable."',
vm_primary_key = '".$vm_fields_primary_key."',
vm_table_width = '".$vm_table_width."',
vm_table_width_units = '".$vm_table_width_units."',
em_table_name = '".$selEditModeTable."',
em_primary_key = '".$em_fields_primary_key."',
em_table_width = '".$em_table_width."',
em_table_width_units = '".$em_table_width_units."'
WHERE datagrid_page_id = ".$dgpid."";
$db->Exec($sql);
if($debug) $debug_msg .= "<br /><br /><b><i>Update Settings Table:</i></b> (total: ".$db->AffectedRows().") ".$db->Error()."<br />".$sql;
}else{
$sql = "INSERT INTO ".TABLE_DG_WIZARD_SETTINGS." (
datagrid_page_id,
unique_pefix,
debug_mode,
allow_operation_add,
allow_operation_edit,
allow_operation_delete,
allow_operation_details,
allow_multi_operations,
allow_multi_operation_edit,
allow_multi_operation_details,
allow_multi_operation_delete,
language,
lang_collation,
css_class,
allow_printing,
allow_exporting,
export_all_records,
allow_sorting,
allow_paging,
allow_filtering,
vm_table_name,
vm_primary_key,
vm_table_width,
vm_table_width_units,
em_table_name,
em_primary_key,
em_table_width,
em_table_width_units
)VALUES(
".$dgpid.",
'".$txtUniquePrefix."',
'".$txtDebugMode."',
'".$chkOperationAdd."',
'".$chkOperationEdit."',
'".$chkOperationDelete."',
'".$chkOperationDetails."',
'".$chkMltOperations."',
'".$chkMltOperationEdit."',
'".$chkMltOperationDetails."',
'".$chkMltOperationDelete."',
'".$selLangName."',
'".$selLangCollation."',
'".$selCssClass."',
'".$selPrinting."',
'".$selExporting."',
'".$selExportAll."',
'".$selSorting."',
'".$selPaging."',
'".$selFiltering."',
'".$selViewModeTable."',
'".$vm_fields_primary_key."',
'".$vm_table_width."',
'".$vm_table_width_units."',
'".$selEditModeTable."',
'".$em_fields_primary_key."',
'".$em_table_width."',
'".$em_table_width_units."'
)";
$db->Exec($sql);
if($debug) $debug_msg .= "<br /><br /><b><i>Insert to Settings Table:</i></b> (total: ".$db->AffectedRows().") ".$db->Error()."<br />".$sql;
}
// ---------------------------------------------------------
// save View Mode parameters of datagrid in database
$sql = "DELETE FROM ".TABLE_DG_WIZARD_FIELDS." WHERE mode = '0' AND datagrid_page_id = ".$dgpid;
$db->Exec($sql);
$sql = "INSERT INTO ".TABLE_DG_WIZARD_FIELDS."
(id, datagrid_page_id, mode,
field_name,
field_header,
field_visible,
field_type,
field_align,
field_width,
field_wrap,
field_case,
field_text_length,
field_tooltip,
field_req_type,
field_req_subtype,
field_readonly,
field_unique,
field_default,
field_edit_type,
field_target_path) VALUES ";
$fields_count = 0;
foreach($arrViewModeFields as $key => $val){
if(array_key_exists("vm_fields_".$val."_name", $_POST)){
if($fields_count > 0) $sql .= ", ";
$sql .= "(NULL, ".$dgpid.", '0',
'".$_POST["vm_fields_".$val."_name"]."',
'".$_POST["vm_fields_".$val."_header"]."',
'".$_POST["vm_fields_".$val."_visible"]."',
'".$_POST["vm_fields_".$val."_type"]."',
'".$_POST["vm_fields_".$val."_align"]."',
'".$_POST["vm_fields_".$val."_width"]."',
'".$_POST["vm_fields_".$val."_wrap"]."',
'".$_POST["vm_fields_".$val."_case"]."',
'".$_POST["vm_fields_".$val."_text_length"]."',
'".$_POST["vm_fields_".$val."_tooltip"]."',
'',
'',
'false',
'false',
'',
'',
'')";
$fields_count++;
}
};
if($fields_count == 0) $sql .= "(NULL, ".$dgpid.", '0', '*', '', '', '', '', '', '', '', '-1', 'false', '', '', 'false', 'false', '', '', '')";
$db->Exec($sql);
if($debug) $debug_msg .= "<br /><br /><b><i>Insert fields for View Mode:</i></b> (total: ".$db->AffectedRows().") ".$db->Error()."<br />".$sql;
// ---------------------------------------------------------
// save Add/Edit Mode parameters of datagrid in database
$sql = "DELETE FROM ".TABLE_DG_WIZARD_FIELDS." WHERE mode = '1' AND datagrid_page_id = ".$dgpid;
$db->Exec($sql);
$sql = "INSERT INTO ".TABLE_DG_WIZARD_FIELDS."
(id, datagrid_page_id, mode,
field_name,
field_header,
field_visible,
field_type,
field_align,
field_width,
field_wrap,
field_case,
field_text_length,
field_tooltip,
field_req_type,
field_req_subtype,
field_readonly,
field_unique,
field_default,
field_edit_type,
field_target_path) VALUES ";
$fields_count_em = 0;
foreach($arrEditModeFields as $key => $val){
if(array_key_exists("em_fields_".$val."_name", $_POST)){
if($fields_count_em > 0) $sql .= ", ";
$em_fields_req_subtype = isset($_POST["em_fields_".$val."_req_subtype"]) ? $_POST["em_fields_".$val."_req_subtype"] : "y";
$sql .= "(NULL, ".$dgpid.", '1',
'".$_POST["em_fields_".$val."_name"]."',
'".$_POST["em_fields_".$val."_header"]."',
'".$_POST["em_fields_".$val."_visible"]."',
'".$_POST["em_fields_".$val."_type"]."',
'".$_POST["em_fields_".$val."_align"]."',
'".$_POST["em_fields_".$val."_width"]."',
'',
'',
'',
'',
'".$_POST["em_fields_".$val."_req_type"]."',
'".$em_fields_req_subtype."',
'".$_POST["em_fields_".$val."_readonly"]."',
'".$_POST["em_fields_".$val."_unique"]."',
'".$_POST["em_fields_".$val."_default"]."',
'".$_POST["em_fields_".$val."_edit_type"]."',
'".$_POST["em_fields_".$val."_target_path"]."')";
$fields_count_em++;
}
};
if($fields_count_em == 0) $sql .= "(NULL, ".$dgpid.", '1', '*', '', '', '', '', '', '', '', '', '', '', '', 'false', 'false', '', '', '')";
$db->Exec($sql);
if($debug) $debug_msg .= "<br /><br /><b><i>Insert fields for Add/Edit Mode:</i></b> (total: ".$db->AffectedRows().") ".$db->Error()."<br />".$sql;
// ---------------------------------------------------------
// save Filtering Mode parameters of datagrid in database
if(isset($_POST["fm_fields_0_caption"]) && $_POST["fm_fields_0_caption"] != ""){
$fm_fields_0_caption = isset($_POST["fm_fields_0_caption"]) ? $_POST["fm_fields_0_caption"] : "";
$fm_fields_0_type = isset($_POST["fm_fields_0_type"]) ? $_POST["fm_fields_0_type"] : "";
$fm_fields_0_table = isset($_POST["fm_fields_0_table"]) ? $_POST["fm_fields_0_table"] : "";
$fm_fields_0_field = isset($_POST["fm_fields_0_field"]) ? $_POST["fm_fields_0_field"] : "";
$fm_fields_0_operator = isset($_POST["fm_fields_0_operator"]) ? $_POST["fm_fields_0_operator"] : "";
$fm_fields_0_sensitivity = isset($_POST["fm_fields_0_sensitivity"]) ? $_POST["fm_fields_0_sensitivity"] : "";
$fm_fields_0_comparison = isset($_POST["fm_fields_0_comparison"]) ? $_POST["fm_fields_0_comparison"] : "";
$sql = "DELETE FROM ".TABLE_DG_WIZARD_FILTERING." WHERE f_caption = '".$fm_fields_0_caption."' AND datagrid_page_id = ".(int)$dgpid;
$db->Exec($sql);
$sql = "INSERT INTO ".TABLE_DG_WIZARD_FILTERING."
(id, datagrid_page_id,
f_caption,
f_type,
f_table,
f_field,
f_operator,
f_sensitivity,
f_comparison) VALUES ";
$sql .= "(NULL, ".$dgpid.",
'".$fm_fields_0_caption."',
'".$fm_fields_0_type."',
'".$fm_fields_0_table."',
'".$fm_fields_0_field."',
'".$fm_fields_0_operator."',
'".$fm_fields_0_sensitivity."',
'".$fm_fields_0_comparison."')";
///echo $sql;
$db->Exec($sql);
if($debug) $debug_msg .= "<br /><br /><b><i>Insert fields for Filtering Mode:</i></b> (total: ".$db->AffectedRows().") ".$db->Error()."<br />".$sql;
}
// ---------------------------------------------------------
// save Foreign Keys parameters of datagrid in database
if($foreign_keys_act == "insert_foreign_keys_field" && $fkm_fields_0_foreign_field != ""){
$sql = "DELETE FROM ".TABLE_DG_WIZARD_FOREIGN_KEYS." WHERE f_foreign_field = '".$fkm_fields_0_foreign_field."' AND datagrid_page_id = ".(int)$dgpid;
$db->Exec($sql);
$sql = "INSERT INTO ".TABLE_DG_WIZARD_FOREIGN_KEYS."
(id, datagrid_page_id,
f_foreign_field,
f_table,
f_field_key,
f_field_name,
f_view_type,
f_order_type) VALUES ";
$sql .= "(NULL, ".$dgpid.",
'".$fkm_fields_0_foreign_field."',
'".$fkm_fields_0_table."',
'".$fkm_fields_0_field_key."',
'".$fkm_fields_0_field_name."',
'".$fkm_fields_0_view_type."',
'".$fkm_fields_0_order_type."')";
///echo $sql;
$db->Exec($sql);
if($debug) $debug_msg .= "<br /><br /><b><i>Insert fields for Foreign Keys:</i></b> (total: ".$db->AffectedRows().") ".$db->Error()."<br />".$sql;
}
// update some fields in datagrid_pages table
$sql = "UPDATE ".TABLE_DATAGRID_PAGES." SET updated_at = '"hide@address.com("Y-m-d H:i:s")."' WHERE id = ".(int)$dgpid;
$db->Exec($sql);
}
@chmod($path."pages/".$file_name, 0644);
}
}
$arrViewModeFields = array();
$arrEditModeFields = array();
if($act == "dont_retrive_view_mode_fields"){
// View Mode - do nothing
// Edit Mode - retrive
dont_retrive_view_mode_fields($arrEditModeFields, $selEditModeTable);
}else if($act == "dont_retrive_edit_mode_fields"){
// Edit Mode - do nothing
// View Mode - retrive
dont_retrive_edit_mode_fields($arrViewModeFields, $selViewModeTable);
}else if($act == "retrive_view_edit_mode_fields"){
// View Mode - retrive
// Edit Mode - retrive
retrive_view_edit_mode_fields($arrViewModeFields, $selViewModeTable, $arrEditModeFields, $selEditModeTable);
}else{
// do nothing "dont_retrive_view_edit_mode_fields"
}
// FILTER FIELDS
if($filter_act == "add_filter_field"){
//retrive_filter_mode_fields($arrFilterModeFields);
$arrFilterModeFields = $arrViewModeFields;
}else if($filter_act == "remove_filter_field"){
$sql = "DELETE FROM ".TABLE_DG_WIZARD_FILTERING." WHERE id = ".(int)$filter_act_id;
$db->Exec($sql);
}
// FOREIGN FIELDS
if($foreign_keys_act == "add_foreign_keys_field"){
$arrForeignKeysFields = $arrEditModeFields;
}else if($foreign_keys_act == "remove_foreign_keys_field"){
$sql = "DELETE FROM ".TABLE_DG_WIZARD_FOREIGN_KEYS." WHERE id = ".(int)$foreign_keys_act_id;
$db->Exec($sql);
}else if($foreign_keys_act == "change_foreign_keys_table"){
retrive_foreign_key_table_fields($arrForeignKeysTableFields, $foreign_keys_act_table);
}
}
//////////////////////////////////////////////////////////////////////////////////
$sql = "SELECT
".TABLE_MENU.".name,
".TABLE_MENU.".page_name
FROM ".TABLE_DATAGRID_PAGES."
INNER JOIN ".TABLE_MENU." ON ".TABLE_DATAGRID_PAGES.".menu_id = ".TABLE_MENU.".id
WHERE ".TABLE_DATAGRID_PAGES.".id = ".(int)$dgpid;
$db->Query($sql);
if($row = $db->FetchArray()){
$page_name = $row['name'];
$file_name = $row['page_name'];
}
// remove tables, used for View and Edit modes
$arrAllowedFKTables = remove_item_by_value($arrAllowedFKTables, $selViewModeTable);
$arrAllowedFKTables = remove_item_by_value($arrAllowedFKTables, $selEditModeTable);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><?php echo $SETTINGS['site_name']; ?> :: Admin Panel :: DataGrid Wizard</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link href="../styles/<?php echo $SETTINGS['css_style'];?>/style.css" type="text/css" rel="stylesheet">
<style>
SPAN.l {
color:#002070;
border-bottom:1px dotted #bababa;
}
LEGEND {
margin-bottom:3px;
cursor:pointer;
}
.yes { color:green; }
.no { color:darkred; }
#tblFilterMode TH { background-color:#f1f2f3; border:1px solid #ababab; }
#tblViewMode TH { background-color:#f1f2f3; border:1px solid #ababab; }
#tblEditMode TH { background-color:#f1f2f3; border:1px solid #ababab; }
#tblForeignKeys TH { background-color:#f1f2f3; border:1px solid #ababab; }
</style>
<!-- JavaScript files -->
<script type="text/javascript" src="../modules/jquery/jquery.js"></script>
<script type="text/javascript" src="../modules/datagrid_wizard/js/functions.common.js"></script>
<script type="text/javascript" src="../modules/datagrid_wizard/js/functions.wizard.js"></script>
</head>
<body dir="<?php echo $SETTINGS['language_dir'];?>">
<div id="dgWrapper">
<h3>DataGrid Wizard - <?php echo $page_name." (".$file_name.")"; ?></h3>
<form name="frmEditPage" id="frmEditPage" action="datagrid_wizard.php" method="post">
<input type="hidden" name="act" id="act" value="" />
<input type="hidden" name="filter_act" id="filter_act" value="" />
<input type="hidden" name="filter_act_id" id="filter_act_id" value="" />
<input type="hidden" name="foreign_keys_act" id="foreign_keys_act" value="" />
<input type="hidden" name="foreign_keys_act_id" id="foreign_keys_act_id" value="" />
<input type="hidden" name="foreign_keys_act_table" id="foreign_keys_act_table" value="" />
<input type="hidden" name="submit_act" id="submit_act" value="" />
<input type="hidden" name="dgpid" value="<?php echo $dgpid;?>" />
<input type="hidden" name="file_name" value="<?php echo $file_name;?>" />
<table border="0" cellpadding="2" cellspacing="2" width="<?php echo $fieldset_width; ?>" style="margin-bottom:5px;">
<tr valign="top">
<td><?php echo $msg;?></td>
<td></td>
</tr>
</table>
<?php draw_buttons(); ?>
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px;border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsCreatingCalling')"><b>Creating & Calling</b></legend>
<table id="fsCreatingCalling" <?php echo (($fsCreatingCalling_state == "close") ? "style='display:none;'" : ""); ?> align="left" border="0" cellpadding="2" cellspacing="2" width="<?php echo $fieldset_width; ?>">
<tr valign="top">
<td align="left" width="190px"><span class='l'>Unique Prefix: (ex.: ABC_)</span></td>
<td align="left"><input type="text" name="txtUniquePrefix" size="7" maxlength="10" value="<?php echo $txtUniquePrefix; ?>" /></td>
<td align="right">
<span class='l'>Debug Mode:</span>
<input type='radio' name='txtDebugMode' id='txtDebugModeOn' value='true' <?php echo (($txtDebugMode === "true") ? "checked='checked'" : ""); ?> /> <label for="txtDebugModeOn">On</label>
<input type='radio' name='txtDebugMode' id='txtDebugModeOff' value='false' <?php echo (($txtDebugMode === "false") ? "checked='checked'" : ""); ?> /> <label for="txtDebugModeOff">Off</label>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px; border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsGeneralSettings')"><b>General Settings</b></legend>
<table id="fsGeneralSettings" <?php echo (($fsGeneralSettings_state == "close") ? "style='display:none;'" : ""); ?> border="0" align="left" cellpadding="2" cellspacing="2" width="100%">
<tr valign="top">
<td align="left" width="200px"><span class='l'>Language:</span></td>
<td align="left" width="210px">
<select name="selLangName">
<?php
$fill_from_array_languages = $config->langsArray();
foreach($fill_from_array_languages as $key => $val){
echo "<option ".(($selLangName == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
<td align="left">
<span class='l'>Collation:</span>
<select name="selLangCollation">
<option value="">-- select --</option>
<?php
foreach($fill_from_array_collations as $key => $val){
foreach($val as $v_key => $v_val){
if($key == $v_val['value']){
echo "<optgroup label='".str_replace(".", "", $v_val['value'])."' title='".$v_val['title']."'>";
}else{
echo "<option ".(($selLangCollation == $v_val['value']) ? "selected" : "")." value='".$v_val['value']."' title='".$v_val['title']."'>".$v_val['value']."</option>";
}
}
echo "</optgroup>";
}
?>
</select>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px"><span class='l'>CSS Class:</span></td>
<td align="left" colspan="2">
<select name="selCssClass">
<?php
$arrCssClass = array("default"=>"Default", "blue"=>"Blue", "x-blue"=>"X-Blue", "gray"=>"Gray", "x-gray"=>"X-gray", "green"=>"Green", "pink"=>"Pink");
foreach($arrCssClass as $key => $val){
echo "<option ".(($selCssClass == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px"><span class='l'>Allowed Mode Operations:</span></td>
<td align="left" colspan="2">
<input type="checkbox" name="chkOperationAdd" id="chkOperationAdd" value="true" <?php echo ($chkOperationAdd == "true" ? "checked" : ""); ?> /> <label for="chkOperationAdd">Add</label> |
<input type="checkbox" name="chkOperationEdit" id="chkOperationEdit" value="true" <?php echo ($chkOperationEdit == "true" ? "checked" : ""); ?> /> <label for="chkOperationEdit">Edit</label> |
<input type="checkbox" name="chkOperationDelete" id="chkOperationDelete" value="true" <?php echo ($chkOperationDelete == "true" ? "checked" : ""); ?> /> <label for="chkOperationDelete">Delete</label> |
<input type="checkbox" name="chkOperationDetails" id="chkOperationDetails" value="true" <?php echo ($chkOperationDetails == "true" ? "checked" : ""); ?> /> <label for="chkOperationDetails">Details</label>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px"><span class='l'>Multi-Row Operations:</span></td>
<td align="left">
<input type="checkbox" name="chkMltOperationEdit" id="chkMltOperationEdit" value="true" <?php echo ($chkMltOperationEdit == "true" ? "checked" : ""); ?> /> <label for="chkMltOperationEdit">Edit</label> |
<input type="checkbox" name="chkMltOperationDetails" id="chkMltOperationDetails" value="true" <?php echo ($chkMltOperationDetails == "true" ? "checked" : ""); ?> /> <label for="chkMltOperationDetails">Details</label> |
<input type="checkbox" name="chkMltOperationDelete" id="chkMltOperationDelete" value="true" <?php echo ($chkMltOperationDelete == "true" ? "checked" : ""); ?> /> <label for="chkMltOperationDelete">Delete</label>
</td>
<td align="left">
<span class='l'>Enable:</span>
<input type="radio" name="chkMltOperations" id="chkMltOperationsOn" onclick='chkMltOperations_OnClick(this.value)' value="true" <?php echo ($chkMltOperations == "true" ? "checked='checked'" : ""); ?> /> <label for="chkMltOperationsOn">On</label>
<input type="radio" name="chkMltOperations" id="chkMltOperationsOff" onclick='chkMltOperations_OnClick(this.value)' value="false" <?php echo ($chkMltOperations == "false" ? "checked='checked'" : ""); ?> /> <label for="chkMltOperationsOff">Off</label>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px;border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsPrintingExporting')"><b>Printing & Exporting Settings</b></legend>
<table id="fsPrintingExporting" <?php echo (($fsPrintingExporting_state == "close") ? "style='display:none;'" : ""); ?> border="0" align="left" cellpadding="2" cellspacing="2" width="100%">
<tr valign="top">
<td align="left" width="200px"><span class='l'>Allow Printing:</span></td>
<td align="left">
<select name="selPrinting">
<?php
$arrPrinting = array("false"=>"No", "true"=>"Yes");
foreach($arrPrinting as $key => $val){
echo "<option ".(($selPrinting == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px"><span class='l'>Allow Exporting:</span></td>
<td align="left">
<select name="selExporting">
<?php
$arrExporting = array("false"=>"No", "true"=>"Yes");
foreach($arrExporting as $key => $val){
echo "<option ".(($selExporting == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
<span class='l'>Export all records</span>:
<select name="selExportAll">
<?php
$arrExportAll = array("false"=>"No", "true"=>"Yes");
foreach($arrExportAll as $key => $val){
echo "<option ".(($selExportAll == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px; border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsSortingPaging')"><b>Sorting & Paging Settings</b></legend>
<table id="fsSortingPaging" <?php echo (($fsSortingPaging_state == "close") ? "style='display:none;'" : ""); ?> border="0" align="left" cellpadding="2" cellspacing="2" width="100%">
<tr valign="top">
<td align="left" width="200px"><span class='l'>Allow Column Sorting:</span></td>
<td align="left">
<select name="selSorting">
<?php
$arrSorting = array("false"=>"No", "true"=>"Yes");
foreach($arrSorting as $key => $val){
echo "<option ".(($selSorting == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px"><span class='l'>Allow Paging:</span></td>
<td align="left">
<select name="selPaging">
<?php
$arrPaging = array("false"=>"No", "true"=>"Yes");
foreach($arrPaging as $key => $val){
echo "<option ".(($selPaging == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px; border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsFiltering')"><b>Filtering Settings</b></legend>
<table id="fsFiltering" <?php echo (($fsFiltering_state == "close") ? "style='display:none;'" : ""); ?> border="0" align="left" cellpadding="2" cellspacing="2" width="100%">
<tr valign="top">
<td align="left" width="200px"><span class='l'>Allow Filtering:</span></td>
<td align="left">
<select name="selFiltering">
<?php
$arrFiltering = array("false"=>"No", "true"=>"Yes");
foreach($arrFiltering as $key => $val){
echo "<option ".(($selFiltering == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<table id='tblFilterMode' border='0' width='100%'>
<?php
$sql = "SELECT * FROM ".TABLE_DG_WIZARD_FILTERING." WHERE datagrid_page_id = ".$dgpid;
$db->Query($sql);
if($db->RowCount() > 0 || $filter_act == "add_filter_field"){
echo "<tr align='center'>
<th align='left'> <b>Caption</b></th>
<th><b>Type</b></th>
<th><b>Table</b></th>
<th><b>Field</b></th>
<th><b>Operator</b></th>
<th><b>Case Sensitive</b></th>
<th><b>Comparison Type</b></th>
<th></th>
</tr>";
}else{
echo "<tr><td colspan='8'></td></tr>";
}
while($row = $db->FetchArray()){
echo "<tr>";
echo "<td>".$row['f_caption']."</td>";
echo "<td align='center'>".$row['f_type']."</td>";
echo "<td align='center'>".$row['f_table']."</td>";
echo "<td align='center'>".$row['f_field']."</td>";
echo "<td align='center'>".$row['f_operator']."</td>";
echo "<td align='center'>".(($row['f_sensitivity'] == "true") ? "Yes" : "No")."</td>";
echo "<td align='center'>".$row['f_comparison']."</td>";
echo "<td align='center'><a href='javascript:removeFilteringFields(\"".$row['id']."\");' title='Click to Remove from DataGrid'><img src='../images/remove.png' alt='' /></a></td>";
echo "</tr>";
}
if($filter_act == "add_filter_field"){
echo "<tr align='center'>";
echo "<td><input type='text' style='width:70px' name='fm_fields_0_caption' id='fm_fields_0_caption' value='' /></td>";
echo "<td><select name='fm_fields_0_type'>
<option value='textbox'>Textbox</option>
<option value='dropdownlist'>Dropdownlist</option>
<option value='calendar'>Calendar</option>
</select></td>";
echo "<td>
<select name='fm_fields_0_table' id='fm_fields_0_table' style='width:100px;'>
<option value=''>-- select --</option>";
if($selFilterModeTable != ""){
echo "<option value='".$selFilterModeTable."'>".$selFilterModeTable."</option>";
}
echo "</select></td>";
echo "<td>
<select name='fm_fields_0_field' id='fm_fields_0_field' style='width:100px;'>
<option value=''>-- select --</option>";
if(count($arrViewModeFields) <= 0) retrive_view_mode_fields($arrViewModeFields, $selFilterModeTable);
foreach($arrViewModeFields as $key){
echo "<option value='". $key."'>". $key."</option>";
}
echo "</select></td>";
echo "<td>
<select name='fm_fields_0_operator' id='fm_fields_0_operator'>
<option value='='> = </option>
<option value='<'> < </option>
<option value='>'> > </option>
<option value='like'> like </option>
<option value='%like'> %like </option>
<option value='like%'> like% </option>
<option value='%like%'> %like% </option>
<option value='not like'> not like </option>
</select></td>";
echo "<td>
<select name='fm_fields_0_sensitivity' id='fm_fields_0_sensitivity'>
<option value='false'>No</option>
<option value='true'>Yes</option>
</select></td>";
echo "<td>
<select name='fm_fields_0_comparison' id='fm_fields_0_comparison'>
<option value='string'>String</option>
<option value='numeric'>Numeric</option>
<option value='binary'>Binary</option>
</select>
</td>
<td></td>";
echo "</tr>";
}
?>
</table>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px">
<?php if($filter_act == "" || $filter_act == "remove_filter_field"){ ?>
<a href="javascript:void('filtering|add new');" onclick="javascript:addFilteringFields();">+ Add New Field</a>
<?php }else{ ?>
<a href="javascript:void('filtering|insert');" onclick="javascript:insertFilteringFields();">↓ Insert Field</a> | <a href="javascript:void('filtering|cancel');" onclick="javascript:cancelFilteringFields();">Cancel</a>
<?php } ?>
</td>
<td align="left"></td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px; border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsViewMode')"><b>VIEW MODE Settings</b></legend>
<table id="fsViewMode" <?php echo (($fsViewMode_state == "close") ? "style='display:none;'" : ""); ?> align="left" border="0" cellpadding="2" cellspacing="2" width="<?php echo $fieldset_width; ?>">
<tr><td colspan='4' nowrap height='3px'></td></tr>
<tr valign="top">
<td align="left" nowrap width="10px"></td>
<td align="left" nowrap>
<span class='l'>Table</span> <a style='cursor:help;color:#0000a3' title='You may select only non-system tables! To work with your own tables, you have to add them to the database before. Remember: new tables must be created with the same prefix that was used while installation of ApPHP AdminPanel.'>[?]</a>: <font color="#b60000">*</a>
<select name="selViewModeTable" id="selViewModeTable" style="width:240px;" onchange="selViewModeTable_OnChange()">
<option value="">-- select --</option>
<?php
foreach($arrAllowedTables as $table){
echo "<option ".(($selViewModeTable == $table) ? "selected" : "")." value='".$table."'>".$table."</option>";
}
?>
</select>
</td>
<td align="left" nowrap>
<span class='l'>Fields Definition:</span>
<select name="selDefiningFieldsView" id="selDefiningFieldsView" onchange="selDefiningFieldsView_OnChange()">
<?php
$arrDefiningFields = array("all"=>"All fields (*) - auto generated", "by_one"=>"Specify by one");
foreach($arrDefiningFields as $key => $val){
echo "<option ".(($selDefiningFieldsView == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
<td align="left" nowrap>
<span class='l'>Width:</span> <input type="text" name="txtViewModeTableWidth" style="width:32px" maxlength="4" value="<?php echo $vm_table_width; ?>" />
<select name="txtViewModeTableWidthUnits">
<option value="%" <?php echo (($vm_table_width_units == "%") ? "selected='selected'" : ""); ?>>%</option>
<option value="px" <?php echo (($vm_table_width_units == "px") ? "selected='selected'" : ""); ?>>px</option>
<option value="em" <?php echo (($vm_table_width_units == "em") ? "selected='selected'" : ""); ?>>em</option>
<option value="pt" <?php echo (($vm_table_width_units == "pt") ? "selected='selected'" : ""); ?>>pt</option>
</select>
</td>
</tr>
<?php
if(count($arrViewModeFields) > 0) echo "<tr><td colspan='4' nowrap height='10px' style='margin-top:3px; padding-top:2px; border-bottom:1px solid #dedede;'></td></tr>";
?>
<tr valign="top">
<td colspan='4' align='right'>
<?php
if(count($arrViewModeFields) > 0)
{
echo "<table id='tblViewMode' border='0'>";
echo "<tr align='center'>
<th title='Primary Key'><b>PK</b></th>
<th align='left'> <b>Field</b></th>
<th><b>Visible</b></th>
<th><b>Header</b></th>
<th><b>Type</b></th>
<th><b>Align</b></th>
<th nowrap><b>Width</b> <a href='javascript:void(0);' style='cursor:help;' title='Usage: 10% or 200px'>[?]</a></th>
<th><b>Wrap</b></th>
<th><b>Case</b></th>
<th><b>Len</b> <a href='javascript:void(0);' style='cursor:help;' title='Text Length attribute - defines a visible length of the field text in View Mode. To see hidden text set Tooltip = Yes.'>[?]</a></th>
<th><b>Tooltip</b></th>
</tr>";
$vm_fields_rows_id = "0";
foreach($arrViewModeFields as $key => $val){
$vm_fields_header = isset($_POST["vm_fields_".$val."_header"]) ? $_POST["vm_fields_".$val."_header"] : (isset($arrViewModeFieldsAttributes[$val]['field_header']) ? $arrViewModeFieldsAttributes[$val]['field_header'] : $val);
$vm_fields_visible = isset($_POST["vm_fields_".$val."_visible"]) ? $_POST["vm_fields_".$val."_visible"] : (isset($arrViewModeFieldsAttributes[$val]['field_visible']) ? $arrViewModeFieldsAttributes[$val]['field_visible'] : "true");
$vm_fields_width = isset($_POST["vm_fields_".$val."_width"]) ? $_POST["vm_fields_".$val."_width"] : (isset($arrViewModeFieldsAttributes[$val]['field_width']) ? $arrViewModeFieldsAttributes[$val]['field_width'] : "");
$vm_fields_type = isset($_POST["vm_fields_".$val."_type"]) ? $_POST["vm_fields_".$val."_type"] : (isset($arrViewModeFieldsAttributes[$val]['field_type']) ? $arrViewModeFieldsAttributes[$val]['field_type'] : "");
$vm_fields_align = isset($_POST["vm_fields_".$val."_align"]) ? $_POST["vm_fields_".$val."_align"] : (isset($arrViewModeFieldsAttributes[$val]['field_align']) ? $arrViewModeFieldsAttributes[$val]['field_align'] : "");
$vm_fields_wrap = isset($_POST["vm_fields_".$val."_wrap"]) ? $_POST["vm_fields_".$val."_wrap"] : (isset($arrViewModeFieldsAttributes[$val]['field_wrap']) ? $arrViewModeFieldsAttributes[$val]['field_wrap'] : "");
$vm_fields_case = isset($_POST["vm_fields_".$val."_case"]) ? $_POST["vm_fields_".$val."_case"] : (isset($arrViewModeFieldsAttributes[$val]['field_case']) ? $arrViewModeFieldsAttributes[$val]['field_case'] : "");
$vm_fields_text_length = isset($_POST["vm_fields_".$val."_text_length"]) ? $_POST["vm_fields_".$val."_text_length"] : (isset($arrViewModeFieldsAttributes[$val]['field_text_length']) ? $arrViewModeFieldsAttributes[$val]['field_text_length'] : "-1");
$vm_fields_tooltip = isset($_POST["vm_fields_".$val."_tooltip"]) ? $_POST["vm_fields_".$val."_tooltip"] : (isset($arrViewModeFieldsAttributes[$val]['field_tooltip']) ? $arrViewModeFieldsAttributes[$val]['field_tooltip'] : "");
echo "<tr align='left'>";
echo "<td><input type='radio' name='vm_fields_primary_key' id='vm_fields_primary_key".$val."' value='".$val."' ".(($val == $vm_fields_primary_key) ? "checked='checked'" : "")." /></td>";
echo "<td><label for='vm_fields_primary_key".$val."'><u>".$val."</u></label><input type='hidden' name='vm_fields_".$val."_name' value='".$val."' /></td>";
echo "<td><select name='vm_fields_".$val."_visible'>
<option ".(($vm_fields_visible == "true") ? "selected" : "")." class='yes' value='true'>Yes</option>
<option ".(($vm_fields_visible == "false") ? "selected" : "")." class='no' value='false'>No</option>
</select></td>";
echo "<td><input type='text' style='width:70px' name='vm_fields_".$val."_header' value='".transform_header($vm_fields_header)."' /></td>";
echo "<td><select name='vm_fields_".$val."_type'>
<option ".(($vm_fields_type == "label") ? "selected" : "")." value='label'>label</option>
<option ".(($vm_fields_type == "image") ? "selected" : "")." value='image'>image</option>
<option ".(($vm_fields_type == "linktoview") ? "selected" : "")." value='linktoview'>linktoview</option>
<option ".(($vm_fields_type == "linktoedit") ? "selected" : "")." value='linktoedit'>linktoedit</option>
<option ".(($vm_fields_type == "linktodelete") ? "selected" : "")." value='linktodelete'>linktodelete</option>
<option ".(($vm_fields_type == "link") ? "selected" : "")." value='link'>link</option>
<option ".(($vm_fields_type == "money") ? "selected" : "")." value='money'>money</option>
<option ".(($vm_fields_type == "password") ? "selected" : "")." value='password'>password</option>
<option ".(($vm_fields_type == "barchart") ? "selected" : "")." value='barchart'>barchart</option>
<option ".(($vm_fields_type == "enum") ? "selected" : "")." value='enum'>enum</option>
<option ".(($vm_fields_type == "blob") ? "selected" : "")." value='blob'>blob</option>
</select></td>";
echo "<td><select name='vm_fields_".$val."_align'>
<option ".(($vm_fields_align == "left") ? "selected" : "")." value='left'>left</option>
<option ".(($vm_fields_align == "center") ? "selected" : "")." value='center'>center</option>
<option ".(($vm_fields_align == "right") ? "selected" : "")." value='right'>right</option>
</select></td>";
echo "<td><input type='text' style='width:70px' name='vm_fields_".$val."_width' value='".$vm_fields_width."' /></td>";
echo "<td><select name='vm_fields_".$val."_wrap'>
<option ".(($vm_fields_wrap == "nowrap") ? "selected" : "")." value='nowrap'>nowrap</option>
<option ".(($vm_fields_wrap == "wrap") ? "selected" : "")." value='wrap'>wrap</option>
</select></td>";
echo "<td><select name='vm_fields_".$val."_case'>
<option ".(($vm_fields_case == "normal") ? "selected" : "")." value='normal'>normal</option>
<option ".(($vm_fields_case == "upper") ? "selected" : "")." value='upper'>upper</option>
<option ".(($vm_fields_case == "lower") ? "selected" : "")." value='lower'>lower</option>
<option ".(($vm_fields_case == "camel") ? "selected" : "")." value='camel'>camel</option>
</select></td>";
echo "<td><input type='text' style='width:40px' maxlength='5' name='vm_fields_".$val."_text_length' id='vm_fields_".$vm_fields_rows_id."_9' value='".$vm_fields_text_length."' /></td>";
echo "<td><select name='vm_fields_".$val."_tooltip'>
<option ".(($vm_fields_tooltip == "false") ? "selected" : "")." value='false'>No</option>
<option ".(($vm_fields_tooltip == "true") ? "selected" : "")." value='true'>Yes</option>
</select></td>";
echo "</tr>";
$vm_fields_rows_id++;
}
echo "</table>";
}
?>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px; border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsEditMode')"><b>ADD/EDIT/DETAILS Mode Settings</b></legend>
<table id="fsEditMode" <?php echo (($fsEditMode_state == "close") ? "style='display:none;'" : ""); ?> align="left" border="0" cellpadding="2" cellspacing="2" width="<?php echo $fieldset_width; ?>">
<tr><td colspan='4' nowrap height='3px'></td></tr>
<tr valign="top">
<td align="left" nowrap width="10px"></td>
<td align="left" nowrap>
<span class='l'>Table</span> <a style='cursor:help;color:#0000a3' title='You may select only non-system tables! To work with your own tables, you have to add them to the database before. Remember: new tables must be created with the same prefix that was used while installation of ApPHP AdminPanel.'>[?]</a>: <font color="#b60000">*</a>
</td>
<td align="left" nowrap>
<select name="selEditModeTable" id="selEditModeTable" style="width:240px;" onchange="selEditModeTable_OnChange()">
<option value="">-- select --</option>
<?php
foreach($arrAllowedTables as $table){
echo "<option ".(($selEditModeTable == $table) ? "selected" : "")." value='".$table."'>".$table."</option>";
}
?>
</select>
<span class='l'>Fields Definition:</span>
<select name="selDefiningFieldsEdit" id="selDefiningFieldsEdit" onchange="selDefiningFieldsEdit_OnChange()">
<?php
$arrDefiningFieldsEditMode = array("all"=>"All fields (*) - auto generated", "by_one"=>"Specify by one");
foreach($arrDefiningFieldsEditMode as $key => $val){
echo "<option ".(($selDefiningFieldsEdit == $key) ? "selected" : "")." value='".$key."'>".$val."</option>";
}
?>
</select>
</td>
<td align="left" nowrap>
<span class='l'>Width:</span> <input type="text" name="txtEditModeTableWidth" style="width:32px" maxlength="4" value="<?php echo $em_table_width; ?>" />
<select name="txtEditModeTableWidthUnits">
<option value="%" <?php echo (($em_table_width_units == "%") ? "selected='selected'" : ""); ?>>%</option>
<option value="px" <?php echo (($em_table_width_units == "px") ? "selected='selected'" : ""); ?>>px</option>
<option value="em" <?php echo (($em_table_width_units == "em") ? "selected='selected'" : ""); ?>>em</option>
<option value="pt" <?php echo (($em_table_width_units == "pt") ? "selected='selected'" : ""); ?>>pt</option>
</select>
</td>
</tr>
<?php
if(count($arrEditModeFields) > 0) echo "<tr><td colspan='4' nowrap height='10px' style='margin-top:3px; padding-top:2px; border-bottom:1px solid #dedede;'></td></tr>";
?>
<tr valign="top">
<td colspan="4" align="right">
<table border="0">
<tr>
<td style="padding-left:5px;">
<?php
if(count($arrEditModeFields) > 0)
{
echo "<table id='tblEditMode' border='0'>";
echo "<tr align='center'>
<th title='Primary Key'><b>PK</b></th>
<th align='left'> <b>Field</b></th>
<th><b>Visible</b></th>
<th><b>Header</b></th>
<th><b>Type</b></th>
<th><b>Align</b></th>
<th nowrap><b>Width</b> <a style='cursor:help;color:#0000a3' title='Maximal text length in percents(%) or pixels(px)'>[?]</a></th>
<th><b>Required</b></th>
<th><b>Validation</b></th>
<th><b>Readonly</b></th>
<th><b>Unique</b></th>
<th nowrap><b>Default</b> <a style='cursor:help;color:#0000a3' title='Default value, that will be inserted in Add Mode'>[?]</a></th>
<th> Additional </th>
</tr>";
$em_fields_rows_id = "0";
foreach($arrEditModeFields as $key => $val){
$em_fields_header = isset($_POST["em_fields_".$val."_header"]) ? $_POST["em_fields_".$val."_header"] : (isset($arrEditModeFieldsAttributes[$val]['field_header']) ? $arrEditModeFieldsAttributes[$val]['field_header'] : $val);
$em_fields_visible = isset($_POST["em_fields_".$val."_visible"]) ? $_POST["em_fields_".$val."_visible"] : (isset($arrEditModeFieldsAttributes[$val]['field_visible']) ? $arrEditModeFieldsAttributes[$val]['field_visible'] : $val);
$em_fields_width = isset($_POST["em_fields_".$val."_width"]) ? $_POST["em_fields_".$val."_width"] : (isset($arrEditModeFieldsAttributes[$val]['field_width']) ? $arrEditModeFieldsAttributes[$val]['field_width'] : "");
$em_fields_type = isset($_POST["em_fields_".$val."_type"]) ? $_POST["em_fields_".$val."_type"] : (isset($arrEditModeFieldsAttributes[$val]['field_type']) ? $arrEditModeFieldsAttributes[$val]['field_type'] : "");
$em_fields_align = isset($_POST["em_fields_".$val."_align"]) ? $_POST["em_fields_".$val."_align"] : (isset($arrEditModeFieldsAttributes[$val]['field_align']) ? $arrEditModeFieldsAttributes[$val]['field_align'] : "");
$em_fields_req_type = isset($_POST["em_fields_".$val."_req_type"]) ? $_POST["em_fields_".$val."_req_type"] : (isset($arrEditModeFieldsAttributes[$val]['field_req_type']) ? $arrEditModeFieldsAttributes[$val]['field_req_type'] : "");
$em_fields_req_subtype = isset($_POST["em_fields_".$val."_req_subtype"]) ? $_POST["em_fields_".$val."_req_subtype"] : (isset($arrEditModeFieldsAttributes[$val]['field_req_subtype']) ? $arrEditModeFieldsAttributes[$val]['field_req_subtype'] : "");
$em_fields_readonly = isset($_POST["em_fields_".$val."_readonly"]) ? $_POST["em_fields_".$val."_readonly"] : (isset($arrEditModeFieldsAttributes[$val]['field_readonly']) ? $arrEditModeFieldsAttributes[$val]['field_readonly'] : "");
$em_fields_unique = isset($_POST["em_fields_".$val."_unique"]) ? $_POST["em_fields_".$val."_unique"] : (isset($arrEditModeFieldsAttributes[$val]['field_unique']) ? $arrEditModeFieldsAttributes[$val]['field_unique'] : "");
$em_fields_default = isset($_POST["em_fields_".$val."_default"]) ? $_POST["em_fields_".$val."_default"] : (isset($arrEditModeFieldsAttributes[$val]['field_default']) ? $arrEditModeFieldsAttributes[$val]['field_default'] : "");
$em_fields_edit_type = isset($_POST["em_fields_".$val."_edit_type"]) ? $_POST["em_fields_".$val."_edit_type"] : (isset($arrEditModeFieldsAttributes[$val]['field_edit_type']) ? $arrEditModeFieldsAttributes[$val]['field_edit_type'] : "");
$em_fields_target_path = isset($_POST["em_fields_".$val."_target_path"]) ? $_POST["em_fields_".$val."_target_path"] : (isset($arrEditModeFieldsAttributes[$val]['field_target_path']) ? $arrEditModeFieldsAttributes[$val]['field_target_path'] : "");
$style = (($val == $em_fields_primary_key) ? "display:none;" : "");
echo "<tr>";
echo "<td><input type='radio' name='em_fields_primary_key' id='em_fields_primary_key".$val."' value='".$val."' ".(($val == $em_fields_primary_key) ? "checked='checked'" : "")." onclick='em_fields_primary_key_OnClick(\"".$em_fields_rows_id."\", \"".count($arrEditModeFields)."\")' /></td>";
echo "<td align='left'><label for='em_fields_primary_key".$val."'><u>".$val."</u></label><input type='hidden' name='em_fields_".$val."_name' value='".$val."' /></td>";
echo "<td><select style='".$style."' name='em_fields_".$val."_visible' id='em_field_".$em_fields_rows_id."_1'>
<option ".(($em_fields_visible == "true") ? "selected" : "")." class='yes' value='true'>Yes</option>
<option ".(($em_fields_visible == "false") ? "selected" : "")." class='no' value='false'>No</option>
</select></td>";
echo "<td><input type='text' style='width:70px;".$style."' name='em_fields_".$val."_header' id='em_field_".$em_fields_rows_id."_2' value='".transform_header($em_fields_header)."' /></td>";
echo "<td><select name='em_fields_".$val."_type' id='em_field_".$em_fields_rows_id."_3' style='".$style."' onchange='em_fields_type_OnChange(this.value, \"".$em_fields_rows_id."\")'>
<option ".(($em_fields_type == "textbox") ? "selected" : "")." value='textbox'>textbox</option>
<option ".(($em_fields_type == "textarea") ? "selected" : "")." value='textarea'>textarea</option>
<option ".(($em_fields_type == "label") ? "selected" : "")." value='label'>label</option>
<option ".(($em_fields_type == "date") ? "selected" : "")." value='date'>date</option>
<option ".(($em_fields_type == "datetime") ? "selected" : "")." value='datetime'>datetime</option>
<option ".(($em_fields_type == "time") ? "selected" : "")." value='time'>time</option>
<option ".(($em_fields_type == "money") ? "selected" : "")." value='money'>money</option>
<option ".(($em_fields_type == "enum") ? "selected" : "")." value='enum'>enum</option>
<option ".(($em_fields_type == "print") ? "selected" : "")." value='print'>print</option>
<option ".(($em_fields_type == "checkbox") ? "selected" : "")." value='checkbox'>checkbox</option>
<option ".(($em_fields_type == "image") ? "selected" : "")." value='image'>image</option>
<option ".(($em_fields_type == "file") ? "selected" : "")." value='file'>file</option>
<option ".(($em_fields_type == "link") ? "selected" : "")." value='link'>link</option>
<option ".(($em_fields_type == "foreign_key") ? "selected" : "")." value='foreign_key'>foreign_key</option>
<option ".(($em_fields_type == "blob") ? "selected" : "")." value='blob'>blob</option>
<option ".(($em_fields_type == "hidden") ? "selected" : "")." value='hidden'>hidden</option>
<option ".(($em_fields_type == "validator") ? "selected" : "")." value='validator'>validator</option>
</select></td>";
echo "<td><select name='em_fields_".$val."_align' id='em_field_".$em_fields_rows_id."_4' style='".$style."'>
<option ".(($em_fields_align == "left") ? "selected" : "")." value='left'>left</option>
<option ".(($em_fields_align == "center") ? "selected" : "")." value='center'>center</option>
<option ".(($em_fields_align == "right") ? "selected" : "")." value='right'>right</option>
</select></td>";
echo "<td><input type='text' style='width:60px;".$style."' name='em_fields_".$val."_width' id='em_field_".$em_fields_rows_id."_5' value='".$em_fields_width."' /></td>";
echo "<td align='center'><select name='em_fields_".$val."_req_type' id='em_field_".$em_fields_rows_id."_6' style='".$style."' onchange='em_fields_header_OnChange(\"".$em_fields_rows_id."\", this.value)'>
<option ".(($em_fields_req_type == "r") ? "selected" : "")." value='r'>Yes</option>
<option ".(($em_fields_req_type == "s") ? "selected" : "")." value='s'>No</option>
</select></td>";
//if($style == "" && $em_fields_req_type == "s") $req_sub_type_disabled = "disabled='disabled'";
//else $req_sub_type_disabled = "";
echo "<td><select name='em_fields_".$val."_req_subtype' id='em_field_".$em_fields_rows_id."_7' style='".$style."'>
<option ".(($em_fields_req_subtype == "y") ? "selected" : "")." value='y'>any</option>
<option ".(($em_fields_req_subtype == "t") ? "selected" : "")." value='t'>text</option>
<option ".(($em_fields_req_subtype == "a") ? "selected" : "")." value='a'>alphanumeric</option>
<option ".(($em_fields_req_subtype == "n") ? "selected" : "")." value='n'>numeric</option>
<option ".(($em_fields_req_subtype == "i") ? "selected" : "")." value='i'>integer</option>
<option ".(($em_fields_req_subtype == "f") ? "selected" : "")." value='f'>float</option>
<option ".(($em_fields_req_subtype == "l") ? "selected" : "")." value='l'>login</option>
<option ".(($em_fields_req_subtype == "e") ? "selected" : "")." value='e'>email</option>
<option ".(($em_fields_req_subtype == "p") ? "selected" : "")." value='p'>password</option>
<option ".(($em_fields_req_subtype == "z") ? "selected" : "")." value='z'>zipcode</option>
<option ".(($em_fields_req_subtype == "v") ? "selected" : "")." value='v'>verified</option>
<option ".(($em_fields_req_subtype == "c") ? "selected" : "")." value='c'>checkbox</option>
<option ".(($em_fields_req_subtype == "u") ? "selected" : "")." value='u'>URL</option>
</select></td>";
echo "<td align='center'><select name='em_fields_".$val."_readonly' id='em_field_".$em_fields_rows_id."_8' style='".$style."'>
<option ".(($em_fields_readonly == "false") ? "selected" : "")." value='false'>No</option>
<option ".(($em_fields_readonly == "true") ? "selected" : "")." value='true'>Yes</option>
</select></td>";
echo "<td><select name='em_fields_".$val."_unique' id='em_field_".$em_fields_rows_id."_9' style='".$style."'>
<option ".(($em_fields_unique == "false") ? "selected" : "")." value='false'>No</option>
<option ".(($em_fields_unique == "true") ? "selected" : "")." value='true'>Yes</option>
</select></td>";
echo "<td><input type='text' style='width:60px;".$style."' name='em_fields_".$val."_default' id='em_field_".$em_fields_rows_id."_10' value='".$em_fields_default."' /></td>";
echo "<td nowrap='nowrap'>
<span id='em_field_".$em_fields_rows_id."_11' style='display:".(($em_fields_type == "textarea") ? "" : "none").";'>
<select name='em_fields_".$val."_edit_type' style='width:76px;'>
<option ".(($em_fields_edit_type == "simple") ? "selected" : "")." value='simple'>Simple</option>
<option ".(($em_fields_edit_type == "wysiwyg") ? "selected" : "")." value='wysiwyg'>Wysiwyg</option>
</select>
</span>
<span id='em_field_".$em_fields_rows_id."_12' style='display:".(($em_fields_type == "image" || $em_fields_type == "file") ? "" : "none").";'>
<input name='em_fields_".$val."_target_path' style='width:54px;' value='".$em_fields_target_path."' /><a style='cursor:help;color:#0000a3;' title='Path to folder where files/images is saved'>[?]</a>
</span>
</td>";
echo "</tr>";
$em_fields_rows_id++;
}
echo "</table>";
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset style="width:<?php echo $fieldset_width; ?>;padding:5px; border:#7a7a7a 1px solid;">
<legend onclick="toggleFieldSet('fsForeignKeys')"><b>Foreign Keys Settings</b></legend>
<table id="fsForeignKeys" <?php echo (($fsForeignKeys_state == "close") ? "style='display:none;'" : ""); ?> border="0" align="left" cellpadding="2" cellspacing="2" width="100%">
<tr>
<td></td>
<td colspan="2">
<table id='tblForeignKeys' border='0' width='100%'>
<?php
$sql = "SELECT * FROM ".TABLE_DG_WIZARD_FOREIGN_KEYS." WHERE datagrid_page_id = ".$dgpid;
$db->Query($sql);
if($db->RowCount() > 0 || $foreign_keys_act == "add_foreign_keys_field" || $foreign_keys_act == "change_foreign_keys_table"){
echo "<tr align='center'>
<th align='left'> <b>Foreign Key Field</b></th>
<th><b>Table</b></th>
<th><b>Field Key</b></th>
<th><b>Field Name</b></th>
<th><b>View Type</b></th>
<th><b>Order Type</b></th>
<th></th>
</tr>";
}else{
echo "<tr><td colspan='7'></td></tr>";
}
while($row = $db->FetchArray()){
echo "<tr>";
echo "<td>".$row['f_foreign_field']."</td>";
echo "<td align='center'>".$row['f_table']."</td>";
echo "<td align='center'>".$row['f_field_key']."</td>";
echo "<td align='center'>".$row['f_field_name']."</td>";
echo "<td align='center'>".$row['f_view_type']."</td>";
echo "<td align='center'>".$row['f_order_type']."</td>";
echo "<td align='center'><a href='javascript:removeForeignKeysFields(\"".$row['id']."\");' title='Click to Remove from DataGrid'><img src='../images/remove.png' alt='' /></a></td>";
echo "</tr>";
}
if($foreign_keys_act == "add_foreign_keys_field" || $foreign_keys_act == "change_foreign_keys_table"){
echo "<tr align='center'>";
echo "<td>
<select name='fkm_fields_0_foreign_field' id='fkm_fields_0_foreign_field' style='width:140px;'>
<option value=''>-- select --</option>";
if(count($arrEditModeFields) <= 0) retrive_edit_mode_fields($arrEditModeFields, $selForeignKeysModeTable);
foreach($arrEditModeFields as $key){
echo "<option value='".$key."' ".(($fkm_fields_0_foreign_field == $key) ? "selected='selected'" : "").">". $key."</option>";
}
echo "</select></td>";
echo "<td>
<select name='fkm_fields_0_table' id='fkm_fields_0_table' style='width:140px;' onchange='javascript:changeForeignKeysTable(this.value);'>
<option value=''>-- select --</option>";
foreach($arrAllowedFKTables as $table){
echo "<option ".(($foreign_keys_act_table == $table) ? "selected" : "")." value='".$table."'>".$table."</option>";
}
echo "</select></td>";
echo "<td>
<select name='fkm_fields_0_field_key' id='fkm_fields_0_field_key' style='width:120px;'>
<option value=''>-- select --</option>";
foreach($arrForeignKeysTableFields as $key){
echo "<option value='".$key."'>".$key."</option>";
}
echo "</select>
</select></td>";
echo "<td>
<select name='fkm_fields_0_field_name' id='fkm_fields_0_field_name' style='width:120px;'>
<option value=''>-- select --</option>";
foreach($arrForeignKeysTableFields as $key){
echo "<option value='".$key."'>".$key."</option>";
}
echo "</select>
</select></td>";
echo "<td>
<select name='fkm_fields_0_view_type' id='fkm_fields_0_view_type'>
<option value='dropdownlist'> dropdownlist </option>
<option value='radiobutton'> radiobutton </option>
<option value='textbox'> textbox </option>
<option value='label'> label </option>
</select></td>";
echo "<td>
<select name='fkm_fields_0_order_type' id='fkm_fields_0_order_type'>
<option value='ASC'>ASC</option>
<option value='DESC'>DESC</option>
</select></td>
<td></td>";
echo "</tr>";
}
?>
</table>
</td>
</tr>
<tr valign="top">
<td align="left" width="200px">
<?php if($foreign_keys_act == "" || $foreign_keys_act == "remove_foreign_keys_field" || $foreign_keys_act == "insert_foreign_keys_field"){ ?>
<a href="javascript:void('foreign keys|add new');" onclick="javascript:addForeignKeysFields();">+ Add New Field</a>
<?php }else{ ?>
<a href="javascript:void('foreign keys|insert');" onclick="javascript:insertForeignKeysFields();">↓ Insert Field</a> | <a href="javascript:void('foreign keys|cancel');" onclick="javascript:cancelForeignKeysFields();">Cancel</a>
<?php } ?>
</td>
<td align="left"></td>
</tr>
</table>
</fieldset>
<br />
<?php draw_buttons(); ?>
<?php if($debug && $debug_msg != "") echo "<br><br><b>Debug Info:</b>".$debug_msg; ?>
</form>
</div>
<br />
</body>
</html>