load->model('ModelInventoryView', 'MIView'); $this->load->model('ModelType', 'MType'); $this->load->model('ModelProcessor', 'MProcessor'); $this->load->model('ModelRam', 'MRam'); $this->load->model('ModelHarddisk', 'MHarddisk'); $this->load->model('ModelSsd', 'MSsd'); $this->load->model('ModelVga', 'MVga'); $this->load->model('ModelOs', 'MOs'); $this->load->model('ModelDvd', 'MDvd'); $this->load->model('ModelSp', 'MSp'); $this->load->model('ModelKeyMou', 'MKeyMou'); $this->load->model('ModelWarna', 'MWarna'); $this->load->model('ModelRaid', 'MRaid'); $this->load->library(['datatables', 'form_validation']); $this->form_validation->set_error_delimiters('', ''); } public function output_json($data, $encode = true) { if ($encode) $data = json_encode($data); $this->output->set_content_type('application/json')->set_output($data); } public function index() { $username = $this->session->userdata('username'); $jabatan = $this->session->userdata('jabatan'); if ($username == null) { redirect("Action"); } elseif ($jabatan != "ADMIN") { redirect("Action"); } $datInventoryView = $this->MIView->getDataInventoryView(); $data = [ 'sidebar' => "data inventory", 'navChild' => "data inventory view", 'view' => $datInventoryView ]; $this->load->view('inventory/table-inventoryView', $data); } public function addPC() { $username = $this->session->userdata('username'); if ($username == null) { redirect("Login"); } $datInventory = $this->MI->getDataInventory(); $datType = $this->MType->getDataType(); $datProcessor = $this->MProcessor->getDataProcessor(); $datRam = $this->MRam->getDataRam(); $datHarddisk = $this->MHarddisk->getDataHarddisk(); $datSsd = $this->MSsd->getDataSsd(); $datVga = $this->MVga->getDataVga(); $datOs = $this->MOs->getDataOs(); $datDvd = $this->MDvd->getDataDvd(); $datSp = $this->MSp->getDataSp(); $datKeyMou = $this->MKeyMou->getDataKeyMou(); $data = [ 'sidebar' => "data inventory", 'navChild' => "data inventory sku", 'inventory' => $datInventory, 'type' => $datType, 'processor' => $datProcessor, 'ram' => $datRam, 'hdd' => $datHarddisk, 'ssd' => $datSsd, 'vga' => $datVga, 'os' => $datOs, 'dvd' => $datDvd, 'sp' => $datSp, 'keymou' => $datKeyMou ]; //var_dump($data); $this->load->view('inventory/inventory-tambahpc', $data); } public function addNB() { $username = $this->session->userdata('username'); if ($username == null) { redirect("Login"); } $datInventory = $this->MI->getDataInventory(); $datType = $this->MType->getDataType(); $datProcessor = $this->MProcessor->getDataProcessor(); $datRam = $this->MRam->getDataRam(); $datHarddisk = $this->MHarddisk->getDataHarddisk(); $datSsd = $this->MSsd->getDataSsd(); $datVga = $this->MVga->getDataVga(); $datOs = $this->MOs->getDataOs(); $datDvd = $this->MDvd->getDataDvd(); $datWarna = $this->MWarna->getDataWarna(); $data = [ 'sidebar' => "data inventory", 'navChild' => "data inventory sku", 'inventory' => $datInventory, 'type' => $datType, 'processor' => $datProcessor, 'ram' => $datRam, 'hdd' => $datHarddisk, 'ssd' => $datSsd, 'vga' => $datVga, 'os' => $datOs, 'dvd' => $datDvd, 'warna' => $datWarna ]; //var_dump($data); $this->load->view('inventory/inventory-tambahnb', $data); } public function addSRV() { $username = $this->session->userdata('username'); if ($username == null) { redirect("Login"); } $datInventory = $this->MI->getDataInventory(); $datType = $this->MType->getDataType(); $datProcessor = $this->MProcessor->getDataProcessor(); $datRam = $this->MRam->getDataRam(); $datHarddisk = $this->MHarddisk->getDataHarddisk(); $datSsd = $this->MSsd->getDataSsd(); $datVga = $this->MVga->getDataVga(); $datOs = $this->MOs->getDataOs(); $datDvd = $this->MDvd->getDataDvd(); $datKeyMou = $this->MKeyMou->getDataKeyMou(); $datRaid = $this->MRaid->getDataRaid(); $data = [ 'sidebar' => "data inventory", 'navChild' => "data inventory sku", 'inventory' => $datInventory, 'type' => $datType, 'processor' => $datProcessor, 'ram' => $datRam, 'hdd' => $datHarddisk, 'ssd' => $datSsd, 'vga' => $datVga, 'os' => $datOs, 'dvd' => $datDvd, 'keymou' => $datKeyMou, 'raid' => $datRaid ]; //var_dump($data); $this->load->view('inventory/inventory-tambahsrv', $data); } public function savePC() { $method = $this->input->post('method'); $id_inventory = $this->input->post('id'); $type = $this->input->post('TYPE'); $processor = $this->input->post('PROCESSOR'); $ram = $this->input->post('RAM'); $hdd = $this->input->post('HDD'); $ssd = $this->input->post('SSD'); $vga = $this->input->post('VGA'); $os = $this->input->post('OS'); $dvd = $this->input->post('DVD'); $sp = $this->input->post('SP'); $keymou = $this->input->post('KEYMOU'); $this->form_validation->set_rules('TYPE', 'Pilih Type', 'required'); $this->form_validation->set_rules('PROCESSOR', 'Pilih Processor', 'required'); $this->form_validation->set_rules('RAM', 'Pilih RAM', 'required'); $this->form_validation->set_rules('HDD', 'Pilih HDD', 'required'); $this->form_validation->set_rules('SSD', 'Pilih SSD', 'required'); $this->form_validation->set_rules('VGA', 'Pilih VGA', 'required'); $this->form_validation->set_rules('OS', 'Pilih OS', 'required'); $this->form_validation->set_rules('DVD', 'Pilih Dvd', 'required'); $this->form_validation->set_rules('SP', 'Pilih Serial Paralel', 'required'); $this->form_validation->set_rules('KEYMOU', 'Pilih Keyboard Mouse', 'required'); if ($this->form_validation->run() == FALSE) { $data = [ 'status' => false, 'errors' => [ 'TYPE' => form_error('TYPE'), 'PROCESSOR' => form_error('PROCESSOR'), 'RAM' => form_error('RAM'), 'HDD' => form_error('HDD'), 'SSD' => form_error('SSD'), 'VGA' => form_error('VGA'), 'OS' => form_error('OS'), 'DVD' => form_error('DVD'), 'SP' => form_error('SP'), 'KEYMOU' => form_error('KEYMOU') ] ]; //$this->output_json($data);// $this->session->set_flashdata('flashgagal', 'ditambah'); redirect('ManageInventory'); } else { $input = [ 'ID_TYPE' => $type, 'ID_PROCESSOR' => $processor, 'ID_RAM' => $ram, 'ID_HDD' => $hdd, 'ID_SSD' => $ssd, 'ID_VGA' => $vga, 'ID_OS' => $os, 'ID_DVD' => $dvd, 'ID_SP' => $sp, 'ID_KEYMOU' => $keymou, 'ID_RAID' => '1', 'ID_WARNA' => '1' ]; $action = $this->MI->create('inventory', $input); if ($action) { $this->session->set_flashdata('flash', 'ditambah'); //$this->output_json(['status' => true]); redirect('ManageInventory'); } else { $this->session->set_flashdata('flashgagal', 'ditambah'); //$this->output_json(['status' => true]); redirect('ManageInventory'); } } } public function saveNB() { $method = $this->input->post('method'); $id_inventory = $this->input->post('id'); $type = $this->input->post('TYPE'); $processor = $this->input->post('PROCESSOR'); $ram = $this->input->post('RAM'); $hdd = $this->input->post('HDD'); $ssd = $this->input->post('SSD'); $vga = $this->input->post('VGA'); $os = $this->input->post('OS'); $dvd = $this->input->post('DVD'); $warna = $this->input->post('WARNA'); $this->form_validation->set_rules('TYPE', 'Pilih Type', 'required'); $this->form_validation->set_rules('PROCESSOR', 'Pilih Processor', 'required'); $this->form_validation->set_rules('RAM', 'Pilih RAM', 'required'); $this->form_validation->set_rules('HDD', 'Pilih HDD', 'required'); $this->form_validation->set_rules('SSD', 'Pilih SSD', 'required'); $this->form_validation->set_rules('VGA', 'Pilih VGA', 'required'); $this->form_validation->set_rules('OS', 'Pilih OS', 'required'); $this->form_validation->set_rules('DVD', 'Pilih Dvd', 'required'); $this->form_validation->set_rules('WARNA', 'Pilih Warna', 'required'); if ($this->form_validation->run() == FALSE) { $data = [ 'status' => false, 'errors' => [ 'TYPE' => form_error('TYPE'), 'PROCESSOR' => form_error('PROCESSOR'), 'RAM' => form_error('RAM'), 'HDD' => form_error('HDD'), 'SSD' => form_error('SSD'), 'VGA' => form_error('VGA'), 'OS' => form_error('OS'), 'DVD' => form_error('DVD'), 'WARNA' => form_error('WARNA') ] ]; //$this->output_json($data);// $this->session->set_flashdata('flashgagal', 'ditambah'); redirect('ManageInventory'); } else { $input = [ 'ID_TYPE' => $type, 'ID_PROCESSOR' => $processor, 'ID_RAM' => $ram, 'ID_HDD' => $hdd, 'ID_SSD' => $ssd, 'ID_VGA' => $vga, 'ID_OS' => $os, 'ID_DVD' => $dvd, 'ID_WARNA' => $warna, 'ID_SP' => '1', 'ID_KEYMOU' => '1', 'ID_RAID' => '1' ]; $action = $this->MI->create('inventory', $input); if ($action) { $this->session->set_flashdata('flash', 'ditambah'); //$this->output_json(['status' => true]); redirect('ManageInventory'); } else { $this->session->set_flashdata('flashgagal', 'ditambah'); //$this->output_json(['status' => true]); redirect('ManageInventory'); } } } public function saveSRV() { $method = $this->input->post('method'); $id_inventory = $this->input->post('id'); $type = $this->input->post('TYPE'); $processor = $this->input->post('PROCESSOR'); $ram = $this->input->post('RAM'); $hdd = $this->input->post('HDD'); $ssd = $this->input->post('SSD'); $vga = $this->input->post('VGA'); $os = $this->input->post('OS'); $dvd = $this->input->post('DVD'); $raid = $this->input->post('RAID'); $keymou = $this->input->post('KEYMOU'); $this->form_validation->set_rules('TYPE', 'Pilih Type', 'required'); $this->form_validation->set_rules('PROCESSOR', 'Pilih Processor', 'required'); $this->form_validation->set_rules('RAM', 'Pilih RAM', 'required'); $this->form_validation->set_rules('HDD', 'Pilih HDD', 'required'); $this->form_validation->set_rules('SSD', 'Pilih SSD', 'required'); $this->form_validation->set_rules('VGA', 'Pilih VGA', 'required'); $this->form_validation->set_rules('OS', 'Pilih OS', 'required'); $this->form_validation->set_rules('DVD', 'Pilih Dvd', 'required'); $this->form_validation->set_rules('RAID', 'Pilih RAID Controller', 'required'); $this->form_validation->set_rules('KEYMOU', 'Pilih Keyboard Mouse', 'required'); if ($this->form_validation->run() == FALSE) { $data = [ 'status' => false, 'errors' => [ 'TYPE' => form_error('TYPE'), 'PROCESSOR' => form_error('PROCESSOR'), 'RAM' => form_error('RAM'), 'HDD' => form_error('HDD'), 'SSD' => form_error('SSD'), 'VGA' => form_error('VGA'), 'OS' => form_error('OS'), 'DVD' => form_error('DVD'), 'RAID' => form_error('RAID'), 'KEYMOU' => form_error('KEYMOU') ] ]; //$this->output_json($data);// $this->session->set_flashdata('flashgagal', 'ditambah'); redirect('ManageInventory'); } else { $input = [ 'ID_TYPE' => $type, 'ID_PROCESSOR' => $processor, 'ID_RAM' => $ram, 'ID_HDD' => $hdd, 'ID_SSD' => $ssd, 'ID_VGA' => $vga, 'ID_OS' => $os, 'ID_DVD' => $dvd, 'ID_RAID' => $raid, 'ID_KEYMOU' => $keymou, 'ID_WARNA' => '1', 'ID_SP' => '1' ]; $action = $this->MI->create('inventory', $input); if ($action) { $this->session->set_flashdata('flash', 'ditambah'); //$this->output_json(['status' => true]); redirect('ManageInventory'); } else { $this->session->set_flashdata('flashgagal', 'ditambah'); //$this->output_json(['status' => true]); redirect('ManageInventory'); } } } public function hapus() { $id = $this->input->post('id'); if ($this->MI->delete('inventory', $id, 'ID_INVENTORY')) { $this->session->set_flashdata('flash', 'dihapus'); redirect('ManageInventory'); } } }