public virtual async Task <ShipmentListModel> PrepareShipmentListModel() { var model = new ShipmentListModel(); //countries model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = "" }); foreach (var c in await _countryService.GetAllCountries(showHidden: true)) { model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString() }); } //states model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" }); //warehouses model.AvailableWarehouses.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "" }); foreach (var w in await _shippingService.GetAllWarehouses()) { model.AvailableWarehouses.Add(new SelectListItem { Text = w.Name, Value = w.Id.ToString() }); } return(model); }
public async Task <IActionResult> PdfPackagingSlipAll(ShipmentListModel model) { if (_workContext.CurrentCustomer.IsStaff()) { model.StoreId = _workContext.CurrentCustomer.StaffStoreId; } //load shipments var shipments = await _shipmentViewModelService.PrepareShipments(model, 1, 100); //ensure that we at least one shipment selected if (shipments.totalCount == 0) { ErrorNotification(_localizationService.GetResource("Admin.Orders.Shipments.NoShipmentsSelected")); return(RedirectToAction("List")); } byte[] bytes; using (var stream = new MemoryStream()) { await _pdfService.PrintPackagingSlipsToPdf(stream, shipments.shipments.ToList(), _workContext.WorkingLanguage.Id); bytes = stream.ToArray(); } return(File(bytes, "application/pdf", "packagingslips.pdf")); }
public IActionResult ShipmentListSelect(DataSourceRequest command, ShipmentListModel model) { var shipments = _shipmentViewModelService.PrepareShipments(model, command.Page, command.PageSize); var gridModel = new DataSourceResult { Data = shipments.shipments.Select(shipment => _shipmentViewModelService.PrepareShipmentModel(shipment, false)), Total = shipments.totalCount }; return(Json(gridModel)); }
public ActionResult DoAddPurchaseOrder(int si, string pos) { var model = new ShipmentListModel(); try { var shipment = ShipmentService.FindShipmentModel(si, CurrentCompany, false); ShipmentService.AddPurchaseOrders(CurrentCompany, CurrentUser, shipment, pos); } catch (Exception e1) { this.WriteLog(e1); model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult DropContent(int index, int id) { // Called when a user clicks to drop a purchase order from the shipment content list var model = new ShipmentListModel(); model.GridIndex = index; try { ShipmentService.DeleteShipmentContent(id, false); } catch (Exception e1) { this.WriteLog(e1); model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(int index, int?sci, int?si) { var model = new ShipmentListModel(); model.GridIndex = index; try { if (sci != null) { // Got a shipping content id to delete ShipmentService.DeleteShipmentContent(sci.Value, true); } else if (si != null) { // No shipping content id, but got a shipping id to delete ShipmentService.DeleteShipment(si.Value); } } catch (Exception e1) { this.WriteLog(e1); model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> ShipmentListSelect(DataSourceRequest command, ShipmentListModel model) { //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !_workContext.CurrentCustomer.IsStaff()) { model.VendorId = _workContext.CurrentVendor.Id; } if (_workContext.CurrentCustomer.IsStaff()) { model.StoreId = _workContext.CurrentCustomer.StaffStoreId; } var shipments = await _shipmentViewModelService.PrepareShipments(model, command.Page, command.PageSize); var items = new List <ShipmentModel>(); foreach (var item in shipments.shipments) { items.Add(await _shipmentViewModelService.PrepareShipmentModel(item, false)); } var gridModel = new DataSourceResult { Data = items, Total = shipments.totalCount }; return(Json(gridModel)); }
public virtual async Task <(IEnumerable <Shipment> shipments, int totalCount)> PrepareShipments(ShipmentListModel model, int pageIndex, int pageSize) { DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); //load shipments var shipments = await _shipmentService.GetAllShipments( storeId: model.StoreId, vendorId: model.VendorId, warehouseId : model.WarehouseId, shippingCountryId : model.CountryId, shippingStateId : model.StateProvinceId, shippingCity : model.City, trackingNumber : model.TrackingNumber, loadNotShipped : model.LoadNotShipped, createdFromUtc : startDateValue, createdToUtc : endDateValue, pageIndex : pageIndex - 1, pageSize : pageSize); return(shipments.ToList(), shipments.TotalCount); }
public virtual (IEnumerable <Shipment> shipments, int totalCount) PrepareShipments(ShipmentListModel model, int pageIndex, int pageSize) { DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); //a vendor should have access only to his products string vendorId = ""; if (_workContext.CurrentVendor != null) { vendorId = _workContext.CurrentVendor.Id; } //load shipments var shipments = _shipmentService.GetAllShipments(vendorId: vendorId, warehouseId: model.WarehouseId, shippingCountryId: model.CountryId, shippingStateId: model.StateProvinceId, shippingCity: model.City, trackingNumber: model.TrackingNumber, loadNotShipped: model.LoadNotShipped, createdFromUtc: startDateValue, createdToUtc: endDateValue, pageIndex: pageIndex - 1, pageSize: pageSize); return(shipments.ToList(), shipments.TotalCount); }
public async Task <IActionResult> ShipmentListSelect(DataSourceRequest command, ShipmentListModel model) { var shipments = await _shipmentViewModelService.PrepareShipments(model, command.Page, command.PageSize); var items = new List <ShipmentModel>(); foreach (var item in shipments.shipments) { items.Add(await _shipmentViewModelService.PrepareShipmentModel(item, false)); } var gridModel = new DataSourceResult { Data = items, Total = shipments.totalCount }; return(Json(gridModel)); }