public virtual IEnumerable openContact(PXAdapter adapter)
        {
            var entity = this.Caches[typeof(ObfuscateEntity)].Current as ObfuscateEntity;

            if (entity == null)
            {
                return(adapter.Get());
            }

            if (entity.Deleted == true)
            {
                throw new PXSetPropertyException(Messages.NavigateDeleted);
            }

            var primary = RemapToPrimary(new List <ObfuscateEntity> {
                entity
            });

            foreach (IBqlTable table in primary)
            {
                if (table is Contact)
                {
                    var graph = PXGraph.CreateInstance <ContactMaint>();
                    PXRedirectHelper.TryRedirect(graph, table, PXRedirectHelper.WindowMode.New);
                }
                else if (table is CRContact)
                {
                    var opp = new PXSelect <
                        CROpportunity,
                        Where <CROpportunity.opportunityContactID, Equal <Required <CRContact.contactID> > > >(this)
                              .SelectSingle((table as CRContact).ContactID);

                    var graph = PXGraph.CreateInstance <OpportunityMaint>();
                    PXRedirectHelper.TryRedirect(graph, opp, PXRedirectHelper.WindowMode.New);
                }
            }

            return(adapter.Get());
        }
Exemplo n.º 2
0
        public virtual IEnumerable ViewDetails(PXAdapter adapter)
        {
            APGLDiscrepancyByVendorEnqFilter header = Filter.Current;
            APGLDiscrepancyByVendorEnqResult row    = Rows.Current;

            if (header != null && row != null)
            {
                APGLDiscrepancyByDocumentEnq     detailsGraph = PXGraph.CreateInstance <APGLDiscrepancyByDocumentEnq>();
                APGLDiscrepancyByVendorEnqFilter filter       = detailsGraph.Filter.Current;
                filter.BranchID   = header.BranchID;
                filter.VendorID   = row.VendorID;
                filter.PeriodFrom = header.PeriodFrom;
                filter.AccountID  = header.AccountID;
                filter.SubCD      = header.SubCD;
                filter.ShowOnlyWithDiscrepancy = header.ShowOnlyWithDiscrepancy;
                detailsGraph.Filter.Select();

                PXRedirectHelper.TryRedirect(detailsGraph, PXRedirectHelper.WindowMode.New);
            }

            return(adapter.Get());
        }
Exemplo n.º 3
0
        public virtual void editRecord()
        {
            SMEmail item = Emails.Current;

            if (item == null)
            {
                return;
            }

            if (item.RefNoteID != null)
            {
                CREmailActivityMaint graph = CreateInstance <CREmailActivityMaint>();
                graph.Message.Current = graph.Message.Search <CRSMEmail.noteID>(item.RefNoteID);
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
            else
            {
                CRSMEmailMaint graph = CreateInstance <CRSMEmailMaint>();
                graph.Email.Current = graph.Email.Search <SMEmail.noteID>(item.NoteID);
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
        }
        public virtual void AddOpportunity()
        {
            var row = ContactCurrent.Current;

            if (row == null || row.ContactID == null)
            {
                return;
            }

            CRContactClass ctcls = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Required <Contact.classID> > > > .Select(this, row.ClassID);

            var graph          = PXGraph.CreateInstance <OpportunityMaint>();
            var newOpportunity = graph.Opportunity.Insert();

            newOpportunity.BAccountID = row.BAccountID;
            if (ctcls != null && ctcls.TargetOpportunityClassID != null)
            {
                newOpportunity.CROpportunityClassID = ctcls.TargetOpportunityClassID;
            }
            newOpportunity.ContactID = row.ContactID;
            graph.Opportunity.Update(newOpportunity);
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
        }
Exemplo n.º 5
0
        public virtual IEnumerable ViewDocument(PXAdapter adapter)
        {
            LinesToPO.Cache.IsDirty = false;

            POEnabledFSSODet poEnabledFSSODetRow = LinesToPO.Current;

            if (poEnabledFSSODetRow == null ||
                poEnabledFSSODetRow.SrvOrdType == null ||
                poEnabledFSSODetRow.RefNbr == null)
            {
                return(adapter.Get());
            }

            ServiceOrderEntry graphServiceOrderEntry = PXGraph.CreateInstance <ServiceOrderEntry>();

            graphServiceOrderEntry.ServiceOrderRecords.Current =
                graphServiceOrderEntry.ServiceOrderRecords
                .Search <FSServiceOrder.refNbr>(poEnabledFSSODetRow.RefNbr, poEnabledFSSODetRow.SrvOrdType);

            PXRedirectHelper.TryRedirect(graphServiceOrderEntry, PXRedirectHelper.WindowMode.Popup);

            return(adapter.Get());
        }
Exemplo n.º 6
0
                  ShortcutCtrl = true, ShortcutShift = true, ShortcutChar = (char)75)]       //Ctrl + Shift + K
        protected virtual void completeAndFollowUp()
        {
            EPActivity row = Tasks.Current;

            if (row == null)
            {
                return;
            }

            CompleteTask(row);

            CRTaskMaint graph = CreateInstance <CRTaskMaint>();

            EPActivity followUpTask = (EPActivity)graph.Tasks.Cache.CreateCopy(row);

            followUpTask.TaskID            = null;
            followUpTask.ParentTaskID      = row.ParentTaskID;
            followUpTask.UIStatus          = null;
            followUpTask.NoteID            = null;
            followUpTask.PercentCompletion = null;

            if (followUpTask.StartDate != null)
            {
                followUpTask.StartDate = ((DateTime)followUpTask.StartDate).AddDays(1D);
                graph.Tasks.Cache.SetDefaultExt <EPActivity.weekID>(followUpTask);
            }
            if (followUpTask.EndDate != null)
            {
                followUpTask.EndDate = ((DateTime)followUpTask.EndDate).AddDays(1D);
            }

            followUpTask.TimeBillable     = null;
            followUpTask.OvertimeBillable = null;

            graph.Tasks.Cache.Insert(followUpTask);
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
        }
