function team_get() { // check that the id is at least a valid number $this->_check_id(); // get the single team by id $team = new Team(); $team->where('id', $this->get('id'))->limit(1)->get(); if ($team->result_count() == 1) { $result = $team->to_array(); $members = new Membership(); // get members gives an actual object with ->profile_othervariable $memb = $members->get_members($team->id); // we have to select the user array manually because... we don't want to expose password hashes foreach ($memb->all as $key => $mem) { $result['members'][$key] = $mem->to_array(array('id', 'username')); $result['members'][$key]['display_name'] = $mem->profile_display_name; $result['members'][$key]['twitter'] = $mem->profile_twitter; $result['members'][$key]['bio'] = $mem->profile_bio; } // all good $this->response($result, 200); // 200 being the HTTP response code } else { // no team for this id $this->response(array('error' => _('Team could not be found')), 404); } }
function _get_requests() { $application = array(); $members = new Membership(); if ($members->get_requests()) { foreach ($members->all as $key => $applicant) { $application[] = array( $applicant->team->name, $applicant->is_leader, array( 'display' => 'buttoner', 'href' => site_url('/admin/members/accept_application/' . $applicant->team->id), 'text' => _('Accept'), 'plug' => _('Do you really want to join this team?') ), array( 'display' => 'buttoner', 'href' => site_url('/admin/members/reject_application/' . $applicant->team->id), 'text' => _('Reject'), 'plug' => _('Do you really want to reject the request to join this team?') ) ); } $list = tabler($application, TRUE, FALSE); $data = array('application' => $list, 'section' => _('Pending requests')); $this->viewdata['main_content_view'] .= $this->load->view("admin/dashboard/applicants", $data, TRUE); } }
/** * Tests for success at creating the object. */ public function testCreate() { $test_name = 'test_name'; $t = new Membership(); $t->setDescription($test_name); $this->assertTrue($t instanceof Membership); $this->assertEquals($t->__toString(), $test_name); }
public function save() { $membershipId = $this->getValue('membershipId'); if (!empty($membershipId)) { $membership = $this->getMembershipService()->getMembershipById($membershipId); } else { $membership = new Membership(); } $membership->setName($this->getValue('name')); $membership->save(); }
/** * Singleton Pattern * * Auto Create Object Instance. * */ public static function getInstance() { if (null === self::$_objInstance) { self::$_objInstance = new Membership(); } return self::$_objInstance; }
public static function instance() { if (self::$instance == null) { self::$instance = new Membership(); } return self::$instance; }
protected function Form_Create() { $this->lblLabel = new QLabel($this); $this->lblLabel->Text = "Members who left after "; $this->dtxBeforeValue = new QDateTimeTextBox($this); $this->dtxBeforeValue->Name = "Members who Exited Before:"; $this->dtxBeforeValue->Required = true; $this->beforeCalValue = new QCalendar($this, $this->dtxBeforeValue); $this->dtxBeforeValue->RemoveAllActions(QClickEvent::EventName); $this->dtxBeforeValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change')); $this->dtxBeforeValue->Text = QApplication::PathInfo(1); $this->dtxAfterValue = new QDateTimeTextBox($this); $this->dtxAfterValue->Name = "Members who exited After:"; $this->dtxAfterValue->Required = true; $this->afterCalValue = new QCalendar($this, $this->dtxAfterValue); $this->dtxAfterValue->RemoveAllActions(QClickEvent::EventName); $this->dtxAfterValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change')); $this->dtxAfterValue->Text = QApplication::PathInfo(0); $this->dtgExitingMembers = new QDataGrid($this); $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Name', '<?= $_ITEM->Person->FullName; ?>', 'Width=270px')); $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Membership End Date', '<?= $_ITEM->DateEnd; ?>', 'Width=270px')); $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Termination Reason', '<?= $_ITEM->TerminationReason; ?>', 'Width=270px')); $dtAfterValue = new QDateTime($this->dtxAfterValue->Text); $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text); $objMembershipArray = Membership::LoadArrayByEndDateRange($dtAfterValue, $dtBeforeValue); $this->iTotalCount = count($objMembershipArray); $this->dtgExitingMembers->DataSource = $objMembershipArray; }
public function team($stub = NULL) { if (is_null($stub)) show_404(); $team = new Team(); $team->where('stub', $stub)->get(); if ($team->result_count() < 1) show_404(); $memberships = new Membership(); $members = $memberships->get_members($team->id); $this->template->title(_('Team')); $this->template->set('team', $team); $this->template->set('members', $members); $this->template->build('team'); }
protected function dtgNewMembers_Bind() { $dtAfterValue = new QDateTime($this->dtxAfterValue->Text); $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text); $this->dtgNewMembers->TotalItemCount = Membership::CountArrayByStartDateRange($dtAfterValue, $dtBeforeValue); $objMembershipArray = Membership::LoadArrayByStartDateRange($dtAfterValue, $dtBeforeValue, $this->dtgNewMembers->LimitClause); $this->dtgNewMembers->DataSource = $objMembershipArray; }
public function actionUpdatepasswd() { if (isset($_POST['password']) && isset($_POST['password2']) && $_POST['password'] == $_POST['password2']) { $membership = Membership::model()->findByPk($this->member_id); $membership->member_password = md5($_POST['password']); $membership->save(); $this->redirect(array('site/message', 'message_info' => '密码修改成功', 'menu_type' => 'membership_safe')); } $this->render('update_passwd'); }
public function delete() { Membership::delete_all_from_circle($this->circle_id); Shared_With::delete_all_from_circle($this->circle_id); global $database; $sql = "DELETE FROM " . self::$table_name . " "; $sql .= "WHERE circle_id=" . $database->escape_value($this->circle_id); $sql .= " LIMIT 1"; $database->query($sql); return $database->affected_rows() == 1 ? true : false; }
protected function dtgNewMembers_Bind() { $dtAfterValue = new QDateTime($this->dtxAfterValue->Text); $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text); $objcondition = QQ::Equal(QQN::Membership()->Person->AttributeValue->Attribute->Name, 'Post-2016'); $this->dtgNewMembers->TotalItemCount = Membership::CountArrayByStartDateRange($dtAfterValue, $dtBeforeValue, $objcondition); $objMembershipArray = Membership::LoadArrayByStartDateRange($dtAfterValue, $dtBeforeValue, $objcondition, $this->dtgNewMembers->LimitClause); $this->dtgNewMembers->DataSource = $objMembershipArray; $this->iTotalCount = count($objMembershipArray); $this->CalculateMaritalAndAgeStatus($objMembershipArray); $this->CalculateAttributeStatistics($objMembershipArray); }
function team_get() { if (!$this->get('id') || !is_numeric($this->get('id'))) { $this->response(NULL, 400); } $team = new Team(); $team->where('id', $this->get('id'))->limit(1)->get(); if ($team->result_count() == 1) { $result = $team->to_array(); $members = new Membership(); $memb = $members->get_members($team->id); foreach($memb->all as $key => $mem) { $result['members'][$key] = $memb->to_array(array('id','username')); $result['members'][$key]['display_name'] = $memb->profile_display_name; $result['members'][$key]['twitter'] = $memb->profile_twitter; $result['members'][$key]['bio'] = $memb->profile_bio; } $this->response($result, 200); // 200 being the HTTP response code } else { $this->response(array('error' => _('Team could not be found')), 404); } }
protected function Form_Create() { $this->lblLabel = new QLabel($this); $this->lblLabel->Text = "Members who left after "; $this->dtxBeforeValue = new QDateTimeTextBox($this); $this->dtxBeforeValue->Name = "Members who Exited Before:"; $this->dtxBeforeValue->Required = true; $this->beforeCalValue = new QCalendar($this, $this->dtxBeforeValue); $this->dtxBeforeValue->RemoveAllActions(QClickEvent::EventName); $this->dtxBeforeValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change')); $this->dtxBeforeValue->Text = QApplication::PathInfo(1); $this->dtxAfterValue = new QDateTimeTextBox($this); $this->dtxAfterValue->Name = "Members who exited After:"; $this->dtxAfterValue->Required = true; $this->afterCalValue = new QCalendar($this, $this->dtxAfterValue); $this->dtxAfterValue->RemoveAllActions(QClickEvent::EventName); $this->dtxAfterValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change')); $this->dtxAfterValue->Text = QApplication::PathInfo(0); $this->dtgExitingMembers = new QDataGrid($this); $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Name', '<?= $_ITEM->Person->FullName; ?>', 'Width=270px')); $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Membership End Date', '<?= $_ITEM->DateEnd; ?>', 'Width=270px')); $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Termination Reason', '<?= $_ITEM->TerminationReason; ?>', 'Width=270px')); $dtAfterValue = new QDateTime($this->dtxAfterValue->Text); $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text); $objcondition = QQ::Equal(QQN::Membership()->Person->AttributeValue->Attribute->Name, 'Post-2016'); $objMembershipArray = Membership::LoadArrayByEndDateRange($dtAfterValue, $dtBeforeValue, $objcondition); $this->iTotalCount = count($objMembershipArray); $this->dtgExitingMembers->DataSource = $objMembershipArray; $chartArray = array(); $terminationReason = array(); foreach ($objMembershipArray as $member) { if (array_key_exists($member->TerminationReason, $terminationReason)) { $terminationReason[$member->TerminationReason]++; } else { $terminationReason[$member->TerminationReason] = 1; } } ksort($terminationReason, SORT_STRING); foreach ($terminationReason as $key => $value) { $objItem = new memberArray(); $objItem->reason = $key; $objItem->count = $value; $chartArray[] = $objItem; } QApplication::ExecuteJavaScript('initializeChart(' . json_encode($chartArray) . ');'); }
public function getDelete($id) { // Find the membership using the user id $membership = Membership::find($id); if ($membership == null) { $errors = new \Illuminate\Support\MessageBag(); $errors->add('deleteError', "The membership cannot be found. It could have already been deleted."); return \Redirect::to('/admin/memberships')->withErrors($errors); } // Cannot delete if in use $modMediaMembership = ModuleMediaMembership::where('membership_id', $id)->get(); if (count($modMediaMembership) > 0) { $errors = new \Illuminate\Support\MessageBag(); $errors->add('deleteError', "The membership cannot be deleted because it is in used."); return \Redirect::to('/admin/memberships')->withErrors($errors); } // Delete the membership $membership->delete(); return \Redirect::to('admin/memberships'); }
public function actionIndex() { $this->layout = 'membership'; $model = new Membership(); $members = Membership::model()->findAll(array('order' => 'id desc')); $this->performAjaxValidation($model); if (isset($_POST['Membership'])) { $model->attributes = $_POST['Membership']; $model->parola = md5($model->parola); $model->created_at = time(); $model->updated_at = time(); $flash = 'Membership successfully created'; if ($model->validate()) { if ($model->save()) { Yii::app()->user->setFlash('success', $flash); $this->redirect(array('index')); } } } $this->render('index', array('model' => $model, 'members' => $members)); }
<?php require_once 'classes/Membership.php'; $Membership = new Membership(); $Membership->confirm_Member(); ?> <!DOCTYPE html > <html> <head> <title>TheGallery</title> <link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet"> <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css"> <link rel="stylesheet" href="css/main.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript" src="js/main.js"></script> </head> <body> <div class="nav"> <div class="container"> <ul class="pull-left"> <li><a href="About.php">About</a></li> <li><a href="Profile.php">Profile</a></li> <li><a href="Browse.php">Browse</a></li> </ul> <ul class="pull-right"> <li><a href="SignUp.php">Sign Up</a></li> <li><a href="Login.php?un=">Log Out</a></li> <li><a href="Help.php">Help</a></li> </ul>
} ?> "><a href="<?php echo $backPath; ?> application_list.php">Applications</a></li> </ul> <ul class="login"> <li>Hi, <?php echo $userName; ?> </li> <?php if (Membership::isLoggedIn()) { ?> <li><a href="<?php echo $backPath; ?> developer_profile.php">My profile</a></li> <li><a href="<?php echo $rootPath; ?> login.php?action=logout">Log Out</a></li> <?php } else { ?> <li><a href="<?php echo $rootPath;
public function checkUsernameAvailable() { $request = self::$_appInstance->request(); $username = $request->post('username'); $username = filter_var($username, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH); //check username in DB $result = Membership::getInstance()->checkUsername($username); $results = array(); if ($result[0]['valid'] > 0) { $results['message'] = "คุณไม่สามารถใช้ชื่อบัญชีนี้ได้"; $results['image'] = '<img src="img/not-available.png" /> ' . $results['message']; $results['error'] = true; } else { $results['message'] = "คุณสามารถใช้ชื่อบัญชีนี้ได้"; $results['image'] = '<img src="img/available.png" /> ' . $results['message']; $results['error'] = false; } echo json_encode($results); }
/** * Test create order api for membership */ public function testAddOrderForMembership() { require_once 'CiviTest/Membership.php'; $membership = new Membership(); $membershipType = $membership->createMembershipType(); $membershipType1 = $membership->createMembershipType(); $membershipType = $membershipTypes = array($membershipType->id, $membershipType1->id); $p = array('contact_id' => $this->_individualId, 'receive_date' => '2010-01-20', 'total_amount' => 200, 'financial_type_id' => $this->_financialTypeId, 'contribution_status_id' => 1); $priceFields = $this->createPriceSet(); foreach ($priceFields['values'] as $key => $priceField) { $lineItems[$key] = array('price_field_id' => $priceField['price_field_id'], 'price_field_value_id' => $priceField['id'], 'label' => $priceField['label'], 'field_title' => $priceField['label'], 'qty' => 1, 'unit_price' => $priceField['amount'], 'line_total' => $priceField['amount'], 'financial_type_id' => $priceField['financial_type_id'], 'entity_table' => 'civicrm_membership', 'membership_type_id' => array_pop($membershipType)); } $p['line_items'][] = array('line_item' => array(array_pop($lineItems)), 'params' => array('contact_id' => $this->_individualId, 'membership_type_id' => array_pop($membershipTypes), 'join_date' => '2006-01-21', 'start_date' => '2006-01-21', 'end_date' => '2006-12-21', 'source' => 'Payment', 'is_override' => 1, 'status_id' => 1)); $order = $this->callAPIAndDocument('order', 'create', $p, __FUNCTION__, __FILE__); $params = array('contribution_id' => $order['id']); $order = $this->callAPISuccess('order', 'get', $params); $expectedResult = array($order['id'] => array('total_amount' => 200, 'contribution_id' => $order['id'], 'contribution_status' => 'Completed', 'net_amount' => 200)); $this->checkPaymentResult($order, $expectedResult); $this->callAPISuccessGetCount('MembershipPayment', $params, 1); $this->callAPISuccess('Contribution', 'Delete', array('id' => $order['id'])); $p['line_items'][] = array('line_item' => array(array_pop($lineItems)), 'params' => array('contact_id' => $this->_individualId, 'membership_type_id' => array_pop($membershipTypes), 'join_date' => '2006-01-21', 'start_date' => '2006-01-21', 'end_date' => '2006-12-21', 'source' => 'Payment', 'is_override' => 1, 'status_id' => 1)); $p['total_amount'] = 300; $order = $this->callAPISuccess('order', 'create', $p); $expectedResult = array($order['id'] => array('total_amount' => 300, 'contribution_status' => 'Completed', 'net_amount' => 300)); $paymentMembership = array('contribution_id' => $order['id']); $order = $this->callAPISuccess('order', 'get', $paymentMembership); $this->checkPaymentResult($order, $expectedResult); $this->callAPISuccessGetCount('MembershipPayment', $paymentMembership, 2); $this->callAPISuccess('Contribution', 'Delete', array('id' => $order['id'])); }
foreach ($questions as $question) { $tempData[$index]['question_id'] = $question['question_id']; $tempData[$index]['answer'] = $question['answer']; $index++; } $content = "<tr><td>ข้อสอบข้อที่</td><td>หมายเลขข้อสอบจากคลังข้อสอบ</td><td>เฉลย</td></tr>"; $flag = false; $index = 1; foreach ($tempData as $answer) { $content .= "<tr><td>{$index}</td><td>" . $answer['question_id'] . "</td> <td>" . $answer['answer'] . "</td></tr>"; $index++; } header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment;Filename=เฉลยปัญหาข้อสอบ.xls"); header("Pragma: no-cache"); header("Expires: 0"); echo "<html>"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"; echo "<body>"; echo "<table>"; echo $content; echo "</table>"; echo "</body>"; echo "</html>"; } else { echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"; $text = 'ขออภัยไม่พบข้อมูลข้อสอบในระบบฐานข้อมูล'; Membership::getInstance()->sms($text); Membership::getInstance()->redirect('list_of_exams.php'); } //end loop of validate
public function actionMDelete($id) { if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) { $this->redirect(Yii::app()->homeUrl); } $model = Membership::model()->findByPK($id); $model->delete(); $this->redirect(Yii::app()->homeUrl . 'admin/webshop/membership/'); }
/** * Deletes all associated Memberships * @return void */ public function DeleteAllMemberships() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMembership on this unsaved Person.'); } // Get the Database Object for this Class $objDatabase = Person::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (Membership::LoadArrayByPersonId($this->intId) as $objMembership) { $objMembership->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `membership` WHERE `person_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
public static function getMembership($membership_id) { $membership = Membership::model()->findByPk($membership_id); return $membership; }
protected function SetupPanel() { // Ensure the User is allowed to Edit Memberships if (!QApplication::IsLoginHasPermission(PermissionType::EditMembershipStatus)) { return $this->ReturnTo('#general/view_membership'); } // Get and Validate the Membership Object $this->objMembership = Membership::Load($this->strUrlHashArgument); if (!$this->objMembership) { // Trying to create a NEW membership // Let's make sure this person doesn't have a current membership if ($this->objPerson->CurrentMembershipInfo) { return $this->ReturnTo('#general/view_membership'); } $this->objMembership = new Membership(); $this->objMembership->Person = $this->objPerson; $this->blnEditMode = false; $this->btnSave->Text = 'Create'; } else { // Ensure the Membership object belongs to the person if ($this->objMembership->PersonId != $this->objPerson->Id) { return $this->ReturnTo('#general/view_membership'); } $this->blnEditMode = true; $this->btnSave->Text = 'Update'; $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to permenantly DELETE this record?')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } // Create Controls $this->dtxDateStart = new QDateTimeTextBox($this); $this->dtxDateStart->Name = 'Membership Started'; $this->dtxDateStart->Required = true; $this->dtxDateStart->Text = $this->objMembership->DateStart ? $this->objMembership->DateStart->__toString() : null; $this->calDateStart = new QCalendar($this, $this->dtxDateStart); $this->dtxDateEnd = new QDateTimeTextBox($this); $this->dtxDateEnd->Name = 'Membership Ended'; $this->dtxDateEnd->Text = $this->objMembership->DateEnd ? $this->objMembership->DateEnd->__toString() : null; $this->dtxDateEnd->AddAction(new QBlurEvent(), new QAjaxControlAction($this, 'dtxDateEnd_Blur')); $this->calDateEnd = new QCalendar($this, $this->dtxDateEnd); $this->dtxDateStart->RemoveAllActions(QClickEvent::EventName); $this->dtxDateEnd->RemoveAllActions(QClickEvent::EventName); $this->lstTermination = new QListBox($this); $this->lstTermination->Name = 'Reason for Termination'; $this->lstTermination->AddItem('- Select One -', null); if ($strTerminationReasons = Registry::GetValue('membership_termination_reason')) { foreach (explode(',', $strTerminationReasons) as $strReason) { $strReason = trim($strReason); $this->lstTermination->AddItem($strReason, $strReason, strtolower($strReason) == strtolower($this->objMembership->TerminationReason)); } } $this->lstTermination->AddItem('- Other... -', -1); // Setup "Other" textbox $this->txtTermination = new QTextBox($this); $this->txtTermination->Name = ' '; // Pre-Select "Other" if applicable if ($this->objMembership->TerminationReason && is_null($this->lstTermination->SelectedValue)) { $this->lstTermination->SelectedValue = -1; $this->txtTermination->Text = $this->objMembership->TerminationReason; } // Setup and Call Actions $this->lstTermination->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'txtTermination_Refresh')); $this->txtTermination_Refresh(); $this->dtxDateEnd_Blur(); }
function leave_leadership($team_stub) { $this->viewdata["navbar"] = ""; $team = new Team(); $team->where('stub', $team_stub)->get(); if ($team->result_count() != 1) { show_404(); } if (!$this->tank_auth->is_team_leader($team->id) && !$this->tank_auth->is_allowed()) { show_404(); } if ($this->input->post()) { $member = new Membership(); if (!$member->remove_team_leader($team->id)) { return show_404(); } redirect('/account/teams/'); } $this->viewdata["function_title"] = _("Leave team leadership"); $data["team_name"] = $team->name; $data["team_id"] = $team->id; $this->viewdata["main_content_view"] = $this->load->view('account/profile/leave_leadership', $data, TRUE); $this->load->view("account/default.php", $this->viewdata); }
<?php session_start(); require_once 'classes/Membership.php'; $Membership = new Membership(); if ($_POST) { $directory = getcwd() . DIRECTORY_SEPARATOR . "userImages" . DIRECTORY_SEPARATOR; if (!empty($_FILES["fileToUpload"]["name"])) { $fileDirectory = $directory . basename($_FILES["fileToUpload"]["name"]) . ""; $response = $Membership->attach_Image($fileDirectory); } else { $response = "Please choose a file to upload."; } } ?> <!DOCTYPE html> <html> <head> <title>TheGallery</title> <link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet"> <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css"> <link href = "css/main.css" rel = "stylesheet"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript" src="js/main.js"></script> </head> <body> <div class="nav"> <div class="container"> <ul class="pull-left"> <li><a href="About.php">About</a></li>
/** * Recalculates this member's Membership Status and updates MembershipStatusTypeId * based on the calculation. Will call save if asked to do so * @param boolean $blnSave whether or not to call save after updating * @return integer the new/updated TypeId */ public function RefreshMembershipStatusTypeId($blnSave = true) { // If this Individual record isn't saved yet, then we are automatically not a member if (!$this->intId) { $this->intMembershipStatusTypeId = MembershipStatusType::NonMember; if ($blnSave) { $this->Save(); } return $this->intMembershipStatusTypeId; } // Pull the most recent Membership $objMembership = Membership::QuerySingle(QQ::Equal(QQN::Membership()->PersonId, $this->intId), QQ::OrderBy(QQN::Membership()->DateStart, false)); // If no membership if (!$objMembership) { // TODO: Check to see if "Child of Member" $this->intMembershipStatusTypeId = MembershipStatusType::NonMember; if ($blnSave) { $this->Save(); } return $this->intMembershipStatusTypeId; } // If no EndDate, or EndDate is in the future if (!$objMembership->DateEnd || $objMembership->DateEnd->IsLaterThan(QDateTime::Now(false))) { $this->intMembershipStatusTypeId = MembershipStatusType::Member; if ($blnSave) { $this->Save(); } return $this->intMembershipStatusTypeId; } // Check to see if we're deceased if ($objMembership->TerminationReason == MembershipStatusType::ToString(MembershipStatusType::Deceased)) { $this->intMembershipStatusTypeId = MembershipStatusType::Deceased; if ($blnSave) { $this->Save(); } return $this->intMembershipStatusTypeId; } // Otherwise, we are a Past member $this->intMembershipStatusTypeId = MembershipStatusType::FormerMember; if ($blnSave) { $this->Save(); } return $this->intMembershipStatusTypeId; }
public function showpage($dp = null) { $title = 'index'; $extension = 'html'; if (!empty($dp) && empty($this->params['pagename'])) { $this->params['pagename'] = $dp; } $arr = $this->getNamedParamsAsArr(); $mem_id = $this->Session->read('Auth.Membership.id'); if (!empty($mem_id)) { App::import('Model', 'Membership'); $Membership = new Membership(); $this->set('membership', $Membership->read(null, $mem_id, 1)); } // when Post action is done it redirects with no Printing Center Id $fromSessionPrintingCenterId = $this->Session->read('PrintingCenter.id'); if (!empty($arr['printing_center_id'])) { $this->Session->write('PrintingCenter.id', $arr['printing_center_id']); } else { if (!empty($fromSessionPrintingCenterId)) { if (!is_array($arr)) { $arr = array(); } $arr['printing_center_id'] = $fromSessionPrintingCenterId; } } App::import('Model', 'PrintingCenterAuditorBranch'); $objPrintingCenterAuditorBranch = new PrintingCenterAuditorBranch(); $options = array('conditions' => array('PrintingCenterAuditorBranch.printing_center_id' => $arr['printing_center_id'], 'PrintingCenterAuditorBranch.regular_period_id' => $this->_setRegularPeriods()), 'recursive' => 2, 'contain' => array('AuditorBranch', 'AuditorBranch.AuditorFirm')); $printingCenterAuditorBranches = $objPrintingCenterAuditorBranch->find('all', $options); $this->set('city_name', array_pop(Set::extract("/PrintingCenter[id={$arr['printing_center_id']}]/PrintedAt/city_name", $this->Session->read('Auth')))); $this->set('printing_Center_auditor_branches', $printingCenterAuditorBranches); if (isset($this->params['pagename']) && !empty($this->params['pagename'])) { $arr_file_details = explode('.', $this->params['pagename']); $title = $arr_file_details[0]; $extension = array_pop($arr_file_details); } $allowed_extensions = array('zip', 'pdf'); if (in_array($extension, $allowed_extensions)) { $download = true; if ($extension == 'pdf') { $download = false; } $this->download($title, $extension, $download); } else { $this->set('element', $title); } $tempTitle = str_replace('auth-', 'auth_', $title); $this->{$tempTitle}(); // $fetched_values = $this->DynamicPage->getPageDetails($title); // // foreach ($fetched_values as $k => $v) { // $this->set($k, $v); // } // $this->layout = $fetched_values['layout']; // $this->set('data', $fetched_values['body']); // $this->set('element', $fetched_values['element']); if ($this->RequestHandler->isAjax()) { $this->layout = 'ajax'; } }
protected static function GenerateMembershipsForIndividual(Person $objPerson, QDateTime $dttEarliestPossible, $intMembershipCount) { for ($i = 0; $i < $intMembershipCount; $i++) { $objMembership = new Membership(); $objMembership->Person = $objPerson; $dttDateStart = QDateTime::Now(); $dttDateStart = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateStart); $dttDateStart = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateStart); $dttDateStart = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateStart); $dttDateStart = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateStart); $objMembership->DateStart = $dttDateStart; $dttEarliestPossible = new QDateTime($dttDateStart); if ($i + 1 != $intMembershipCount || !rand(0, 3)) { $dttDateEnd = QDateTime::Now(); $dttDateEnd = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateEnd); $dttDateEnd = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateEnd); $dttDateEnd = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateEnd); $dttDateEnd = QDataGen::GenerateDateTime($dttEarliestPossible, $dttDateEnd); $objMembership->DateEnd = $dttDateEnd; $dttEarliestPossible = new QDateTime($dttDateEnd); $objMembership->TerminationReason = QDataGen::GenerateContent(1, 3, 10); } $objMembership->Save(); } $objPerson->RefreshMembershipStatusTypeId(); }