public function getCreate()
 {
     $stockInfos = new StockInfo();
     $allStockInfos = $stockInfos->getStockInfoDropDown();
     $parties = new Party();
     $partyAll = $parties->getPartiesDropDown();
     $imports = new Import();
     $consignmentAll = $imports->getConsignmentNameDropDown();
     $branches = new Branch();
     $branchAll = $branches->getBranchesDropDown();
     return view('SalesReturn.add', compact('allStockInfos', 'consignmentAll'))->with('branchAll', $branchAll)->with('partyAll', $partyAll);
 }
Пример #2
0
 public function getImports()
 {
     $imports = Import::where('status', '=', 'Activate')->get();
     echo "<option value ='N/A' >N/A </option>";
     foreach ($imports as $import) {
         echo "<option value = {$import->consignment_name} > {$import->consignment_name}</option> ";
     }
 }
 public function index()
 {
     return view('index', ['imports' => Import::all()]);
 }
Пример #4
0
 public function getEdit($id)
 {
     $stockInvoices = StockInvoice::find($id);
     $branches = new Branch();
     $branchAll = $branches->getBranchesDropDown();
     $stockDetails = StockDetail::where('invoice_id', '=', $stockInvoices->invoice_id)->first();
     $stockDetails2 = StockDetail::where('invoice_id', '=', $stockInvoices->invoice_id)->get();
     // get all stocks
     $stockInfos = new StockInfo();
     $allStockInfos = $stockInfos->getStockInfoDropDown();
     $invoiceId = $stockInvoices->invoice_id;
     //$invoiceId = 's121513';
     $buyersAll = 0;
     $imports = Import::where('status', '=', 'Activate')->get();
     $productsName = Product::where('product_type', '=', $stockDetails->product_type)->where('branch_id', '=', $stockDetails->branch_id)->get();
     return view('Stocks.edit2', compact('buyersAll', 'invoiceId', 'stockInvoices', 'stockDetails', 'productsName', 'stockDetails2', 'imports'))->with('branchAll', $branchAll)->with('allStockInfos', $allStockInfos);
     //        return view('Stocks.edit',compact('stock'))
     //            ->with('allStockInfos',$allStockInfos)
     //            ->with('branchAll',$branchAll);
 }
Пример #5
0
 public function getAddToStock($import_id, $to_stock_id)
 {
     $stockInvoces = new StockInvoice();
     $stockDetails = new StockDetail();
     $invoiceId = $stockInvoces->invoice_id = $this->generateInvoiceId();
     $import = Import::find($import_id);
     $import_details = ImportDetail::where('import_num', '=', $import_id)->where('stock_in_status', '=', '0')->get();
     if (!empty($import_details[0])) {
         $this->insertStockData($stockInvoces, $import, $invoiceId);
     }
     foreach ($import_details as $row) {
         $this->setStockData($import, $row, $stockDetails, $invoiceId, $to_stock_id);
     }
     Session::flash('message', 'Product added to the stock successfully');
     return Redirect::to('imports/details/' . $import->id);
     //$list = $this->setStockData($import, $stockDetails);
 }
Пример #6
0
 /**
  * 
  */
 public function postImportToTable(Request $req, $db, $file_id)
 {
     // dd($file_id);
     $db = $this->mod($db);
     $response['msg'] = '';
     $response['code'] = 200;
     $date = date('Y-m-d h:i:s');
     if ($req->get('data')) {
         $tanda_ok_for_log_import = 'ok';
         $jumlah_baris = 0;
         $jumlah_kolom = 0;
         foreach ($req->get('data') as $value) {
             $value['fileentries_id'] = '';
             $value['files_id'] = $file_id;
             // dd($value);
             $row = json_encode($value);
             $jumlah_kolom = count($row);
             if (!$db->create($value)) {
                 $tanda_ok_for_log_import = 'err';
                 $response['msg'] .= "Data ini {$row} Error <br>";
                 return json_encode($response);
             } else {
                 $tanda_ok_for_log_import = 'ok';
                 $response['msg'] .= "Data ini {$row}  OK <br>";
             }
             $jumlah_baris++;
         }
         if ($tanda_ok_for_log_import == 'ok') {
             $data_import['files_id'] = $file_id;
             $data_import['status_import'] = 'OK';
             $data_import['jumlah_baris'] = $jumlah_baris;
             $data_import['jumlah_kolom'] = $jumlah_kolom;
             $data_import['users_id'] = \Sentry::getUser()->id;
             Import::create($data_import);
         }
         return json_encode($response);
     }
     $response['code'] = 404;
     $response['msg'] = "Gagal Import File !!!";
     return json_encode($response);
 }
Пример #7
0
 private function createAutoGeneratedImportNum()
 {
     $imports = new Import();
     $import_number = $imports->getLastImportId();
     if ($import_number) {
         $test = explode('IMP', $import_number->import_num);
         $test[1] = $test[1] + 1;
         $number = sprintf('%06d', $test[1]);
         $import_num = 'IMP' . $number;
     } else {
         $sec = 'IMP';
         $num = '000001';
         $import_num = $sec . $num;
     }
     return $import_num;
 }