Postingan lainnya
Apakah bisa melakukan join serta insert secara bersamaan ?
Ane punya kendala gan, apakah bisa melakukan join serta insert secara bersaamaan ? ane stuck disini. jdi ane mau buat seperti input barcode gitu dengan user hanya input Lot Numbernya yang diambil dari table lain ( Receiving ) kemudian si attribute nya seperti Qty, Balance, Receive_date, Customer itu muncul dengan Query Join. di Table Codeigniter tampil, tapi di Table Mysqlnya kosong/ Null, ane sengaja kasih null biar mudah diceknya. caranya berhasil. tapi data ga masuk ke mysqlnya. yang masuk cuman si Lot Number sisanya Kosong...
ane pke Codeigniter 3 Gan.
ss_mysql.pngss_codeigniter2.png
Views :
<div class="card shadow">
<div class="card-header"><strong>Stock Incoming</strong></div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<td>No</td>
<td>Lot Number</td>
<td>Receive Date</td>
<td>Part Number</td>
<td>Qty In</td>
<td>Balance</td>
<td>Remark</td>
<td>Txndate</td>
<td>User Id</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<?php $no = 1; ?>
<?php foreach ($all_incoming as $incoming) { ?>
<tr>
<td><?= $no++; ?></td>
<td><?= $incoming->lot_numberI ?></td>
<td><?= $incoming->receive_date ?></td>
<td><?= $incoming->number_part ?></td>
<td><?= $incoming->qty_transfer ?></td>
<td><?= $incoming->balance ?></td>
<td><?= $incoming->remark ?></td>
<td><?= $incoming->txndate ?></td>
<td><?= $incoming->userid ?></td>
<td>
<a href="<?= base_url('incoming/detail/' . $incoming->id) ?>" class="btn btn-primary btn-sm mr-2" style="font-size: 13px;"><i class="far fa-folder"></i> Detail</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
ini Modal :
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">INCOMING FORM</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form action="<?= base_url('incoming/proses_tambah') ?>" method="POST">
<div class="modal-body">
<table class="table table-stripped">
<tr>
<td>UserId</td>
<td><input type="text" class="form-control" name="userid" autocomplete="off" value="<?= $this->session->login['nama'] ?>" readonly></td>
</tr>
<tr>
<td>Remark</td>
<td><input type="date" class="form-control" name="remark" autocomplete="off"></td>
</tr>
<tr>
<td>Txndate</td>
<td><input type="date" class="form-control" name="txndate" autocomplete="off"></td>
</tr>
<tr>
<td>Receive Date</td>
<td><input type="date" class="form-control" name="receive_date" autocomplete="off"></td>
</tr>
<tr>
<td>Lot Number</td>
<td>
<div class="input-group">
<input type="text" class="form-control" placeholder="Lot Number.." aria-describedby="basic-addon2" name="lot_numberI" id="lot_number" autocomplete="off">
<div class="input-group-append">
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#btnlotnumber">
<i class="fas fa-plus"></i> Incoming
</button>
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success">Add</button>
</div>
</form>
</div>
</div>
</div>
Controller index & Proses tambah
public function index()
{
$this->data['title'] = 'INCOMING';
$this->data['all_receiving'] = $this->m_receiving->lihat();
$this->data['all_incoming'] = $this->m_incoming->joinAttributeLotNumber(); // Ini
$this->data['printOutBarcode'] = $this->m_printBarcode->lihat();
$this->data['all_printoutbr'] = $this->m_delivery_printoutbarcode->lihat();
$this->data['no'] = 1;
$this->load->view('incoming/index', $this->data);
}
public function proses_tambah()
{
$data = [
'lot_numberI' => $this->input->post('lot_numberI'),
'receive_date' => $this->input->post('receive_date'),
'part_number' => $this->input->post('part_number'),
'qty_in' => $this->input->post('qty_in'),
'balance' => $this->input->post('balance'),
'remark' => $this->input->post('remark'),
'txndate' => $this->input->post('txndate'),
'userid' => $this->input->post('userid'),
];
if ($this->m_incoming->insertJoin($data)) {
$this->session->set_flashdata('success', 'Data Incoming <strong>Berhasil</strong> Ditambahkan!');
redirect('incoming');
} else {
$this->session->set_flashdata('error', 'Data Incoming <strong>Gagal</strong> Ditambahkan!');
redirect('incoming');
}
}
Model :
public function joinAttributeLotNumber()
{
$this->db->select('*');
$this->db->from('incoming');
$this->db->join('tb_printoutbarcode', 'incoming.lot_numberI = tb_printoutbarcode.lot_number','INNER');
$query = $this->db->get();
return $query->result();
}
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban