Esempio n. 1
0
 /**
  * { index }
  *
  * @param     
  *
  * @return
  */
 public function index($org_id = 0)
 {
     //1. validate
     if (is_null($org_id)) {
         App::abort(403, 'Id Organisasi tidak ada');
     }
     //2. get data
     $SortList = new SortList();
     $this->page_attributes->page_subtitle = 'index';
     //dummy
     $this->page_attributes->filters = [];
     //dummy
     $this->page_attributes->sorts = [];
     //2. get data parameter
     $data_parameter = $this->setPageDataParameter();
     //3. get data
     $search = array_merge(['name' => $data_parameter['search']], $data_parameter['filter']);
     $APIOrg = new APIOrg();
     $organisation = $APIOrg->getShow($org_id);
     //4. set page datas
     $this->page_datas->datas['id'] = $org_id;
     $this->page_datas->datas['name'] = $organisation['data']['name'];
     //5. generate view
     $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$organisation['data']['name'] => route('org.show', ['id' => $org_id]), 'Kebijakan' => route('policy.index', ['org_id' => $org_id])]);
     $view_source = $this->view_source_root . '.index';
     $route_source = route(Route::CurrentRouteName());
     return $this->generateView($view_source, $route_source);
 }
Esempio n. 2
0
 /**
  * { store }
  *
  * @param     
  *1. id
  *2. input name
  *3. input code
  *
  * @return
  * 1. response
  * 
  * steps
  * 1. get input
  * 2. get data
  * 3. post to API
  * 4. return response
  */
 public function store($id = null)
 {
     //1. get input
     $input['name'] = Input::get('name');
     $input['code'] = Input::get('code');
     $input['logo'] = Input::get('logo');
     //2. get data
     if (!is_null($id)) {
         $APIOrg = new APIOrg();
         $data = $APIOrg->getShow($id)['data'];
         $data['name'] = $input['name'];
         $data['code'] = $input['code'];
         $data['logo'] = $input['logo'];
     } else {
         $data['id'] = "";
         $data['name'] = $input['name'];
         $data['code'] = $input['code'];
         $data['logo'] = $input['logo'];
         $data['branches'] = [];
         $data['policies'] = [];
     }
     //3. post to API
     $APIOrg = new APIOrg();
     $result = $APIOrg->postData($data);
     //4. return response
     if ($result['status'] != 'success') {
         $this->errors = $result['message'];
     }
     if (!empty($id)) {
         $this->page_attributes->msg = "Data Organisasi Telah Diubah";
     } else {
         $this->page_attributes->msg = "Data Organisasi Telah Ditambahkan";
     }
     return $this->generateRedirectRoute('org.index');
 }
Esempio n. 3
0
 /**
  * { create }
  *
  * @param     
  * 1. id
  * 2. org_id
  *
  * @return
  * 1. Layout
  * 2. page_attributes
  * 3. page_datas
  * 
  * steps
  * 1. validate
  * 2. get data
  * 3. set page attributes
  * 4. set page datas
  * 5. generate view
  */
 public function create($org_id = null, $id = null)
 {
     //1. validate
     if (is_null($org_id)) {
         App::abort(403, 'Id Organisasi tidak ada');
     }
     // 2 & 3
     $APIOrg = new APIOrg();
     $org = $APIOrg->getShow($org_id);
     if (!is_null($id)) {
         //2. get data
         $APIBranch = new APIBranch();
         $data = $APIBranch->getShow($org_id, $id);
         //3. set page attributes
         $current_route = route(Route::CurrentRouteName(), ['org_id' => $org_id, 'id' => $id]);
         $this->page_attributes->page_subtitle = 'Edit Cabang ' . $data['data']['name'];
         $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$org['data']['name'] => route('org.show', ['id' => $org_id]), 'Cabang' => route('branch.index', ['org_id' => $org_id]), 'Edit Cabang ' . $data['data']['name'] => $current_route]);
     } else {
         //2. get data
         $data['data']['id'] = "";
         $data['data']['organisation_id'] = $org_id;
         $data['data']['name'] = null;
         $data['data']['address'] = null;
         $data['data']['phone'] = null;
         $data['data']['email'] = null;
         $data['data']['charts'] = [];
         //3. set page attributes
         $current_route = route(Route::CurrentRouteName(), ['org_id' => $org_id]);
         $this->page_attributes->page_subtitle = 'Cabang Baru';
         $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$org['data']['name'] => route('org.show', ['id' => $org_id]), 'Cabang' => route('branch.index', ['org_id' => $org_id]), 'Cabang Baru' => $current_route]);
     }
     $APIBranch = new APIBranch();
     $branches = $APIBranch->getIndex($org_id, []);
     //4. set page datas
     $this->page_datas->datas['id'] = $org_id;
     $this->page_datas->datas['name'] = $org['data']['name'];
     $this->page_datas->datas['branch'] = $data['data'];
     $this->page_datas->datas['branches'] = $branches['data']['data'];
     //5. generate view
     $view_source = $this->view_source_root . '.create';
     $route_source = $current_route;
     return $this->generateView($view_source, $route_source);
 }
