/**
  * @param Career $model
  */
 private function edit(Career $model)
 {
     if (isset($_POST['Career']) && $_POST['Career']) {
         $model->attributes = $_POST['Career'];
         if ($model->save()) {
             $this->redirect(array('update', 'id' => $model->id));
         }
     }
     $this->render('edit', array('model' => $model));
 }
 public function add_career()
 {
     $this->_checkPermission();
     $data = $_POST['career'];
     Flash::set('postdata', $data);
     // verification
     if (empty($data['title'])) {
         Flash::set('error', __('You have to specify a job title!'));
         redirect(get_url('career/create'));
     }
     // if (empty($data['contact_person'])){
     // 	Flash::set('error', __('You have to specify the contact email!'));
     // 	redirect(get_url('career/create'));
     // }
     if (empty($data['posted_date'])) {
         Flash::set('error', __('You have to specify the posted date!'));
         redirect(get_url('career/create'));
     }
     if (empty($data['closing_date'])) {
         Flash::set('error', __('You have to specify the closing date!'));
         redirect(get_url('career/create'));
     }
     $career = new Career($data);
     $career->posted_date = date("Y-m-d", strtotime($career->posted_date));
     $career->closing_date = date("Y-m-d", strtotime($career->closing_date));
     $career->status = 1;
     $career->created_by_id = AuthUser::getId();
     $career->created_on = date('Y-m-d H:i:s');
     if (!$career->save()) {
         Flash::set('error', __('Career is not added!'));
         redirect(get_url('career/create'));
     } else {
         Flash::set('success', __('Career has been added!'));
         if (isset($_POST['commit'])) {
             redirect(get_url('career'));
         } else {
             redirect(get_url('career/view/' . $career->lastInsertId()));
         }
     }
     redirect(get_url('career'));
 }
Beispiel #3
0
<?php 
$career = new Career();
// Action handling: Add
switch ($action) {
    case 'add':
        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
            api_not_allowed();
        }
        Session::write('notebook_view', 'creation_date');
        $url = api_get_self() . '?action=' . Security::remove_XSS($_GET['action']);
        $form = $career->return_form($url, 'add');
        // The validation or display
        if ($form->validate()) {
            if ($check) {
                $values = $form->exportValues();
                $res = $career->save($values);
                if ($res) {
                    Display::display_confirmation_message(get_lang('ItemAdded'));
                }
            }
            $career->display();
        } else {
            echo '<div class="actions">';
            echo '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
            echo '</div>';
            $form->addElement('hidden', 'sec_token');
            $form->setConstants(array('sec_token' => $token));
            $form->display();
        }
        break;
    case 'edit':