135 lines
3.7 KiB
PHP
135 lines
3.7 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageProgress extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelProgress', 'MP');
|
|
$this->load->model('ModelService', 'MS');
|
|
$this->load->model('ModelOperator', 'MO');
|
|
$this->load->model('ModelTeknisi', 'MT');
|
|
$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("Authority");
|
|
} elseif ($jabatan != "ADMIN") {
|
|
redirect("Authority");
|
|
}
|
|
|
|
$datProgress = $this->MP->getDataProgressView();
|
|
$datService = $this->MS->getDataService();
|
|
$datTeknisi = $this->MT->getDataTeknisi();
|
|
|
|
$data = [
|
|
'sidebar' => "data proses service",
|
|
'navChild' => "data proses pengerjaan",
|
|
'progress' => $datProgress,
|
|
'service' => $datService,
|
|
'teknisi' => $datTeknisi
|
|
];
|
|
|
|
$this->load->view('master/Progress', $data);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
$jabatan = $this->session->userdata('jabatan');
|
|
if ($username == null) {
|
|
redirect("Action");
|
|
} elseif ($jabatan != "ADMIN") {
|
|
redirect("Action");
|
|
}
|
|
|
|
$datProgress = $this->MP->getDataProgress();
|
|
$datService = $this->MS->getDataServiceNull();
|
|
$datTeknisi = $this->MT->getDataTeknisi();
|
|
|
|
$data = [
|
|
'sidebar' => "data proses service",
|
|
'navChild' => "data proses pengerjaan",
|
|
'progress' => $datProgress,
|
|
'service' => $datService,
|
|
'teknisi' => $datTeknisi
|
|
];
|
|
|
|
$this->load->view('proses/UpdateService', $data);
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_progress = $this->input->post('id_progress');
|
|
$id_teknisi = $this->input->post('id_teknisied');
|
|
$status_progress = $this->input->post('status_progressed');
|
|
$kerusakan_progress = $this->input->post('kerusakan_progressed');
|
|
|
|
$input = [
|
|
'TEKNISI_ID' => $id_teknisi,
|
|
'STATUS_PROGRESS' => $status_progress,
|
|
'KERUSAKAN_PROGRESS' => $kerusakan_progress,
|
|
'TANGGAL_PROGRESS' => date('Y-m-d H:i:s')
|
|
];
|
|
|
|
$action = $this->MP->update('progress', $input,'ID_PROGRESS',$id_progress);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageProgress');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageProgress');
|
|
}
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_progress = $this->input->post('id');
|
|
$id_service = $this->input->post('id_service');
|
|
$id_teknisi = $this->input->post('id_teknisi');
|
|
$status_progress = $this->input->post('status_progress');
|
|
$kerusakan_progress = $this->input->post('kerusakan_progress');
|
|
|
|
$input = [
|
|
'TEKNISI_ID' => $id_teknisi,
|
|
'STATUS_PROGRESS' => $status_progress,
|
|
'KERUSAKAN_PROGRESS' => $kerusakan_progress,
|
|
'TANGGAL_PROGRESS' => date('Y-m-d H:i:s')
|
|
];
|
|
|
|
$action = $this->MP->create('progress', $input);
|
|
|
|
$datID = $this->MP->getDataProgressID();
|
|
|
|
if (is_array($datID)||is_object($$datID)) {
|
|
$update = [
|
|
'PROGRESS_ID' => $datID[0]['ID_PROGRESS']
|
|
];
|
|
$actionupdate = $this->MS->update('service', $update, 'ID_SERVICE',$id_service);
|
|
}
|
|
|
|
if ($actionupdate) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageProgress');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageProgress');
|
|
}
|
|
|
|
}
|
|
|
|
}
|