Exemplo n.º 7
0
        public virtual IEnumerable openContact(PXAdapter adapter)
        {
            var entity = this.Caches[typeof(SMPersonalDataIndex)].Current as SMPersonalDataIndex;

            if (entity == null)
            {
                return(adapter.Get());
            }

            var primary = RemapToPrimary(new List <SMPersonalDataIndex> {
                entity
            });

            foreach (IBqlTable table in primary)
            {
                if (table is Contact)
                {
                    PXPrimaryGraphCollection primaryGraph = new PXPrimaryGraphCollection(this);

                    PXGraph graph = primaryGraph[table];

                    PXRedirectHelper.TryRedirect(graph, table, PXRedirectHelper.WindowMode.New);
                }
                else if (table is CRContact)
                {
                    var opp = new PXSelect <
                        CROpportunity,
                        Where <CROpportunity.opportunityContactID, Equal <Required <CRContact.contactID> > > >(this)
                              .SelectSingle((table as CRContact).ContactID);

                    var graph = PXGraph.CreateInstance <OpportunityMaint>();
                    PXRedirectHelper.TryRedirect(graph, opp, PXRedirectHelper.WindowMode.New);
                }
            }

            return(adapter.Get());
        }
        public virtual IEnumerable viewDetails(PXAdapter adapter)
        {
            if (Members.Current != null)
            {
                InventoryItem _inventoryItem = PXSelect <InventoryItem,
                                                         Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .
                                               SelectSingleBound(this, null, Members.Current.InventoryID);

                if (_inventoryItem != null)
                {
                    if (_inventoryItem.StkItem == true)
                    {
                        InventoryItemMaint graph  = PXGraph.CreateInstance <InventoryItemMaint>();
                        PXResult           result = graph.Item.Search <InventoryItem.inventoryID>(Members.Current.InventoryID);
                        if (result != null)
                        {
                            InventoryItem _ninventoryItem = result[typeof(InventoryItem)] as InventoryItem;
                            graph.Item.Current = _ninventoryItem;
                            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Same);
                        }
                    }

                    else
                    {
                        NonStockItemMaint graph  = PXGraph.CreateInstance <NonStockItemMaint>();
                        PXResult          result = graph.Item.Search <InventoryItem.inventoryID>(Members.Current.InventoryID);
                        if (result != null)
                        {
                            InventoryItem _sinventoryItem = result[typeof(InventoryItem)] as InventoryItem;
                            graph.Item.Current = _sinventoryItem;
                            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Same);
                        }
                    }
                }
            }
            return(adapter.Get());
        }
        public virtual IEnumerable ViewContract(PXAdapter adapter)
        {
            var row = Activity.Current;

            var apRow = (EPActivityApprove)row;

            if (apRow != null)
            {
                Contract contractRow = null;

                contractRow = PXSelectJoin <Contract,
                                            InnerJoin <CRCase,
                                                       On <CRCase.contractID, Equal <Contract.contractID> >,
                                                       InnerJoin <CRActivityLink,
                                                                  On <CRActivityLink.refNoteID, Equal <CRCase.noteID> > > >,
                                            Where <CRActivityLink.noteID, Equal <Required <EPActivityApprove.refNoteID> > > > .Select(this, apRow.RefNoteID);

                if (contractRow != null)
                {
                    PXRedirectHelper.TryRedirect(this, contractRow, PXRedirectHelper.WindowMode.NewWindow);
                }
            }
            return(adapter.Get());
        }
