コード例 #1
0
ファイル: EducationDao.php プロジェクト: rabbitdigital/HRM
 public function saveEducation(Education $education)
 {
     try {
         $education->save();
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
 }
コード例 #2
0
    $education->id = (int) $_GET['id'];
    if ($education->delete()) {
        $session->message("Education deleted ");
        redirect_to($_SERVER['PHP_SELF'] . "?#" . $_GET['id']);
        die;
    } else {
        $message = join("<br />", $education->errors);
    }
}
if (isset($_GET['action']) && $_GET['action'] == "add") {
    if (isset($_POST['bt_add'])) {
        $education = new Education();
        $education->education_name = $_POST['txt_education_name'];
        $education->var_name = $education->mod_write_check($_POST['txt_education_name']);
        $education->is_active = $_POST['txt_is_active'];
        if ($education->save()) {
            $session->message("New Education added.");
            redirect_to($_SERVER['PHP_SELF']);
            die;
        } else {
            $message = join("<br />", $education->errors);
        }
    }
}
$education = Education::find_all();
$manage_lists = array();
if ($education && is_array($education)) {
    $i = 1;
    foreach ($education as $list) {
        $manage_lists[$i]['id'] = $list->id;
        $manage_lists[$i]['education_name'] = $list->education_name;
コード例 #3
0
ファイル: pds2.php プロジェクト: billyriantono/ihrmis
 function education($employee_id = '')
 {
     $data['page_name'] = '<b>Personal Data Sheet</b>';
     $data['section_name'] = '<b>Personal Information</b>';
     $data['focus_field'] = 'elem_school';
     $data['msg'] = '';
     $e = new Employee_m();
     $data['employee'] = $e->get_by_id($employee_id);
     $e = new Education();
     if (Input::get('op')) {
         // EDUCATIONAL BACKGROUND============================================
         // ELEMENTARY
         if (Input::get('elem_school') != "") {
             $e = new Education();
             $e->where('level', 1);
             $e->where('employee_id', $employee_id)->get();
             $e->delete_all();
             $e->employee_id = $employee_id;
             $e->level = 1;
             $e->school_name = Input::get('elem_school');
             $e->degree_course = Input::get('elem_degree');
             $e->year_graduated = Input::get('elem_grad');
             $e->highest_grade = Input::get('elem_units');
             $e->attend_from = Input::get('elem_date1');
             $e->attend_to = Input::get('elem_date2');
             $e->scholarship = Input::get('elem_scho');
             $e->save();
         }
         // HIGHSCHOOL
         if (Input::get('sec_school') != "") {
             $e = new Education();
             $e->where('level', 2);
             $e->where('employee_id', $employee_id)->get();
             $e->delete_all();
             $e->employee_id = $employee_id;
             $e->level = 2;
             $e->school_name = Input::get('sec_school');
             $e->degree_course = Input::get('sec_degree');
             $e->year_graduated = Input::get('sec_grad');
             $e->highest_grade = Input::get('sec_units');
             $e->attend_from = Input::get('sec_date1');
             $e->attend_to = Input::get('sec_date2');
             $e->scholarship = Input::get('sec_scho');
             $e->save();
         }
         // VOC
         if (Input::get('voc_school') != "") {
             $e = new Education();
             $e->where('level', 3);
             $e->where('employee_id', $employee_id)->get();
             $e->delete_all();
             $e->employee_id = $employee_id;
             $e->level = 3;
             $e->school_name = Input::get('voc_school');
             $e->degree_course = Input::get('voc_degree');
             $e->year_graduated = Input::get('voc_grad');
             $e->highest_grade = Input::get('voc_units');
             $e->attend_from = Input::get('voc_date1');
             $e->attend_to = Input::get('voc_date2');
             $e->scholarship = Input::get('voc_scho');
             $e->save();
         }
         // COLLEGE
         if (Input::get('col_school') != "") {
             $e = new Education();
             $e->where('level', 4);
             $e->where('employee_id', $employee_id)->get();
             $e->delete_all();
             $e->employee_id = $employee_id;
             $e->level = 4;
             $e->school_name = Input::get('col_school');
             $e->degree_course = Input::get('col_degree');
             $e->year_graduated = Input::get('col_grad');
             $e->highest_grade = Input::get('col_units');
             $e->attend_from = Input::get('col_date1');
             $e->attend_to = Input::get('col_date2');
             $e->scholarship = Input::get('col_scho');
             $e->save();
         }
         // GRAD SCHOOL
         if (Input::get('grad_school') != "") {
             $e = new Education();
             $e->where('level', 5);
             $e->where('employee_id', $employee_id)->get();
             $e->delete_all();
             $e->employee_id = $employee_id;
             $e->level = 5;
             $e->school_name = Input::get('grad_school');
             $e->degree_course = Input::get('grad_degree');
             $e->year_graduated = Input::get('grad_grad');
             $e->highest_grade = Input::get('grad_units');
             $e->attend_from = Input::get('grad_date1');
             $e->attend_to = Input::get('grad_date2');
             $e->scholarship = Input::get('grad_scho');
             $e->save();
         }
         $data['msg'] = 'Educational Background has been saved!';
     }
     // Educational Background======================================
     $e = new Education();
     $data['educs1'] = $e->get_single_educ($employee_id, $level = 1);
     $data['educs2'] = $e->get_single_educ($employee_id, $level = 2);
     $data['educs3'] = $e->get_single_educ($employee_id, $level = 3);
     $data['educs4'] = $e->get_single_educ($employee_id, $level = 4);
     $data['educs5'] = $e->get_single_educ($employee_id, $level = 5);
     $e = new Employee_m();
     $e->get_by_id($employee_id);
     $data['selected'] = $e->office_id;
     //Use for office listbox
     $data['options'] = $this->options->office_options();
     $data['employee_id'] = $employee_id;
     $data['main_content'] = 'education';
     return View::make('includes/template', $data);
 }
コード例 #4
0
ファイル: UserprofileController.php プロジェクト: vishu87/cpr
 public function duplicatecvpage($cv_code)
 {
     $cv_old = Cv::where('cv_code', $cv_code)->first();
     if ($cv_old->user_id != Auth::id()) {
         return 'False';
     }
     $new_cv_name = $cv_old->cv_name . ' - Copy';
     $cv = new Cv();
     do {
         $random = str_random(10);
         $count = Cv::where('cv_code', $random)->count();
     } while ($count != 0);
     $cv->cv_code = $random;
     if (Auth::check()) {
         $cv->user_id = Auth::id();
     }
     $cv->cv_name = $new_cv_name;
     $cv->user_id = $cv_old->user_id;
     $cv->full_name = $cv_old->full_name;
     $cv->phone_num = $cv_old->phone_num;
     $cv->email = $cv_old->email;
     $cv->website = $cv_old->website;
     $cv->add_line1 = $cv_old->add_line1;
     $cv->add_line2 = $cv_old->add_line2;
     $cv->dob = $cv_old->dob;
     $cv->marital_status = $cv_old->marital_status;
     $cv->profile_image = $cv_old->profile_image;
     $cv->sex = $cv_old->sex;
     $cv->state_origin = $cv_old->state_origin;
     $cv->religion = $cv_old->religion;
     $cv->religion_text = $cv_old->religion_text;
     $cv->show_profile_pic = $cv_old->show_profile_pic;
     $cv->local_government = $cv_old->local_government;
     $cv->save();
     $new_cv_id = $cv->id;
     // copying sections
     $sections = Section::where('cv_id', $cv_old->id)->get();
     foreach ($sections as $section) {
         $section_new = new Section();
         $section_new->cv_id = $new_cv_id;
         $section_new->section_name = $section->section_name;
         $section_new->type = $section->type;
         $section_new->content = $section->content;
         $section_new->default = $section->default;
         $section_new->priority = $section->priority;
         $section_new->save();
     }
     // copying educations
     $educations = Education::where('cv_id', $cv_old->id)->get();
     foreach ($educations as $education) {
         $education_new = new Education();
         $education_new->cv_id = $new_cv_id;
         $education_new->coursename = $education->coursename;
         $education_new->institutename = $education->institutename;
         $education_new->add_line1 = $education->add_line1;
         $education_new->add_line2 = $education->add_line2;
         $education_new->startdate = $education->startdate;
         $education_new->enddate = $education->enddate;
         $education_new->otherinfo = $education->otherinfo;
         $education_new->priority = $education->priority;
         $education_new->save();
     }
     // copying languages
     $languages = Language::where('cv_id', $cv_old->id)->get();
     foreach ($languages as $language) {
         $language_new = new Language();
         $language_new->cv_id = $new_cv_id;
         $language_new->language_id = $language->language_id;
         $language_new->language_name = $language->language_name;
         $language_new->ability_id = $language->ability_id;
         $language_new->level_id = $language->level_id;
         $language_new->priority = $language->priority;
         $language_new->save();
     }
     // copying nysc
     $nyscs = Nysc::where('cv_id', $cv_old->id)->get();
     foreach ($nyscs as $nysc) {
         $nysc_new = new Nysc();
         $nysc_new->cv_id = $new_cv_id;
         $nysc_new->year = $nysc->year;
         $nysc_new->batch = $nysc->batch;
         $nysc_new->ppa = $nysc->ppa;
         $nysc_new->cd = $nysc->cd;
         $nysc_new->otherinfo = $nysc->otherinfo;
         $nysc_new->priority = $nysc->priority;
         $nysc_new->save();
     }
     // copying work_exp
     $work_exps = WorkExperience::where('cv_id', $cv_old->id)->get();
     foreach ($work_exps as $work_exp) {
         $work_exp_new = new WorkExperience();
         $work_exp_new->cv_id = $new_cv_id;
         $work_exp_new->title = $work_exp->title;
         $work_exp_new->company = $work_exp->company;
         $work_exp_new->location = $work_exp->location;
         $work_exp_new->startdate = $work_exp->startdate;
         $work_exp_new->enddate = $work_exp->enddate;
         $work_exp_new->otherinfo = $work_exp->otherinfo;
         $work_exp_new->priority = $work_exp->priority;
         $work_exp_new->save();
     }
     return Redirect::back();
 }
コード例 #5
0
 public function store()
 {
     // Get StudentID
     // From student_id or Create New
     // Create Registration
     // Create Issue
     // Create Education
     // Create Placement
     // Create Receivables
     // Reductions
     // Create Installment
     try {
         //DB::beginTransaction();
         if (Input::get('student_id') == 0) {
             // Create New Student
             $student = new Student();
             $student->name = Input::get('name');
             $student->sex = Input::get('sex');
             $student->birthplace = Input::get('birthplace');
             $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate')));
             $student->religion = Input::get('religion');
             $student->address = Input::get('address');
             $student->contact = Input::get('contact');
             $student->email = Input::get('email');
             if (Input::get('sex') == 'L') {
                 $student->photo = 'boy.png';
             } else {
                 $student->photo = 'girl.png';
             }
             $student->father_name = Input::get('father_name');
             $student->father_occupation = Input::get('father_occupation');
             $student->father_address = Input::get('father_address');
             $student->father_contact = Input::get('father_contact');
             $student->father_email = Input::get('father_email');
             $student->mother_name = Input::get('mother_name');
             $student->mother_occupation = Input::get('mother_occupation');
             $student->mother_address = Input::get('mother_address');
             $student->mother_contact = Input::get('mother_contact');
             $student->mother_email = Input::get('mother_email');
             $student->save();
             $id = $student->id;
         } else {
             $student = Student::find(Input::get('student_id'));
             $student->name = Input::get('name');
             $student->sex = Input::get('sex');
             $student->birthplace = Input::get('birthplace');
             $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate')));
             $student->religion = Input::get('religion');
             $student->address = Input::get('address');
             $student->contact = Input::get('contact');
             $student->email = Input::get('email');
             if (Input::get('sex') == 'L') {
                 $student->photo = 'boy.png';
             } else {
                 $student->photo = 'girl.png';
             }
             $student->father_name = Input::get('father_name');
             $student->father_occupation = Input::get('father_occupation');
             $student->father_address = Input::get('father_address');
             $student->father_contact = Input::get('father_contact');
             $student->father_email = Input::get('father_email');
             $student->mother_name = Input::get('mother_name');
             $student->mother_occupation = Input::get('mother_occupation');
             $student->mother_address = Input::get('mother_address');
             $student->mother_contact = Input::get('mother_contact');
             $student->mother_email = Input::get('mother_email');
             $student->save();
             $id = $student->id;
         }
         // Create Registration Data
         $registration = new Registration();
         $registration->project_id = Auth::user()->curr_project_id;
         $registration->location_id = Auth::user()->location_id;
         $registration->student_id = $id;
         $registration->classification_id = Input::get('classification');
         $registration->base_id = Input::get('location');
         $registration->registration_date = date('Y-m-d', strtotime(Input::get('registration_date')));
         $registration->registration_cost = Input::get('fee');
         $registration->recommender_type = Input::get('recommender_type');
         $registration->recommender_id = Input::get('recommender_id');
         $registration->employee_id = Input::get('employee');
         $registration->save();
         // Create Issue
         $issue = new Issue();
         $issue->project_id = Auth::user()->curr_project_id;
         $issue->location_id = Auth::user()->location_id;
         $issue->registration_id = $registration->id;
         $issue->generation_id = Input::get('generation');
         $issue->student_id = $id;
         $issue->issue = Input::get('issue');
         $issue->save();
         //Create Education Data
         if (Input::get('school') != '0') {
             $education = new Education();
             $education->project_id = Auth::user()->curr_project_id;
             $education->issue_id = $issue->id;
             $education->school_id = Input::get('school');
             $education->generation_id = Input::get('generation');
             $education->save();
         }
         // Receivables - Registration Costs
         $receivable = new Receivable();
         $receivable->project_id = Auth::user()->curr_project_id;
         $receivable->location_id = Auth::user()->location_id;
         $receivable->issue_id = $issue->id;
         $receivable->registration_id = $registration->id;
         $receivable->total = Input::get('total');
         $receivable->billable = Input::get('billable');
         $receivable->receivable = Input::get('receivables');
         $receivable->balance = Input::get('billable');
         if (Input::get('payment') == 0) {
             $receivable->payment = 'Cash';
         } else {
             $receivable->payment = 'Installment';
         }
         $receivable->save();
         $billable = Input::get('billable');
         $payment = Input::get('payment');
         if ((int) $payment > 0) {
             // First Installment
             $installment = new Installment();
             $installment->project_id = Auth::user()->curr_project_id;
             $installment->location_id = Auth::user()->location_id;
             $installment->receivable_id = $receivable->id;
             $installment->schedule = Input::get('registration_date');
             $installment->total = $billable / $payment;
             $installment->balance = $billable / $payment;
             $installment->paid = 0;
             $installment->save();
             // Extracting Date
             $dd = (int) substr(Input::get('registration_date'), 8, 2);
             $mm = (int) substr(Input::get('registration_date'), 5, 2);
             $yy = (int) substr(Input::get('registration_date'), 0, 4);
             if ($dd > 25) {
                 $mm += 2;
                 if ($mm > 12) {
                     $new_mm = $mm - 12;
                     $yy += 1;
                 } else {
                     $new_mm = $mm;
                 }
             } else {
                 $mm += 1;
                 if ($mm > 12) {
                     $new_mm = $mm - 12;
                     $yy += 1;
                 } else {
                     $new_mm = $mm;
                 }
             }
             for ($i = 2; $i <= $payment; $i++) {
                 $installment_date = $yy . '-' . str_pad($new_mm, 2, "0", STR_PAD_LEFT) . '-' . '05';
                 $installment = new Installment();
                 $installment->project_id = Auth::user()->curr_project_id;
                 $installment->location_id = Auth::user()->location_id;
                 $installment->receivable_id = $receivable->id;
                 $installment->schedule = date('Y-m-d', strtotime($installment_date));
                 $installment->total = $billable / $payment;
                 $installment->balance = $billable / $payment;
                 $installment->paid = 0;
                 $installment->save();
                 $new_mm += 1;
                 if ($new_mm > 12) {
                     $new_mm = $new_mm - 12;
                     $yy += 1;
                 }
             }
         }
         // Placements
         $courses = Input::get('course');
         foreach ($courses as $key => $value) {
             $course = explode("#", $value);
             $placement = new Placement();
             $placement->project_id = Auth::user()->curr_project_id;
             $placement->location_id = Auth::user()->location_id;
             $placement->registration_id = $registration->id;
             $placement->issue_id = $issue->id;
             $placement->course_id = $course[0];
             $placement->save();
         }
         // Reductions - Discounts
         $discounts = Input::get('discounts');
         if ($discounts) {
             foreach ($discounts as $key => $value) {
                 $discount = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Discount';
                 $reduction->reductable_id = $discount[0];
                 $reduction->save();
             }
         }
         // Reductions - Promotions
         $promotions = Input::get('promotions');
         if ($promotions) {
             foreach ($promotions as $key => $value) {
                 $promotion = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Promotion';
                 $reduction->reductable_id = $promotion[0];
                 $reduction->save();
             }
         }
         // Reductions - Vouchers
         $vouchers = Input::get('vouchers');
         if ($vouchers) {
             foreach ($vouchers as $key => $value) {
                 $voucher = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Voucher';
                 $reduction->reductable_id = $voucher[0];
                 $reduction->save();
             }
         }
         // Reductions - Charges
         $charges = Input::get('charges');
         if ($charges) {
             foreach ($charges as $key => $value) {
                 $charger = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Charge';
                 $reduction->reductable_id = $charger[0];
                 $reduction->save();
             }
         }
         // Updating Student Timelines
         $content = 'Bergabung menjadi Siswa One School ' . Auth::user()->location->name . 'untuk periode ' . Auth::user()->curr_project->name;
         $timeline = new Timeline();
         $timeline->project_id = Auth::user()->curr_project_id;
         $timeline->location_id = Auth::user()->location_id;
         $timeline->informable_type = 'Issue';
         $timeline->informable_id = $issue->id;
         $timeline->content = $content;
         $timeline->save();
         // Updating Employee Timeline
         $content = 'Menerima Pendaftaran Siswa untuk periode ' . Auth::user()->curr_project->name;
         $timeline = new Timeline();
         $timeline->project_id = Auth::user()->curr_project_id;
         $timeline->location_id = Auth::user()->location_id;
         $timeline->informable_type = 'Employee';
         $timeline->informable_id = Input::get('employee');
         $timeline->content = $content;
         $timeline->save();
         //DB::commit();
         return Response::json(array('status' => 'Succeed', 'registration_id' => $registration->id, 'issue_id' => $issue->id));
     } catch (Exception $e) {
         DB::rollback();
         return Response::json(array('status' => 'Failed', 'error' => $e));
     }
 }
コード例 #6
0
ファイル: educations.php プロジェクト: anggadjava/payroll
 function save()
 {
     $education = new Education();
     $education->staff_id = $this->staff_id;
     $education->edu_year = $this->input->post('edu_year');
     $education->edu_gelar = $this->input->post('edu_gelar');
     $education->edu_name = $this->input->post('edu_name');
     if ($education->save()) {
         $this->session->set_flashdata('message', 'Education successfully created!');
         redirect('staffs/' . $this->staff_id . '/educations/index');
     } else {
         // Failed
         $education->error_message('custom', 'Field required');
         $msg = $education->error->custom;
         $this->session->set_flashdata('message', $msg);
         redirect('staffs/' . $this->staff_id . '/educations/add');
     }
 }
コード例 #7
0
 public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $file = $folder . basename($_FILES['uploadfile']['name']);
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
         $row = 0;
         if (($handle = fopen($file, "r")) !== FALSE) {
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if ($row > 0) {
                     $model = Education::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Education();
                     }
                     $model->educationid = (int) $data[0];
                     $model->educationname = $data[1];
                     $model->recordstatus = (int) $data[2];
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         }
                     } catch (Exception $e) {
                         $this->messages = $this->messages . $e->getMessage();
                     }
                 }
                 $row++;
             }
         } else {
             $this->messages = $this->messages . ' memory or harddisk full';
         }
         fclose($handle);
     } else {
         $this->messages = $this->messages . ' check your directory permission';
     }
     if ($this->messages == '') {
         $this->messages = 'success';
     }
     echo $this->messages;
 }
