Пример #1
0
        public void AddSelectedContactsAsLeadsToProject(String project_id, String source)
        {
            ArrayList added_lead_ids = SelectedValidContactIDs;

            String username = Util.GetUserFullNameFromUserId(hf_user_id.Value);

            // Iterate -selected- and -valid- contacts in Contact Manager and add as Leads
            for (int i = 0; i < added_lead_ids.Count; i++)
            {
                String ctc_id          = (String)added_lead_ids[i];
                String contact_history = "Added at " + DateTime.Now + " (GMT) by " + username;

                String iqry    = "INSERT INTO dbl_lead (ProjectID, ContactID, Source, LatestNoteID) VALUES (@ProjectID, @ContactID, @Source, (SELECT MAX(NoteID) FROM db_contact_note WHERE ContactID=@ContactID));";
                long   lead_id = SQL.Insert(iqry,
                                            new String[] { "@ProjectID", "@ContactID", "@Source" },
                                            new Object[] { project_id, ctc_id, source });

                // Add lead flag to contact types
                iqry = "INSERT IGNORE INTO db_contactintype (ContactID, ContactTypeID) VALUES (@ctc_id, (SELECT ContactTypeID FROM db_contacttype WHERE SystemName='Lead' AND ContactType='Lead'));";
                SQL.Insert(iqry, "@ctc_id", ctc_id);

                // Log
                LeadsUtil.AddLeadHistoryEntry(lead_id.ToString(), "Adding Lead to the " + LeadsUtil.GetProjectFullNameFromID(project_id) + " Project.");
            }
        }
Пример #2
0
    protected void KillThisLead(object sender, EventArgs e)
    {
        if (dd_dont_contact_for.Items.Count > 0 && dd_dont_contact_reason.Items.Count > 0)
        {
            String action = "Lead killed";
            String dont_contact_for_expr = String.Empty;
            if (cb_dont_contact_for.Checked)
            {
                dont_contact_for_expr = ", dont_contact_until=DATE_ADD(NOW(), INTERVAL " + dd_dont_contact_for.SelectedItem.Value + " MONTH) ";
                action += ". Don't contact set for " + dd_dont_contact_for.SelectedItem.Text;
            }
            String dont_contact_reason = dd_dont_contact_reason.SelectedItem.Text;
            if (dd_dont_contact_reason.SelectedItem.Text == "Other" && tb_other_reason.Text.Trim() != String.Empty)
            {
                dont_contact_reason = tb_other_reason.Text;
            }

            action += ". Reason: " + dont_contact_reason + ".";

            String uqry = "UPDATE dbl_lead, db_contact SET dbl_lead.Active=0, DateUpdated=CURRENT_TIMESTAMP, dont_contact_reason=@dont_contact_reason," +
                          "dont_contact_added=CURRENT_TIMESTAMP, dont_contact_user_id=@user_id " + dont_contact_for_expr +
                          "WHERE dbl_lead.ContactID = db_contact.ctc_id AND LeadID=@LeadID";
            SQL.Update(uqry,
                       new String[] { "@LeadID", "@user_id", "@dont_contact_reason" },
                       new Object[] { hf_lead_id.Value, Util.GetUserId(), dont_contact_reason });

            // Log
            LeadsUtil.AddLeadHistoryEntry(hf_lead_id.Value, action);

            Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Util.SetRebindOnWindowClose(this, false);
            if (Request.QueryString["mode"] != null && !String.IsNullOrEmpty(Request.QueryString["mode"]))
            {
                hf_mode.Value = Request.QueryString["mode"];
                if (hf_mode.Value == "new" && Request.QueryString["proj_id"] != null && !String.IsNullOrEmpty(Request.QueryString["proj_id"]))
                {
                    hf_project_id.Value = Request.QueryString["proj_id"];
                }
                else if (hf_mode.Value == "edit" && Request.QueryString["bucket_id"] != null && !String.IsNullOrEmpty(Request.QueryString["bucket_id"]))
                {
                    hf_project_id.Value = Request.QueryString["bucket_id"];
                }

                hf_parent_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value);

                SetFormMode();
            }
            else
            {
                Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error");
            }
        }
    }