Exemplo n.º 10
0
        public new IEnumerable NewContact(PXAdapter adapter)
        {
            if (this.BAccountAccessor.Cache.GetStatus(this.BAccountAccessor.Current) != PXEntryStatus.Inserted)
            {
                EmployeeMaint graph = CreateInstance <EmployeeMaint>();
                try
                {
                    int?ParentBAccountID = BaccountIDForNewEmployee();
                    graph.Employee.Insert(new EPEmployee
                    {
                        RouteEmails      = true,
                        ParentBAccountID = ParentBAccountID
                    });
                    graph.Employee.Cache.IsDirty = false;

                    graph.Caches <RedirectEmployeeParameters>().Insert(new RedirectEmployeeParameters
                    {
                        RouteEmails      = true,
                        ParentBAccountID = ParentBAccountID
                    });
                }
                catch (PXFieldProcessingException ex)
                {
                    if (graph.Employee.Cache.GetBqlField(ex.FieldName) == typeof(EPEmployee.parentBAccountID))
                    {
                        throw new PXSetPropertyException(Messages.YouDoNotHaveSufficientAccessRightsToViewOrModifyAnEmployee,
                                                         PXUIFieldAttribute.GetItemName(BAccount.Cache),
                                                         BAccountAccessor.Current.AcctCD);
                    }
                    throw;
                }

                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
            return(adapter.Get());
        }
        protected virtual IEnumerable viewSegment(PXAdapter adapter)
        {
            var current = Detail.Current;

            if (current != null)
            {
                Segment row;
                if (current.Inherited == true)
                {
                    row = (Segment)PXSelectReadonly2 <Segment,
                                                      InnerJoin <Dimension, On <Dimension.parentDimensionID, Equal <Segment.dimensionID> > >,
                                                      Where <Dimension.dimensionID, Equal <Required <Dimension.dimensionID> >,
                                                             And <Segment.segmentID, Equal <Required <Segment.segmentID> > > > > .
                          Select(this, current.DimensionID, current.SegmentID);
                }
                else
                {
                    row = (Segment)PXSelectReadonly <Segment> .
                          Search <Segment.dimensionID, Segment.segmentID>(this, current.DimensionID, current.SegmentID);
                }
                PXRedirectHelper.TryRedirect(Caches[typeof(Segment)], row, string.Empty);
            }
            return(adapter.Get());
        }
        public virtual void AddCase()
        {
            var row = ContactCurrent.Current;

            if (row == null || row.ContactID == null)
            {
                return;
            }

            var graph   = PXGraph.CreateInstance <CRCaseMaint>();
            var newCase = (CRCase)graph.Case.Cache.CreateInstance();

            newCase = PXCache <CRCase> .CreateCopy(graph.Case.Insert(newCase));

            newCase.CustomerID = row.BAccountID;
            newCase.ContactID  = row.ContactID;
            try
            {
                graph.Case.Update(newCase);
            }
            catch {}

            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
        }
Exemplo n.º 13
0
        public virtual void AddCase()
        {
            var row = ContactCurrent.Current;

            if (row == null || row.ContactID == null)
            {
                return;
            }

            Contact contact = (Contact)PXSelect <Contact, Where <Contact.contactID, Equal <Required <Contact.contactID> > > > .Select(this, row.ContactID);

            if (contact.BAccountID == null)
            {
                Contact.Cache.RaiseExceptionHandling <Contact.bAccountID>(row, null, new PXSetPropertyException <Contact.bAccountID>(Messages.BAccountRequiredToCreateCase));
                return;
            }
            var graph   = PXGraph.CreateInstance <CRCaseMaint>();
            var newCase = (CRCase)graph.Case.Cache.CreateInstance();

            newCase.CustomerID = row.BAccountID;
            newCase.ContactID  = row.ContactID;
            graph.Case.Insert(newCase);
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
        }
        protected virtual void getMoreApprovals()
        {
            var epApprovalsGraph = PXGraph.CreateInstance <EPApprovalProcess>();

            PXRedirectHelper.TryRedirect(epApprovalsGraph, PXRedirectHelper.WindowMode.Same);
        }
Exemplo n.º 15
0
        public void RedirectToBoxUserProfile()
        {
            var graph = PXGraph.CreateInstance <UserProfile>();

            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Same);
        }
Exemplo n.º 16
0
 public virtual void NavigateToItem(CRActivity current)
 {
     PXRedirectHelper.TryRedirect(this, current, PXRedirectHelper.WindowMode.NewWindow);
 }
