Exemple #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Check user is logged in
     if (Auth::check()) {
         // init vars
         //$destination_path = '/Users/duncansmith/Sites/dart.local/public/dsscript/uploads';
         $destination_path = getEnv('PUBLIC_BASE_PATH') . 'uploads/';
         $target_path = getEnv('PUBLIC_BASE_PATH') . 'media/images/';
         $action = 'store';
         // validate
         // read more on validation at http://laravel.com/docs/validation
         $rules = array('title' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('works/create')->withErrors($validator)->withInput(Input::except('password'));
         } else {
             // store
             $work = new Work();
             $work->title = Input::get('title');
             $work->media = Input::get('media');
             $work->dimensions = Input::get('dimensions');
             $work->work_date = Input::get('work_date');
             $work->description = Input::get('description');
             $work->notes = Input::get('notes');
             $work->save();
             // create the image reference
             $work->reference = sprintf("%04d", $work->id);
             $work->save();
             // Try to upload the photo
             $this->file_upload_resize_cut(Input::file('image'), $work, $destination_path, $target_path, $action);
             // redirect
             Session::flash('message', 'Successfully created work');
             return Redirect::to('works');
         }
     } else {
         // User is not logged in
         Session::flash('message', 'Please log in');
         return Redirect::to('/');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Work();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Work'])) {
         $model->attributes = $_POST['Work'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemple #3
0
 public function create($item_id)
 {
     $data = Input::all();
     $item = Item::where('id', '=', $item_id)->get()[0];
     $screen_name = User::where('id', '=', $item->user_id)->first()['attributes']['screen_name'];
     $now = date("Y-m-d H:i:s");
     if ($item['type'] == 'video') {
         $reg = '/^http:\\/\\/www\\.nicovideo\\.jp\\/watch\\/(sm[0-9]+)/';
     } else {
         $reg = '/^http:\\/\\/seiga\\.nicovideo\\.jp\\/seiga\\/im([0-9]+)/';
     }
     preg_match($reg, $data['url'], $match);
     $nico_content = $match ? $match[1] : 0;
     if ($item['type'] == 'video') {
         $Niconico = new Niconico();
         $ret = $Niconico->getThumbInfo($nico_content);
         $title = $ret->title;
         $thumbnail_url = $ret->thumbnail_url;
     } else {
         $title = '';
         $thumbnail_url = "http://lohas.nicoseiga.jp/thumb/{$nico_content}q";
     }
     if ($nico_content) {
         $work = new Work();
         $work->item_id = $item_id;
         $work->user_id = Auth::user()->id;
         $work->url = $data['url'];
         $work->title = $title;
         $work->thumbnail_url = $thumbnail_url;
         $work->comment = nl2br(htmlspecialchars($data['comment']));
         $work->created_at = date("Y-m-d H:i:s");
         $work->updated_at = date("Y-m-d H:i:s");
         $work->save();
         Starmap::where('item_id', '=', $item_id)->update(array('notice_flag' => 1));
         return Redirect::to("/{$screen_name}/items/{$item_id}");
     } else {
         echo "その作品はあかん";
     }
 }
Exemple #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Work();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Work'])) {
         $model->attributes = $_POST['Work'];
         if ($model->save()) {
             if (!empty($_POST['yt1'])) {
                 Yii::app()->user->setFlash('work-created', "¡El trabajo <b><i>&quot;{$model->name}&quot;</i></b> fue creado exitosamente!");
                 $modelSaved = $model;
                 $model = new Work();
                 $model->service_type_id = $modelSaved->service_type_id;
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     if (ServiceType::model()->count('active = 1') > 0) {
         $this->render('create', array('model' => $model));
     } else {
         throw new CHttpException('', 'Primero debe ' . CHtml::link('Crear un Tipo de Servicio', array('serviceType/create')) . '.');
     }
 }
Exemple #5
0
 function work($employee_id = '')
 {
     $data['page_name'] = '<b>Personal Data Sheet</b>';
     $data['section_name'] = '<b>Personal Information</b>';
     $data['focus_field'] = 'work_date1';
     $data['msg'] = '';
     $e = new Employee_m();
     $data['employee'] = $e->get_by_id($employee_id);
     if (Input::get('op')) {
         // WORK EXPERIENCE=================================
         $work_date1 = Input::get('work_date1');
         $work_date2 = Input::get('work_date2');
         $work_position = Input::get('work_position');
         $work_office = Input::get('work_office');
         $work_salary = Input::get('work_salary');
         $work_sg = Input::get('work_sg');
         $work_status = Input::get('work_status');
         $movement = Input::get('movement');
         $work_service = Input::get('work_service');
         $work = new Work();
         $work->get_by_employee_id($employee_id);
         $work->delete_all();
         $i = 0;
         foreach ($work_date1 as $work_date) {
             if ($work_date != "") {
                 $work = new Work();
                 $work->employee_id = $employee_id;
                 $work->inclusive_date_from = $work_date1[$i];
                 $work->inclusive_date_to = $work_date2[$i];
                 $work->position = $work_position[$i];
                 $work->company = $work_office[$i];
                 $work->monthly_salary = $work_salary[$i];
                 $work->salary_grade = $work_sg[$i];
                 $work->status = $work_status[$i];
                 $work->movement = $movement[$i];
                 $work->govt_service = $work_service[$i];
                 $work->save();
             }
             $i++;
         }
         $data['msg'] = 'Work Experience has been saved!';
     }
     // Work=============================================================
     $work = new Work();
     $work->order_by('inclusive_date_from', 'DESC');
     $data['works'] = $work->get_by_employee_id($employee_id);
     $data['govt_service_options'] = array('1' => 'Yes', '0' => 'No');
     if ($employee_id == '') {
         $data['works'] = array();
     }
     $data['selected'] = $e->office_id;
     // Use for office listbox
     $data['options'] = $this->options->office_options();
     $data['employee_id'] = $employee_id;
     $data['main_content'] = 'work';
     return View::make('includes/template', $data);
 }
 function save()
 {
     $work = new Work();
     $work->staff_id = $this->staff_id;
     $work->history_date = $this->input->post('history_date');
     $work->history_description = $this->input->post('history_description');
     if ($work->save()) {
         $this->session->set_flashdata('message', 'Work successfully created!');
         redirect('staffs/' . $this->staff_id . '/work_histories/index');
     } else {
         // Failed
         $work->error_message('custom', 'Field required');
         $msg = $work->error->custom;
         $this->session->set_flashdata('message', $msg);
         redirect('staffs/' . $this->staff_id . '/work_histories/add');
     }
 }