예제 #1
0
 private function ajax_save_program()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']);
     $OP = $FANNIE_OP_DB . $dbc->sep();
     /* Place to accumulate not-immediately-fatal messages
      *  that will be displayed in the ajax-return-string.
      * Maybe better as array.
      */
     $returnMessage = "";
     /* These are from the query (parameters) string in the AJAX request
      *  and are the same as the input form id= values.
      */
     $configno = FormLib::get_form_value('configno', 0);
     $dummytender = FormLib::get_form_value('dummytender', '');
     $dummydept = FormLib::get_form_value('dummydept', 0);
     $deptmin = FormLib::get_form_value('deptmin', 0);
     $deptmax = FormLib::get_form_value('deptmax', 0);
     $dummybanker = FormLib::get_form_value('dummybanker', 0);
     $bankermin = FormLib::get_form_value('bankermin', 0);
     $bankermax = FormLib::get_form_value('bankermax', 0);
     $membermin = FormLib::get_form_value('membermin', 0);
     $membermax = FormLib::get_form_value('membermax', 0);
     $isnew = FormLib::get_form_value('isnew', 9);
     /* Check for problems.
      * See CoopCredProgramEditor for examples.
      */
     $sMessage = "";
     /* Each check */
     /* After all checks done.
      */
     if ($sMessage) {
         $sMessage = preg_replace("/^\n+/", "", $sMessage);
         $sMessage .= "\n\nNo current changes have been Saved.";
         echo $sMessage;
         return;
     }
     /* Save changes to or Create the Config proper.
      */
     $config = new CCredConfigModel($dbc);
     $config->configID($configno);
     $config->dummyTenderCode($dummytender);
     $config->dummyDepartment($dummydept);
     $config->deptMin($deptmin);
     $config->deptMax($deptmax);
     //
     $config->dummyBanker($dummybanker);
     $config->bankerMin($bankermin);
     $config->bankerMax($bankermax);
     //
     $config->regularMemberMin($membermin);
     $config->regularMemberMax($membermax);
     //
     $config->modifiedBy($this->authUserNumber);
     $config->modified(date('Y-m-d H:i:s'));
     /* save() decides UPDATE vs INSERT based on whether configID already
      * exists.
      */
     $saved = $config->save();
     if ($isnew == 1) {
         if ($saved === False) {
             echo 'Error: could not create Configuration';
             return;
         }
     } else {
         if ($saved === False) {
             echo 'Error: could not save the changes to the Configuration';
             return;
         } else {
             $returnMessage .= sprintf("\nSaved Configuration (#%d)", $configno);
         }
     }
     $returnMessage = preg_replace("/^\n+/", "", $returnMessage);
     echo $returnMessage;
     // ajax_save_program()
 }