Exemplo n.º 17
0
        public virtual IEnumerable messageDetails(PXAdapter a)
        {
            PXRedirectHelper.TryOpenPopup(History.Cache, History.Current, string.Empty);

            yield return(MassMails.Current);
        }
    protected virtual void Page_LoadComplete(object sender, EventArgs e)
    {
        string noteID = Request.Params["navigate"];

        if (!string.IsNullOrEmpty(noteID))
        {
            try
            {
                PXEntitySearch search = new PXEntitySearch();
                search.Redirect(Guid.Parse(noteID));
            }
            catch (PXRedirectRequiredException ex)
            {
                string url = PX.Web.UI.PXDataSource.getMainForm(ex.Graph.GetType());
                if (url != null)
                {
                    ex.Graph.Unload();
                    PXContext.Session.RedirectGraphType[PXUrl.ToAbsoluteUrl(url)] = ex.Graph.GetType();
                    Response.Redirect(this.ResolveUrl/**/ (url));
                    //throw new PXRedirectRequiredException(url, ex.Graph, "Redirect0:" + this.ResolveUrl/**/(url));
                }
            }
        }

        string fileName = Request.Params["file"];

        if (!string.IsNullOrEmpty(fileName))
        {
            try
            {
                WikiFileMaintenance      graph = PXGraph.CreateInstance <WikiFileMaintenance>();
                UploadFileWithIDSelector cur   =
                    PXSelect <UploadFileWithIDSelector,
                              Where <UploadFileWithIDSelector.name,
                                     Equal <Required <UploadFileWithIDSelector.name> > > > .Select(graph, HttpUtility.UrlDecode(fileName));

                if (cur != null)
                {
                    graph.Files.Current = cur;
                }
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Same);
            }
            catch (PXRedirectRequiredException ex)
            {
                string url = PX.Web.UI.PXDataSource.getMainForm(ex.Graph.GetType());
                if (url != null)
                {
                    ex.Graph.Unload();
                    PXContext.Session.RedirectGraphType[PXUrl.ToAbsoluteUrl(url)] = ex.Graph.GetType();
                    Response.Redirect(this.ResolveUrl/**/ (url));
                    //throw new PXRedirectRequiredException(url, ex.Graph, "Redirect0:" + this.ResolveUrl/**/(url));
                }
            }
        }
        //if (Page.IsPostBack && !Page.IsCallback)
        //	AcceptInput();

        //int page = 0;
        //int.TryParse(Request.Params["page"], out page);
        string query = TrimLongString(txtSearch.Text);

        switch (searchType)
        {
        case SearchService.SearchLookupType.ActiveModule:
        case SearchService.SearchLookupType.AllEntities:
            if (PerformSearchEntity(query, pageIndex))
            {
                divMessage.Visible = false;
            }
            break;

        case SearchService.SearchLookupType.ActiveWiki:
        case SearchService.SearchLookupType.AllHelp:
            if (PerformSearchArticle(query, pageIndex))
            {
                divMessage.Visible = false;
            }
            break;

        case SearchService.SearchLookupType.Files:
            if (PerformSearchFile(query, pageIndex))
            {
                divMessage.Visible = false;
            }
            break;
        }
    }
