Пример #1
0
 public function move_item(Request $request)
 {
     $storeStock = StoreStock::find($request->input('item_id'));
     $volume = $request->input('doses') * PackagingInformation::find($storeStock->packaging_id)->cm_per_dose * 0.001;
     $recipient = Recipient::find(Auth::user()->recipient_id);
     $storeStock->amount = $request->has('doses') ? $storeStock->amount - $request->input('doses') : $storeStock->amount;
     $storeStock->save();
     if ($storeStock->amount == 0) {
         $storeStock->delete();
     }
     if (count(StoreStock::where('store_id', $request->input('to_store'))->where('vaccine_id', $storeStock->vaccine_id)->where('lot_number', $storeStock->lot_number)->get()) != 0) {
         $storeStock1 = StoreStock::where('store_id', $request->input('to_store'))->where('vaccine_id', $storeStock->vaccine_id)->where('lot_number', $storeStock->lot_number)->first();
         $storeStock1->amount = $request->has('doses') ? $storeStock1->amount + $request->input('doses') : $storeStock1->amount;
         $storeStock1->save();
     } else {
         $storeStock1 = new StoreStock();
         $storeStock1->vaccine_id = $storeStock->vaccine_id;
         $storeStock1->store_id = $request->input('to_store');
         $storeStock1->amount = $request->input('doses');
         $storeStock1->lot_number = $storeStock->lot_number;
         $storeStock1->packaging_id = $storeStock->packaging_id;
         $storeStock1->expiry_date = $storeStock->expiry_date;
         $storeStock1->unit_price = $storeStock->unit_price;
         $storeStock1->source_id = $storeStock->source_id;
         $storeStock1->activity_id = $storeStock->activity_id;
         $storeStock1->save();
     }
     $movement = new ItemMovement();
     $nextNumber = $this->getNextMovementNumber();
     $str = "";
     for ($sj = 6; $sj > strlen($nextNumber); $sj--) {
         $str .= "0";
     }
     $movement->reference = date('Y') . "4" . $str + "" . $nextNumber;
     $movement->from_store = $storeStock->store_id;
     $movement->to_store = $storeStock1->store_id;
     $movement->store_item_id = $storeStock->id;
     $movement->user_id = Auth::user()->id;
     $movement->amount = $request->input('doses');
     $movement->recipient_id = Auth::user()->recipient_id;
     $movement->vaccine_id = $storeStock->vaccine_id;
     $movement->lot_number = $storeStock->lot_number;
     $movement->expiry_date = $storeStock->expiry_date;
     $movement->moved_volume = $volume;
     $movement->year = date('Y');
     $movement->order_no = $nextNumber;
     $movement->save();
     $store = Store::find($storeStock->store_id);
     $store1 = Store::find($storeStock1->store_id);
     $store->used_volume = $store->used_volume - $volume;
     $store->save();
     $store1->used_volume = $store1->used_volume + $volume;
     $store1->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Move " . $request->input('doses') . " Doses of " . Vaccine::find($storeStock->vaccine_id)->name . " from " . $store->name . " To " . $store1->name));
     return $movement->reference;
 }
Пример #2
0
 /**
  * get storage volume of specific store.
  *
  * @param  int  $id
  * @return Response
  */
 public function vaccineStocks($id)
 {
     $item = Stock::where('recipient_id', Auth::user()->recipient_id)->select('vaccine_id', DB::raw('sum(amount) as total'))->groupBy('vaccine_id')->get();
     $array = array();
     foreach ($item as $stock) {
         $array[] = array('id' => $stock->vaccine_id, 'name' => Vaccine::find($stock->vaccine_id)->name, 'amount' => $stock->total);
     }
     return json_encode($array);
 }
