Esempio n. 1
0
    private void LoadOrganization(int organizationID)
    {
        Organization    organization = (Organization)Organizations.GetOrganization(UserSession.LoginUser, _organizatinID);
        BillingInfoItem item         = (BillingInfoItem)BillingInfo.GetBillingInfoItem(UserSession.LoginUser, _organizatinID);

        if (item != null && organization != null)
        {
            cbFree.Checked = organization.IsCustomerFree;
            cmbProductType.SelectedValue = ((int)organization.ProductType).ToString();
            cbActive.Checked             = organization.IsActive;
            cbAdvancedPortal.Checked     = organization.IsAdvancedPortal;
            cbBasicPortal.Checked        = organization.IsBasicPortal;
            cbAuto.Checked            = item.IsAutomatic;
            numUserPrice.Value        = (double?)item.UserPrice;
            numChatPrice.Value        = (double?)item.ChatPrice;
            numPortalPrice.Value      = (double?)item.PortalPrice;
            numBasicPortalPrice.Value = (double?)item.BasicPortalPrice;
            numStoragePrice.Value     = (double?)item.StoragePrice;
            numUserSeats.Value        = organization.UserSeats;
            numChatSeats.Value        = organization.ChatSeats;
            numPortalSeats.Value      = organization.PortalSeats;
            numStorage.Value          = organization.ExtraStorageUnits;
            textInactive.Text         = organization.InActiveReason;
            cbApiActive.Checked       = organization.IsApiActive;
            cbApiEnabled.Checked      = organization.IsApiEnabled;
            cbInventory.Checked       = organization.IsInventoryEnabled;
        }
    }
        public static string GetBillingInfoItem(RestCommand command, int organizationID)
        {
            BillingInfoItem billingInfoItem = BillingInfo.GetBillingInfoItem(command.LoginUser, organizationID);

            if (billingInfoItem.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(billingInfoItem.GetXml("BillingInfoItem", true));
        }
    private void VerifyBillingInfo()
    {
        BillingInfoItem item = (BillingInfoItem)BillingInfo.GetBillingInfoItem(UserSession.LoginUser, _organizationID);

        if (item == null)
        {
            BillingInfo info = new BillingInfo(UserSession.LoginUser);
            item                 = info.AddNewBillingInfoItem();
            item.IsAutomatic     = true;
            item.NextInvoiceDate = DateTime.UtcNow;
            item.OrganizationID  = _organizationID;
            item.Collection.Save();
        }
    }
Esempio n. 4
0
    public override bool Save()
    {
        Organization    organization = (Organization)Organizations.GetOrganization(UserSession.LoginUser, _organizatinID);
        BillingInfoItem item         = (BillingInfoItem)BillingInfo.GetBillingInfoItem(UserSession.LoginUser, _organizatinID);

        if (item != null && organization != null)
        {
            organization.IsCustomerFree = cbFree.Checked;
            ProductType productType = (ProductType)int.Parse(cmbProductType.SelectedValue);
            if (productType != organization.ProductType)
            {
                UserSettings.DeleteOrganizationSettings(UserSession.LoginUser, organization.OrganizationID);
            }
            organization.ProductType      = productType;
            organization.IsActive         = cbActive.Checked;
            organization.IsBasicPortal    = cbBasicPortal.Checked;
            organization.IsAdvancedPortal = cbAdvancedPortal.Checked;
            item.IsAutomatic                = cbAuto.Checked;
            item.UserPrice                  = numUserPrice.Value;
            item.ChatPrice                  = numChatPrice.Value;
            item.PortalPrice                = numPortalPrice.Value;
            item.BasicPortalPrice           = numBasicPortalPrice.Value;
            item.StoragePrice               = numStoragePrice.Value;
            organization.UserSeats          = (int)numUserSeats.Value;
            organization.ChatSeats          = (int)numChatSeats.Value;
            organization.PortalSeats        = (int)numPortalSeats.Value;
            organization.ExtraStorageUnits  = (int)numStorage.Value;
            organization.InActiveReason     = textInactive.Text;
            organization.IsApiEnabled       = cbApiEnabled.Checked;
            organization.IsApiActive        = cbApiActive.Checked;
            organization.IsInventoryEnabled = cbInventory.Checked;
            organization.Collection.Save();
            item.Collection.Save();
        }
        else
        {
            _manager.Alert("There was an error saving the account information");
        }

        return(true);
    }
    private void LoadDetails()
    {
        VerifyBillingInfo();
        BillingInfoItem item         = (BillingInfoItem)BillingInfo.GetBillingInfoItem(UserSession.LoginUser, _organizationID);
        Organization    organization = (Organization)Organizations.GetOrganization(UserSession.LoginUser, _organizationID);
        StringBuilder   builder      = new StringBuilder();

        if (organization != null)
        {
            builder.Append("<tr><td style=\"width: 200px;\"><strong>Organization ID: </strong></td><td>");
            builder.Append(organization.OrganizationID.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Is Customer Free: </strong></td><td>");
            builder.Append(organization.IsCustomerFree.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Heard about us from: </strong></td><td>");
            builder.Append(organization.WhereHeard + "</td></tr>");
            builder.Append("<tr><td><strong>Product Type: </strong></td><td>");
            builder.Append(DataUtils.ProductTypeString(organization.ProductType) + "</td></tr>");
            builder.Append("<tr><td><strong>Is Active: </strong></td><td>");
            builder.Append(organization.IsActive.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Inactive Reason: </strong></td><td>");
            builder.Append(organization.InActiveReason + "</td></tr>");
            //builder.Append("<tr><td style=\"width: 200px;\"><strong>Automatic Payment: </strong></td><td>");
            //builder.Append(item.IsAutomatic.ToString() + "</td></tr>");

            builder.Append("<tr><td><strong>User Seats: </strong></td><td>");
            builder.Append(organization.UserSeats.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Users Used: </strong></td><td>");
            builder.Append(Organizations.GetUserCount(UserSession.LoginUser, _organizationID).ToString() + "</td></tr>");
            if (item.UserPrice == null)
            {
                builder.Append("<tr><td><strong>Override User Price: </strong></td><td>");
                builder.Append("Default</td></tr>");
            }
            else
            {
                builder.Append("<tr><td><strong>Override User Price: </strong></td><td>");
                builder.Append(item.UserPrice.ToString() + "</td></tr>");
            }

            builder.Append("<tr><td><strong>Portal Seats: </strong></td><td>");
            builder.Append(organization.PortalSeats.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Portals Used: </strong></td><td>");
            builder.Append(Organizations.GetPortalCount(UserSession.LoginUser, _organizationID).ToString() + "</td></tr>");
            if (item.PortalPrice == null)
            {
                builder.Append("<tr><td><strong>Override Advanced Portal Price: </strong></td><td>");
                builder.Append("Default</td></tr>");
            }
            else
            {
                builder.Append("<tr><td><strong>Override Advanced Portal Price: </strong></td><td>");
                builder.Append(item.PortalPrice.ToString() + "</td></tr>");
            }

            if (item.BasicPortalPrice == null)
            {
                builder.Append("<tr><td><strong>Override Basic Portal Price: </strong></td><td>");
                builder.Append("Default</td></tr>");
            }
            else
            {
                builder.Append("<tr><td><strong>Override Basic Portal Price: </strong></td><td>");
                builder.Append(item.BasicPortalPrice.ToString() + "</td></tr>");
            }
            builder.Append("<tr><td><strong>Advanced Portal: </strong></td><td>");
            builder.Append(organization.IsAdvancedPortal.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Basic Portal: </strong></td><td>");
            builder.Append(organization.IsBasicPortal.ToString() + "</td></tr>");

            builder.Append("<tr><td><strong>Extra Storage Units: </strong></td><td>");
            builder.Append(organization.ExtraStorageUnits.ToString() + "</td></tr>");
            builder.Append("<tr><td><strong>Storage Used: </strong></td><td>");
            builder.Append(Organizations.GetStorageUsed(UserSession.LoginUser, _organizationID).ToString() + "MB</td></tr>");
            if (item.StoragePrice == null)
            {
                builder.Append("<tr><td><strong>Override Storage Price: </strong></td><td>");
                builder.Append("Default</td></tr>");
            }
            else
            {
                builder.Append("<tr><td><strong>Override Storage Price: </strong></td><td>");
                builder.Append(item.StoragePrice.ToString() + "</td></tr>");
            }

            builder.Append("<tr><td><strong>Extra Storage Allowed: </strong></td><td>");
            builder.Append(Organizations.GetExtraStorageAllowed(UserSession.LoginUser, _organizationID) + "MB</td></tr>");
            builder.Append("<tr><td><strong>Base Storage Allowed: </strong></td><td>");
            builder.Append(Organizations.GetBaseStorageAllowed(UserSession.LoginUser, _organizationID) + "MB</td></tr>");
            builder.Append("<tr><td><strong>Total Storage Allowed: </strong></td><td>");
            builder.Append(Organizations.GetTotalStorageAllowed(UserSession.LoginUser, _organizationID) + "MB</td></tr>");



            /*  if (item.NextInvoiceDate == null)
             * {
             *  builder.Append("<tr><td><strong>Next Invoice Date: </strong></td><td>");
             *  builder.Append("None</td></tr>");
             * }
             * else
             * {
             *  builder.Append("<tr><td><strong>Next Invoice Date: </strong></td><td>");
             *  builder.Append(item.NextInvoiceDate.ToString() + "</td></tr>");
             * }
             */


            builder.Append("<tr><td><strong>API Security Token: </strong></td><td>");
            builder.Append(organization.WebServiceID + "</td></tr>");
            if (organization.IsApiActive != null && organization.IsApiActive == true)
            {
                builder.Append("<tr><td><strong>API Active: </strong></td><td>True</td></tr>");
            }
            else
            {
                builder.Append("<tr><td><strong>API Active: </strong></td><td>False</td></tr>");
            }

            if (organization.IsApiEnabled)
            {
                builder.Append("<tr><td><strong>API Enabled: </strong></td><td>True</td></tr>");
            }
            else
            {
                builder.Append("<tr><td><strong>API Enabled: </strong></td><td>False</td></tr>");
            }

            string email = organization.SystemEmailID + "@teamsupport.com";
            builder.Append("<tr><td><strong>System Email: </strong></td><td>");
            builder.Append("<a href=\"mailto:" + email + "\">" + email + "</a>" + "</td></tr>");
            string portalLink = SystemSettings.GetPortalUrl() + "?OrganizationID=" + organization.OrganizationID.ToString();
            portalLink = @"<a href=""" + portalLink + @""" target=""PortalLink"" onclick=""window.open('" + portalLink + @"', 'PortalLink')"">" + portalLink + "</a>";
            builder.Append("<tr><td><strong>Portal Link: </strong></td><td>");
            builder.Append(portalLink + "</td></tr>");

            builder.Append("<tr><td><strong>Total Bill: </strong></td><td>");
            double total = 0;
            total = (organization.UserSeats - 3) * (item.UserPrice == null ? 25.0 : (double)item.UserPrice);
            if (total < 0)
            {
                total = 0;
            }
            total = total + (organization.PortalSeats * (item.PortalPrice == null ? 3.0 : (double)item.PortalPrice));
            total = total + (organization.ExtraStorageUnits * (item.StoragePrice == null ? 3.0 : (double)item.StoragePrice));

            builder.Append("$" + total.ToString("#0.00") + "</td></tr>");
        }

        LoadAddress();
        if (item.CreditCardID != null)
        {
            LoadCredit((int)item.CreditCardID);
        }

        litAccount.Text = builder.ToString();
    }