public function save()
 {
     $rules = ['fullname' => 'required', 'email' => 'required|email', 'position' => 'required', 'message' => 'required', 'cv' => 'mimes:doc,docx,pdf,size:2000'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return View::make('error')->with(['message' => 'Please ensure to fulfil all requirements.', 'breadcrumb' => 'find-job']);
     }
     $email = Input::get('email');
     $filename = '';
     $dest_path = '';
     if (Input::hasFile('cv')) {
         $extension = Input::file('cv')->getClientOriginalExtension();
         $size = Input::file('cv')->getSize();
         $dest_path = storage_path() . '/cv/';
         $filename = $email . '.' . $extension;
         Input::file('cv')->move($dest_path, $filename);
     }
     $applicant = Application::firstOrCreate(['email' => $email]);
     if (!empty($applicant->fullname)) {
         $applicant = new Application();
         $applicant->email = $email;
     }
     $applicant->fullname = Input::get('fullname');
     $applicant->position = Input::get('position');
     $applicant->message = Input::get('message');
     $applicant->cv = $dest_path . $filename;
     $applicant->save();
     $position = Input::get('position');
     $fullname = Input::get('fullname');
     Mail::send('emails.application', array(Input::all()), function ($message) use($position, $fullname) {
         $message->to('*****@*****.**')->subject('Application for ' . $position . ' - ' . $fullname);
     });
     return View::make('thank_you')->with(['person' => 'HR agents', 'breadcrumb' => 'team']);
 }
  protected function execute($arguments = array(), $options = array())
  {
    if ( !$options['appmin'] || !$options['appmax'] || ($options['appmin'] > $options['appmax']))
    {
      throw new Exception("invalid option: ");
    }

    $databaseManager = new sfDatabaseManager($this->configuration);
    $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();

    $applist = range($options['appmin'], $options['appmax']);
    foreach ($applist as $application_id)
    {
      $sql = 'SELECT id FROM application WHERE id = ?';
      $where = array(intval($application_id));
      $app = $this->conn->fetchOne($sql, $where);
      if (!$app)
      {
        $application = new Application();
        $application->setUrl("http://");
        $application->setIsMobile('1');
        $application->setIsPc('0');
        $application->save();
        $application->free();
        $this->logSection('application', sprintf("%s", $application_id));
      }
    }

  }
 /**
  * Store a newly created resource in storage.
  * POST /application
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['name' => 'required|min:3', 'url' => 'required|active_url'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator->messages());
     }
     $app = new Application();
     $app->name = Input::get('name');
     $app->url = Input::get('url');
     $app->save();
     return Redirect::action('application.show', [$app->id])->withSuccess('Application created.');
 }
Example #4
0
 function create_session($session, $remember = false)
 {
     $a = new Application();
     $a->user_id = $this->id;
     $a->token = koken_rand();
     $a->role = 'god';
     $a->save();
     $session->set_userdata(array('token' => $a->token, 'user' => $this->to_array()));
     if ($remember) {
         $token = koken_rand();
         $this->remember_me = $token;
         $this->save();
         $this->load->helper('cookie');
         set_cookie(array('name' => 'remember_me', 'value' => $token, 'expire' => 1209600));
     }
     return $a->token;
 }
 public function save()
 {
     # Set rules for validation
     $rules = ['firstname' => 'required', 'lastname' => 'required', 'email' => 'required|email', 'location' => 'required', 'skills' => 'required', 'programme' => 'required', 'period' => 'required', 'certificate' => 'required', 'passport' => 'mimes:gif,jpg,jpeg,png,size:2000'];
     $validator = Validator::make(Input::all(), $rules);
     # Handle validation failure
     if ($validator->fails() or !Input::hasFile('passport')) {
         return View::make('error')->with(['message' => 'Please ensure to fulfil all requirements.']);
     }
     # Proceed on valid form data
     $email = Input::get('email');
     # Upload passport photograph
     $filename = '';
     $dest_path = '';
     $extension = Input::file('passport')->getClientOriginalExtension();
     $size = Input::file('passport')->getSize();
     $dest_path = storage_path() . '/passport/';
     $filename = $email . '.' . $extension;
     Input::file('passport')->move($dest_path, $filename);
     #Create new record or update existing one
     $student = Enrollment::firstOrCreate(['email' => $email]);
     if (!empty($student->first_name)) {
         $student = new Application();
         $student->email = $email;
     }
     $student->first_name = Input::get('firstname');
     $student->last_name = Input::get('lastname');
     $student->email = Input::get('email');
     $student->phone = Input::get('phone');
     $student->programme = Input::get('programme');
     $student->period = Input::get('period');
     $student->certificate = Input::get('certificate');
     $student->location = Input::get('location');
     $student->skills = Input::get('skills');
     $student->passport = $dest_path . $filename;
     $student->save();
     # Shoot email to chene academy
     Mail::send('emails.enrol', array(Input::all()), function ($message) {
         $message->to('*****@*****.**')->subject('Enrolment for ' . Input::get('programme') . '-' . Input::get('fullname'));
     });
     return View::make('thank_you')->with(['person' => 'Trainers']);
 }
Example #6
0
 /**
  * Store a newly created order in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Order::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $order = new Order();
     $order->product_id = Input::get('product_id');
     $order->order_date = date('d-m-Y');
     $order->customer_name = $member->member_name;
     $order->customer_number = $member->member_account;
     $order->save();
     $application = new Application();
     $application->product = $loan_product;
     $application->member_account = $member->member_account;
     $application->member = $member->member_name;
     $application->amount = Input::get('product_price');
     $application->save();
     return Redirect::route('orders.index');
 }
Example #7
0
 public function applyAction()
 {
     if ($this->request->isPost()) {
         $user = $this->getAuth();
         $new_car = $this->request->getPost('new_car');
         if ($new_car == 0) {
             $car = Car::findFirst(array('conditions' => 'number = ?1', 'bind' => array(1 => $this->request->getPost('choose-car'))));
         } else {
             $car = new Car();
             $car->number = $this->request->getPost('number');
             $car->brand = $this->request->getPost('brand');
             $car->model = $this->request->getPost('model');
             $car->owner = $user['user_id'];
             if (!$car->save()) {
                 message($this, "d", "Данные об автомобиле указаны неверно");
                 return $this->response->redirect("applyForService");
             }
         }
         if ($car) {
             $date = $this->request->getPost('date');
             $time = $this->request->getPost('time');
             $apps = Application::find(array('conditions' => 'term = ?1', 'bind' => array(1 => $date)));
             if ($date) {
                 if ($time) {
                     if (count($apps) < 4 * 20) {
                         $services = $this->request->getPost('services');
                         if (count($services) > 0) {
                             $app = new Application();
                             $app->car = $car->number;
                             $app->term = $date . ' ' . $time;
                             $app->confirmed = 0;
                             $app->manager = NULL;
                             if ($app->save()) {
                                 foreach ($services as $service) {
                                     $as = new ApplicationService();
                                     $as->application_id = $app->id;
                                     $as->service_id = $service;
                                     if (!$as->save()) {
                                         message($this, "d", "Ошибка при сохранении выбранной услуги");
                                         return $this->response->redirect("applyForService");
                                     }
                                 }
                                 //todo! Обработка поля с доп. информацией
                                 message($this, "s", "Заявка отправлена. В ближайшее время наш менеджер свяжется с Вами для ее подтверждения");
                                 return $this->response->redirect("cabinet");
                             } else {
                                 message($this, "d", "Ошибка при сохранении заявки");
                                 foreach ($app->getMessages() as $message) {
                                     message($this, "d", "Ошибка: " . $message->getMessage() . " в поле " . $message->getField() . ". Тип: " . $message->getType());
                                 }
                                 return $this->response->redirect("applyForService");
                             }
                         } else {
                             message($this, "d", "Минимум одна услуга должна быть выбрана");
                             return $this->response->redirect("applyForService");
                         }
                     } else {
                         message($this, "d", "Выбранная дата занята. Пожалуйста, выберите другой день");
                         return $this->response->redirect("applyForService");
                     }
                 } else {
                     message($this, "d", "Время не выбрано!");
                     return $this->response->redirect("applyForService");
                 }
             } else {
                 message($this, "d", "Дата не выбрана!");
                 return $this->response->redirect("applyForService");
             }
         } else {
             message($this, "d", "Автомобиль не найден");
             return $this->response->redirect("applyForService");
         }
     }
 }
Example #8
0
    $rtn = array();
    foreach ($files as $file) {
        $file = trim($file);
        // for cache file, we move it to its proper location
        if (strpos($file, str_replace(WEBROOT . DS, "", CACHE_DIR)) === 0) {
            $oldname = WEBROOT . DS . $file;
            $newname = WEBROOT . DS . "files/application" . str_replace(CACHE_DIR, "", WEBROOT . DS . $file);
            rename($oldname, $newname);
            $file = str_replace(WEBROOT . DS, "", $newname);
        }
        $rtn[] = $file;
    }
    $object->setIeltsTranscripts(implode("\n", $rtn));
    $object->setCreatedAt(time());
    if ($error_flag == false) {
        if ($object->save()) {
            Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Thanks for your application. We will come back to you as soon as possible.", "zh" => "记录保存成功"))));
            sendemailAdmin('Apply for course', '<p>A new application for course has just been submitted: <br /><a href="http://en.ct21.com.au/admin/application/edit/' . $object->getId() . '">http://en.ct21.com.au/admin/application/edit/' . $object->getId() . '</a></p>');
            HTML::forwardBackToReferer();
        } else {
            Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败"))));
        }
    }
}
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Application', 'zh' => 'Create 申请'))));
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$html->renderOut('application/backend/application_create', array('object' => $object));
$html->output('</div>');
$html->renderOut('core/backend/html_footer');
Example #9
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::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());
 }
 public static function update($values, $user)
 {
     $id = $values['id'];
     if ($id) {
         $q = new Doctrine_Query();
         $q = $q->select('a.*')->from('Application a');
         $q = $q->addWhere('id = ?', array($id));
         if (!$user->getRole() == User::ADMIN) {
             $q = $q->addWhere('user_id = ?', array($user->getId()));
         }
         $application = $q->fetchOne();
     } else {
         $application = new Application();
     }
     if ($application) {
         $application->setName($values['name']);
         $application->setDescription($values['description']);
         $application->setSourceUrl($values['source_url']);
         if (!$application->getUserId()) {
             $application->setUserId($user->getId());
         }
         $application->setApproved(false);
         $application->save();
         $folderpath = $application->getFolderPath();
         if (!is_dir($folderpath)) {
             mkdir($folderpath);
         }
         $screenshot = $values['screenshot'];
         if ($screenshot) {
             $screenshotpath = $folderpath . $application->getId() . $screenshot->getOriginalName();
             $screenshot->save($screenshotpath);
             $smallThumb = new Thumbnail($screenshotpath);
             if ($smallThumb->getCurrentWidth() > 150 || $smallThumb->getCurrentHeight() > 150) {
                 $smallThumb->resize(150, 150);
             }
             $smallThumb->show(100, $folderpath . 'smallthumb.png');
             $bigThumb = new Thumbnail($screenshotpath);
             if ($bigThumb->getCurrentWidth() > 500 || $bigThumb->getCurrentHeight() > 500) {
                 $bigThumb->resize(500, 500);
             }
             $bigThumb->show(100, $folderpath . 'bigthumb.png');
             $screenshot = new Thumbnail($screenshotpath);
             $screenshot->show(100, $folderpath . 'screenshot.png');
             unlink($screenshotpath);
         }
         return $application;
     }
     return null;
 }
 /**
  * add a new application
  *
  * @param string  $url
  * @param boolean $update
  * @param string  $culture
  * @return Application
  */
 public function addApplication($url, $update = false, $culture = null)
 {
     if ($culture === null) {
         $culture = sfContext::getInstance()->getUser()->getCulture();
     }
     if ($culture != sfConfig::get('sf_default_culture')) {
         self::addApplication($url, $update, sfConfig::get('sf_default_culture'));
     }
     $application = $this->findOneByUrl($url);
     if (!$application) {
         $application = new Application();
     }
     if (isset($application->Translation[$culture]) && !$update) {
         $ua = $application->getUpdatedAt();
         $time = strtotime($ua);
         if (!empty($ua) && time() - $ua <= Doctrine::getTable('SnsConfig')->get('application_cache_time', 24 * 60 * 60)) {
             return $application;
         }
     }
     $gadget = opOpenSocialToolKit::fetchGadgetMetadata($url, $culture);
     $prefs = array();
     foreach ($gadget->gadgetSpec->userPrefs as $pref) {
         $prefs[$pref['name']] = $pref;
     }
     $views = array();
     foreach ($gadget->gadgetSpec->views as $name => $view) {
         unset($view['content']);
         $views[$name] = $view;
     }
     $translation = $application->Translation[$culture];
     $application->setUrl($url);
     $application->setLinks($gadget->gadgetSpec->links);
     $translation->title = $gadget->getTitle();
     $translation->title_url = $gadget->getTitleUrl();
     $translation->description = $gadget->getDescription();
     $translation->directory_title = $gadget->getDirectoryTitle();
     $translation->screenshot = $gadget->getScreenShot();
     $translation->thumbnail = $gadget->getThumbnail();
     $translation->author = $gadget->getAuthor();
     $translation->author_aboutme = $gadget->getAuthorAboutme();
     $translation->author_affiliation = $gadget->getAuthorAffiliation();
     $translation->author_email = $gadget->getAuthorEmail();
     $translation->author_photo = $gadget->getAuthorPhoto();
     $translation->author_link = $gadget->getAuthorLink();
     $translation->author_quote = $gadget->getAuthorQuote();
     $translation->settings = $prefs;
     $translation->views = $views;
     if (isset($views['mobile'])) {
         if (!(isset($views['mobile']['type']) && 'URL' === strtoupper($views['mobile']['type']))) {
             throw new Exception();
         }
     }
     $application->setIsPc(true);
     if (count($views) == 1) {
         if (isset($views['mobile'])) {
             $application->setIsPc(false);
         }
     }
     if ($application->getIsMobile()) {
         if (!isset($views['mobile'])) {
             $application->setIsMobile(false);
         }
     }
     if ($gadget->getScrolling() == 'true') {
         $application->setScrolling(true);
     } else {
         $application->setScrolling(false);
     }
     $singleton = $gadget->getSingleton();
     if ($singleton == 'true' || empty($singleton)) {
         $application->setSingleton(true);
     } else {
         $application->setSingleton(false);
     }
     $height = $gadget->getHeight();
     $application->setHeight(!empty($height) ? $height : 0);
     $application->save();
     return $application;
 }
 protected final function request_token()
 {
     if (class_exists('Application') && isset($_POST)) {
         $a = new Application();
         $a->single_use = 1;
         $a->role = 'read-write';
         $a->token = koken_rand();
         $a->save();
         return $a->token;
     } else {
         return false;
     }
 }