Пример #4
0
    protected void DeReactiveProjects(object sender, EventArgs e)
    {
        if (dd_user.Items.Count > 0 && dd_user.SelectedItem != null)
        {
            String UserID         = dd_user.SelectedItem.Value;
            int    NumReactivated = 0;
            bool   Reactivating   = btn_dereactivate_projects.Text.Contains("Reactivate");
            foreach (GridDataItem item in rg_user_projects.Items)
            {
                if (((CheckBox)item["Selected"].FindControl("cb_selected")).Checked)
                {
                    String ProjectID = item["ProjectID"].Text;
                    LeadsUtil.ReactivateOrDeactivateProject(ProjectID, UserID, Reactivating);
                    NumReactivated++;
                }
            }

            BindProjectList(null, null);

            String Action = "Reactivated";
            if (!Reactivating)
            {
                Action = "Deactivated";
            }

            if (NumReactivated == 0)
            {
                Util.PageMessageAlertify(this, "No Projects selected, select some using the checkboxes to the right of the Project list!", "No Projects Selected", ram);
            }
            else
            {
                Util.PageMessageSuccess(this, "Project(s) " + Action + "!", Action + "!");
            }
        }
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LeadsUtil.SetNoRebindOnWindowClose(this, true);
            if (Request.QueryString["lead_id"] != null && !String.IsNullOrEmpty(Request.QueryString["lead_id"]))
            {
                hf_lead_id.Value = Request.QueryString["lead_id"];

                String qry        = "SELECT Suspect FROM dbl_lead WHERE LeadID=@lead_id";
                bool   is_suspect = SQL.SelectString(qry, "Suspect", "@lead_id", hf_lead_id.Value) == "1";

                if (is_suspect) // make push to prospect
                {
                    btn_push_to.OnClientClick = "var rw = GetRadWindow(); var rwm = rw.get_windowManager(); rwm.open('/dashboard/leads/pushtoprospect.aspx?lead_id=" + Server.UrlEncode(hf_lead_id.Value) + "', 'rw_push_to_prospect'); rw.Close();";
                    btn_push_to.Text          = "Push to Prospect";
                }
                else // make push to suspect
                {
                    btn_push_to.OnClientClick = "var rw = GetRadWindow(); var rwm = rw.get_windowManager(); rwm.open('/dashboard/leads/pushtosuspect.aspx?lead_id=" + Server.UrlEncode(hf_lead_id.Value) + "', 'rw_push_to_suspect'); rw.Close();";
                    btn_push_to.Text          = "Push to Suspect";
                }

                BindTemplate();
            }
            else
            {
                Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error");
            }
        }
        else
        {
            LeadsUtil.SetNoRebindOnWindowClose(this, false); // assume any partial postback is an update of some kind (some exceptions)
        }
    }
Пример #6
0
    public static void BindBuckets(RadDropDownList dd_Projects, RadDropDownList dd_Buckets, String BucketID, bool SelectCurrentlyViewed, bool ShowOnlyInactiveBuckets = false, bool OnlyCountContactsWithEmail = false)
    {
        if (dd_Projects.Items.Count > 0 && dd_Projects.SelectedItem != null)
        {
            String OnlyWithEmailExpr = String.Empty;
            if (OnlyCountContactsWithEmail)
            {
                OnlyWithEmailExpr = " AND (Email IS NOT NULL OR PersonalEmail IS NOT NULL)";
            }

            String SumLeadsExpr = "SUM(CASE WHEN l.Active=1" + OnlyWithEmailExpr + " THEN 1 ELSE 0 END)";
            if (ShowOnlyInactiveBuckets)
            {
                SumLeadsExpr = "SUM(CASE WHEN l.Active=0" + OnlyWithEmailExpr + " THEN 1 ELSE 0 END)";
            }

            String qry = "SELECT p.ProjectID, CONCAT(Name,' (',IFNULL(" + SumLeadsExpr + ",0),CASE WHEN IFNULL(" + SumLeadsExpr + ",0)=1 THEN ' lead)' ELSE ' leads)' END) as 'Name' " +
                         "FROM dbl_project p LEFT JOIN dbl_lead l ON p.ProjectID = l.ProjectID LEFT JOIN db_contact c ON c.ContactID = l.ContactID " +
                         "WHERE p.Active=@active AND p.IsBucket=1 AND ParentProjectID=@project_id GROUP BY p.ProjectID ORDER BY Name";
            DataTable dt_buckets = SQL.SelectDataTable(qry,
                                                       new String[] { "@project_id", "@active" },
                                                       new Object[] { dd_Projects.SelectedItem.Value, !ShowOnlyInactiveBuckets });

            dd_Buckets.DataSource     = dt_buckets;
            dd_Buckets.DataTextField  = "Name";
            dd_Buckets.DataValueField = "ProjectID";
            dd_Buckets.DataBind();

            if (SelectCurrentlyViewed)
            {
                LeadsUtil.SelectCurrentlyViewedProject(dd_Buckets, BucketID);
            }
        }
    }
