function addEditGift($lGiftID, $lFID = 0)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gdteNow, $gclsChapterACO, $gbDateFormatUS;
     if (!bTestForURLHack('dataEntryGifts')) {
         return '';
     }
     $this->load->helper('dl_util/verify_id');
     if ($lGiftID . '' != '0') {
         verifyID($this, $lGiftID, 'donation ID');
     }
     if ($lFID . '' != '0') {
         verifyID($this, $lFID, 'people/business ID');
     }
     $displayData = array();
     $displayData['lGiftID'] = $lGiftID = (int) $lGiftID;
     $displayData['lFID'] = $lFID = (int) $lFID;
     $displayData['js'] = '';
     $displayData['bNew'] = $bNew = $lGiftID <= 0;
     if ($bNew) {
         if (!bTestForURLHack('dataEntryGifts')) {
             return;
         }
     } else {
         if (!bTestForURLHack('editGifts')) {
             return;
         }
     }
     // load models
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->library('js_build/ajax_support');
     $this->load->helper('dl_util/web_layout');
     //      $this->load->helper ('dl_util/email_web');
     $this->load->helper('dl_util/time_date');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->model('util/mlist_generic', 'clsList');
     $this->load->model('people/mpeople', 'clsPeople');
     $this->load->model('biz/mbiz', 'clsBiz');
     $this->load->model('donations/maccts_camps', 'clsAC');
     $this->load->model('donations/mdonations', 'clsGift');
     $this->clsGift->loadGiftViaGID($lGiftID);
     $gifts =& $this->clsGift->gifts[0];
     if ($bNew) {
         $bPeople = !$this->clsPeople->bBizRec($lFID);
         $gifts->ga_lKeyID = -1;
         $gifts->gi_dteDonation = $gdteNow;
         //         $gifts->lACOID           = $gclsChapterACO->lKeyID;
         $gifts->gi_curAmnt = 0.0;
         if ($bPeople) {
             $this->clsPeople->loadPeopleViaPIDs($lFID, false, false);
             $gifts->lACOID = $this->clsPeople->people[0]->lACO;
         } else {
             $this->clsBiz->loadBizRecsViaBID($lFID);
             $gifts->lACOID = $this->clsBiz->bizRecs[0]->lACO;
         }
     } else {
         $lFID = $this->clsGift->gifts[0]->gi_lForeignID;
         $bPeople = !$this->clsGift->gifts[0]->pe_bBiz;
     }
     $this->clsAC->loadAccounts(false, false, null);
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtAmount', 'Donation Amount', 'trim|required|callback_stripCommas|numeric');
     $this->form_validation->set_rules('rdoACO', 'Accounting Country', 'trim|required');
     $this->form_validation->set_rules('ddlAccount', 'Account', 'trim|required|callback_giftVerifyAccountValid');
     $this->form_validation->set_rules('ddlCamps', 'Campaign', 'trim|callback_giftVerifyCampValid');
     $this->form_validation->set_rules('ddlInKind', 'In-Kind', 'trim');
     $this->form_validation->set_rules('ddlPayType', 'Payment Type', 'trim|callback_giftVerifyPayType');
     $this->form_validation->set_rules('ddlGiftCat', 'Gift Category', 'trim');
     $this->form_validation->set_rules('ddlAttrib', 'Attributed To', 'trim');
     $this->form_validation->set_rules('txtCheck', 'Check #', 'trim');
     $this->form_validation->set_rules('txtDDate', 'Donation date', 'trim|required|callback_giftVerifyDDateValid');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $lSponID = $this->clsGift->gifts[0]->gi_lSponsorID;
         $displayData['bSponPayment'] = $bSponPayment = !is_null($lSponID);
         //-------------------------------
         // Acct/Camp and ajax interface
         //-------------------------------
         if ($bSponPayment) {
             redirect('sponsors/payments/addEditPayment/' . $lSponID . '/' . $lFID . '/' . $lGiftID);
         } else {
             $clsAjax = new ajax_support();
             $displayData['js'] .= $clsAjax->showCreateXmlHTTPObject();
             $displayData['js'] .= $clsAjax->showCampaignLoadViaAcctID();
         }
         $this->load->library('generic_form');
         $displayData['js'] .= strDatePicker('datepickerFuture', true);
         $displayData['formData']->strStaffCFName = $gifts->strStaffCFName;
         $displayData['formData']->strStaffCLName = $gifts->strStaffCLName;
         $displayData['formData']->dteOrigin = $gifts->dteOrigin;
         $displayData['formData']->strStaffLFName = $gifts->strStaffLFName;
         $displayData['formData']->strStaffLLName = $gifts->strStaffLLName;
         $displayData['formData']->dteLastUpdate = $gifts->dteLastUpdate;
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $this->clsAC->loadCampaigns(false, true, $gifts->ga_lKeyID, false, null);
             $displayData['formData']->txtAmount = number_format($gifts->gi_curAmnt, 2);
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios($gifts->lACOID, 'rdoACO');
             if (!$bSponPayment) {
                 $displayData['formData']->strDDLAccts = $this->clsAC->strDDLAccts($gifts->ga_lKeyID, true, true);
                 $displayData['formData']->strDDLCamps = $this->clsAC->strDDLCampaigns($gifts->gc_lKeyID, false);
             }
             $displayData['formData']->strNotes = htmlspecialchars($gifts->strNotes);
             $displayData['formData']->strCheckNum = htmlspecialchars($gifts->gi_strCheckNum);
             if (is_null($gifts->mdteDonation)) {
                 $displayData['formData']->txtDDate = '';
             } else {
                 $displayData['formData']->txtDDate = strNumericDateViaMysqlDate($gifts->mdteDonation, $gbDateFormatUS);
             }
             $this->clsList->strBlankDDLName = 'n/a';
             $this->clsList->enumListType = CENUM_LISTTYPE_INKIND;
             $displayData['formData']->strDDLGIK = $this->clsList->strLoadListDDL('ddlInKind', true, $gifts->gi_lGIK_ID);
             $this->clsList->strBlankDDLName = '&nbsp;';
             $this->clsList->enumListType = CENUM_LISTTYPE_GIFTPAYTYPE;
             $displayData['formData']->strDDLPayType = $this->clsList->strLoadListDDL('ddlPayType', true, $gifts->gi_lPaymentType);
             $this->clsList->enumListType = CENUM_LISTTYPE_MAJORGIFTCAT;
             $displayData['formData']->strDDLMajGiftType = $this->clsList->strLoadListDDL('ddlGiftCat', true, $gifts->gi_lMajorGiftCat);
             $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
             $displayData['formData']->strDDLAttrib = $this->clsList->strLoadListDDL('ddlAttrib', true, $gifts->gi_lAttributedTo);
         } else {
             setOnFormError($displayData);
             $this->clsAC->loadCampaigns(false, true, set_value('ddlAccount'), false, null);
             $displayData['formData']->txtDDate = set_value('txtDDate');
             $displayData['formData']->txtAmount = set_value('txtAmount');
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios(set_value('rdoACO'), 'rdoACO');
             if (!$bSponPayment) {
                 $displayData['formData']->strDDLAccts = $this->clsAC->strDDLAccts(set_value('ddlAccount'), true, true);
                 $displayData['formData']->strDDLCamps = $this->clsAC->strDDLCampaigns(set_value('ddlCamps'), false);
             }
             $displayData['formData']->strNotes = set_value('txtNotes');
             $displayData['formData']->strCheckNum = set_value('txtCheck');
             $this->clsList->strBlankDDLName = 'n/a';
             $this->clsList->enumListType = CENUM_LISTTYPE_INKIND;
             $displayData['formData']->strDDLGIK = $this->clsList->strLoadListDDL('ddlInKind', true, set_value('ddlInKind'));
             $this->clsList->strBlankDDLName = '&nbsp;';
             $this->clsList->enumListType = CENUM_LISTTYPE_GIFTPAYTYPE;
             $displayData['formData']->strDDLPayType = $this->clsList->strLoadListDDL('ddlPayType', true, set_value('ddlPayType'));
             $this->clsList->enumListType = CENUM_LISTTYPE_MAJORGIFTCAT;
             $displayData['formData']->strDDLMajGiftType = $this->clsList->strLoadListDDL('ddlGiftCat', true, set_value('ddlGiftCat'));
             $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
             $displayData['formData']->strDDLAttrib = $this->clsList->strLoadListDDL('ddlAttrib', true, set_value('ddlAttrib'));
         }
         $displayData['gift'] =& $gifts;
         //--------------------------
         // breadcrumbs
         //--------------------------
         if ($bPeople) {
             $displayData['pageTitle'] = anchor('main/menu/people', 'People', 'class="breadcrumb"') . ' | ' . anchor('people/people_record/view/' . $lFID, 'Record', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . ' Donation Record';
             $displayData['mainTemplate'] = array('donations/gift_add_edit_view');
             $this->clsPeople->loadPeopleViaPIDs($lFID, false, false);
             $displayData['contextSummary'] = $this->clsPeople->peopleHTMLSummary(0);
         } else {
             $displayData['pageTitle'] = anchor('main/menu/biz', 'Businesses/Organizations', 'class="breadcrumb"') . ' | ' . anchor('biz/biz_record/view/' . $lFID, 'Record', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . ' Donation Record';
             $displayData['mainTemplate'] = array('donations/gift_add_edit_view');
             $this->clsBiz->loadBizRecsViaBID($lFID);
             $displayData['contextSummary'] = $this->clsBiz->strBizHTMLSummary(0);
         }
         $displayData['title'] = CS_PROGNAME . ' | Donations';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $this->load->model('personalization/muser_fields', 'clsUF');
         $this->load->model('personalization/muser_fields_create', 'clsUFC');
         $this->load->model('admin/mpermissions', 'perms');
         $this->load->helper('dl_util/util_db');
         $gifts->gi_curAmnt = (double) trim($_POST['txtAmount']);
         $gifts->gc_lKeyID = trim((int) $_POST['ddlCamps']);
         $gifts->gi_lSponsorID = null;
         $gifts->lACOID = (int) trim($_POST['rdoACO']);
         $gifts->strNotes = trim($_POST['txtNotes']);
         $gifts->gi_strCheckNum = trim($_POST['txtCheck']);
         $gifts->gi_lAttributedTo = (int) trim($_POST['ddlAttrib']);
         $gifts->gi_lGIK_ID = (int) trim($_POST['ddlInKind']);
         $gifts->gi_lPaymentType = (int) trim($_POST['ddlPayType']);
         $gifts->gi_lMajorGiftCat = (int) trim($_POST['ddlGiftCat']);
         $gifts->gi_lForeignID = $lFID;
         if ($gifts->gi_lAttributedTo <= 0) {
             $gifts->gi_lAttributedTo = null;
         }
         if ($gifts->gi_lGIK_ID <= 0) {
             $gifts->gi_lGIK_ID = null;
         }
         $gifts->gi_bGIK = !is_null($gifts->gi_lGIK_ID);
         $strDate = trim($_POST['txtDDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $gifts->mdteDonation = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lGiftID = $this->clsGift->lAddNewGiftRecord();
             $this->session->set_flashdata('msg', 'Gift added');
         } else {
             $this->clsGift->updateGiftRecord();
             $this->session->set_flashdata('msg', 'Gift record updated');
         }
         redirect('donations/gift_record/view/' . $lGiftID);
     }
 }
 function addEdit($lPledgeID, $lFID = '0')
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gdteNow, $gclsChapterACO, $gbDateFormatUS;
     $this->load->helper('dl_util/verify_id');
     if ($lPledgeID . '' != '0') {
         verifyID($this, $lPledgeID, 'pledge ID');
     }
     if ($lFID . '' != '0') {
         verifyID($this, $lFID, 'people/business ID');
     }
     $displayData = array();
     $displayData['lPledgeID'] = $lPledgeID = (int) $lPledgeID;
     $displayData['lFID'] = $lFID = (int) $lFID;
     $displayData['js'] = '';
     $displayData['bNew'] = $bNew = $lPledgeID <= 0;
     if ($bNew) {
         if (!bTestForURLHack('dataEntryGifts')) {
             return;
         }
     } else {
         if (!bTestForURLHack('editGifts')) {
             return;
         }
     }
     // load models
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->library('js_build/ajax_support');
     $this->load->helper('dl_util/web_layout');
     //      $this->load->helper ('dl_util/email_web');
     $this->load->helper('dl_util/time_date');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->model('util/mlist_generic', 'clsList');
     $this->load->model('people/mpeople', 'clsPeople');
     $this->load->model('biz/mbiz', 'clsBiz');
     $this->load->model('donations/maccts_camps', 'clsAC');
     //      $this->load->model  ('donations/mdonations',   'clsGift');
     $this->load->model('donations/mpledges', 'clsPledges');
     $this->clsPledges->loadPledgeViaPledgeID($lPledgeID);
     $pledge =& $this->clsPledges->pledges[0];
     if ($bNew) {
         $bPeople = !$this->clsPeople->bBizRec($lFID);
         $pledge->lAccountID = -1;
         $pledge->dteStart = $gdteNow;
         $pledge->curCommitment = 0.0;
         if ($bPeople) {
             $this->clsPeople->loadPeopleViaPIDs($lFID, false, false);
             $pledge->lACOID = $this->clsPeople->people[0]->lACO;
         } else {
             $this->clsBiz->loadBizRecsViaBID($lFID);
             $pledge->lACOID = $this->clsBiz->bizRecs[0]->lACO;
         }
     } else {
         $lFID = $pledge->lForeignID;
         $bPeople = !$pledge->bBiz;
         if ($bPeople) {
             $this->clsPeople->loadPeopleViaPIDs($lFID, false, false);
         } else {
             $this->clsBiz->loadBizRecsViaBID($lFID);
         }
     }
     $this->clsAC->loadAccounts(false, false, null);
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtCommit', 'Commitment Amount', 'trim|required|callback_stripCommas|numeric|callback_pledgeVerifyCommitment');
     $this->form_validation->set_rules('txtNumPay', 'Number of Payments', 'trim|required|callback_stripCommas|numeric|greater_than[0]');
     $this->form_validation->set_rules('rdoACO', 'Accounting Country', 'trim|required');
     $this->form_validation->set_rules('ddlAccount', 'Account', 'trim|required|callback_pledgeVerifyAccountValid');
     $this->form_validation->set_rules('ddlCamps', 'Campaign', 'trim|callback_pledgeVerifyCampValid');
     $this->form_validation->set_rules('ddlAttrib', 'Attributed To', 'trim');
     $this->form_validation->set_rules('ddlFreq', 'Payment Frequency', 'trim|callback_pledgeFreqValid');
     $this->form_validation->set_rules('txtStartDate', 'Start date', 'trim|required|callback_pledgeVerifyDateValid');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         //-------------------------------
         // Acct/Camp and ajax interface
         //-------------------------------
         $clsAjax = new ajax_support();
         $displayData['js'] .= $clsAjax->showCreateXmlHTTPObject();
         $displayData['js'] .= $clsAjax->showCampaignLoadViaAcctID();
         $this->load->library('generic_form');
         $displayData['js'] .= strDatePicker('datepickerFuture', true);
         $displayData['formData']->strStaffCFName = $pledge->strStaffCFName;
         $displayData['formData']->strStaffCLName = $pledge->strStaffCLName;
         $displayData['formData']->dteOrigin = $pledge->dteOrigin;
         $displayData['formData']->strStaffLFName = $pledge->strStaffLFName;
         $displayData['formData']->strStaffLLName = $pledge->strStaffLLName;
         $displayData['formData']->dteLastUpdate = $pledge->dteLastUpdate;
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $this->clsAC->loadCampaigns(false, true, $pledge->lAccountID, false, null);
             $displayData['formData']->txtCommit = number_format($pledge->curCommitment, 2);
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios($pledge->lACOID, 'rdoACO');
             $displayData['formData']->strDDLAccts = $this->clsAC->strDDLAccts($pledge->lAccountID, true, true);
             $displayData['formData']->strDDLCamps = $this->clsAC->strDDLCampaigns($pledge->lCampaignID, false);
             $displayData['formData']->strDDLFreq = $this->clsPledges->strDDLPledgeFrequecy('ddlFreq', $pledge->enumFreq, true);
             $displayData['formData']->txtNumPay = $pledge->lNumCommit;
             $displayData['formData']->strNotes = htmlspecialchars($pledge->strNotes);
             if (is_null($pledge->mdteStart)) {
                 $displayData['formData']->txtStartDate = '';
             } else {
                 $displayData['formData']->txtStartDate = strNumericDateViaMysqlDate($pledge->mdteStart, $gbDateFormatUS);
             }
             $this->clsList->strBlankDDLName = 'n/a';
             $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
             $displayData['formData']->strDDLAttrib = $this->clsList->strLoadListDDL('ddlAttrib', true, $pledge->lAttributedTo);
         } else {
             setOnFormError($displayData);
             $this->clsAC->loadCampaigns(false, true, set_value('ddlAccount'), false, null);
             $displayData['formData']->txtStartDate = set_value('txtStartDate');
             $displayData['formData']->txtCommit = set_value('txtCommit');
             $displayData['formData']->txtNumPay = set_value('txtNumPay');
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios(set_value('rdoACO'), 'rdoACO');
             $displayData['formData']->strDDLAccts = $this->clsAC->strDDLAccts(set_value('ddlAccount'), true, true);
             $displayData['formData']->strDDLCamps = $this->clsAC->strDDLCampaigns(set_value('ddlCamps'), false);
             $displayData['formData']->strNotes = set_value('txtNotes');
             $this->clsList->strBlankDDLName = '&nbsp;';
             $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
             $displayData['formData']->strDDLAttrib = $this->clsList->strLoadListDDL('ddlAttrib', true, set_value('ddlAttrib'));
             $displayData['formData']->strDDLFreq = $this->clsPledges->strDDLPledgeFrequecy('ddlFreq', set_value('ddlFreq'), true);
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['mainTemplate'] = 'donations/pledge_add_edit_view';
         if ($bPeople) {
             $displayData['pageTitle'] = anchor('main/menu/people', 'People', 'class="breadcrumb"') . ' | ' . anchor('people/people_record/view/' . $lFID, 'Record', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . ' Pledge Record';
             $this->clsPeople->loadPeopleViaPIDs($lFID, false, false);
             $displayData['contextSummary'] = $this->clsPeople->peopleHTMLSummary(0);
         } else {
             $displayData['pageTitle'] = anchor('main/menu/biz', 'Businesses/Organizations', 'class="breadcrumb"') . ' | ' . anchor('biz/biz_record/view/' . $lFID, 'Record', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . ' Pledge Record';
             $this->clsBiz->loadBizRecsViaBID($lFID);
             $displayData['contextSummary'] = $this->clsBiz->strBizHTMLSummary(0);
         }
         $displayData['title'] = CS_PROGNAME . ' | Pledges';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $pledge->curCommitment = (double) trim($_POST['txtCommit']);
         $pledge->lNumCommit = (int) trim($_POST['txtNumPay']);
         $pledge->enumFreq = trim($_POST['ddlFreq']);
         $pledge->lCampaignID = (int) trim($_POST['ddlCamps']);
         $pledge->lForeignID = $lFID;
         $pledge->lACOID = (int) trim($_POST['rdoACO']);
         $pledge->strNotes = trim($_POST['txtNotes']);
         $pledge->lAttributedTo = (int) trim($_POST['ddlAttrib']);
         if ($pledge->lAttributedTo <= 0) {
             $pledge->lAttributedTo = null;
         }
         $strDate = trim($_POST['txtStartDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $pledge->mdteStart = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lPledgeID = $this->clsPledges->lAddNewPledgeRecord();
             $this->session->set_flashdata('msg', 'Pledge added');
         } else {
             $this->clsPledges->updatePledgeRecord($pledge->lKeyID);
             $this->session->set_flashdata('msg', 'Pledge record updated');
         }
         redirect('donations/pledge_record/view/' . $lPledgeID);
     }
 }
 function addEditAuction($lAuctionID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gdteNow, $gbDateFormatUS, $gclsChapterACO;
     if (!bTestForURLHack('showAuctions')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     if ($lAuctionID . '' != '0') {
         verifyID($this, $lAuctionID, 'auction ID');
     }
     $displayData = array();
     $displayData['formData'] = new stdClass();
     $displayData['lAuctionID'] = $lAuctionID = (int) $lAuctionID;
     $displayData['bNew'] = $bNew = $lAuctionID <= 0;
     $displayData['js'] = '';
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/link_auction');
     $this->load->helper('auctions/auction');
     $this->load->model('auctions/mauctions', 'cAuction');
     $this->load->model('auctions/mbid_sheets', 'cBidSheets');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->model('donations/maccts_camps', 'clsAC');
     $this->load->helper('dl_util/web_layout');
     $this->load->library('js_build/ajax_support');
     $this->cAuction->loadAuctionByAucID($lAuctionID);
     $auction = $this->cAuction->auctions[0];
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtAuctionName', 'Auction Name', 'trim|required|' . 'callback_verifyUniqueAuction[' . $lAuctionID . ']');
     $this->form_validation->set_rules('txtContact', 'Contact', 'trim');
     $this->form_validation->set_rules('txtDescription', 'Description', 'trim');
     $this->form_validation->set_rules('txtLocation', 'Location', 'trim');
     $this->form_validation->set_rules('txtEmail', 'Email', 'trim');
     $this->form_validation->set_rules('txtPhone', 'Phone', 'trim');
     $this->form_validation->set_rules('rdoACO', 'Accounting Country', 'trim');
     $this->form_validation->set_rules('ddlDefBS', 'Default Bid Sheet', 'trim');
     $this->form_validation->set_rules('txtADate', 'Auction Date', 'trim|required|callback_auctionDateValid');
     $this->form_validation->set_rules('ddlAccount', 'Account', 'trim|required|callback_auctionVerifyAccountValid');
     $this->form_validation->set_rules('ddlCamps', 'Campaign', 'trim|callback_auctionVerifyCampValid');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         $displayData['js'] .= strDatePicker('datepickerFuture', true);
         $this->clsAC->loadAccounts(false, false, null);
         $clsAjax = new ajax_support();
         $displayData['js'] .= $clsAjax->showCreateXmlHTTPObject();
         $displayData['js'] .= $clsAjax->showCampaignLoadViaAcctID();
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             //echo(__FILE__.' '.__LINE__.'<br>'."\n"); die;
             if ($bNew) {
                 $auction->lACOID = $gclsChapterACO->lKeyID;
                 $displayData['formData']->txtADate = '';
                 $auction->lAccountID = -1;
                 $displayData['lNumBidSheets'] = 0;
             } else {
                 $displayData['ddlDefBidSheet'] = $this->cBidSheets->strBidSheetListDDL($auction->lKeyID, $auction->lBidsheetID, 'ddlDefBS', true, $displayData['lNumBidSheets']);
                 $displayData['formData']->txtADate = strNumericDateViaMysqlDate($auction->mdteAuction, $gbDateFormatUS);
             }
             $this->clsAC->loadCampaigns(false, true, $auction->lAccountID, false, null);
             $displayData['formData']->strDDLAccts = $this->clsAC->strDDLAccts($auction->lAccountID, true, true);
             $displayData['formData']->strDDLCamps = $this->clsAC->strDDLCampaigns($auction->lCampaignID, false);
             $displayData['formData']->txtAuctionName = htmlspecialchars($auction->strAuctionName);
             $displayData['formData']->txtDescription = htmlspecialchars($auction->strDescription);
             $displayData['formData']->txtLocation = htmlspecialchars($auction->strLocation);
             $displayData['formData']->txtContact = htmlspecialchars($auction->strContact);
             $displayData['formData']->txtEmail = htmlspecialchars($auction->strEmail);
             $displayData['formData']->txtPhone = htmlspecialchars($auction->strPhone);
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios($auction->lACOID, 'rdoACO');
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtAuctionName = set_value('txtAuctionName');
             $displayData['formData']->txtDescription = set_value('txtDescription');
             $displayData['formData']->txtLocation = set_value('txtLocation');
             $displayData['formData']->txtContact = set_value('txtContact');
             $displayData['formData']->txtEmail = set_value('txtEmail');
             $displayData['formData']->txtPhone = set_value('txtPhone');
             $displayData['formData']->txtADate = set_value('txtADate');
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios(set_value('rdoACO'), 'rdoACO');
             if ($bNew) {
                 $displayData['lNumBidSheets'] = 0;
             } else {
                 $displayData['ddlDefBidSheet'] = $this->cBidSheets->strBidSheetListDDL($auction->lKeyID, set_value('ddlDefBS'), 'ddlDefBS', true, $displayData['lNumBidSheets']);
             }
             $this->clsAC->loadCampaigns(false, true, set_value('ddlAccount'), false, null);
             $displayData['formData']->strDDLAccts = $this->clsAC->strDDLAccts(set_value('ddlAccount'), true, true);
             $displayData['formData']->strDDLCamps = $this->clsAC->strDDLCampaigns(set_value('ddlCamps'), false);
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = GSTR_AUCTIONTOPLEVEL . ' | ' . anchor('auctions/auctions/auctionEvents', 'Silent Auctions', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . '  Auction';
         $displayData['title'] = CS_PROGNAME . ' | Silent Auctions';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'auctions/add_edit_auction_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strDate = trim($_POST['txtADate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $auction->mdteAuction = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $auction->strAuctionName = trim($_POST['txtAuctionName']);
         $auction->strDescription = trim($_POST['txtDescription']);
         $auction->lACOID = trim($_POST['txtADate']);
         $auction->strLocation = trim($_POST['txtLocation']);
         $auction->strContact = trim($_POST['txtContact']);
         $auction->strPhone = trim($_POST['txtPhone']);
         $auction->strEmail = trim($_POST['txtEmail']);
         $auction->lACOID = (int) trim($_POST['rdoACO']);
         $auction->lCampaignID = (int) trim($_POST['ddlCamps']);
         $auction->lDefaultBidSheet = (int) trim(@$_POST['ddlDefBS']);
         if ($auction->lDefaultBidSheet <= 0) {
             $auction->lDefaultBidSheet = null;
         }
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lAuctionID = $this->cAuction->addNewAuction();
             $this->session->set_flashdata('msg', 'Auction record added');
         } else {
             $this->cAuction->updateAuction($lAuctionID);
             $this->session->set_flashdata('msg', 'Auction record updated');
         }
         redirect('auctions/auctions/viewAuctionRecord/' . $lAuctionID);
     }
 }