Exemplo n.º 19
0
 public virtual IEnumerable showCustomer(PXAdapter adapter)
 {
     PXRedirectHelper.TryRedirect(customer.Cache, CUSTOMER, Messages.Customer, PXRedirectHelper.WindowMode.NewWindow);
     return(adapter.Get());
 }
        private static void ClaimDetail(List <EPExpenseClaimDetails> details)
        {
            PXSetup <EPSetup> epsetup   = new PXSetup <EPSetup>(PXGraph.CreateInstance(typeof(ExpenseClaimDetailEntry)));
            bool enabledApprovalReceipt = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() && epsetup.Current.ClaimDetailsAssignmentMapID != null;
            bool isError        = false;
            bool notAllApproved = false;
            Dictionary <string, EPExpenseClaim> result = new Dictionary <string, EPExpenseClaim>();

            IEnumerable <Receipts> List;

            if (epsetup.Current.AllowMixedTaxSettingInClaims == true)
            {
                List = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                    item => new
                {
                    item.EmployeeID,
                    item.BranchID,
                    item.CustomerID,
                    item.CustomerLocationID,
                },
                    (key, item) => new Receipts
                {
                    employee         = key.EmployeeID,
                    branch           = key.BranchID,
                    customer         = key.CustomerID,
                    customerLocation = key.CustomerLocationID,
                    details          = item
                }
                    );
            }
            else
            {
                List = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                    item => new
                {
                    item.EmployeeID,
                    item.BranchID,
                    item.CustomerID,
                    item.CustomerLocationID,
                    item.TaxZoneID,
                    item.TaxCalcMode
                },
                    (key, item) => new Receipts
                {
                    employee         = key.EmployeeID,
                    branch           = key.BranchID,
                    customer         = key.CustomerID,
                    customerLocation = key.CustomerLocationID,
                    details          = item
                }
                    );
            }

            foreach (Receipts item in List)
            {
                isError        = false;
                notAllApproved = false;
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    ExpenseClaimEntry expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
                    expenseClaimEntry.SelectTimeStamp();
                    EPExpenseClaim expenseClaim = (EPExpenseClaim)expenseClaimEntry.ExpenseClaim.Cache.CreateInstance();
                    expenseClaim.EmployeeID         = item.employee;
                    expenseClaim.BranchID           = item.branch;
                    expenseClaim.CustomerID         = item.customer;
                    expenseClaim.DocDesc            = EP.Messages.SubmittedReceipt;
                    expenseClaim                    = expenseClaimEntry.ExpenseClaim.Update(expenseClaim);
                    expenseClaim.CustomerLocationID = item.customerLocation;
                    expenseClaim.TaxCalcMode        = item.details.First().TaxCalcMode;
                    expenseClaim.TaxZoneID          = item.details.First().TaxZoneID;

                    foreach (EPExpenseClaimDetails detail in item.details)
                    {
                        PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(detail);

                        if (detail.Approved ?? false)
                        {
                            try
                            {
                                if (detail.TipAmt != 0 && epsetup.Current.NonTaxableTipItem == null)
                                {
                                    PXProcessing <EPExpenseClaimDetails> .SetError(Messages.TipItemIsNotDefined);

                                    isError = true;
                                }
                                else
                                {
                                    EPClaimReceiptController.SubmitReceipt(expenseClaimEntry.ExpenseClaim.Cache,
                                                                           expenseClaimEntry.ExpenseClaimDetails.Cache, expenseClaimEntry.ExpenseClaim.Current, detail);

                                    PXProcessing <EPExpenseClaimDetails> .SetProcessed();
                                }


                                expenseClaimEntry.Save.Press();
                                if (!result.ContainsKey(expenseClaim.RefNbr))
                                {
                                    result.Add(expenseClaim.RefNbr, expenseClaim);
                                }
                                detail.RefNbr = expenseClaim.RefNbr;
                            }
                            catch (Exception ex)
                            {
                                PXProcessing <EPExpenseClaimDetails> .SetError(ex);

                                isError = true;
                            }
                        }
                        else
                        {
                            PXProcessing.SetError(enabledApprovalReceipt
                                                                ? Messages.ReceiptNotApproved
                                                                : Messages.ReceiptTakenOffHold);
                            notAllApproved = true;
                        }
                    }
                    if (!isError)
                    {
                        ts.Complete();
                    }
                }
            }



            if (!isError && !notAllApproved)
            {
                if (result.Count == 1)
                {
                    ExpenseClaimEntry expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
                    PXRedirectHelper.TryRedirect(expenseClaimEntry, result.First().Value, PXRedirectHelper.WindowMode.InlineWindow);
                }
            }
            else
            {
                PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(null);

                throw new PXException(Messages.ErrorProcessingReceipts);
            }
        }
        protected virtual void getMoreEmails()
        {
            var epEmailGraph = PXGraph.CreateInstance <CRCommunicationInbox>();

            PXRedirectHelper.TryRedirect(epEmailGraph, PXRedirectHelper.WindowMode.Same);
        }
