Ejemplo n.º 1
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);
    }
Ejemplo 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!");
    }
Ejemplo n.º 3
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);
    }
Ejemplo 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);
        }
    }
Ejemplo n.º 5
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);
    }
Ejemplo n.º 6
0
    protected void MoveOrShareProject(object sender, EventArgs e)
    {
        if (dd_recipient_user.Items.Count > 0 && dd_recipient_user.SelectedItem != null)
        {
            hf_project_id.Value = hf_project_id.Value.Replace(",", " ").Trim();
            String[] project_ids = hf_project_id.Value.Split(' ');

            String MovedOrShared = "moved";
            if (!dd_move_or_share.SelectedItem.Text.Contains("Move"))
            {
                MovedOrShared = "shared";
            }

            foreach (String project_id in project_ids)
            {
                String[] pn = new String[] { "@recipient_userid", "@project_id" };
                Object[] pv = new Object[] { dd_recipient_user.SelectedItem.Value, project_id };
                if (dd_move_or_share.SelectedItem.Text.Contains("Move"))
                {
                    String uqry = "UPDATE dbl_project SET UserID=@recipient_userid WHERE ProjectID=@project_id OR ProjectID IN (SELECT ProjectID FROM (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@project_id) as t)";
                    SQL.Update(uqry, pn, pv);

                    // Log
                    LeadsUtil.AddProjectHistoryEntry(project_id, null, LeadsUtil.GetProjectFullNameFromID(project_id), "Project moved to user " + dd_recipient_user.SelectedItem.Text);
                }
                else
                {
                    // Share parent
                    String iqry = "INSERT IGNORE INTO dbl_project_share (ProjectID, UserID) VALUES (@project_id, @recipient_userid)";
                    SQL.Insert(iqry, pn, pv);

                    // Log
                    LeadsUtil.AddProjectHistoryEntry(project_id, null, LeadsUtil.GetProjectFullNameFromID(project_id), "Project shared with user " + dd_recipient_user.SelectedItem.Text);

                    // Share buckets
                    String    qry        = "SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@project_id AND Active=1";
                    DataTable dt_buckets = SQL.SelectDataTable(qry, "@project_id", project_id);
                    for (int i = 0; i < dt_buckets.Rows.Count; i++)
                    {
                        String BucketID = dt_buckets.Rows[i]["ProjectID"].ToString();
                        SQL.Insert(iqry,
                                   new String[] { "@project_id", "@recipient_userid" },
                                   new Object[] { BucketID, dd_recipient_user.SelectedItem.Value });
                    }
                }
            }

            BindRecipientUsers();
            String plural = "Project";
            if (project_ids.Length > 1)
            {
                plural += "s";
            }

            Util.PageMessageSuccess(this, plural + " successfully " + MovedOrShared + "!<br/>You can now close this window.", plural + " Moved");

            if (hf_cca_action.Value == "1")
            {
                Util.SetRebindOnWindowClose(this, true);
                Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
            }
        }
    }