Пример #7
0
    private void BindDestinationProjects()
    {
        LeadsUtil.BindProjects(dd_move_projects, dd_move_buckets, hf_parent_project_id.Value, hf_project_id.Value, true);
        LeadsUtil.BindProjects(dd_del_projects, dd_del_buckets, hf_parent_project_id.Value, hf_project_id.Value, true, false);

        dd_del_buckets.Items.Insert(0, new Telerik.Web.UI.DropDownListItem("Delete all remaining Leads", "-1"));
    }
Пример #8
0
    protected void BindBuckets(object sender, Telerik.Web.UI.DropDownListEventArgs e)
    {
        LeadsUtil.BindBuckets(dd_move_projects, dd_move_buckets, hf_project_id.Value, true);
        LeadsUtil.BindBuckets(dd_del_projects, dd_del_buckets, hf_project_id.Value, false, true);

        dd_del_buckets.Items.Insert(0, new Telerik.Web.UI.DropDownListItem("Delete all remaining Leads", "-1"));
    }
Пример #9
0
    public static void ReactivateOrDeactivateProject(String ProjectID, String UserID, bool Activate, String CustomLogEntry = "")
    {
        String Active = "1";

        if (!Activate)
        {
            Active = "0";
        }

        String uqry = "UPDATE dbl_Project SET Active=@active, DateModified=CURRENT_TIMESTAMP WHERE UserID=@user_id AND (ProjectID=@project_id OR ParentProjectID=@project_id); " +
                      "UPDATE dbl_lead JOIN db_contact ON dbl_lead.ContactID = db_contact.ContactID " +
                      "SET dbl_lead.Active=@active " +
                      "WHERE (ProjectID=@project_id OR ProjectID IN (SELECT ProjectID FROM dbl_Project WHERE ParentProjectID=@project_id)) AND DontContactDateSet IS NULL;";

        SQL.Update(uqry,
                   new String[] { "@user_id", "@project_id", "@active" },
                   new Object[] { UserID, ProjectID, Active });

        String LogMsg = "Project Reactivated";

        if (CustomLogEntry != String.Empty)
        {
            LogMsg = CustomLogEntry;
        }

        // Log
        LeadsUtil.AddProjectHistoryEntry(ProjectID, null, GetProjectFullNameFromID(ProjectID), LogMsg);
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["lead_ids"] != null && !String.IsNullOrEmpty(Request.QueryString["lead_ids"]) &&
                Request.QueryString["project_id"] != null && !String.IsNullOrEmpty(Request.QueryString["project_id"]))
            {
                hf_lead_ids.Value = Request.QueryString["lead_ids"];

                if (Request.QueryString["project_id"].ToString() == "search") // when moving from search, rather than from another project
                {
                    hf_from_search.Value = "1";
                    lbl_title.Text       = "Add your selected contacts to a <b>Project</b> as <b>Leads</b>..";
                    btn_move_leads.Text  = "Add Selected Contacts to Project";
                }
                else
                {
                    hf_bucket_id.Value  = Request.QueryString["project_id"];
                    hf_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_bucket_id.Value);
                }

                LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_project_id.Value, hf_bucket_id.Value, true);
            }
            else
            {
                Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Util.SetRebindOnWindowClose(this, false);
            if (Request.QueryString["proj_id"] != null && !String.IsNullOrEmpty(Request.QueryString["proj_id"]))
            {
                hf_project_id.Value        = Request.QueryString["proj_id"];
                hf_parent_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value);
                hf_user_id.Value           = Util.GetUserId();

                // Delete any temp created companies for this user
                String temp_cpy_source = "db_templead_" + Util.GetUserId();
                String dqry            = "DELETE FROM db_contact WHERE CompanyID IN (SELECT CompanyID FROM db_company WHERE Source=@Source); DELETE FROM db_company WHERE Source=@Source;"; // remove all temp contacts/companies for this user
                SQL.Delete(dqry, "@Source", temp_cpy_source);

                // Bind destination projects
                LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_parent_project_id.Value, hf_project_id.Value, true);
            }
            else
            {
                Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error");
            }
        }
    }
