Exemplo n.º 1
0
 public function view()
 {
     $model_group = new \Model_Mgroups();
     $model_media = new \Model_Mmedia();
     $model_partner = new \Model_Mpartner();
     $model_post = new Model_Mpost();
     $data['listgroup2'] = array();
     $list_partner2 = $model_partner->get_list_by_type(2);
     if ($list_partner2) {
         $data['listgroup2'] = $model_group->get_list_by_partner($list_partner2);
     }
     $data['listpost'] = array();
     $data['listmedia'] = array();
     $data['listpartner'] = array();
     $post_id = $this->post_id;
     $data['post_id_selected'] = 0;
     $data['media_id_selected'] = 0;
     $data['partner_code_selected'] = 0;
     $data['group_id_selected'] = 0;
     $media_id = 0;
     $partner_code = 0;
     $group_id = 0;
     $data['media_name'] = null;
     if ($post_id) {
         $post_info = $model_post->find_by_pk($post_id);
         if ($post_info) {
             $media_id = $post_info['m_media_id'];
         } else {
             $data['no_data'] = true;
         }
         if ($media_id) {
             $media_info = $model_media->find_by_pk($media_id);
             if ($media_info) {
                 $partner_code = $media_info['partner_code'];
                 $data['media_name'] = $media_info['media_name'];
             } else {
                 $data['no_data'] = true;
             }
             if ($partner_code) {
                 $partner_info = $model_partner->find_by_pk($partner_code);
                 if ($partner_info) {
                     $group_id = $partner_info['m_group_id'];
                     $data['listpartner'] = $model_partner->get_partner_group($group_id, 2);
                     $config['where'] = array('partner_code' => $partner_code);
                     $data['listmedia'] = $model_media->get_search_data($config);
                 } else {
                     $data['no_data'] = true;
                 }
             }
             $config['where'] = array('m_media_id' => $media_id);
             $data['listpost'] = $model_post->get_search_data($config);
         }
     }
     $data['post_id_selected'] = $post_id;
     $data['media_id_selected'] = $media_id;
     $data['partner_code_selected'] = $partner_code;
     $data['group_id_selected'] = $group_id;
     $this->data = $data;
 }
