function ReadPostData($ReportID, $Prefs) { global $db; // check for page setup form entry to look at check boxes and save as new defaults, return if (isset($_POST['PageForm'])) { $success = SavePrefs($ReportID); // values saved, read them back in to update $Prefs array $sql = "SELECT *\tFROM " . DBReports . " WHERE id = '" . $ReportID . "'"; $Result = DB_query($sql, $db, '', '', false, true); $myrow = DB_fetch_assoc($Result); foreach ($myrow as $key => $value) { $Prefs[$key] = $value; } return $Prefs; } // Since we are not at the page setup form, we read from the filter form, fetch user selections $Prefs['DateListings']['params'] = $_POST['DefDate']; if ($_POST['DefDate'] == 'b') { // then it's a range selection, save dates, else discard $Prefs['DateListings']['params'] .= ':' . $_POST['DefDateFrom'] . ':' . $_POST['DefDateTo']; } $Prefs['defgroup'] = $_POST['DefGroup']; $Prefs['defsort'] = $_POST['DefSort']; $Prefs['TruncListings']['params'] = $_POST['DefTrunc']; if (!$Prefs['defaultreport']) { // Then save the filter settings because it's a custom report and we save them $success = SaveFilters($ReportID, 'dateselect', $Prefs['DateListings']['params']); $success = SaveFilters($ReportID, 'trunclong', $Prefs['TruncListings']['params']); if (isset($Prefs['defgroup'])) { $success = SaveDefSettings($ReportID, 'grouplist', $Prefs['defgroup']); } if (isset($Prefs['defsort'])) { $success = SaveDefSettings($ReportID, 'sortlist', $Prefs['defsort']); } } // update Prefs with current user selections if (isset($Prefs['defgroup'])) { // First clear all defaults and reset the user's choice for ($i = 0; $i < count($Prefs['GroupListings']); $i++) { $Prefs['GroupListings'][$i]['params'] = 0; } if ($Prefs['defgroup'] != 0) { $Prefs['GroupListings'][$Prefs['defgroup'] - 1]['params'] = '1'; } } if (isset($Prefs['defsort'])) { // First clear all defaults and reset the user's choice for ($i = 0; $i < count($Prefs['SortListings']); $i++) { $Prefs['SortListings'][$i]['params'] = 0; } if ($Prefs['defsort'] != 0) { $Prefs['SortListings'][$Prefs['defsort'] - 1]['params'] = '1'; } } // Criteria Field Selection $i = 1; while (isset($_POST['defcritsel' . $i])) { // then there is at least one criteria // Build the criteria default string $Prefs['CritListings'][$i - 1]['params'] = mb_substr($Prefs['CritListings'][$i - 1]['params'], 0, 1); $Prefs['CritListings'][$i - 1]['params'] .= ':' . $_POST['defcritsel' . $i]; $Prefs['CritListings'][$i - 1]['params'] .= ':' . $_POST['fromvalue' . $i]; if ($_POST['tovalue' . $i] == '') { $_POST['tovalue' . $i] = $_POST['fromvalue' . $i]; } $Prefs['CritListings'][$i - 1]['params'] .= ':' . $_POST['tovalue' . $i]; if (!$Prefs['defaultreport']) { // save it since it's a custom report $sql = "UPDATE " . DBRptFields . " SET params='" . $Prefs['CritListings'][$i - 1]['params'] . "'\n\t\t\t\tWHERE reportid ='" . $ReportID . "' AND entrytype='critlist' AND seqnum='" . $i . "'"; $Result = DB_query($sql, $db, '', '', false, true); } $i++; } // If it's a default report, we're done, return if ($Prefs['defaultreport']) { return $Prefs; } // Read in the display field form selections $i = 1; while (isset($_POST['DataField' . $i])) { // read in the field choices if ($_POST['show' . $i] == '1') { $Prefs['FieldListings'][$i - 1]['visible'] = '1'; } else { $Prefs['FieldListings'][$i - 1]['visible'] = '0'; } if ($_POST['break' . $i] == '1') { $Prefs['FieldListings'][$i - 1]['columnbreak'] = '1'; } else { $Prefs['FieldListings'][$i - 1]['columnbreak'] = '0'; } $sql = "UPDATE " . DBRptFields . " SET\n\t\t\t\tvisible='" . $Prefs['FieldListings'][$i - 1]['visible'] . "',\n\t\t\t\tcolumnbreak='" . $Prefs['FieldListings'][$i - 1]['columnbreak'] . "'\n\t\t\tWHERE reportid ='" . $ReportID . "' AND entrytype='fieldlist' AND seqnum='" . $i . "'"; $Result = DB_query($sql, $db, '', '', false, true); $i++; } return $Prefs; }
function RetrieveFields($ReportID, $EntryType) { global $db; $FieldListings = ''; $sql = "SELECT *\tFROM " . DBRptFields . " \n\t\tWHERE reportid = " . $ReportID . " AND entrytype = '" . $EntryType . "'\n\t\tORDER BY seqnum"; $Result = DB_query($sql, $db, '', '', false, true); while ($FieldValues = DB_fetch_assoc($Result)) { $FieldListings[] = $FieldValues; } return $FieldListings; }
$DropDownString = RetrieveReports(); $FormParams = PrepStep('1'); break; } } break; case "step6a": // entered from properties page for fields $ButtonValue = RPT_BTN_ADDNEW; // default the field button to Add New unless overidden by the edit image pressed $reportname = $_POST['ReportName']; $SeqNum = $_POST['SeqNum']; // first fetch the original Params $sql = "SELECT id, params FROM " . DBRptFields . "\n\t\t\tWHERE reportid = " . $ReportID . " AND entrytype='fieldlist' AND seqnum = " . $SeqNum . ";"; $Result = DB_query($sql, $db, '', '', false, true); $myrow = DB_fetch_assoc($Result); $Params = unserialize($myrow['params']); if (!isset($_POST['todo'])) { // then a sequence image button was pushed, we must be in form table entry $success = ModFormTblEntry($Params); if (!$success) { // check for errors $usrMsg[] = array('message' => RPT_BADDATA, 'level' => 'error'); } else { // update the database $sql = "UPDATE " . DBRptFields . " SET params='" . serialize($Params) . "' WHERE id = " . $_POST['ID'] . ";"; $Result = DB_query($sql, $db, '', '', false, true); if ($success == 'edit') { // then the edit button was pressed, change button name from Add New to Change $ButtonValue = RPT_BTN_CHANGE; }
<?php include 'includes/session.inc'; $q = $_GET['term']; $sql = "SELECT id,description FROM stockmaster WHERE description Like '{$q}%'"; $obj = array(); $result = DB_query($sql, $db); while ($row = DB_fetch_assoc($result)) { $obj[] = array('stockid' => $row['id'], 'description' => $row['description']); } print json_encode($obj);