コード例 #8
0
 /**
  * Store a newly created template in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Template::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $template = new Template();
         $template->color = Input::get('color');
         $template->layout = Input::get('templateID');
         $template->user_id = Auth::id();
         $template->save();
         //Storing header info
         if (Input::has('headerJobTitle')) {
             $header = new Header1();
             $header->job_title = Input::get('headerJobTitle');
             $header->template_id = $template->id;
             if (Input::has('headerResumeTitle')) {
                 $header->description = Input::get('headerResumeTitle');
             }
             if (Input::hasFile('headerImage')) {
                 $header->picture = Input::file('headerImage')->move("images/uploaded/");
             }
             if (Input::has('headerJobTitle')) {
                 $header->description = Input::get('headerJobTitle');
             }
             $header->save();
         }
         //Storing adjectives for template 2
         if (Input::has('adjectives1')) {
             $header1 = new Header1();
             $header1->template_id = $template->id;
             $header1->adjective = Input::get('adjectives1');
             $header1->save();
         }
         if (Input::has('adjectives2')) {
             $header2 = new Header1();
             $header2->template_id = $template->id;
             $header2->adjective = Input::get('adjectives2');
             $header2->save();
         }
         if (Input::has('adjectives3')) {
             $header3 = new Header1();
             $header3->template_id = $template->id;
             $header3->adjective = Input::get('adjectives3');
             $header3->save();
         }
         //Checking for up to 6 skill inputs to be accpeted
         if (Input::has('skillPercent1') && Input::has('skillTitle1')) {
             $skill1 = new Skill();
             $skill1->template_id = $template->id;
             $skill1->percent = Input::get('skillPercent1');
             $skill1->skill_title = Input::get('skillTitle1');
             if (Input::has('skillDescription1')) {
                 $skill1->description = Input::get('skillDescription1');
             }
             if (Input::has('skillDescriptionTitle1')) {
                 $skill1->description_title = Input::get('skillDescriptionTitle1');
             }
             if (Input::has('hobbies1')) {
                 $skill1->description_title = Input::get('hobbies1');
             }
             $skill1->save();
         }
         if (Input::has('skillPercent2') && Input::has('skillTitle2')) {
             $skill2 = new Skill();
             $skill2->template_id = $template->id;
             $skill2->percent = Input::get('skillPercent2');
             $skill2->skill_title = Input::get('skillTitle2');
             if (Input::has('skillDescription2')) {
                 $skill2->description = Input::get('skillDescription2');
             }
             if (Input::has('skillDescriptionTitle2')) {
                 $skill2->description_title = Input::get('skillDescriptionTitle2');
             }
             if (Input::has('hobbies2')) {
                 $skill2->description_title = Input::get('hobbies2');
             }
             $skill2->save();
         }
         if (Input::has('skillPercent3') && Input::has('skillTitle3')) {
             $skill3 = new Skill();
             $skill3->template_id = $template->id;
             $skill3->percent = Input::get('skillPercent3');
             $skill3->skill_title = Input::get('skillTitle3');
             if (Input::has('skillDescription3')) {
                 $skill3->description = Input::get('skillDescription3');
             }
             if (Input::has('skillDescriptionTitle3')) {
                 $skill3->description_title = Input::get('skillDescriptionTitle3');
             }
             if (Input::has('hobbies3')) {
                 $skill3->description_title = Input::get('hobbies3');
             }
             $skill3->save();
         }
         if (Input::has('skillPercent4') && Input::has('skillTitle4')) {
             $skill4 = new Skill();
             $skill4->template_id = $template->id;
             $skill4->percent = Input::get('skillPercent4');
             $skill4->skill_title = Input::get('skillTitle4');
             if (Input::has('skillDescription4') && Input::has('descriptionTitle4')) {
                 $skill4->description = Input::get('skillDescription4');
             }
             if (Input::has('skillDescriptionTitle4')) {
                 $skill4->description_title = Input::get('skillDescriptionTitle4');
             }
             $skill4->save();
         }
         if (Input::has('skillPercent5') && Input::has('skillTitle5')) {
             $skill5 = new Skill();
             $skill5->template_id = $template->id;
             $skill5->percent = Input::get('skillPercent5');
             $skill5->skill_title = Input::get('skillTitle5');
             if (Input::has('skillDescription5')) {
                 $skill5->description = Input::get('skillDescription5');
             }
             if (Input::has('skillDescriptionTitle5')) {
                 $skill5->description_title = Input::get('skillDescriptionTitle5');
             }
             $skill5->save();
         }
         //Knowledge storage starts here for template 2
         if (Input::has('knowledge1') && Input::has('miscHead1') && Input::has('miscFoot1') && Input::has('miscPercent1')) {
             $knowledge1 = new Knowledge();
             $knowledge1->template_id = $template->id;
             $knowledge1->knowledge_item = Input::get('knowledge1');
             $knowledge1->sub_percent = Input::get('miscPercent1');
             $knowledge1->sub_head = Input::get('miscHead1');
             $knowledge1->sub_foot = Input::get('miscFoot1');
             if (Input::has('miscTitle1')) {
                 $knowledge1->sub_title = Input::get('miscTitle1');
             }
             $knowledge1->save();
         }
         if (Input::has('knowledge2') && Input::has('miscHead2') && Input::has('miscFoot2') && Input::has('miscPercent2')) {
             $knowledge2 = new Knowledge();
             $knowledge2->template_id = $template->id;
             $knowledge2->knowledge_item = Input::get('knowledge2');
             $knowledge2->sub_percent = Input::get('miscPercent2');
             $knowledge2->sub_head = Input::get('miscHead2');
             $knowledge2->sub_foot = Input::get('miscFoot2');
             $knowledge2->save();
         }
         if (Input::has('knowledge3') && Input::has('miscHead3') && Input::has('miscFoot3') && Input::has('miscPercent3')) {
             $knowledge3 = new Knowledge();
             $knowledge3->template_id = $template->id;
             $knowledge3->knowledge_item = Input::get('knowledge3');
             $knowledge3->sub_percent = Input::get('miscPercent3');
             $knowledge3->sub_head = Input::get('miscHead3');
             $knowledge3->sub_foot = Input::get('miscFoot3');
             $knowledge3->save();
         }
         if (Input::has('knowledge4') && Input::has('miscHead4') && Input::has('miscFoot4') && Input::has('miscPercent4')) {
             $knowledge4 = new Knowledge();
             $knowledge4->template_id = $template->id;
             $knowledge4->knowledge_item = Input::get('knowledge4');
             $knowledge4->sub_percent = Input::get('miscPercent4');
             $knowledge4->sub_head = Input::get('miscHead4');
             $knowledge4->sub_foot = Input::get('miscFoot4');
             $knowledge4->save();
         }
         if (Input::has('aboutDescription1')) {
             $abouts1 = new About();
             $abouts1->template_id = $template->id;
             $abouts1->description = Input::get('aboutDescription1');
             if (Input::has('aboutTitle')) {
                 $abouts1->title = Input::get('aboutTitle');
             }
             if (Input::hasFile('aboutBackgroundImage1')) {
                 $abouts1->picture = Input::file('aboutBackgroundImage1')->move("images/uploaded/");
             }
             $abouts1->save();
         }
         if (Input::has('aboutDescription2')) {
             $abouts2 = new About();
             $abouts2->template_id = $template->id;
             $abouts2->description = Input::get('aboutDescription2');
             if (Input::has('aboutTitle')) {
                 $abouts2->title = Input::get('aboutTitle');
             }
             if (Input::hasFile('aboutBackgroundImage2')) {
                 $abouts2->picture = Input::file('aboutBackgroundImage2')->move("images/uploaded/");
             }
             $abouts2->save();
         }
         if (Input::has('aboutDescription3')) {
             $abouts3 = new About();
             $abouts3->template_id = $template->id;
             $abouts3->description = Input::get('aboutDescription3');
             if (Input::has('aboutTitle')) {
                 $abouts3->title = Input::get('aboutTitle');
             }
             if (Input::hasFile('aboutBackgroundImage3')) {
                 $abouts3->picture = Input::file('aboutBackgroundImage3')->move("images/uploaded/");
             }
             $abouts3->save();
         }
         if (Input::has('contactDescription')) {
             $contacts = new Contact();
             $contacts->template_id = $template->id;
             $contacts->description = Input::get('contactDescription');
             $contacts->save();
         }
         //Storing services currently for template 2
         if (Input::has('serviceTitle1') || Input::has('serviceTitle2') || Input::has('serviceTitle3') || Input::has('serviceTitle4') || Input::has('serviceTitle5') || Input::has('serviceTitle6')) {
             if (Input::has('serviceTitle1') && Input::has('serviceDescription1')) {
                 $service1 = new Service();
                 $service1->template_id = $template->id;
                 $service1->title = Input::get('serviceTitle1');
                 $service1->description = Input::get('serviceDescription1');
                 $service1->save();
             }
             if (Input::has('serviceTitle2') && Input::has('serviceDescription2')) {
                 $service2 = new Service();
                 $service2->template_id = $template->id;
                 $service2->title = Input::get('serviceTitle2');
                 $service2->description = Input::get('serviceDescription2');
                 $service2->save();
             }
             if (Input::has('serviceTitle3') && Input::has('serviceDescription3')) {
                 $service3 = new Service();
                 $service3->template_id = $template->id;
                 $service3->title = Input::get('serviceTitle3');
                 $service3->description = Input::get('serviceDescription3');
                 $service3->save();
             }
             if (Input::has('serviceTitle4') && Input::has('serviceDescription4')) {
                 $service4 = new Service();
                 $service4->template_id = $template->id;
                 $service4->title = Input::get('serviceTitle4');
                 $service4->description = Input::get('serviceDescription4');
                 $service4->save();
             }
             if (Input::has('serviceTitle5') && Input::has('serviceDescription5')) {
                 $service5 = new Service();
                 $service5->template_id = $template->id;
                 $service5->title = Input::get('serviceTitle5');
                 $service5->description = Input::get('serviceDescription5');
                 $service5->save();
             }
             if (Input::has('serviceTitle6') && Input::has('serviceDescription6')) {
                 $service6 = new Service();
                 $service6->template_id = $template->id;
                 $service6->title = Input::get('serviceTitle6');
                 $service6->description = Input::get('serviceDescription6');
                 $service6->save();
             }
         }
         //There are the inputs for the portfolio storeTemplate1Images
         if (Input::has('portfolioDescription1')) {
             $portfolio1 = new Portfolio();
             if (Input::has('portfolioTitle1')) {
                 $portfolio1->title = Input::get('portfolioTitle1');
             }
             $portfolio1->template_id = $template->id;
             $portfolio1->description = Input::get('portfolioDescription1');
             if (Input::hasFile('portfolioPicture1')) {
                 $portfolio1->picture = Input::file('portfolioPicture1')->move("img/uploaded/");
             }
             if (Input::has('portfolioLink1')) {
                 $portfolio1->link = Input::get('portfolioLink1');
             }
             if (Input::has('portfolioCategory1')) {
                 $portfolio1->category = Input::get('portfolioCategory1');
             }
             $portfolio1->save();
         }
         if (Input::has('portfolioDescription2')) {
             $portfolio2 = new Portfolio();
             if (Input::has('portfolioTitle2')) {
                 $portfolio2->title = Input::get('portfolioTitle2');
             }
             $portfolio2->template_id = $template->id;
             $portfolio2->description = Input::get('portfolioDescription2');
             if (Input::hasFile('portfolioPicture2')) {
                 $portfolio2->picture = Input::file('portfolioPicture2')->move("img/uploaded/");
             }
             if (Input::has('portfolioLink2')) {
                 $portfolio2->link = Input::get('portfolioLink2');
             }
             if (Input::has('portfolioCategory2')) {
                 $portfolio2->category = Input::get('portfolioCategory2');
             }
             $portfolio2->save();
         }
         if (Input::has('portfolioDescription3')) {
             $portfolio3 = new Portfolio();
             if (Input::has('portfolioTitle3')) {
                 $portfolio3->title = Input::get('portfolioTitle3');
             }
             $portfolio3->template_id = $template->id;
             $portfolio3->description = Input::get('portfolioDescription3');
             if (Input::hasFile('portfolioPicture3')) {
                 $portfolio3->picture = Input::file('portfolioPicture3')->move("img/uploaded/");
             }
             if (Input::has('portfolioLink3')) {
                 $portfolio3->link = Input::get('portfolioLink3');
             }
             if (Input::has('portfolioCategory3')) {
                 $portfolio3->category = Input::get('portfolioCategory3');
             }
             $portfolio3->save();
         }
         if (Input::has('portfolioDescription4')) {
             $portfolio4 = new Portfolio();
             if (Input::has('portfolioTitle4')) {
                 $portfolio4->title = Input::get('portfolioTitle4');
             }
             $portfolio4->template_id = $template->id;
             $portfolio4->description = Input::get('portfolioDescription4');
             if (Input::hasFile('portfolioPicture4')) {
                 $portfolio4->picture = Input::file('portfolioPicture4')->move("img/uploaded/");
             }
             if (Input::has('portfolioLink4')) {
                 $portfolio4->link = Input::get('portfolioLink4');
             }
             if (Input::has('portfolioCategory4')) {
                 $portfolio4->category = Input::get('portfolioCategory4');
             }
             $portfolio4->save();
         }
         if (Input::has('portfolioDescription5')) {
             $portfolio5 = new Portfolio();
             if (Input::has('portfolioTitle5')) {
                 $portfolio5->title = Input::get('portfolioTitle5');
             }
             $portfolio5->template_id = $template->id;
             $portfolio5->description = Input::get('portfolioDescription5');
             if (Input::hasFile('portfolioPicture5')) {
                 $portfolio5->picture = Input::file('portfolioPicture5')->move("img/uploaded/");
             }
             if (Input::has('portfolioLink5')) {
                 $portfolio5->link = Input::get('portfolioLink5');
             }
             if (Input::has('portfolioCategory5')) {
                 $portfolio5->category = Input::get('portfolioCategory5');
             }
             $portfolio5->save();
         }
         if (Input::has('portfolioDescription6')) {
             $portfolio6 = new Portfolio();
             if (Input::has('portfolioTitle6')) {
                 $portfolio6->title = Input::get('portfolioTitle6');
             }
             $portfolio6->template_id = $template->id;
             $portfolio6->description = Input::get('portfolioDescription6');
             if (Input::hasFile('portfolioPicture6')) {
                 $portfolio6->picture = Input::file('portfolioPicture6')->move("img/uploaded/");
             }
             if (Input::hasFile('portfolioLink6')) {
                 $portfolio6->link = Input::get('portfolioLink6');
             }
             if (Input::hasFile('portfolioCategory6')) {
                 $portfolio6->category = Input::get('portfolioCategory6');
             }
             $portfolio6->save();
         }
         //Awards
         if (Input::has('awardTitle1') && Input::has('awardNumber1')) {
             $award1 = new Award();
             $award1->template_id = $template->id;
             $award1->award_number = Input::get('awardTitle1');
             $award1->award_title = Input::get('awardNumber1');
             $award1->save();
         }
         if (Input::has('awardTitle2') && Input::has('awardNumber2')) {
             $award2 = new Award();
             $award2->template_id = $template->id;
             $award2->award_number = Input::get('awardTitle2');
             $award2->award_title = Input::get('awardNumber2');
             $award2->save();
         }
         if (Input::has('awardTitle3') && Input::has('awardNumber3')) {
             $award3 = new Award();
             $award3->template_id = $template->id;
             $award3->award_number = Input::get('awardTitle3');
             $award3->award_title = Input::get('awardNumber3');
             $award3->save();
         }
         //Storing up to 6 work experience sections
         if (Input::has('workExperienceStart1') && Input::has('workExperienceDescription1') && Input::has('workExperienceTitle1')) {
             $experience1 = new workExperience();
             if (Input::has('workExperienceExtraText1')) {
                 $experience1->description = Input::get('workExperienceExtraText1');
             }
             $experience1->template_id = $template->id;
             $experience1->start_date = Input::get('workExperienceStart1');
             $experience1->title = Input::get('workExperienceTitle1');
             $experience1->description = Input::get('workExperienceDescription1');
             if (Input::has('workExperienceEnd1')) {
                 $experience1->end_date = Input::get('workExperienceEnd1');
             }
             $experience1->save();
         }
         if (Input::has('workExperienceStart2') && Input::has('workExperienceDescription2') && Input::has('workExperienceTitle2')) {
             $experience2 = new workExperience();
             $experience2->template_id = $template->id;
             $experience2->start_date = Input::get('workExperienceStart2');
             $experience2->title = Input::get('workExperienceTitle2');
             $experience2->description = Input::get('workExperienceDescription2');
             if (Input::has('workExperienceEnd2')) {
                 $experience2->end_date = Input::get('workExperienceEnd2');
             }
             $experience2->save();
         }
         if (Input::has('workExperienceStart3') && Input::has('workExperienceDescription3') && Input::has('workExperienceTitle3')) {
             $experience3 = new workExperience();
             $experience3->template_id = $template->id;
             $experience3->start_date = Input::get('workExperienceStart3');
             $experience3->title = Input::get('workExperienceTitle3');
             $experience3->description = Input::get('workExperienceDescription3');
             if (Input::has('workExperienceEnd3')) {
                 $experience3->end_date = Input::get('workExperienceEnd3');
             }
             $experience3->save();
         }
         if (Input::has('workExperienceStart4') && Input::has('workExperienceDescription4') && Input::has('workExperienceTitle4')) {
             $experience4 = new workExperience();
             $experience4->template_id = $template->id;
             $experience4->start_date = Input::get('workExperienceStart4');
             $experience4->title = Input::get('workExperienceTitle4');
             $experience4->description = Input::get('workExperienceDescription4');
             if (Input::has('workExperienceEnd4')) {
                 $experience4->end_date = Input::get('workExperienceEnd4');
             }
             $experience4->save();
         }
         if (Input::has('workExperienceStart5') && Input::has('workExperienceDescription5') && Input::has('workExperienceTitle5')) {
             $experience5 = new workExperience();
             $experience5->template_id = $template->id;
             $experience5->start_date = Input::get('workExperienceStart5');
             $experience5->title = Input::get('workExperienceTitle5');
             $experience5->description = Input::get('workExperienceDescription5');
             if (Input::has('workExperienceEnd5')) {
                 $experience5->end_date = Input::get('workExperienceEnd5');
             }
             $experience5->save();
         }
         if (Input::has('workExperienceStart6') && Input::has('workExperienceDescription6') && Input::has('workExperienceTitle6')) {
             $experience6 = new workExperience();
             $experience6->template_id = $template->id;
             $experience6->start_date = Input::get('workExperienceStart6');
             $experience6->title = Input::get('workExperienceTitle6');
             $experience6->description = Input::get('workExperienceDescription6');
             if (Input::has('workExperienceEnd6')) {
                 $experience6->end_date = Input::get('workExperienceEnd6');
             }
             $experience6->save();
         }
         if (Input::has('educationStart1') && Input::has('educationDescription1') && Input::has('educationTitle1')) {
             $education1 = new Education();
             $education1->template_id = $template->id;
             $education1->start_date = Input::get('educationStart1');
             if (Input::has('educationEnd1')) {
                 $education1->end_date = Input::get('educationEnd1');
             }
             $education1->title = Input::get('educationTitle1');
             $education1->description = Input::get('educationDescription1');
             $education1->save();
         }
         if (Input::has('educationStart2') && Input::has('educationDescription2') && Input::has('educationTitle2')) {
             $education2 = new Education();
             $education2->template_id = $template->id;
             $education2->start_date = Input::get('educationStart2');
             if (Input::has('educationEnd2')) {
                 $education2->end_date = Input::get('educationEnd2');
             }
             $education2->title = Input::get('educationTitle2');
             $education2->description = Input::get('educationDescription2');
             $education2->save();
         }
         if (Input::has('educationStart3') && Input::has('educationDescription3') && Input::has('educationTitle3')) {
             $education3 = new Education();
             $education3->template_id = $template->id;
             $education3->start_date = Input::get('educationStart3');
             if (Input::has('educationEnd3')) {
                 $education3->end_date = Input::get('educationEnd3');
             }
             $education3->title = Input::get('educationTitle3');
             $education3->description = Input::get('educationDescription3');
             $education3->save();
         }
         if (Input::has('educationStart4') && Input::has('educationDescription4') && Input::has('educationTitle4')) {
             $education4 = new Education();
             $education4->template_id = $template->id;
             $education4->start_date = Input::get('educationStart4');
             if (Input::has('educationEnd4')) {
                 $education4->end_date = Input::get('educationEnd4');
             }
             $education4->title = Input::get('educationTitle4');
             $education4->description = Input::get('educationDescription4');
             $education4->save();
         }
     }
     return Redirect::action('UsersController@getProfile');
 }
コード例 #9
0
 public function run()
 {
     $education = new Education();
     $education->description = "I worked as a fisher";
     $education->title = "Fisherman";
     $education->start_date = "June 6, 1990";
     $education->end_date = "May 7, 2000";
     $education->template_id = 1;
     $education->save();
     $education2 = new Education();
     $education2->description = "I worked as a fisher";
     $education2->title = "Fisherman";
     $education2->start_date = "June 6, 1990";
     $education2->end_date = "May 7, 2000";
     $education2->template_id = 1;
     $education2->save();
     $education3 = new Education();
     $education3->description = "I worked as a fisher";
     $education3->title = "Fisherman";
     $education3->start_date = "June 6, 1990";
     $education3->end_date = "May 7, 2000";
     $education3->template_id = 1;
     $education3->save();
     $education4 = new Education();
     $education4->description = "I worked as a fisher";
     $education4->title = "Fisherman";
     $education4->start_date = "June 6, 1990";
     $education4->end_date = "May 7, 2000";
     $education4->template_id = 1;
     $education4->save();
     $education5 = new Education();
     $education5->description = "I worked as a fisher";
     $education5->title = "Fisherman";
     $education5->start_date = "June 6, 1990";
     $education5->end_date = "May 7, 2000";
     $education5->template_id = 2;
     $education5->save();
     $education6 = new Education();
     $education6->description = "I worked as a fisher";
     $education6->title = "Fisherman";
     $education6->start_date = "June 6, 1990";
     $education6->end_date = "May 7, 2000";
     $education6->template_id = 2;
     $education6->save();
     $education7 = new Education();
     $education7->description = "I worked as a fisher";
     $education7->title = "Fisherman";
     $education7->start_date = "June 6, 1990";
     $education7->end_date = "May 7, 2000";
     $education7->template_id = 2;
     $education7->save();
     $education8 = new Education();
     $education8->description = "I worked as a fisher";
     $education8->title = "Fisherman";
     $education8->start_date = "June 6, 1990";
     $education8->end_date = "May 7, 2000";
     $education8->template_id = 2;
     $education8->save();
     $education9 = new Education();
     $education9->description = "I worked as a fisher";
     $education9->title = "Fisherman";
     $education9->start_date = "June 6, 1990";
     $education9->end_date = "May 7, 2000";
     $education9->template_id = 3;
     $education9->save();
     $education10 = new Education();
     $education10->description = "I worked as a fisher";
     $education10->title = "Fisherman";
     $education10->start_date = "June 6, 1990";
     $education10->end_date = "May 7, 2000";
     $education10->template_id = 3;
     $education10->save();
     $education11 = new Education();
     $education11->description = "I worked as a fisher";
     $education11->title = "Fisherman";
     $education11->start_date = "June 6, 1990";
     $education11->end_date = "May 7, 2000";
     $education11->template_id = 3;
     $education11->save();
     $education12 = new Education();
     $education12->description = "I worked as a fisher";
     $education12->title = "Fisherman";
     $education12->start_date = "June 6, 1990";
     $education12->end_date = "May 7, 2000";
     $education12->template_id = 3;
     $education12->save();
 }
コード例 #10
0
}
$journo = db_getRow("SELECT * FROM journo WHERE id=?", $journo_id);
admPageHeader($journo['ref'] . " Education Info");
$action = get_http_var('_action');
if ($action == 'update' || $action == 'create') {
    // form has been submitted
    $obj = new Education();
    $obj->fromHTTPVars($_POST);
    /*
        print"<hr/><pre><code>\n";
        print_r( $_POST );
        print "--------\n";
        print_r( $obj );
        print"</code></pre><hr/>\n";
    */
    $obj->save();
    ?>
