/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $distribution = Distribution::find($id); $selected_recipients = $distribution->recipients->all(); $all_recipients = Recipient::whereNotIn('id', $selected_recipients)->get(); return view('distribution.edit', ['distribution' => $distribution, 'all_recipients' => $all_recipients, 'selected_recipients' => $selected_recipients]); }
public function cancelDispatch($id, Request $request) { $dispatch = RecipientPackage::find($id); $recipient = Recipient::find(Auth::user()->recipient_id); foreach ($dispatch->items as $items) { $volume = $items->amount * PackagingInformation::find($items->packaging_id)->cm_per_dose * 0.001; $stock = Stock::where('recipient_id', $recipient->id)->where('vaccine_id', $items->vaccine_id)->where('lot_number', $items->batch_number)->first(); $storeStock = StoreStock::where('store_id', $items->store_id)->where('vaccine_id', $items->vaccine_id)->where('lot_number', $items->batch_number)->first(); $stock->amount = $stock->amount + $items->amount; $storeStock->amount = $storeStock->amount + $items->amount; $stock->save(); $storeStock->save(); //reduce volume in store $store = Store::find($items->store_id); $store->used_volume = $store->used_volume + $volume; $store->save(); //update line item status $items->status = 'canceled'; $items->save(); //delete stock item if amount has turned to zero if ($stock->amount == 0) { $stock->delete(); } if ($storeStock->amount == 0) { $storeStock->delete(); } } //update arrival status $dispatch->receiving_status = 'canceled'; $dispatch->comments = $request->has('notes') ? $request->input('notes') : ""; $dispatch->save(); Log::create(array("user_id" => Auth::user()->id, "action" => "Cancel Dispatch with reference Number " . $dispatch->voucher_number)); return $dispatch->voucher_number; }
/** * get movedItems. *@param $recipient * @param $level * @return Response */ public function movedItems1($recipient, $level) { if ($level == '1') { return ItemMovement::where('recipient_id', $recipient)->get(); } elseif ($level == '2') { $orgunit = Recipient::find($recipient); $arr = [0, $recipient]; array_push($arr, $recipient); foreach ($orgunit->childrens as $val) { array_push($arr, $val->id); } $dispatch = ItemMovement::whereIn('recipient_id', $arr)->get(); } elseif ($level == '3') { $orgunit = Recipient::find($recipient); $arr = [0]; array_push($arr, $recipient); foreach ($orgunit->childrens as $val) { array_push($arr, $val->id); $orgunit1 = Recipient::find($val->id); foreach ($orgunit1->childrens as $val) { array_push($arr, $val->id); } } $dispatch = ItemMovement::whereIn('recipient_id', $arr)->get(); } else { return ItemMovement::where('recipient_id', $recipient)->get(); } return $dispatch; }
/** * save new system settings * * @param Request $request * @return view */ public function saveSettings(Request $request) { if (count(SystemSettings::all()) != 0) { $item = SystemSettings::first(); } else { $item = new SystemSettings(); } $item->language = $request->input("language"); $item->main_currency = $request->input("main_currency"); $item->start_year = $request->input("start_year"); $item->save(); $central = Recipient::where('parent_id', 0)->first(); $central->name = $request->input("central_level_name"); $central->save(); Log::create(array("user_id" => Auth::user()->id, "action" => "Update System Settings")); return $item; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $item = Recipient::find($id); $item->status = "deleted"; $item->save(); Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Recipient named " . $item->name)); return $item; }
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' // ]); }
/** * Display the number of items in recipient level. * * @return Response */ public function getCentralLevel() { return Recipient::where('parent_id', 0)->first(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $recipient = Recipient::findOrFail($id); $recipient->delete(); return redirect()->route('recipient'); }