public function acceptanceStore(Request $req) { $vals = ['po_id' => $_POST['po_id'], 'pener_date' => now(), 'userid_input' => Auth::user()->user_id, 'visibility' => 1]; $pener = Pener::create($vals); foreach ($_POST['pos_id'] as $pos_id) { if (!empty($_POST['peners_jml_' . $pos_id])) { $vals = ['pener_id' => $pener->pener_id, 'pos_id' => $pos_id, 'peners_jml' => $_POST['peners_jml_' . $pos_id]]; Peners::create($vals); if (!empty($_POST['mat_id_' . $pos_id])) { $mat = MatModel::find($_POST['mat_id_' . $pos_id]); $mat->mat_stock_akhir = $mat->mat_stock_akhir + $_POST['peners_jml_' . $pos_id]; $mat->save(); } } } #Checking for update po_status $sub = Po_sub::fetchDetail($_POST['po_id']); $el = array(); foreach ($sub as $row) { $diterima = countDiterima($row->pos_id); $rest = $row->pbs_jml - $diterima; if ($rest > 0) { array_push($el, 'open'); } } if (!in_array('open', $el)) { $rec = Po::find($_POST['po_id']); $rec->po_status = 2; $rec->save(); } #End of checking Session::flash('inserted', '<div class="info success">Penerimaan material berhasil diinput.</div>'); return redirect('material/acceptance'); }
<th>Tgl Order</th> <th>Permintaan</th> <th>Jml Masuk</th> <th>Status</th> <th>Aksi</th> </tr> </thead> <tbody> <?php $x = 0; $po_no = ''; ?> @foreach($fetch as $row) <?php $accepted = countDiterima($row->pos_id); $text = null; ?> @if($po_no != $row->po_no) <?php $tr_class = 'new-po'; $po_no = $row->po_no; ?> @else <?php $tr_class = ''; ?> @endif <tr class="{{ $tr_class }}"> <td class="text-center">{{ ++$x }}.</td>
<thead> <tr> <th>Material</th> <th>Spesifikasi</th> <th>Permintaan</th> <th>Telah Diterima</th> <th>Kekurangan</th> <th>Diterima</th> <th>Satuan</th> <th>Status</th> </tr> </thead> <tbody> @foreach($sub as $row) <?php $diterima = countDiterima($row->pos_id); $rest = $row->pbs_jml - $diterima; ?> <tr> <td class="mat_nama"> <input type="hidden" name="pos_id[]" value="{{ $row->pos_id }}" /> {{ $row->mat_nama }} </td> <td class="mat_spesifikasi text-center">{{ $row->mat_spesifikasi }}</td> <td class="pbs_jml text-center">{{ $row->pbs_jml }}</td> <td class="diterima text-center">{{ $diterima }}</td> <td class="kekurangan text-center">{{ ($rest <= 0 ? '-' : $rest) }}</td> <td class="peners_jml text-center"> @if($rest > 0) <input type="hidden" name="mat_id_{{ $row->pos_id }}" value="{{ $row->mat_id }}" /> <input type="text" class="text-center peners" name="peners_jml_{{ $row->pos_id }}" required="required" />