Example #1
0
     }
     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;
             }
         }
         // Update field properties
         $FormParams = PrepStep('prop');
         $FormParams['id'] = $myrow['id'];
 // first fetch the original Params
 $sql = "select id, params from " . TABLE_REPORT_FIELDS . " \r\n\t\t\twhere reportid = " . $ReportID . " and entrytype = 'fieldlist' and seqnum = " . $SeqNum;
 $result = $db->Execute($sql);
 $myrow = $result->fields;
 $Params = unserialize($myrow['params']);
 // fetch the choices with the form post data
 foreach ($_POST as $key => $value) {
     $Params[$key] = $value;
 }
 // check for what button or image was pressed
 switch ($todo) {
     case 'up':
     case 'down':
     case 'edit':
     case 'delete':
         $success = ModFormTblEntry($Params, $todo, $rowSeq);
         if (!$success) {
             // check for errors
             $messageStack->add(RW_RPT_BADDATA, 'error');
         } else {
             // update the database
             $sql = "update " . TABLE_REPORT_FIELDS . " set params = '" . serialize($Params) . "' \r\n\t\t\t\t\t\twhere id = " . $_POST['ID'];
             $result = $db->Execute($sql);
             if ($success === 'edit') {
                 // then the edit button was pressed, change button name from Add New to Change
                 $ButtonValue = TEXT_CHANGE;
             } else {
                 // clear the entry text fields
                 $Params['TblSeqNum'] = '';
                 $Params['TblField'] = '';
                 $Params['Processing'] = '';