public function lCreateNewBizRec() { //----------------------------------------------------------------------- // //----------------------------------------------------------------------- global $glUserID, $glChapterID; $clsUFC = new muser_fields_create(); $sqlStr = "INSERT INTO people_names\n SET\n pe_lOriginID = {$glUserID},\n pe_dteOrigin = NOW(), " . $this->strBizSQLCommon(); $query = $this->db->query($sqlStr); $this->lBID = $lBID = $this->db->insert_id(); // $result = mysql_query($sqlStr); // if (bSQLError('SQL error on line '.__LINE__.', file '.__FILE__.', function '.__FUNCTION__, $sqlStr) ) { // screamForHelp('Unexpected SQL error'); // } // // $this->lBID = $lBID = mysql_insert_id(); //-------------------------------------------------------- // create blank/default records for all the personalized // people tables //-------------------------------------------------------- $clsUFC->enumTType = CENUM_CONTEXT_BIZ; $clsUFC->loadTablesViaTType(); if ($clsUFC->lNumTables > 0) { foreach ($clsUFC->userTables as $clsTable) { $clsUFC->createSingleEmptyRec($clsTable, $lBID); } } return $this->lBID; }
function cloneCProgram($lCProgSourceID, $lCProgDestID) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $cdest = new muser_fields_create(); $ccpSource = new mcprograms(); $ccpDest = new mcprograms(); $ccpSource->loadClientProgramsViaCPID($lCProgSourceID); $cpSource =& $ccpSource->cprogs[0]; $ccpDest->loadClientProgramsViaCPID($lCProgDestID); $cpDest =& $ccpDest->cprogs[0]; $lETableSrcID = $cpSource->lEnrollmentTableID; $lATableSrcID = $cpSource->lAttendanceTableID; $lETableDestID = $cpDest->lEnrollmentTableID; $lATableDestID = $cpDest->lAttendanceTableID; // clone the enrollment table $attr = new stdClass(); $attr->lSrcTableID = $lETableSrcID; $attr->lDestTableID = $lETableDestID; $this->cloneUTable($attr); // clone the attendance table; first remove the new // activity DDL field (it will be cloned appropriately) $cdest->loadSingleField($cpDest->lActivityFieldID); $cdest->strENPTableName = $cpDest->strAttendanceTable; $cdest->removeField(); $attr->lSrcTableID = $lATableSrcID; $attr->lDestTableID = $lATableDestID; $this->cloneUTable($attr); //-------------------------------------------------- // now identify the new activity ddl, and set // that field name in the parent Client Program // record //-------------------------------------------------- // this is a bit kludgy - the activity field will be // the first ddl field in the attendance table //-------------------------------------------------- $sqlStr = "SELECT pff_lKeyID\n FROM uf_fields\n WHERE pff_lTableID={$lATableDestID}\n AND pff_enumFieldType='DDL'\n ORDER BY pff_lKeyID\n LIMIT 0,1;"; $query = $this->db->query($sqlStr); if ($query->num_rows() != 1) { screamForHelp($lATableDestID . ': Attendance table clone failure: unable to detect the activity DDL in cloned table<br>error on line <b> -- ' . __LINE__ . ' --</b>,<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__); } $row = $query->row(); $lActivityFieldID = (int) $row->pff_lKeyID; $sqlStr = "UPDATE cprograms\n SET cp_lActivityFieldID={$lActivityFieldID}\n WHERE cp_lKeyID={$lCProgDestID};"; $query = $this->db->query($sqlStr); }
public function lAddNewVolunteer() { //----------------------------------------------------------------------- // //----------------------------------------------------------------------- global $glUserID; $clsUFC = new muser_fields_create(); if (!isset($this->volRecs[0]->lRegFormID) || is_null($this->volRecs[0]->lRegFormID)) { $strRegFormID = 'null'; } else { $strRegFormID = (int) $this->volRecs[0]->lRegFormID; } $sqlStr = 'INSERT INTO volunteers SET vol_lPeopleID = ' . $this->volRecs[0]->lPeopleID . ', vol_bInactive = 0, vol_dteInactive = NULL, vol_Notes = ' . strPrepStr($this->volRecs[0]->Notes) . ",\n vol_bRetired = 0,\n vol_lRegFormID = {$strRegFormID},\n vol_lOriginID = {$glUserID},\n vol_lLastUpdateID = {$glUserID},\n vol_dteOrigin = NOW(),\n vol_dteLastUpdate = NOW()\n ON DUPLICATE KEY UPDATE\n vol_bInactive = 0,\n vol_dteInactive = NULL;"; $query = $this->db->query($sqlStr); $this->volRecs[0]->lKeyID = $lKeyID = $this->db->insert_id(); //-------------------------------------------------------- // create blank/default records for all the personalized // people tables //-------------------------------------------------------- $clsUFC->enumTType = CENUM_CONTEXT_VOLUNTEER; $clsUFC->loadTablesViaTType(); if ($clsUFC->lNumTables > 0) { foreach ($clsUFC->userTables as $clsTable) { $clsUFC->createSingleEmptyRec($clsTable, $lKeyID); } } return $lKeyID; }
public function lAddNewClient() { //----------------------------------------------------------------------- // //----------------------------------------------------------------------- global $gdteNow, $glUserID; $clsUFC = new muser_fields_create(); $sqlCommon = $this->strCommonClientSQL(); $sqlStr = "INSERT INTO client_records\n SET {$sqlCommon},\n cr_lStatusCatID = " . $this->clients[0]->lStatusCatID . ",\n cr_lOriginID = {$glUserID},\n cr_bRetired = 0,\n cr_dteOrigin = NOW();"; $query = $this->db->query($sqlStr); $this->clients[0]->lKeyID = $lKeyID = $this->db->insert_id(); //mysql_insert_id(); //-------------------------------------------------------- // create blank/default records for all the personalized // client tables //-------------------------------------------------------- $clsUFC->enumTType = CENUM_CONTEXT_CLIENT; $clsUFC->loadTablesViaTType(); if ($clsUFC->lNumTables > 0) { foreach ($clsUFC->userTables as $clsTable) { $clsUFC->createSingleEmptyRec($clsTable, $lKeyID); } } return $lKeyID; }
function removeCProgram() { //--------------------------------------------------------------------- // caller must first call // $this->loadClientProgramsViaCPID($lCPID) // and load // $this->load->model('client_features/mcprograms', 'cprograms'); // $this->load->model('personalization/muser_fields', 'clsUF'); // $this->load->model('personalization/muser_fields_create', 'clsUFC'); //--------------------------------------------------------------------- $clsUFC = new muser_fields_create(); $cprog =& $this->cprogs[0]; $lCProgID = $cprog->lKeyID; // remove the personalized tables $clsUFC->removeUFTable($cprog->lEnrollmentTableID); $clsUFC->removeUFTable($cprog->lAttendanceTableID); // remove the cprogram table entry $sqlStr = "DELETE FROM cprograms\n WHERE cp_lKeyID={$lCProgID};"; $query = $this->db->query($sqlStr); }
public function lAddNewGiftRecord() { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- global $glUserID; $sqlCommon = $this->strCommonGiftSQL(); $sqlStr = "INSERT INTO gifts\n SET {$sqlCommon},\n gi_lOriginID = {$glUserID},\n gi_lForeignID = " . $this->gifts[0]->gi_lForeignID . ', gi_bRetired = 0, gi_dteOrigin = NOW();'; $this->db->query($sqlStr); $this->gifts[0]->gi_lKeyID = $lGiftID = $this->db->insert_id(); //-------------------------------------------------------- // create blank/default records for all the personalized // gift tables //-------------------------------------------------------- $clsUFC = new muser_fields_create(); $clsUFC->enumTType = CENUM_CONTEXT_GIFT; $clsUFC->loadTablesViaTType(); if ($clsUFC->lNumTables > 0) { foreach ($clsUFC->userTables as $clsTable) { $clsUFC->createSingleEmptyRec($clsTable, $lGiftID); } } return $lGiftID; }
public function lCreateNewPeopleRec() { //----------------------------------------------------------------------- // //----------------------------------------------------------------------- global $glUserID, $glChapterID; $clsUFC = new muser_fields_create(); $lHID = $this->people[0]->lHouseholdID; $sqlStr = "INSERT INTO people_names\n SET\n pe_lChapterID = {$glChapterID},\n pe_lHouseholdID = " . strDBValueConvert_INT($lHID) . ",\n pe_lOriginID = {$glUserID},\n pe_dteOrigin = NOW(), " . $this->strPeopleSQLCommon() . ';'; $query = $this->db->query($sqlStr); $this->people[0]->lKeyID = $lKeyID = $this->db->insert_id(); //------------------------------------------------------------ // if not part of a household, make person head of household //------------------------------------------------------------ if ($lHID == 0) { $sqlStr = "UPDATE people_names\n SET\n pe_lHouseholdID={$lKeyID}\n WHERE pe_lKeyID={$lKeyID};"; $this->db->query($sqlStr); } //-------------------------------------------------------- // create blank/default records for all the personalized // people tables //-------------------------------------------------------- $clsUFC->enumTType = CENUM_CONTEXT_PEOPLE; $clsUFC->loadTablesViaTType(); if ($clsUFC->lNumTables > 0) { foreach ($clsUFC->userTables as $clsTable) { $clsUFC->createSingleEmptyRec($clsTable, $lKeyID); } } return $lKeyID; }