/** * @author Bui Dang <*****@*****.**> * action load ss list - ajax */ public function action_ss_list() { $data = array(); $partner_id = Input::post('partner_id'); $addr1 = Input::post('addr1', null); $flag = Input::post('flag', null); $mss = new \Model_Mss(); if ($addr1 && $partner_id == null) { $model_partner = new \Model_Mpartner(); $config = array('addr1' => $addr1, 'type' => 1); $list_partner = $model_partner->get_filter_partner($config); $list_partner_code = array(); if ($list_partner) { foreach ($list_partner as $partner) { $list_partner_code[] = $partner['partner_code']; } } if ($list_partner_code) { $data['list_ss'] = $mss->get_all_ss_by_list_partner_code($list_partner_code); } } else { $data['list_ss'] = $mss->get_ss_partner($partner_id); if ($flag && $partner_id == null) { $data['list_ss'] = $mss->get_ss_partner($partner_id, true); } } return json_encode($data); }
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 <*****@*****.**> * list media */ public function action_get_partner() { $m_group_id = Input::post('m_group_id'); if (!isset($m_group_id) || $m_group_id == '') { exit(json_encode($this->_partners)); } $m_partner = new \Model_Mpartner(); $partners = $this->_partners + array_column($m_partner->get_partner_group($m_group_id, $this->_partner_type), 'branch_name', 'partner_code'); return Response::forge(json_encode($partners)); }
/** * @author: Bui Cong Dang (dangbcd6591@seta-asia.com.vn) * @params: List partner **/ public function action_index() { $data = array(); $partner = new \Model_Mpartner(); //Get value from form search if ($filter = Input::get()) { Session::set('url_filter_partner', http_build_query($filter)); //Set url filter } $pagination = \Uospagination::forge('pagination', array('pagination_url' => Uri::base() . 'master/partners?' . http_build_query($filter), 'total_items' => $partner->count_data($filter), 'per_page' => \Constants::$default_limit_pagination, 'num_links' => \Constants::$default_num_links, 'uri_segment' => 'page', 'show_last' => true)); $filter['offset'] = $pagination->offset; $filter['limit'] = $pagination->per_page; $data['pagination'] = $pagination; $data['filter'] = $filter; $data['partners'] = $partner->get_filter_partner($filter); $this->template->title = 'UOS求人システム'; $this->template->content = View::forge('partners/index', $data); }
/** * get all data partner * @return array */ private function _get_data_partner() { $result = array(); $list = \Model_Mpartner::find_all(); foreach ($list as $partner) { $result[$partner['partner_code']]['m_group_id'] = $partner['m_group_id']; $result[$partner['partner_code']]['branch_name'] = $partner['branch_name']; $result[$partner['partner_code']]['user_id'] = $partner['user_id']; $result[$partner['partner_code']]['department_id'] = $partner['department_id']; } return $result; }
/** * 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; }
public function action_get_partner() { $address1 = \Input::post('addr1'); //model partner $data = array(); $model_partner = new \Model_Mpartner(); $config = array('type' => 1); if ($address1) { $config = array('addr1' => $address1, 'type' => 1); } $data['list_partner'] = $model_partner->get_filter_partner($config); $content_type = array('Content-type' => 'application/json', 'SUCCESS' => 0); echo new \Response(json_encode($data), 200, $content_type); return false; }
public function edit_partner($id, $arr_partner) { if (empty($arr_partner) || !($partner = \Model_Mpartner::find_by_pk($id))) { Session::set_flash('error', '取引先は存在しません'); Response::redirect('master/partners'); } $data_json = json_encode($arr_partner); $partner->updated_at = date('Y-m-d H:i:s'); $partner->status = \Constants::$_status_partner['pending']; $partner->edit_data = $data_json; if ($partner != null && $partner->save() >= 0) { return true; } else { return false; } }
/** * @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); }
/** * @author Thuanth6589 <*****@*****.**> * action create/edit media */ public function action_index() { $m_media_id = Input::get('id', null); $filter_group = $this->filter_group; $datafilter['field'] = $filter_group; $media = new \Model_Mmedia(); if (isset($m_media_id)) { $media = \Model_Mmedia::find_by_pk($m_media_id); if (!isset($media)) { Session::set_flash('error', '媒体は存在しません'); return Response::redirect('/master/medias'); } $datafilter['datafilter'] = \Presenter_Group_Filter::edit($filter_group['step'], $filter_group['type'], $media->partner_code); $data['media'] = $media; $data['posts'] = \Model_Mpost::find_by_m_media_id($m_media_id); } $data['media_name_existed'] = $media->get_list_media('media_name'); $data['media_version_name_existed'] = $media->get_list_media('media_version_name'); if (Input::method() == 'POST') { $url = Session::get('medias_url') ? Session::get('medias_url') : Uri::base() . 'master/medias'; $m_media_id = Input::post('m_media_id', null); if ($m_media_id && !\Model_Mmedia::find_by_pk($m_media_id)) { Session::set_flash('error', '媒体は存在しません'); return Response::redirect($url); } if (!\Model_Mpartner::find_by_pk(Input::post('partner_code'))) { Session::set_flash('error', '取引先(受注先)は存在しません'); } else { $media = new \Model_Mmedia(); $media_data = $media->set_data(Input::post()); $umedia = new \Model_Umedia(); $posts = Input::post('post') != null ? Input::post('post') : array(); if ($umedia->save_media($media_data, $posts, Input::post('m_media_id'))) { Session::set_flash('success', \Constants::$message_create_success); return Response::redirect($url); } Session::set_flash('error', \Constants::$message_create_error); } } $data['classification'] = \Constants::get_create_media_classification(); $this->template->title = 'UOS求人システム'; $this->template->content = View::forge('media', $data); $this->template->content->filtergroup = \Presenter::forge('group/filter')->set('custom', $datafilter); }
public function action_index() { $data = array(); $model_par = new \Model_Mpartner(); $model_ss = new \Model_Mss(); $model_job = new \Model_Job(); $model_or = new \Model_Orders(); $m_user = new Model_Muser(); $m_person = new Model_Person(); $data['m_partner'] = $model_par->count_data(array('status' => 1)); $data['m_ss'] = $model_ss->count_data(array('status' => '0')); $data['job'] = $model_job->count_data(); $data['or'] = count($model_or->get_all_order_list(null, null, array('unapproved' => '0'))); $data['person_inactive'] = $m_person->count_data(array('status' => '0')); $this->template->title = 'UOS求人システム'; $this->template->content = View::forge('default/top', $data); $user_info = \Fuel\Core\Session::get('login_info'); $division = $user_info['division_type']; $department_id = $user_info['department_id']; if ($division == 2) { $data['count_partner'] = $model_par->count_data(array('department_id' => $department_id, 'status' => '1')); $data['count_ss'] = $model_ss->count_data(array('department_id' => $department_id, 'status' => '0')); $data['count_job'] = $model_job->count_job_department_id(array('department_id' => $department_id, 'status' => '0')); $data['count_order'] = count($model_or->get_all_order_list(null, null, array('department_id' => $department_id, 'unapproved' => '0'))); $data['list_user'] = $m_user->get_data(array('department_id' => $department_id, 'order_by_time' => 1)); $data['link_partner'] = \Fuel\Core\Uri::base() . 'master/partners?department_id=' . $department_id . '&status=1'; $data['link_ss'] = \Fuel\Core\Uri::base() . 'master/sslist?department_id=' . $department_id . '&status=0'; $data['link_job'] = \Fuel\Core\Uri::base() . 'job/jobs?department_id=' . $department_id . '&status=0'; $data['link_order'] = \Fuel\Core\Uri::base() . 'job/orders?department_id=' . $department_id . '&unapproved=0&flag=1'; $array_user = array(); foreach ($data['list_user'] as $user) { $array_user[] = $user->user_id; } $list_person = $m_person->get_person_division_2($array_user); foreach ($list_person as $person) { foreach ($array_user as $k => $v) { if ($person['interview_user_id'] == $v || $person['agreement_user_id'] == $v || $person['training_user_id'] == $v || $person['partner_user_id'] == $v) { if ($person['contact_result'] == 0) { $data['count'][$v]['contact_result'] = isset($data['count'][$v]['contact_result']) ? $data['count'][$v]['contact_result'] + 1 : 1; } if ($person['review_date'] == '') { $data['count'][$v]['review_date'] = isset($data['count'][$v]['review_date']) ? $data['count'][$v]['review_date'] + 1 : 1; } if ($person['review_result'] == 0) { $data['count'][$v]['review_result'] = isset($data['count'][$v]['review_result']) ? $data['count'][$v]['review_result'] + 1 : 1; } if ($person['adoption_result'] == 0) { $data['count'][$v]['adoption_result'] = isset($data['count'][$v]['adoption_result']) ? $data['count'][$v]['adoption_result'] + 1 : 1; } if ($person['contract_date'] == '') { $data['count'][$v]['contract_date'] = isset($data['count'][$v]['contract_date']) ? $data['count'][$v]['contract_date'] + 1 : 1; } if ($person['contract_result'] == 0) { $data['count'][$v]['contract_result'] = isset($data['count'][$v]['contract_result']) ? $data['count'][$v]['contract_result'] + 1 : 1; } if ($person['hire_date'] == '') { $data['count'][$v]['hire_date'] = isset($data['count'][$v]['hire_date']) ? $data['count'][$v]['hire_date'] + 1 : 1; } if ($person['employee_code'] == '') { $data['count'][$v]['employee_code'] = isset($data['count'][$v]['employee_code']) ? $data['count'][$v]['employee_code'] + 1 : 1; } if ($person['work_confirmation'] == 0) { $data['count'][$v]['work_confirmation'] = isset($data['count'][$v]['work_confirmation']) ? $data['count'][$v]['work_confirmation'] + 1 : 1; } } } } $data['pagination'] = \Uospagination::forge('pagination', array('pagination_url' => Uri::base() . '?division=2', 'total_items' => count($data['list_user']), 'per_page' => \Constants::$default_limit_pagination, 'num_links' => \Constants::$default_num_links, 'uri_segment' => 'page', 'show_last' => true)); $this->template->content = View::forge('default/division2', $data); } elseif ($division == 3) { $this->division3(); } else { $this->template->content = View::forge('default/top', $data); } }
public static function get_group_partner($idpartnet) { $partner = new Model_Mpartner(); $group_id = $partner->get_group_partner($idpartnet); return $group_id; }
echo Fuel\Core\Form::select('department', $department_id, $department, array('class' => 'form-control')); echo ' - '; echo Fuel\Core\Form::select('user_id', $user_id, array('' => '担当者を選択してください') + $arr_user, array('class' => 'form-control')); ?> <span class="text-info text-info-userid">※受注先の場合必須</span> <label id="form_user_id-error" class="error" for="form_user_id"></label> <div class="edit-before <?php echo isset($is_view['user_id']) ? $is_view['user_id'] : ''; ?> disabled"> <?php if (isset($edit_partner)) { $user_id = $edit_partner->user_id; $department_id = Model_Mpartner::get_department_user($user_id); $arr_user = Model_Mpartner::get_filter_user_department($department_id); $arr_user = array_column($arr_user, 'name', 'user_id'); echo Fuel\Core\Form::select('department_edit', $department_id, $department, array('class' => 'form-control', 'disabled')); echo Fuel\Core\Form::select('user_id_edit', $user_id, $arr_user, array('class' => 'form-control', 'disabled')); } ?> </div> </td> </tr> <tr> <th class="text-right">請求先部署</th> <td> <?php echo Fuel\Core\Form::input('billing_department', isset($partner->billing_department) ? $partner->billing_department : '', array('class' => 'form-control', 'size' => '50'));
public function approval_partner($partner_id) { if (!isset($partner_id) || !($partner = \Model_Mpartner::find_by_pk($partner_id))) { Session::set_flash('error', '取引先は存在しません'); Response::redirect('master/partners/?' . Session::get('url_filter_partner')); } //Get json from field edit_data $edit_data = json_decode($partner->edit_data, true); //Set array partner to save array field //Check group in json exits if ($edit_data and !Model_Mgroups::find_by_pk($edit_data['m_group_id'])) { Session::set_flash('error', '取引先グループは存在しません'); Response::redirect('master/partners/?' . Session::get('url_filter_partner')); } if (isset($edit_data)) { $arr_partner = \Model_Mpartner::_set($edit_data); } $arr_partner['status'] = \Constants::$_status_partner['approval']; $arr_partner['edit_data'] = null; $partner->set($arr_partner); if ($partner->save()) { return true; } return false; }
?> </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>
/** * @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 <*****@*****.**> * approve ss * @param $ss_id * @return bool */ public function approve($ss_id) { if ($ss = static::find_by_pk($ss_id)) { $this->fields = array(); $edit_data = $ss->edit_data; if ($edit_data != '') { $this->fields = json_decode($edit_data, true); if (!Model_Mpartner::find_by_pk($this->fields['partner_code'])) { Session::set_flash('error', '取引先は存在しません'); $url = Session::get('sslist_url') ? Session::get('sslist_url') : Uri::base() . 'master/sslist'; return Response::redirect($url); } } $this->fields['ss_id'] = $ss_id; $this->fields['status'] = self::$status['accept']; $this->fields['edit_data'] = ''; if ($this->save_data()) { return true; } } return false; }
/** * @author: Bui Cong Dang (dangbcd6591@seta-asia.com.vn) * @params: Event change department filter user in form **/ public function action_change_department($id_department = null) { if (Input::post()) { $id_department = Input::post('department_id'); if ($id_department == null || $id_department == '') { return false; } $partner = new \Model_Mpartner(); $arr_user = $partner->get_filter_user_department($id_department); return Response::forge(json_encode($arr_user)); } }
public function action_get_partners() { $group_id = \Fuel\Core\Input::get('group_id'); $type = \Fuel\Core\Input::get('type'); $model_partner = new \Model_Mpartner(); $partners = $model_partner->get_filter_partner(array('group_id' => $group_id, 'type' => $type)); $response = array(); foreach ($partners as $partner) { $response[$partner['partner_code']] = $partner; } return new \Response(json_encode($response), 200, array()); }
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 : ''); }
public function get_division_3() { $data = array('sssale_list' => array(), 'person_list' => array(), 'employment_list' => array()); $user_info = \Fuel\Core\Session::get('login_info'); $order_obj = new Model_Orders(); $partner_obj = new Model_Mpartner(); $mss_obj = new Model_Mss(); $person_obj = new Model_Person(); $employment_obj = new Model_Employment(); $sssale_obj = new Model_Sssale(); $list_order_id = array(); $list_sssale_id = array(); $order_list = $order_obj->get_list_oders_login($user_info['user_id']); /*where 1*/ if (count($order_list)) { foreach ($order_list as $row) { $list_order_id[] = $row['order_id']; } } /*where 2*/ $list_partner_code = array(); $list_ss_id = array(); $partner_list = $partner_obj->get_list_partner_login($user_info['user_id']); if (count($partner_list)) { foreach ($partner_list as $row) { $list_partner_code[] = $row['partner_code']; } } if (count($list_partner_code)) { $mss_list = $mss_obj->get_all_ss_by_list_partner_code($list_partner_code); $mss_list_id = ''; $sssale_array = array(); if (count($mss_list)) { foreach ($mss_list as $row) { $mss_list_id .= $row['ss_id'] . ','; $ss_array_list[$row['ss_id']] = $row['ss_name']; } $sssale_list = $sssale_obj->get_list_sssale('ss_id IN (' . trim($mss_list_id, ',') . ')'); foreach ($sssale_list as $row) { $list_sssale_id[] = $row['sssale_id']; } } } $person_list = $person_obj->get_person_division_3($list_sssale_id, $list_order_id); $list_person_id = array(); if (count($person_list)) { $list_sssale_id = array(); foreach ($person_list as $row) { $list_person_id[] = $row['person_id']; $list_sssale_id[] = (int) $row['sssale_id']; } $list_employment = $employment_obj->get_list_data($list_person_id); $list_sssale_of_person = $sssale_obj->get_list_sssale('sssale_id IN (' . implode(',', $list_sssale_id) . ')'); $list_employment_array = array(); $list_sssale = array(); foreach ($list_employment as $row) { $list_employment_array[$row['person_id']] = $row; } $list_ss_id = array(); $list_sssale_of_ss = array(); foreach ($list_sssale_of_person as $row) { $list_ss_id[] = (int) $row['ss_id']; $list_sssale_of_ss[$row['sssale_id']] = (int) $row['ss_id']; } $list_ss_of_person = $mss_obj->get_list_ss('ss_id IN (' . implode(',', $list_ss_id) . ')'); $list_ss_name = array(); foreach ($list_ss_of_person as $row) { $list_ss_name[$row['ss_id']] = $row['ss_name']; } $list_person_ss_name = array(); foreach ($list_sssale_of_ss as $sssale_id => $ss_id) { $list_person_ss_name[$sssale_id] = $list_ss_name[$ss_id]; } $data['person_list'] = $person_list; $data['sssale_list'] = $list_person_ss_name; $data['employment_list'] = $list_employment_array; } return $data; }
if ($step >= 2) { /*Select partner*/ if (isset($customdata) and $edit_partner = isset($customdata['edit_partner']) ? $customdata['edit_partner'] : array()) { $arr_partner = array_column($edit_partner, 'branch_name', 'partner_code'); $arr_partner = $default_partner + $arr_partner; } ?> <?php echo Form::select('partner_code', isset($customdata['partner_code']) ? $customdata['partner_code'] : '', $arr_partner, array('class' => 'form-control')); ?> <?php if ($is_diff_ss && isset($customdata['label_partner_code'])) { ?> <span class="edit-before edit-before-ss"> <?php echo Model_Mpartner::find_by_pk($customdata['label_partner_code'])->branch_name; ?> </span> <?php } } if ($step >= 3) { /*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'));
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; }
public function get_default_business_user_id($sssale_id) { $business_user_id = 0; $sssale_obj = new \Model_Sssale(); $ss_obj = new \Model_Mss(); $partner_obj = new \Model_Mpartner(); $sssale_info = $sssale_obj->get_sssale_info($sssale_id); $ss_id = $sssale_info['ss_id']; $ss_info = current($ss_obj->get_ss_info($ss_id)); $partner_code = $ss_info['partner_code']; if ($partner_code) { $partner_info = $partner_obj->get_list_partner('partner_code ="' . $partner_code . '"'); $partner_info = $partner_info->as_array(); $partner_info = current($partner_info); $business_user_id = $partner_info['user_id']; } return $business_user_id; }