Exemplo n.º 22
0
        private static void ClaimDetail(List <EPExpenseClaimDetails> details, bool isApiContext, bool singleOperation)
        {
            ExpenseClaimEntry expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
            PXSetup <EPSetup> epsetup           = new PXSetup <EPSetup>(PXGraph.CreateInstance(typeof(ExpenseClaimDetailEntry)));
            bool enabledApprovalReceipt         = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() && epsetup.Current.ClaimDetailsAssignmentMapID != null;
            bool isError        = false;
            bool notAllApproved = false;
            Dictionary <string, EPExpenseClaim> result = new Dictionary <string, EPExpenseClaim>();

            IEnumerable <Receipts> List;

            if (epsetup.Current.AllowMixedTaxSettingInClaims == true)
            {
                List = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                    item => new
                {
                    item.EmployeeID,
                    item.BranchID,
                    item.CustomerID,
                    item.CustomerLocationID,
                    ClaimCuryID = GetClaimCuryID(expenseClaimEntry, item)
                },
                    (key, item) => new Receipts
                {
                    employee         = key.EmployeeID,
                    branch           = key.BranchID,
                    customer         = key.CustomerID,
                    customerLocation = key.CustomerLocationID,
                    claimCuryID      = key.ClaimCuryID,
                    details          = item
                }
                    );
            }
            else
            {
                List = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                    item => new
                {
                    item.EmployeeID,
                    item.BranchID,
                    item.CustomerID,
                    item.CustomerLocationID,
                    item.TaxZoneID,
                    item.TaxCalcMode,
                    ClaimCuryID = GetClaimCuryID(expenseClaimEntry, item)
                },
                    (key, item) => new Receipts
                {
                    employee         = key.EmployeeID,
                    branch           = key.BranchID,
                    customer         = key.CustomerID,
                    customerLocation = key.CustomerLocationID,
                    claimCuryID      = key.ClaimCuryID,
                    details          = item
                }
                    );
            }

            string errorMessage = null;

            foreach (Receipts item in List)
            {
                isError        = false;
                notAllApproved = false;
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    expenseClaimEntry.Clear();
                    expenseClaimEntry.SelectTimeStamp();
                    EPExpenseClaim expenseClaim = (EPExpenseClaim)expenseClaimEntry.ExpenseClaim.Cache.CreateInstance();
                    expenseClaim.EmployeeID         = item.employee;
                    expenseClaim.BranchID           = item.branch;
                    expenseClaim.CustomerID         = item.customer;
                    expenseClaim.DocDesc            = EP.Messages.SubmittedReceipt;
                    expenseClaim                    = expenseClaimEntry.ExpenseClaim.Update(expenseClaim);
                    expenseClaim.CuryID             = item.claimCuryID;
                    expenseClaim                    = expenseClaimEntry.ExpenseClaim.Update(expenseClaim);
                    expenseClaim.CustomerLocationID = item.customerLocation;
                    expenseClaim.TaxCalcMode        = item.details.First().TaxCalcMode;
                    expenseClaim.TaxZoneID          = item.details.First().TaxZoneID;

                    foreach (EPExpenseClaimDetails detail in item.details)
                    {
                        PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(detail);

                        if (detail.Approved ?? false)
                        {
                            try
                            {
                                if (detail.IsPaidWithCard)
                                {
                                    EPEmployee employee =
                                        PXSelect <EPEmployee,
                                                  Where <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > >
                                        .Select(expenseClaimEntry, item.employee);

                                    if (employee.AllowOverrideCury != true && detail.CardCuryID != employee.CuryID)
                                    {
                                        errorMessage = PXMessages.Localize(Messages.ClaimCannotBeCreatedForReceiptBecauseCuryCannotBeOverriden);

                                        isError = true;
                                    }
                                }

                                if (!isError && detail.TipAmt != 0 && epsetup.Current.NonTaxableTipItem == null)
                                {
                                    errorMessage = Messages.TipItemIsNotDefined;
                                    isError      = true;
                                }

                                if (!isError)
                                {
                                    expenseClaimEntry.ReceiptEntryExt.SubmitReceiptExt(expenseClaimEntry.ExpenseClaim.Cache,
                                                                                       expenseClaimEntry.ExpenseClaimDetails.Cache, expenseClaimEntry.ExpenseClaim.Current, detail);

                                    expenseClaimEntry.Save.Press();
                                    if (!result.ContainsKey(expenseClaim.RefNbr))
                                    {
                                        result.Add(expenseClaim.RefNbr, expenseClaim);
                                    }
                                    detail.RefNbr = expenseClaim.RefNbr;

                                    PXProcessing <EPExpenseClaimDetails> .SetProcessed();
                                }
                            }
                            catch (Exception ex)
                            {
                                errorMessage = ex.Message;
                                isError      = true;
                            }
                        }
                        else
                        {
                            errorMessage = enabledApprovalReceipt
                                                                ? Messages.ReceiptNotApproved
                                                                : Messages.ReceiptTakenOffHold;

                            notAllApproved = true;
                        }

                        if (errorMessage != null)
                        {
                            PXProcessing <EPExpenseClaimDetails> .SetError(errorMessage);
                        }
                    }
                    if (!isError)
                    {
                        ts.Complete();
                    }
                }
            }

            if (!isError && !notAllApproved)
            {
                if (result.Count == 1 && isApiContext == false)
                {
                    expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
                    PXRedirectHelper.TryRedirect(expenseClaimEntry, result.First().Value, PXRedirectHelper.WindowMode.InlineWindow);
                }
            }
            else
            {
                PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(null);

                if (singleOperation)
                {
                    throw new PXException(errorMessage);
                }
                else
                {
                    throw new PXException(Messages.ErrorProcessingReceipts);
                }
            }
        }
        protected virtual void getMoreTasks()
        {
            var epTaskGraph = PXGraph.CreateInstance <CRTaskMaint>();

            PXRedirectHelper.TryRedirect(epTaskGraph, PXRedirectHelper.WindowMode.Same);
        }
        protected virtual void getMoreAnnouncements()
        {
            var epAnnouncementGraph = PXGraph.CreateInstance <CRCommunicationAnnouncement>();

            PXRedirectHelper.TryRedirect(epAnnouncementGraph, PXRedirectHelper.WindowMode.Same);
        }
        protected virtual void getMoreEvents()
        {
            var epEventGraph = PXGraph.CreateInstance <EPEventMaint>();

            PXRedirectHelper.TryRedirect(epEventGraph, PXRedirectHelper.WindowMode.Same);
        }
        protected virtual IEnumerable filteredItems([PXString] string action)
        {
            if (!String.Equals(Operations.Current.Action, action, StringComparison.OrdinalIgnoreCase))
            {
                FilteredItems.Cache.Clear();
            }
            Operations.Current.Action = action;

            var mailListID = MailLists.Current.With(ml => ml.MarketingListID);

            //Dinamic)
            if (MailLists.Current.With(ml => ml.IsDynamic == true))
            {
                return(CRSubscriptionsSelect.Select(this, mailListID));
            }

            CRSubscriptionsSelect.MergeFilters(this, mailListID);

            if (_ProcessPending)
            {
                _ProcessPending = false;
                Contact saved = FilteredItems.Current;
                var     list  = new List <Contact>();
                int     start = 0;
                int     total = 0;
                foreach (PXResult <Contact> item in FilteredItems.View.Select(null, new object[] { action }, null, null, null, PXView.Filters, ref start, 0, ref total))
                {
                    ((Contact)item).Selected = true;
                    FilteredItems.Update(item);
                    list.Add(((Contact)item));
                }
                FilteredItems.Current       = saved;
                FilteredItems.Cache.IsDirty = false;
                PerformAction(list);
                PXRedirectHelper.TryRedirect(this, PXRedirectHelper.WindowMode.Same);
            }

            //Remove
            if (string.Equals(Operations.Current.Action, REMOVE_ACTION, StringComparison.OrdinalIgnoreCase))
            {
                return(this.QuickSelect(RemoveItems.View.BqlSelect, PXView.Filters));
            }

            //Add
            var command = FilteredItems.View.BqlSelect;

            if (MailLists.Current.With(ml => ml.NoCall == true))
            {
                command = command.WhereAnd(
                    typeof(Where <Contact.noCall, IsNull,
                                  Or <Contact.noCall, NotEqual <True> > >));
            }
            if (MailLists.Current.With(ml => ml.NoEMail == true))
            {
                command = command.WhereAnd(
                    typeof(Where <Contact.noEMail, IsNull,
                                  Or <Contact.noEMail, NotEqual <True> > >));
            }
            if (MailLists.Current.With(ml => ml.NoFax == true))
            {
                command = command.WhereAnd(
                    typeof(Where <Contact.noFax, IsNull,
                                  Or <Contact.noFax, NotEqual <True> > >));
            }
            if (MailLists.Current.With(ml => ml.NoMail == true))
            {
                command = command.WhereAnd(
                    typeof(Where <Contact.noMail, IsNull,
                                  Or <Contact.noMail, NotEqual <True> > >));
            }
            if (MailLists.Current.With(ml => ml.NoMarketing == true))
            {
                command = command.WhereAnd(
                    typeof(Where <Contact.noMarketing, IsNull,
                                  Or <Contact.noMarketing, NotEqual <True> > >));
            }
            if (MailLists.Current.With(ml => ml.NoMassMail == true))
            {
                command = command.WhereAnd(
                    typeof(Where <Contact.noMassMail, IsNull,
                                  Or <Contact.noMassMail, NotEqual <True> > >));
            }

            return(this.QuickSelect(command, PXView.Filters));
        }