<div class="info">Saved.</div>
<?php 
} else {
    $obj = new Education();
    if (!$id) {
        // it's new.
        $obj->journo_id = $journo_id;
    } else {
        // fetch from db
        $sql = <<<EOT
SELECT e.*,
        l.id as src__id,
        l.url as src__url,
        l.title as src__title,
コード例 #11
0
ファイル: UserController.php プロジェクト: erick305/testing
 public function actionRegisterLinkedIn()
 {
     // if user canceled, redirect to home page
     if (isset($_GET['oauth_problem'])) {
         $problem = $_GET['oauth_problem'];
         if ($problem == 'user_refused') {
             $this->redirect('/JobFair/index.php');
         }
     }
     if (!isset($_SESSION)) {
         session_start();
     }
     //edit by Manuel making the link dynamic, using Yii
     $config['base_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/auth1.php';
     $config['callback_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/RegisterLinkedIn';
     $config['linkedin_access'] = '2rtmn93gu2m4';
     $config['linkedin_secret'] = 'JV0fYG9ls3rclP8v';
     include_once Yii::app()->basePath . "/views/user/linkedin.php";
     # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
     $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
     //$linkedin->debug = true;
     if (isset($_REQUEST['oauth_verifier'])) {
         $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
         $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
         header("Location: " . $config['callback_url']);
         exit;
     } else {
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
     }
     # You now have a $linkedin->access_token and can make calls on behalf of the current member
     $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,industry,email-address,languages,phone-numbers,skills,educations,location:(name),positions,picture-urls::(original))");
     $data = simplexml_load_string($xml_response);
     // get user by linkedinid
     $model = new User();
     $user = User::model()->findByAttributes(array('linkedinid' => $data->id));
     // check if user exits in database, if so login
     if ($user != null) {
         if ($user->disable != 1) {
             $identity = new UserIdentity($user->username, '');
             if ($identity->authenticateOutside()) {
                 Yii::app()->user->login($identity);
             }
             $this->redirect("/JobFair/index.php/home/studenthome");
             return;
         } else {
             $this->redirect("/JobFair/index.php/site/page?view=disableUser");
             return;
         }
         // register
     } else {
         // 			print "<pre>"; print_r('user is null');print "</pre>";
         // check that there is no duplicate user if so link to that account
         $duplicateUser = User::model()->findByAttributes(array('email' => $data->{'email-address'}));
         if ($duplicateUser != null) {
             // get username and link the accounts
             $username = $duplicateUser->username;
             $user = User::model()->find("username=:username", array(':username' => $username));
             $user->linkedinid = $data->{'id'};
             $user->save(false);
             $user_id = $user->id;
             // ------------------BASIC INFO---------------
             $basic_info = null;
             $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $user_id));
             if ($basic_info == null) {
                 $basic_info = new BasicInfo();
             }
             $basic_info->userid = $user_id;
             $basic_info->save(false);
             // ------------------BASIC INFO -----------------
             // -----------------EDUCATION ----------------------
             // get number of educations to add
             $educ_count = $data->educations['total'];
             // delete current educations
             $delete_educs = Education::model()->findAllByAttributes(array('FK_user_id' => $user_id));
             foreach ($delete_educs as $de) {
                 $de->delete();
             }
             // add educations
             for ($i = 0; $i < $educ_count; $i++) {
                 // first check if current education is in school table. if not, add it
                 $current_school_name = $data->educations->education[$i]->{'school-name'};
                 $school_exists = School::model()->findByAttributes(array('name' => $current_school_name));
                 if ($school_exists == null) {
                     $new_school = new School();
                     $new_school->name = $current_school_name;
                     $new_school->save();
                     $school_id = School::model()->findByAttributes(array('name' => $current_school_name))->id;
                 } else {
                     $school_id = $school_exists->id;
                 }
                 // now ready to add new education
                 $new_educ = new Education();
                 $new_educ->degree = $data->educations->education[$i]->degree;
                 $new_educ->major = $data->educations->education[$i]->{'field-of-study'};
                 // 	   	$model->admission_date=date('Y-m-d',strtotime($model->admission_date));
                 $new_educ->graduation_date = date('Y-m-d', strtotime($data->educations->education[$i]->{'end-date'}->year));
                 // 	   	print "<pre>"; print_r($new_educ->graduation_date);print "</pre>";return;
                 $new_educ->FK_school_id = $school_id;
                 $new_educ->FK_user_id = $user_id;
                 $new_educ->additional_info = $data->educations->education[$i]->notes;
                 $new_educ->save(false);
             }
             // -----------------EDUCATION ----------------------
             // -----------------EXPERIENCE -------------------
             // get number of educations to add
             $pos_count = $data->positions['total'];
             // delete current positions
             $delete_pos = Experience::model()->findAllByAttributes(array('FK_userid' => $user_id));
             foreach ($delete_pos as $de) {
                 $de->delete();
             }
             for ($i = 0; $i < $pos_count; $i++) {
                 $new_pos = new Experience();
                 $new_pos->FK_userid = $user_id;
                 $new_pos->company_name = $data->positions->position[$i]->company->name;
                 $new_pos->job_title = $data->positions->position[$i]->title;
                 $new_pos->job_description = $data->positions->position[$i]->summary;
                 $temp_start_date = $data->positions->position[$i]->{'start-date'}->month . '/01/' . $data->positions->position[$i]->{'start-date'}->year;
                 $new_pos->startdate = date('Y-m-d', strtotime($temp_start_date));
                 if ($data->positions->position[$i]->{'is-current'} == 'true') {
                     $new_pos->enddate = '';
                 } else {
                     $temp_end_date = $data->positions->position[$i]->{'end-date'}->month . '/01/' . $data->positions->position[$i]->{'end-date'}->year;
                     $new_pos->enddate = date('Y-m-d', strtotime($temp_end_date));
                 }
                 $new_pos->city = '';
                 $new_pos->state = '';
                 $new_pos->save(false);
             }
             // -----------------EXPERIENCE -------------------
             // ----------------------SKILLS----------------------
             // get number of educations to add
             $linkedin_skill_count = $data->skills['total'];
             for ($i = 0; $i < $linkedin_skill_count; $i++) {
                 // check if skill exists in skill set table, if not, add it to skill set table
                 if (Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name)) == null) {
                     $new_skill = new Skillset();
                     $new_skill->name = $data->skills->skill[$i]->skill->name;
                     $new_skill->save(false);
                     //echo 'New Skill ' . $new_skill->attributes;
                 }
                 // check if student has that skill, if not add it to student-skill-map table
                 if (StudentSkillMap::model()->findByAttributes(array('userid' => $user_id, 'skillid' => Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id)) == null) {
                     $new_sdnt_skill = new StudentSkillMap();
                     $new_sdnt_skill->userid = $user_id;
                     $new_sdnt_skill->skillid = Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id;
                     $new_sdnt_skill->ordering = $i + 1;
                     $new_sdnt_skill->save(false);
                     echo 'New Skill for student' . $new_sdnt_skill->attributes;
                 }
             }
             // ----------------------SKILLS----------------------
             if ($duplicateUser->disable != 1) {
                 $identity = new UserIdentity($duplicateUser->username, '');
                 if ($identity->authenticateOutside()) {
                     Yii::app()->user->login($identity);
                 }
                 $mesg = "LinkedIn";
                 //get variables
                 $mesg = "LinkedIn";
                 $phone = $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'};
                 if ($phone != null) {
                     $phone = strip_tags($data->{'phone-numbers'}->{'phone-number'}->{'phone-number'}->asXML());
                 }
                 $city = $data->location->name;
                 if ($city != null) {
                     $city = strip_tags($data->location->name->asXML());
                 }
                 $state = '';
                 $about_me = $data->headline;
                 if ($about_me != null) {
                     $about_me = strip_tags($data->headline->asXML());
                 }
                 $picture = $data->{'picture-urls'}->{'picture-url'}[0];
                 if ($picture != null) {
                     $picture = strip_tags($data->{'picture-urls'}->{'picture-url'}[0]->asXML());
                 }
                 $this->actionLinkTo($data->{'email-address'}, $data->{'first-name'}, $data->{'last-name'}, $picture, $mesg, $phone, $city, $state, $about_me);
                 return;
             } else {
                 $this->redirect("/JobFair/index.php/site/page?view=disableUser");
                 return;
             }
         }
         // Populate user attributes
         $model->FK_usertype = 1;
         $model->registration_date = new CDbExpression('NOW()');
         $model->activation_string = 'linkedin';
         $model->username = $data->{'email-address'}[0];
         $model->first_name = $data->{'first-name'};
         $model->last_name = $data->{'last-name'};
         $model->email = $data->{'email-address'};
         $model->image_url = $data->{'picture-urls'}->{'picture-url'}[0];
         $model->linkedinid = $data->id;
         //Hash the password before storing it into the database
         $hasher = new PasswordHash(8, false);
         $model->password = $hasher->HashPassword('tester');
         $model->activated = 1;
         $model->has_viewed_profile = 1;
         $model->save(false);
         // 		// ------------------BASIC INFO---------------
         $basic_info = null;
         $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $model->id));
         if ($basic_info == null) {
             $basic_info = new BasicInfo();
         }
         $basic_info->userid = $model->id;
         $basic_info->phone = $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'};
         $basic_info->city = $data->location->name;
         $basic_info->state = '';
         $basic_info->about_me = $data->headline;
         $basic_info->save(false);
         // ------------------BASIC INFO -----------------
         // -----------------EDUCATION ----------------------
         // get number of educations to add
         $educ_count = $data->educations['total'];
         // delete current educations
         $delete_educs = Education::model()->findAllByAttributes(array('FK_user_id' => $model->id));
         foreach ($delete_educs as $de) {
             $de->delete();
         }
         // add educations
         for ($i = 0; $i < $educ_count; $i++) {
             // first check if current education is in school table. if not, add it
             $current_school_name = $data->educations->education[$i]->{'school-name'};
             $school_exists = School::model()->findByAttributes(array('name' => $current_school_name));
             if ($school_exists == null) {
                 $new_school = new School();
                 $new_school->name = $current_school_name;
                 $new_school->save();
                 $school_id = School::model()->findByAttributes(array('name' => $current_school_name))->id;
             } else {
                 $school_id = $school_exists->id;
             }
             // now ready to add new education
             $new_educ = new Education();
             $new_educ->degree = $data->educations->education[$i]->degree;
             $new_educ->major = $data->educations->education[$i]->{'field-of-study'};
             // 	   	$model->admission_date=date('Y-m-d',strtotime($model->admission_date));
             $new_educ->graduation_date = date('Y-m-d', strtotime($data->educations->education[$i]->{'end-date'}->year));
             // 	   	print "<pre>"; print_r($new_educ->graduation_date);print "</pre>";return;
             $new_educ->FK_school_id = $school_id;
             $new_educ->FK_user_id = $model->id;
             $new_educ->additional_info = $data->educations->education[$i]->notes;
             $new_educ->save(false);
         }
         // -----------------EDUCATION ----------------------
         // -----------------EXPERIENCE -------------------
         // get number of educations to add
         $pos_count = $data->positions['total'];
         // delete current positions
         $delete_pos = Experience::model()->findAllByAttributes(array('FK_userid' => $model->id));
         foreach ($delete_pos as $de) {
             $de->delete();
         }
         for ($i = 0; $i < $pos_count; $i++) {
             $new_pos = new Experience();
             $new_pos->FK_userid = $model->id;
             $new_pos->company_name = $data->positions->position[$i]->company->name;
             $new_pos->job_title = $data->positions->position[$i]->title;
             $new_pos->job_description = $data->positions->position[$i]->summary;
             $temp_start_date = $data->positions->position[$i]->{'start-date'}->month . '/01/' . $data->positions->position[$i]->{'start-date'}->year;
             $new_pos->startdate = date('Y-m-d', strtotime($temp_start_date));
             if ($data->positions->position[$i]->{'is-current'} == 'true') {
                 $new_pos->enddate = '';
             } else {
                 $temp_end_date = $data->positions->position[$i]->{'end-date'}->month . '/01/' . $data->positions->position[$i]->{'end-date'}->year;
                 $new_pos->enddate = date('Y-m-d', strtotime($temp_end_date));
             }
             $new_pos->city = '';
             $new_pos->state = '';
             $new_pos->save(false);
         }
         // -----------------EXPERIENCE -------------------
         // ----------------------SKILLS----------------------
         // get number of educations to add
         $linkedin_skill_count = $data->skills['total'];
         for ($i = 0; $i < $linkedin_skill_count; $i++) {
             // check if skill exists in skill set table, if not, add it to skill set table
             if (Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name)) == null) {
                 $new_skill = new Skillset();
                 $new_skill->name = $data->skills->skill[$i]->skill->name;
                 $new_skill->save(false);
                 //echo 'New Skill ' . $new_skill->attributes;
             }
             // check if student has that skill, if not add it to student-skill-map table
             if (StudentSkillMap::model()->findByAttributes(array('userid' => $model->id, 'skillid' => Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id)) == null) {
                 $new_sdnt_skill = new StudentSkillMap();
                 $new_sdnt_skill->userid = $model->id;
                 $new_sdnt_skill->skillid = Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id;
                 $new_sdnt_skill->ordering = $i + 1;
                 $new_sdnt_skill->save(false);
             }
         }
         // ----------------------SKILLS----------------------
         // LOGIN
         $user = User::model()->find("username=:username", array(':username' => $model->username));
         $identity = new UserIdentity($user->username, 'tester');
         if ($identity->authenticate()) {
             Yii::app()->user->login($identity);
         }
         $this->redirect("/JobFair/index.php/user/ChangeFirstPassword");
     }
 }