Пример #12
0
    protected void EstimateEmailWithDataGeek(Contact c)
    {
        String UserID = Util.GetUserId();

        EstimatedEmail     = c.GetEstimatedEmailThroughDataGeek(UserID);
        IsDataGeekEstimate = true;

        if (EstimatedEmail.Contains("@"))
        {
            // Determine the ID of the entry to delete is the user cancels this estimation
            String qry            = "SELECT EmailHistoryID FROM db_contact_email_history WHERE EmailHistoryID=(SELECT MAX(EmailHistoryID) FROM db_contact_email_history WHERE ContactID=@ContactID AND DataGeekEstimate=1 AND Deleted=0 AND EstimatedByUserId=@EstimatedByUserId)";
            String EmailHistoryID = SQL.SelectString(qry, "EmailHistoryID", new String[] { "@ContactID", "@EstimatedByUserId" }, new Object[] { c.ContactID, UserID });
            if (!String.IsNullOrEmpty(EmailHistoryID))
            {
                String onok     = "var rb=$find('" + se.ClientID + "'); rb.click();";
                String oncancel = "var rb=$find('" + de.ClientID + "'); rb.click();";
                Util.PageMessagePrompt(this.Parent.Page, "Here's what DataGeek generated.. ", EstimatedEmail, onok, oncancel, "E-mail Address Generated");

                if (!String.IsNullOrEmpty(LeadID))
                {
                    LeadsUtil.AddLeadHistoryEntry(LeadID, "Estimated e-mail for this contact using DataGeek, generated e-mail: " + EstimatedEmail);
                }
            }
        }
        else
        {
            Util.PageMessageAlertify(this.Parent.Page, EstimatedEmail, "Estimation Results");
        }
    }
    protected void PerformSearch(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        RadComboBox rcb_search = (RadComboBox)sender;

        LeadsUtil.Search(rcb_search, e.Text, hf_user_id.Value, true,
                         "$get('" + hf_clicked_company_id.ClientID + "').value='[cpy_id]'; $get('" + btn_bind_company_and_contacts.ClientID + "').click();");
    }
Пример #14
0
    protected void BindBuckets(object sender, Telerik.Web.UI.DropDownListEventArgs e)
    {
        RadDropDownList dd_project = (RadDropDownList)sender;
        RadDropDownList dd_bucket  = null;

        if (dd_project.ID == "dd_del_move_project")
        {
            dd_bucket = dd_del_move_bucket;
            if (dd_del_move_project.SelectedItem.Text.Contains("Just delete"))
            {
                dd_bucket.Items.Clear();
                dd_bucket.Enabled = false;
                dd_bucket         = null;
            }
        }
        else
        {
            dd_bucket = dd_buckets;
        }

        if (dd_bucket != null)
        {
            dd_bucket.Enabled = true;
            LeadsUtil.BindBuckets(dd_project, dd_bucket, hf_project_id.Value, true);
        }

        Util.ResizeRadWindow(this);
    }
Пример #15
0
    private void BindTemplate()
    {
        String qry = "SELECT dbl_lead.*, db_company.*, db_contact.ctc_id " +
                     "FROM dbl_lead, db_contact, db_company " +
                     "WHERE dbl_lead.ContactID = db_contact.ctc_id " +
                     "AND db_contact.new_cpy_id = db_company.cpy_id " +
                     "AND dbl_lead.LeadID=@LeadID;";
        DataTable dt_lead = SQL.SelectDataTable(qry, "@LeadID", hf_lead_id.Value);

        if (dt_lead.Rows.Count > 0)
        {
            String cpy_id     = dt_lead.Rows[0]["cpy_id"].ToString();
            String ctc_id     = dt_lead.Rows[0]["ctc_id"].ToString();
            String project_id = dt_lead.Rows[0]["ProjectID"].ToString();

            hf_project_id.Value        = project_id;
            hf_parent_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value);
            hf_cpy_id.Value            = cpy_id;
            hf_ctc_id.Value            = ctc_id;

            // Bind Company and Contacts
            CompanyManager.BindCompany(cpy_id);
            ContactManager.BindContact(ctc_id);

            // Bind Notes and Next Action
            ContactNotesManager.LeadID = hf_lead_id.Value;
            ContactNotesManager.Bind(ctc_id);

            // Bind Other Contacts
            BindOtherContacts(null, null);

            // Bind destination projects
            LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_parent_project_id.Value, hf_project_id.Value, true);
        }
    }
