コード例 #1
0
ファイル: ss.php プロジェクト: huylv-hust/uosbo
 /**
  * @author Thuanth6589 <*****@*****.**>
  * action create/update ss
  */
 public function action_index()
 {
     $ss_id = Input::get('ss_id');
     $filter_group = $this->filter_group;
     $data_filter['field'] = $filter_group;
     if (isset($ss_id)) {
         $ss = \Model_Mss::find_by_pk($ss_id);
         if (!isset($ss)) {
             Session::set_flash('error', 'SSは存在しません');
             return Response::redirect('/master/sslist');
         }
         $data['ss'] = $ss;
         $data['json'] = $ss->edit_data != '' ? json_decode($ss->edit_data) : $ss;
         $data_filter['datafilter'] = \Presenter_Group_Filter::edit($filter_group['step'], $filter_group['type'], $data['json']->partner_code);
         $partner = \Model_Mpartner::find_by_pk($ss->partner_code);
         $group = \Model_Mgroups::find_by_pk($partner->m_group_id);
         $data['branch_name'] = $partner->branch_name;
         $data['group_name'] = $group->name;
         $data['is_view'] = $this->_compare_data_json($ss, $ss->edit_data);
     }
     $submit = Input::post('submit');
     if (isset($submit)) {
         $url = Session::get('sslist_url') ? Session::get('sslist_url') : Uri::base() . 'master/sslist';
         $ss = new \Model_Mss();
         $ss->set_data(Input::post());
         if (isset($ss->fields['ss_id']) && !\Model_Mss::find_by_pk($ss->fields['ss_id'])) {
             Session::set_flash('error', 'SSは存在しません');
             return Response::redirect($url);
         }
         if (!\Model_Mpartner::find_by_pk(Input::post('partner_code'))) {
             Session::set_flash('error', '取引先(受注先)は存在しません');
         } else {
             if ($ss->save_data()) {
                 Session::set_flash('success', \Constants::$message_create_success);
                 return Response::redirect($url);
             }
             Session::set_flash('error', \Constants::$message_create_error);
         }
     }
     $data['address1'] = \Constants::get_create_address();
     $this->template->title = 'UOS求人システム';
     $this->template->content = View::forge('ss', $data);
     $this->template->content->filtergroup = \Presenter::forge('group/filter')->set('custom', $data_filter);
 }