public ActionResult ThongTinPhoiVe(int NguonVeXeId, string ngaydi)
        {
            if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVQLChuyen))
            {
                return(AccessDeniedView());
            }
            var model   = new DinhViXeModel();
            var _ngaydi = Convert.ToDateTime(ngaydi);

            model.NguonVeXeId = NguonVeXeId;
            var _nguonve = _hanhtrinhService.GetNguonVeXeById(NguonVeXeId);

            if (_nguonve != null)
            {
                model.GioDiText   = _nguonve.ThoiGianDi.ToString("HH:mm");
                model.GioDenText  = _nguonve.ThoiGianDen.ToString("HH:mm");
                model.TuyenXeChay = _nguonve.TenDiemDon + "-" + _nguonve.TenDiemDen;
            }
            var _historyxexuatben = _nhaxeService.GetHistoryXeXuatBenByNguonVeId(NguonVeXeId, _ngaydi);

            if (_historyxexuatben != null)
            {
                model.TenLaiXe1 = _historyxexuatben.ThongTinLaiPhuXe();
                model.TenLaiXe2 = _historyxexuatben.ThongTinLaiPhuXe(1);
                model.TenLaiXe3 = _historyxexuatben.ThongTinLaiPhuXe(2);
                model.BienSo    = _historyxexuatben.xevanchuyen.BienSo;
            }

            model.NgayDi  = _ngaydi;
            model.SoNguoi = _phoiveService.GetAllSoNguoi(NguonVeXeId, _ngaydi);
            model.Revenue = _phoiveService.GetRevenueHistoryXeXuatBen(NguonVeXeId, _ngaydi).ToTien(_priceFormatter);
            return(View(model));
        }
        public ActionResult ListXeXuatBen(string ids)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.CVHangHoaKiGui))
            {
                return(AccessDeniedView());
            }
            var model = new PhieuGuiHangModel();

            model.ChuoiPhieuGuiHangId = ids;
            var items = _nhaxeService.GetAllXeXuatBenByNgayDi(_workContext.NhaXeId, DateTime.Now).Distinct();

            if (items.Count() == 0)
            {
                model.HasXeXuatBen = false;
            }
            else
            {
                model.XeXuatBenId   = items.First().Id;
                model.HasXeXuatBen  = true;
                model.ListXeXuatBen = items.Select(c =>
                {
                    var item    = new PhieuGuiHangModel.XeXuatBenModel();
                    item.Id     = c.Id;
                    var nguonve = _hanhtrinhService.GetNguonVeXeById(c.NguonVeId);

                    item.TenXeXuatBen = string.Format("{0}-{1} - {2}-{3} -{4} ({5})", nguonve.ThoiGianDi.ToString("HH:mm"), nguonve.ThoiGianDen.ToString("HH:mm"), "", c.NgayDi.ToString("dd/MM/yyyy"), c.xevanchuyen.TenXe, c.xevanchuyen.BienSo);
                    return(item);
                }).ToList();
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult GetSoDoGheXeInfo(int NguonVeXeId, int ParentId, long NgayDi, int?TangIndex)
        {
            int nguonveid = NguonVeXeId;

            if (ParentId > 0)
            {
                nguonveid = ParentId;
            }
            //lấy thong tin nguồn xe
            var nguonvexe = _hanhtrinhService.GetNguonVeXeById(nguonveid);

            if (nguonvexe == null)
            {
                return(new HttpUnauthorizedResult());
            }

            var loaixe = _xeinfoService.GetById(nguonvexe.LoaiXeId);

            if (loaixe == null)
            {
                return(new HttpUnauthorizedResult());
            }

            //var nhaxe = this.getCurrentNhaXe;
            var sodoghe      = _xeinfoService.GetSoDoGheXeById(loaixe.SoDoGheXeID);
            var modelsodoghe = new LoaiXeModel.SoDoGheXeModel();

            modelsodoghe.PhanLoai = ENPhanLoaiPhoiVe.PHOI_VE;
            SoDoGheXeToSoDoGheXeModel(sodoghe, modelsodoghe);
            //Lấy thông tin ma tran
            var sodoghevitris  = _xeinfoService.GetAllSoDoGheViTri(sodoghe.Id);
            var sodoghequytacs = _xeinfoService.GetAllSoDoGheXeQuyTac(loaixe.Id);

            modelsodoghe.MaTran   = new int[modelsodoghe.SoHang, modelsodoghe.SoCot];
            modelsodoghe.PhoiVes1 = new LoaiXeModel.PhoiVeAdvanceModel[modelsodoghe.SoHang + 1, modelsodoghe.SoCot + 1];
            modelsodoghe.SoTang   = 1;
            if (sodoghe.KieuXe == ENKieuXe.GiuongNam)
            {
                modelsodoghe.SoTang   = 2;
                modelsodoghe.PhoiVes2 = new LoaiXeModel.PhoiVeAdvanceModel[modelsodoghe.SoHang + 1, modelsodoghe.SoCot + 1];
            }
            foreach (var s in sodoghevitris)
            {
                modelsodoghe.MaTran[s.y, s.x] = 1;
            }

            DateTime _ngaydi = new DateTime(NgayDi);

            if (sodoghequytacs != null && sodoghequytacs.Count > 0)
            {
                foreach (var s in sodoghequytacs)
                {
                    if (s.Tang == 1)
                    {
                        modelsodoghe.PhoiVes1[s.y, s.x]        = new LoaiXeModel.PhoiVeAdvanceModel();
                        modelsodoghe.PhoiVes1[s.y, s.x].KyHieu = s.Val;
                        if (s.y >= 1 && s.x >= 1)
                        {
                            //kiem tra thong tin vi tri phoi ve
                            modelsodoghe.PhoiVes1[s.y, s.x].Info = _phoiveService.GetPhoiVe(nguonveid, s, _ngaydi, true);
                            modelsodoghe.PhoiVes1[s.y, s.x].IsCurrentCustomer = true;
                            if (modelsodoghe.PhoiVes1[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.Huy && modelsodoghe.PhoiVes1[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.ConTrong)
                            {
                                if (modelsodoghe.PhoiVes1[s.y, s.x].Info.CustomerId != _workContext.CurrentCustomer.Id)
                                {
                                    modelsodoghe.PhoiVes1[s.y, s.x].IsCurrentCustomer = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        modelsodoghe.PhoiVes2[s.y, s.x]        = new LoaiXeModel.PhoiVeAdvanceModel();
                        modelsodoghe.PhoiVes2[s.y, s.x].KyHieu = s.Val;
                        if (s.y >= 1 && s.x >= 1)
                        {
                            //kiem tra thong tin vi tri phoi ve
                            modelsodoghe.PhoiVes2[s.y, s.x].Info = _phoiveService.GetPhoiVe(nguonveid, s, _ngaydi, true);
                            modelsodoghe.PhoiVes2[s.y, s.x].IsCurrentCustomer = true;
                            if (modelsodoghe.PhoiVes2[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.Huy && modelsodoghe.PhoiVes2[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.ConTrong)
                            {
                                if (modelsodoghe.PhoiVes2[s.y, s.x].Info.CustomerId != _workContext.CurrentCustomer.Id)
                                {
                                    modelsodoghe.PhoiVes2[s.y, s.x].IsCurrentCustomer = false;
                                }
                            }
                        }
                    }
                }
            }
            //selected tab
            SaveSelectedTabIndex(TangIndex);
            return(PartialView(modelsodoghe));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Print orders to PDF
        /// </summary>
        /// <param name="stream">Stream</param>
        /// <param name="orders">Orders</param>
        /// <param name="languageId">Language identifier; 0 to use a language used when placing an order</param>
        public virtual void PrintOrdersToPdf(Stream stream, PhoiVe _phoive, int languageId = 0)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (_phoive == null)
            {
                throw new ArgumentNullException("Không có vé");
            }
            //get thong tin nguon ve
            var order = _orderService.GetOrderById(_phoive.OrderId);

            if (order == null)
            {
                throw new ArgumentNullException("Không có đơn hàng");
            }
            var nguonvexe = _hanhtrinhService.GetNguonVeXeById(_phoive.NguonVeXeId);

            if (nguonvexe.ParentId > 0)
            {
                nguonvexe = _hanhtrinhService.GetNguonVeXeById(_phoive.NguonVeXeConId);
            }
            //get thong tin nha xe
            var nhaxe = _nhaxeService.GetNhaXeById(nguonvexe.NhaXeId);

            var diachi = _diachiService.GetById(nhaxe.DiaChiID);
            //get thong tin xe xuan ben
            var xexuatbenInfo = _nhaxeService.GetHistoryXeXuatBenByNguonVeId(nguonvexe.Id, _phoive.NgayDi);
            var TenXe         = "";
            var BienSo        = "";

            if (xexuatbenInfo != null)
            {
                var xeInfo = _xeinfoService.GetXeInfoById(xexuatbenInfo.XeVanChuyenId.GetValueOrDefault(0));
                TenXe  = xeInfo.TenXe;
                BienSo = xeInfo.BienSo;
            }


            //logo
            var logoPicture = _pictureService.GetPictureById(nhaxe.LogoID);
            var logoExists  = logoPicture != null;
            var doc         = new Document();
            var pdfWriter   = PdfWriter.GetInstance(doc, stream);

            doc.Open();
            //fonts
            var titleFont = GetFont();

            titleFont.Size = BaseFont.SUPERSCRIPT_SIZE;
            //font ten nha xe
            var TenNhaXe = GetFont();

            TenNhaXe.SetStyle("initial");

            //font thong tin
            var InfoFont = GetFont();

            InfoFont.Size = 14;
            var font = GetFont();

            font.Size = 13;

            var pdfSettingsByStore = _settingContext.LoadSetting <PdfSettings>(order.StoreId);
            var lang = _workContext.WorkingLanguage;

            //header
            float[] widths     = { 3, 7 };
            var     HeaderVeIn = new PdfPTable(widths);

            HeaderVeIn.DefaultCell.Border = Rectangle.NO_BORDER;

            if (logoExists)
            {
                var logoFilePath = _pictureService.GetThumbLocalPath(logoPicture, 0, false);
                var logo         = Image.GetInstance(logoFilePath);
                logo.ScaleToFit(200, 100);

                PdfPCell CellLeft = new PdfPCell(logo);
                CellLeft.Border      = Rectangle.NO_BORDER;
                CellLeft.FixedHeight = 80f;
                HeaderVeIn.AddCell(CellLeft);
            }
            PdfPCell CellRight = new PdfPCell();

            CellRight.Border = Rectangle.NO_BORDER;
            var ParaTenNhaXe = new Paragraph(string.Format(_localizationService.GetResource("PDFInvoice.TenNhaXe", lang.Id),
                                                           nhaxe.TenNhaXe), font);

            ParaTenNhaXe.Alignment = Element.ALIGN_RIGHT;
            CellRight.AddElement(ParaTenNhaXe);
            var ParaDiaChi = new Paragraph(string.Format(_localizationService.GetResource("PDFInvoice.DiaChiNhXe", lang.Id),
                                                         diachi.DiaChi1 + " " + diachi.DiaChi2), font);

            ParaDiaChi.Alignment = Element.ALIGN_RIGHT;
            CellRight.AddElement(ParaDiaChi);
            var ParaSdt = new Paragraph(string.Format(_localizationService.GetResource("PDFInvoice.SDTNhaXe", lang.Id),
                                                      nhaxe.DienThoai), font);

            ParaSdt.Alignment = Element.ALIGN_RIGHT;
            CellRight.AddElement(ParaSdt);
            HeaderVeIn.AddCell(CellRight);
            doc.Add(HeaderVeIn);
            doc.Add(new Paragraph(""));
            doc.Add(new Paragraph(""));
            //add line
            var line = new iTextSharp.text.pdf.draw.LineSeparator(0, 100, BaseColor.GRAY, Element.ALIGN_CENTER, 1);

            doc.Add(new Chunk(line));
            //content
            Paragraph vexekhach = new Paragraph(_localizationService.GetResource("PDFInvoice.VeXeKhach", lang.Id), titleFont);

            vexekhach.Alignment = Element.ALIGN_CENTER;
            doc.Add(vexekhach);
            doc.Add(new Paragraph(""));
            doc.Add(new Paragraph(""));
            var Table1 = new PdfPTable(2);

            float[] widthTable1 = new float[] { 1f, 2f };
            Table1.SetWidths(widthTable1);
            Table1.RunDirection       = GetDirection(lang);
            Table1.DefaultCell.Border = Rectangle.NO_BORDER;
            Table1.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.Tuyen", lang.Id), font));
            Table1.AddCell(new Paragraph(nguonvexe.TenDiemDon + " -- " + nguonvexe.TenDiemDen, InfoFont));
            Table1.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.GiaVe", lang.Id), font));
            Table1.AddCell(new Paragraph(nguonvexe.LichTrinhInfo.GiaVeToanTuyen.ToString() + " VNĐ", InfoFont));
            doc.Add(Table1);
            //add ghe,xe
            var Table2 = new PdfPTable(4);

            float[] widthTable2 = new float[] { 1f, 2f, 1f, 2f };
            Table2.SetWidths(widthTable2);
            Table2.RunDirection       = GetDirection(lang);
            Table2.DefaultCell.Border = Rectangle.NO_BORDER;
            Table2.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.SoXe", lang.Id), font));
            Table2.AddCell(new Paragraph(TenXe + "/" + BienSo, InfoFont));
            Table2.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.SoGhe", lang.Id), font));
            Table2.AddCell(new Paragraph(_phoive.sodoghexequytac.Val + " ( Tầng" + _phoive.sodoghexequytac.Tang + ")", InfoFont));
            doc.Add(Table2);
            //add thoi gian khoi hanh
            var Table3 = new PdfPTable(4);

            float[] widthTable3 = new float[] { 2f, 1f, 1f, 2f };
            Table3.SetWidths(widthTable3);
            Table3.RunDirection       = GetDirection(lang);
            Table3.DefaultCell.Border = Rectangle.NO_BORDER;
            Table3.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.ThoiGianDi", lang.Id), font));
            Table3.AddCell(new Paragraph(nguonvexe.ThoiGianDi.ToString("HH:mm"), InfoFont));
            Table3.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.NgayDi", lang.Id), font));
            Table3.AddCell(new Paragraph(_phoive.NgayDi.ToString("dd/MM/yyyy"), InfoFont));
            doc.Add(Table3);
            //add footer
            var FooterNgayBan = new Paragraph("Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year, font);

            FooterNgayBan.Alignment = Element.ALIGN_RIGHT;
            var FooterNguoiBanTitle = new Paragraph("Người bán vé", font);

            FooterNguoiBanTitle.Alignment = Element.ALIGN_RIGHT;
            var firtname          = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.FirstName);
            var lastname          = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.LastName);
            var FooterTenNguoiBan = new Paragraph(firtname + " " + lastname, font);

            FooterTenNguoiBan.Alignment = Element.ALIGN_RIGHT;
            var Table4 = new PdfPTable(1);

            Table4.DefaultCell.Border = Rectangle.NO_BORDER;
            PdfPCell CellFooter = new PdfPCell();

            CellFooter.Border = Rectangle.NO_BORDER;
            CellFooter.AddElement(FooterNgayBan);
            CellFooter.AddElement(FooterNguoiBanTitle);
            CellFooter.AddElement(FooterTenNguoiBan);
            Table4.AddCell(CellFooter);
            doc.Add(Table4);
            doc.Add(new Paragraph(" "));
            doc.NewPage();
            doc.Close();
        }