Пример #16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LeadsUtil.BindProjects(dd_project, dd_buckets, LeadsUtil.GetProjectParentIDFromID(LeadsUtil.GetLastViewedProjectID()), null, false);
     }
 }
    protected void dd_project_SelectedIndexChanged(object sender, DropDownListEventArgs e)
    {
        RadDropDownList dd_project = (RadDropDownList)sender;
        String          TempLeadID = dd_project.ID.Replace("dd_project_", String.Empty);
        RadDropDownList dd_bucket  = (RadDropDownList)dd_project.Parent.FindControl("dd_bucket_" + TempLeadID);

        LeadsUtil.BindBuckets(dd_project, dd_bucket, String.Empty, true);
    }
    private void ConfigurePageForUser()
    {
        if (User.Identity.IsAuthenticated)
        {
            // Set user id
            hf_user_id.Value = Util.GetUserId();

            LeadsUtil.LoadPersistence(rpm);
        }
    }
Пример #19
0
 protected void BindBuckets(object sender, Telerik.Web.UI.DropDownListEventArgs e)
 {
     if (hf_from_search.Value == "1")
     {
         LeadsUtil.BindBuckets(dd_projects, dd_buckets, null, false);
     }
     else
     {
         LeadsUtil.BindBuckets(dd_projects, dd_buckets, hf_bucket_id.Value, true);
     }
 }
Пример #20
0
    private void BindCompanyInfo()
    {
        String    qry    = "SELECT cpy_id, ProjectID FROM dbl_lead, db_contact, db_company WHERE dbl_lead.ContactID=db_contact.ctc_id AND db_contact.new_cpy_id=db_company.cpy_id AND LeadID=@lead_id";
        DataTable dt_cpy = SQL.SelectDataTable(qry, "@lead_id", hf_lead_id.Value);

        if (dt_cpy.Rows.Count > 0)
        {
            hf_company_id.Value = dt_cpy.Rows[0]["cpy_id"].ToString();
            hf_project_id.Value = LeadsUtil.GetProjectParentIDFromID(dt_cpy.Rows[0]["ProjectID"].ToString());
            CompanyManager.BindCompany(hf_company_id.Value);
        }
    }
