function addFromCForm($lParentID, $lCFID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $gErrMessages, $gbShowHiddenVerifyError;
     $this->load->helper('dl_util/verify_id');
     verifyID($this, $lCFID, 'custom form ID');
     $displayData = array();
     $displayData['js'] = '';
     $displayData['lCFID'] = $lCFID = (int) $lCFID;
     $displayData['lParentID'] = $lParentID = (int) $lParentID;
     $gbShowHiddenVerifyError = false;
     $gErrMessages = array();
     /*------------------------------------------------
           models/libraries/helpers
       ------------------------------------------------*/
     $params = array('enumStyle' => 'terse');
     $this->load->library('generic_rpt', $params);
     $this->load->model('custom_forms/mcustom_forms', 'cForm');
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('personalization/muser_fields_display', 'clsUFD');
     $this->load->model('admin/madmin_aco', 'clsACO');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->helper('dl_util/context');
     $this->load->helper('dl_util/custom_forms');
     $this->load->helper('dl_util/time_date');
     $this->load->library('util/dl_date_time', '', 'clsDateTime');
     // load the custom form
     $this->cForm->loadCustomFormsViaCFID($lCFID);
     $displayData['cForm'] = $cForm =& $this->cForm->customForms[0];
     $enumType = $cForm->enumContextType;
     // now that the context is known, verify the parent ID
     verifyIDsViaType($this, $enumType, $lParentID, true);
     // custom verification ?
     $displayData['bCusVerification'] = $bCusVerification = $cForm->strVerificationModule . '' != '';
     //-----------------------------
     // validation rules
     //-----------------------------
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     if ($bCusVerification) {
         $this->load->helper('path');
         $this->form_validation->set_rules('hVerify', 'Hidden verification', 'callback_hiddenVerify[' . $cForm->strVerificationModule . ',' . $cForm->strVModEntryPoint . ']');
     }
     // personalized tables and associated fields
     $this->cForm->loadPTablesForDisplay($lCFID, $this->clsUF);
     $displayData['utables'] = $utables =& $this->cForm->utables;
     $displayData['lNumTables'] = $lNumTables = $this->cForm->lNumTables;
     setValidationUTables($displayData['js'], $lNumTables, $utables);
     if ($this->form_validation->run() == FALSE) {
         $this->load->library('generic_form');
         $this->load->model('util/mlist_generic', 'clsList');
         $this->load->helper('dl_util/web_layout');
         loadSupportModels($enumType, $lParentID);
         initUTableDates($displayData['js'], $lNumTables, $utables);
         initUTableDDLs($lNumTables, $utables);
         if (validation_errors() == '') {
             populateCustomTables($lNumTables, $utables, $lParentID);
             setCustomUTableDDLs($lNumTables, $utables);
         } else {
             setOnFormError($displayData);
             repopulateCustomTables($lNumTables, $utables);
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         $displayData['pageTitle'] = $this->cForm->strCustomFormsPageTitleAddEdit($enumType, $cForm->strFormName);
         $displayData['strHTMLSummary'] = strContextHTML($enumType, $lParentID, $enumType);
         $displayData['errMessages'] = arrayCopy($gErrMessages);
         $displayData['title'] = CS_PROGNAME . ' | Custom Forms';
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = array('custom_forms/custom_form_data_entry_view');
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         saveCustomPTables($lParentID, $lNumTables, $utables);
         $this->cForm->lLogFormSave($lParentID, $lCFID);
         $this->fromWhenceYeCame($lParentID, $enumType, $cForm);
     }
 }
Example #2
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);
     }
 }