orders export v2.3 filtered order list

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi All,

I am trying to create a export packing slips feature for v2.3 on the orders list page in admin area, I need to pass the list of orders which are a result of orderSearch.

I am getting stuck at the part where I need to pass the model parameter to the action method.

Inside List.cshtml:


<a href="@Url.Action("PdfPackagingSlips", ???)" class="t-button">Print Packing Slips</a>

Inside Orders controller:


        public ActionResult PdfPackagingSlips(OrderListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedView();

            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);

            OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null;
            PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null;
            ShippingStatus? shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null;


            var orders = _orderService.SearchOrders(startDateValue, endDateValue, orderStatus,
                paymentStatus, shippingStatus, model.CustomerEmail, model.OrderGuid, 0, 10000);
            
            var orderList = new List<Order>();

             foreach(Order order in orders){
                 orderList.Add(order);
             }
        
            
            string fileName = string.Format("packagingslip_{0}_{1}.pdf", "", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
            string filePath = string.Format("{0}content\\files\\ExportImport\\{1}", this.Request.PhysicalApplicationPath, fileName);
            _pdfService.PrintPackagingSlipsToPdf(orderList, filePath);
            var bytes = System.IO.File.ReadAllBytes(filePath);
            return File(bytes, "application/pdf", fileName);
        }

....

Please help me if I have lost my way... Appreciate your support.

Thanks.
12 years ago
Hi, did you resolve this?

I have literally just amended my code to include a check box and ability to print the checked orders pdf packing slip or order invoice, is this similar to what you're after?

Many thanks,

Dave
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.