Ejemplo n.º 7
0
    protected void ModifyThisBucket(object sender, EventArgs e)
    {
        String mode = hf_mode.Value;

        String bucket_name = tb_bucket_name.Text.Trim();

        if (bucket_name == String.Empty)
        {
            Util.PageMessageAlertify(this, "Client List name must not be blank!", "Blank Name!");
        }
        else if (bucket_name.Length > 100)
        {
            Util.PageMessageAlertify(this, "Client List name must not be more than 100 characters!", "100 Character Limit");
        }
        else
        {
            String user_id = Util.GetUserId();

            String[] pn = new String[] { "@ProjectID", "@BucketID", "@UserID", "@Name" };
            Object[] pv = new Object[] { hf_project_id.Value, hf_project_id.Value, user_id, bucket_name };

            String action         = "Client List " + bucket_name + " added.";
            String log_project_id = hf_project_id.Value;
            if (mode == "new")
            {
                // First, determine sharing
                String    qry      = "SELECT ProjectID, UserID FROM dbl_project_share WHERE ProjectID=@ParentProjID";
                DataTable dt_share = SQL.SelectDataTable(qry, "@ParentProjID", hf_parent_project_id.Value);
                bool      IsShared = dt_share.Rows.Count > 0;
                if (IsShared)
                {
                    // set owner of this new bucket to the owner of the parent project
                    qry     = "SELECT UserID FROM dbl_project WHERE ProjectID=@ParentProjID";
                    user_id = SQL.SelectString(qry, "UserID", "@ParentProjID", hf_parent_project_id.Value);
                }

                String iqry = "INSERT INTO dbl_project (UserID, Name, IsBucket, IsModifiable, ParentProjectID) VALUES (@UserID, @Name, 1, 1, @ParentProjID);";
                hf_project_id.Value = SQL.Insert(iqry,
                                                 new String[] { "@UserID", "@Name", "@ParentProjID" },
                                                 new Object[] { user_id, bucket_name, hf_project_id.Value }).ToString();

                // Add this to share if necessary
                for (int i = 0; i < dt_share.Rows.Count; i++)
                {
                    String ShareUserId = dt_share.Rows[i]["UserID"].ToString();
                    iqry = "INSERT IGNORE INTO dbl_project_share (ProjectID, UserID) VALUES (@project_id, @recipient_userid)";
                    SQL.Insert(iqry,
                               new String[] { "@project_id", "@recipient_userid" },
                               new Object[] { hf_project_id.Value, ShareUserId });
                }
            }
            else if (mode == "edit")
            {
                // Update Bucket
                String OriginalName = SQL.SelectString("SELECT Name FROM dbl_project WHERE ProjectID=@BucketID", "Name", pn, pv);
                String uqry         = "UPDATE dbl_project SET Name=@Name, DateModified=CURRENT_TIMESTAMP WHERE ProjectID=@BucketID;";
                SQL.Update(uqry, pn, pv);

                action         = "Client List renamed from '" + OriginalName + "' to '" + bucket_name + "'";
                log_project_id = hf_project_id.Value;
            }

            // Log
            LeadsUtil.AddProjectHistoryEntry(hf_project_id.Value, null, bucket_name, action);

            Util.SetRebindOnWindowClose(this, true);
            Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
        }
    }
