copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,413 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManagePenjualan extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelSupplier', 'MS');
|
||||
$this->load->model('ModelPembelian', 'MP');
|
||||
$this->load->model('ModelBarang', 'MB');
|
||||
$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');
|
||||
|
||||
$datPembelian = $this->MP->getDataPembelian();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "menu pembelian",
|
||||
'navChild' => ""
|
||||
];
|
||||
|
||||
$this->load->view('informasi/pembelian', $data);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$datSupplier = $this->MS->getDataSupplier();
|
||||
$datBarang = $this->MB->getDataBarang();
|
||||
$datPembelian = $this->MP->getDataPembelian();
|
||||
$data = [
|
||||
'sidebar' => "menu pembelian",
|
||||
'navChild' => "",
|
||||
'supplier' => $datSupplier,
|
||||
'pembelian' => $datPembelian,
|
||||
'barang' => $datBarang
|
||||
];
|
||||
$this->load->view('proses/pembelian', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$tgl_penjualan = $this->input->post('tgl_penjualan');
|
||||
$nama_customer = $this->input->post('nama_customer');
|
||||
$no_sn = $this->input->post('no_sn');
|
||||
|
||||
$this->form_validation->set_rules('tgl_penjualan', 'Tanggal Penjualan', 'required');
|
||||
$this->form_validation->set_rules('nama_customer', 'Nama Customer', 'required');
|
||||
$this->form_validation->set_rules('no_sn', 'Serial Number', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data = [
|
||||
'status' => false,
|
||||
'errors' => [
|
||||
'tgl_penjualan' => form_error('tgl_penjualan'),
|
||||
'nama_customer' => form_error('nama_customer'),
|
||||
'no_sn' => form_error('no_sn')
|
||||
]
|
||||
];
|
||||
$this->output_json($data);
|
||||
} else {
|
||||
$input = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn
|
||||
];
|
||||
|
||||
$input2 = [
|
||||
'ID_SN' => $no_sn,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$action = $this->MPenjualan->create('penjualan', $input);
|
||||
$action = $this->MSn->update('sn', $input2, 'ID_SN', $no_sn);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManagePenjualan');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManagePenjualan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function save5()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$tgl_penjualan = $this->input->post('tgl_penjualan');
|
||||
$nama_customer = $this->input->post('nama_customer');
|
||||
$no_sn1 = $this->input->post('no_sn1');
|
||||
$no_sn2 = $this->input->post('no_sn2');
|
||||
$no_sn3 = $this->input->post('no_sn3');
|
||||
$no_sn4 = $this->input->post('no_sn4');
|
||||
$no_sn5 = $this->input->post('no_sn5');
|
||||
|
||||
$this->form_validation->set_rules('tgl_penjualan', 'Tanggal Penjualan', 'required');
|
||||
$this->form_validation->set_rules('nama_customer', 'Nama Customer', 'required');
|
||||
$this->form_validation->set_rules('no_sn1', 'Serial Number 1', 'required');
|
||||
$this->form_validation->set_rules('no_sn2', 'Serial Number 2', 'required');
|
||||
$this->form_validation->set_rules('no_sn3', 'Serial Number 3', 'required');
|
||||
$this->form_validation->set_rules('no_sn4', 'Serial Number 4', 'required');
|
||||
$this->form_validation->set_rules('no_sn5', 'Serial Number 5', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data = [
|
||||
'status' => false,
|
||||
'errors' => [
|
||||
'tgl_penjualan' => form_error('tgl_penjualan'),
|
||||
'nama_customer' => form_error('nama_customer'),
|
||||
'no_sn1' => form_error('no_sn1'),
|
||||
'no_sn2' => form_error('no_sn2'),
|
||||
'no_sn3' => form_error('no_sn3'),
|
||||
'no_sn4' => form_error('no_sn4'),
|
||||
'no_sn5' => form_error('no_sn5')
|
||||
]
|
||||
];
|
||||
$this->output_json($data);
|
||||
} else {
|
||||
|
||||
$inputPenjualan1 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn1
|
||||
];
|
||||
|
||||
$inputPenjualan2 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn2
|
||||
];
|
||||
|
||||
$inputPenjualan3 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn3
|
||||
];
|
||||
|
||||
$inputPenjualan4 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn4
|
||||
];
|
||||
|
||||
$inputPenjualan5 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn5
|
||||
];
|
||||
|
||||
$inputStatus1 = [
|
||||
'ID_SN' => $no_sn1,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus2 = [
|
||||
'ID_SN' => $no_sn2,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus3 = [
|
||||
'ID_SN' => $no_sn3,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus4 = [
|
||||
'ID_SN' => $no_sn4,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus5 = [
|
||||
'ID_SN' => $no_sn5,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan1);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan2);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan3);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan4);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan5);
|
||||
$action = $this->MSn->update('sn', $inputStatus1, 'ID_SN', $no_sn1);
|
||||
$action = $this->MSn->update('sn', $inputStatus2, 'ID_SN', $no_sn2);
|
||||
$action = $this->MSn->update('sn', $inputStatus3, 'ID_SN', $no_sn3);
|
||||
$action = $this->MSn->update('sn', $inputStatus4, 'ID_SN', $no_sn4);
|
||||
$action = $this->MSn->update('sn', $inputStatus5, 'ID_SN', $no_sn5);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManagePenjualan');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManagePenjualan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function save10()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$tgl_penjualan = $this->input->post('tgl_penjualan');
|
||||
$nama_customer = $this->input->post('nama_customer');
|
||||
$no_sn1 = $this->input->post('no_sn1');
|
||||
$no_sn2 = $this->input->post('no_sn2');
|
||||
$no_sn3 = $this->input->post('no_sn3');
|
||||
$no_sn4 = $this->input->post('no_sn4');
|
||||
$no_sn5 = $this->input->post('no_sn5');
|
||||
$no_sn6 = $this->input->post('no_sn6');
|
||||
$no_sn7 = $this->input->post('no_sn7');
|
||||
$no_sn8 = $this->input->post('no_sn8');
|
||||
$no_sn9 = $this->input->post('no_sn9');
|
||||
$no_sn10 = $this->input->post('no_sn10');
|
||||
|
||||
$this->form_validation->set_rules('tgl_penjualan', 'Tanggal Penjualan', 'required');
|
||||
$this->form_validation->set_rules('nama_customer', 'Nama Customer', 'required');
|
||||
$this->form_validation->set_rules('no_sn1', 'Serial Number 1', 'required');
|
||||
$this->form_validation->set_rules('no_sn2', 'Serial Number 2', 'required');
|
||||
$this->form_validation->set_rules('no_sn3', 'Serial Number 3', 'required');
|
||||
$this->form_validation->set_rules('no_sn4', 'Serial Number 4', 'required');
|
||||
$this->form_validation->set_rules('no_sn5', 'Serial Number 5', 'required');
|
||||
$this->form_validation->set_rules('no_sn6', 'Serial Number 6', 'required');
|
||||
$this->form_validation->set_rules('no_sn7', 'Serial Number 7', 'required');
|
||||
$this->form_validation->set_rules('no_sn8', 'Serial Number 8', 'required');
|
||||
$this->form_validation->set_rules('no_sn9', 'Serial Number 9', 'required');
|
||||
$this->form_validation->set_rules('no_sn10', 'Serial Number 10', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data = [
|
||||
'status' => false,
|
||||
'errors' => [
|
||||
'tgl_penjualan' => form_error('tgl_penjualan'),
|
||||
'nama_customer' => form_error('nama_customer'),
|
||||
'no_sn1' => form_error('no_sn1'),
|
||||
'no_sn2' => form_error('no_sn2'),
|
||||
'no_sn3' => form_error('no_sn3'),
|
||||
'no_sn4' => form_error('no_sn4'),
|
||||
'no_sn5' => form_error('no_sn5'),
|
||||
'no_sn6' => form_error('no_sn6'),
|
||||
'no_sn7' => form_error('no_sn7'),
|
||||
'no_sn8' => form_error('no_sn8'),
|
||||
'no_sn9' => form_error('no_sn9'),
|
||||
'no_sn10' => form_error('no_sn10')
|
||||
]
|
||||
];
|
||||
$this->output_json($data);
|
||||
} else {
|
||||
|
||||
$inputPenjualan1 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn1
|
||||
];
|
||||
|
||||
$inputPenjualan2 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn2
|
||||
];
|
||||
|
||||
$inputPenjualan3 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn3
|
||||
];
|
||||
|
||||
$inputPenjualan4 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn4
|
||||
];
|
||||
|
||||
$inputPenjualan5 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn5
|
||||
];
|
||||
|
||||
$inputPenjualan6 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn6
|
||||
];
|
||||
|
||||
$inputPenjualan7 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn7
|
||||
];
|
||||
|
||||
$inputPenjualan8 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn8
|
||||
];
|
||||
|
||||
$inputPenjualan9 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn9
|
||||
];
|
||||
|
||||
$inputPenjualan10 = [
|
||||
'TGL_PENJUALAN' => $tgl_penjualan,
|
||||
'NAMA_CUSTOMER' => $nama_customer,
|
||||
'ID_SN' => $no_sn10
|
||||
];
|
||||
|
||||
$inputStatus1 = [
|
||||
'ID_SN' => $no_sn1,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus2 = [
|
||||
'ID_SN' => $no_sn2,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus3 = [
|
||||
'ID_SN' => $no_sn3,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus4 = [
|
||||
'ID_SN' => $no_sn4,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus5 = [
|
||||
'ID_SN' => $no_sn5,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus6 = [
|
||||
'ID_SN' => $no_sn6,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus7 = [
|
||||
'ID_SN' => $no_sn7,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus8 = [
|
||||
'ID_SN' => $no_sn8,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus9 = [
|
||||
'ID_SN' => $no_sn9,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$inputStatus10 = [
|
||||
'ID_SN' => $no_sn10,
|
||||
'ID_STATUSPENJUALAN' => '2'
|
||||
];
|
||||
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan1);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan2);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan3);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan4);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan5);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan6);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan7);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan8);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan9);
|
||||
$action = $this->MPenjualan->create('penjualan', $inputPenjualan10);
|
||||
$action = $this->MSn->update('sn', $inputStatus1, 'ID_SN', $no_sn1);
|
||||
$action = $this->MSn->update('sn', $inputStatus2, 'ID_SN', $no_sn2);
|
||||
$action = $this->MSn->update('sn', $inputStatus3, 'ID_SN', $no_sn3);
|
||||
$action = $this->MSn->update('sn', $inputStatus4, 'ID_SN', $no_sn4);
|
||||
$action = $this->MSn->update('sn', $inputStatus5, 'ID_SN', $no_sn5);
|
||||
$action = $this->MSn->update('sn', $inputStatus6, 'ID_SN', $no_sn6);
|
||||
$action = $this->MSn->update('sn', $inputStatus7, 'ID_SN', $no_sn7);
|
||||
$action = $this->MSn->update('sn', $inputStatus8, 'ID_SN', $no_sn8);
|
||||
$action = $this->MSn->update('sn', $inputStatus9, 'ID_SN', $no_sn9);
|
||||
$action = $this->MSn->update('sn', $inputStatus10, 'ID_SN', $no_sn10);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManagePenjualan');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManagePenjualan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$no_sn = $this->input->post('no_sn');
|
||||
if ($this->MPenjualan->delete('penjualan', $id, 'ID_PENJUALAN')) {
|
||||
$inputStatus = [
|
||||
'ID_SN' => $no_sn,
|
||||
'ID_STATUSPENJUALAN' => '1'
|
||||
];
|
||||
$action = $this->MSn->update('sn', $inputStatus, 'ID_SN', $no_sn);
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManagePenjualan');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user