Example #13
0
 public function postApplication()
 {
     if (!Auth::check()) {
         return Response::json(array('errCode' => 1, 'message' => '请登录!'));
     }
     $user_id = Auth::user()->id;
     $name = Input::get('name');
     $gender = Input::get('gender');
     if ($gender == null) {
         $gender = 2;
     }
     $year = Input::get('year');
     $month = Input::get('month');
     $day = Input::get('day');
     $hometown = Input::get('hometown');
     $address = Input::get('address');
     $guardian = Input::get('guardian');
     $phone = Input::get('phone');
     $unit = Input::get('unit');
     $position = Input::get('position');
     $qq = Input::get('QQ');
     $school = Input::get('school');
     $postcode = Input::get('postcode');
     $trainingunit = Input::get('trainingunit');
     $profession = Input::get('profession');
     $timeoflearn = Input::get('timeoflearn');
     $details = Input::get('details');
     $validation = Validator::make(array('name' => $name, 'phone' => $phone), array('name' => 'required', 'phone' => 'required'));
     if ($validation->fails()) {
         return Response::json(array('errCode' => 2, 'message' => '名字和手机必须填写完整!'));
     }
     $reg = "/^0?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}\$/";
     if (!preg_match($reg, $phone)) {
         return Response::json(array('errCode' => 3, 'message' => '手机格式不正确!'));
     }
     //存储报名表
     $application = new Application();
     $application->user_id = $user_id;
     $application->name = $name;
     $application->gender = $gender;
     $application->year = $year;
     $application->month = $month;
     $application->day = $day;
     $application->hometown = $hometown;
     $application->address = $address;
     $application->guardian = $guardian;
     $application->phone = $phone;
     $application->unit = $unit;
     $application->position = $position;
     $application->qq = $qq;
     $application->school = $school;
     $application->postcode = $postcode;
     $application->trainingunit = $trainingunit;
     $application->profession = $profession;
     $application->timeoflearn = $timeoflearn;
     $application->details = $details;
     //产生考生编号
     $possible_charactors = "0123456789";
     $scorenumber = "";
     //
     while (strlen($scorenumber) < 6) {
         $scorenumber .= substr($possible_charactors, rand(0, strlen($possible_charactors) - 1), 1);
     }
     $application->scorenumber = $scorenumber;
     if ($application->save()) {
         return Response::json(array('errCode' => 0, 'message' => $scorenumber));
     }
     return Response::json(array('errCode' => 4, 'message' => '资料保存失败!'));
 }
