"; html_footer(); quit; } /*** * For new record ***/ if ( $ORECID == "" && $SUBMIT_FORM == "" ) { $TEMP = $TEMPLATE; while ( strpos( $TEMP, "}" ) > 0 ) { $TEMP = substr($TEMP, strpos($TEMP, "{" ) + 1); $T2 = substr( $TEMP, 0, strpos($TEMP, "}") ); $TEMP = substr( $TEMP, strpos($TEMP, "}") + 1); if ( strpos( $T2, ":" ) == 0 ) { $FN_LABEL_TABLE = substr($T2, 0, strpos($T2, ".")); $FN_LABEL_FIELD = substr($T2, strpos($T2, ".") + 1); labels(); $FNT_FIELDNAME = strtolower("FIELD_" . $FN_LABEL_TABLE . "_" . $FN_LABEL_FIELD); ${$FNT_FIELDNAME} = variable_decode($FN_LABEL_DEFAULT_VALUE); } } } /*** * For existing record ***/ if ( $ORECID != "" ) { /*&& $SUBMIT_FORM == "" ) {*/ $SQL_RESULT = fnsql_run_query ("SELECT * FROM " . fnsql_result( $FORM_INFO, 0, "form_table" ) . " WHERE recid = $ORECID"); $TEMP = fnsql_fetch_row( $SQL_RESULT ); for ( $x = 0; $x < fnsql_num_fields($SQL_RESULT); $x++ ) { $FNT_FIELDNAME = strtolower("FIELD_" . fieldVariable( $SQL_RESULT, $x )); ${$FNT_FIELDNAME} = $TEMP[$x]; } } /*** * For redoing an entry ***/ if ( $SUBMIT_FORM != "" && $REDO ) { $DRAWFORM = true; $READONLY = false; $FIELDS = explode( ",", $FORM_FIELD_LIST ); for ( $x = 0; $x < count($FIELDS); $x++ ) { $T_TABLE = substr( $FIELDS[$x], 0, strpos( $FIELDS[$x], "__" )); $T_FIELD = substr( $FIELDS[$x], strpos( $FIELDS[$x], "__" ) + 2 ); $T_FIELD = substr( $T_FIELD, 0, strpos( $T_FIELD, "__" )); $FNT_FIELDNAME = strtolower("FIELD_" . $T_TABLE . "_" . $T_FIELD); if ( ! is_array( $_POST[$FIELDS[$x]] ) ) { ${$FNT_FIELDNAME} = $_POST[$FIELDS[$x]]; } else { for ( $y = 0; $y < count( $_POST[$FIELDS[$x]] ); $y++ ) { if ( $_POST[$FIELDS[$x]][$y] != "" ) { ${$FNT_FIELDNAME} = ${$FNT_FIELDNAME} . "," . $_POST[$FIELDS[$x]][$y] . ","; } } if ( ${$FNT_FIELDNAME} == ",," ) { ${$FNT_FIELDNAME} = ""; } } } } /***************************************************************************** * Draw Form *****************************************************************************/ /*** * Draw it out on the screen ***/ $FORM_FIELD_LIST = ""; $VALIDATE_FIELD_LIST = ""; if ( $DRAWFORM ) { /*** * Reset readonly flag if needed ***/ if ( $_REQUEST["RO"] == 1 ) { $READONLY = true; $pfcNoCustom = 1; } html_header($FN_PAGE_TITLE, "body"); echo "
\n"; echo "
\n"; if ( $_REQUEST["RO"] == "" && $PALMPILOT == "" && $ORECID != "" ) { echo "" . "\"Go\n"; echo "\"Print\n"; } echo "
\n"; dynamic("form_" . $form_name . "_onLoad"); /*** * Draw Javascript Functions ***/ if ( $PALMPILOT == "" ) { jsDrawBasic(); jsNewWindow(); jsY2K(); jsPopupCalFunction(); jsPushPull(); } /*** * Is there an alert? ***/ if ( $ALERT_MESSAGE != "" ) { jsAlertBox( $ALERT_MESSAGE ); } echo "
\n"; /*** * Turn the template into the form ***/ $FORM_FIELD_LIST = ""; $VALIDATE_FIELD_LIST = ""; while ( strpos( $TEMPLATE, "}" ) > 0 ) { echo substr($TEMPLATE, 0, strpos( $TEMPLATE, "{" )); $TEMPLATE = substr($TEMPLATE, strpos($TEMPLATE, "{" ) + 1); $TEMP = substr( $TEMPLATE, 0, strpos($TEMPLATE, "}") ); $TEMPLATE = substr( $TEMPLATE, strpos($TEMPLATE, "}") + 1 ); if ( strpos( $TEMP, ":" ) > 0 ) { $COMMAND = substr($TEMP, 0, strpos($TEMP, ":")); $ARGUMENT = substr($TEMP, strpos($TEMP, ":") + 1); if ( $COMMAND == "INI" ) { if ( $READONLY ) { echo get_key ( $DATA[1]); } else { $HAS_INI = "Yes"; $VARIABLE = "fn_ini__ini_value__" . get_key_id( $ARGUMENT ); $FORM_FIELD_LIST = $FORM_FIELD_LIST . "," . $VARIABLE; $VALIDATE_FIELD_LIST .= "," . $VARIABLE; echo "\n"; echo "\n"; } } if ( $COMMAND == "VIEW" && $ORECID != "" ) { $TEMP = fnsql_run_query("SELECT * FROM fn_view WHERE view_name = \"$ARGUMENT\""); while ( $TEMP_DATA = fnsql_fetch_row($TEMP) ) { $FORM_FIELD_LIST = $FORM_FIELD_LIST . html_table( fnsql_result($TEMP, 0, "view_sql"), fnsql_result($TEMP, 0, "updateable_view" ), true, "", fnsql_result($TEMP, 0, "hide_recids"), fnsql_result($TEMP, 0, "show_delete" ), fnsql_result($TEMP, 0, "override_form"), fnsql_result($TEMP, 0, "add_row" )); } } if ( $COMMAND == "PROGRAM" ) { include( $HOMEPATH . $ARGUMENT ); } if ( $COMMAND == "LABEL" ) { if ( strpos( $ARGUMENT, ".") > 0 ) { echo field_label( substr($ARGUMENT, 0, strpos($ARGUMENT, ".")), substr($ARGUMENT, strpos($ARGUMENT, ".") + 1) ); if ( ! $READONLY && $RO == "" && $PALMPILOT == "" && field_help_text(substr($ARGUMENT, 0, strpos($ARGUMENT, ".")), substr($ARGUMENT, strpos($ARGUMENT, ".") + 1)) <> "" ) { echo "\n"; } } } if ( $COMMAND == "VARIABLE" ) { echo ${$ARGUMENT}; } } else { $FN_LABEL_TABLE = substr($TEMP, 0, strpos($TEMP, ".")); $FN_LABEL_FIELD = substr($TEMP, strpos($TEMP, ".") + 1); $VARIABLE = $FN_LABEL_TABLE . "__" . $FN_LABEL_FIELD . "__" . $ORECID; $FORM_FIELD_LIST = $FORM_FIELD_LIST . "," . $VARIABLE; $VALIDATE_FIELD_LIST .= "," . $VARIABLE; labels(); $FNT_FIELDNAME = strtolower("FIELD_" . $FN_LABEL_TABLE . "_" . $FN_LABEL_FIELD); if ( $ORECID == "" && $SUBMIT_FORM == "" ) { if ( $FN_LABEL_FIELD_DEFAULT == "" || $FN_LABEL_FIELD_DEFAULT == "0000-00-00" ) { $CURRENT_VALUE = variable_decode($FN_LABEL_DEFAULT_VALUE); } else { $CURRENT_VALUE = variable_decode($FN_LABEL_FIELD_DEFAULT); } } else { if ( ( $FN_LABEL_FIELD_TYPE == "date" || $FN_LABEL_FIELD_TYPE == "datetime" ) && substr(${$FNT_FIELDNAME}, 0, 10) == "0000-00-00" ) { $CURRENT_VALUE = ""; } else { $CURRENT_VALUE = ${$FNT_FIELDNAME}; } } include("form.i"); } } echo $TEMPLATE; /*** * Calculate and draw the submit button ***/ if ( ! $READONLY ) { echo "
"; if ( $ORECID != "" || $HAS_INI != "" ) { if ( fnsql_result($FORM_INFO, 0, "delete_button") == "Y" ) { echo "\n"; } if ( fnsql_result($FORM_INFO, 0, "display_update_button" ) == "Y" ) { echo "\n"; } if ( fnsql_result( $FORM_INFO, 0, "display_copy") == "Y" ) { echo "\n"; } echo "\n"; } else { if ( fnsql_result($FORM_INFO, 0, "display_update_button" ) == "Y" ) { echo "\n"; } echo "\n"; } echo "
"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; html_footer(); } /***************************************************************************** * Cleanup *****************************************************************************/