/** * @author Thuanth6589 <*****@*****.**> * action delete ss * @param null $ss_id * @return bool */ public static function delete_ss($ss_id = null) { if (!isset($ss_id)) { return false; } $ss = Model_Mss::find_by_pk($ss_id); if (!isset($ss)) { return false; } try { \Fuel\Core\DB::start_transaction(); $sssale = new Model_Sssale(); $delete = $sssale->delete_by_ss($ss_id); if (!isset($delete)) { return false; } if (!$ss->delete()) { \Fuel\Core\DB::rollback_transaction(); return false; } \Fuel\Core\DB::commit_transaction(); return true; } catch (Exception $e) { \Fuel\Core\DB::rollback_transaction(); return false; } }
/** * @author Thuanth6589 <*****@*****.**> * list, create, update sssale */ public function action_index() { $data = array(); $sssale = new \Model_Sssale(); $data['ss_id'] = Input::get('ss_id', null); $ss_name = Input::get('ss_name'); $data['ss_name'] = Input::get('ss_name') ? urldecode($ss_name) : null; if (!isset($data['ss_id']) || !isset($data['ss_name']) || !\Model_Mss::find_by_pk($data['ss_id'])) { Session::set_flash('error', '売上形態は存在しません'); return Response::redirect('/master/sslist'); } Session::set('sssale_url', Uri::current() . '?ss_id=' . $data['ss_id'] . '&ss_name=' . $ss_name); if (Input::method() == 'POST') { $sssale_id = Input::post('sssale_id', null); if ($sssale_id and !\Model_Sssale::find_by_pk($sssale_id)) { Session::set_flash('error', '売上形態は存在しません'); return Response::redirect(Session::get('sssale_url')); } $fields = $sssale->set_data(Input::post()); $check = true; $message = \Constants::$message_create_error; if (!$sssale->check_data_null($fields)) { $check = false; $message = '入力内容がありません。'; } if ($check == true && $sssale->save_data($fields)) { Session::set_flash('success', \Constants::$message_create_success); return Response::redirect(Session::get('sssale_url')); } if (!isset($sssale_id)) { $data['action'] = 'add'; } Session::set_flash('error-' . Input::post('panel_index'), $message); } $data['sale_type'] = \Constants::$sale_type; $data['hours'] = \Constants::$hours; $data['minutes'] = \Constants::$minutes; $data['sssales'] = $sssale->get_data($data['ss_id']); $this->template->title = 'UOS求人システム'; $this->template->content = View::forge('sssale', $data); }
/** * Start append ss list * * @author Ha Huu Don<*****@*****.**> * @date 16/09/2015 */ public function view() { $model_group = new \Model_Mgroups(); $model_ss = new Model_Mss(); $model_partner = new \Model_Mpartner(); $data['listgroup1'] = array(); $list_partner1 = $model_partner->get_list_by_type(); if ($list_partner1) { $data['listgroup1'] = $model_group->get_list_by_partner($list_partner1); } $data['listss'] = array(); $data['listpartner'] = array(); $ss_id = $this->ss_id; $data['ss_id_selected'] = 0; $data['partner_code_selected'] = 0; $data['group_id_selected'] = 0; $partner_code = 0; $group_id = 0; if ($ss_id) { $ss_info = $model_ss->find_by_pk($ss_id); if ($ss_info) { $partner_code = $ss_info['partner_code']; } 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, 1); } $config['where'] = array('partner_code' => $partner_code); $data['listss'] = $model_ss->find($config); } } $data['stt_selected'] = $this->stt; $data['ss_id_selected'] = $ss_id; $data['partner_code_selected'] = $partner_code; $data['group_id_selected'] = $group_id; $this->data = $data; }
?> </div> <div> <?php if (isset($person->mobile) and $person->mobile != null) { echo '(固定)' . $person->mobile; } ?> </div> </td> </tr> <tr> <th class="text-right">対象SS</th> <td colspan="3"> <?php if (isset($person->sssale_id)) { $ss_id = Model_Sssale::find_by_pk($person->sssale_id)->ss_id; $partner_code = Model_Mss::find_by_pk($ss_id)->partner_code; $m_group_id = Model_Mpartner::find_by_pk($partner_code)->m_group_id; $group_name = Model_Mgroups::find_by_pk($m_group_id)->name; $partner_name = Model_Mpartner::find_by_pk($partner_code)->branch_name; $ss_name = Model_Mss::find_by_pk($ss_id)->ss_name; $sssale_name = Model_Sssale::find_by_pk($person->sssale_id)->sale_name; echo $group_name . $partner_name . $ss_name . $sssale_name; } ?> </td> </tr> </table> </div> </div>
public function get_remaining_cost($apply_date, $list_ss, $ss_id, $order = array()) { //get ss_info $ss_info = \Model_Mss::find_by_pk($ss_id); //get list ss by partner_code $list_ss_primary = array(); if ($ss_info) { $model_mss = new \Model_Mss(); $partner = \Model_Mpartner::find_by_pk($ss_info->partner_code); if ($partner) { $department_id = $partner->department_id; } $list_ss_partner_code = $model_mss->get_list_all_ss(array('partner_code' => $ss_info->partner_code)); if ($list_ss_partner_code) { $list_ss_primary = array_column($list_ss_partner_code, 'ss_id'); } } $department_id = isset($partner->department_id) ? $partner->department_id : ''; //get price for order $cost_of_order = 0; if ($order) { $check = true; if ($order['status'] == 2) { $check = false; } if ($order['status'] == 2 && $order['action'] == 'copy') { $check = true; } if ($check == true) { $cost_of_order = \Model_Orders::cost_of_order($order, $list_ss_primary, true); } } //get list orders by list_ss_id $list_orders = \Model_Orders::get_list_order_in_listss($list_ss_primary, $apply_date); $total_price = 0; foreach ($list_orders as $key => $value) { $total_price = $total_price + \Model_Orders::cost_of_order($value, $list_ss_primary, true); } //get plan job_cost $job_cost = \Model_Plan::get_info_by_startdate($apply_date, $department_id); $remaining_cost = $job_cost - $total_price - $cost_of_order; return $remaining_cost; }
/** * @author Bui Dang <*****@*****.**> * @params: send data edit presenter */ public static function edit($step = null, $type = null, $id = null, $id_label = null) { $p_partner = new \Model_Mpartner(); $p_mss = new \Model_Mss(); $p_sssale_id = new \Model_Sssale(); if ($order_id = \Fuel\Core\Input::get('order_id') and \Fuel\Core\Uri::current() == \Fuel\Core\Uri::base() . 'job/person') { $sssale_id_order = Model_Orders::find_by_pk($order_id)->agreement_type; if (!isset($order_id) or $order_id != 0) { $ss_id_order = Model_Orders::find_by_pk($order_id)->ss_id; } } switch ($step) { case 2: $label_arr_id = array(); $arr_id = array(); $arr_edit = array(); $partner_code = $id; $label_partner_code = $id_label; if (isset($id_label)) { $label_group_id = Model_Mpartner::find_by_pk($label_partner_code)->m_group_id; $label_arr_id = array('label_m_group_id' => $label_group_id, 'label_partner_code' => $label_partner_code); } if ($m_partner = \Model_Mpartner::find_by_pk($partner_code)) { $group_id = $m_partner->m_group_id; $arr_edit_partner = $p_partner->get_partner_group($group_id, $type); $arr_id = array('m_group_id' => $group_id, 'partner_code' => $partner_code); $arr_edit = array('edit_partner' => $arr_edit_partner); } return array_merge($arr_id, $arr_edit, $label_arr_id); break; case 3: $label_arr_id = array(); $arr_id = array(); $arr_edit = array(); $label_ss_id = $id_label; $ss_id = $id; if (!isset($type) || $type == '') { return false; } if (isset($id_label)) { $label_partner_code = \Model_Mss::find_by_pk($label_ss_id)->partner_code; $label_group_id = Model_Mpartner::find_by_pk($label_partner_code)->m_group_id; $label_arr_id = array('label_ss_id' => $label_ss_id, 'label_m_group_id' => $label_group_id, 'label_partner_code' => $label_partner_code); } if ($m_ss = \Model_Mss::find_by_pk($ss_id) and $m_group = \Model_Mpartner::find_by_pk($m_ss->partner_code)) { $partner_code = $m_ss->partner_code; $group_id = $m_group->m_group_id; $arr_edit_partner = $p_partner->get_partner_group($group_id, $type); $arr_edit_ss_id = $p_mss->get_ss_partner($partner_code); $arr_id = array('ss_id' => $ss_id, 'partner_code' => $partner_code, 'm_group_id' => $group_id); $arr_edit = array('edit_partner' => $arr_edit_partner, 'edit_ss_id' => $arr_edit_ss_id); } return array_merge($label_arr_id, $arr_id, $arr_edit); break; case 4: $label_arr_id = array(); $arr_id = array(); $arr_edit = array(); $sssale_id = $id; if (!isset($sssale_id) and isset($sssale_id_order) and $sssale_id_order != 0) { $sssale_id = $sssale_id_order; } $label_sssale_id = $id_label; if (!isset($type) || $type == '') { return false; } if (isset($id_label)) { $label_ss_id = \Model_Sssale::find_by_pk($label_sssale_id)->ss_id; $label_partner_code = \Model_Mss::find_by_pk($label_ss_id)->partner_code; $label_group_id = Model_Mpartner::find_by_pk($label_partner_code)->m_group_id; $label_arr_id = array('label_sssale_id' => $label_sssale_id, 'label_ss_id' => $label_ss_id, 'label_m_group_id' => $label_group_id, 'label_partner_code' => $label_partner_code); } if ($m_ss_sale = \Model_Sssale::find_by_pk($sssale_id) and $m_ss = \Model_Mss::find_by_pk($m_ss_sale->ss_id) and $m_partner = \Model_Mpartner::find_by_pk($m_ss->partner_code)) { $ss_id = $m_ss_sale->ss_id; $partner_code = $m_ss->partner_code; $group_id = $m_partner->m_group_id; $arr_edit_partner = $p_partner->get_partner_group($group_id, $type); $arr_edit_ss_id = $p_mss->get_ss_partner($partner_code); $arr_edit_ss_sale = $p_sssale_id->get_sssale_ss($ss_id); $arr_id = array('sssale_id' => $sssale_id, 'ss_id' => $ss_id, 'partner_code' => $partner_code, 'm_group_id' => $group_id); $arr_edit = array('edit_partner' => $arr_edit_partner, 'edit_ss_id' => $arr_edit_ss_id, 'edit_ss_sale' => $arr_edit_ss_sale); } else { if (isset($ss_id_order) and $m_ss = \Model_Mss::find_by_pk($ss_id_order) and $m_partner = \Model_Mpartner::find_by_pk($m_ss->partner_code)) { $ss_id = $ss_id_order; $partner_code = $m_ss->partner_code; $group_id = $m_partner->m_group_id; $arr_edit_partner = $p_partner->get_partner_group($group_id, $type); $arr_edit_ss_id = $p_mss->get_ss_partner($partner_code); $arr_edit_ss_sale = $p_sssale_id->get_sssale_ss($ss_id); $arr_id = array('sssale_id' => $sssale_id, 'ss_id' => $ss_id, 'partner_code' => $partner_code, 'm_group_id' => $group_id); $arr_edit = array('edit_partner' => $arr_edit_partner, 'edit_ss_id' => $arr_edit_ss_id, 'edit_ss_sale' => $arr_edit_ss_sale); } } return array_merge($label_arr_id, $arr_id, $arr_edit); break; default: return false; break; } }
/** * @author Thuanth6589 <*****@*****.**> * @param array $data * @return bool * @throws \Exception */ public function save_data() { $data = $this->fields; if (empty($data)) { return false; } $data['updated_at'] = date('Y-m-d H:i:s', time()); if (!isset($data['ss_id'])) { $data['created_at'] = date('Y-m-d H:i:s', time()); $data['is_available'] = 0; $ss = Model_Mss::forge(); } else { $ss = Model_Mss::find_by_pk($data['ss_id']); if (!isset($ss)) { return false; } $ss->is_new(false); } $ss->set($data); if ($ss->save()) { return true; } return false; }
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'; } }
public function get_ss_info($ss_id, $get_partner = false) { //get partner and group by ss_id $ss_info = \Model_Mss::find_by_pk($ss_id); if ($ss_info) { $ss_partner = \Model_Mpartner::find_by_pk($ss_info->partner_code); if ($ss_partner) { $group_info = \Model_Mgroups::find_by_pk($ss_partner->m_group_id); $user_info = \Model_Muser::find_by_pk($ss_partner->user_id); $department = isset(\Constants::$department[$ss_partner->department_id]) ? \Constants::$department[$ss_partner->department_id] : ''; if ($get_partner) { return $ss_partner; } } } return array('group_info_name' => isset($group_info->name) ? $group_info->name : '', 'ss_partner_name' => isset($ss_partner->branch_name) ? $ss_partner->branch_name : '', 'ss_info_ss_name' => isset($ss_info->ss_name) ? $ss_info->ss_name : '', 'department_name' => isset($department) ? $department : '', 'department_id' => isset($ss_partner->department_id) ? $ss_partner->department_id : '', 'user_info_name' => isset($user_info->name) ? $user_info->name : ''); }
/** * @author Thuanth6589 <*****@*****.**> * action delete ss */ public function action_delete() { if (Input::method() == 'POST') { $ss_id = Input::post('ss_id', null); $result = 'error'; if (!\Model_Mss::find_by_pk($ss_id)) { $message = 'SSは存在しません'; } else { $message = \Constants::$message_delete_error; if (\Model_Uss::delete_ss($ss_id)) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('sslist_url') ? Session::get('sslist_url') : Uri::base() . 'master/sslist'; return Response::redirect($url); }
/*Select SS*/ if (isset($customdata) and $edit_ss_id = isset($customdata['edit_ss_id']) ? $customdata['edit_ss_id'] : array()) { $arr_sss = array_column($edit_ss_id, 'ss_name', 'ss_id'); $arr_sss = $default_ss + $arr_sss; } ?> <p></p> <?php echo Form::select('ss_id', isset($customdata['ss_id']) ? $customdata['ss_id'] : '', $arr_sss, array('class' => 'form-control')); ?> <?php if ($is_diff_ss && isset($customdata['label_ss_id'])) { ?> <span class="edit-before edit-before-ss"> <?php echo Model_Mss::find_by_pk($customdata['label_ss_id'])->ss_name; ?> </span> <?php } } if ($step >= 4) { /*Select SSsale*/ if (isset($customdata) and $edit_ss_sale = isset($customdata['edit_ss_sale']) ? $customdata['edit_ss_sale'] : array()) { $arr_ss_sale = array(); foreach ($edit_ss_sale as $ss_sale) { if (isset($ss_sale['sale_type']) and $ss_sale['sale_type']) { $sale_type = $ss_sale['sale_type']; } else { $sale_type = ''; }