public function formObject() { $model = new Person($this->data->id); $this->data->forUpdate = $this->data->id != ''; $this->data->object = $model->getData(); $this->data->title = $this->data->forUpdate ? $model->getDescription() : _M("New Person"); $this->data->save = "@fnbr20/auth/person/save/" . $model->getId() . '|formObject'; $this->data->delete = "@fnbr20/auth/person/delete/" . $model->getId() . '|formObject'; $this->render(); }
/** * Create the person or find it. */ public function executeTwitterCallback(sfWebRequest $request) { $user = $this->getUser(); $this->isAuthenticated = false; if ($user->isAuthenticated() == true) { $this->isAuthenticated = true; $guardUser = $user->getGuardUser(); $guardUserId = $guardUser->getId(); $token = $user->getAttribute('sfTwitterAuth_oauth_access_token'); $secret = $user->getAttribute('sfTwitterAuth_oauth_access_token_secret'); //look for a person with this guard user id already. $q = Doctrine_Query::create()->from('Person p')->where('p.sf_guard_user_id = ?', $guardUserId); $person = $q->fetchOne(); $personTable = Doctrine_Core::getTable('Person'); $person = $personTable->findOneBy('sf_guard_user_id', $guardUserId); $this->addedPerson = false; $this->personSQLQuery = "GuardUserID={$guardUserId} " . $q->getSqlQuery(); // . "params = " . print_r($q->getParams(), true); if ($person === false) { $person = new Person(); $person->setSfGuardUserId($guardUserId); $person->setTwitterToken($token); $person->setTwitterSecret($secret); $person->save(); $this->addedPerson = true; } $personId = $person->getId(); $user->setPersonId($personId); $this->personId = $personId; $this->redirect('@homepage'); } }
function testCreate_OneToOne() { $this->_createModelAndIncludeThem('social_security', 'SocialSecurity'); $this->_createModelAndIncludeThem('person', 'Person'); $ss = new SocialSecurity(); $ss->setCode($ss_code = 42); $ss->save(); $person = new Person(); $person->setName($person_name = 'Vasya'); $person->setSocialSecurity($ss); $person->save(); $loaded_ss = lmbActiveRecord::findById('SocialSecurity', $ss->getId()); $this->assertEqual($loaded_ss->getCode(), $ss_code); $this->assertEqual($loaded_ss->getPerson()->getId(), $person->getId()); $loaded_person = lmbActiveRecord::findById('Person', $person->getId()); $this->assertEqual($loaded_person->getSocialSecurity()->getId(), $ss->getId()); }
public function id() { if ($this->exists("LOGIN-id")) { return $this->getVariable("LOGIN-id"); } else { $id = parent::getId(); $this->addVariable("LOGIN-id", $id); return $id; } }
/** * @test */ public function shouldBeAbleToCreateAndGetObjects() { // given $person = new Person(); $person->setFirstname('Alf'); $person->commit(); // when $p = new Person($person->getId()); // then $this->assertEquals('Alf', $p->getFirstname()); }
/** * Find the relationships in which the given person is a child * * @param Gedcomx\Conclusion\Person\Person $child * * @return Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship|null */ public function findChildAndParentsRelationshipTo(Person $child) { $relationships = $this->getChildAndParentsRelationships(); if ($relationships != null) { foreach ($relationships as $relation) { $personReference = $relation->getChild(); if ($personReference != null) { $reference = $personReference->getResource(); if ($reference == "#" . $child->getId()) { return $relation; } } } } return null; }
public function __construct() { session_start(); header('Content-type: text/json'); // Get the website user $userId = SessionManager::getInstance()->getUserId(); $json['result'] = 'true'; // Make sure a user is logged in if (!isset($userId)) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->session->title; $json['message'] = (string) Content::c()->errors->session->no_session; echo json_encode($json); exit; } // Validate input if (empty($_POST['introducee1Name']) || empty($_POST['introducee1FacebookId']) && empty($_POST['introducee1LinkedInId']) && empty($_POST['introducee1TwitterId']) || empty($_POST['introducee2Name']) || empty($_POST['introducee2FacebookId']) && empty($_POST['introducee2LinkedInId']) && empty($_POST['introducee2TwitterId'])) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->input->title; $json['message'] = (string) Content::c()->errors->input->introduction_not_created; echo json_encode($json); exit; } // Make sure the introducees are unique if (!empty($_POST['introducee1FacebookId']) && !empty($_POST['introducee2FacebookId']) && $_POST['introducee1FacebookId'] == $_POST['introducee2FacebookId'] || !empty($_POST['introducee1LinkedInId']) && !empty($_POST['introducee2LinkedInId']) && $_POST['introducee1LinkedInId'] == $_POST['introducee2LinkedInId'] || !empty($_POST['introducee1TwitterId']) && !empty($_POST['introducee2TwitterId']) && $_POST['introducee1TwitterId'] == $_POST['introducee2TwitterId']) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->input->title; $json['message'] = (string) Content::c()->errors->input->introduce_to_self; echo json_encode($json); exit; } // Connect to the database $db = Database::getInstance(); $introducee1 = new Person(array('name' => $_POST['introducee1Name'], 'facebookId' => !empty($_POST['introducee1FacebookId']) ? $_POST['introducee1FacebookId'] : '', 'linkedInId' => !empty($_POST['introducee1LinkedInId']) ? $_POST['introducee1LinkedInId'] : null, 'twitterId' => !empty($_POST['introducee1TwitterId']) ? $_POST['introducee1TwitterId'] : null)); $introducee2 = new Person(array('name' => $_POST['introducee2Name'], 'facebookId' => !empty($_POST['introducee2FacebookId']) ? $_POST['introducee2FacebookId'] : '', 'linkedInId' => !empty($_POST['introducee2LinkedInId']) ? $_POST['introducee2LinkedInId'] : null, 'twitterId' => !empty($_POST['introducee2TwitterId']) ? $_POST['introducee2TwitterId'] : null)); // See if the introducees are already in our database, that would be nice! if (!empty($_POST['introducee1FacebookId'])) { $introducee1->getDataFromFacebookId($_POST['introducee1FacebookId']); } elseif (!empty($_POST['introducee1LinkedInId'])) { $introducee1->getDataFromLinkedInId($_POST['introducee1LinkedInId']); } elseif (!empty($_POST['introducee1TwitterId'])) { $introducee1->getDataFromTwitterId($_POST['introducee1TwitterId']); } if (!empty($_POST['introducee2FacebookId'])) { $introducee2->getDataFromFacebookId($_POST['introducee2FacebookId']); } elseif (!empty($_POST['introducee2LinkedInId'])) { $introducee2->getDataFromLinkedInId($_POST['introducee2LinkedInId']); } elseif (!empty($_POST['introducee2TwitterId'])) { $introducee2->getDataFromTwitterId($_POST['introducee2TwitterId']); } // Make sure the introducees are still unique if ($introducee1->getFacebookId() != null && $introducee1->getFacebookId() == $introducee2->getFacebookId() || $introducee1->getLinkedInId() != null && $introducee1->getLinkedInId() == $introducee2->getLinkedInId() || $introducee1->getTwitterId() != null && $introducee1->getTwitterId() == $introducee2->getTwitterId()) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->input->title; $json['message'] = (string) Content::c()->errors->input->introduce_to_self; echo json_encode($json); exit; } // If the introducees aren't in the database yet, add them $introducee1->addToDatabase(); $introducee2->addToDatabase(); // If the introducees are on LinkedIn, add their public profile URL and picture to the DB if ($introducee1->getLinkedInId() != null || $introducee2->getLinkedInId() != null) { // Connect to LinkedIn API $sth = $db->prepare('SELECT id, access_token FROM linkedin WHERE person_id = :person_id'); $sth->execute(array(':person_id' => $userId)); $userDetails = $sth->fetch(PDO::FETCH_ASSOC); if (!empty($userDetails['access_token'])) { $linkedInAccessToken = $userDetails['access_token']; // Create LinkedIn object $API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => ''); $OBJ_linkedin = new LinkedIn($API_CONFIG); $OBJ_linkedin->setTokenAccess(unserialize($linkedInAccessToken)); // Which introducees are on LinkedIn? $profilesToRequest = array(); if ($introducee1->getLinkedInId() != null) { $profilesToRequest[] = 'id=' . $introducee1->getLinkedInId(); } if ($introducee2->getLinkedInId() != null) { $profilesToRequest[] = 'id=' . $introducee2->getLinkedInId(); } try { $linkedInProfiles = $OBJ_linkedin->profileNew('::(' . implode(',', $profilesToRequest) . '):(id,public-profile-url,picture-url)'); } catch (ErrorException $e) { } if ($linkedInProfiles['success'] === TRUE) { $linkedInProfiles['linkedin'] = new SimpleXMLElement($linkedInProfiles['linkedin']); if ($linkedInProfiles['linkedin']->getName() == 'people') { foreach ($linkedInProfiles['linkedin']->person as $person) { $id = (string) $person->id; $url = (string) $person->{'public-profile-url'}; $pic = (string) $person->{'picture-url'}; if ($id && ($url || $pic)) { $update = $db->prepare('REPLACE INTO temp_linkedin SET linkedin_id = :linkedin_id, time=NOW(), profile_url = :profile_url, picture_url = :picture_url'); $update->execute(array(':linkedin_id' => $id, ':profile_url' => $url, ':picture_url' => $pic)); } } } } } } // If the introducees are on Twitter, add their screen name and picture to the DB if ($introducee1->getTwitterId() != null || $introducee2->getTwitterId() != null) { // Which introducees are on Twitter? $profilesToRequest = array(); if ($introducee1->getTwitterId() != null) { $profilesToRequest[] = $introducee1->getTwitterId(); } if ($introducee2->getTwitterId() != null) { $profilesToRequest[] = $introducee2->getTwitterId(); } // Connect to Twitter API $sth = $db->prepare('SELECT id, access_token FROM twitter WHERE person_id = :person_id'); $sth->execute(array(':person_id' => $userId)); $userDetails = $sth->fetch(PDO::FETCH_ASSOC); if (!empty($userDetails['access_token'])) { $twitterAccessToken = unserialize($userDetails['access_token']); try { $twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']); $twitter->format = 'json'; $twitterProfiles = $twitter->get('users/lookup', array('user_id' => implode(',', $profilesToRequest))); foreach ($twitterProfiles as $friend) { $id = (string) $friend->id; $screenName = (string) $friend->screen_name; $pic = (string) $friend->profile_image_url; $protected = (string) $friend->protected; if ($id && ($screenName || $pic || $protected)) { $update = $db->prepare('REPLACE INTO temp_twitter SET twitter_id = :twitter_id, time=NOW(), screen_name = :screen_name, picture_url = :picture_url, protected = :protected'); $update->execute(array(':twitter_id' => $id, ':screen_name' => $screenName, ':picture_url' => $pic, ':protected' => $protected)); } } } catch (ErrorException $e) { // Could not post to Twitter. Bad access token? Debug::l('Error posting to Twitter ' . $e); } } } $linkPassword = BaseConvert::generatePassword(); // Add the introduction to the database $insert = $db->prepare('INSERT INTO introduction (introducer_id, introducee1_id, introducee2_id, time, link_password) VALUES (:introducer_id, :introducee1_id, :introducee2_id, NOW(), :link_password)'); $insert->execute(array(':introducer_id' => $userId, ':introducee1_id' => $introducee1->getId(), ':introducee2_id' => $introducee2->getId(), ':link_password' => $linkPassword)); $introId = $db->lastInsertId(); // Add the links for each introducee $linkPassword1 = BaseConvert::generatePassword(); $linkPassword2 = BaseConvert::generatePassword(); $insert = $db->prepare('INSERT INTO link (introduction_id, person_id, link_password) VALUES (:introduction_id, :person_id, :link_password)'); $insert->execute(array(':introduction_id' => $introId, ':person_id' => $introducee1->getId(), ':link_password' => $linkPassword1)); $insert->execute(array(':introduction_id' => $introId, ':person_id' => $introducee2->getId(), ':link_password' => $linkPassword2)); // If there is a message, add it to the database if (!empty($_POST["message"])) { $message = htmlentities(trim($_POST['message']), ENT_QUOTES, 'UTF-8'); if (!empty($message)) { $insert = $db->prepare('INSERT INTO message (body, time, introduction_id, writer_id) VALUES (:body, NOW(), :introduction_id, :writer_id)'); $insert->execute(array(':body' => $message, ':introduction_id' => $introId, ':writer_id' => $userId)); } } // Return the success message, which will tell the Javascript to redirect the user to the send-introduction page $json['result'] = 'true'; $json['link'] = APP_URL . '/' . Content::l() . '/send-introduction/'; $json['time'] = Debug::getInstance()->getTimeElapsed(); echo json_encode($json); }
try { $d = new Department($row['department']['name']); $person->setDepartment($d); } catch (Exception $e) { // We may have deleted a department that person was a member of // The person will just not get put in a department } } if (!empty($row['phone']['number'])) { $person->setPhoneNumber($row['phone']['number']); } if (!empty($row['phone']['device_id'])) { $person->setPhoneDeviceId($row['phone']['device_id']); } $person->save(); $zend_db->insert('people_crosswalk', array('person_id' => $person->getId(), 'mongo_id' => (string) $row['_id'])); echo "Person: {$person->getFullname()}\n"; } // Load the Categories $result = $mongo->categories->find(); foreach ($result as $r) { $c = new Category(); $c->setName($r['name']); $c->setDescription($r['description']); $c->setDisplayPermissionLevel($r['displayPermissionLevel']); $c->setPostingPermissionLevel($r['postingPermissionLevel']); $g = new CategoryGroup($r['group']['name']); $c->setCategoryGroup($g); $d = new Department($r['department']['name']); $c->setDepartment($d); if (!empty($r['customFields'])) {
<?php function printAllEmployees($employees) { foreach ($employees as $employee) { echo "Id : " . $employee->id . "\n" . "Name : " . $employee->name . "\n"; } } include_once "Entities\\Person.php"; include_once "Entities\\Employee.php"; include_once "Entities\\Manager.php"; include_once "Entities\\Department.php"; $ivan = new Person("vano", 111); // $ivan -> id = 111123; // $ivan -> name = "vano"; echo $ivan->getName() . "\n"; echo $ivan->getId() . "\n"; echo $ivan->__get("name") . "\n"; echo $ivan->__get("id") . "\n"; $ivanSalary = $ivan->__get("salary") . "\n"; $ivanAge = $ivan->age . "\n"; // неявно вызывает функцию __get echo "ivan has salary :" . $ivanSalary; echo "ivan has age :" . $ivanAge; $he = new Employee(); $hisResult = $he->work(true); echo "Он работал весь день и результат: " . $hisResult . "\n"; $she = new Manager(10000000); $herSalary = $she->salary; echo "Она не работала весь день и ее зарплата: " . $herSalary . "\n"; $employees = array(); $department = new Department("IT", $employees, $she);
public function executeUpdateAjaxCompanion(sfWebRequest $request) { #security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } # id parameter is companion id which then edits if ($request->hasParameter('id')) { $cmp = CompanionPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($cmp); } else { #new companion adding to existing passenger $cmpnnPid = $request->getParameter('campnn[passenger_id]'); $cmp = new Companion(); if (isset($cmpnnPid)) { $cmp->setPassengerId($cmpnnPid); } else { $cmp->setPassengerId($request->getParameter('passenger_id')); } } $this->itId = $request->getParameter('itId'); #referer if ($request->hasParameter('referer')) { $this->referer = $request->getParameter('referer'); } else { $this->referer = $request->getReferer() ? $request->getReferer() : $this->generateUrl('companion', array(), true); } $form = new CompanionForm($cmp); if ($request->getParameter('back')) { $this->back = $request->getParameter('back'); } # validate and save if ($request->isMethod('post')) { $form->bind($request->getParameter($form->getName())); if ($form->isValid()) { $is_new = $form->isNew(); if ($is_new) { $person = new Person(); $names = explode(" ", $form->getValue('name')); $person->setFirstName($names[0]); if (isset($names[1])) { $person->setLastName($names[1]); } else { $person->setLastName(NULL); } $person->setDayPhone($form->getValue('companion_phone')); $person->setDayComment($form->getValue('companion_phone_comment')); $person->save(); $comp = $form->getObject(); $comp->setName($form->getValue('name')); $comp->setRelationship($form->getValue('relationship')); $comp->setDateOfBirth($form->getValue('date_of_birth')); $comp->setWeight($form->getValue('weight')); $comp->setCompanionPhone($form->getValue('companion_phone')); $comp->setCompanionPhoneComment($form->getValue('companion_phone_comment')); $comp->setPersonId($person->getId()); $comp->save(); } else { $form->save(); } $this->getUser()->setFlash('success', 'Companion has successfully ' . ($is_new ? 'created' : 'saved') . '!'); $this->companion_saved = $form->getValue('name'); $this->companion_id = $comp->getId(); $this->relationship = $form->getValue('relationship'); } } $passenger = $cmp->getPassenger(); $this->forward404Unless($passenger); $this->passenger = $passenger; $this->form_a = $form; $this->cmp = $cmp; }
public function executeAjaxCreate(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } $this->form = new CompanionForm(); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { //---------------------------------------------- $person = new Person(); $names[] = split(" ", $this->form->getValue('name')); //echo var_dump($names); die(); $person->setFirstName($names[0][0]); $person->setLastName($names[0][1]); $person->setDayPhone($this->form->getValue('companion_phone')); $person->setDayComment($this->form->getValue('companion_phone_comment')); $person->save(); $comp = $this->form->getObject(); $comp->setPassengerId($this->form->getValue('passenger_id')); $comp->setName($this->form->getValue('name')); $comp->setRelationship($this->form->getValue('relationship')); $comp->setDateOfBirth($this->form->getValue('date_of_birth')); $comp->setWeight($this->form->getValue('weight')); $comp->setCompanionPhone($this->form->getValue('companion_phone')); $comp->setCompanionPhoneComment($this->form->getValue('companion_phone_comment')); $comp->setPersonId($person->getId()); $comp->save(); //---------------------------------------------- //$companion = $this->form->save(); $id = $comp->getId(); $name = addslashes($comp->getName()); $rel = addslashes($comp->getRelationship()); return $this->renderText("<script type=\"text/javascript\">appendCompanion({$id},'{$name}','{$rel}')</script>"); } else { $this->setTemplate('ajaxNew'); $this->el_id = $request->getParameter('el_id'); } }
/** * Signs the user in * @param Person $person * @param sfWebRequest $request */ private function signIn(Person $person, sfWebRequest $request) { $cur_user = $this->getUser(); $cur_user->setAttribute('id', $person->getId(), 'person'); $cur_user->setAttribute('username', $person->getUsername(), 'person'); $cur_user->setAttribute('firstname', $person->getFirstName(), 'person'); $cur_user->setAttribute('lastname', $person->getLastName(), 'person'); # set member and pilot ids $members = $person->getMembers(); if (isset($members[0])) { $cur_user->setAttribute('member_id', $members[0]->getId(), 'person'); $pilot = $members[0]->getPilot(); if ($pilot) { $cur_user->setAttribute('pilot_id', $pilot->getId(), 'person'); } } /* Custom Code - Ziyed and Aftab */ $cur_user_roles = array(); $query = "select role_id from afids.person_role where person_role.person_id ='" . $person->getId() . "'"; $conn = Propel::getConnection(); $statement = $conn->prepare($query); $statement->execute(); while ($row = $statement->fetch()) { $cur_user_roles[] = $row['role_id']; } ///////Ziyed do credential////// $warnings = array(); if (array_intersect($cur_user_roles, array(1, 2, 26))) { $cur_user->addCredential('Administrator'); } elseif (array_intersect($cur_user_roles, array(3, 4, 28))) { $cur_user->addCredential('Staff'); } elseif (array_intersect($cur_user_roles, array(7, 24, 25, 29))) { $cur_user->addCredential('Coordinator'); } else { if (array_intersect($cur_user_roles, array(31, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23))) { if (isset($members[0]) && $members[0] instanceof Member) { $cur_user->addCredential('Member'); } else { $warnings[] = 'You are a member but you don\'t have proper database record'; } } elseif (array_intersect($cur_user_roles, array(30))) { $cur_user->addCredential('Volunteer'); } elseif (array_intersect($cur_user_roles, array(5, 6, 27))) { if (isset($pilot) && $pilot instanceof Pilot) { $cur_user->addCredential('Pilot'); } else { $warnings[] = 'You are a pilot but you don\'t have proper database record'; } } else { $warnings[] = 'you don\'t have proper database record'; if (count($warnings)) { $this->getUser()->setFlash('warning', implode(". ", $warnings)); } $this->redirect('/'); } } //////Ziyed end $cur_user->setAuthenticated(true); /* End of Custom Code - Ziyed and Aftab */ # add credentials /* $warnings = array(); $person_roles = $person->getPersonRolesJoinRole(); foreach ($person_roles as $person_role) { $credential = $person_role->getRole()->getTitle(); //if ($credential == '@Pilot'){ if ($credential == 'Pilot'){ // @Pilot role can be assigned only if current user has Pilot record set if (isset($pilot) && ($pilot instanceof Pilot)) { $cur_user->addCredential($credential); }else{ $warnings[] = 'You are a pilot but you don\'t have proper database record'; } }elseif ($credential == 'Member'){ // @Member role can be assigned only if current user has Member record set if (isset($members[0]) && ($members[0] instanceof Member)) { $cur_user->addCredential($credential); }else{ $warnings[] = 'You are a member but you don\'t have proper database record'; } }else{ $cur_user->addCredential($credential); } }*/ if (count($warnings)) { $this->getUser()->setFlash('warning', implode(". ", $warnings)); } }
/** * {@inheritdoc} */ protected function assertPreConditions() { $this->assertInstanceOf('JLM\\ContactBundle\\Model\\CompanyInterface', $this->entity); $this->assertNull($this->entity->getId()); $this->assertCount(0, $this->entity->getContacts()); }
protected function processStep3Check(sfWebRequest $request) { $default_airport = AirportPeer::getByIdent(sfConfig::get('app_default_airport_ident')); $this->forward404Unless($default_airport); $app = $this->application_temp; $person = $this->person; if (!$person instanceof Person) { $person = new Person(); } /* @var $app ApplicationTemp */ /* @var $person Person */ // Person $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['evening_phone'] = $tmp_arr['eve_phone']; $tmp_arr['evening_comment'] = $tmp_arr['eve_comment']; unset($tmp_arr['id']); $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $person->save(); // Member $member = MemberPeer::getByPersonId($person->getId()); if (!$member instanceof Member) { $member = new Member(); } // Generate external id using last member is and external id $c = new Criteria(); $c->add(MemberPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL); $c->addDescendingOrderByColumn(MemberPeer::ID); $external_member = MemberPeer::doSelectOne($c); $external_id = $external_member->getExternalId(); $currentExternalId = $external_id + 1; //print_r($external_id); //print_r($currentExternalId); $member->setActive(1); $member->setCoPilot($app->getApplicantCopilot()); $member->setContact('By Email'); $member->setDateOfBirth($app->getDateOfBirth()); $member->setDriversLicenseState($app->getDriversLicenseState()); $member->setDriversLicenseNumber($app->getDriversLicenseNumber()); $member->setEmergencyContactName($app->getEmergencyContactName()); $member->setEmergencyContactPhone($app->getEmergencyContactPhone()); $member->setFlightStatus($app->getApplicantPilot() ? 'Verify Orientation' : 'Non-pilot'); $member->setJoinDate(time()); $member->setLanguages($app->getLanguagesSpoken()); //$member->setMasterMemberId($app->getMasterMemberId()); $member->setMemberClassId($app->getMemberClassId()); $member->setPersonId($person->getId()); $member->setRenewedDate(time()); $member->setRenewalDate(strtotime('+1 year')); $member->setSpouseName($app->getSpouseFirstName() . ' ' . $app->getSpouseLastName()); //external_id generate $member->setExternalId($currentExternalId); $member->setWingId($app->getWingId()); $member->save(); // Pilot if ($app->getApplicantPilot()) { $pilot = new Pilot(); $pilot->setMemberId($member->getId()); $airport = AirportPeer::getByIdent($app->getHomeBase()); if (!$airport instanceof Airport) { $airport = $default_airport; } $pilot->setPrimaryAirportId($airport->getId()); $pilot->setTotalHours($app->getTotalHours()); $pilot->setLicenseType('Private'); foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setLicenseType($key); } } $pilot->setIfr(stripos($app->getRatings(), 'ifr') !== false ? 1 : 0); $pilot->setMultiEngine(stripos($app->getRatings(), 'multi') !== false ? 1 : 0); $pilot->setSeInstructor('No'); // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setSeInstructor($key); } } $pilot->setMeInstructor($pilot->getSeInstructor()); $pilot->save(); // Availability $availability = new Availability(); $availability->setMemberId($member->getId()); $availability->setNotAvailable(0); $availability->setNoWeekday($app->getAvailabilityWeekdays() == 0); $availability->setNoNight($app->getAvailabilityWeeknights() == 0); $availability->setLastMinute($app->getAvailabilityLastMinute()); $availability->setAsMissionMssistant($app->getAvailabilityCopilot()); $availability->setNoWeekend($app->getAvailabilityWeekends() == 0); try { $availability->save(); } catch (Exception $e) { } // Primary aircraft if ($app->getAircraftPrimaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftPrimaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftPrimaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftPrimaryOwn()); $pilot_aircraft->setSeats($app->getAircraftPrimarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftPrimaryIce()); $pilot_aircraft->save(); } // Secondary aircraft if ($app->getAircraftSecondaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftSecondaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftSecondaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftSecondaryOwn()); $pilot_aircraft->setSeats($app->getAircraftSecondarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftSecondaryIce()); $pilot_aircraft->save(); } // Third aircraft if ($app->getAircraftThirdId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftThirdId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftThirdNNumber()); $pilot_aircraft->setOwn($app->getAircraftThirdOwn()); $pilot_aircraft->setSeats($app->getAircraftThirdSeats()); $pilot_aircraft->setKnownIce($app->getAircraftThirdIce()); $pilot_aircraft->save(); } } // Application_temp $app->setPersonId($person->getId()); $app->setMemberId($member->getId()); $app->setProcessedDate(time()); $app->save(); // Application $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['date'] = $tmp_arr['application_date']; $tmp_arr['company'] = $tmp_arr['company_name']; foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['license_type'] = $key; } } $tmp_arr['ifr'] = stripos($tmp_arr['ratings'], 'ifr') !== false ? 1 : 0; $tmp_arr['multi_engine'] = stripos($tmp_arr['ratings'], 'multi') !== false ? 1 : 0; $tmp_arr['se_instructor'] = 'No'; // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['se_instructor'] = $key; } } $tmp_arr['me_instructor'] = $tmp_arr['se_instructor']; $tmp_arr['other_ratings'] = $tmp_arr['ratings']; $tmp_arr['fbo'] = $tmp_arr['fbo_name']; $tmp_arr['member_meetings'] = 0; $tmp_arr['executive_board'] = 0; $tmp_arr['dues_amount_paid'] = $tmp_arr['dues_amount_paid'] ? $tmp_arr['dues_amount_paid'] : 0; unset($tmp_arr['id']); $application = new Application(); $application->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $application->save(); $where = $request->getParameter('step3_redirect'); //Ziyed save default role for new member $appTemp = $this->application_temp; if ($appTemp->getPersonId()) { $person_role = new PersonRole(); $person_role->setPersonId($appTemp->getPersonId()); if ($appTemp->getApplicantPilot() == 1) { $person_role->setRoleId(27); } else { $person_role->setRoleId(31); } $person_role->save(); } //Ziyed end save if ($where == 1) { $this->redirect('@member_view?id=' . $member->getId()); } else { /* if ($application->getEmail()) { # send email failure to payment $this->getComponent('mail', 'memberApplicationProcessed', array('email' => $application->getEmail(),'member_id'=>$member->getId(), 'name' => $application->getFirstName() . ' ' . $application->getLastName())); }*/ $this->redirect('pending_member/processComplete?id=' . $member->getId()); } }
private function getPersonWithPhone($firstname = '', $phoneNumbers = array()) { $person = new Person(); $person->setFirstname($firstname); $this->createCity(); $person->setZip(4330); $person->commit(); $id = $person->getId(); foreach ($phoneNumbers as $number) { $this->addPhone($id, $number); } return new Person($id); }
/** * Update one Person in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Person $Person The Person to update * @return boolean If was possible to update */ static function updatePerson($Person = null) { if ($Person === null) { return false; } $tablePerson = DatabaseManager::getNameTable('TABLE_PERSON'); $id = $Person->getId(); $names = $Person->getNames(); $lastname1 = $Person->getLastname1(); $lastname2 = $Person->getLastname2(); $gender = $Person->getGender(); $address = $Person->getAddress(); $phoneNumber = $Person->getPhoneNumber(); $Person->getIdFather() == 0 ? $idFather = 'null' : ($idFather = $Person->getIdFather()); $Person->getIdMother() == 0 ? $idMother = 'null' : ($idMother = $Person->getIdMother()); $idCityAddress = $Person->getIdCityAddress(); if ($idCityAddress === NULL) { $idCityAddress = 'NULL'; } $query = "UPDATE {$tablePerson}\n SET names = '{$names}', \n lastname1 = '{$lastname1}', \n lastname2 = '{$lastname2}', \n gender = '{$gender}', \n address = '{$address}', \n phoneNumber = '{$phoneNumber}', \n idFather = {$idFather}, \n idMother = {$idMother}, \n idCityAddress = {$idCityAddress}\n WHERE {$tablePerson}.id = {$id}"; return DatabaseManager::singleAffectedRow($query); }
public function assignPageContent(\phpQueryObject $_) { $this->setSynopsis(trim($_['p[itemprop=description]']->text())); if ($duration = $_['[itemprop=duration]']->attr('datetime')) { $this->setLength(new \DateInterval($duration)); } $this->setRating((double) $_['[itemprop=ratingValue]']->text()); $this->setTitle(trim($_['h1 [itemprop=name]']->text())); $this->setVotes((int) preg_replace('/[^\\d]+/', '', $_['[itemprop=ratingCount]']->text())); $this->setPosterUri($_['img[itemprop=image]']->attr('src')); $this->setDatePublished(\DateTime::createFromFormat('Y-m-d', $_['.infobar [itemprop="datePublished"]']->attr('content'))); $g = []; foreach ($_['.infobar [itemprop=genre]'] as $genre) { $g[] = pq($genre)->text(); } $this->setGenres($g); foreach ($_['#title-overview-widget [itemtype="http://schema.org/Person"][itemprop!=actors]'] as $x) { $x = pq($x); foreach ($x['a[itemprop=url]'] as $p) { $p = pq($p); $person = new Person(); $person->setId(preg_replace('@^.*(nm\\d+).*@', '$1', $p->attr('href'))); $person->setName($p->text()); if (!isset($this->_people[$x->attr('itemprop')])) { $this->_people[$x->attr('itemprop')] = []; } $this->_people[$x->attr('itemprop')][$person->getId()] = $person; } } // Casting if (!isset($this->_people['actors'])) { $this->_people['actors'] = []; } foreach ($_['table.cast_list tr:has([itemprop=name])'] as $p) { $p = pq($p); $actor = new Actor(); $actor->setId(preg_replace('@^.*(nm\\d+).*@', '$1', $p['[itemprop=url]']->attr('href'))); $actor->setName($p['[itemprop=name]']->text()); $actor->setCharacter($p['a[href^=/character]']->text()); $this->_people['actors'][$actor->getId()] = $actor; } }
/** * @param Person $person * @return int */ public function countPersonClothes(Person $person) { return count($this->clothes[$person->getId()]); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Person $value A Person object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Person $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Declares an association between this object and a Person object. * * @param Person $v * @return PersonalNote The current object (for fluent API support) * @throws PropelException */ public function setPerson(Person $v = null) { if ($v === null) { $this->setPersonId(NULL); } else { $this->setPersonId($v->getId()); } $this->aPerson = $v; // Add binding for other direction of this 1:1 relationship. if ($v !== null) { $v->setPersonalNote($this); } return $this; }
protected function processStep2Check(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $form->save(); } $app = $this->application_temp; $person = $this->person; if (!$person instanceof Person) { $person = new Person(); } /* @var $app ContactRequest */ /* @var $person Person */ // Person $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['evening_phone'] = $tmp_arr['eve_phone']; $tmp_arr['evening_comment'] = $tmp_arr['eve_comment']; $tmp_arr['fax_phone1'] = $tmp_arr['fax_phone']; $tmp_arr['fax_comment1'] = $tmp_arr['fax_comment']; unset($tmp_arr['id']); $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $person->save(); // Contact $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['letter_sent'] = $tmp_arr['letter_sent_date']; unset($tmp_arr['id']); $contact = new Contact(); $contact->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $contact->setPersonId($person->getId()); $contact->save(); // ContactRequest $app->setPersonId($person->getId()); $app->setProcessed(1); $app->save(); $this->redirect('contact/processComplete?id=' . $contact->getId()); }
protected function processStep3Check(sfWebRequest $request) { $default_airport = AirportPeer::getByIdent(sfConfig::get('app_default_airport_ident')); $this->forward404Unless($default_airport); $app = $this->application_temp; $person = $this->person; if (!$person instanceof Person) { $person = new Person(); } /* @var $app ApplicationTemp */ /* @var $person Person */ // Person $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['evening_phone'] = $tmp_arr['eve_phone']; $tmp_arr['evening_comment'] = $tmp_arr['eve_comment']; unset($tmp_arr['id']); $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $person->save(); // Member $member = MemberPeer::retrieveByPK($app->getMemberId()); if (!$member instanceof Member) { $member = new Member(); } $member->setActive(1); $member->setCoPilot($app->getApplicantCopilot()); $member->setContact('By Email'); $member->setDateOfBirth($app->getDateOfBirth()); $member->setDriversLicenseState($app->getDriversLicenseState()); $member->setDriversLicenseNumber($app->getDriversLicenseNumber()); $member->setEmergencyContactName($app->getEmergencyContactName()); $member->setEmergencyContactPhone($app->getEmergencyContactPhone()); $member->setFlightStatus($app->getApplicantPilot() ? 'Verify Orientation' : 'Non-pilot'); //$member->setJoinDate(time()); $member->setLanguages($app->getLanguagesSpoken()); //Farazi //$member->setMasterMemberId($app->getMasterMemberId()); // Get Last renewal date $this->member = MemberPeer::retrieveByPK($app->getMemberId()); $lastRenewalDate = strtotime($this->member->getRenewalDate()); $member->setMemberClassId($app->getMemberClassId()); $member->setPersonId($person->getId()); $member->setRenewedDate(time()); ///Farazi Renewal Date From Memberclass if ($app->getMemberClassId()) { $memclass = MemberClassPeer::retrieveByPK($app->getMemberClassId()); $renewal_period = $memclass->getRenewalPeriod(); $renewalTime = strtotime('+' . $renewal_period . ' month', $lastRenewalDate); //echo $renewalTime; $member->setRenewalDate($renewalTime); //$member->setRenewalDate(strtotime('+'.$renewal_period.' month')); } // Farazi End //$member->setRenewalDate(strtotime('+1 year')); $member->setSpouseName($app->getSpouseFirstName() . ' ' . $app->getSpouseLastName()); $member->setWeight($app->getWeight()); $member->setWingId($app->getWingId()); $member->save(); // Pilot if ($app->getApplicantPilot()) { $pilot = $member->getPilot(); if (!$pilot instanceof Pilot) { $pilot = new Pilot(); } if ($pilot->isNew()) { // remove aircrafts foreach ($member->getPilotAircrafts() as $p_a) { PilotAircraftPeer::doDelete($p_a); } } $pilot->setMemberId($member->getId()); $airport = AirportPeer::getByIdent($app->getHomeBase()); if (!$airport instanceof Airport) { $airport = $default_airport; } $pilot->setPrimaryAirportId($airport->getId()); $pilot->setTotalHours($app->getTotalHours()); $pilot->setLicenseType('Private'); foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setLicenseType($key); } } $pilot->setIfr(stripos($app->getRatings(), 'ifr') !== false ? 1 : 0); $pilot->setMultiEngine(stripos($app->getRatings(), 'multi') !== false ? 1 : 0); $pilot->setSeInstructor('No'); // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setSeInstructor($key); } } $pilot->setMeInstructor($pilot->getSeInstructor()); $pilot->save(); // Availability $availability = $member->getAvailability(); if (!$availability instanceof Availability) { $availability = new Availability(); } $availability->setMemberId($member->getId()); $availability->setNotAvailable(0); $availability->setNoWeekday($app->getAvailabilityWeekdays() == 0); $availability->setNoNight($app->getAvailabilityWeeknights() == 0); $availability->setLastMinute($app->getAvailabilityLastMinute()); $availability->setAsMissionMssistant($app->getAvailabilityCopilot()); $availability->setNoWeekend($app->getAvailabilityWeekends() == 0); $availability->save(); //Farazi //Delete all aircrafts $pilot_aircrafts = PilotAircraftPeer::getByMemberId($member->getId()); foreach ($pilot_aircrafts as $pilot_aircraft) { $pilot_aircraft->delete(); } // Primary aircraft if ($app->getAircraftPrimaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftPrimaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftPrimaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftPrimaryOwn()); $pilot_aircraft->setSeats($app->getAircraftPrimarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftPrimaryIce()); $pilot_aircraft->save(); } // Secondary aircraft if ($app->getAircraftSecondaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftSecondaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftSecondaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftSecondaryOwn()); $pilot_aircraft->setSeats($app->getAircraftSecondarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftSecondaryIce()); $pilot_aircraft->save(); } // Third aircraft if ($app->getAircraftThirdId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftThirdId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftThirdNNumber()); $pilot_aircraft->setOwn($app->getAircraftThirdOwn()); $pilot_aircraft->setSeats($app->getAircraftThirdSeats()); $pilot_aircraft->setKnownIce($app->getAircraftThirdIce()); $pilot_aircraft->save(); } } // Application_temp $app->setPersonId($person->getId()); $app->setMemberId($member->getId()); $app->setProcessedDate(time()); $app->save(); // Application $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['date'] = $tmp_arr['application_date']; $tmp_arr['company'] = $tmp_arr['company_name']; foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['license_type'] = $key; } } $tmp_arr['ifr'] = stripos($tmp_arr['ratings'], 'ifr') !== false ? 1 : 0; $tmp_arr['multi_engine'] = stripos($tmp_arr['ratings'], 'multi') !== false ? 1 : 0; $tmp_arr['se_instructor'] = 'No'; // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['se_instructor'] = $key; } } $tmp_arr['me_instructor'] = $tmp_arr['se_instructor']; $tmp_arr['other_ratings'] = $tmp_arr['ratings']; $tmp_arr['fbo'] = $tmp_arr['fbo_name']; $tmp_arr['member_meetings'] = 0; $tmp_arr['executive_board'] = 0; $tmp_arr['dues_amount_paid'] = $tmp_arr['dues_amount_paid'] ? $tmp_arr['dues_amount_paid'] : 0; $tmp_arr['donation_amount_paid'] = $tmp_arr['donation_amount_paid'] ? $tmp_arr['donation_amount_paid'] : 0; unset($tmp_arr['id']); $application = new Application(); $application->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $application->save(); $this->getUser()->setFlash('success', 'Membership renewal completed successfully.'); //$this->redirect('renewal/processComplete?id='.$member->getId()); $this->redirect('renewal/processStep3?id=' . $this->application_temp->getId()); //$this->redirect('renewal/index?id='.$member->getId()); }
/** * Exclude object from result * * @param Person $person Object to remove from the list of results * * @return PersonQuery The current query, for fluid interface */ public function prune($person = null) { if ($person) { $this->addUsingAlias(PersonPeer::ID, $person->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * @test */ public function shouldBeAbleToDeleteRecord() { // given $p = new Person(); $p->setFirstname('John'); $p->commit(); // when $p2 = new Person($p->getId()); $id = $p2->getId(); $p2->delete(); $p3 = new Person($p->getId()); // then $this->assertEquals(null, $p2->getId()); $this->assertEquals(null, $p3->getId()); }
public function executeStepSave(sfWebRequest $request) { $passenger_session_step5 = $this->getUser()->getAttribute('passangers_step5'); if (!$passenger_session_step5) { return $this->forward('passanger', 'step5_4'); } //save Person data $person = new Person(); $person->setTitle($passenger_session_step5['title']); $person->setFirstName($passenger_session_step5['firstname']); $person->setLastName($passenger_session_step5['lastname']); $person->setAddress1($passenger_session_step5['address1']); $person->setAddress2($passenger_session_step5['address2']); $person->setCity($passenger_session_step5['city']); $person->setCounty($passenger_session_step5['county']); $person->setState($passenger_session_step5['state']); $person->setCountry($passenger_session_step5['country']); $person->setZipcode($passenger_session_step5['zipcode']); $person->setDayPhone($passenger_session_step5['day_phone']); $person->setDayComment($passenger_session_step5['day_comment']); $person->setEveningPhone($passenger_session_step5['eve_phone']); $person->setEveningComment($passenger_session_step5['eve_comment']); $person->setMobilePhone($passenger_session_step5['mobile_phone']); $person->setMobileComment($passenger_session_step5['mobile_comment']); $person->setPagerPhone($passenger_session_step5['pager_phone']); $person->setPagerComment($passenger_session_step5['pager_comment']); $person->setOtherPhone($passenger_session_step5['other_comment']); $person->setOtherComment($passenger_session_step5['other_comment']); $person->setFaxPhone1($passenger_session_step5['fax_phone1']); $person->setFaxComment1($passenger_session_step5['fax_comment1']); $person->setAutoFax($passenger_session_step5['auto_fax']); $person->setFaxPhone2($passenger_session_step5['fax_phone2']); $person->setFaxComment2($passenger_session_step5['fax_comment2']); $person->setEmail($passenger_session_step5['email']); $person->setEmailTextOnly($passenger_session_step5['textonly']); $person->setEmailBlocked($passenger_session_step5['emailblocked']); $person->setComment($passenger_session_step5['comment']); $person->setBlockMailings($passenger_session_step5['blockmailings']); $person->setNewsletter($passenger_session_step5['newsletter']); $person->setGender($passenger_session_step5['gender']); $person->setDeceased($passenger_session_step5['deceased']); $person->setDeceasedComment($passenger_session_step5['deceased_comment']); $person->setSecondaryEmail($passenger_session_step5['secemail']); $person->setDeceasedDate($passenger_session_step5['deceased_date']); $person->setMiddleName($passenger_session_step5['middlename']); $person->setSuffix($passenger_session_step5['suffix']); $person->setNickname($passenger_session_step5['nickname']); $person->setVeteran($passenger_session_step5['military']); $person->save(); //save Passenger data $passenger = new Passenger(); $passenger->setPersonId($person->getId()); if ($passenger_session_step5['passenger_type_id'] == 0) { $passenger->setPassengerTypeId(null); } else { $passenger->setPassengerTypeId($passenger_session_step5['passenger_type_id']); } $passenger->setParent($passenger_session_step5['parent']); $passenger->setDateOfBirth($passenger_session_step5['date_of_birth']); $passenger->setWeight($passenger_session_step5['weight']); $passenger->setIllness($passenger_session_step5['illness']); $passenger->setPassengerIllnessCategoryId($passenger_session_step5['passenger_illness_category_id']); $passenger->setLanguageSpoken($passenger_session_step5['language_spoken']); $passenger->setBestContactMethod($passenger_session_step5['best_contact_method']); $passenger->setFinancial($passenger_session_step5['facility_name']); $passenger->setPublicConsiderations($passenger_session_step5['public_considerations']); $passenger->setPrivateConsiderations($passenger_session_step5['private_considerations']); $passenger->setGroundTransportationComment($passenger_session_step5['ground_transportation_comment']); $passenger->setTravelHistoryNotes($passenger_session_step5['travel_history_notes']); $passenger->setReleasingPhysician($passenger_session_step5['releasing_physician']); $passenger->setReleasingPhone($passenger_session_step5['releasing_phone']); $passenger->setReleasingFax1($passenger_session_step5['releasing_fax1']); $passenger->setReleasingFax1Comment($passenger_session_step5['releasing_fax1_comment']); $passenger->setReleasingEmail($passenger_session_step5['releasing_email']); $passenger->setNeedMedicalRelease($passenger_session_step5['need_medical_release']); $passenger->setMedicalReleaseRequested($passenger_session_step5['medical_release_requested']); $passenger->setMedicalReleaseReceived($passenger_session_step5['medical_release_received']); $passenger->setTreatingPhysician($passenger_session_step5['treating_physician']); $passenger->setTreatingPhone($passenger_session_step5['treating_phone']); $passenger->setTreatingFax1($passenger_session_step5['treating_fax1']); $passenger->setTreatingFax1Comment($passenger_session_step5['treating_fax1_comment']); $passenger->setTreatingEmail($passenger_session_step5['treating_email']); $passenger->setLanguageSpoken($passenger_session_step5['language_spoken']); $passenger->setLodgingPhone($passenger_session_step5['lodging_phone']); $passenger->setLodgingPhoneComment($passenger_session_step5['lodging_phone_comment']); $passenger->setFacilityName($passenger_session_step5['facility_name']); $passenger->setFacilityPhone($passenger_session_step5['facility_phone']); $passenger->setFacilityPhoneComment($passenger_session_step5['facility_phone_comment']); $passenger->setEmergencyContactName($passenger_session_step5['emergency_contact_name']); $passenger->setEmergencyContactPrimaryPhone($passenger_session_step5['emergency_contact_primary_phone']); $passenger->setEmergencyContactPrimaryComment($passenger_session_step5['emergency_contact_primary_comment']); $passenger->setEmergencyContactSecondaryPhone($passenger_session_step5['emergency_contact_secondary_phone']); $passenger->setEmergencyContactSecondaryComment($passenger_session_step5['emergency_contact_secondary_comment']); $passenger->save(); $key = $passenger_session_step5['key']; $this->getUser()->setFlash('success', 'Passenger information has been successfully created!'); $this->redirect('@passenger'); //removing used session like passenger data unset($passenger_session_step5p[$key]); $this->getUser()->setAttribute('passanger_step5', $passenger_session_step5); }
<?php /** * @copyright 2013 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @author Cliff Ingham <*****@*****.**> */ include '../configuration.inc'; // We want to find all tickets, not just the ones that are public. // This can only be done with a logged in user, which we don't have // when this is run from the CRON. // Instead, we create a Mock user with Admin privileges. $_SESSION['USER'] = new Person(); $_SESSION['USER']->setRole('Administrator'); $zend_db = Database::getConnection(); $sql = "select distinct assignedPerson_id\n\t\tfrom tickets\n\t\twhere status='open'"; $ids = $zend_db->fetchCol($sql); foreach ($ids as $id) { $person = new Person($id); $tickets = new TicketList(); $tickets->find(array('assignedPerson_id' => $person->getId(), 'status' => 'open'), 't.enteredDate'); $template = new Template('email', 'txt'); $template->blocks[] = new Block('notifications/digestNotification.inc', array('person' => $person)); $template->blocks[] = new Block('tickets/ticketList.inc', array('ticketList' => $tickets, 'title' => 'Outstanding cases', 'disableButtons' => true)); $text = $template->render(); $count = count($tickets); $person->sendNotification($text, "{$count} open cases in " . APPLICATION_NAME); }
/** * missionRequests save all data into corresponding tables * CODE:mission_request_create */ public function executeSave(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } $miss_req_session = $this->getUser()->getAttribute('miss_req'); if (!$miss_req_session) { return $this->forward('passenger', 'step3'); } //set Requester Person $req_person = new Person(); $req_person->setFirstName($miss_req_session->getReqFirstname()); $req_person->setLastName($miss_req_session->getReqLastname()); $req_person->setAddress1($miss_req_session->getReqAddress1()); $req_person->setAddress2($miss_req_session->getReqAddress2()); $req_person->setCity($miss_req_session->getReqCity()); $req_person->setCounty($miss_req_session->getReqCounty()); $req_person->setState($miss_req_session->getReqState()); $req_person->setCountry($miss_req_session->getReqCountry()); $req_person->setZipcode($miss_req_session->getReqZipcode()); $req_person->setEmail($miss_req_session->getReqEmail()); $req_person->setSecondaryEmail($miss_req_session->getReqSecondaryEmail()); $req_person->setPagerEmail($miss_req_session->getReqPagerEmail()); $req_person->setDayPhone($miss_req_session->getReqDayPhone()); $req_person->setDayComment($miss_req_session->getReqDayComment()); $req_person->setEveningPhone($miss_req_session->getReqEvePhone()); $req_person->setEveningComment($miss_req_session->getReqEveComment()); $req_person->setMobilePhone($miss_req_session->getReqMobilePhone()); $req_person->setMobileComment($miss_req_session->getReqMobileComment()); $req_person->setPagerPhone($miss_req_session->getReqPagerPhone()); $req_person->setPagerComment($miss_req_session->getReqPagerComment()); $req_person->setOtherPhone($miss_req_session->getReqOtherPhone()); $req_person->setOtherComment($miss_req_session->getReqOtherComment()); $req_person->save(); //end of Requester Person // set Requester Agency $agency = AgencyPeer::getByNamePhone(trim($miss_req_session->getAgencyName())); if ($agency) { # nothing } else { $agency = new Agency(); $agency->setName(trim($miss_req_session->getAgencyName())); $agency->save(); } //set Requester $requester = new Requester(); $requester->setPersonId($req_person->getId()); $requester->setAgencyId($agency->getId()); //$requester->setDischarge($miss_req_session->getReqDischarge()); $requester->save(); if (isset($miss_req_session->passenger_id)) { $passenger = PassengerPeer::retrieveByPK($miss_req_session->passenger_id); if (!$passenger instanceof Passenger) { $passenger = new Passenger(); } } else { $passenger = new Passenger(); } if ($passenger->isNew()) { $person = new Person(); } else { $person = $passenger->getPerson(); } //set Person to Passenger $person->setTitle($miss_req_session->getPassTitle()); $person->setFirstName($miss_req_session->getPassFirstName()); $person->setLastName($miss_req_session->getPassLastName()); $person->setGender($miss_req_session->getPassGender()); $person->setAddress1($miss_req_session->getPassAddress1()); $person->setAddress2($miss_req_session->getPassAddress2()); $person->setCity($miss_req_session->getPassCity()); $person->setState($miss_req_session->getPassState()); $person->setZipcode($miss_req_session->getPassZipcode()); $person->setCountry($miss_req_session->getPassCountry()); $person->setEmail($miss_req_session->getPassEmail()); $person->setDayPhone($miss_req_session->getPassDayPhone()); $person->setDayComment($miss_req_session->getPassDayComment()); $person->setEveningPhone($miss_req_session->getPassEvePhone()); $person->setEveningComment($miss_req_session->getPassEveComment()); $person->setMobilePhone($miss_req_session->getPassMobilePhone()); $person->setMobileComment($miss_req_session->getPassMobileComment()); $person->setPagerPhone($miss_req_session->getPassPagerPhone()); $person->setPagerComment($miss_req_session->getPassPagerComment()); $person->setOtherPhone($miss_req_session->getPassOtherPhone()); $person->setOtherComment($miss_req_session->getPassOtherComment()); $person->save(); //set Passenger $passenger->setPersonId($person->getId()); $passenger->setPassengerTypeId($miss_req_session->getPassType()); $passenger->setDateOfBirth($miss_req_session->getPassDateOfBirth()); $passenger->setIllness($miss_req_session->getIllness()); $passenger->setFinancial($miss_req_session->getFinancial()); $passenger->setPublicConsiderations($miss_req_session->getPassPublicCons()); $passenger->setPrivateConsiderations($miss_req_session->getPassPrivateCons()); $passenger->setReleasingPhysician($miss_req_session->getReleasingPhysician()); $passenger->setReleasingPhone($miss_req_session->getReleasePhone()); $passenger->setReleasingFax1($miss_req_session->getReleaseFax()); $passenger->setReleasingFax1Comment($miss_req_session->getReleaseFaxComment()); $passenger->setLodgingName($miss_req_session->getLodgingName()); $passenger->setLodgingPhone($miss_req_session->getLodgingPhone()); $passenger->setLodgingPhoneComment($miss_req_session->getLodgingPhoneComment()); $passenger->setFacilityName($miss_req_session->getFacilityName()); $passenger->setFacilityPhone($miss_req_session->getFacilityPhone()); $passenger->setFacilityPhoneComment($miss_req_session->getFacilityPhoneComment()); $passenger->setReleasingEmail($miss_req_session->getReleaseEmail()); $passenger->setTreatingPhysician($miss_req_session->getTreatingPhysician()); $passenger->setTreatingPhone($miss_req_session->getTreatingPhone()); $passenger->setTreatingFax1($miss_req_session->getTreatingFax()); $passenger->setTreatingFax1Comment($miss_req_session->getTreatingFaxComment()); $passenger->setTreatingEmail($miss_req_session->getTreatingEmail()); $passenger->setLanguageSpoken($miss_req_session->getPassLanguage()); $passenger->setBestContactMethod($miss_req_session->getBestContact()); $passenger->setEmergencyContactName($miss_req_session->getEmergencyName()); $passenger->setEmergencyContactPrimaryPhone($miss_req_session->getEmergencyPhone1()); $passenger->setEmergencyContactPrimaryComment($miss_req_session->getEmergencyPhone1Comment()); $passenger->setEmergencyContactSecondaryPhone($miss_req_session->getEmergencyPhone2()); $passenger->setEmergencyContactSecondaryComment($miss_req_session->getEmergencyPhone2Comment()); $passenger->setNeedMedicalRelease($miss_req_session->getPassMedical()); $passenger->save(); //set Companions if ($passenger && $miss_req_session->getCom1Name()) { $person = new Person(); $names[] = split(" ", $miss_req_session->getCom1Name()); //echo var_dump($names); die(); $person->setFirstName($names[0][0]); $person->setLastName($names[0][1]); $person->setDayPhone($miss_req_session->getCom1Phone()); $person->setDayComment($miss_req_session->getCom1Comment()); $person->save(); $companion = new Companion(); $companion->setPassengerId($passenger->getId()); $companion->setName($miss_req_session->getCom1Name()); $companion->setRelationship($miss_req_session->getCom1Relationship()); $companion->setDateOfBirth($miss_req_session->getCom1DateOfBirth()); $companion->setWeight($miss_req_session->getCom1Weigth()); $companion->setCompanionPhone($miss_req_session->getCom1Phone()); $companion->setCompanionPhoneComment($miss_req_session->getCom1Comment()); $companion->setPersonId($person->getId()); $companion->save(); } if ($passenger && $miss_req_session->getCom2Name()) { $person = new Person(); $names[] = split(" ", $miss_req_session->getCom2Name()); //echo var_dump($names); die(); $person->setFirstName($names[0][0]); $person->setLastName($names[0][1]); $person->setDayPhone($miss_req_session->getCom2Phone()); $person->setDayComment($miss_req_session->getCom2Comment()); $person->save(); $companion = new Companion(); $companion->setPassengerId($passenger->getId()); $companion->setName($miss_req_session->getCom2Name()); $companion->setRelationship($miss_req_session->getCom2Relationship()); $companion->setDateOfBirth($miss_req_session->getCom2DateOfBirth()); $companion->setWeight($miss_req_session->getCom2Weigth()); $companion->setCompanionPhone($miss_req_session->getCom2Phone()); $companion->setCompanionPhoneComment($miss_req_session->getCom2Comment()); $companion->setPersonId($person->getId()); $companion->save(); } if ($passenger && $miss_req_session->getCom3Name()) { $person = new Person(); $names[] = split(" ", $miss_req_session->getCom3Name()); //echo var_dump($names); die(); $person->setFirstName($names[0][0]); $person->setLastName($names[0][1]); $person->setDayPhone($miss_req_session->getCom3Phone()); $person->setDayComment($miss_req_session->getCom3Comment()); $person->save(); $companion = new Companion(); $companion->setPassengerId($passenger->getId()); $companion->setName($miss_req_session->getCom3Name()); $companion->setRelationship($miss_req_session->getCom3Relationship()); $companion->setDateOfBirth($miss_req_session->getCom3DateOfBirth()); $companion->setWeight($miss_req_session->getCom3Weigth()); $companion->setCompanionPhone($miss_req_session->getCom3Phone()); $companion->setCompanionPhoneComment($miss_req_session->getCom3Comment()); $companion->setPersonId($person->getId()); $companion->save(); } if ($passenger && $miss_req_session->getCom4Name()) { $person = new Person(); $names[] = split(" ", $miss_req_session->getCom4Name()); //echo var_dump($names); die(); $person->setFirstName($names[0][0]); $person->setLastName($names[0][1]); $person->setDayPhone($miss_req_session->getCom4Phone()); $person->setDayComment($miss_req_session->getCom4Comment()); $person->save(); $companion = new Companion(); $companion->setPassengerId($passenger->getId()); $companion->setName($miss_req_session->getCom4Name()); $companion->setRelationship($miss_req_session->getCom4Relationship()); $companion->setDateOfBirth($miss_req_session->getCom4DateOfBirth()); $companion->setWeight($miss_req_session->getCom4Weigth()); $companion->setCompanionPhone($miss_req_session->getCom4Phone()); $companion->setCompanionPhoneComment($miss_req_session->getCom4Comment()); $companion->setPersonId($person->getId()); $companion->save(); } if ($passenger && $miss_req_session->getCom5Name()) { $person = new Person(); $names[] = split(" ", $miss_req_session->getCom5Name()); //echo var_dump($names); die(); $person->setFirstName($names[0][0]); $person->setLastName($names[0][1]); $person->setDayPhone($miss_req_session->getCom5Phone()); $person->setDayComment($miss_req_session->getCom5Comment()); $person->save(); $companion = new Companion(); $companion->setPassengerId($passenger->getId()); $companion->setName($miss_req_session->getCom5Name()); $companion->setRelationship($miss_req_session->getCom5Relationship()); $companion->setDateOfBirth($miss_req_session->getCom5DateOfBirth()); $companion->setWeight($miss_req_session->getCom5Weigth()); $companion->setCompanionPhone($miss_req_session->getCom5Phone()); $companion->setCompanionPhoneComment($miss_req_session->getCom5Comment()); $companion->setPersonId($person->getId()); $companion->save(); } //set Itinerary $itinerary = ItineraryPeer::getByMissReqId($miss_req_session->getId()); if (!$itinerary) { $new_itinerary = new Itinerary(); $new_itinerary->setDateRequested(date('m/d/Y')); $new_itinerary->setMissionRequestId($miss_req_session->getId()); $new_itinerary->setMissionTypeId($miss_req_session->getMissionRequestTypeId()); $new_itinerary->setApointTime($miss_req_session->getApptDate()); $new_itinerary->setPassengerId($passenger->getId()); $new_itinerary->setRequesterId($requester->getId()); $new_itinerary->setFacility($miss_req_session->getFacilityName()); $new_itinerary->setLodging($miss_req_session->getLodgingName()); $new_itinerary->setOrginCity($miss_req_session->getOrginCity()); $new_itinerary->setOrginState($miss_req_session->getOrginState()); $new_itinerary->setDestCity($miss_req_session->getDestCity()); $new_itinerary->setDestState($miss_req_session->getDestState()); $new_itinerary->setWaiverNeed(0); $new_itinerary->setNeedMedicalRelease($miss_req_session->getPassMedical()); $new_itinerary->setComment($miss_req_session->getComment()); $new_itinerary->setAgencyId($agency->getId()); $new_itinerary->save(); } //set default Mission to Mission table //get Passenger //$passenger = PassengerPeer::getByPersonId($person->getId()); $misson = new Mission(); $misson->setRequestId($miss_req_session->getId()); $misson->setItineraryId($new_itinerary->getId()); $misson->setMissionTypeId($miss_req_session->getMissionRequestTypeId()); $misson->setDateRequested($miss_req_session->getRequesterDate()); if ($passenger) { $misson->setPassengerId($passenger->getId()); } if ($requester) { $misson->setRequesterId($requester->getId()); } if ($agency) { $misson->setAgencyId($agency->getId()); } // Farazi Mission 1 externa ID $c = new Criteria(); $c->add(MissionPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL); $c->addDescendingOrderByColumn(MissionPeer::ID); $external_mission = MissionPeer::doSelectOne($c); $external_id = $external_mission->getExternalId(); $currentExternalId = $external_id + 1; $misson->setExternalId($currentExternalId); $misson->setApptDate($miss_req_session->getApptDate()); $misson->setFlightTime($miss_req_session->getFlightTime()); $misson->setMissionDate($miss_req_session->getMissionDate()); $misson->setMissionCount(1); $misson->save(); $missLeg = new MissionLeg(); $missLeg->setMissionId($misson->getId()); $missLeg->setLegNumber(1); if ($miss_req_session->getOrginState() && $miss_req_session->getOrginZipcode()) { //echo $miss_req_session->getOrginState().'-'.$miss_req_session->getOrginZipcode();die(); $fromairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getOrginState(), $miss_req_session->getOrginZipcode()); if ($fromairport) { $missLeg->setFromAirportId($fromairport->getId()); } } if ($miss_req_session->getDestState() && $miss_req_session->getDestZipcode()) { //echo $miss_req_session->getDestState().'--'.$miss_req_session->getDestZipcode();die(); $toairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getDestState(), $miss_req_session->getDestZipcode()); if ($toairport) { $missLeg->setToAirportId($toairport->getId()); } } //echo "oder";die(); $missLeg->setPassOnBoard(0); $missLeg->setWebCoordinated(0); $missLeg->setTransportation('air_mission'); $missLeg->save(); //end set Mission $this->getUser()->setFlash('success', 'New mission has successfully created!'); $miss_req_session->setProcessedDate(time()); $miss_req_session->save(); $this->getUser()->setAttribute('miss_req', null); //$this->redirect('miss_req'); //$this->getUser()->setFlash('success',$success); //$request->getParameter('back') $this->redirect('/itinerary/detail/' . $new_itinerary->getId()); }
$grandFatherM->setId('NULL'); } if ($_POST["nameMotherM"] !== '') { $grandMotherM = new Person(); $grandMotherM->setId(0); $grandMotherM->setNames($_POST["nameMotherM"]); $grandMotherM->setLastname1($_POST["lastname1MotherM"]); $grandMotherM->setLastname2($_POST["lastname2MotherM"]); $grandMotherM->setGender('F'); PersonManager::addPerson($grandMotherM, 'true'); $grandMotherM = PersonManager::getSinglePerson('id', PersonManager::getLastID()); } else { $grandMotherM = new Person(); $grandMotherM->setId('NULL'); } $mother->getIdMother($grandMotherM->getId()); $mother->getIdFather($grandFatherM->getId()); PersonManager::addPerson($mother, 'true'); $mother = PersonManager::getSinglePerson('id', PersonManager::getLastID()); } } //Process The Child $child->setIdFather($father->getId()); $child->setIdMother($mother->getId()); if ($child->getId() === '0') { PersonManager::addPerson($child, 'true'); $child = PersonManager::getSinglePerson('id', PersonManager::getLastID()); } else { PersonManager::updatePerson($child); } $baptism->setIdOwner($child->getId());
/** * Declares an association between this object and a Person object. * * @param Person $v * @return WingLeader The current object (for fluent API support) * @throws PropelException */ public function setPerson(Person $v = null) { if ($v === null) { $this->setPersonId(NULL); } else { $this->setPersonId($v->getId()); } $this->aPerson = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Person object, it will not be re-added. if ($v !== null) { $v->addWingLeader($this); } return $this; }
/** * Tests Person->getId() */ public function testGetId() { $this->assertEquals('ID', $this->Person->getId()); }