Exemplo n.º 27
0
        private static void ClaimDetail(List <EPExpenseClaimDetails> details)
        {
            PXSetup <EPSetup> epsetup   = new PXSetup <EPSetup>(PXGraph.CreateInstance(typeof(ExpenseClaimDetailEntry)));
            bool enabledApprovalReceipt = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() && epsetup.Current.ClaimDetailsAssignmentMapID != null;
            bool isError        = false;
            bool notAllApproved = false;
            bool emptyClaim     = true;
            var  List           = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                item => new { item.EmployeeID, item.BranchID, item.CustomerID, item.CustomerLocationID }
                , (key, item) => new { employee = key.EmployeeID, branch = key.BranchID, customer = key.CustomerID, customerLocation = key.CustomerLocationID, details = item }
                );

            List <EPExpenseClaim> result = new List <EPExpenseClaim>();

            foreach (var item in List)
            {
                isError        = false;
                notAllApproved = false;
                emptyClaim     = true;
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    ExpenseClaimEntry expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
                    EPExpenseClaim    expenseClaim      = (EPExpenseClaim)expenseClaimEntry.ExpenseClaim.Cache.CreateInstance();
                    expenseClaim.EmployeeID         = item.employee;
                    expenseClaim.BranchID           = item.branch;
                    expenseClaim.CustomerID         = item.customer;
                    expenseClaim.DocDesc            = EP.Messages.SubmittedReceipt;
                    expenseClaim                    = expenseClaimEntry.ExpenseClaim.Update(expenseClaim);
                    expenseClaim.CustomerLocationID = item.customerLocation;

                    foreach (EPExpenseClaimDetails detail in item.details)
                    {
                        PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(detail);

                        if (detail.Approved ?? false)
                        {
                            try
                            {
                                expenseClaimEntry.SubmitDetail(detail);
                                PXProcessing <EPExpenseClaimDetails> .SetProcessed();

                                emptyClaim = false;
                            }
                            catch (Exception ex)
                            {
                                PXProcessing <EPExpenseClaimDetails> .SetError(ex);

                                isError = true;
                            }
                        }
                        else
                        {
                            PXProcessing.SetError(enabledApprovalReceipt
                                ? Messages.ReceiptNotApproved
                                : Messages.ReceiptTakenOffHold);
                            notAllApproved = true;
                        }
                    }

                    if (!emptyClaim)
                    {
                        try
                        {
                            expenseClaimEntry.Actions.PressSave();
                            result.Add(expenseClaim);
                        }
                        catch (Exception ex)
                        {
                            foreach (EPExpenseClaimDetails detail in item.details)
                            {
                                PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(detail);

                                PXProcessing <EPExpenseClaimDetails> .SetError(ex);
                            }
                            isError = true;
                        }
                    }
                    if (!isError)
                    {
                        ts.Complete();
                    }
                }
            }

            if (!isError && !notAllApproved)
            {
                if (result.Count == 1)
                {
                    ExpenseClaimEntry expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
                    PXRedirectHelper.TryRedirect(expenseClaimEntry, result[0], PXRedirectHelper.WindowMode.InlineWindow);
                }
            }
            else
            {
                PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(null);

                throw new PXException(Messages.ErrorProcessingReceipts);
            }
        }
        private void CreateActivity(int classId, Guid?refNoteID, string typeCode, Guid?owner, PXRedirectHelper.WindowMode windowMode = PXRedirectHelper.WindowMode.NewWindow)
        {
            var graphType = CRActivityPrimaryGraphAttribute.GetGraphType(classId);

            if (!PXAccess.VerifyRights(graphType))
            {
                throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType));
            }

            CRActivity activity = null;

            var cache = CreateInstanceCache <CRActivity>(graphType);

            if (cache == null)
            {
                return;
            }

            if (owner == null)
            {
                owner = EmployeeMaint.GetCurrentEmployeeID(cache.Graph);
            }

            Action <object> initializeHandler = delegate(object act1)
            {
                var act = act1 as CRActivity;
                if (act == null)
                {
                    return;
                }

                act.ClassID   = classId;
                act.RefNoteID = refNoteID;
                if (!string.IsNullOrEmpty(typeCode))
                {
                    act.Type = typeCode;
                }
                act.OwnerID = owner;
            };

            EntityHelper helper = new EntityHelper(cache.Graph);
            var          type   = helper.GetEntityRowType(refNoteID);
            var          entity = helper.GetEntityRow(type, refNoteID);

            Type entityGraphType = null;

            if (type != null)
            {
                PXPrimaryGraphAttribute.FindPrimaryGraph(cache.Graph.Caches[type], ref entity, out entityGraphType);
            }
            if (entityGraphType != null)
            {
                PXGraph entry = PXGraph.CreateInstance(entityGraphType);
                PXCache <CRActivity> activityCache = entry.Caches[typeof(CRActivity)] as PXCache <CRActivity>;
                if (activityCache != null)
                {
                    entry.Views[entry.PrimaryView].Cache.Current = entity;
                    activity = (CRActivity)activityCache.CreateInstance();
                    if (initializeHandler != null)
                    {
                        initializeHandler(activity);
                    }
                    activity = activityCache.InitNewRow(activity);
                }
            }

            if (activity == null)
            {
                activity = (CRActivity)cache.CreateInstance();

                initializeHandler(activity);

                activity = ((PXCache <CRActivity>)cache).InitNewRow(activity);
            }

            cache.Update(activity);
            PXRedirectHelper.TryRedirect(cache.Graph, windowMode);
        }
Exemplo n.º 29
0
 public virtual IEnumerable ViewAsset(PXAdapter adapter)
 {
     PXRedirectHelper.TryRedirect(Assets.Cache, Assets.Current, "ViewAsset", PXRedirectHelper.WindowMode.Same);
     return(adapter.Get());
 }