Ejemplo n.º 8
0
    protected void ModifyThisProject(object sender, EventArgs e)
    {
        String mode = hf_mode.Value;

        String project_name = tb_project_name.Text.Trim();

        if (project_name == String.Empty)
        {
            Util.PageMessageAlertify(this, "Project name must not be blank!", "Blank Name!");
        }
        else if (project_name.Length > 100)
        {
            Util.PageMessageAlertify(this, "Project name must not be more than 100 characters!", "100 Character Limit");
        }
        else
        {
            String user_id = Util.GetUserId();

            // Check to see if this is user's first list
            bool   first_project = false;
            String qry           = "SELECT ProjectID FROM dbl_project WHERE UserID=@UserID AND Active=1;";
            if (SQL.SelectDataTable(qry, "@UserID", user_id).Rows.Count == 0)
            {
                first_project = true;
            }

            String TargetTerritoryID = null;
            if (dd_target_territory.Items.Count > 0 && dd_target_territory.SelectedItem != null && dd_target_territory.SelectedItem.Text != String.Empty)
            {
                TargetTerritoryID = dd_target_territory.SelectedItem.Value;
            }
            String TargetIndustryID = null;
            if (dd_target_industry.Items.Count > 0 && dd_target_industry.SelectedItem != null && dd_target_industry.SelectedItem.Text != String.Empty)
            {
                TargetIndustryID = dd_target_industry.SelectedItem.Value;
            }

            String[] pn = new String[] { "@ProjectID", "@UserID", "@Name", "@TargetTerritoryID", "@TargetIndustryID", "@Description" };
            Object[] pv = new Object[] { hf_project_id.Value, user_id, project_name, TargetTerritoryID, TargetIndustryID, tb_project_description.Text.Trim() };

            String action = "Project added.";
            if (mode == "new")
            {
                String iqry = "INSERT INTO dbl_project (UserID, Name, TargetTerritoryID, TargetIndustryID, DateCreated, DateModified, Description) " +
                              "VALUES (@UserID, @Name, @TargetTerritoryID, @TargetIndustryID, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, @Description);";
                hf_project_id.Value = SQL.Insert(iqry, pn, pv).ToString();

                if (first_project)
                {
                    // Set this as user's 'last viewed' project
                    String nuqry = "UPDATE dbl_preferences SET LastViewedProjectID=@project_id WHERE UserID=@user_id";
                    SQL.Update(nuqry,
                               new String[] { "@project_id", "@user_id" },
                               new Object[] { hf_project_id.Value, user_id });
                }

                qry = "SELECT * FROM dbl_bucket_defaults";
                DataTable dt_buckets = SQL.SelectDataTable(qry, null, null);
                for (int i = 0; i < dt_buckets.Rows.Count; i++)
                {
                    String bucket_name = dt_buckets.Rows[i]["Name"].ToString();
                    iqry = "INSERT INTO dbl_project (UserID, Name, DateCreated, DateModified, IsBucket, IsModifiable, ParentProjectID) VALUES (@UserID, @Name, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 1, 0, @ParentProjID);";
                    SQL.Insert(iqry,
                               new String[] { "@UserID", "@Name", "@ParentProjID" },
                               new Object[] { user_id, bucket_name, hf_project_id.Value });
                }
            }
            else if (mode == "edit")
            {
                // Determine log text for update
                action = "Project updated ";
                String existing_project_name     = String.Empty;
                String existing_description      = String.Empty;
                String existing_target_territory = String.Empty;
                String existing_target_industry  = String.Empty;

                qry = "SELECT * FROM dbl_project WHERE ProjectID=@ProjectID";
                DataTable dt_project = SQL.SelectDataTable(qry, "@ProjectID", hf_project_id.Value);
                if (dt_project.Rows.Count > 0)
                {
                    existing_project_name     = dt_project.Rows[0]["Name"].ToString();
                    existing_description      = dt_project.Rows[0]["Description"].ToString();
                    existing_target_territory = dt_project.Rows[0]["TargetTerritoryID"].ToString();
                    existing_target_industry  = dt_project.Rows[0]["TargetIndustryID"].ToString();

                    if (existing_project_name != tb_project_name.Text)
                    {
                        action += "- Project Renamed ";
                    }
                    if (existing_description != tb_project_description.Text)
                    {
                        action += "- Description Updated ";
                    }
                    if (existing_target_territory != dd_target_territory.SelectedItem.Value)
                    {
                        action += "- Target Territory Updated ";
                    }
                    if (existing_target_industry != dd_target_industry.SelectedItem.Value)
                    {
                        action += "- Target Industry Updated ";
                    }
                }
                action = action.Trim() + ".";

                // Update Project
                String uqry = "UPDATE dbl_project SET Name=@Name, TargetTerritoryID=@TargetTerritoryID, TargetIndustryID=@TargetIndustryID, Description=@Description, " +
                              "DateModified=CURRENT_TIMESTAMP WHERE ProjectID=@ProjectID;";
                SQL.Update(uqry, pn, pv);

                // Update Project sharing
                if (tr_sharing_management.Visible)
                {
                    for (int i = 0; i < rtv_share_recipients.Nodes[0].Nodes.Count; i++)
                    {
                        RadTreeNode n               = rtv_share_recipients.Nodes[0].Nodes[i];
                        bool        Share           = n.Checked;
                        String      RecipientUserID = n.Value;

                        pn = new String[] { "@project_id", "@recipient_userid" };
                        pv = new Object[] { hf_parent_project_id.Value, RecipientUserID };
                        if (Share)
                        {
                            String iqry = "INSERT IGNORE INTO dbl_project_share (ProjectID, UserID) VALUES (@project_id, @recipient_userid)";
                            SQL.Insert(iqry, pn, pv);
                        }
                        else
                        {
                            String dqry = "DELETE FROM dbl_project_share WHERE ProjectID=@project_id AND UserID=@recipient_userid";
                            SQL.Delete(dqry, pn, pv);
                        }
                    }
                }
            }

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

            Util.SetRebindOnWindowClose(this, true);
            Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false);
        }
    }