function addEditDate($lEventID, $lDateID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gdteNow, $gbDateFormatUS;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lEventID, 'event ID');
     if ($lDateID . '' != '0') {
         verifyID($this, $lDateID, 'event date ID');
     }
     $displayData = array();
     $displayData['lEventID'] = $lEventID = (int) $lEventID;
     $displayData['lDateID'] = $lDateID = (int) $lDateID;
     $this->load->model('vols/mvol_event_dates', 'clsVolEventDates');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/web_layout');
     $this->clsVolEventDates->loadEventDateViaDateID($lDateID);
     $displayData['bNew'] = $bNew = $lDateID <= 0;
     $displayData['edate'] = $edate = $this->clsVolEventDates->dates[0];
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtEDate', 'Event date', 'trim|required|callback_edateVerifyDateValid');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $params = array('enumStyle' => 'terse');
         $this->load->library('generic_rpt', $params);
         $this->load->model('vols/mvol_events', 'clsVolEvents');
         $this->clsVolEvents->loadEventsViaEID($lEventID);
         $displayData['contextSummary'] = $this->clsVolEvents->volEventHTMLSummary(0);
         $this->load->library('generic_form');
         if (validation_errors() == '') {
             if (is_null($edate->dteEvent)) {
                 $displayData['formData']->txtEDate = '';
             } else {
                 $displayData['formData']->txtEDate = strNumericDateViaMysqlDate($edate->mDteEvent, $gbDateFormatUS);
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtEDate = set_value('txtEDate');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/vols', 'Volunteers', 'class="breadcrumb"') . ' | ' . anchor('volunteers/events_schedule/viewEventsList', 'Event List', 'class="breadcrumb"') . ' | ' . anchor('volunteers/events_record/viewEvent/' . $lEventID, 'Event', 'class="breadcrumb"');
         if (!$bNew) {
             $displayData['pageTitle'] .= ' | ' . anchor('volunteers/event_dates_view/viewDates/' . $lDateID, 'Event Date', 'class="breadcrumb"');
         }
         $displayData['pageTitle'] .= ' | ' . ($bNew ? 'Add New' : 'Edit') . ' Event Date';
         $displayData['title'] = CS_PROGNAME . ' | Volunteers';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'vols/vol_event_date_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strEDate = trim($_POST['txtEDate']);
         MDY_ViaUserForm($strEDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $strEDate = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         if ($bNew) {
             $lDateID = $this->clsVolEventDates->lInsertEventDate($lEventID, $strEDate, true);
         } else {
             $this->clsVolEventDates->updateEventDate($lDateID, $strEDate, true);
         }
         $this->session->set_flashdata('msg', 'The event date was ' . ($bNew ? 'added' : 'updated'));
         redirect('volunteers/event_dates_view/viewDates/' . $lDateID);
     }
 }
 function cicoGeneric($lIItemID, $bCheckOut, $bCheckIn, $bLost)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gstrFormatDatePicker, $gbDateFormatUS, $gdteNow;
     if (!bTestForURLHack('inventoryMgr')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lIItemID, 'inventory item ID');
     $displayData = array();
     $displayData['js'] = '';
     $displayData['lIItemID'] = $lIItemID = (int) $lIItemID;
     $displayData['bCheckOut'] = $bCheckOut = (bool) $bCheckOut;
     $displayData['bCheckIn'] = $bCheckIn = (bool) $bCheckIn;
     $displayData['bLost'] = $bLost = (bool) $bLost;
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->model('staff/inventory/minventory');
     $this->load->model('staff/inventory/minv_cico', 'ccico');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('staff/link_inventory');
     $this->load->helper('dl_util/time_date');
     $params = array('enumStyle' => 'terse', 'clsRpt');
     $this->load->library('generic_rpt', $params);
     $displayData['formData'] = new stdClass();
     $this->load->library('generic_form');
     // load the inventory item
     $this->ccico->loadSingleInventoryItem($lIItemID, $lNumItems, $items);
     $displayData['item'] = $item =& $items[0];
     $displayData['lICatID'] = $lICatID = $displayData['item']->lCategoryID;
     // most recent check-out / check-in entry
     $this->ccico->itemCICOMostRecent($lIItemID, $lNumCICO, $CICOrec);
     $displayData['bNew'] = $bNew = $lNumCICO == 0;
     $displayData['lCICO_ID'] = $lCICO_ID = $CICOrec->lKeyID;
     $displayData['CICOrec'] = $CICOrec;
     $bCheckedOut = $this->ccico->bItemCheckedOut($lIItemID, $lCICO_CO_ID);
     $bLost = $item->bLost;
     // make sure the request is compatible with current ci/co state of item
     if ($bCheckOut) {
         if ($bCheckedOut) {
             $this->session->set_flashdata('error', 'The item is currently checked out.');
             redirect('staff/inventory/inventory_items/iitemRec/' . $lIItemID);
         }
         if ($bLost) {
             $this->session->set_flashdata('error', 'This item is flagged as "lost" and can not be checked out.');
             redirect('staff/inventory/inventory_items/iitemRec/' . $lIItemID);
         }
         $strTitleLabel = 'Item Check-out / Loan';
         $strVerifyDate = 'Date Checked Out';
     } elseif ($bCheckIn) {
         if (!$bCheckedOut) {
             $this->session->set_flashdata('error', 'The item is not currently checked out.');
             redirect('staff/inventory/inventory_items/iitemRec/' . $lIItemID);
         }
         if ($bLost) {
             $this->session->set_flashdata('error', 'This item is flagged as "lost" and can not be checked out.');
             redirect('staff/inventory/inventory_items/iitemRec/' . $lIItemID);
         }
         $strTitleLabel = 'Item Check-in / Return';
         $strVerifyDate = 'Date Checked In';
     } elseif ($bLost) {
         $strTitleLabel = 'Item Lost';
     } else {
         screamForHelp('Invalid ci/co operation<br>error on line  <b> -- ' . __LINE__ . ' --</b>,<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
     }
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     if ($bCheckOut) {
         $this->form_validation->set_rules('txtCheckedOutTo', '<b>Checked-Out To</b>', 'trim|required');
         $this->form_validation->set_rules('txtSecurity', 'Security Deposit');
         $this->form_validation->set_rules('txtCO_Notes', 'Notes');
         $this->form_validation->set_rules('txtDateCICO', '<b>' . $strVerifyDate . '</b>', 'trim|required|callback_itemVerifyDateCICOValid[false,0]');
     } elseif ($bCheckIn) {
         $this->form_validation->set_rules('txtCO_Notes', 'Notes');
         $this->form_validation->set_rules('txtDateCICO', '<b>' . $strVerifyDate . '</b>', 'trim|required|callback_itemVerifyDateCICOValid[true,' . $CICOrec->dteCheckedOut . ']');
     } elseif ($bLost) {
     }
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         // load the inventory category breadcrumbs
         $item->strCatBreadCrumb = '';
         $this->ccico->icatBreadCrumbs($item->strCatBreadCrumb, $lICatID);
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             if ($bCheckOut) {
                 $displayData['formData']->txtSecurity = '';
                 $displayData['formData']->txtCO_Notes = '';
                 $displayData['formData']->txtCheckedOutTo = '';
                 $displayData['formData']->txtDateCICO = date($gstrFormatDatePicker, $gdteNow);
                 /*
                                $displayData['formData']->txtSecurity     = htmlspecialchars($CICOrec->strSecurity);
                                $displayData['formData']->txtCO_Notes     = htmlspecialchars($CICOrec->strCO_Notes);
                                $displayData['formData']->txtCheckedOutTo = htmlspecialchars($CICOrec->strCheckedOutTo);
                                if (is_null($CICOrec->dteCheckedOut)){
                                   $displayData['formData']->txtDateCICO = '';
                                }else {
                                   $displayData['formData']->txtDateCICO = date($gstrFormatDatePicker, $CICOrec->dteCheckedOut);
                                }
                 */
             } elseif ($bCheckIn) {
                 $displayData['formData']->txtCI_Notes = htmlspecialchars($CICOrec->strCI_Notes);
                 if (is_null($CICOrec->dteCheckedIn)) {
                     $displayData['formData']->txtDateCICO = '';
                 } else {
                     $displayData['formData']->txtDateCICO = date($gstrFormatDatePicker, $item->dteCheckedIn);
                 }
             } elseif ($bLost) {
             }
         } else {
             setOnFormError($displayData);
             if ($bCheckOut) {
                 $displayData['formData']->txtSecurity = set_value('txtSecurity');
                 $displayData['formData']->txtCO_Notes = set_value('txtCO_Notes');
                 $displayData['formData']->txtCheckedOutTo = set_value('txtCheckedOutTo');
                 $displayData['formData']->txtDateCICO = set_value('txtDateCICO');
             } elseif ($bCheckIn) {
                 $displayData['formData']->txtDateCICO = set_value('txtDateCICO');
                 $displayData['formData']->txtCI_Notes = set_value('txtCI_Notes');
             } elseif ($bLost) {
             }
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['contextSummary'] = $this->ccico->strIItemHTMLSummary($item);
         $displayData['pageTitle'] = anchor('main/menu/more', 'More', 'class="breadcrumb"') . ' | ' . anchor('staff/inventory/icat/viewICats', 'Inventory Categories', 'class="breadcrumb"') . ' | ' . anchor('staff/inventory/inventory_items/iitemRec/' . $lIItemID, 'Inventory Item', 'class="breadcrumb"') . ' | ' . $strTitleLabel;
         $displayData['title'] = CS_PROGNAME . ' | Inventory Management';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'staff/inventory/cico_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $CICOrec->lItemID = $lIItemID;
         $strDate = trim($_POST['txtDateCICO']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         if ($bCheckOut) {
             $CICOrec->strCO_Notes = trim($_POST['txtCO_Notes']);
             $CICOrec->strCheckedOutTo = trim($_POST['txtCheckedOutTo']);
             $CICOrec->strSecurity = trim($_POST['txtSecurity']);
             $CICOrec->mdteCheckedOut = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
             $lCICO_ID = $this->ccico->lAddCheckOutRec($CICOrec);
             $this->ccico->lAddItemHistoryRec($lIItemID, $lCICO_ID, 'checked-out');
             $this->session->set_flashdata('msg', 'Inventory item checked-out');
         } elseif ($bCheckIn) {
             $CICOrec->strCI_Notes = trim($_POST['txtCI_Notes']);
             $CICOrec->mdteCheckedIn = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
             $this->ccico->addCheckInRec($CICOrec);
             $this->ccico->lAddItemHistoryRec($lIItemID, $lCICO_ID, 'checked-in');
             $this->session->set_flashdata('msg', 'Inventory item checked-in');
         } elseif ($bLost) {
         }
         redirect('staff/inventory/inventory_items/iitemRec/' . $lIItemID);
     }
 }
 function edit($lImageDocID)
 {
     //------------------------------------------------------------------------------
     //
     //------------------------------------------------------------------------------
     global $gstrFormatDatePicker, $gbDateFormatUS;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lImageDocID, 'image/document ID');
     $displayData = array();
     $displayData['formData'] = new stdClass();
     $displayData['lImageDocID'] = $lImageDocID = (int) $lImageDocID;
     $displayData['bUpdate'] = true;
     //-------------------------
     // models & helpers
     //-------------------------
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     $this->load->model('img_docs/mimage_doc', 'clsImgDoc');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->helper('auctions/auction');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/context');
     $this->load->helper('img_docs/image_doc');
     $this->load->helper('img_docs/link_img_docs');
     $displayData['enumContextType'] = $enumContextType = $this->clsImgDoc->enumContextViaID($lImageDocID);
     $displayData['lFID'] = $lFID = $this->clsImgDoc->lForeignIDViaID($lImageDocID);
     $displayData['enumEntryType'] = $enumEntryType = $this->clsImgDoc->enumEntryTypeViaID($lImageDocID);
     $displayData['bImage'] = $bImage = $enumEntryType == CENUM_IMGDOC_ENTRY_IMAGE;
     $strLabel = $bImage ? 'Image' : 'Document';
     loadSupportModels($enumContextType, $lFID);
     $this->clsImgDoc->loadDocImageInfoViaID($lImageDocID);
     $imgDoc =& $this->clsImgDoc->imageDocs[0];
     $enumIDContext = imgDocTags\xlateTagTypeViaContextType($enumContextType, $enumEntryType);
     $displayData['strTagLabel'] = imgDocTags\strXlateImgDocContext($enumIDContext);
     $this->cidTags->loadImgDocTagsForDDL($enumIDContext, $lImageDocID, $displayData['lNumTags'], $displayData['tags']);
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtDescription', 'Description', 'trim');
     $this->form_validation->set_rules('txtCaption', 'Caption', 'trim');
     $this->form_validation->set_rules('txtDate', 'Date of ' . $strLabel, 'trim|required|' . 'callback_clientImageUploadVerifyBDateValid');
     if ($bImage) {
         $this->form_validation->set_rules('chkProfile', 'Profile', 'trim');
     }
     if ($this->form_validation->run() == FALSE) {
         $this->load->helper('dl_util/web_layout');
         $this->load->library('generic_form');
         if ($bImage) {
             $displayData['strImageTag'] = strLinkHTMLTag($enumContextType, $enumEntryType, $lFID, $imgDoc->strSystemFN, 'View in new window', true, '') . strImageHTMLTag($enumContextType, $enumEntryType, $lFID, $imgDoc->strSystemThumbFN, '', false, ' style="border: 1px solid black;" ') . '</a>';
         } else {
             $displayData['strImageTag'] = '';
         }
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $displayData['formData']->txtDate = date($gstrFormatDatePicker, $imgDoc->dteDocImage);
             $displayData['formData']->txtDescription = htmlspecialchars($imgDoc->strDescription);
             $displayData['formData']->txtCaption = htmlspecialchars($imgDoc->strCaptionTitle);
             if ($bImage) {
                 $displayData['formData']->bProfile = $imgDoc->bProfile;
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtDate = set_value('txtDate');
             $displayData['formData']->txtDescription = set_value('txtDescription');
             $displayData['formData']->txtCaption = set_value('txtCaption');
             $this->updateTagSelect($displayData['lNumTags'], $displayData['tags']);
             if ($bImage) {
                 $displayData['formData']->bProfile = set_value('chkProfile') == 'TRUE';
             }
         }
         $displayData['contextSummary'] = strContextHTML($enumContextType, $lFID, $displayData['strContextName']);
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = breadCrumbsToRecViewViaContextType($enumContextType, $lFID, 'Update ' . $strLabel);
         $displayData['title'] = CS_PROGNAME . ' | Clients';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'img_docs/upload_image_doc_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $this->load->model('img_docs/mimage_doc', 'clsImgDoc');
         if ($bImage) {
             $this->load->library('image_lib');
         }
         $this->clsImgDoc->loadDocImageInfoViaID(-1);
         $imageDoc =& $this->clsImgDoc->imageDocs[0];
         $bProfile = @$_POST['chkProfile'] == 'TRUE';
         $strDate = trim($_POST['txtDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $dteMySQLDate = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //         $uploadResults = $_SESSION[CS_NAMESPACE.'uploadResults'];
         $enumEntryType = $bImage ? CENUM_IMGDOC_ENTRY_IMAGE : CENUM_IMGDOC_ENTRY_PDF;
         $imageDoc->enumEntryType = $enumEntryType;
         $imageDoc->enumContextType = $enumContextType;
         $imageDoc->lForeignID = $lFID;
         $imageDoc->strCaptionTitle = trim($_POST['txtCaption']);
         $imageDoc->strDescription = trim($_POST['txtDescription']);
         $imageDoc->dteMysqlDocImage = $dteMySQLDate;
         $imageDoc->bProfile = $bProfile;
         // tags
         $this->setUserSelectedTagsFromPost($lImageDocID);
         $this->clsImgDoc->updateDocImageRec($lImageDocID);
         if ($bImage && $bProfile) {
             $this->clsImgDoc->setProfileFlag($lImageDocID, $enumContextType, $lFID);
         }
         $this->session->set_flashdata('msg', 'The ' . $strLabel . ' information was updated');
         redirectViaContextType($enumContextType, $lFID);
     }
 }
function saveCustomPTables($lFID, $lNumTables, &$utables)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $gbDateFormatUS;
    if ($lNumTables == 0) {
        return;
    }
    $CI =& get_instance();
    $CI->clsUFD->lForeignID = $lFID;
    $CI->clsUFD->fields = array();
    $CI->clsUFD->fields[0] = new stdClass();
    $vfield =& $CI->clsUFD->fields[0];
    foreach ($utables as $utable) {
        $bMultiEntry = $utable->bMultiEntry;
        if (!isset($utable->bCProg)) {
            $utable->bCProg = false;
        }
        if ($bMultiEntry) {
            $utable->lKeyID = $utable->lTableID;
            $lRecID = $CI->clsUFD->lSaveMultiRecViaPost(true, $lFID, $lRecID, $utable);
        } else {
            $CI->clsUFD->lTableID = $lTableID = $utable->lTableID;
            foreach ($utable->ufields as $ufield) {
                $vfield->enumFieldType = $enumType = $ufield->enumFieldType;
                $vfield->pff_lKeyID = $ufield->lFieldID;
                $strFN = $ufield->strFieldNameInternal;
                $varUserVal = null;
                switch ($enumType) {
                    case CS_FT_CHECKBOX:
                        $varUserVal = @$_POST[$strFN] == 'true';
                        break;
                    case CS_FT_DATE:
                        $varUserVal = trim($_POST[$strFN]);
                        if ($varUserVal == '') {
                            $varUserVal = ' null ';
                        } else {
                            MDY_ViaUserForm($varUserVal, $lMon, $lDay, $lYear, $gbDateFormatUS);
                            $varUserVal = ' "' . strMoDaYr2MySQLDate($lMon, $lDay, $lYear) . '" ';
                        }
                        break;
                    case CS_FT_TEXTLONG:
                    case CS_FT_TEXT255:
                    case CS_FT_TEXT80:
                    case CS_FT_TEXT20:
                        $varUserVal = trim($_POST[$strFN]);
                        break;
                    case CS_FT_INTEGER:
                        $varUserVal = trim($_POST[$strFN]);
                        $varUserVal = (int) stripCustomCommas($varUserVal);
                        //                     $varUserVal = (integer)trim($varUserVal);
                        break;
                    case CS_FT_HEADING:
                        break;
                    case CS_FT_CURRENCY:
                        $varUserVal = trim($_POST[$strFN]);
                        $varUserVal = stripCustomCommas($varUserVal);
                        $varUserVal = number_format((double) $varUserVal, 2, '.', '');
                        break;
                    case CS_FT_DDL:
                        $varUserVal = (int) $_POST[$strFN];
                        if ($varUserVal <= 0) {
                            $varUserVal = ' null ';
                        }
                        break;
                    case CS_FT_DDLMULTI:
                        $multiDDL = new stdClass();
                        $multiDDL->lFieldID = $ufield->lFieldID;
                        $multiDDL->lTableID = $utable->lTableID;
                        $multiDDL->entries = array();
                        $multiDDL->lNumEntries = 0;
                        if (isset($_POST[$strFN])) {
                            foreach ($_POST[$strFN] as $strDDL) {
                                $lID = (int) $strDDL;
                                if ($lID > 0) {
                                    $multiDDL->entries[] = $lID;
                                    ++$multiDDL->lNumEntries;
                                }
                            }
                        }
                        $CI->clsUFD->addDDLMultiEntries($lFID, $multiDDL);
                        break;
                    default:
                        screamForHelp($enumType . ': invalid field type<br>error on line ' . __LINE__ . ',<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
                        break;
                }
                if ($enumType != CS_FT_HEADING && $enumType != CS_FT_DDLMULTI) {
                    $CI->clsUFD->updateUserField($varUserVal);
                }
            }
        }
    }
}
 function addEditVolTraining($lTrainingID, $lVolID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $glVolID, $gbVolMgr, $gbDateFormatUS, $glChapterID;
     $this->load->helper('dl_util/verify_id');
     verifyID($glChapterID, $lVolID, 'volunteer ID');
     if ((int) $lTrainingID > 0) {
         verifyID($glChapterID, $lTrainingID, 'vol training ID');
     }
     $displayData = array();
     $displayData['formData'] = new stdClass();
     $displayData['lTrainingID'] = $lTrainingID = (int) $lTrainingID;
     $displayData['lVolID'] = $lVolID = (int) $lVolID;
     $displayData['bNew'] = $bNew = $lTrainingID <= 0;
     //-------------------------------------
     // models / helpers / libraries
     //-------------------------------------
     $this->load->model('vols/mvol', 'clsVol');
     $this->load->model('vols/mvol_training', 'cvt');
     $this->load->model('util/mlist_generic', 'clsList');
     $this->load->helper('dl_util/time_date');
     // for date verification
     $this->load->helper('hospice/link_hospice');
     $this->load->helper('hospice/patient_visit');
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->helper('dl_util/web_layout');
     //--------------------------
     // load training record
     //--------------------------
     $this->cvt->loadVolTrainingViaTID($lTrainingID, $lNumTraining, $training);
     $train =& $training[0];
     $this->clsVol->loadVolRecsViaVolID($lVolID, true);
     $displayData['volRec'] = $volRec =& $this->clsVol->volRecs[0];
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('ddlDuration', 'Duration', 'trim|callback_vtVerifyDuration');
     $this->form_validation->set_rules('ddlTraining', 'Training', 'trim|callback_vtVerifyType');
     $this->form_validation->set_rules('ddlTrainingBy', 'Conducted By', 'trim|callback_vtVerifyTrainingBy');
     $this->form_validation->set_rules('txtDate', 'Date of Training', 'trim|required' . '|callback_verifyDateValid');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     if ($this->form_validation->run() == FALSE) {
         //         $this->clsVol->loadVolRecsViaVolID($lVolID, true);
         $displayData['contextSummary'] = $this->clsVol->volHTMLSummary(0);
         $displayData['volRec'] =& $this->clsVol->volRecs[0];
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             if (is_null($train->dteTraining)) {
                 $displayData['formData']->txtDate = '';
             } else {
                 $displayData['formData']->txtDate = strNumericDateViaMysqlDate($train->mysqlDteTrain, $gbDateFormatUS);
             }
             $displayData['formData']->strNotes = htmlspecialchars($train->strNotes);
             $displayData['formData']->ddlDuration = pvisit\strDurationDDL($train->lDuration, true, 'ddlDuration', 'dur');
             // training type generic list
             $this->clsList->strBlankDDLName = '&nbsp;';
             $this->clsList->enumListType = CENUM_LISTTYPE_VOLTRAINING;
             $displayData['formData']->strTrainingType = $this->clsList->strLoadListDDL($glChapterID, 'ddlTraining', true, $train->lTrainingID);
             // training conducted by generic list
             $this->clsList->enumListType = CENUM_LISTTYPE_VOLTRAININGBY;
             $displayData['formData']->strTrainingBy = $this->clsList->strLoadListDDL($glChapterID, 'ddlTrainingBy', true, $train->lTrainingByID);
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtDate = set_value('txtDate');
             $displayData['formData']->strNotes = set_value('txtNotes');
             $displayData['formData']->ddlDuration = pvisit\strDurationDDL(set_value('ddlDuration'), true, 'ddlDuration', 'dur');
             // training type generic list
             $this->clsList->strBlankDDLName = '&nbsp;';
             $this->clsList->enumListType = CENUM_LISTTYPE_VOLTRAINING;
             $displayData['formData']->strTrainingType = $this->clsList->strLoadListDDL($glChapterID, 'ddlTraining', true, set_value('ddlTraining'));
             // training conducted by generic list
             $this->clsList->enumListType = CENUM_LISTTYPE_VOLTRAININGBY;
             $displayData['formData']->strTrainingBy = $this->clsList->strLoadListDDL($glChapterID, 'ddlTrainingBy', true, set_value('ddlTrainingBy'));
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = 'Log Volunteer Training';
         $displayData['title'] = CS_PROGNAME . ' | Volunteers';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'hospice/vols/training_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $train->lVolID = $lVolID;
         $train->strNotes = trim($_POST['txtNotes']);
         $train->lTrainingID = (int) trim($_POST['ddlTraining']);
         $train->lTrainingByID = (int) trim($_POST['ddlTrainingBy']);
         $train->lDuration = (int) trim($_POST['ddlDuration']);
         $strDate = trim($_POST['txtDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $train->mysqlDteTrain = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lTrainingID = $this->cvt->lAddVolTraining($training[0]);
             $this->session->set_flashdata('msg', 'Volunteer training was recorded for ' . $volRec->strSafeNameFL . '.');
         } else {
             $this->cvt->updateVolTraining($lTrainingID, $training[0]);
             $this->session->set_flashdata('msg', 'Training record updated');
         }
         redirect('hospice/vols/vol_training/volTrainingLog/' . $lVolID);
         //         redirect('hospice/vols/vol_directory/view/false/'.strtoupper(substr($volRec->strLName, 0, 1)));
     }
 }
 public function contact($lPID = '', $lHID = 0)
 {
     //-------------------------------------------------------------------------
     //
     //-------------------------------------------------------------------------
     global $gclsChapterACO, $gbDateFormatUS, $gbVolLogin, $gVolPerms, $glVolPeopleID, $glUserID;
     global $gstrDuplicateWarning;
     $gstrDuplicateWarning = '';
     if ($gbVolLogin) {
         $lPID = $glVolPeopleID;
     }
     $this->load->helper('dl_util/verify_id');
     if ($lPID . '' != '0') {
         verifyID($this, $lPID, 'people ID');
     }
     if ($lHID . '' != '0') {
         verifyID($this, $lHID, 'household ID');
     }
     $displayData = array();
     $displayData['formData'] = new stdClass();
     $displayData['lPID'] = $lPID = (int) $lPID;
     $displayData['bNew'] = $bNew = $lPID <= 0;
     $bExistingHousehold = $lHID > 0;
     if ($bNew) {
         if (!bTestForURLHack('dataEntryPeopleBizVol')) {
             return;
         }
     } else {
         $bOkayToEdit = bAllowAccess('dataEntryPeopleBizVol') || bAllowAccess('volEditContact');
         if (!$bOkayToEdit) {
             bTestForURLHack('forceFail');
             return;
         }
     }
     // models associated with the people record
     $this->load->model('people/mpeople', 'clsPeople');
     $this->load->model('admin/madmin_aco', 'clsACO');
     if (!$gbVolLogin) {
         $this->load->model('sponsorship/msponsorship', 'clsSpon');
         $this->load->model('donations/mdonations', 'clsGifts');
     }
     if ($bNew) {
         $this->load->model('util/mdup_checker', 'cDupChecker');
     }
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/web_layout');
     //      $this->load->helper('dl_util/email_web');
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     //--------------------------
     // load people record
     //--------------------------
     $this->clsPeople->sqlWhereExtra = " AND pe_lKeyID = {$lPID} ";
     if ($gbVolLogin) {
         $this->clsPeople->loadPeople(false, false, true);
     } else {
         $this->clsPeople->loadPeople(true, true, true);
     }
     $people = $this->clsPeople->people[0];
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtFName', 'First Name', 'trim|required');
     $this->form_validation->set_rules('txtTitle', '', 'trim');
     $this->form_validation->set_rules('txtMName', '', 'trim');
     $this->form_validation->set_rules('txtLName', 'Last Name', 'trim|required');
     $this->form_validation->set_rules('txtPName', '', 'trim');
     $this->form_validation->set_rules('txtSal', '', 'trim');
     $this->form_validation->set_rules('txtAddr1', '', 'trim');
     $this->form_validation->set_rules('txtAddr2', '', 'trim');
     $this->form_validation->set_rules('txtCity', '', 'trim');
     $this->form_validation->set_rules('txtState', '', 'trim');
     $this->form_validation->set_rules('txtZip', '', 'trim');
     $this->form_validation->set_rules('txtCountry', '', 'trim');
     $this->form_validation->set_rules('txtNotes', '', 'trim');
     $this->form_validation->set_rules('txtPhone', '', 'trim');
     $this->form_validation->set_rules('txtCell', '', 'trim');
     $this->form_validation->set_rules('rdoGender', '', 'trim');
     $this->form_validation->set_rules('txtBDate', '', 'trim|callback_peopleRecVerifyBDateValid' . '|callback_peopleRecVerifyBDatePast');
     if ($gbVolLogin) {
         $this->form_validation->set_rules('txtEmail', 'Email', 'trim|required|valid_email|callback_verifyUniqueUserID');
     } else {
         $this->form_validation->set_rules('txtEmail', 'Email', 'trim|valid_email');
         $this->form_validation->set_rules('rdoACO', '', 'trim');
         $this->form_validation->set_rules('ddlAttrib', 'Attributed to');
     }
     // test for duplicate people
     if ($bNew) {
         $this->form_validation->set_rules('hiddenTestDup', 'dummy', 'callback_verifyNoDups');
         $displayData['bHiddenNewTestDup'] = true;
     }
     if ($bNew) {
         $people->lHouseholdID = $lHID;
         if ($lHID <= 0) {
             $people->strHouseholdName = '<i>new</i>';
         } else {
             $people->strHouseholdName = $this->clsPeople->strHouseholdNameViaHID($lHID);
         }
     }
     if ($this->form_validation->run() == FALSE) {
         $displayData['js'] = '';
         $this->load->library('generic_form');
         $this->load->model('util/mlist_generic', 'clsList');
         $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
         $displayData['strDuplicateWarning'] = $gstrDuplicateWarning;
         if (validation_errors() == '') {
             if ($bNew) {
                 $displayData['formData']->strBDay = $displayData['formData']->txtTitle = $displayData['formData']->txtFName = $displayData['formData']->txtMName = $displayData['formData']->txtLName = $displayData['formData']->txtPName = $displayData['formData']->txtSal = $displayData['formData']->txtNotes = $displayData['formData']->txtEmail = $displayData['formData']->txtCell = '';
                 $displayData['formData']->enumGender = 'Unknown';
                 $displayData['formData']->dteMysqlBirthDate = '';
                 if ($bExistingHousehold) {
                     $clsHouse = new mpeople();
                     $clsHouse->loadPeopleViaPIDs($lHID, false, false);
                     $house = $clsHouse->people[0];
                     $displayData['formData']->txtAddr1 = htmlspecialchars($house->strAddr1);
                     $displayData['formData']->txtAddr2 = htmlspecialchars($house->strAddr2);
                     $displayData['formData']->txtCity = htmlspecialchars($house->strCity);
                     $displayData['formData']->txtState = htmlspecialchars($house->strState);
                     $displayData['formData']->txtZip = htmlspecialchars($house->strZip);
                     $displayData['formData']->txtCountry = htmlspecialchars($house->strCountry);
                     $displayData['formData']->txtPhone = htmlspecialchars($house->strPhone);
                     $lACO = $house->lACO;
                 } else {
                     $displayData['formData']->txtAddr1 = $displayData['formData']->txtAddr2 = $displayData['formData']->txtCity = $displayData['formData']->txtState = $displayData['formData']->txtZip = $displayData['formData']->txtCountry = $displayData['formData']->txtPhone = '';
                     $lACO = $gclsChapterACO->lKeyID;
                 }
                 if (!$gbVolLogin) {
                     $displayData['formData']->rdoACO = $this->clsACO->strACO_Radios($lACO, 'rdoACO');
                     $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL('ddlAttrib', true, -1);
                 }
             } else {
                 $displayData['formData']->txtTitle = $people->strTitle;
                 $displayData['formData']->txtFName = htmlspecialchars($people->strFName);
                 $displayData['formData']->txtMName = htmlspecialchars($people->strMName);
                 $displayData['formData']->txtLName = htmlspecialchars($people->strLName);
                 $displayData['formData']->txtPName = htmlspecialchars($people->strPreferredName);
                 $displayData['formData']->txtSal = htmlspecialchars($people->strSalutation);
                 $displayData['formData']->txtNotes = htmlspecialchars($people->strNotes);
                 $displayData['formData']->txtAddr1 = htmlspecialchars($people->strAddr1);
                 $displayData['formData']->txtAddr2 = htmlspecialchars($people->strAddr2);
                 $displayData['formData']->txtCity = htmlspecialchars($people->strCity);
                 $displayData['formData']->txtState = htmlspecialchars($people->strState);
                 $displayData['formData']->txtZip = htmlspecialchars($people->strZip);
                 $displayData['formData']->txtCountry = htmlspecialchars($people->strCountry);
                 $displayData['formData']->txtEmail = htmlspecialchars($people->strEmail);
                 $displayData['formData']->txtPhone = htmlspecialchars($people->strPhone);
                 $displayData['formData']->txtCell = htmlspecialchars($people->strCell);
                 $displayData['formData']->enumGender = $people->enumGender;
                 if (is_null($people->dteMysqlBirthDate)) {
                     $displayData['formData']->strBDay = '';
                 } else {
                     $displayData['formData']->strBDay = strNumericDateViaMysqlDate($people->dteMysqlBirthDate, $gbDateFormatUS);
                 }
                 if (!$gbVolLogin) {
                     $displayData['formData']->rdoACO = $this->clsACO->strACO_Radios($people->lACO, 'rdoACO');
                     $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL('ddlAttrib', true, $people->lAttributedTo);
                 }
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtTitle = set_value('txtTitle');
             $displayData['formData']->txtFName = set_value('txtFName');
             $displayData['formData']->txtMName = set_value('txtMName');
             $displayData['formData']->txtLName = set_value('txtLName');
             $displayData['formData']->txtPName = set_value('txtPName');
             $displayData['formData']->txtSal = set_value('txtSal');
             $displayData['formData']->txtNotes = set_value('txtNotes');
             $displayData['formData']->txtAddr1 = set_value('txtAddr1');
             $displayData['formData']->txtAddr2 = set_value('txtAddr2');
             $displayData['formData']->txtCity = set_value('txtCity');
             $displayData['formData']->txtState = set_value('txtState');
             $displayData['formData']->txtZip = set_value('txtZip');
             $displayData['formData']->txtCountry = set_value('txtCountry');
             $displayData['formData']->txtEmail = set_value('txtEmail');
             $displayData['formData']->txtPhone = set_value('txtPhone');
             $displayData['formData']->txtCell = set_value('txtCell');
             $displayData['formData']->enumGender = set_value('rdoGender');
             $displayData['formData']->strBDay = set_value('txtBDate');
             if (!$gbVolLogin) {
                 $displayData['formData']->rdoACO = $this->clsACO->strACO_Radios(set_value('rdoACO'), 'rdoACO');
                 $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL('ddlAttrib', true, set_value('ddlAttrib'));
             }
         }
         $displayData['people'] = $people;
         //--------------------------
         // breadcrumbs
         //--------------------------
         if ($gbVolLogin) {
             $displayData['pageTitle'] = anchor('people/people_record/view/' . $lPID, 'Record', 'class="breadcrumb"') . ' | Edit';
         } else {
             $displayData['pageTitle'] = anchor('main/menu/people', 'People', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Record' : anchor('people/people_record/view/' . $lPID, 'Record', 'class="breadcrumb"')) . ' | ' . ($bNew ? 'Add New' : 'Edit');
         }
         $displayData['title'] = CS_PROGNAME . ' | People';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'people/people_add_edit_view';
         $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');
         $people =& $this->clsPeople->people[0];
         $people->lHouseholdID = (int) $lHID;
         $people->strTitle = trim($_POST['txtTitle']);
         $people->strFName = trim($_POST['txtFName']);
         $people->strMName = trim($_POST['txtMName']);
         $people->strLName = trim($_POST['txtLName']);
         $people->strPreferredName = trim($_POST['txtPName']);
         $people->strSalutation = trim($_POST['txtSal']);
         $people->strNotes = trim($_POST['txtNotes']);
         if ($people->strPreferredName == '') {
             $people->strPreferredName = $people->strFName;
         }
         if ($people->strSalutation == '') {
             $people->strSalutation = $people->strFName;
         }
         $people->strAddr1 = trim($_POST['txtAddr1']);
         $people->strAddr2 = trim($_POST['txtAddr2']);
         $people->strCity = trim($_POST['txtCity']);
         $people->strState = trim($_POST['txtState']);
         $people->strZip = trim($_POST['txtZip']);
         $people->strCountry = trim($_POST['txtCountry']);
         if ($gbVolLogin) {
             $strOriginalEmail = $people->strEmail;
         }
         $people->strEmail = trim($_POST['txtEmail']);
         $people->strPhone = trim($_POST['txtPhone']);
         $people->strCell = trim($_POST['txtCell']);
         $people->enumGender = trim($_POST['rdoGender']);
         if ($gbVolLogin) {
             $this->load->model('admin/muser_accts', 'clsUser');
             $this->clsUser->updateUserAcctViaPeopleInfo($glUserID, $people);
         }
         if (!$gbVolLogin) {
             $people->lACO = (int) $_POST['rdoACO'];
             $lAttrib = (int) $_REQUEST['ddlAttrib'];
             if ($lAttrib <= 0) {
                 $people->lAttributedTo = null;
             } else {
                 $people->lAttributedTo = $lAttrib;
             }
         }
         $strBDate = trim($_POST['txtBDate']);
         if ($strBDate == '') {
             $people->dteMysqlBirthDate = null;
         } else {
             MDY_ViaUserForm($strBDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
             $people->dteMysqlBirthDate = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         }
         if ($bNew) {
             $people->dteExpire = $people->dteMysqlDeath = null;
             $lPID = $this->clsPeople->lCreateNewPeopleRec();
             $this->session->set_flashdata('msg', 'The people record was added');
         } else {
             $this->clsPeople->updatePeopleRec($lPID);
             if ($gbVolLogin) {
                 $this->session->set_flashdata('msg', 'Your contact information was updated.');
             } else {
                 $this->session->set_flashdata('msg', 'The people record was updated');
             }
         }
         redirect('people/people_record/view/' . $lPID);
     }
 }
 function addEditAuctionItem($lPackageID, $lItemID, $lDonorID = null)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gbDateFormatUS;
     if (!bTestForURLHack('showAuctions')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lPackageID, 'package ID');
     if ($lItemID . '' != '0') {
         verifyID($this, $lItemID, 'auction item ID');
     }
     if (!is_null($lDonorID)) {
         verifyID($this, $lDonorID, 'people/business ID');
     }
     $displayData = array();
     $displayData['js'] = '';
     $displayData['formData'] = new stdClass();
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->helper('dl_util/time_date');
     $this->load->model('auctions/mauctions', 'cAuction');
     $this->load->model('auctions/mpackages', 'cPackages');
     $this->load->model('auctions/mitems', 'cItems');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->model('img_docs/mimage_doc', 'clsImgDoc');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('dl_util/link_auction');
     $this->load->helper('auctions/auction');
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->library('generic_form');
     //-----------------------------------------
     // load package and associated auction
     //-----------------------------------------
     setPackageContext($lPackageID, $lAuctionID, $displayData);
     $displayData['lAuctionID'] = $lAuctionID = (int) $lAuctionID;
     $displayData['lPackageID'] = $lPackageID = (int) $lPackageID;
     $displayData['lItemID'] = $lItemID = (int) $lItemID;
     $displayData['lDonorID'] = $lDonorID;
     $displayData['bNew'] = $bNew = $lItemID <= 0;
     $this->cItems->loadItemViaItemID($lItemID);
     $displayData['item'] = $item =& $this->cItems->items[0];
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtItemName', 'Item Name', 'trim|required');
     $this->form_validation->set_rules('txtDonorAck', 'Donor Acknowledgement', 'trim|required');
     $this->form_validation->set_rules('txtPublicNotes', 'Public Notes', 'trim');
     $this->form_validation->set_rules('txtPrivateNotes', 'Private Notes', 'trim');
     $this->form_validation->set_rules('txtODate', 'Date Item Obtained', 'trim|required|callback_obtainedDateValid');
     $this->form_validation->set_rules('txtEstValue', 'Estimated Value', 'trim|required|callback_stripCommas|numeric|callback_minPackageAmnt[0.01]');
     $this->form_validation->set_rules('txtOutOfPocket', 'Out of Pocket Expenses', 'trim|required|callback_stripCommas|numeric|callback_minPackageAmnt[0.00]');
     if ($this->form_validation->run() == FALSE) {
         $displayData['js'] .= strDatePicker('datepickerFuture', true);
         if (is_null($lDonorID)) {
             $lHoldDonorID = $item->lItemDonorID;
             $bBiz = $item->itemDonor_bBiz;
             $displayData['formData']->txtItemDonor = $item->itemDonor_safeName;
             $strTempAck = 'Anonymous';
         } else {
             $lHoldDonorID = $lDonorID;
             $this->load->model('people/mpeople', 'clsPeople');
             $this->clsPeople->peopleBizInfoViaPID($lDonorID, $pbInfo);
             $bBiz = $pbInfo->bBiz;
             $displayData['formData']->txtItemDonor = $strTempAck = $pbInfo->strSafeNameFL;
         }
         if ($bBiz) {
             $displayData['formData']->txtItemDonor .= ' <i>(business)</i>' . strLinkView_BizRecord($lHoldDonorID, 'View business record', true);
         } else {
             $displayData['formData']->txtItemDonor .= ' ' . strLinkView_PeopleRecord($lHoldDonorID, 'View people record', true);
         }
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             if ($bNew) {
                 $displayData['formData']->txtODate = '';
             } else {
                 $displayData['formData']->txtODate = strNumericDateViaMysqlDate($item->mdteItemObtained, $gbDateFormatUS);
             }
             $displayData['formData']->txtItemName = htmlspecialchars($item->strItemName);
             if ($item->strDonorAck . '' == '') {
                 $displayData['formData']->txtDonorAck = $strTempAck;
             } else {
                 $displayData['formData']->txtDonorAck = htmlspecialchars($item->strDonorAck);
             }
             $displayData['formData']->txtPublicNotes = htmlspecialchars($item->strDescription);
             $displayData['formData']->txtPrivateNotes = htmlspecialchars($item->strInternalNotes);
             $displayData['formData']->txtEstValue = number_format($item->curEstAmnt, 2);
             $displayData['formData']->txtOutOfPocket = number_format($item->curOutOfPocket, 2);
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtItemName = set_value('txtItemName');
             $displayData['formData']->txtDonorAck = set_value('txtDonorAck');
             $displayData['formData']->txtPublicNotes = set_value('txtPublicNotes');
             $displayData['formData']->txtPrivateNotes = set_value('txtPrivateNotes');
             $displayData['formData']->txtODate = set_value('txtODate');
             $displayData['formData']->txtEstValue = set_value('txtEstValue');
             $displayData['formData']->txtOutOfPocket = set_value('txtOutOfPocket');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = GSTR_AUCTIONTOPLEVEL . ' | ' . anchor('auctions/auctions/auctionEvents', 'Silent Auctions', 'class="breadcrumb"') . ' | ' . anchor('auctions/auctions/viewAuctionRecord/' . $lAuctionID, 'Auction', 'class="breadcrumb"') . ' | ' . anchor('auctions/packages/viewPackageRecord/' . $lPackageID, 'Auction Package', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . '  Item';
         $displayData['title'] = CS_PROGNAME . ' | Silent Auctions';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'auctions/add_edit_item_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strDate = trim($_POST['txtODate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $item->mdteItemObtained = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $item->lPackageID = $lPackageID;
         $item->strItemName = trim($_POST['txtItemName']);
         $item->strDonorAck = trim($_POST['txtDonorAck']);
         $item->strDescription = trim($_POST['txtPublicNotes']);
         $item->strInternalNotes = trim($_POST['txtPrivateNotes']);
         $item->curEstAmnt = (double) trim($_POST['txtEstValue']);
         $item->curOutOfPocket = (double) trim($_POST['txtOutOfPocket']);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lItemID = $this->cItems->addNewItem($lDonorID, $lPackageID);
             $this->session->set_flashdata('msg', 'Auction item record added');
         } else {
             $this->cItems->updateItem($lItemID);
             $this->session->set_flashdata('msg', 'Auction item record updated');
         }
         redirect('auctions/items/viewItemRecord/' . $lItemID);
     }
 }
 function addEditPRec($lPatientID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gbVolMgr, $glChapterID, $gstrFormatDatePicker, $gbDateFormatUS;
     if (!bTestForURLHack('volMgr')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     if ((int) $lPatientID > 0) {
         verifyID($glChapterID, $lPatientID, 'patient ID');
     }
     $displayData = array();
     $displayData['lPatientID'] = $lPatientID = (int) $lPatientID;
     $displayData['bNew'] = $bNew = $lPatientID <= 0;
     $displayData['js'] = '';
     $displayData['formData'] = new stdClass();
     //------------------------------------------------
     // models, libraries and utilities
     //------------------------------------------------
     $this->load->model('patients/mpatients', 'cPatients');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('dl_util/time_date');
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     // load patient record
     $this->cPatients->loadPatientsViaPatientID($lPatientID);
     $displayData['patient'] = $pRec =& $this->cPatients->patients[0];
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtTitle', '<b>Title</b>', 'trim');
     $this->form_validation->set_rules('txtFName', '<b>First Name</b>', 'trim|required');
     $this->form_validation->set_rules('txtMName', '<b>Middle Name</b>', 'trim');
     $this->form_validation->set_rules('txtLName', '<b>Last Name</b>', 'trim|required');
     $this->form_validation->set_rules('txtBDate', '<b>Date of Birth</b>', 'trim|required|callback_patientRecVerifyBDateValid' . '|callback_patientRecVerifyBDatePast');
     $this->form_validation->set_rules('txtPhone', 'Phone', 'trim');
     $this->form_validation->set_rules('txtCell', 'Cell', 'trim');
     $this->form_validation->set_rules('txtEmail', '<b>EMail</b>', 'trim|valid_email');
     $this->form_validation->set_rules('txtAddr1', '', 'trim');
     $this->form_validation->set_rules('txtAddr2', '', 'trim');
     $this->form_validation->set_rules('txtCity', '', 'trim');
     $this->form_validation->set_rules('txtState', '', 'trim');
     $this->form_validation->set_rules('txtZip', '', 'trim');
     $this->form_validation->set_rules('txtCountry', '', 'trim');
     $this->form_validation->set_rules('txtNotes', '', 'trim');
     if ($this->form_validation->run() == FALSE) {
         $this->load->library('generic_form');
         if (validation_errors() == '') {
             if (is_null($pRec->dteBirth)) {
                 $displayData['formData']->txtBDate = '';
             } else {
                 $displayData['formData']->txtBDate = strNumericDateViaMysqlDate($pRec->dteBirth, $gbDateFormatUS);
             }
             if ($bNew) {
                 $displayData['formData']->txtTitle = $displayData['formData']->txtFName = $displayData['formData']->txtMName = $displayData['formData']->txtLName = '';
                 $displayData['formData']->txtPhone = $displayData['formData']->txtCell = $displayData['formData']->txtEmail = '';
                 $displayData['formData']->txtAddr1 = $displayData['formData']->txtAddr2 = $displayData['formData']->txtCity = $displayData['formData']->txtState = $displayData['formData']->txtZip = $displayData['formData']->txtCountry = '';
                 $displayData['formData']->txtNotes = '';
             } else {
                 $displayData['formData']->txtTitle = htmlspecialchars($pRec->strTitle);
                 $displayData['formData']->txtFName = htmlspecialchars($pRec->strFName);
                 $displayData['formData']->txtMName = htmlspecialchars($pRec->strMName);
                 $displayData['formData']->txtLName = htmlspecialchars($pRec->strLName);
                 $displayData['formData']->txtPhone = htmlspecialchars($pRec->strPhone);
                 $displayData['formData']->txtCell = htmlspecialchars($pRec->strCell);
                 $displayData['formData']->txtEmail = htmlspecialchars($pRec->strEmail);
                 $displayData['formData']->txtAddr1 = htmlspecialchars($pRec->strAddr1);
                 $displayData['formData']->txtAddr2 = htmlspecialchars($pRec->strAddr2);
                 $displayData['formData']->txtCity = htmlspecialchars($pRec->strCity);
                 $displayData['formData']->txtState = htmlspecialchars($pRec->strState);
                 $displayData['formData']->txtZip = htmlspecialchars($pRec->strZip);
                 $displayData['formData']->txtCountry = htmlspecialchars($pRec->strCountry);
                 $displayData['formData']->txtNotes = htmlspecialchars($pRec->strBio);
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtTitle = set_value('txtTitle');
             $displayData['formData']->txtFName = set_value('txtFName');
             $displayData['formData']->txtMName = set_value('txtMName');
             $displayData['formData']->txtLName = set_value('txtLName');
             $displayData['formData']->txtBDate = set_value('txtBDate');
             $displayData['formData']->txtPhone = set_value('txtPhone');
             $displayData['formData']->txtCell = set_value('txtCell');
             $displayData['formData']->txtEmail = set_value('txtEmail');
             $displayData['formData']->txtAddr1 = set_value('txtAddr1');
             $displayData['formData']->txtAddr2 = set_value('txtAddr2');
             $displayData['formData']->txtCity = set_value('txtCity');
             $displayData['formData']->txtState = set_value('txtState');
             $displayData['formData']->txtZip = set_value('txtZip');
             $displayData['formData']->txtCountry = set_value('txtCountry');
             $displayData['formData']->txtNotes = set_value('txtNotes');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $params = array('enumStyle' => 'terse');
         $this->load->library('generic_rpt', $params, 'generic_rpt');
         $displayData['pageTitle'] = ' Patient Record';
         $displayData['title'] = CS_PROGNAME . ' | Patient';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'hospice/patients/patient_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strBDate = trim($_POST['txtBDate']);
         MDY_ViaUserForm($strBDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $pRec->dteBirth = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $pRec->strTitle = $_POST['txtTitle'];
         $pRec->strFName = $_POST['txtFName'];
         $pRec->strMName = $_POST['txtMName'];
         $pRec->strLName = $_POST['txtLName'];
         $pRec->strAddr1 = $_POST['txtAddr1'];
         $pRec->strAddr2 = $_POST['txtAddr2'];
         $pRec->strCity = $_POST['txtCity'];
         $pRec->strState = $_POST['txtState'];
         $pRec->strCountry = $_POST['txtCountry'];
         $pRec->strZip = $_POST['txtZip'];
         $pRec->strPhone = $_POST['txtPhone'];
         $pRec->strCell = $_POST['txtCell'];
         $pRec->strEmail = $_POST['txtEmail'];
         $pRec->strBio = $_POST['txtNotes'];
         if ($bNew) {
             $lPatientID = $this->cPatients->lAddNewPatient($pRec);
             $this->session->set_flashdata('msg', 'The patient record was added.');
         } else {
             $this->cPatients->updatePatient($lPatientID, $pRec);
             $this->session->set_flashdata('msg', 'The patient record was updated.');
         }
         redirect('hospice/patients/patient_rec/viewRec/' . $lPatientID);
     }
 }
 function addEditClient($lClientID, $clsClients)
 {
     //---------------------------------------------------------------
     //
     //---------------------------------------------------------------
     global $gbDateFormatUS, $gstrFormatDatePicker, $gdteNow, $glChapterID;
     global $gstrDuplicateWarning;
     if (!bTestForURLHack('showClients')) {
         return;
     }
     $displayData = array();
     $gstrDuplicateWarning = '';
     $displayData['lClientID'] = $lClientID = (int) $lClientID;
     $displayData['bNew'] = $bNew = $lClientID <= 0;
     $displayData['client'] = $client = $clsClients->clients[0];
     if (is_null($client->lLocationID)) {
         $client->lLocationID = (int) $_POST['lLocationID'];
         $client->lStatusCatID = (int) $_POST['lStatusCatID'];
         $client->lVocID = (int) $_POST['lVocID'];
     }
     //--------------------------------------------
     // models associated with the client record
     //--------------------------------------------
     $this->load->model('clients/mclient_locations', 'clsLocation');
     $this->load->model('sponsorship/msponsorship_programs', 'clsSponProg');
     $this->load->model('clients/mclient_status', 'clsClientStat');
     $this->load->model('clients/mclient_vocabulary', 'clsClientV');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/web_layout');
     if ($bNew) {
         $this->load->model('util/mdup_checker', 'cDupChecker');
         $this->load->model('admin/mpermissions', 'perms');
         $this->load->model('personalization/muser_fields', 'clsUF');
         $this->load->model('personalization/muser_schema', 'cUFSchema');
         $this->load->model('client_features/mcprograms', 'cprograms');
     }
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtFName', 'Client\'s First Name', 'trim|required');
     $this->form_validation->set_rules('txtMName', 'Client\'s Middle Name', 'trim');
     $this->form_validation->set_rules('txtLName', 'Client\'s Last Name', 'trim');
     $this->form_validation->set_rules('txtBDate', 'Birth date', 'trim|required|callback_clientRecVerifyBDateValid' . '|callback_clientRecVerifyBDatePast');
     $this->form_validation->set_rules('txtPEntryDate', 'Enrollment date', 'trim|required|callback_clientRecVerifyEDateValid' . '|callback_clientRecVerifyEDatePast');
     $this->form_validation->set_rules('txtMaxSpon', 'Max # of Sponsors', 'trim|required|is_natural');
     $this->form_validation->set_rules('rdoGender', 'Gender', 'required');
     $this->form_validation->set_rules('txtBio', 'Bio', 'trim');
     $this->form_validation->set_rules('ddlAttrib', 'Attributed to');
     $this->form_validation->set_rules('txtAddr1', '', 'trim');
     $this->form_validation->set_rules('txtAddr2', '', 'trim');
     $this->form_validation->set_rules('txtCity', '', 'trim');
     $this->form_validation->set_rules('txtState', '', 'trim');
     $this->form_validation->set_rules('txtZip', '', 'trim');
     $this->form_validation->set_rules('txtCountry', '', 'trim');
     $this->form_validation->set_rules('txtEmail', 'Email', 'trim|valid_email');
     $this->form_validation->set_rules('txtPhone', '', 'trim');
     $this->form_validation->set_rules('txtCell', '', 'trim');
     // test for duplicate clients
     if ($bNew) {
         $this->form_validation->set_rules('hiddenTestDup', 'dummy', 'callback_verifyNoDups');
         $this->form_validation->set_rules('ddlStatus', '', 'required|callback_clientRecVerifyInitStat');
         $displayData['bHiddenNewTestDup'] = true;
     }
     if ($this->form_validation->run() == FALSE) {
         $this->load->model('util/mlist_generic', 'clsList');
         $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
         $displayData['formData'] = new stdClass();
         $displayData['lLocationID'] = $lLocationID = $this->clsLocation->cl_lKeyID = $client->lLocationID;
         $this->clsLocation->loadLocationRec($lLocationID);
         $displayData['lVocID'] = $lVocID = $this->clsClientV->lVocID = $client->lVocID;
         $this->clsClientV->loadClientVocabulary(true, false);
         $displayData['clsClientV'] = $this->clsClientV;
         $displayData['clsLocation'] = $this->clsLocation;
         $this->clsSponProg->loadSponProgsViaLocID($lLocationID);
         $displayData['clsSponProg'] = $this->clsSponProg;
         $displayData['clsClientStat'] = $this->clsClientStat;
         $lSCID = $client->lStatusCatID;
         $this->clsClientStat->loadClientStatCatsEntries(true, $lSCID, false, null, true, false);
         $strMessage = '<font color="red">One or more client status entries must be established before
                          adding clients.</font>';
         $displayData['bNoStatEntries'] = $bNoStatEntries = $this->clsClientStat->bTestNoStatEntries($lSCID, true, $strMessage, $displayData['strNoStatErrMsg']);
         $this->load->library('generic_form');
         $displayData['strDuplicateWarning'] = $gstrDuplicateWarning;
         if (validation_errors() == '') {
             $displayData['formData']->txtFName = htmlspecialchars($client->strFName);
             $displayData['formData']->txtMName = htmlspecialchars($client->strMName);
             $displayData['formData']->txtLName = htmlspecialchars($client->strLName);
             $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL($glChapterID, 'ddlAttrib', true, $client->lAttribID);
             if (is_null($client->dteBirth)) {
                 $displayData['formData']->txtBDate = '';
             } else {
                 $displayData['formData']->txtBDate = strNumericDateViaMysqlDate($client->dteBirth, $gbDateFormatUS);
             }
             if (is_null($client->dteEnrollment)) {
                 $displayData['formData']->txtPEntryDate = '';
             } else {
                 $displayData['formData']->txtPEntryDate = date($gstrFormatDatePicker, $client->dteEnrollment);
             }
             if ($bNew) {
                 $displayData['formData']->lInitStatID = -1;
             }
             if ($this->clsSponProg->lNumSponPrograms > 0) {
                 foreach ($this->clsSponProg->sponProgs as $clsLocSP) {
                     $lSCID = $clsLocSP->lKeyID;
                     $clsLocSP->bSupported = $this->clsSponProg->bClientInSponProgram($lClientID, $lSCID, $lcsp_lKeyID);
                 }
             }
             $displayData['formData']->txtMaxSpon = $client->lMaxSponsors;
             $displayData['formData']->rdoGender = $client->enumGender;
             $displayData['formData']->txtBio = htmlspecialchars($client->strBio);
             $displayData['formData']->txtAddr1 = htmlspecialchars($client->strAddr1);
             $displayData['formData']->txtAddr2 = htmlspecialchars($client->strAddr2);
             $displayData['formData']->txtCity = htmlspecialchars($client->strCity);
             $displayData['formData']->txtState = htmlspecialchars($client->strState);
             $displayData['formData']->txtZip = htmlspecialchars($client->strZip);
             $displayData['formData']->txtCountry = htmlspecialchars($client->strCountry);
             $displayData['formData']->txtEmail = htmlspecialchars($client->strEmail);
             $displayData['formData']->txtPhone = htmlspecialchars($client->strPhone);
             $displayData['formData']->txtCell = htmlspecialchars($client->strCell);
         } else {
             setOnFormError($displayData);
             $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL($glChapterID, 'ddlAttrib', true, set_value('ddlAttrib'));
             $displayData['formData']->txtFName = set_value('txtFName');
             $displayData['formData']->txtMName = set_value('txtMName');
             $displayData['formData']->txtLName = set_value('txtLName');
             $displayData['formData']->txtBDate = set_value('txtBDate');
             $displayData['formData']->txtPEntryDate = set_value('txtPEntryDate');
             if ($bNew) {
                 $displayData['formData']->lInitStatID = set_value('ddlStatus');
             }
             // couldn't find a ci form validation way to do this....
             if ($this->clsSponProg->lNumSponPrograms > 0) {
                 if (isset($_POST['chkSP'])) {
                     foreach ($this->clsSponProg->sponProgs as $clsLocSP) {
                         $lSCID = $clsLocSP->lKeyID;
                         $clsLocSP->bSupported = in_array($lSCID, $_POST['chkSP']);
                     }
                 }
             }
             $displayData['formData']->txtMaxSpon = set_value('txtMaxSpon');
             $displayData['formData']->rdoGender = set_value('rdoGender');
             $displayData['formData']->txtBio = set_value('txtBio');
             $displayData['formData']->txtAddr1 = set_value('txtAddr1');
             $displayData['formData']->txtAddr2 = set_value('txtAddr2');
             $displayData['formData']->txtCity = set_value('txtCity');
             $displayData['formData']->txtState = set_value('txtState');
             $displayData['formData']->txtZip = set_value('txtZip');
             $displayData['formData']->txtCountry = set_value('txtCountry');
             $displayData['formData']->txtEmail = set_value('txtEmail');
             $displayData['formData']->txtPhone = set_value('txtPhone');
             $displayData['formData']->txtCell = set_value('txtCell');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         if ($lClientID > 0) {
             $displayData['pageTitle'] = anchor('main/menu/client', 'Clients', 'class="breadcrumb"') . ' | ' . anchor('clients/client_record/view/' . $lClientID, 'Client Record', 'class="breadcrumb"') . ' | Edit Client Record';
         } else {
             $displayData['pageTitle'] = anchor('main/menu/client', 'Clients', 'class="breadcrumb"') . ' | Add New Client Record';
         }
         $displayData['title'] = CS_PROGNAME . ' | Clients';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'client/client_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strBDate = trim($_POST['txtBDate']);
         MDY_ViaUserForm($strBDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $client->dteBirth = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $strEnrollDate = trim($_POST['txtPEntryDate']);
         MDY_ViaUserForm($strEnrollDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $client->dteEnrollment = strtotime($lMon . '/' . $lDay . '/' . $lYear);
         $client->strFName = trim($_POST['txtFName']);
         $client->strMName = trim($_POST['txtMName']);
         $client->strLName = trim($_POST['txtLName']);
         $client->strBio = trim($_POST['txtBio']);
         $client->enumGender = trim($_POST['rdoGender']);
         $client->lMaxSponsors = (int) trim($_POST['txtMaxSpon']);
         $client->strAddr1 = trim($_POST['txtAddr1']);
         $client->strAddr2 = trim($_POST['txtAddr2']);
         $client->strCity = trim($_POST['txtCity']);
         $client->strState = trim($_POST['txtState']);
         $client->strZip = trim($_POST['txtZip']);
         $client->strCountry = trim($_POST['txtCountry']);
         $client->strEmail = trim($_POST['txtEmail']);
         $client->strPhone = trim($_POST['txtPhone']);
         $client->strCell = trim($_POST['txtCell']);
         $lAttrib = (int) $_REQUEST['ddlAttrib'];
         if ($lAttrib <= 0) {
             $client->lAttribID = null;
         } else {
             $client->lAttribID = $lAttrib;
         }
         if ($bNew) {
             $this->load->model('personalization/muser_fields', 'clsUF');
             $this->load->model('personalization/muser_fields_create', 'clsUFC');
             $this->load->model('admin/mpermissions', 'perms');
             $lClientID = $this->clsClients->lAddNewClient();
             $this->clsClientStat->clientStatus = array();
             $status = $this->clsClientStat->clientStatus[0] = new stdClass();
             $status->lClientID = $lClientID;
             $status->lStatusID = (int) trim($_POST['ddlStatus']);
             $status->bIncludeNotesInPacket = false;
             $status->dteStatus = $gdteNow;
             $status->strStatusTxt = 'Initial status';
             $this->clsClientStat->lInsertClientStatus();
             $this->session->set_flashdata('msg', 'The client record was added');
         } else {
             $clsClients->updateClientRec();
             $this->session->set_flashdata('msg', 'The client record was updated');
         }
         //----------------------------------------
         // update supported sponsor categories
         //----------------------------------------
         $this->clsSponProg->clearClientSponPrograms($lClientID);
         if (isset($_POST['chkSP'])) {
             foreach ($_POST['chkSP'] as $lSCID) {
                 $this->clsSponProg->setClientSponProgram($lClientID, (int) $lSCID);
             }
         }
         redirect('clients/client_record/view/' . $client->lKeyID);
     }
 }
 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);
     }
 }
 function userAddEdit($lTableID, $lForeignID, $lEditFieldID)
 {
     //-----------------------------------------------------------------------------
     //
     //-----------------------------------------------------------------------------
     global $gbDateFormatUS;
     $this->load->helper('dl_util/verify_id');
     if (!vid_bUserTableIDExists($this, $lTableID, $enumTabType)) {
         vid_bTestFail($this, false, 'user table ID', $lTableID);
     }
     verifyIDsViaType($this, $enumTabType, $lForeignID, false);
     if (!is_numeric($lEditFieldID)) {
         vid_bTestFail($this, false, 'user field ID', $lEditFieldID);
     }
     $displayData = array();
     $displayData['lTableID'] = $lTableID = (int) $lTableID;
     $displayData['lForeignID'] = $lForeignID = (int) $lForeignID;
     $displayData['lEditFieldID'] = $lEditFieldID = (int) $lEditFieldID;
     //-----------------------
     // load table info
     //-----------------------
     $bEditMode = $lEditFieldID > 0;
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('personalization/muser_fields_display', 'clsUFD');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     $params = array('enumStyle' => 'enpRptC');
     $this->load->library('generic_rpt', $params);
     $this->load->model('admin/madmin_aco');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/context');
     $this->clsUFD->lTableID = $lTableID;
     $this->clsUFD->lForeignID = $lForeignID;
     $this->clsUFD->loadTableViaTableID();
     $enumTType = $this->clsUFD->userTables[0]->enumTType;
     loadSupportModels($enumTType, $lForeignID);
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtxxxx');
     // dummy
     if ($bEditMode) {
         $this->clsUFD->loadSingleField($lEditFieldID);
         $enumFType = $this->clsUFD->fields[0]->enumFieldType;
         $strFName = 'var' . $lEditFieldID;
         if ($enumFType == CS_FT_DATE) {
             $this->form_validation->set_rules($strFName, 'Date Field', 'trim|callback_ufFieldVerifyDateValid');
         }
         if ($enumFType == CS_FT_INTEGER) {
             $this->form_validation->set_rules($strFName, 'Number Field', 'trim|required|callback_stripCommas|integer');
         }
         if ($enumFType == CS_FT_CURRENCY) {
             $this->form_validation->set_rules($strFName, 'Currency Field', 'trim|required|callback_stripCommas|numeric');
         }
     }
     if ($this->form_validation->run() == FALSE) {
         //------------------------------------------------------
         // set form validation based on field type being edited
         //------------------------------------------------------
         if ($bEditMode) {
             $this->load->helper('dl_util/web_layout');
         }
         $displayData['title'] = CS_PROGNAME . ' | Personalized Fields';
         $displayData['pageTitle'] = $this->clsUFD->strBreadcrumbsTableDisplay(0);
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['strTableDisplay'] = $this->clsUFD->strEditUserTableEntries($lEditFieldID);
         $displayData['strHTMLSummary'] = $this->clsUFD->strHTMLSummary;
         $displayData['mainTemplate'] = 'admin/user_table_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $this->clsUFD->loadSingleField($lEditFieldID);
         $enumType = $this->clsUFD->fields[0]->enumFieldType;
         $strFieldID = 'var' . $lEditFieldID;
         switch ($enumType) {
             case CS_FT_CHECKBOX:
                 $varUserVal = @$_POST[$strFieldID] == 'TRUE';
                 break;
             case CS_FT_DATE:
                 $varUserVal = trim($_POST[$strFieldID]);
                 if ($varUserVal == '') {
                     $varUserVal = ' null ';
                 } else {
                     MDY_ViaUserForm($varUserVal, $lMon, $lDay, $lYear, $gbDateFormatUS);
                     $varUserVal = ' "' . strMoDaYr2MySQLDate($lMon, $lDay, $lYear) . '" ';
                 }
                 break;
             case CS_FT_DATETIME:
                 break;
             case CS_FT_TEXTLONG:
             case CS_FT_TEXT255:
             case CS_FT_TEXT80:
             case CS_FT_TEXT20:
                 $varUserVal = trim($_POST[$strFieldID]);
                 break;
             case CS_FT_INTEGER:
                 $varUserVal = (int) $_POST[$strFieldID];
                 break;
             case CS_FT_CURRENCY:
                 $varUserVal = number_format($_POST[$strFieldID], 2, '.', '');
                 break;
             case CS_FT_DDL:
                 $varUserVal = (int) $_POST[$strFieldID];
                 break;
             default:
                 screamForHelp($enumType . ': invalid field type<br>error on line ' . __LINE__ . ',<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
                 break;
         }
         $this->clsUFD->updateUserField($varUserVal);
         redirect('admin/uf_user_edit/userAddEdit/' . $lTableID . '/' . $lForeignID . '/0');
     }
 }
Exemple #12
0
 function saveVolReg(&$rRec, $lNumTables, &$utables, $lNumSkills, &$jobSkills, $bCreateAcct)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gclsChapterACO, $glUserID, $gbDateFormatUS, $gdteNow, $gclsChapter;
     $this->load->model('people/mpeople', 'clsPeople');
     $this->load->model('vols/mvol', 'clsVol');
     $this->load->model('vol_reg/mvol_reg', 'volReg');
     $this->load->model('personalization/muser_fields_create', 'clsUFC');
     $this->load->model('admin/muser_accts', 'clsUser');
     $this->load->model('personalization/muser_fields_display', 'clsUFD');
     $this->load->model('vols/mvol_skills', 'clsVolSkills');
     $this->load->helper('dl_util/util_db');
     $this->load->helper('personalization/field_display');
     // make the default Delightful Labor user the person who created the vol registration form
     $glUserID = $rRec->lOriginID;
     $strChapter = $gclsChapter->strChapterName;
     $lRegFormID = $rRec->lKeyID;
     //----------------------------
     // add a people record
     //----------------------------
     $this->clsPeople->loadPeopleViaPIDs(-1, false, false);
     $pRec =& $this->clsPeople->people[0];
     if ($rRec->bShowFName) {
         $pRec->strFName = $pRec->strPreferredName = $pRec->strSalutation = trim($_POST['txtFName']);
     }
     if ($rRec->bShowLName) {
         $pRec->strLName = trim($_POST['txtLName']);
     }
     $pRec->strMName = '';
     $pRec->enumGender = 'Unknown';
     $pRec->lACO = $gclsChapterACO->lKeyID;
     $pRec->lHouseholdID = 0;
     // new volunteer will become head of household
     if ($rRec->bShowAddr) {
         $pRec->strAddr1 = trim($_POST['txtAddr1']);
         $pRec->strAddr2 = trim($_POST['txtAddr2']);
         $pRec->strCity = trim($_POST['txtCity']);
         $pRec->strState = trim($_POST['txtState']);
         $pRec->strCountry = trim($_POST['txtCountry']);
         $pRec->strZip = trim($_POST['txtZip']);
         $pRec->strNotes = 'Auto-created via volunteer registration';
     }
     if ($rRec->bShowPhone) {
         $pRec->strPhone = trim($_POST['txtPhone']);
     }
     if ($rRec->bShowCell) {
         $pRec->strCell = trim($_POST['txtCell']);
     }
     if ($rRec->bShowEmail) {
         $pRec->strEmail = trim($_POST['txtEmail']);
     }
     $pRec->dteMysqlDeath = null;
     if ($rRec->bShowBDay) {
         $strBDate = trim($_POST['txtBDate']);
         if ($strBDate == '') {
             $pRec->dteMysqlBirthDate = null;
         } else {
             MDY_ViaUserForm($strBDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
             $pRec->dteMysqlBirthDate = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         }
     }
     $lPeopleID = $this->clsPeople->lCreateNewPeopleRec();
     //----------------------------
     // add volunteer record
     //----------------------------
     $this->clsVol->loadVolRecsViaPeopleID(-1, true);
     $vRec =& $this->clsVol->volRecs[0];
     $vRec->lPeopleID = $lPeopleID;
     $vRec->lRegFormID = $rRec->lKeyID;
     $vRec->Notes = 'Self-registered via form "' . $rRec->strFormName . '" on ' . date('l, F jS, Y H:i:s', $gdteNow);
     $lVolID = $this->clsVol->lAddNewVolunteer();
     //----------------------------
     // job skills
     //----------------------------
     $this->clsVolSkills->lVolID = $lVolID;
     if ($lNumSkills > 0) {
         foreach ($jobSkills as $skill) {
             if (@$_POST[$skill->checkFN] == 'true') {
                 $this->clsVolSkills->setVolSkill($skill->lSkillID);
             }
         }
     }
     //----------------------------
     // personalized tables
     //----------------------------
     saveCustomPTables($lVolID, $lNumTables, $utables);
     //----------------------------
     // create volunteer account
     //----------------------------
     if ($bCreateAcct) {
         $this->clsUser->sqlWhere = ' AND us_lKeyID=-1 ';
         $this->clsUser->loadUserRecords();
         $uRec =& $this->clsUser->userRec[0];
         $uRec->us_strUserName = $uRec->us_strEmail = $pRec->strEmail . '';
         $uRec->us_strFirstName = $pRec->strFName . '';
         $uRec->us_strLastName = $pRec->strLName . '';
         $uRec->us_strUserPWord = trim($_POST['txtPWord1']);
         $uRec->us_strTitle = 'Volunteer';
         $uRec->us_strPhone = $pRec->strPhone . '';
         $uRec->us_strCell = $pRec->strCell . '';
         $uRec->us_strAddr1 = $pRec->strAddr1 . '';
         $uRec->us_strAddr2 = $pRec->strAddr2 . '';
         $uRec->us_strCity = $pRec->strCity . '';
         $uRec->us_strState = $pRec->strState . '';
         $uRec->us_strCountry = $pRec->strCountry . '';
         $uRec->us_strZip = $pRec->strZip . '';
         $uRec->lPeopleID = $lPeopleID;
         if ($gbDateFormatUS) {
             $uRec->us_enumDateFormat = 'm/d/Y';
             $uRec->us_enumMeasurePref = 'English';
         } else {
             $uRec->us_enumDateFormat = 'd/m/Y';
             $uRec->us_enumMeasurePref = 'metric';
         }
         $uRec->us_bAdmin = false;
         $uRec->bVolAccount = true;
         $uRec->bVolEditContact = $rRec->bPermEditContact;
         $uRec->bVolPassReset = $rRec->bPermPassReset;
         $uRec->bVolViewGiftHistory = $rRec->bPermViewGiftHistory;
         $uRec->bVolEditJobSkills = $rRec->bPermEditJobSkills;
         $uRec->bVolViewHrsHistory = $rRec->bPermViewHrsHistory;
         $uRec->bVolAddVolHours = $rRec->bPermAddVolHours;
         $uRec->bVolShiftSignup = $rRec->bVolShiftSignup;
         $lUserID = $this->clsUser->addUserAccount();
     }
     //----------------------------
     // add volunteer to group
     //----------------------------
     if (!is_null($rRec->lVolGroupID)) {
         $this->load->model('groups/mgroups', 'groups');
         $this->load->helper('groups/groups');
         $this->groups->lForeignID = $lVolID;
         $this->groups->lGroupID = $rRec->lVolGroupID;
         $this->groups->addGroupMembership();
     }
     // load vol registration form
     $this->volReg->loadVolRegFormsViaRFID($lRegFormID);
     $regForm =& $this->volReg->regRecs[0];
     $this->volReg->loadRegistrationViaRegFormIDVolID($lVolID, $lRegFormID, $lNumRegs, $regTable);
     $regRec =& $regTable[$lVolID];
     $strRegHTML = $this->volReg->strVolReg2HTML($regRec);
     //-----------------------------
     // email the vol. coordinator
     //-----------------------------
     $to = $regForm->strContactEmail;
     $subject = 'New volunteer registration: ' . $regForm->strFormName;
     $headers = "From: " . $regForm->strContactEmail . "\r\n";
     $headers .= "Reply-To: " . $regForm->strContactEmail . "\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
     $message = '<html><body>' . 'You have a new registration for <b>' . htmlspecialchars($regForm->strFormName) . '</b><br><br>' . 'Here are the details:<br>' . $strRegHTML . '<br>' . 'This message was automatically generated via your installation of Delightful Labor.';
     $message .= "</body></html>";
     @mail($to, $subject, $message, $headers);
     //-----------------------------
     // email the volunteer
     //-----------------------------
     if ($regRec->strEmail . '' != '') {
         $to = $regRec->strEmail;
         $subject = 'Thank you for registering for ' . $regForm->strFormName;
         $headers = "From: " . $regForm->strContactEmail . "\r\n";
         $headers .= "Reply-To: " . $regForm->strContactEmail . "\r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
         $message = '<html><body>' . 'You have been registered for <b>' . htmlspecialchars($regForm->strFormName) . '</b><br><br>' . 'Here are the details:<br>' . $strRegHTML . 'Please contact ' . htmlspecialchars($rRec->strContactEmail) . ' with any questions or updates to your information.';
         $message .= "</body></html>";
         @mail($to, $subject, $message, $headers);
     }
 }
 public function addEdit($lCProgID = '', $lCloneSourceID = 0)
 {
     //-------------------------------------------------------------------------
     //
     //-------------------------------------------------------------------------
     global $gstrFormatDatePicker, $gbDateFormatUS;
     if (!bTestForURLHack('adminOnly')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     if ($lCProgID . '' != '0') {
         verifyID($this, $lCProgID, 'client program ID');
     }
     $displayData = array();
     $displayData['js'] = '';
     $displayData['lCProgID'] = $lCProgID = (int) $lCProgID;
     $displayData['bNew'] = $bNew = $lCProgID <= 0;
     $displayData['lCloneSourceID'] = $lCloneSourceID = (int) $lCloneSourceID;
     $displayData['bClone'] = $bClone = $lCloneSourceID > 0;
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->model('client_features/mcprograms', 'cprograms');
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('personalization/muser_schema', 'cUFSchema');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->helper('dl_util/time_date');
     // for date verification
     $this->load->helper('dl_util/util_db');
     $this->load->helper('personalization/validate_custom_verification');
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->helper('dl_util/web_layout');
     // load the client program
     if ($bClone) {
         $this->cprograms->loadClientProgramsViaCPID($lCloneSourceID);
         $displayData['strSourceProgName'] = $this->cprograms->cprogs[0]->strProgramName;
         $strBlockLabel = 'Clone Client Program';
     } else {
         $this->cprograms->loadClientProgramsViaCPID($lCProgID);
         $strBlockLabel = ($bNew ? 'Add New' : 'Update') . ' Client Program';
     }
     $displayData['strBlockLabel'] = $strBlockLabel;
     $cprog =& $this->cprograms->cprogs[0];
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtProgramName', 'Program Name', 'trim|required|callback_verifyUniqueClientProg[' . $lCProgID . ']');
     $this->form_validation->set_rules('txtEnrollLabel', 'Enrollment Label', 'trim|required');
     $this->form_validation->set_rules('txtAttendLabel', 'Attendance Label', 'trim|required');
     $this->form_validation->set_rules('txtDescription', 'Description', 'trim');
     $this->form_validation->set_rules('chkHidden', 'Hidden', 'trim');
     $this->form_validation->set_rules('chkETableReadOnly', 'ETable Read Only', 'trim');
     $this->form_validation->set_rules('chkATableReadOnly', 'ATable Read Only', 'trim');
     $this->form_validation->set_rules('txtStartDate', 'Starting Date', 'trim|required' . '|callback_verifyDateValid');
     $this->form_validation->set_rules('txtEndDate', 'Ending Date', 'trim|required' . '|callback_verifyDateValid|callback_verifyCBH');
     $this->form_validation->set_rules('chkMentorMentee', 'Mentor/Mentee', 'trim');
     $this->form_validation->set_rules('txtE_VerificationModule', 'Enrollment Validation File', 'callback_verifyEVerMod');
     $this->form_validation->set_rules('txtE_VModEntryPoint', 'Enrollment Validation Entry Point', 'callback_verifyEVModEntry');
     $this->form_validation->set_rules('txtA_VerificationModule', 'Attendance Validation File', 'callback_verifyAVerMod');
     $this->form_validation->set_rules('txtA_VModEntryPoint', 'Attendance Validation Entry Point', 'callback_verifyAVModEntry');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             if ($bClone) {
                 $cprog->strProgramName .= ' (clone)';
             }
             $displayData['formData']->txtProgramName = htmlspecialchars($cprog->strProgramName . '');
             $displayData['formData']->txtEnrollLabel = htmlspecialchars($cprog->strEnrollmentLabel . '');
             $displayData['formData']->txtAttendLabel = htmlspecialchars($cprog->strAttendanceLabel . '');
             $displayData['formData']->txtDescription = htmlspecialchars($cprog->strDescription . '');
             $displayData['formData']->bHidden = $cprog->bHidden;
             $displayData['formData']->bETableReadOnly = $cprog->bETableReadOnly;
             $displayData['formData']->bATableReadOnly = $cprog->bATableReadOnly;
             $displayData['formData']->txtE_VerificationModule = htmlspecialchars($cprog->strE_VerificationModule . '');
             $displayData['formData']->txtE_VModEntryPoint = htmlspecialchars($cprog->strE_VModEntryPoint . '');
             $displayData['formData']->txtA_VerificationModule = htmlspecialchars($cprog->strA_VerificationModule . '');
             $displayData['formData']->txtA_VModEntryPoint = htmlspecialchars($cprog->strA_VModEntryPoint . '');
             // mentor support
             $displayData['formData']->bMentorMentee = $cprog->bMentorMentee;
             if (is_null($cprog->dteMysqlStart)) {
                 $displayData['formData']->txtStartDate = '';
             } else {
                 $displayData['formData']->txtStartDate = strNumericDateViaMysqlDate($cprog->dteMysqlStart, $gbDateFormatUS);
             }
             if (is_null($cprog->dteMysqlEnd)) {
                 $displayData['formData']->txtEndDate = '';
             } else {
                 $displayData['formData']->txtEndDate = strNumericDateViaMysqlDate($cprog->dteMysqlEnd, $gbDateFormatUS);
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtProgramName = set_value('txtProgramName');
             $displayData['formData']->txtDescription = set_value('txtDescription');
             $displayData['formData']->txtEnrollLabel = set_value('txtEnrollLabel');
             $displayData['formData']->txtAttendLabel = set_value('txtAttendLabel');
             $displayData['formData']->txtStartDate = set_value('txtStartDate');
             $displayData['formData']->txtEndDate = set_value('txtEndDate');
             $displayData['formData']->bHidden = set_value('chkHidden') == 'true';
             $displayData['formData']->bETableReadOnly = set_value('chkETableReadOnly') == 'true';
             $displayData['formData']->bATableReadOnly = set_value('chkATableReadOnly') == 'true';
             $displayData['formData']->txtE_VerificationModule = set_value('txtE_VerificationModule');
             $displayData['formData']->txtE_VModEntryPoint = set_value('txtE_VModEntryPoint');
             $displayData['formData']->txtA_VerificationModule = set_value('txtA_VerificationModule');
             $displayData['formData']->txtA_VModEntryPoint = set_value('txtA_VModEntryPoint');
             $displayData['formData']->bMentorMentee = set_value('chkMentorMentee') == 'true';
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprograms/overview', 'Client Programs', 'class="breadcrumb"') . ' | ' . $strBlockLabel;
         $displayData['title'] = CS_PROGNAME . ' | Client Program';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'cprograms/cprog_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $cprog->strProgramName = trim($_POST['txtProgramName']);
         $cprog->strEnrollmentLabel = trim($_POST['txtEnrollLabel']);
         $cprog->strAttendanceLabel = trim($_POST['txtAttendLabel']);
         $cprog->strDescription = trim($_POST['txtDescription']);
         $cprog->bHidden = trim(@$_POST['chkHidden']) == 'true';
         $cprog->bETableReadOnly = trim(@$_POST['chkETableReadOnly']) == 'true';
         $cprog->bATableReadOnly = trim(@$_POST['chkATableReadOnly']) == 'true';
         $cprog->bMentorMentee = trim(@$_POST['chkMentorMentee']) == 'true';
         $cprog->strE_VerificationModule = trim($_POST['txtE_VerificationModule']);
         $cprog->strE_VModEntryPoint = trim($_POST['txtE_VModEntryPoint']);
         $cprog->strA_VerificationModule = trim($_POST['txtA_VerificationModule']);
         $cprog->strA_VModEntryPoint = trim($_POST['txtA_VModEntryPoint']);
         $strDate = trim($_POST['txtStartDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $cprog->dteMysqlStart = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $strDate = trim($_POST['txtEndDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $cprog->dteMysqlEnd = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $this->load->model('personalization/muser_fields', 'clsUF');
             $this->load->model('personalization/muser_fields_create', 'clsUFC');
             $lCProgID = $this->cprograms->addNewCProgram();
             if ($bClone) {
                 $this->load->model('personalization/muser_fields', 'clsUF');
                 $this->load->model('personalization/muser_fields_create', 'clsUFC');
                 $this->load->model('personalization/muser_clone', 'cUFClone');
                 $this->cUFClone->cloneCProgram($lCloneSourceID, $lCProgID);
                 $this->session->set_flashdata('msg', 'Client program cloned');
             } else {
                 $this->session->set_flashdata('msg', 'New client program added');
             }
         } else {
             $this->cprograms->updateCProgram($lCProgID);
             $this->session->set_flashdata('msg', 'Client program record updated');
         }
         redirect('cprograms/cprog_record/view/' . $lCProgID);
     }
 }
function arecIDXsViaERecDate($erec, $lMonth, $lDay, $lYear, &$lNumARecs, &$arecIDX)
{
    $lNumARecs = 0;
    $arecIDX = array();
    if ($erec->lNumARecs == 0) {
        return;
    }
    $mdteTestDate = strMoDaYr2MySQLDate($lMonth, $lDay, $lYear);
    $idx = 0;
    foreach ($erec->arecs as $arec) {
        if ($arec->dteMysqlAttendance == $mdteTestDate) {
            $arecIDX[$lNumARecs] = $idx;
            ++$lNumARecs;
        }
        ++$idx;
    }
}
 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 addEditGeneric($lID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gbDateFormatUS;
     if (!bTestForURLHack('test')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     if ($lID . '' != '0') {
         verifyID($this, $ID, 'test ID');
     }
     $displayData = array();
     $displayData['id'] = $lID = (int) $lID;
     $displayData['js'] = '';
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->helper('dl_util/time_date');
     // for date verification
     $this->load->library('generic_form');
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->helper('dl_util/web_layout');
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtField1', 'My Field', 'trim|required');
     $this->form_validation->set_rules('txtDate', 'My date', 'trim|required' . '|callback_verifyDateValid' . '|callback_verifyDatePast');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $displayData['formData']->txtField1 = htmlspecialchars($myModel->strField1);
             $displayData['formData']->txtDate = $myModel->strDate;
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtField1 = set_value('txtField1');
             $displayData['formData']->txtDate = set_value('txtDate');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/home', 'Home', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New' : 'Edit') . '  Record';
         $displayData['title'] = CS_PROGNAME . ' | My Record';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'my_record/my_record_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strField1 = trim($_POST['txtField1']);
         $strDate = trim($_POST['txtDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $dteMyDate = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         if ($bNew) {
             $lID = $myModel->addNewRecord($strField1, $dteMyDate);
             $this->session->set_flashdata('msg', 'Record added');
         } else {
             $myModel->updateRecord($lID, $strField1, $dteMyDate);
             $this->session->set_flashdata('msg', 'Record updated');
         }
         redirect('myRecords/myRecord/view/' . $lID);
     }
 }
 function addEditItem($lICatID, $lIItemID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gstrFormatDatePicker, $gclsChapterACO, $gbDateFormatUS;
     if (!bTestForURLHack('inventoryMgr')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lICatID, 'inventory cat ID');
     if ($lIItemID != '0') {
         verifyID($this, $lIItemID, 'inventory item ID');
     }
     $displayData = array();
     $displayData['js'] = '';
     $displayData['lICatID'] = $lICatID = (int) $lICatID;
     $displayData['lIItemID'] = $lIItemID = (int) $lIItemID;
     $displayData['bNew'] = $bNew = $lIItemID <= 0;
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->model('staff/inventory/minventory', 'cinv');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('staff/link_inventory');
     $this->load->helper('dl_util/time_date');
     // load the inventory category
     $this->cinv->loadSingleInventoryCategories($lICatID, $displayData['cat']);
     // load the inventory category breadcrumbs
     $displayData['strBreadCrumb'] = '';
     $this->cinv->icatBreadCrumbs($displayData['strBreadCrumb'], $lICatID);
     // load the inventory item
     $this->cinv->loadSingleInventoryItem($lIItemID, $lNumItems, $items);
     $item =& $items[0];
     if (is_null($item->lACOID)) {
         $item->lACOID = $gclsChapterACO->lKeyID;
     }
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtItem', 'Item', 'trim|required');
     $this->form_validation->set_rules('txtRParty', 'Responsible Party', 'trim|required');
     $this->form_validation->set_rules('txtNotes', 'Description', 'trim');
     $this->form_validation->set_rules('txtSNa', 'Serial # (a)', 'trim');
     $this->form_validation->set_rules('txtSNb', 'Serial # (b)', 'trim');
     $this->form_validation->set_rules('txtLocation', 'Location', 'trim|required');
     $this->form_validation->set_rules('txtDateAcquired', 'Date Acquired', 'trim|required|callback_itemVerifyDateAcquiredValid');
     $this->form_validation->set_rules('txtEstValue', 'Estimated Value', 'trim|required|callback_stripCommas|numeric');
     $this->form_validation->set_rules('rdoACO', 'Accounting Country', 'trim|required');
     $this->form_validation->set_rules('chkAvailLoan', 'Available for Loan');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $displayData['formData']->txtItem = htmlspecialchars($item->strItemName);
             $displayData['formData']->txtNotes = htmlspecialchars($item->strDescription);
             $displayData['formData']->txtSNa = htmlspecialchars($item->strItemSNa);
             $displayData['formData']->txtSNb = htmlspecialchars($item->strItemSNb);
             $displayData['formData']->txtLocation = htmlspecialchars($item->strLocation);
             $displayData['formData']->txtRParty = htmlspecialchars($item->strRParty);
             $displayData['formData']->bAvailForLoan = $item->bAvailForLoan;
             if (is_null($item->dteObtained)) {
                 $displayData['formData']->txtDateAcquired = '';
             } else {
                 $displayData['formData']->txtDateAcquired = date($gstrFormatDatePicker, $item->dteObtained);
             }
             $displayData['formData']->txtEstValue = number_format($item->curEstValue, 2);
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios($item->lACOID, 'rdoACO');
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtItem = set_value('txtItem');
             $displayData['formData']->txtNotes = set_value('txtNotes');
             $displayData['formData']->txtSNa = set_value('txtSNa');
             $displayData['formData']->txtSNb = set_value('txtSNb');
             $displayData['formData']->txtLocation = set_value('txtLocation');
             $displayData['formData']->txtDateAcquired = set_value('txtDateAcquired');
             $displayData['formData']->txtRParty = set_value('txtRParty');
             $displayData['formData']->txtEstValue = set_value('txtEstValue');
             $displayData['formData']->strACORadio = $this->clsACO->strACO_Radios($_POST['rdoACO'], 'rdoACO');
             $displayData['formData']->bAvailForLoan = set_value('chkAvailLoan') == 'TRUE';
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/more', 'More', 'class="breadcrumb"') . ' | ' . anchor('staff/inventory/icat/viewICats', 'Inventory Categories', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New ' : 'Edit ') . 'Item';
         $displayData['title'] = CS_PROGNAME . ' | Inventory Management';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'staff/inventory/iitems_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $item->strItemName = trim($_POST['txtItem']);
         $item->strRParty = trim($_POST['txtRParty']);
         $item->lCategoryID = $lICatID;
         $item->strDescription = trim($_POST['txtNotes']);
         $item->strLocation = trim($_POST['txtLocation']);
         $item->strItemSNa = trim($_POST['txtSNa']);
         $item->strItemSNb = trim($_POST['txtSNb']);
         $item->lACOID = (int) trim($_POST['rdoACO']);
         $item->curEstValue = (double) trim($_POST['txtEstValue']);
         $item->bAvailForLoan = @$_POST['chkAvailLoan'] == 'TRUE';
         $strDate = trim($_POST['txtDateAcquired']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $item->mdteObtained = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         if ($bNew) {
             $lIItemID = $this->cinv->lAddNewIItem($item);
             $this->cinv->lAddItemHistoryRec($lIItemID, null, 'created');
             $this->session->set_flashdata('msg', 'Inventory item added');
         } else {
             $this->cinv->updateIItem($lIItemID, $item);
             $this->cinv->lAddItemHistoryRec($lIItemID, null, 'updated');
             $this->session->set_flashdata('msg', 'Inventory item updated');
         }
         redirect('staff/inventory/inventory_items/iitemRec/' . $lIItemID);
     }
 }
 function lSaveMultiRecViaPost($bNew, $lFID, &$lRecID, &$utable)
 {
     //---------------------------------------------------------------------
     // note: with the new personalized table gui (1/2014), single record
     // personalized table records go thru here also.
     //---------------------------------------------------------------------
     global $gbDateFormatUS;
     $bMultiEntry = $utable->bMultiEntry;
     // special case for client program tables: add additional default fields
     if ($utable->bCProg) {
         $strFP = $utable->strFieldPrefix;
         if ($utable->bEnrollment) {
             $strEStart = trim($_POST['txtEStart']);
             MDY_ViaUserForm($strEStart, $lMon, $lDay, $lYear, $gbDateFormatUS);
             $strEStartMysql = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
             $strEEnd = trim($_POST['txtEEnd']);
             if ($strEEnd == '') {
                 $strEEndMysql = 'NULL';
             } else {
                 MDY_ViaUserForm($strEEnd, $lMon, $lDay, $lYear, $gbDateFormatUS);
                 $strEEndMysql = strPrepStr(strMoDaYr2MySQLDate($lMon, $lDay, $lYear));
             }
             $strCProgFields = $strFP . '_dteStart = ' . strPrepStr($strEStartMysql) . ", \n" . $strFP . '_dteEnd   = ' . $strEEndMysql . ", \n" . $strFP . '_bCurrentlyEnrolled = ' . (@$_POST['chkEnrolled'] == 'true' ? '1' : '0') . "\n";
         } else {
             $strAttend = trim($_POST['txtADate']);
             MDY_ViaUserForm($strAttend, $lMon, $lDay, $lYear, $gbDateFormatUS);
             $strADateMysql = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
             if (isset($_POST['ddlDuration'])) {
                 $strDuration = (double) trim($_POST['ddlDuration']);
             } else {
                 $strDuration = '0';
             }
             $strCProgFields = $strFP . '_dteAttendance = ' . strPrepStr($strADateMysql) . ", \n" . $strFP . '_strCaseNotes  = ' . strPrepStr(trim($_POST['txtCaseNotes'])) . ", \n" . $strFP . '_dDuration     = ' . $strDuration . " \n";
             if ($bNew) {
                 $strCProgFields .= ', ' . $strFP . '_lEnrollID     = ' . $utable->lEnrollRecID . "\n";
             }
         }
     } else {
         $strCProgFields = '';
     }
     $this->lForeignID = $lFID;
     $this->lTableID = $lTableID = $utable->lKeyID;
     $this->userTables[0] =& $utable;
     $idx = 0;
     if (isset($utable->ufields)) {
         // special case for CProg tables w/only base fields
         foreach ($utable->ufields as $ufield) {
             $this->fields[$idx] = $vfield =& $ufield;
             $enumType = $ufield->enumFieldType;
             $strFN = $ufield->strFieldNameInternal;
             $vfield->varUserVal = null;
             switch ($enumType) {
                 case CS_FT_CHECKBOX:
                     $vfield->varUserVal = @$_POST[$strFN] == 'true';
                     break;
                 case CS_FT_DATE:
                     $vfield->varUserVal = trim($_POST[$strFN]);
                     if ($vfield->varUserVal == '') {
                         $vfield->varUserVal = ' null ';
                     } else {
                         MDY_ViaUserForm($vfield->varUserVal, $lMon, $lDay, $lYear, $gbDateFormatUS);
                         $vfield->varUserVal = ' "' . strMoDaYr2MySQLDate($lMon, $lDay, $lYear) . '" ';
                     }
                     break;
                 case CS_FT_TEXTLONG:
                 case CS_FT_TEXT255:
                 case CS_FT_TEXT80:
                 case CS_FT_TEXT20:
                     $vfield->varUserVal = trim($_POST[$strFN]);
                     break;
                 case CS_FT_CLIENTID:
                 case CS_FT_INTEGER:
                     $vfield->varUserVal = trim($_POST[$strFN]);
                     $this->stripCommas(trim($vfield->varUserVal));
                     $vfield->varUserVal = (int) $vfield->varUserVal;
                     break;
                 case CS_FT_HEADING:
                     break;
                 case CS_FT_CURRENCY:
                     $vfield->varUserVal = trim($_POST[$strFN]);
                     $this->stripCommas($vfield->varUserVal);
                     $vfield->varUserVal = number_format((double) $vfield->varUserVal, 2, '.', '');
                     break;
                 case CS_FT_DDL:
                     $vfield->varUserVal = (int) $_POST[$strFN];
                     if ($vfield->varUserVal <= 0) {
                         $vfield->varUserVal = ' null ';
                     }
                     break;
                 case CS_FT_DDLMULTI:
                 case CS_FT_LOG:
                     break;
                 default:
                     screamForHelp($enumType . ': invalid field type<br>error on line ' . __LINE__ . ',<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
                     break;
             }
             ++$idx;
         }
     }
     if ($bNew) {
         $lRecID = $this->insertMRRecord($lFID, $strCProgFields, $bMultiEntry);
     } else {
         $this->updateMRRecord($lRecID, $strCProgFields, $bMultiEntry);
     }
     return $lRecID;
 }
 function addEditVol($lVolID = '0')
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gbVolMgr, $gbDateFormatUS, $glChapterID, $glUserID;
     global $gbVolLogin;
     if ($gbVolLogin) {
         $this->load->model('admin/mpermissions', 'perms');
         $this->load->model('admin/muser_accts', 'cusers');
         if ($lVolID != $this->cusers->lVolIDViaUserID($glUserID)) {
             bTestForURLHack('forceFail');
             return;
         }
     } elseif (!bTestForURLHack('volMgr')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     if ($lVolID != '0') {
         verifyID($glChapterID, $lVolID, 'volunteer ID');
     }
     $displayData = array();
     $displayData['js'] = '';
     $displayData['formData'] = new stdClass();
     $displayData['lVolID'] = $lVolID = (int) $lVolID;
     $displayData['bNew'] = $bNew = $lVolID <= 0;
     //------------------------------------------------
     // models, libraries and utilities
     //------------------------------------------------
     $this->load->model('vols/mvol', 'cVol');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->model('admin/muser_accts', 'cusers');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/web_layout');
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     // load volunteer record
     $this->cVol->loadVolRecsViaVolID($lVolID, true);
     $vRec =& $this->cVol->volRecs[0];
     // account ID
     if ($bNew) {
         $lAcctID = -1;
     } else {
         $lAcctID = $this->cusers->lUserIDViaUserName($vRec->strEmail);
     }
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtFName', 'First Name', 'trim|required');
     $this->form_validation->set_rules('txtTitle', '', 'trim');
     $this->form_validation->set_rules('txtMName', '', 'trim');
     $this->form_validation->set_rules('txtLName', 'Last Name', 'trim|required');
     $this->form_validation->set_rules('txtPName', '', 'trim');
     $this->form_validation->set_rules('txtSal', '', 'trim');
     $this->form_validation->set_rules('txtAddr1', '', 'trim');
     $this->form_validation->set_rules('txtAddr2', '', 'trim');
     $this->form_validation->set_rules('txtCity', '', 'trim');
     $this->form_validation->set_rules('txtState', '', 'trim');
     $this->form_validation->set_rules('txtZip', '', 'trim');
     $this->form_validation->set_rules('txtCountry', '', 'trim');
     $this->form_validation->set_rules('txtNotes', '', 'trim');
     $this->form_validation->set_rules('txtPhone', '', 'trim');
     $this->form_validation->set_rules('txtCell', '', 'trim');
     //      $this->form_validation->set_rules('rdoGender',      '',  'trim');
     $this->form_validation->set_rules('txtBDate', '', 'trim|callback_peopleRecVerifyBDateValid' . '|callback_peopleRecVerifyBDatePast');
     $this->form_validation->set_rules('txtEmail', 'Email', 'trim|required|valid_email|callback_verifyUniqueAcct[' . $lAcctID . ']');
     $this->form_validation->set_rules('rdoACO', '', 'trim');
     $this->form_validation->set_rules('ddlAttrib', 'Attributed to');
     if ($bNew) {
         $this->form_validation->set_rules('txtPWord1', 'Password', 'trim|required');
         $this->form_validation->set_rules('txtPWord2', 'Password (again)', 'trim|required|callback_verifyPWordMatch');
     }
     if ($this->form_validation->run() == FALSE) {
         $displayData['js'] = '';
         $this->load->library('generic_form');
         $this->load->model('util/mlist_generic', 'clsList');
         $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
         if (validation_errors() == '') {
             if (!isset($vRec->mdteBirthDate)) {
                 $vRec->mdteBirthDate = null;
             }
             if (is_null($vRec->mdteBirthDate)) {
                 $displayData['formData']->txtBDate = '';
             } else {
                 $displayData['formData']->txtBDate = strNumericDateViaMysqlDate($vRec->mdteBirthDate, $gbDateFormatUS);
             }
             if ($bNew) {
                 $displayData['formData']->strBDay = $displayData['formData']->txtTitle = $displayData['formData']->txtFName = $displayData['formData']->txtMName = $displayData['formData']->txtLName = $displayData['formData']->txtPName = $displayData['formData']->txtSal = $displayData['formData']->txtNotes = $displayData['formData']->txtEmail = $displayData['formData']->txtCell = '';
                 //               $displayData['formData']->dteMysqlBirthDate = '';
                 $displayData['formData']->txtAddr1 = $displayData['formData']->txtAddr2 = $displayData['formData']->txtCity = $displayData['formData']->txtState = $displayData['formData']->txtZip = $displayData['formData']->txtCountry = $displayData['formData']->txtPhone = '';
                 $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL($glChapterID, 'ddlAttrib', true, -1);
                 $displayData['formData']->txtPWord1 = $displayData['formData']->txtPWord2 = $displayData['formData']->txtAcct = '';
             } else {
                 $displayData['formData']->strBDay = htmlspecialchars($vRec->mdteBirthDate);
                 $displayData['formData']->txtTitle = htmlspecialchars($vRec->strTitle);
                 $displayData['formData']->txtFName = htmlspecialchars($vRec->strFName);
                 $displayData['formData']->txtMName = htmlspecialchars($vRec->strMName);
                 $displayData['formData']->txtLName = htmlspecialchars($vRec->strLName);
                 $displayData['formData']->txtPName = htmlspecialchars($vRec->strPreferred);
                 $displayData['formData']->txtNotes = htmlspecialchars($vRec->strNotes);
                 $displayData['formData']->txtEmail = htmlspecialchars($vRec->strEmail);
                 $displayData['formData']->txtCell = htmlspecialchars($vRec->strCell);
                 $displayData['formData']->txtPhone = htmlspecialchars($vRec->strPhone);
                 $displayData['formData']->txtAddr1 = htmlspecialchars($vRec->strAddr1);
                 $displayData['formData']->txtAddr2 = htmlspecialchars($vRec->strAddr2);
                 $displayData['formData']->txtCity = htmlspecialchars($vRec->strCity);
                 $displayData['formData']->txtState = htmlspecialchars($vRec->strState);
                 $displayData['formData']->txtZip = htmlspecialchars($vRec->strZip);
                 $displayData['formData']->txtCountry = htmlspecialchars($vRec->strCountry);
                 $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL($glChapterID, 'ddlAttrib', true, $vRec->lAttributedTo);
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtTitle = set_value('txtTitle');
             $displayData['formData']->txtFName = set_value('txtFName');
             $displayData['formData']->txtMName = set_value('txtMName');
             $displayData['formData']->txtLName = set_value('txtLName');
             $displayData['formData']->txtPName = set_value('txtPName');
             $displayData['formData']->txtSal = set_value('txtSal');
             $displayData['formData']->txtNotes = set_value('txtNotes');
             $displayData['formData']->txtAddr1 = set_value('txtAddr1');
             $displayData['formData']->txtAddr2 = set_value('txtAddr2');
             $displayData['formData']->txtCity = set_value('txtCity');
             $displayData['formData']->txtState = set_value('txtState');
             $displayData['formData']->txtZip = set_value('txtZip');
             $displayData['formData']->txtCountry = set_value('txtCountry');
             $displayData['formData']->txtEmail = set_value('txtEmail');
             $displayData['formData']->txtPhone = set_value('txtPhone');
             $displayData['formData']->txtCell = set_value('txtCell');
             //            $displayData['formData']->enumGender        = set_value('rdoGender');
             $displayData['formData']->txtBDate = set_value('txtBDate');
             $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL($glChapterID, 'ddlAttrib', true, set_value('ddlAttrib'));
             $displayData['formData']->txtPWord1 = set_value('txtPWord1');
             $displayData['formData']->txtPWord2 = set_value('txtPWord2');
             $displayData['formData']->txtAcct = set_value('txtAcct');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = ($bNew ? 'Add New' : 'Update') . ' Volunteer Record';
         $displayData['title'] = CS_PROGNAME . ' | Volunteers';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'hospice/vols/vol_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $this->load->model('admin/mpermissions', 'perms');
         $this->load->model('admin/muser_accts', 'cusers');
         $this->load->helper('dl_util/util_db');
         $vRec->strTitle = trim($_POST['txtTitle']);
         $vRec->strFName = trim($_POST['txtFName']);
         $vRec->strMName = trim($_POST['txtMName']);
         $vRec->strLName = trim($_POST['txtLName']);
         $vRec->strPreferredName = trim($_POST['txtPName']);
         $vRec->strNotes = trim($_POST['txtNotes']);
         if ($vRec->strPreferredName == '') {
             $vRec->strPreferredName = $vRec->strFName;
         }
         $vRec->strAddr1 = trim($_POST['txtAddr1']);
         $vRec->strAddr2 = trim($_POST['txtAddr2']);
         $vRec->strCity = trim($_POST['txtCity']);
         $vRec->strState = trim($_POST['txtState']);
         $vRec->strZip = trim($_POST['txtZip']);
         $vRec->strCountry = trim($_POST['txtCountry']);
         $vRec->strEmail = trim($_POST['txtEmail']);
         $vRec->strPhone = trim($_POST['txtPhone']);
         $vRec->strCell = trim($_POST['txtCell']);
         //         $vRec->enumGender      = trim($_POST['rdoGender']);
         $lAttrib = (int) $_REQUEST['ddlAttrib'];
         if ($lAttrib <= 0) {
             $vRec->lAttributedTo = null;
         } else {
             $vRec->lAttributedTo = $lAttrib;
         }
         $strBDate = trim($_POST['txtBDate']);
         if ($strBDate == '') {
             $vRec->dteMysqlBirthDate = null;
         } else {
             MDY_ViaUserForm($strBDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
             $vRec->dteMysqlBirthDate = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         }
         if ($bNew) {
             $lVolID = $this->cVol->lAddNewVolunteer();
             $this->addVolAcct($lVolID, $vRec);
         } else {
             $this->cVol->updateVolunteerRec($lVolID);
             $this->cusers->updateUserNameViaID($lAcctID, $vRec->strEmail);
         }
         $this->session->set_flashdata('msg', 'The volunteer record was ' . ($bNew ? 'added' : 'updated'));
         redirect('hospice/vols/vol_record/viewRec/' . $lVolID);
     }
 }
 public function cloneAttOpts($lCProgID, $lARecID)
 {
     //-------------------------------------------------------------------------
     //
     //-------------------------------------------------------------------------
     global $genumDateFormat, $gbDateFormatUS;
     $displayData = array();
     $displayData['js'] = '';
     $displayData['lCProgID'] = $lCProgID = (int) $lCProgID;
     $displayData['lARecID'] = $lARecID = (int) $lARecID;
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('personalization/muser_schema', 'cUFSchema');
     $this->load->model('client_features/mcprograms', 'cprograms');
     $this->load->helper('dl_util/time_date');
     // for date verification
     $this->load->helper('dl_util/web_layout');
     $params = array('enumStyle' => 'terse', 'clsRpt');
     $this->load->library('generic_rpt', $params);
     //------------------------------------
     // load the check/uncheck support
     //------------------------------------
     $this->load->helper('js/set_check_boxes');
     $displayData['js'] = insertCheckSet();
     $this->load->helper('js/verify_check_set');
     $displayData['js'] .= verifyCheckSet();
     // load client program
     $this->cprograms->loadClientProgramsViaCPID($lCProgID);
     $displayData['cprog'] = $cprog =& $this->cprograms->cprogs[0];
     $strProg = $cprog->strProgramName;
     $lATableID = $cprog->lAttendanceTableID;
     $this->cprograms->loadBaseARecViaARecID($cprog, $lARecID, $lNumARecs, $arecs);
     $displayData['arec'] = $arec =& $arecs[0];
     $lClientID = $arec->lClientID;
     $lERecID = $arec->lEnrollID;
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtADate', 'Attendance Date', 'trim|required' . '|callback_verifyDateValid');
     $this->form_validation->set_rules('chkSkipDups', 'Skip Duplicates', 'trim');
     // clients enrolled in this program - potential destinations of the clone
     $this->cprograms->clientsEnrolledViaProgID($lCProgID, $cprog, true, $lNumClients, $displayData['clients'], true);
     if ($lNumClients > 0) {
         foreach ($displayData['clients'] as $client) {
             $client->bSelected = false;
         }
     }
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $displayData['bSkipDups'] = true;
             $displayData['formData']->txtADate = '';
         } else {
             setOnFormError($displayData);
             $displayData['bSkipDups'] = set_value('chkSkipDups') == 'true';
             $displayData['formData']->txtADate = set_value('txtADate');
             if (isset($_POST['chkClient'])) {
                 if ($lNumClients > 0) {
                     foreach ($displayData['clients'] as $client) {
                         $client->bSelected = in_array($client->lClientID, $_POST['chkClient']);
                     }
                 }
             }
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/client', 'Clients', 'class="breadcrumb"') . ' | ' . anchor('clients/client_record/view/' . $lClientID, 'Client Record', 'class="breadcrumb"') . ' | ' . anchor('admin/uf_multirecord_view/viewMRViaFID/' . $lATableID . '/' . $lClientID . '/' . $lERecID, 'Attendance: ' . htmlspecialchars($strProg), 'class="breadcrumb"') . ' | Clone Attendance Record';
         $displayData['title'] = CS_PROGNAME . ' | Client Program';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'cprograms/arec_clone_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $cloneOpts = new stdClass();
         $strADate = trim($_POST['txtADate']);
         MDY_ViaUserForm($strADate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $cloneOpts->mdteAttendance = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $cloneOpts->bSkipDups = @$_POST['chkSkipDups'] == 'true';
         $cloneOpts->clients = array();
         $idx = 0;
         foreach ($_POST['chkClient'] as $strIDs) {
             $cloneOpts->clients[$idx] = new stdClass();
             $IDs = explode('_', $strIDs);
             $cloneOpts->clients[$idx]->lClientID = (int) $IDs[0];
             $cloneOpts->clients[$idx]->lEnrollID = (int) $IDs[1];
             ++$idx;
         }
         $cloneOpts->lATableID = $cprog->lAttendanceTableID;
         $cloneOpts->lARecID = $lARecID;
         $cloneOpts->lCProgID = $lCProgID;
         $this->load->model('personalization/muser_fields', 'clsUF');
         $this->load->model('personalization/muser_fields_create', 'clsUFC');
         $this->load->model('personalization/muser_clone', 'cUFClone');
         $this->cUFClone->cloneAttendance($cloneOpts);
         $this->session->set_flashdata('msg', 'The specified attendance record was cloned.');
         redirect('cprograms/cprog_dir/viewEnroll/' . $lCProgID . '/true');
     }
 }
 function term_selected($lReportID, $strField, $lTermID = 0)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $glUserID, $gbDateFormatUS;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lReportID, 'custom report ID');
     verifyIDsViaType($this, CENUM_CONTEXT_CUSTOMREPORTTERM, $lTermID, true);
     $displayData = array();
     $displayData['lReportID'] = $lReportID = (int) $lReportID;
     $displayData['lTermID'] = $lTermID = (int) $lTermID;
     $displayData['bNew'] = $bNew = $lTermID <= 0;
     $displayData['strField'] = $strField = trim($strField);
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->helper('reports/creport_util');
     $this->load->helper('creports/link_creports');
     $this->load->helper('dl_util/special_ddl');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('dl_util/context');
     $this->load->helper('reports/search');
     $this->load->helper('dl_util/time_date');
     $this->load->model('admin/madmin_aco');
     $this->load->model('personalization/muser_schema', 'cUFSchema');
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->model('creports/mcreports', 'clsCReports');
     $this->load->model('creports/mcrpt_search_terms', 'crptTerms');
     $this->load->library('generic_form');
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     //------------------------------------------------
     // load report
     //------------------------------------------------
     $this->clsCReports->loadReportViaID($lReportID, false);
     $displayData['report'] = $report =& $this->clsCReports->reports[0];
     $enumRptType = $report->enumRptType;
     $displayData['contextSummary'] = $this->clsCReports->strCReportHTMLSummary();
     $tables = $this->clsCReports->loadTableStructures($enumRptType);
     $this->clsCReports->findFieldInTables($strField, $tables, $lTableIDX, $lFieldIDX);
     $table =& $tables[$lTableIDX];
     $displayData['lFieldID'] = $lFieldID = $table->fields[$lFieldIDX]->lFieldID;
     $displayData['lTableID'] = $table->lTableID;
     $displayData['lTableIDX'] = $lTableIDX;
     $displayData['lFieldIDX'] = $lFieldIDX;
     //-----------------------
     // search expression
     //-----------------------
     $this->crptTerms->loadSearchTermViaTermID($lTermID);
     $displayData['term'] = $term =& $this->crptTerms->terms[0];
     $displayData['field'] = $field =& $tables[$lTableIDX]->fields[$lFieldIDX];
     // special case for currency for new search terms
     if (is_null($term->lKeyID) && $field->enumType == CS_FT_CURRENCY) {
         $displayData['term']->lCurrencyACO = $field->lCurrencyACO;
         $displayData['term']->ACO = clone $field->ACO;
     }
     if ($table->lTableID > 0) {
         $displayData['tableName'] = '[' . $table->strAttachLabel . '] [' . htmlspecialchars($table->name) . ']';
     } else {
         $displayData['tableName'] = '[' . $table->name . ']';
     }
     $this->crptTerms->loadFieldTermOpts($lReportID, $term, $field);
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->setRulesViaFieldType($field->enumType);
     if ($this->form_validation->run() == FALSE) {
         if (validation_errors() == '') {
             $term->strCompVal = htmlspecialchars($term->strCompVal);
         } else {
             setOnFormError($displayData);
             $this->loadSearchCriteriaViaType($term, $field->enumType);
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/reports', 'Reports', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/view/' . $glUserID, 'Custom Report Directory', 'class="breadcrumb"') . ' | ' . anchor('creports/custom_directory/viewRec/' . $lReportID, 'Custom Report', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add New ' : 'Edit ') . 'Search Expression';
         $displayData['title'] = CS_PROGNAME . ' | Reports';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'creports/search_expression_add_edit_view.php';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $this->load->helper('dl_util/util_db');
         if ($bNew) {
             $term->lReportID = $lReportID;
             $term->lTableID = (int) $_POST['lTableID'];
             $term->lFieldID = (int) $_POST['lFieldID'];
             $term->strFieldID = $_POST['internalFieldID'];
             $term->lNumRParen = 0;
             $term->lNumLParen = 0;
             $term->lSortIDX = $this->crptTerms->lMaxSortIDXViaReport($lReportID) + 1;
         } else {
         }
         $this->loadSearchCriteriaViaType($term, $field->enumType);
         if ($field->enumType == CS_FT_DATE) {
             MDY_ViaUserForm($term->strDteCompVal, $lMon, $lDay, $lYear, $gbDateFormatUS);
             $term->mdteCompVal = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         }
         if ($bNew) {
             $lTermID = $this->crptTerms->lAddNewSearchTerm();
         } else {
             $this->crptTerms->updateSearchTerm($lTermID);
         }
         $this->session->set_flashdata('msg', 'The search term was ' . ($bNew ? 'added' : 'updated') . '.');
         redirect('creports/custom_directory/viewRec/' . $lReportID);
     }
 }
 function addEditPayment($lPledgeID, $lGiftID, $dtePledge)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gdteNow, $gbDateFormatUS, $gstrFormatDatePicker;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lPledgeID, 'pledge ID');
     $displayData = array();
     $displayData['lPledgeID'] = $lPledgeID = (int) $lPledgeID;
     $displayData['dtePledge'] = $dtePledge = (int) $dtePledge;
     $displayData['lGiftID'] = $lGiftID = (int) $lGiftID;
     $displayData['js'] = '';
     if (!bTestForURLHack('dataEntryGifts')) {
         return;
     }
     $bNew = $lGiftID <= 0;
     // load models
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $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('people/mpeople', 'clsPeople');
     $this->load->model('biz/mbiz', 'clsBiz');
     $this->load->model('donations/mdonations', 'clsGift');
     $this->load->model('util/mlist_generic', 'clsList');
     $this->load->model('donations/mpledges', 'clsPledges');
     // load pledge
     $this->clsPledges->loadPledgeViaPledgeID($lPledgeID);
     $displayData['pledge'] = $pledge =& $this->clsPledges->pledges[0];
     $bPeople = !$pledge->bBiz;
     $lFID = $pledge->lForeignID;
     // load gift associated with pledge
     $this->clsGift->loadGiftViaGID($lGiftID);
     $gifts =& $this->clsGift->gifts[0];
     /* -------------------------------------
     echo('<font class="debug">'.substr(__FILE__, strrpos(__FILE__, '\\'))
        .': '.__LINE__.'<br>$gifts   <pre>');
     echo(htmlspecialchars( print_r($gifts, true))); echo('</pre></font><br>');
     // ------------------------------------- */
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtAmount', 'Amount', 'trim|required|callback_stripCommas|numeric|callback_pledgeVerifyCommitment');
     $this->form_validation->set_rules('txtDDate', 'Date', 'trim|required|callback_pledgeVerifyDateValid');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     $this->form_validation->set_rules('txtCheckNum', 'Check Number', 'trim');
     $this->form_validation->set_rules('ddlPayType', 'Payment Type', 'callback_pledgeVerifyPayType');
     $this->form_validation->set_rules('ddlGiftCat', 'Gift Category', 'trim');
     $this->form_validation->set_rules('ddlAttrib', 'Attributed To', 'trim');
     if ($this->form_validation->run() == FALSE) {
         $displayData['formData'] = new stdClass();
         $this->load->library('generic_form');
         $displayData['js'] .= strDatePicker('datepickerFuture', true);
         if (validation_errors() == '') {
             if ($bNew) {
                 $displayData['formData']->strNotes = '';
                 $displayData['formData']->strCheckNum = '';
                 $displayData['formData']->txtDDate = date($gstrFormatDatePicker, $dtePledge);
                 $displayData['formData']->txtAmount = number_format($pledge->curCommitment, 2, '.', '');
                 $this->clsList->strBlankDDLName = '&nbsp;';
                 $this->clsList->enumListType = CENUM_LISTTYPE_GIFTPAYTYPE;
                 $displayData['formData']->strDDLPayType = $this->clsList->strLoadListDDL('ddlPayType', true, -1);
                 $this->clsList->enumListType = CENUM_LISTTYPE_MAJORGIFTCAT;
                 $displayData['formData']->strDDLMajGiftType = $this->clsList->strLoadListDDL('ddlGiftCat', true, -1);
             } else {
                 $displayData['formData']->strNotes = htmlspecialchars($gifts->strNotes);
                 $displayData['formData']->strCheckNum = htmlspecialchars($gifts->gi_strCheckNum);
                 $displayData['formData']->txtDDate = date($gstrFormatDatePicker, $gifts->gi_dteDonation);
                 $displayData['formData']->txtAmount = number_format($gifts->gi_curAmnt, 2, '.', '');
                 $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);
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtDDate = set_value('txtDDate');
             $displayData['formData']->txtAmount = set_value('txtAmount');
             $displayData['formData']->strNotes = set_value('txtNotes');
             $displayData['formData']->strCheckNum = set_value('txtCheckNum');
             $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'));
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['mainTemplate'] = 'donations/pledge_payment_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 Payment';
             $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 Payment';
             $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 {
         $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');
         /* -------------------------------------
         echo('<font class="debug">'.substr(__FILE__, strrpos(__FILE__, '\\'))
            .': '.__LINE__.'<br>$pledge   <pre>');
         echo(htmlspecialchars( print_r($pledge, true))); echo('</pre></font><br>');
         // -------------------------------------*/
         $gifts->gi_curAmnt = $curAmnt = trim((double) $_POST['txtAmount']);
         $gifts->gc_lKeyID = $pledge->lCampaignID;
         $gifts->gi_lSponsorID = null;
         $gifts->lACOID = $pledge->lACOID;
         $gifts->strNotes = trim($_POST['txtNotes']);
         $gifts->gi_strCheckNum = trim($_POST['txtCheckNum']);
         $gifts->gi_lAttributedTo = $pledge->lAttributedTo;
         // trim((integer)$_POST['ddlAttrib']);
         $gifts->gi_lGIK_ID = null;
         $gifts->gi_lPaymentType = trim((int) $_POST['ddlPayType']);
         $gifts->gi_lMajorGiftCat = trim((int) $_POST['ddlGiftCat']);
         $gifts->gi_lForeignID = $lFID;
         $gifts->lPledgeID = $lPledgeID;
         //         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);
         $this->session->set_flashdata('msg', 'A pledge payment of ' . $pledge->strACOCurSymbol . number_format($curAmnt, 2) . ' was ' . ($bNew ? 'added.' : 'updated.'));
         if ($bNew) {
             $lGiftID = $this->clsGift->lAddNewGiftRecord();
         } else {
             $this->clsGift->updateGiftRecord();
         }
         redirect('donations/pledge_record/view/' . $lPledgeID);
     }
 }
 function loadFieldTermOpts($lReportID, &$term, &$field)
 {
     // &$tables, $lTableIDX, $lFieldIDX){
     //---------------------------------------------------------------------
     // $vSelVal1 - the comparison key
     // $vSelVal2 - the first comparison value
     //---------------------------------------------------------------------
     global $gdteNow;
     $enumFieldType = $field->enumType;
     $lTermID = $term->lKeyID;
     // new term
     if (is_null($lTermID)) {
         $term->strFieldID = $field->internalName;
         $term->lReportID = $lReportID;
         $term->lSortIDX = 0;
         $term->lNumRParen = 0;
         $term->lNumLParen = 0;
         $term->enumFieldType = $enumFieldType;
         $term->lCompareOpt = 0;
         $term->bCompareBool = false;
         $term->lCompVal = 0;
         $term->curCompVal = 0.0;
         $term->strCompVal = '';
         if ($enumFieldType == CS_FT_DATE) {
             numsMoDaYr($gdteNow, $lMonth, $lDay, $lYear);
             $term->mdteCompVal = strMoDaYr2MySQLDate($lMonth, $lDay, $lYear);
         }
     }
     switch ($enumFieldType) {
         case CS_FT_CHECKBOX:
             $this->setCheckBoxOptions($term);
             break;
         case CS_FT_INTEGER:
         case CS_FT_CURRENCY:
             $this->setNumberOptions($term, $enumFieldType == CS_FT_INTEGER);
             break;
         case CS_FT_DATE:
             $this->setDateOptions($term);
             break;
         case CS_FT_TEXTLONG:
         case CS_FT_TEXT255:
         case CS_FT_TEXT80:
         case CS_FT_TEXT20:
         case CS_FT_TEXT:
             $this->setTextOptions($term);
             break;
         case CS_FT_DDL:
         case CS_FT_DDLMULTI:
             $this->setDDLOptions($term, $field);
             break;
         case CS_FT_DDL_SPECIAL:
             $this->setSpecialDDLOptions($term, $field);
             break;
         case CS_FT_ID:
             $this->setNumberOptions($term, true);
             break;
         case CS_FT_LOG:
         case CS_FT_DATETIME:
         case CS_FT_HEADING:
             //         case CS_FT_EMAIL:
             //         case CS_FT_HLINK:
             checkBackSoon($enumFieldType, __LINE__, __FUNCTION__, __FILE__);
             echo 'field Type:<b>' . strXlateFieldType($enumFieldType) . '</b><br><b>line:</b> ' . __LINE__ . '<br><b>file:</b> ' . __FILE__ . '<br><b>function:</b> ' . __FUNCTION__ . '<br><br>';
             die;
             break;
         default:
             screamForHelp('INVALID FIELD TYPE "' . $enumFieldType . '", error on line ' . __LINE__ . ', file ' . __FILE__ . ', function ' . __FUNCTION__);
             break;
     }
 }
 private function lCreateAutoChargeEntry($lMonth, $lYear)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $glUserID;
     $strMySQLDate = strMoDaYr2MySQLDate($lMonth, 1, $lYear);
     $sqlStr = "INSERT INTO sponsor_autocharge_log\n            SET\n               spcl_dteDateOfCharges='{$strMySQLDate}',\n               spcl_lOriginID={$glUserID};";
     $query = $this->db->query($sqlStr);
     return $this->db->insert_id();
 }
 function setFulfill($lPackageID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gbDateFormatUS;
     if (!bTestForURLHack('showAuctions')) {
         return;
     }
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lPackageID, 'package ID');
     $displayData = array();
     $displayData['js'] = '';
     $displayData['formData'] = new stdClass();
     $displayData['lPackageID'] = $lPackageID = (int) $lPackageID;
     //-------------------------
     // models & helpers
     //-------------------------
     $this->load->helper('dl_util/time_date');
     $this->load->model('auctions/mauctions', 'cAuction');
     $this->load->model('auctions/mpackages', 'cPackages');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->model('img_docs/mimage_doc', 'clsImgDoc');
     $this->load->model('donations/maccts_camps', 'clsAC');
     $this->load->model('util/mlist_generic', 'clsList');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('dl_util/link_auction');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('auctions/auction');
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->library('generic_form');
     setPackageContext($lPackageID, $lAuctionID, $displayData);
     $package =& $displayData['package'];
     $displayData['js'] .= strDatePicker('datepickerFuture', true);
     //-------------------------
     // validation rules
     //-------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtAmount', 'Amount', 'trim|required|callback_stripCommas|numeric|callback_minPackageAmnt[0.00]');
     $this->form_validation->set_rules('txtCheckNum', 'Check Number', 'trim');
     $this->form_validation->set_rules('ddlPayType', 'Payment Type', 'trim|callback_bidVerifyPayType');
     $this->form_validation->set_rules('ddlGiftCat', 'Gift Category', 'trim');
     $this->form_validation->set_rules('ddlAttrib', 'Attributed To', 'trim');
     $this->form_validation->set_rules('txtDDate', 'Fulfillment date', 'trim|required|callback_bidVerifyFDateValid');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     if ($this->form_validation->run() == FALSE) {
         // first time displayed, no user data entry errors
         if (validation_errors() == '') {
             $displayData['formData']->txtAmount = number_format($package->curWinBidAmnt, 2);
             $displayData['formData']->txtCheckNum = '';
             $displayData['formData']->txtDDate = '';
             $displayData['formData']->txtNotes = '';
             $this->clsList->strBlankDDLName = '&nbsp;';
             $this->clsList->enumListType = CENUM_LISTTYPE_GIFTPAYTYPE;
             $displayData['formData']->strDDLPayType = $this->clsList->strLoadListDDL('ddlPayType', true, -1);
             $this->clsList->enumListType = CENUM_LISTTYPE_MAJORGIFTCAT;
             $displayData['formData']->strDDLMajGiftType = $this->clsList->strLoadListDDL('ddlGiftCat', true, -1);
             $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
             $displayData['formData']->strDDLAttrib = $this->clsList->strLoadListDDL('ddlAttrib', true, -1);
         } else {
             setOnFormError($displayData);
             $displayData['formData']->txtAmount = set_value('txtAmount');
             $displayData['formData']->txtCheckNum = set_value('txtCheckNum');
             $displayData['formData']->txtDDate = set_value('txtDDate');
             $displayData['formData']->txtNotes = set_value('txtNotes');
             $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'));
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = GSTR_AUCTIONTOPLEVEL . ' | ' . anchor('auctions/auctions/auctionEvents', 'Silent Auctions', 'class="breadcrumb"') . ' | ' . anchor('auctions/auctions/viewAuctionRecord/' . $lAuctionID, 'Auction', 'class="breadcrumb"') . ' | ' . anchor('auctions/packages/viewPackageRecord/' . $lPackageID, 'Auction Package', 'class="breadcrumb"') . ' | Fulfillment';
         $displayData['title'] = CS_PROGNAME . ' | Silent Auctions';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'auctions/package_fulfillment_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $auction =& $displayData['auction'];
         $this->load->model('personalization/muser_fields', 'clsUF');
         $this->load->model('personalization/muser_fields_create', 'clsUFC');
         $this->load->model('admin/mpermissions', 'perms');
         $this->load->model('donations/mdonations', 'clsGift');
         $this->load->helper('dl_util/util_db');
         $this->clsGift->loadGiftViaGID(-1);
         $gifts =& $this->clsGift->gifts[0];
         $gifts->gi_curAmnt = trim((double) $_POST['txtAmount']);
         $gifts->strNotes = trim($_POST['txtNotes']);
         $gifts->gi_strCheckNum = trim($_POST['txtCheckNum']);
         $gifts->gi_lAttributedTo = trim((int) $_POST['ddlAttrib']);
         $gifts->gi_lPaymentType = trim((int) $_POST['ddlPayType']);
         $gifts->gi_lMajorGiftCat = trim((int) $_POST['ddlGiftCat']);
         $gifts->lACOID = $auction->lACOID;
         $gifts->gi_lForeignID = $package->lBidWinnerID;
         $gifts->gc_lKeyID = $auction->lCampaignID;
         $gifts->gi_lSponsorID = null;
         $gifts->gi_lGIK_ID = null;
         $gifts->gi_bGIK = false;
         if ($gifts->gi_lAttributedTo <= 0) {
             $gifts->gi_lAttributedTo = null;
         }
         $strDate = trim($_POST['txtDDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $gifts->mdteDonation = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         //------------------------------------
         // update db tables and return
         //------------------------------------
         $lGiftID = $this->clsGift->lAddNewGiftRecord();
         $this->cPackages->setBidGiftID($lPackageID, $lGiftID);
         $this->session->set_flashdata('msg', 'Bid fulfilled / gift record <b>' . str_pad($lGiftID, 5, '0', STR_PAD_LEFT) . '</b> added');
         redirect_AuctionPackageList($lAuctionID);
     }
 }
function dateRangeYears($mysqlDteBase, $lAgeYrsMin, $lAgeYrsMax, &$mysqlStartDate, &$mysqlEndDate)
{
    /*--------------------------------------------------------------------------------
       Let's say you want to find all the clients who were between 1 and 2 years
       of age on 2012-12-25:
    
          born           age on 2012-12-25
          ------------   -----------------
          2011-12-24             1
          2011-12-25             1
          2011-12-26             0
    
          2010-12-24             2
          2010-12-25             2
          2010-12-26             1
    
          2009-12-24             3
          2009-12-25             3
          2009-12-26             2
    
            > 2009-12-25  && <= 2011-12-25
    
    
       dateRangeYears('2010-12-25', 1, 2, &$mysqlStartDate, &$mysqlEndDate);
    
       returns $mysqlStartDate='2009-12-25', $mysqlEndDate='2011-12-25'
       ...
       the sql statement....
          WHERE NOT cr_bRetired
             AND cr_dteBirth > '.strPrepStr($mysqlStartDate).'
             AND cr_dteBirth <='.strPrepStr($mysqlEndDate).'
    --------------------------------------------------------------------------------*/
    numsMoDaYrMySQL($mysqlDteBase, $lMonth, $lDay, $lYear);
    $lMonthStart = $lMonth;
    $lDayStart = $lDay;
    $lYearStart = $lYear - ($lAgeYrsMax + 1);
    // leap year normalization
    normalizeDate($lMonthStart, $lDayStart, $lYearStart);
    $lMonthEnd = $lMonth;
    $lDayEnd = $lDay;
    $lYearEnd = $lYear - $lAgeYrsMin;
    // leap year normalization
    normalizeDate($lMonthEnd, $lDayEnd, $lYearEnd);
    $mysqlStartDate = strMoDaYr2MySQLDate($lMonthStart, $lDayStart, $lYearStart);
    $mysqlEndDate = strMoDaYr2MySQLDate($lMonthEnd, $lDayEnd, $lYearEnd);
}
 function addEditMeasurement($lClientID, $lMeasureID = '0')
 {
     //---------------------------------------------------------------
     //
     //---------------------------------------------------------------
     global $gbDateFormatUS, $gstrFormatDatePicker, $gdteNow, $genumMeasurePref, $gbMetric;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lClientID, 'client ID');
     $displayData = array();
     $displayData['lClientID'] = $lClientID;
     $displayData['lMeasureID'] = $lMeasureID = (int) $lMeasureID;
     $displayData['bNew'] = $bNew = $lMeasureID <= 0;
     $displayData['js'] = '';
     /*------------------------------------------------
           models/libraries/helpers
       ------------------------------------------------*/
     $this->load->model('emr/mmeasurements', 'emrMeas');
     $this->load->model('clients/mclients', 'clsClients');
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     $this->load->helper('dl_util/time_date');
     $this->load->helper('dl_util/web_layout');
     $this->load->helper('emr/link_emr');
     $this->clsClients->loadClientsViaClientID($lClientID);
     $displayData['client'] = $client =& $this->clsClients->clients[0];
     $displayData['bShowOFC'] = $bShowOFC = $client->lAgeYears < 3;
     $this->emrMeas->loadMeasurementViaMeasID($lMeasureID);
     $measure =& $this->emrMeas->measurements[0];
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtNotes', 'Notes', 'trim');
     //		$this->form_validation->set_rules('txtHeight',  'Height',     'trim|callback_stripCommas|numeric|callback_measVerifyHeight');
     $this->form_validation->set_rules('txtHeight', 'Height', 'callback_measVerifyHeight');
     $this->form_validation->set_rules('txtWeight', 'Weight', 'trim|callback_stripCommas|numeric|callback_measVerifyWeight');
     $this->form_validation->set_rules('txtOFC', 'OFC/Head Circumference', 'trim|callback_stripCommas|numeric|callback_measVerifyOFC');
     $this->form_validation->set_rules('txtDate', 'Measurement Date', 'trim|required' . '|callback_measRecVerifyDateValid' . '|callback_measRecVerifyDatePast');
     if ($this->form_validation->run() == FALSE) {
         $this->emrMeas->lNumMeasureViaCID($lClientID, true, true, true);
         /*-------------------------------------
               client summary
           -------------------------------------*/
         $displayData['formData'] = new stdClass();
         $this->load->model('img_docs/mimage_doc', 'clsImgDoc');
         $this->load->helper('img_docs/image_doc');
         $this->load->helper('img_docs/link_img_docs');
         $params = array('enumStyle' => 'terse');
         $this->load->library('generic_rpt', $params, 'generic_rpt');
         $displayData['clsRpt'] = $this->generic_rpt;
         $displayData['contextSummary'] = $this->clsClients->strClientHTMLSummary(0);
         /*-------------------------------------
              stripes
           -------------------------------------*/
         $this->load->model('util/mbuild_on_ready', 'clsOnReady');
         $this->clsOnReady->addOnReadyTableStripes();
         $this->clsOnReady->closeOnReady();
         $displayData['js'] .= $this->clsOnReady->strOnReady;
         $this->load->library('generic_form');
         if (validation_errors() == '') {
             if ($bNew) {
                 $displayData['formData']->strDate = strNumericDateViaUTS($gdteNow, $gbDateFormatUS);
                 $displayData['formData']->txtHeight = '';
                 $displayData['formData']->txtWeight = '';
                 $displayData['formData']->txtOFC = '';
                 $displayData['formData']->txtNotes = '';
             } else {
                 $displayData['formData']->strDate = strNumericDateViaUTS($measure->dteMeasurement, $gbDateFormatUS);
                 if ($gbMetric) {
                     $this->setMeasure($measure->sngHeightCM, $displayData['formData']->txtHeight, 1);
                     $this->setMeasure($measure->sngWeightKilos, $displayData['formData']->txtWeight, 1);
                     $this->setMeasure($measure->sngHeadCircCM, $displayData['formData']->txtOFC, 1);
                 } else {
                     $this->setMeasure($measure->sngHeightIn, $displayData['formData']->txtHeight, 1);
                     $this->setMeasure($measure->sngWeightLBS, $displayData['formData']->txtWeight, 1);
                     $this->setMeasure($measure->sngHeadCircIn, $displayData['formData']->txtOFC, 1);
                     $displayData['formData']->txtNotes = htmlspecialchars($measure->strNotes);
                 }
             }
         } else {
             setOnFormError($displayData);
             $displayData['formData']->strDate = set_value('txtDate');
             $displayData['formData']->txtHeight = set_value('txtHeight');
             $displayData['formData']->txtWeight = set_value('txtWeight');
             $displayData['formData']->txtOFC = set_value('txtOFC');
             $displayData['formData']->txtNotes = set_value('txtNotes');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = anchor('main/menu/client', 'Clients', 'class="breadcrumb"') . ' | ' . anchor('clients/client_record/view/' . $lClientID, 'Client Record', 'class="breadcrumb"') . ' | ' . anchor('emr/measurements/viewMeasurement/' . $lClientID, 'Measurements', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add' : 'Edit') . ' Measurements';
         $displayData['title'] = CS_PROGNAME . ' | Clients';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'emr/measurements_add_edit_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $measure->lClientID = $lClientID;
         $strDate = trim($_POST['txtDate']);
         MDY_ViaUserForm($strDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
         $measure->mySQLDateMeasure = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
         $measure->sngHeightCM = $this->strPrepMeasureForDB(trim($_POST['txtHeight']), $gbMetric ? CSTR_UNITS_CM : CSTR_UNITS_IN);
         $measure->sngWeightKilos = $this->strPrepMeasureForDB(trim($_POST['txtWeight']), $gbMetric ? CSTR_UNITS_KG : CSTR_UNITS_LB);
         $measure->sngHeadCircCM = $this->strPrepMeasureForDB(trim($_POST['txtOFC']), $gbMetric ? CSTR_UNITS_CM : CSTR_UNITS_IN);
         $measure->strNotes = trim($_POST['txtNotes']);
         if ($bNew) {
             $this->emrMeas->addNewMeasure();
             $this->session->set_flashdata('msg', 'The client measurements were added.');
         } else {
             $this->emrMeas->updateMeasure($lMeasureID);
             $this->session->set_flashdata('msg', 'The client measurements were updated.');
         }
         redirect_ClientMeasure($lClientID);
     }
     /*
     
           $displayData['client']    = $client    = $clsClients->clients[0];
     
           if (is_null($client->lLocationID)){
              $client->lLocationID  = (integer)$_POST['lLocationID'];
              $client->lStatusCatID = (integer)$_POST['lStatusCatID'];
              $client->lVocID       = (integer)$_POST['lVocID'];
           }
     
              // models associated with the client record
           $this->load->model('clients/mclient_locations',         'clsLocation');
           $this->load->model('sponsorship/msponsorship_programs', 'clsSponProg');
           $this->load->model('clients/mclient_status',            'clsClientStat');
           $this->load->model('clients/mclient_vocabulary',        'clsClientV');
           $this->load->helper('dl_util/time_date');
           $this->load->helper('dl_util/web_layout');
     
              // validation rules
           $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
           $this->form_validation->set_rules('txtFName',      'Client\'s First Name',  'trim|required');
           $this->form_validation->set_rules('txtMName',      'Client\'s Middle Name', 'trim');
           $this->form_validation->set_rules('txtLName',      'Client\'s Last Name',   'trim');
           $this->form_validation->set_rules('txtBDate',      'Birth date', 'trim|required|callback_clientRecVerifyBDateValid'
                                                                                        .'|callback_clientRecVerifyBDatePast');
           $this->form_validation->set_rules('txtPEntryDate', 'Enrollment date', 'trim|required|callback_clientRecVerifyEDateValid'
                                                                                             .'|callback_clientRecVerifyEDatePast');
           $this->form_validation->set_rules('txtMaxSpon',    'Max # of Sponsors',   'trim|required|is_natural');
           $this->form_validation->set_rules('rdoGender',     'Gender',   'required');
           $this->form_validation->set_rules('txtBio',        'Bio',      'trim');
           $this->form_validation->set_rules('ddlAttrib',     'Attributed to');
     
           $this->form_validation->set_rules('txtAddr1',      '',  'trim');
           $this->form_validation->set_rules('txtAddr2',      '',  'trim');
           $this->form_validation->set_rules('txtCity',       '',  'trim');
           $this->form_validation->set_rules('txtState',      '',  'trim');
           $this->form_validation->set_rules('txtZip',        '',  'trim');
           $this->form_validation->set_rules('txtCountry',    '',  'trim');
           $this->form_validation->set_rules('txtEmail',      'Email',  'trim|valid_email');
           $this->form_validation->set_rules('txtPhone',      '',  'trim');
           $this->form_validation->set_rules('txtCell',       '',  'trim');
     
           if ($bNew){
              $this->form_validation->set_rules('ddlStatus',  '',      'required|callback_clientRecVerifyInitStat');
           }
     
           if ($this->form_validation->run() == FALSE){
              $this->load->model  ('util/mlist_generic',     'clsList');
              $this->clsList->enumListType = CENUM_LISTTYPE_ATTRIB;
     
              $displayData['formData'] = new stdClass;
              $displayData['lLocationID'] = $lLocationID = $this->clsLocation->cl_lKeyID = $client->lLocationID;
              $this->clsLocation->loadLocationRec($lLocationID);
     
              $displayData['lVocID'] = $lVocID = $this->clsClientV->lVocID = $client->lVocID;
              $this->clsClientV->loadClientVocabulary(true, false);
              $displayData['clsClientV']  = $this->clsClientV;
              $displayData['clsLocation'] = $this->clsLocation;
              $this->clsSponProg->loadSponProgsViaLocID($lLocationID);
              $displayData['clsSponProg']   = $this->clsSponProg;
              $displayData['clsClientStat'] = $this->clsClientStat;
     
              $lSCID = $client->lStatusCatID;
              $this->clsClientStat->loadClientStatCatsEntries(
                                 true,  $lSCID,
                                 false, null,
                                 true,  false);
     
              $strMessage = '<font color="red">One or more client status entries must be established before
                                  adding clients.</font>';
              $displayData['bNoStatEntries'] = $bNoStatEntries = $this->clsClientStat->bTestNoStatEntries(
                                                $lSCID, true, $strMessage, $displayData['strNoStatErrMsg']);
     
     
              $this->load->library('generic_form');
     
              if (validation_errors()==''){
                 $displayData['formData']->txtFName = htmlspecialchars($client->strFName);
                 $displayData['formData']->txtMName = htmlspecialchars($client->strMName);
                 $displayData['formData']->txtLName = htmlspecialchars($client->strLName);
                 $displayData['strAttribDDL'] = $this->clsList->strLoadListDDL('ddlAttrib', true, $client->lAttribID);
     
                 if (is_null($client->dteBirth)){
                    $displayData['formData']->txtBDate = '';
                 }else {
                    $displayData['formData']->txtBDate = strNumericDateViaMysqlDate($client->dteBirth, $gbDateFormatUS);
                 }
                 if (is_null($client->dteEnrollment)){
                    $displayData['formData']->txtPEntryDate = '';
                 }else {
                    $displayData['formData']->txtPEntryDate = date($gstrFormatDatePicker, $client->dteEnrollment);
                 }
                 if ($bNew) $displayData['formData']->lInitStatID = -1;
     
                 if ($this->clsSponProg->lNumSponPrograms > 0){
                    foreach ($this->clsSponProg->sponProgs as $clsLocSP){
                       $lSCID = $clsLocSP->lKeyID;
                       $clsLocSP->bSupported = $this->clsSponProg->bClientInSponProgram($lClientID, $lSCID, $lcsp_lKeyID);
                    }
                 }
                 $displayData['formData']->txtMaxSpon = $client->lMaxSponsors;
                 $displayData['formData']->rdoGender  = $client->enumGender;
                 $displayData['formData']->txtBio     = htmlspecialchars($client->strBio);
     
                 $displayData['formData']->txtAddr1    = htmlspecialchars($client->strAddr1);
                 $displayData['formData']->txtAddr2    = htmlspecialchars($client->strAddr2);
                 $displayData['formData']->txtCity     = htmlspecialchars($client->strCity);
                 $displayData['formData']->txtState    = htmlspecialchars($client->strState);
                 $displayData['formData']->txtZip      = htmlspecialchars($client->strZip);
                 $displayData['formData']->txtCountry  = htmlspecialchars($client->strCountry);
                 $displayData['formData']->txtEmail    = htmlspecialchars($client->strEmail);
                 $displayData['formData']->txtPhone    = htmlspecialchars($client->strPhone);
                 $displayData['formData']->txtCell     = htmlspecialchars($client->strCell);
     
              }else{
                 setOnFormError($displayData);
                 $displayData['strAttribDDL']            = $this->clsList->strLoadListDDL('ddlAttrib', true, set_value('ddlAttrib'));
                 $displayData['formData']->txtFName      = set_value('txtFName');
                 $displayData['formData']->txtMName      = set_value('txtMName');
                 $displayData['formData']->txtLName      = set_value('txtLName');
                 $displayData['formData']->txtBDate      = set_value('txtBDate');
                 $displayData['formData']->txtPEntryDate = set_value('txtPEntryDate');
     
                 if ($bNew) $displayData['formData']->lInitStatID = set_value('ddlStatus');
     
                    // couldn't find a ci form validation way to do this....
                 if ($this->clsSponProg->lNumSponPrograms > 0){
                    if (isset($_POST['chkSP'])){
                       foreach ($this->clsSponProg->sponProgs as $clsLocSP){
                          $lSCID = $clsLocSP->lKeyID;
                          $clsLocSP->bSupported = in_array($lSCID, $_POST['chkSP']);
                       }
                    }
                 }
     
                 $displayData['formData']->txtMaxSpon = set_value('txtMaxSpon');
                 $displayData['formData']->rdoGender  = set_value('rdoGender');
                 $displayData['formData']->txtBio     = set_value('txtBio');
     
                 $displayData['formData']->txtAddr1   = set_value('txtAddr1');
                 $displayData['formData']->txtAddr2   = set_value('txtAddr2');
                 $displayData['formData']->txtCity    = set_value('txtCity');
                 $displayData['formData']->txtState   = set_value('txtState');
                 $displayData['formData']->txtZip     = set_value('txtZip');
                 $displayData['formData']->txtCountry = set_value('txtCountry');
                 $displayData['formData']->txtEmail   = set_value('txtEmail');
                 $displayData['formData']->txtPhone   = set_value('txtPhone');
                 $displayData['formData']->txtCell    = set_value('txtCell');
              }
     
                 //--------------------------
                 // breadcrumbs
                 //--------------------------
              if ($lClientID > 0){
                 $displayData['pageTitle']      = anchor('main/menu/client',                      'Clients', 'class="breadcrumb"')
                                           .' | '.anchor('clients/client_record/view/'.$lClientID, 'Client Record', 'class="breadcrumb"')
                                           .' | Edit Client Record';
              }else {
                 $displayData['pageTitle']      = anchor('main/menu/client',                      'Clients', 'class="breadcrumb"')
                                           .' | Add New Client Record';
              }
     
              $displayData['title']          = CS_PROGNAME.' | Clients';
              $displayData['nav']            = $this->mnav_brain_jar->navData();
     
              $displayData['mainTemplate']   = 'client/client_add_edit_view';
              $this->load->vars($displayData);
              $this->load->view('template');
           }else {
              $strBDate   = trim($_POST['txtBDate']);
              MDY_ViaUserForm($strBDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
              $client->dteBirth = strMoDaYr2MySQLDate($lMon, $lDay, $lYear);
     
              $strEnrollDate = trim($_POST['txtPEntryDate']);
              MDY_ViaUserForm($strEnrollDate, $lMon, $lDay, $lYear, $gbDateFormatUS);
              $client->dteEnrollment = strtotime($lMon.'/'.$lDay.'/'.$lYear);
     
              $client->strFName      = trim($_POST['txtFName']);
              $client->strMName      = trim($_POST['txtMName']);
              $client->strLName      = trim($_POST['txtLName']);
              $client->strBio        = trim($_POST['txtBio']);
              $client->enumGender    = trim($_POST['rdoGender']);
              $client->lMaxSponsors  = (integer)trim($_POST['txtMaxSpon']);
     
              $client->strAddr1      = trim($_POST['txtAddr1']);
              $client->strAddr2      = trim($_POST['txtAddr2']);
              $client->strCity       = trim($_POST['txtCity']);
              $client->strState      = trim($_POST['txtState']);
              $client->strZip        = trim($_POST['txtZip']);
              $client->strCountry    = trim($_POST['txtCountry']);
              $client->strEmail      = trim($_POST['txtEmail']);
              $client->strPhone      = trim($_POST['txtPhone']);
              $client->strCell       = trim($_POST['txtCell']);
     
              $lAttrib = (integer)$_REQUEST['ddlAttrib'];
              if ($lAttrib <= 0){
                 $client->lAttribID = null;
              }else {
                 $client->lAttribID = $lAttrib;
              }
     
              if ($bNew){
                 $this->load->model('personalization/muser_fields', 'clsUF');
                 $this->load->model('personalization/muser_fields_create', 'clsUFC');
                 $this->load->model ('admin/mpermissions',           'perms');
                 $lClientID = $this->clsClients->lAddNewClient();
                 $this->clsClientStat->clientStatus = array();
     
                 $status = $this->clsClientStat->clientStatus[0] = new stdClass;
                 $status->lClientID             = $lClientID;
                 $status->lStatusID             = (integer)trim($_POST['ddlStatus']);
                 $status->bIncludeNotesInPacket = false;
                 $status->dteStatus             = $gdteNow;
                 $status->strStatusTxt          = 'Initial status';
                 $this->clsClientStat->lInsertClientStatus();
                 $this->session->set_flashdata('msg', 'The client record was added');
              }else {
                 $clsClients->updateClientRec();
                 $this->session->set_flashdata('msg', 'The client record was updated');
              }
     
                 //----------------------------------------
                 // update supported sponsor categories
                 //----------------------------------------
              $this->clsSponProg->clearClientSponPrograms($lClientID);
              if (isset($_POST['chkSP'])){
                 foreach ($_POST['chkSP'] as $lSCID){
                    $this->clsSponProg->setClientSponProgram($lClientID, (integer)$lSCID);
                 }
              }
              redirect('clients/client_record/view/'.$client->lKeyID);
           }
     */
 }