Exemplo n.º 2
0
 public function action_update_status()
 {
     if (\Input::method() == 'POST') {
         $status = \Input::post('status');
         $order_id = \Input::post('order_id');
         $reason = \Input::post('reason', null);
         $result = 'error';
         $message = '保存に失敗しました。';
         $model_orders = new \Model_Orders();
         $order_info = \Model_Orders::find_by_pk($order_id);
         if (!$order_info) {
             return 'failed';
         }
         if ($status == 2) {
             if ($user_login = Session::get('login_info')) {
                 $model_orders->order_update(array('order_user_id' => $user_login['user_id']), $order_id);
             }
         }
         $db_status = array('status' => $status);
         if ($model_orders->order_update($db_status, $order_id)) {
             if ($status == 1 || $status == -1) {
                 //get list media
                 $model_media = new \Model_Mmedia();
                 $listmedias = $model_media->get_list_all_media();
                 $media_name = null;
                 if ($order_info->post_id && $listmedias != null) {
                     $listmedias = array_column($listmedias, 'media_name', 'm_media_id');
                     $post_info = \Model_Mpost::find_by_pk($order_info->post_id);
                     if ($post_info) {
                         $media_id = $post_info->m_media_id;
                         $media_name = isset($listmedias[$media_id]) ? $listmedias[$media_id] : null;
                     }
                 }
                 //get list ss
                 $model_ss = new \Model_Mss();
                 $listss = $model_ss->get_list_all_ss();
                 $ssitem = null;
                 if ($order_info->ss_list && $listss != null) {
                     $listss_name = array_column($listss, 'ss_name', 'ss_id');
                     $ss_list_item = explode(',', trim($order_info->ss_list, ','));
                     foreach ($ss_list_item as $key => $value) {
                         if (array_key_exists($value, $listss_name)) {
                             $ssitem .= $listss_name[$value] . ',';
                         }
                     }
                 }
                 $ssitem = trim($ssitem, ',');
                 $agreement_type = null;
                 if ($order_info->agreement_type) {
                     $agreement = \Model_Sssale::find_by_pk($order_info->agreement_type);
                 }
                 $agreement_type = isset($agreement->sale_name) ? $agreement->sale_name : null;
                 if ($order_info->ss_id) {
                     $ss_info = \Model_Mss::find_by_pk($order_info->ss_id);
                     $ss_name = isset($ss_info->ss_name) ? $ss_info->ss_name : null;
                 }
                 $model_user = new \Model_Muser();
                 //user logging
                 $user_login = \Session::get('login_info');
                 $user_id = $user_login['user_id'];
                 $user_info = $model_user->get_user_info($user_id);
                 $department_id = $user_login['department_id'];
                 if ($user_info) {
                     $department_id = $user_info['department_id'];
                 }
                 $list_emails = $model_user->get_list_email_by_departmentid($department_id, $user_id, 1);
                 $maildata = array('order_id' => $order_id, 'list_media_name' => $media_name, 'agreement_type' => $agreement_type, 'ss_name' => $ss_name, 'ss_list_name' => $ssitem, 'reason' => $reason, 'list_emails' => $list_emails);
                 $model_orders->sendmail($status, $maildata, $order_info->create_id);
             }
             $result = 'success';
             switch ($status) {
                 case -1:
                     $message = '非承認しました';
                     break;
                 case 1:
                     $message = '承認しました';
                     break;
                 case 2:
                     $message = '確定しました。';
                     break;
                 case 3:
                     $message = '停止しました。';
                     break;
                 default:
                     $message = '非承認しました';
                     break;
             }
         }
         \Session::set_flash($result, $message);
         return 'true';
     }
 }