Esempio n. 4
0
 /**
  * { create }
  *
  * @param     
  * 1. id
  * 2. org_id
  *
  * @return
  * 1. Layout
  * 2. page_attributes
  * 3. page_datas
  * 
  * steps
  * 1. validate
  * 2. get data
  * 3. set page attributes
  * 4. set page datas
  * 5. generate view
  */
 public function create($org_id = null, $id = null)
 {
     //1. validate
     if (is_null($org_id)) {
         App::abort(403, 'Id Organisasi tidak ada');
     }
     // 2 & 3
     $APIOrg = new APIOrg();
     $organisation = $APIOrg->getShow($org_id);
     $APICalendar = new APICalendar();
     $employees = $APICalendar->getIndex($org_id, []);
     $APIBranch = new APIBranch();
     $APIChart = new APIChart();
     $branches = $APIBranch->getIndex($org_id, []);
     $positions = $APIChart->getPositions($org_id, []);
     $departments = $APIChart->getDepartments($org_id, []);
     $maritalstatuses = $APICalendar->getMaritalStatuses($org_id, []);
     $grades = $APICalendar->getGrades($org_id, []);
     if (!is_null($id)) {
         //2. get data
         $data = $APICalendar->getShow($org_id, $id);
         //3. set page attributes
         $current_route = route(Route::CurrentRouteName(), ['org_id' => $org_id, 'id' => $id]);
         $this->page_attributes->page_subtitle = 'Edit Karyawan ' . $data['data']['name'];
         $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$organisation['data']['name'] => route('org.show', ['id' => $org_id]), 'Karyawan' => route('employee.index', ['org_id' => $org_id]), 'Edit Karyawan ' . $data['data']['name'] => $current_route]);
     } else {
         //2. get data
         $data['data'] = null;
         //3. set page attributes
         $current_route = route(Route::CurrentRouteName(), ['org_id' => $org_id]);
         $this->page_attributes->page_subtitle = 'Karyawan Baru';
         $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$organisation['data']['name'] => route('org.show', ['id' => $org_id]), 'Karyawan' => route('employee.index', ['org_id' => $org_id]), 'Karyawan Baru' => $current_route]);
     }
     $APICalendar = new APICalendar();
     $employees = $APICalendar->getIndex($org_id, []);
     //4. set page datas
     $this->page_datas->datas['branches'] = $branches['data']['data'];
     $this->page_datas->datas['positions'] = $positions['data'];
     $this->page_datas->datas['departments'] = $departments['data'];
     $this->page_datas->datas['maritalstatuses'] = $maritalstatuses['data'];
     $this->page_datas->datas['grades'] = $grades['data'];
     $this->page_datas->datas['employees'] = $employees['data']['data'];
     $this->page_datas->datas['employee'] = $data['data'];
     $this->page_datas->datas['id'] = $org_id;
     $this->page_datas->datas['name'] = $organisation['data']['name'];
     $this->page_datas->datas['code'] = $organisation['data']['code'];
     //5. generate view
     $view_source = $this->view_source_root . '.create';
     $route_source = $current_route;
     return $this->generateView($view_source, $route_source);
 }
Esempio n. 5
0
 /**
  * { create }
  *
  * @param     
  * 1. org_id
  * 2. branch_id
  * 3. id
  *
  * @return
  * 1. Layout
  * 2. page_attributes
  * 3. page_datas
  * 
  * steps
  * 1. validate
  * 2. get data
  * 3. set page attributes
  * 4. set page datas
  * 5. generate view
  */
 public function create($org_id = null, $branch_id = null, $id = null)
 {
     //1. validate
     if (is_null($org_id)) {
         App::abort(403, 'Id Organisasi tidak ada');
     }
     if (is_null($branch_id)) {
         App::abort(403, 'Id branch tidak ada');
     }
     // 2 & 3
     $APIOrg = new APIOrg();
     $org = $APIOrg->getShow($org_id);
     if (!is_null($id)) {
         //2. get data
         $APIChart = new APIChart();
         $data = $APIChart->getShow($org_id, $branch_id, $id);
         $data['data']['organisation_id'] = $org_id;
         //3. set page attributes
         $current_route = route(Route::CurrentRouteName(), ['org_id' => $org_id, 'branch_id' => $branch_id, 'id' => $id]);
         $this->page_attributes->page_subtitle = 'edit';
         $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$org['data']['name'] => route('org.show', ['id' => $org_id]), 'Edit Struktur ' . $data['data']['name'] => $current_route]);
     } else {
         //2. get data
         $data['data']['id'] = "";
         $data['data']['organisation_id'] = $org_id;
         $data['data']['branch_id'] = $branch_id;
         $data['data']['name'] = null;
         $data['data']['department'] = null;
         $data['data']['path'] = null;
         //3. set page attributes
         $current_route = route(Route::CurrentRouteName(), ['org_id' => $org_id, 'branch_id' => $branch_id]);
         $this->page_attributes->page_subtitle = 'Struktur baru';
         $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, [$org['data']['name'] => route('org.show', ['id' => $org_id]), 'Cabang Baru' => $current_route]);
     }
     //4. set page datas
     $this->page_datas->datas = $data['data'];
     //5. generate view
     $view_source = $this->view_source_root . '.create';
     $route_source = $current_route;
     return $this->generateView($view_source, $route_source);
 }