/** * @author Thuanth6589 <*****@*****.**> * delete media * @param $media_id * @return bool */ public function delete_media($media_id) { $media = Model_Mmedia::find_by_pk($media_id); if ($media) { try { $media_in_job = Model_Job::count('job_id', false, array(array('media_list', 'like', '%,' . $media_id . ',%'))); $media_in_order = Model_Orders::count('order_id', false, array(array('media_list', 'like', '%,' . $media_id . ',%'))); if ($media_in_job || $media_in_order) { return false; } \Fuel\Core\DB::start_transaction(); $post = new Model_Mpost(); $delete_post = $post->delete_by_media($media_id); if (!isset($delete_post)) { \Fuel\Core\DB::rollback_transaction(); return false; } if ($media->delete() != 1) { \Fuel\Core\DB::rollback_transaction(); return false; } \Fuel\Core\DB::commit_transaction(); return true; } catch (Exception $e) { \Fuel\Core\DB::rollback_transaction(); } } return false; }
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; }
/** * @author Thuanth6589 <*****@*****.**> * action delete media */ public function action_delete() { if (Input::method() == 'POST') { $result = 'error'; $m_media_id = Input::post('m_media_id', null); if (!\Model_Mmedia::find_by_pk($m_media_id)) { $message = '媒体は存在しません'; } else { $umedia = new \Model_Umedia(); $message = \Constants::$message_delete_error; if ($umedia->delete_media($m_media_id)) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('medias_url') ? Session::get('medias_url') : Uri::base() . 'master/medias'; return Response::redirect($url); }
public function action_index() { $data = array(); $ujob_obj = new \Model_Ujob(); $job_id = \Fuel\Core\Input::get('job_id', ''); $copy_job_id = \Fuel\Core\Input::get('copy_job_id', ''); $job_id_get_data = $copy_job_id ? $copy_job_id : $job_id; $data_default = $ujob_obj->get_info_job($job_id_get_data); if ($data_default['job_id'] == null && $job_id) { \Fuel\Core\Response::redirect(\Fuel\Core\Uri::base() . 'job/job'); } if ($copy_job_id) { $data_default['edit_data'] = null; } $data = $data_default; $data['old_data'] = $data_default; $data['old_data']['job_add'] = array(); $data['old_data']['job_recruit'] = array(); $data['old_data']['m_image'] = array(); $data['job_add'] = array(); $data['job_recruit'] = array(); $data['m_image'] = array(); $label = array('group' => 'グループ', 'partner' => '取引先(受注先)', 'ss' => 'SS', 'sslist' => '売上形態'); $data_filter['field'] = array('step' => 4, 'type' => 1, 'label' => $label); if (\Fuel\Core\Input::method() == 'POST') { $data_post = \Fuel\Core\Input::post(); if (!isset($data_post['employment_mark'])) { $data_post['employment_mark'] = array(); } if (!isset($data_post['work_time_view'])) { $data_post['work_time_view'] = array(); } if (!isset($data_post['trouble'])) { $data_post['trouble'] = array(); } $check = true; if (!\Model_Sssale::find_by_pk($data_post['sssale_id'])) { \Fuel\Core\Session::set_flash('report', '売上形態は存在しません'); $check = false; } foreach ($data_post['media_list'] as $k => $v) { if ($v == '') { unset($data_post['media_list'][$k]); continue; } if (!\Model_Mmedia::find_by_pk($v)) { \Fuel\Core\Session::set_flash('report', '媒体は存在しません'); $check = false; break; } } if ($check) { $this->save($ujob_obj, $job_id, $data_post); } } if ($data_default['edit_data']) { $data = json_decode($data_default['edit_data'], true); $data_default_edit = $ujob_obj->get_info_job(''); $data = $data + $data_default_edit; $data = \Utility::set_standard_data_job($data, false); $ujob_obj->convert_job_add_recruit($data); $data['m_image'] = $ujob_obj->get_list_m_image($data['image_list']); /*Get old data*/ $data['old_data'] = $data_default; $data['old_data']['job_add'] = $ujob_obj->get_list_job_add($job_id); $data['old_data']['job_recruit'] = $ujob_obj->get_list_job_recruit($job_id); $data['old_data']['m_image'] = $ujob_obj->get_list_m_image($data['old_data']['image_list']); } else { if ($job_id_get_data) { $data['job_add'] = $ujob_obj->get_list_job_add($job_id_get_data); $data['job_recruit'] = $ujob_obj->get_list_job_recruit($job_id_get_data); $data['m_image'] = $ujob_obj->get_list_m_image($data['image_list']); $data['old_data']['job_add'] = $data['job_add']; $data['old_data']['job_recruit'] = $data['job_recruit']; $data['old_data']['m_image'] = $data['m_image']; } } $data['is_show_old'] = array(); if ($job_id) { $data['is_show_old'] = $this->_compare_other_data_json($data['old_data'], $data_default['edit_data']); } $data_filter['datafilter'] = \Presenter_Group_Filter::edit($data_filter['field']['step'], $data_filter['field']['type'], $data['sssale_id'], $data['old_data']['sssale_id']); $data['interview_des'] = '面接は勤務地または近隣にて行います。'; $data['apply_method'] = '下記のフリーダイヤルまたは「応募する」ボタンより、応募シートに必要事項を入力の上、送信して下さい。※応募書類は返却致しません。ご了承ください。'; $data['apply_process'] = '追って、こちらからご連絡差し上げます。※ご連絡は平日に致します。★ネット応募は24h受付中!!'; $this->template->title = 'UOS求人システム'; $this->template->content = \Fuel\Core\View::forge('job/index', $data); $this->template->content->filtergroup = \Presenter::forge('group/filter')->set('custom', $data_filter); }
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; }