Exemplo n.º 3
0
 public function action_index()
 {
     $this->template->title = 'UOS求人システム';
     $order_id = \Input::get('order_id');
     $action = \Input::get('action');
     //presenter group settings
     $datafilter['field'] = array('step' => 3, 'type' => 1, 'label' => array('group' => 'グループ', 'partner' => '取引先(受注先)'));
     $model_orders = new \Model_Orders();
     $model_user = new \Model_Muser();
     $data = array();
     $data['remaining_cost'] = 0;
     $data['listusers_sales'] = array();
     $data['listusers_interview'] = array();
     $data['listusers_agreement'] = array();
     $data['listusers_training'] = array();
     $data['listusers_author'] = array();
     $data['info'] = $model_orders->get_order_info($order_id);
     //user logging
     $user_login = Session::get('login_info');
     if ($order_id) {
         if (empty($data['info']['order_id'])) {
             \Response::redirect(\Uri::base() . 'job/orders?lost=true');
         }
         //permision
         /*
         			if($action != 'copy' && $data['info']['status'] == 3)
         			{
         				\Response::redirect(\Uri::base().'job/orders?permission=false');
         			}
         *
         */
         $datafilter['datafilter'] = \Presenter_Group_Filter::edit($datafilter['field']['step'], $datafilter['field']['type'], $data['info']['ss_id']);
         $data = $model_user->get_user_info_path($data['info']['author_user_id'], 'author', $data);
         //$data = $model_user->get_user_info_path($data['info']['sales_user_id'],'sales',$data);
         $data = $model_user->get_user_info_path($data['info']['interview_user_id'], 'interview', $data);
         $data = $model_user->get_user_info_path($data['info']['agreement_user_id'], 'agreement', $data);
         $data = $model_user->get_user_info_path($data['info']['training_user_id'], 'training', $data);
     }
     //get list ss
     $model_ss = new \Model_Mss();
     $data['listss'] = $model_ss->get_list_all_ss();
     $model_group = new \Model_Mgroups();
     $data['listgroup'] = $model_group->get_all();
     $result = 'error';
     $message = '保存に失敗しました。';
     if (\Input::method() == 'POST') {
         if ($order_id && !\Model_Orders::find_by_pk($order_id)) {
             \Session::set_flash($result, 'オーダーは存在しません');
             return \Response::redirect('job/orders');
         }
         $post = \Input::post();
         $check = true;
         $post['ss_list'] = isset($post['ss_list']) ? $post['ss_list'] : array();
         foreach ($post['ss_list'] as $k => $v) {
             if ($v != '' && !\Model_Mss::find_by_pk($v)) {
                 $message = 'SSは存在しません';
                 $check = false;
                 break;
             }
         }
         if (!\Model_Mpost::find_by_pk($post['list_post'])) {
             $message = '媒体は存在しません';
             $check = false;
         }
         if (!\Model_Mss::find_by_pk($post['ss_id'])) {
             $message = 'SSは存在しません';
             $check = false;
         }
         if ($check && ($last = $model_orders->order_save($post, $action, $order_id))) {
             if ($order_id == null || $action == 'copy') {
                 $user_id = $user_login['user_id'];
                 $user_info = $model_user->get_user_info($user_id);
                 $department_id = $user_login['department_id'];
                 if ($user_info) {
                     $department_id = $user_info['department_id'];
                 }
                 $list_emails = $model_user->get_list_email_by_departmentid($department_id, $user_id, 99);
                 $maildata = array('order_id' => $last[0], 'department_name' => isset($user_info['department_id']) ? \Constants::$department[$user_info['department_id']] : '', 'list_emails' => $list_emails);
                 $maildata['m_user_name'] = isset($user_info['name']) ? $user_info['name'] : '';
                 $model_orders->sendmail(99, $maildata, $user_id);
             }
             $result = 'success';
             $message = '保存しました';
         }
         \Session::set_flash($result, $message);
         $return_url_search = \Cookie::get('return_url_search');
         if ($return_url_search) {
             return \Fuel\Core\Response::redirect($return_url_search);
         }
         return \Response::redirect('job/orders');
     }
     $data['post_id_isset'] = false;
     if ($data['info']['post_id']) {
         if (\Model_Mpost::find_by_pk($data['info']['post_id'])) {
             $data['post_id_isset'] = true;
         }
     }
     $data['properties'] = $model_orders->data_default;
     $this->template->content = \View::forge('orders/input', $data);
     $this->template->content->filtergroup = \Presenter::forge('group/filter')->set('custom', $datafilter);
 }