Example #14
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());
     }
 }
Example #15
0
 public function actionApply($jobid)
 {
     $user = User::getCurrentUser();
     $job = Job::model()->findByPk($jobid);
     $poster = User::model()->findByPk($job->FK_poster);
     $application = new Application();
     $application->jobid = $job->id;
     $application->userid = $user->id;
     $application->application_date = date('Y-m-d H:i:s');
     $application->coverletter = $this->mynl2br($_POST['Application']['coverletter']);
     $application->save(false);
     $link = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/student/user/' . $user->username;
     $link1 = CHtml::link('click here to see ' . $user->username . ' profile', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/student/user/' . $user->username);
     $message = "The User " . $user->username . " just applied for your job " . $job->title . ". Click here to view his profile";
     $message1 = "{$user->username} just applied for your job {$job->title}<br/>{$link1}";
     $html = User::replaceMessage($poster->username, $message1);
     User::sendEmployerNotificationAlart($user->id, $job->FK_poster, $message, $link, 3);
     User::sendEmail($poster->email, "Virtual Job Fair Application Submitted", "New Application Submitted", $message1);
     //User::sendEmailNotificationAlart($poster->email, $poster->username, $user->username ,$message1);
     $this->redirect("/JobFair/index.php/Job/View/jobid/" . $jobid);
 }
Example #16
0
 /**
  * Implementation for 'POST' method for Rest API
  *
  * @param  mixed $appUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function post($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
 {
     try {
         $result = array();
         $obj = new Application();
         $obj->setAppUid($appUid);
         $obj->setAppNumber($appNumber);
         $obj->setAppParent($appParent);
         $obj->setAppStatus($appStatus);
         $obj->setProUid($proUid);
         $obj->setAppProcStatus($appProcStatus);
         $obj->setAppProcCode($appProcCode);
         $obj->setAppParallel($appParallel);
         $obj->setAppInitUser($appInitUser);
         $obj->setAppCurUser($appCurUser);
         $obj->setAppCreateDate($appCreateDate);
         $obj->setAppInitDate($appInitDate);
         $obj->setAppFinishDate($appFinishDate);
         $obj->setAppUpdateDate($appUpdateDate);
         $obj->setAppData($appData);
         $obj->setAppPin($appPin);
         $obj->save();
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
 }