Esempio n. 1
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");
        }
    }
Esempio n. 2
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!");
    }
Esempio n. 3
0
    protected void DeleteThisBucket(object sender, EventArgs e)
    {
        // If we're chosing to move any existing leads to another bucket..
        String action = "Client List " + LeadsUtil.GetProjectFullNameFromID(hf_project_id.Value) + " deactivated.";

        if (dd_del_buckets.SelectedItem.Value != "-1") // move leads
        {
            String new_bucket_id = dd_del_buckets.SelectedItem.Value;
            String uqry          = "UPDATE dbl_lead SET ProjectID=@NewBucketID WHERE ProjectID=@OldBucketID;";
            SQL.Update(uqry,
                       new String[] { "@NewBucketID", "@OldBucketID" },
                       new Object[] { new_bucket_id, hf_project_id.Value });

            action += " All remaining active Leads moved to the " + LeadsUtil.GetProjectFullNameFromID(new_bucket_id) + " Project.";
        }
        else // else de-active old leads
        {
            String uqry = "UPDATE dbl_lead SET Active=0, DateUpdated=CURRENT_TIMESTAMP WHERE Active=1 AND ProjectID=@BucketID;";
            SQL.Update(uqry, "@BucketID", hf_project_id.Value);

            action += " All remaining active Leads were marked inactive (removed).";
        }

        // Set bucket inactive
        String dqry = "UPDATE dbl_project SET Active=0, DateModified=CURRENT_TIMESTAMP WHERE ProjectID=@BucketID;";

        SQL.Delete(dqry, "@BucketID", hf_project_id.Value);

        // Assign a new project to view
        String prefs_uqry = "UPDATE dbl_preferences SET LastViewedProjectID=(SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@ProjID AND Name='Cold Leads' LIMIT 1) WHERE UserID=@UserID";

        SQL.Update(prefs_uqry, new String[] { "@ProjID", "@UserID" }, new Object[] { hf_parent_project_id.Value, Util.GetUserId() });

        // Log
        LeadsUtil.AddProjectHistoryEntry(hf_project_id.Value, null, tb_bucket_name.Text.Trim(), action.Trim());

        Util.SetRebindOnWindowClose(this, true);
        Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
    }
Esempio n. 4
0
    protected void MoveAllLeads(object sender, EventArgs e)
    {
        if (dd_move_buckets.Items.Count > 0)
        {
            // Move any existing Leads to another Project..
            String new_project_id = dd_move_buckets.SelectedItem.Value;
            String uqry           = "UPDATE dbl_lead SET ProjectID=@NewProjectID WHERE ProjectID=@OldProjectID OR ProjectID IN (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@OldProjectID)";
            SQL.Update(uqry,
                       new String[] { "@NewProjectID", "@OldProjectID" },
                       new Object[] { new_project_id, hf_project_id.Value });

            // Log
            LeadsUtil.AddProjectHistoryEntry(hf_project_id.Value, null, tb_bucket_name.Text.Trim(), "Leads moved to the " + LeadsUtil.GetProjectFullNameFromID(new_project_id) + " Client List.");

            Util.SetRebindOnWindowClose(this, true);
            Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
        }
    }
    protected void BindProject(object sender, EventArgs e)
    {
        String ProjectID = String.Empty;

        if (sender != null) // from grid
        {
            LinkButton lb_project = (LinkButton)sender;
            ProjectID = lb_project.CommandArgument;
        }
        else // from page index changing
        {
            ProjectID = hf_bound_project_id.Value;
        }

        String ActiveExpr = "dbl_lead.Active=1";

        if (cb_show_deactivated_projects.Checked)
        {
            ActiveExpr = "dbl_lead.Active=0";
        }

        String qry = "SELECT " +
                     "dbl_project.ProjectID, dbl_lead.LeadID, db_company.CompanyID, db_contact.ContactID, t3.ProjectName, " +
                     "dbl_lead.DateAdded, CompanyName, Country, FirstName, LastName, JobTitle, db_contact.Phone, Email, PersonalEmail " +
                     "FROM dbl_project " +
                     "LEFT JOIN db_userpreferences ON dbl_Project.UserID = db_userpreferences.userid " +
                     "LEFT JOIN dbl_lead ON dbl_project.ProjectID = dbl_lead.ProjectID " +
                     "LEFT JOIN db_contact ON dbl_lead.ContactID = db_contact.ContactID " +
                     "LEFT JOIN db_company ON db_contact.CompanyID = db_company.CompanyID " +
                     "LEFT JOIN (SELECT t1.ProjectID, CASE WHEN t2.Name IS NULL THEN t1.Name ELSE CONCAT(t2.Name,' - ', t1.Name) END as 'ProjectName' " +
                     "FROM (SELECT ProjectID, ParentProjectID, Name FROM dbl_project) as t1 " +
                     "LEFT JOIN (SELECT ProjectID, Name FROM dbl_project) as t2 ON t1.ParentProjectID = t2.ProjectID) as t3 ON dbl_Project.ProjectID = t3.ProjectID " +
                     "WHERE (dbl_project.ProjectID=@ProjectID OR ParentProjectID=@ProjectID)" +
                     "AND " + ActiveExpr;
        DataTable dt_leads = SQL.SelectDataTable(qry, "@ProjectID", ProjectID);

        rg_leads.DataSource = dt_leads;
        rg_leads.DataBind();

        lbl_leads_title.Text = "Showing " + dt_leads.Rows.Count + " active Leads for " + Server.HtmlEncode(dd_user.SelectedItem.Text.Replace(" (Disabled)", String.Empty)) + "'s " + Server.HtmlEncode(LeadsUtil.GetProjectFullNameFromID(ProjectID)) + " Project.";

        div_leads.Visible = true;

        hf_bound_project_id.Value = ProjectID;
    }