Exemplo n.º 4
0
 public function csv_process($list_orders)
 {
     if (empty($list_orders)) {
         return array();
     }
     $csv_all_data = array();
     $stt = 0;
     foreach ($list_orders as $order) {
         $csv_data = array();
         $total_price = 0;
         $order_ss_list = trim($order['ss_list'], ',');
         $ss_list = explode(',', $order_ss_list);
         //get media info
         $price_int = $price_blance = '';
         if ($order['post_id']) {
             $post = \Model_Mpost::find_by_pk($order['post_id']);
             if ($post) {
                 $media = \Model_Mmedia::find_by_pk($post->m_media_id);
                 if ($media) {
                     if ($media->type == 1) {
                         $type = '自力';
                     }
                     if ($media->type == 2) {
                         $type = '他力';
                     }
                     if ($media->budget_type == 1) {
                         $budget_type = '求人費';
                     }
                     if ($media->budget_type == 2) {
                         $budget_type = '販促費';
                     }
                     if ($media->is_web_reprint == 1) {
                         $is_web_reprint = 'あり';
                     }
                     if ($media->is_web_reprint == 0) {
                         $is_web_reprint = 'なし';
                     }
                     $classification = isset(\Constants::$media_classification[$media->classification]) ? \Constants::$media_classification[$media->classification] : '';
                     $partner = \Model_Mpartner::find_by_pk($media->partner_code);
                     $media_name = $media->media_name;
                     $total_ss = 1 + count($ss_list);
                     if ($media->is_web_reprint == 1) {
                         $total_ss = (1 + count($ss_list)) * 2;
                     }
                     $post_price = $post->price != null ? $post->price : 0;
                     $price = $post_price / $total_ss;
                     $price_int = (int) $price;
                     $price_blance = $price_int + $post_price % $total_ss;
                 }
             }
         }
         //get partner and group by ss_id
         $data_ss = $this->get_ss_info($order['ss_id']);
         //ss_sale info
         if ($order['agreement_type']) {
             $ss_sale = \Model_Sssale::find_by_pk($order['agreement_type']);
             if ($ss_sale) {
                 $sale_name = $ss_sale->sale_name;
                 if ($ss_sale->sale_name == null) {
                     $sale_name = isset(\Constants::$sale_type[$ss_sale->sale_type]) ? \Constants::$sale_type[$ss_sale->sale_type] : '';
                 }
             }
         }
         $csv_data[$order['order_id']][] = array($order['order_id'], $data_ss['group_info_name'], $data_ss['ss_partner_name'], $data_ss['ss_info_ss_name'], $data_ss['department_name'], $data_ss['department_id'], $data_ss['user_info_name'], isset($sale_name) ? $sale_name : '', $order['request_date'] != null ? date('Y/m/d', strtotime($order['request_date'])) : '', $order['post_date'] != null ? date('Y/m/d', strtotime($order['post_date'])) : '', isset($type) ? $type : '', isset($budget_type) ? $budget_type : '', isset($classification) ? $classification : '', isset($is_web_reprint) ? $is_web_reprint : '', isset($media->m_media_id) ? $media->m_media_id : '', 'media_name' => isset($media_name) ? $media_name : '', isset($media->media_version_name) ? $media->media_version_name : '', isset($post->name) ? $post->name : '', isset($partner->branch_name) ? $partner->branch_name : '', 'price' => $stt == 0 ? $price_blance : $price_int, isset($post_price) ? $post_price : 0, $order['notes']);
         //if ss_list
         if ($order['ss_list']) {
             $order_ss_list = trim($order['ss_list'], ',');
             $ss_list = explode(',', $order_ss_list);
             foreach ($ss_list as $ss_key => $ss_item_id) {
                 $data_ss_id = $this->get_ss_info($ss_item_id);
                 $csv_data[$order['order_id']][] = array($order['order_id'], $data_ss_id['group_info_name'], $data_ss_id['ss_partner_name'], $data_ss_id['ss_info_ss_name'], $data_ss_id['department_name'], $data_ss_id['department_id'], $data_ss_id['user_info_name'], isset($sale_name) ? $sale_name : '', $order['request_date'] != null ? date('Y/m/d', strtotime($order['request_date'])) : '', $order['post_date'] != null ? date('Y/m/d', strtotime($order['post_date'])) : '', isset($type) ? $type : '', isset($budget_type) ? $budget_type : '', isset($classification) ? $classification : '', isset($is_web_reprint) ? $is_web_reprint : '', isset($media->m_media_id) ? $media->m_media_id : '', 'media_name' => isset($media_name) ? $media_name : '', isset($media->media_version_name) ? $media->media_version_name : '', isset($post->name) ? $post->name : '', isset($partner->branch_name) ? $partner->branch_name : '', 'price' => isset($price_int) ? $price_int : '', isset($post_price) ? $post_price : 0, $order['notes']);
             }
         }
         if (isset($media->is_web_reprint) && $media->is_web_reprint == 1) {
             foreach ($csv_data as $key => $val) {
                 foreach ($val as $k => $v) {
                     $v['media_name'] = $v['media_name'] . '(WEB転載)';
                     $csv_data[$key][] = $v;
                 }
             }
             foreach ($csv_data as $key => $val) {
                 $blance_2 = count($val) / 2;
                 $csv_data[$key][$blance_2]['price'] = $price_int;
             }
         }
         $csv_all_data[$order['order_id']] = $csv_data;
         $stt++;
     }
     return $csv_all_data;
 }