Пример #1
0
 public static function doSelectByCode($code)
 {
     $c = new Criteria();
     $c->add(MemberPeer::CODE, $code);
     $c->add(MemberPeer::STATUS, array(Member::STATUS_ACTIVE, Member::STATUS_FINAL), Criteria::IN);
     $member = MemberPeer::doSelectOne($c);
     if (!$member) {
         $c = new Criteria();
         $c->add(MemberPeer::EMP_NO, $code);
         $member = MemberPeer::doSelectOne($c);
     }
     return $member;
 }
Пример #2
0
foreach ($sc as $k => $v) {
    $v = explode('#', $v);
    if ($v[0] == 'year') {
        $yr = date('Y');
        if (strlen($yr) <= $v[1]) {
            $no_reg .= str_pad($yr, $v[1], '0', STR_PAD_LEFT);
        } else {
            $no_reg .= substr($yr, strlen($yr) - $v[1]);
        }
        $no_reg_len += $v[1];
    } elseif ($v[0] == 'seq') {
        $c = new Criteria();
        $c->add(MemberPeer::NO_REG, $no_reg . '%', Criteria::LIKE);
        $c->addDescendingOrderByColumn(MemberPeer::NO_REG);
        $c->setLimit(1);
        $last_employee = MemberPeer::doSelectOne($c);
        if ($last_employee) {
            $las = $last_employee->getNoReg();
            $las = substr_replace($las, '', 0, $no_reg_len);
            $las = substr($las, 0, $v[1]);
            $las++;
            $no_reg .= str_pad($las, $v[1], '0', STR_PAD_LEFT);
        } else {
            $no_reg .= str_pad(1, $v[1], '0', STR_PAD_LEFT);
            break;
        }
    }
    $sc[$k] = $v;
}
echo object_input_tag($member, 'getNoReg', array('size' => 12, 'readonly' => false), $no_reg);
?>
Пример #3
0
 /**
  * Get the associated Member object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Member The associated Member object.
  * @throws     PropelException
  */
 public function getMember(PropelPDO $con = null)
 {
     if ($this->aMember === null && $this->member_id !== null) {
         $c = new Criteria(MemberPeer::DATABASE_NAME);
         $c->add(MemberPeer::ID, $this->member_id);
         $this->aMember = MemberPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aMember->addMemberWingJobs($this);
         		 */
     }
     return $this->aMember;
 }
Пример #4
0
 /**
  * @return Member
  */
 public function getMember()
 {
     $c = new Criteria();
     $c->add(MemberPeer::PERSON_ID, $this->getId());
     return MemberPeer::doSelectOne($c);
 }
Пример #5
0
foreach ($sc as $k => $v) {
    $v = explode('#', $v);
    if ($v[0] == 'year') {
        $yr = date('Y');
        if (strlen($yr) <= $v[1]) {
            $no_reg .= str_pad($yr, $v[1], '0', STR_PAD_LEFT);
        } else {
            $no_reg .= substr($yr, strlen($yr) - $v[1]);
        }
        $no_reg_len += $v[1];
    } elseif ($v[0] == 'seq') {
        $c = new Criteria();
        $c->add(MemberPeer::NO_REG, $no_reg . '%', Criteria::LIKE);
        $c->addDescendingOrderByColumn(MemberPeer::NO_REG);
        $c->setLimit(1);
        $last_student = MemberPeer::doSelectOne($c);
        if ($last_student) {
            $las = $last_student->getNoReg();
            $las = substr_replace($las, '', 0, $no_reg_len);
            $las = substr($las, 0, $v[1]);
            $las++;
            $no_reg .= str_pad($las, $v[1], '0', STR_PAD_LEFT);
        } else {
            $no_reg .= str_pad(1, $v[1], '0', STR_PAD_LEFT);
            break;
        }
    }
    $sc[$k] = $v;
}
echo object_input_tag($member, 'getNoReg', array('size' => 12, 'readonly' => false), $no_reg);
?>
Пример #6
0
 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());
     }
 }