Пример #3
0
 public function to_pdf($id)
 {
     $barcode = new DNS1D();
     $translation = array("english" => array("title" => "Vaccines Visibility System", "voucher_title" => "Ministry Of Health, Government of Nicaragua", "dispatch_date" => "Dispatch Date", "entered_by" => "Entered By :", "issued_to" => "Issued To :", "transport_mode1" => "Transport Mode :", "product" => "Products", "manufacture" => "Manufacturer", "lot_number" => "Batch Number", "expired_date" => "Expiration Date", "doses" => "Doses", "vials" => "Vials", "t_price" => "T. Price", "total_price" => "Total Price :", "issued" => "Issued By", "name_signature" => "Name & Designation:", "sign" => "Signature:", "receiver" => "Received By"), "spanish" => array("title" => "Sistema de Visibilidad de Vacunas", "voucher_title" => "Ministerio de Salud, Gobierno de Nicaragua", "dispatch_date" => "Fecha de Despacho", "entered_by" => "Anotado por :", "issued_to" => "Enviado a :", "transport_mode1" => "Modo de Transporte :", "product" => "Producto", "manufacture" => "Fabricante", "lot_number" => "Número de Lote", "expired_date" => "Fecha de Caducación", "doses" => "Dosis", "vials" => "Frascos", "t_price" => "Precio T.", "total_price" => "Precio Total :", "issued" => "Despachado por", "name_signature" => "Nombre y Designación:", "sign" => "Firma:", "receiver" => "Recibido Por"));
     $system_settings = SystemSettings::where('id', '!=', "0")->first();
     $lanKey = $system_settings->language;
     $main_currency = $system_settings->main_currency;
     $translate = $lanKey == "enUS" ? $translation['english'] : $translation['spanish'];
     $package = RecipientPackage::where('voucher_number', $id)->first();
     $transport = TransportMode::find($package->transport_mode_id);
     $issued_to = Recipient::find($package->recipient_id);
     $user = User::find($package->sending_user);
     $html = "<div style='width: 710px; font-family: \"Droid Sans\",\"Helvetica Neue\",Helvetica,Arial,sans-serif;'>";
     $html .= "<table style='width: 710px; font-family: \"Droid Sans\",\"Helvetica Neue\",Helvetica,Arial,sans-serif;'>";
     $html .= '<tr>';
     $html .= '<td><img src="' . asset('img/logo1.jpg') . '" style="height: 100px;width: 100px"></td>';
     $html .= '<td>';
     $html .= '<h3 style="text-align: center">' . $translate['title'] . '</h3>';
     $html .= '<h4 style="text-align: center">' . $translate['voucher_title'] . '</h4>';
     $html .= '</td>';
     $html .= '<td style="text-align: right"><img src="' . asset('img/logo.jpg') . '" style="height: 100px;width: 100px"></td>';
     $html .= '</tr>';
     $html .= "</table>";
     //Barcode Image
     $html .= "<div style='margin-left: 35%'>";
     $html .= '<div>' . $barcode->getBarcodeHTML($id, "C128", 2, 53) . '</div>';
     $html .= "<div style='margin-left: 15%'>" . $id . "</div>";
     $html .= "</div>";
     // Dispatch Date
     $html .= "<div style='text-align: center'>";
     $html .= "<h4>" . $translate['dispatch_date'] . " " . $package->date_sent . "</h4>";
     $html .= "</div>";
     $html .= "<table style='width: 710px; margin-top: 30px;margin-bottom: 20px'>";
     $html .= '<tr>';
     $html .= '<td>' . $translate['entered_by'] . ' ' . $user->first_name . ' ' . $user->last_name . '</td>';
     $html .= '<td>' . $translate['issued_to'] . ' ' . $issued_to->name . '</td>';
     $html .= '<td>' . $translate['transport_mode1'] . ' ' . $transport->name . '</td>';
     $html .= '</tr>';
     $html .= "</table>";
     $html .= "<table style='width: 710px;border-collapse: collapse;' border='1px'>";
     $html .= '<tr style="background-color: #ADFF2F; font-size: 12px">';
     $html .= '<th>Sr</th>';
     $html .= '<th>' . $translate['product'] . '</th>';
     $html .= '<th>' . $translate['manufacture'] . '</th>';
     $html .= '<th>' . $translate['lot_number'] . '</th>';
     $html .= '<th>' . $translate['expired_date'] . '</th>';
     $html .= '<th>' . $translate['doses'] . '</th>';
     $html .= '<th>' . $translate['vials'] . '</th>';
     $html .= '<th>' . $translate['t_price'] . '</th>';
     $html .= '</tr>';
     $i = 1;
     $total_price = 0;
     foreach ($package->items as $val) {
         $vaccine = Vaccine::find($val->vaccine_id);
         $packaging = PackagingInformation::find($val->packaging_id);
         $manufacture = Manufacture::find($packaging->manufacture_id);
         $html .= '<tr style="font-size: 12px">';
         $html .= '<td style="text-align: center">' . $i . '</td>';
         $html .= '<td style="text-align: center">' . $vaccine->name . '</td>';
         $html .= '<td style="text-align: center">' . $manufacture->name . '</td>';
         $html .= '<td style="text-align: center">' . $val->batch_number . '</td>';
         $html .= '<td style="text-align: center">' . $val->expiry_date . '</td>';
         $html .= '<td style="text-align: center">' . $val->amount . '</td>';
         $html .= '<td style="text-align: center">' . round($val->amount / $packaging->dose_per_vial, 0, PHP_ROUND_HALF_DOWN) . '</td>';
         $html .= '<td style="text-align: center">' . $main_currency . "  " . $val->amount * $val->unit_price . '</td>';
         $html .= '</tr>';
         $total_price += $val->amount * $val->unit_price;
     }
     $html .= "</table>";
     $html .= "<div><h4>" . $main_currency . "  " . $translate['total_price'] . " " . $total_price . "</h4></div>";
     $html .= "<table style='width: 710px;'>";
     $html .= '<tr>';
     $html .= '<td style="width: 30%; font-size: 12px"">';
     $html .= '<div>' . $translate['issued'] . '</div>';
     $html .= '<div>' . $translate['name_signature'] . ' _________</div>';
     $html .= '<div>' . $translate['sign'] . ' ________</div>';
     $html .= '</td>';
     $html .= '<td style="width: 40%"></td>';
     $html .= '<td style="width: 30%; font-size: 12px">';
     $html .= '<div>' . $translate['receiver'] . '</div>';
     $html .= '<div>' . $translate['name_signature'] . ' ___________</div>';
     $html .= '<div>' . $translate['sign'] . ' ___________</div>';
     $html .= '</td>';
     $html .= '</tr>';
     $html .= "</table>";
     $html .= "</div>";
     $pdf = App::make('dompdf.wrapper');
     $pdf->loadHTML($html);
     return $pdf->stream();
     //        return view('dispatch_voucher', [
     //            'name' => 'James',
     //            'second_name'=> 'Mbwilo'
     //        ]);
 }