Пример #21
0
    public bool CheckAuthenticated(String Uri, String UserID)
    {
        bool authed = LeadsUtil.CheckGoogleAuthenticated(Uri, UserID);

        div_authenticate.Visible = !authed;

        if (authed)
        {
            lbl_authed.Text      = "You are authenticated with Google Mail API.";
            lbl_authed.ForeColor = System.Drawing.Color.Green;
        }
        return(authed);
    }
    protected void Authenticate()
    {
        var code = Request["code"];

        if (String.IsNullOrEmpty(code))
        {
            // See if we're authed
            AuthorizationCodeWebApp.AuthResult AuthResult = LeadsUtil.GetAuthResult(hf_uri.Value, hf_user_id.Value);
            if (AuthResult != null)
            {
                // User is authenticated..
                if (AuthResult.RedirectUri == null)
                {
                    lbl_title.Text = "You are now authenticated with Google Mail API.. you can close this window and return to DataGeek.";
                }
                // User is not authenticated, start the authentication process..
                else
                {
                    // Redirect the user to the authorization server.
                    Response.Redirect(AuthResult.RedirectUri);
                }
            }
            else
            {
                Util.PageMessageAlertify(this, "Error getting auth result from Google, please try reloading this page.");
            }
        }
        else // When returning with a code to complete in-process authentication
        {
            IAuthorizationCodeFlow flow = LeadsUtil.GetAuthCodeFlow();
            if (flow != null)
            {
                var token = flow.ExchangeCodeForTokenAsync(hf_user_id.Value, code, hf_uri.Value.Substring(0, hf_uri.Value.IndexOf("?")), CancellationToken.None).Result;

                // Extract the right state.
                try
                {
                    var oauthState = AuthWebUtility.ExtracRedirectFromState(flow.DataStore, hf_user_id.Value, Request["state"]).Result;
                    Response.Redirect(oauthState);
                }
                catch
                {
                    Response.Redirect("authwithgmapi.aspx");
                }
            }
            else
            {
                Util.PageMessageAlertify(this, "Error getting token from Google, please try reloading this page.");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LeadsUtil.SetNoRebindOnWindowClose(this, true);
            Security.BindPageValidatorExpressions(this);

            if (Request.QueryString["lead_id"] != null && !String.IsNullOrEmpty(Request.QueryString["lead_id"]))
            {
                hf_lead_id.Value = Request.QueryString["lead_id"];
                String qry = "SELECT team_name, team_id, db_userpreferences.userid, db_userpreferences.office, ctc_id, db_company.cpy_id " +
                             "FROM dbl_lead, dbl_project, db_userpreferences, db_ccateams, db_contact, db_company " +
                             "WHERE dbl_lead.ProjectID = dbl_project.ProjectID " +
                             "AND dbl_project.UserID = db_userpreferences.userid " +
                             "AND db_userpreferences.ccaTeam = db_ccateams.team_id " +
                             "AND dbl_lead.ContactID = db_contact.ctc_id " +
                             "AND db_contact.new_cpy_id = db_company.cpy_id " +
                             "AND LeadID=@lead_id";
                DataTable dt_user_info = SQL.SelectDataTable(qry, "@lead_id", hf_lead_id.Value);
                if (dt_user_info.Rows.Count > 0)
                {
                    hf_user_id.Value    = dt_user_info.Rows[0]["userid"].ToString();
                    hf_team_id.Value    = dt_user_info.Rows[0]["team_id"].ToString();
                    hf_office.Value     = dt_user_info.Rows[0]["office"].ToString();
                    hf_team_name.Value  = dt_user_info.Rows[0]["team_name"].ToString();
                    hf_company_id.Value = dt_user_info.Rows[0]["cpy_id"].ToString();
                    hf_contact_id.Value = dt_user_info.Rows[0]["ctc_id"].ToString();

                    String[] forced_selected = new String[] { hf_contact_id.Value };

                    CompanyManager.BindCompany(hf_company_id.Value);
                    ContactManager.BindContacts(hf_company_id.Value, forced_selected); // for multiple
                    //ContactManager.BindContact(hf_contact_id.Value, true);

                    // Bind Destination Prospect teams
                    BindDestinationTeams();

                    if (CompanyManager.Turnover == String.Empty)
                    {
                        Util.PageMessageAlertify(this, "Company turnover is not specified and is required to push this Lead to Prospect.<br/><br/>Click the company edit pencil and specify a turnover value. ", "Turnover Required");
                    }
                }

                BindRepDropDown();
            }
            else
            {
                Util.PageMessageAlertify(this, "There was an error getting the team information. Please close this window and retry.", "Error");
            }
        }
    }
Пример #24
0
    protected void MoveSelectedLeads(object sender, EventArgs e)
    {
        if (dd_buckets.Items.Count > 0)
        {
            String new_project_id = dd_buckets.SelectedItem.Value;
            hf_lead_ids.Value = hf_lead_ids.Value.Replace(",", " ").Trim();
            String[] ctc_ids     = hf_lead_ids.Value.Split(' ');
            String   ProjectName = LeadsUtil.GetProjectFullNameFromID(new_project_id);
            Util.SetRebindOnWindowClose(udp_move, true);
            String UserID = Util.GetUserId();

            if (hf_from_search.Value == "1")
            {
                String iqry = "INSERT INTO dbl_lead (ProjectID, ContactID, Source) VALUES (@ProjectID, @ContactID, 'RSA');";
                foreach (String ctc_id in ctc_ids)
                {
                    String lead_id = SQL.Insert(iqry,
                                                new String[] { "@ProjectID", "@ContactID" },
                                                new Object[] { new_project_id, ctc_id }).ToString();

                    // Log
                    LeadsUtil.AddLeadHistoryEntry(lead_id, "Lead added to the " + ProjectName + " Project.");
                }
            }
            else
            {
                String uqry = "UPDATE dbl_lead SET ProjectID=@NewProjectID WHERE LeadID=@LeadID;";
                String qry  = "SELECT LeadID FROM dbl_lead WHERE LeadID=@LeadID AND (ProjectID IN (SELECT ProjectID FROM dbl_project WHERE UserID=@UserID) OR ProjectID IN (SELECT ProjectID FROM dbl_project_share WHERE UserID=@UserID))";
                foreach (String lead_id in ctc_ids)
                {
                    // Verify Lead exists and ownership
                    if (SQL.SelectDataTable(qry, new String[] { "@LeadID", "@UserID" }, new Object[] { lead_id, UserID }).Rows.Count > 0)
                    {
                        SQL.Update(uqry,
                                   new String[] { "@NewProjectID", "@LeadID" },
                                   new Object[] { new_project_id, lead_id });

                        // Log
                        LeadsUtil.AddLeadHistoryEntry(lead_id, "Lead moved to the " + ProjectName + " Project.");
                    }
                }
            }

            Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
        }
        else
        {
            Util.PageMessageAlertify(this, "You have no other Projects to move your Leads to.\\n\\nPlease close this window and add another Project first.", "Retry");
        }
    }
Пример #25
0
    protected void RestoreProjectOrClientList(object sender, EventArgs e)
    {
        bool IsClientList = false;
        String ProjectID = String.Empty;
        if (dd_restore_choice.SelectedItem.Value == "P" && dd_project.Items.Count > 0 && dd_project.SelectedItem != null && !String.IsNullOrEmpty(dd_project.SelectedItem.Value))
            ProjectID = dd_project.SelectedItem.Value;
        else if(dd_restore_choice.SelectedItem.Value == "CL" && dd_client_list.Items.Count > 0 && dd_client_list.SelectedItem != null && !String.IsNullOrEmpty(dd_client_list.SelectedItem.Value))
        {
            ProjectID = dd_client_list.SelectedItem.Value;
            IsClientList=true;
        }

        if (ProjectID != String.Empty)
        {

            String WithinExpr = String.Empty;
            int Hours = 0;
            if (Int32.TryParse(dd_leads_killed_within.SelectedItem.Value, out Hours))
                WithinExpr = "AND DateUpdated BETWEEN DATE_ADD(NOW(), INTERVAL -" + Hours + " HOUR) AND NOW();";
            else
            {
                switch (dd_leads_killed_within.SelectedItem.Value)
                {
                    case "today": WithinExpr = "AND DATE(DateUpdated) = DATE(NOW());"; break;
                    case "week": WithinExpr = "AND YEAR(DateUpdated) = YEAR(NOW()) AND MONTH(DateUpdated) = MONTH(NOW()) AND WEEK(DateUpdated) = WEEK(NOW());"; break;
                    case "month": WithinExpr = "AND YEAR(DateUpdated) = YEAR(NOW()) AND MONTH(DateUpdated) = MONTH(NOW());"; break;
                    case "all": WithinExpr = String.Empty; break;
                }
            }
                
            String uqry =
            "UPDATE dbl_project SET Active=1, DateModified=CURRENT_TIMESTAMP WHERE ProjectID=@ProjectID OR ProjectID IN (SELECT ProjectID FROM (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@ProjectID) as t); " +
            "UPDATE dbl_lead SET Active=1, DateUpdated=CURRENT_TIMESTAMP WHERE (ProjectID=@ProjectID OR ProjectID IN " +
            "(SELECT ProjectID FROM (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@ProjectID) as t)) " + WithinExpr;
            SQL.Update(uqry, "@ProjectID", ProjectID);

            String Type = "Project";
            String Action = " reactivated. Leads killed within " + dd_leads_killed_within.SelectedItem.Text.ToLower() + " restored.";
            if(IsClientList)
                Type = "Client List";

            LeadsUtil.AddProjectHistoryEntry(ProjectID, null, LeadsUtil.GetProjectFullNameFromID(ProjectID), Type + Action);

            Util.SetRebindOnWindowClose(this, true);
            Util.PageMessageAlertify(this, Type + " restored!<br/><br/>Close this window to refresh your Project list.", "Restored!");
        }
        else
            Util.PageMessageAlertify(this, "Nothing to restore!", "Select something first!");
    }
Пример #26
0
    protected void DeactivateProject(object sender, EventArgs e)
    {
        if ((dd_del_move_bucket.Items.Count > 0 && dd_del_move_bucket.SelectedItem != null && dd_del_move_bucket.SelectedItem.Value != String.Empty) || dd_del_move_project.SelectedItem.Value == "-1")
        {
            if (User.Identity.IsAuthenticated)
            {
                // If we're chosing to move any existing leads to another project..
                String ParentProjectID = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value);
                if (dd_del_move_project.SelectedItem.Value != "-1") // move leads
                {
                    String new_project_id = dd_del_move_bucket.SelectedItem.Value;

                    String[] pn = new String[] { "@NewProjectID", "@OldProjectID", "@OldParentProjectID" };
                    Object[] pv = new Object[] { new_project_id, hf_project_id.Value, ParentProjectID };

                    String uqry = "UPDATE dbl_lead SET ProjectID=@NewProjectID WHERE (ProjectID=@OldProjectID OR ProjectID=@OldParentProjectID) OR ProjectID IN (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@OldParentProjectID)";
                    SQL.Update(uqry, pn, pv);
                }
                else // else de-activate old leads
                {
                    String uqry = "UPDATE dbl_lead SET Active=0, DateUpdated=CURRENT_TIMESTAMP WHERE Active=1 AND ProjectID=@ProjectID OR ProjectID IN (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@ProjectID)";
                    SQL.Update(uqry, "@ProjectID", ParentProjectID);
                }

                String action = "Project deactivated";
                if (dd_del_move_project.Items.Count > 0)
                {
                    if (dd_del_move_project.SelectedIndex == 0)
                    {
                        action += ", all remaining active Leads were marked inactive (removed).";
                    }
                    else
                    {
                        action += ", all remaining active Leads were moved to the " + dd_del_move_project.SelectedItem.Text + " Project.";
                    }
                }

                // Deactivate and log
                LeadsUtil.ReactivateOrDeactivateProject(hf_project_id.Value, hf_user_id.Value, false, action);
            }

            Util.SetRebindOnWindowClose(this, true);
            Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
        }
        else
        {
            Util.PageMessageAlertify(this, "No Client List selected!", "Oops");
        }
    }
    // Google API
    protected bool CheckAuthenticated()
    {
        bool authed = LeadsUtil.CheckGoogleAuthenticated(hf_uri.Value, hf_user_id.Value);

        if (!authed)
        {
            div_authenticate.Visible = true;
            lbl_authed.Text          = "You are not authenticated with Google Mail API..";
            lbl_authed.ForeColor     = System.Drawing.Color.Red;
            //Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "var w=window.open('authwithgmapi.aspx','_newtab'); "+
            //"if(!w || w.closed || typeof w.closed=='undefined') { Alertify(\"You're not authenticated with Google yet.<br/><br/>Allow pop-ups at the top-right of your browser's address bar (see instructions in red) then close this window and re-load it, then you will be able to allow your Gmail account to talk to DataGeek.\", 'Need to authenticate..'); $get('" + div_blocked_popups.ClientID + "').style.display='block'; }", true);
        }

        return(authed);
    }
    protected void SaveColumnSelection(object sender, EventArgs e)
    {
        String user_id = Util.GetUserId();
        String dqry    = "DELETE FROM dbl_user_columns WHERE UserID=@user_id";

        SQL.Delete(dqry, "@user_id", user_id);

        // Add selected company columns
        String iqry = "INSERT INTO dbl_user_columns (UserID, ColumnID) VALUES (@user_id, @column_id)";

        for (int i = 0; i < rtv_cpy.Nodes[0].Nodes.Count; i++)
        {
            RadTreeNode n = rtv_cpy.Nodes[0].Nodes[i];
            if (n.Checked)
            {
                String column_id = n.Value;
                SQL.Insert(iqry, new String[] { "@user_id", "@column_id" }, new Object[] { user_id, column_id });
            }
        }

        // Add selected contact columns
        for (int i = 0; i < rtv_ctc.Nodes[0].Nodes.Count; i++)
        {
            RadTreeNode n = rtv_ctc.Nodes[0].Nodes[i];
            if (n.Checked)
            {
                String column_id = n.Value;
                SQL.Insert(iqry, new String[] { "@user_id", "@column_id" }, new Object[] { user_id, column_id });
            }
        }

        // Add selected lead columns
        for (int i = 0; i < rtv_lead.Nodes[0].Nodes.Count; i++)
        {
            RadTreeNode n = rtv_lead.Nodes[0].Nodes[i];
            if (n.Checked)
            {
                String column_id = n.Value;
                SQL.Insert(iqry, new String[] { "@user_id", "@column_id" }, new Object[] { user_id, column_id });
            }
        }

        // Log
        LeadsUtil.AddLogEntry("Visible columns updated.");

        Util.SetRebindOnWindowClose(this, true);
        Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
    }
Пример #29
0
    protected void RemoveSharedProject(object sender, EventArgs e)
    {
        String dqry = "DELETE FROM dbl_project_share WHERE ProjectID=@ProjectID AND UserID=@UserID";

        SQL.Delete(dqry,
                   new String[] { "@ProjectID", "@UserID" },
                   new Object[] { hf_parent_project_id.Value, Util.GetUserId() });

        // Log
        String action = "Shared Project removed from Project list.";

        LeadsUtil.AddProjectHistoryEntry(hf_project_id.Value, null, tb_project_name.Text.Trim(), action);

        Util.SetRebindOnWindowClose(this, true);
        Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
    }
Пример #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LeadsUtil.SetNoRebindOnWindowClose(this, true);
            if (Request.QueryString["lead_id"] != null && !String.IsNullOrEmpty(Request.QueryString["lead_id"]))
            {
                hf_lead_id.Value = Request.QueryString["lead_id"];

                BindCompanyInfo();
            }
            else
            {
                Util.PageMessageAlertify(this, "There was an error getting the information. Please close this window and retry.", "Error");
            }
        }
    }