Я пытаюсь закодировать это в Codeigniter
HMVC
контроллер:
public function tambah_pembelian_proses($id) {
//menambahkan ke tabel pembelian
$data = array(
'tgl_beli' => $this->input->post('tgl_beli'),
'waktu' => $this->input->post('waktu'),
'nomor_po' => $this->input->post('nomor_po'),
'nomor_manual' => $this->input->post('nomor_manual'),
'id_koderek' => $this->input->post('id_koderek'),
'id_supplier' => $this->input->post('id_supplier'),
'subtotal' => $this->input->post('subtotal'),
'username' => $this->input->post('username')
);
$update = $this->db->update('pembelian',$data,array('nomor_po' => $id));
//end menambahkan ke tabel pembelian
//menambahkan ke tabel pembelian_sementara
$data4 = array(
'tgl_beli' => $this->input->post('tgl_beli'),
'waktu' => $this->input->post('waktu'),
'nomor_po' => $this->input->post('nomor_po'),
'nomor_manual' => $this->input->post('nomor_manual'),
'id_koderek' => $this->input->post('id_koderek'),
'id_supplier' => $this->input->post('id_supplier'),
'nama_user' => $this->input->post('nama_user'),
'subtotal' => $this->input->post('subtotal')
);
$insert = $this->db->insert('pembelian_sementara',$data4);
//end menambahkan ke tabel pembelian_sementara
//menambahkan ke tabel pembelian_detail
$nomor_po_beli = $_POST['nomor_po_beli'];
$kode_brg = $_POST['kode_brg'];
$nama_barang = $_POST['nama_barang'];
$satuan = $_POST['satuan'];
$hrg = $_POST['hrg'];
$beli_qty = $_POST['beli_qty'];
$beli_total = $_POST['beli_total'];
$user = $_POST['user'];
$data2 = array();
$index = 0;
foreach ($nomor_po_beli as $data_nomor_po_beli){
array_push($data2, array(
'nomor_po_beli' => $data_nomor_po_beli,
'kode_brg' => $kode_brg[$index],
'nama_barang' => $nama_barang[$index],
'satuan' => $satuan[$index],
'hrg' => $hrg[$index],
'beli_qty' => $beli_qty[$index],
'beli_total' => $beli_total[$index],
'user' => $user[$index]
));
//tambah stok
//$this->db->query("update barang set stock=stock+'$beli_qty[$index]' where kode_brg='$kode_brg[$index]'"); //Tambah Add Stock
$index++;
}
$insert_detail = $this->m_pembelian->simpan_pembelian_detail($data2);
//end menambahkan ke tabel pembelian_detail
//menambahkan ke tabel add_to_terima
$nomor_po_beli = $_POST['nomor_po_beli'];
$kode_brg = $_POST['kode_brg'];
$nama_barang = $_POST['nama_barang'];
$satuan = $_POST['satuan'];
$hrg = $_POST['hrg'];
$beli_qty = $_POST['beli_qty'];
$beli_total = $_POST['beli_total'];
$user = $_POST['user'];
$data3 = array();
$index = 0;
foreach ($nomor_po_beli as $data_nomor_po_beli){
array_push($data3, array(
'nomor_po_beli' => $data_nomor_po_beli,
'kode_brg' => $kode_brg[$index],
'nama_barang' => $nama_barang[$index],
'satuan' => $satuan[$index],
'hrg' => $hrg[$index],
'beli_qty' => $beli_qty[$index],
'beli_total' => $beli_total[$index],
'user' => $user[$index]
));
//tambah stok
//$this->db->query("update barang set stock=stock+'$beli_qty[$index]' where kode_brg='$kode_brg[$index]'"); //Tambah Add Stock
$index++;
}
$insert_terima = $this->m_pembelian->simpan_add_to_terima($data3);
//$insert_terima = $this->db->insert('add_to_terima',$data3,array('id_add_terima' => $id));
//end menambahkan ke tabel add_to_terima
if ($insert_detail){
$username_cart = $this->session->userdata("username");
$delete = $this->db->delete('add_to_cart',array('username_cart' => $username_cart));
} else {
redirect('pembelian/lihat_pembelian/'.$id);
}
redirect('pembelian/lihat_pembelian/'.$id);
}
и результат
Обнаружено неперехваченное исключение
Тип: ArgumentCountError
Сообщение: слишком мало аргументов для функции Pembelian :: tambah_pembelian_proses (), 0 передано в C: \ xampp7.3.2 \ htdocs \ egupers \ system \ core \ CodeIgniter.php в строке 532 и ожидается ровно 1
Имя файла: C: \ xampp7.3.2 \ htdocs \ egupers \ application \ modules \ pembelian \ controllers \ Pembelian.php
Номер строки: 64
Backtrace:
Файл: C: \ xampp7.3.2 \ htdocs \ egupers \ index.php
Линия: 315
Функция: require_once