Ejemplo n.º 1
0
 public function addEmployment()
 {
     $title = Input::get('title');
     $content = Input::get('content');
     $data = array('title' => $title, 'content' => $content);
     $rules = array('title' => 'required', 'content' => 'required');
     $validation = Validator::make($data, $rules);
     if ($validation->fails()) {
         return Response::json(array('errCode' => 1, 'message' => '信息填写不完整!'));
     }
     $employment = new Employment();
     $employment->title = $title;
     $employment->content = $content;
     if (!$employment->save()) {
         return Response::json(array('errCode' => 2, 'message' => '添加失败!'));
     }
     return Response::json(array('errCode' => 0, 'message' => '添加成功!'));
 }
            break;
        default:
            // Please remeber to set i
            break;
    }
    $employment->applicant_id = $session->applicant_id;
}
$employment_details = $employment->find_by_id($employment->applicant_id);
/*set employment_id*/
if (!empty($employment_details)) {
    $employment->employment_id = $employment_details->employment_id;
}
//print_r($employment);
/*insert new record or update existing record in the employment table*/
/*check any changes to the database employment table*/
if ($employment->save()) {
    $user = new User();
    $user->applicant_id = $session->applicant_id;
    $user->updateProgress('C');
    sleep(2);
    echo '<h4 class="alert alert-success"> <i class="iconic-o-check" style="color: #51A351"></i> Success</h4>';
    echo '<hr>';
    echo 'You have successfully saved your <span style=" font-weight: bold; text-shadow: 1px 1px 4px #51A351;"> Employment Details </span> tab.';
    echo '<br><hr>';
} else {
    sleep(2);
    echo '<h4 class="alert alert-error"><i class="iconic-o-x" style="color: red"></i> Error!</h4>';
    echo '<hr>';
    echo "Your details were not saved please try again later here";
    echo '<br><hr>';
}