コード例 #12
0
ファイル: CVController.php プロジェクト: vishu87/cpr
 public function postEducation()
 {
     $cre = ['coursename' => Input::get('coursename'), 'institutename' => Input::get('institutename')];
     $rules = ['coursename' => 'required', 'institutename' => 'required'];
     $validator = Validator::make($cre, $rules);
     if ($validator->passes()) {
         $education = new Education();
         $education->cv_id = Input::get('cv_id');
         $education->coursename = Input::get('coursename');
         $education->institutename = Input::get('institutename');
         $education->add_line1 = Input::get('add_line1');
         $education->add_line2 = Input::get('add_line2');
         $education->startdate = Input::get('startdate');
         $education->enddate = Input::get('enddate');
         $education->otherinfo = Input::get('otherinfo');
         $education->save();
         $insert_id = $education->id;
         $data["success"] = true;
         $data["message"] = 'Education details are succefully added';
         $data["title"] = Input::get('title');
         $data["id"] = $insert_id;
         $data["coursename"] = Input::get('coursename');
         $data["institutename"] = Input::get('institutename');
         $data["startdate"] = Input::get('startdate');
         $data["enddate"] = Input::get('enddate');
     } else {
         $data["success"] = false;
         $data["message"] = 'Please fill required fields';
     }
     return json_encode($data);
 }