예제 #1
0
 public function generateNumb()
 {
     $get = PoModel::generateNumb($_POST['type']);
     echo generatePoNumb($get);
 }
예제 #2
0
 public function requestStore(Request $req)
 {
     $values = ['sup_id' => $req->input('sup_id'), 'pb_no' => trim($req->input('pb_no')), 'pb_tgl_butuh' => $req->input('pb_tgl_butuh'), 'pb_note' => trim($req->input('pb_note')), 'visibility' => 1, 'userid_input' => Auth::user()->user_id];
     #pb_status, wether sudden-PO or not
     $values['pb_status'] = $req->input('create_po') == 1 ? 4 : 1;
     #End of sudden-PO
     $pb = Pb::create($values);
     #If sudden-PO then create PO head directly and a notification
     if ($req->input('create_po') == 1) {
         $get = Po::generateNumb('non');
         $values = ['pb_id' => $pb->pb_id, 'po_no' => generatePoNumb($get), 'po_tgl_buat' => now(), 'po_tgl_kedatangan' => $req->input('pb_tgl_butuh'), 'po_is_ppn' => 2, 'po_status' => 1, 'po_sudden' => 1];
         $po = Po::create($values);
         $values = ['gn_desc' => 'Pembuatan <i>Sudden-PO</i> oleh Rawmat dengan nomor PO: <strong>' . $po->po_no . '</strong>', 'gn_date' => now(true), 'gn_role' => 2, 'gn_read' => 2];
         Notif::create($values);
     }
     #Endif
     $x = 0;
     foreach ($_POST['mat_id'] as $val) {
         $values = ['pb_id' => $pb->pb_id, 'mat_id' => $val, 'pbs_jml' => $_POST['pbs_jml'][$x]];
         $pbs = Pbs::create($values);
         #If sudden-PO then create PO sub directly
         if ($req->input('create_po') == 1) {
             $values = ['po_id' => $po->po_id, 'pbs_id' => $pbs->pbs_id, 'pos_harga' => $_POST['mat_harga'][$x]];
             Po_sub::create($values);
         }
         #Endif
         $x++;
     }
     if ($req->input('create_po') == 1) {
         $message = 'Permintaan material telah dibuat berikut PO-nya dengan nomor: <strong>' . $po->po_no . '</strong>';
     } else {
         $message = 'Permintaan material telah dibuat.';
     }
     Session::flash('inserted', '<div class="info success">' . $message . '</div>');
     return redirect('material/request');
 }