Пример #7
0
 /**
  * Member add or edit
  * CODE: member_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     $new_pilot = false;
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Member'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     //FROM PERSON VIEW
     if ($request->getParameter('id')) {
         $member = MemberPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($member);
         $this->title = 'Edit member';
         $success = 'Member information has been successfully changed!';
         $this->person = $member->getPerson();
     } else {
         $this->person = PersonPeer::retrieveByPK($request->getParameter('person_id'));
         $this->forward404Unless($this->person);
         $member = new Member();
         $this->title = 'Add new member';
         $success = 'Member information has been successfully created!';
     }
     $this->form = new MemberForm($member);
     $this->back = $request->getReferer();
     $this->member = $member;
     if (strstr($request->getReferer(), 'person/view')) {
         $this->f_back = 1;
     } elseif (strstr($request->getReferer(), '/member/view/id')) {
         $this->f_back = 3;
     } elseif (strstr($request->getReferer(), '/member')) {
         $this->f_back = 2;
     }
     if ($request->isMethod('post')) {
         $this->referer = $request->getReferer();
         $this->form->bind($request->getParameter('mem'));
         if ($this->form->isValid() && $this->form->getValue('member_class_id') != 0 && $this->form->getValue('flight_status')) {
             if ($request->getParameter('person_id')) {
                 $member->setPersonId($request->getParameter('person_id'));
             }
             $person = PersonPeer::retrieveByPK($request->getParameter('person_id'));
             $member->setDateOfBirth($this->form->getValue('date_of_birth'));
             $member->setWeight($this->form->getValue('weight'));
             $member->setLanguages($this->form->getValue('languages'));
             if ($this->form->getValue('wing_id') == 0) {
                 $member->setWingId(null);
             } else {
                 $member->setWingId($this->form->getValue('wing_id'));
             }
             if ($this->form->getValue('secondary_wing_id') == 0) {
                 $member->setSecondaryWingId(null);
             } else {
                 $member->setSecondaryWingId($this->form->getValue('secondary_wing_id'));
             }
             // setting 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;
             $member->setExternalId($currentExternalId);
             $member->setJoinDate($this->form->getValue('join_date'));
             $member->setMemberClassId($this->form->getValue('member_class_id'));
             $member->setSpouseName($this->form->getValue('spouse_name'));
             $member->setCoordinatorNotes($this->form->getValue('coordinator_notes'));
             $member->setFlightStatus($this->form->getValue('flight_status'));
             if ($this->form->getValue('co_pilot') == null) {
                 $member->setCoPilot(0);
             } else {
                 $member->setCoPilot($this->form->getValue('co_pilot'));
             }
             $new_member = $member->isNew();
             if ($new_member) {
                 $content = $this->getUser()->getName() . ' added new Member: ' . $person->getFirstName();
                 ActivityPeer::log($content);
             }
             $member->save();
             //
             $wing_jobs = $request->getParameter('wing_job1[]');
             if ($request->getParameter('wing_job1')) {
                 $old_mem_wing_jobs = MemberWingJobPeer::getWingJob($member->getId());
                 foreach ($old_mem_wing_jobs as $old_mem_wing_job) {
                     $old_mem_wing_job->delete();
                 }
                 foreach ($wing_jobs as $wing_job) {
                     $member_wing_job = new MemberWingJob();
                     $member_wing_job->setMemberId($member->getId());
                     $member_wing_job->setWingJobId($wing_job);
                     $member_wing_job->save();
                 }
             }
             if (strtolower($member->getFlightStatus()) == 'command pilot') {
                 // if command-pilot then make pilot
                 $pilot = new Pilot();
                 $pilot->setMemberId($member->getId());
                 $pilot->setLicenseType('Default');
                 $pilot->setIfr(0);
                 $pilot->setMultiEngine(0);
                 $pilot->save();
                 $new_pilot = true;
             } else {
                 $new_pilot = false;
             }
             $this->getUser()->setFlash('success', $success);
             $last = $request->getParameter('back');
             $back_url = 'member/index';
             if (strstr($last, 'member/edit')) {
                 $back_url = 'member/index';
             } elseif (strstr($last, 'person/view')) {
                 if (isset($this->person)) {
                     $back_url = '@person_view?id=' . $this->person->getId();
                 }
             } elseif (strstr($last, 'member/view')) {
                 $back_url = '@member_view?id=' . $member->getId();
             }
             //with error validation back url
             if (strstr($request->getReferer(), 'last/1')) {
                 $back_url = '@person_view?id=' . $this->person->getId();
             } elseif (strstr($request->getReferer(), 'last/2')) {
                 $back_url = 'member/index';
             } elseif (strstr($request->getReferer(), 'last/3')) {
                 $back_url = '@member_view?id=' . $member->getId();
             }
             // role for new member
             if ($new_member) {
                 $role = '@Member';
                 $member_role = RolePeer::getByTitle($role);
                 if ($member_role) {
                     $person_role = new PersonRole();
                     $person_role->setPersonId($this->person->getId());
                     $person_role->setRoleId($member_role->getId());
                     $person_role->save();
                 } else {
                     $url = $this->generateUrl('default_index', array('module' => 'role'), true);
                     $this->getUser()->setFlash('warning', '"' . $role . '" role not found! Please navigate ' . $url . ' and fix.');
                 }
             }
             // role for new pilot
             if ($new_pilot) {
                 $role = '@Pilot';
                 $pilot_role = RolePeer::getByTitle($role);
                 $is_true = PersonRolePeer::getIsTrue($this->person->getId(), $pilot_role->getId());
                 if (!$is_true) {
                     $person_role = new PersonRole();
                     $person_role->setPersonId($this->person->getId());
                     $person_role->setRoleId($pilot_role->getId());
                     $person_role->save();
                 } else {
                     $url = $this->generateUrl('default_index', array('module' => 'role'), true);
                     //$this->getUser()->setFlash('warning', '"'.$role.'" role not found! Please navigate '.$url.' and fix');
                 }
             }
             $this->redirect($back_url);
         } else {
             $this->getUser()->setFlash('warning', 'Please confirm flight status and choose the member class!');
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : 'member/index';
     }
     $this->member = $member;
 }