public ActionResult CreateAuditUniverse(Activity org, [Bind(Include = "ActivityID,ActivityParentID,Name,Description,Tahun,DepartementID,Status,Status_Active")] Activity activity, string submit)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                string user     = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    activity.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    activity.Status = HelperController.GetStatusSendback(db, "Audit Universe", activity.Status);
                }
                else if (submit == "Approve")
                {
                    activity.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    activity.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    activity.Status = "Pending for Approve by" + user;
                    string          baseUrl    = Request.Url.GetLeftPart(UriPartial.Authority);
                    List <string>   CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
                    List <Employee> CIAEmpList = new List <Employee>();
                    if (CIAUserIds.Count() > 0)
                    {
                        var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList();
                        foreach (var CIAUser in CIAUsers)
                        {
                            Employee emp = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault();

                            string emailContent = "Dear {0}, <BR/><BR/>Audit Universe : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Audit Universe\">link</a> to show the Audit Universe.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                            string url          = baseUrl + "/AuditUniverses/Details?ActivityID=" + org.ActivityID;
                            emailTransact.SentEmailApproval(emp.Email, emp.Name, org.Name, emailContent, url);
                        }
                    }
                }
                db.Activities.Add(activity);
                db.SaveChanges();
                Activity ac = new Activity();
                auditTransact.CreateAuditTrail("Create", activity.ActivityID, "AuditUniverse", ac, activity, username);
                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "au";
                rrm.Description = page + activity.ActivityID;
                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();
                TempData["message"] = "Audit Universe successfully created!";
                return(RedirectToAction("Index"));
            }

            return(View(activity));
        }
Пример #2
0
 public ActionResult Update(string submit, [Bind(Include = "AnnualPlanningID,Date_Start,Date_End,Status,Approval_Status,Tahun,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] AnnualPlanning annualPlanning, string member, EngagementActivity engagementActivity)
 {
     if (ModelState.IsValid)
     {
         string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
         if (submit == "Save")
         {
             annualPlanning.Approval_Status = "Draft";
         }
         else if (submit == "Send Back")
         {
             annualPlanning.Approval_Status = HelperController.GetStatusSendback(db, "Annual Planning", annualPlanning.Approval_Status);
         }
         else if (submit == "Approve")
         {
             annualPlanning.Approval_Status = "Approve";
         }
         else if (submit == "Submit For Review By" + user)
         {
             annualPlanning.Approval_Status = "Pending for Review by" + user;
         }
         else if (submit == "Submit For Approve By" + user)
         {
             annualPlanning.Approval_Status = "Pending for Approve by" + user;
             //send email to approve user
             string          activname = db.Activities.Where(p => p.ActivityID.Equals(annualPlanning.ActivityID)).Select(p => p.Name).FirstOrDefault();
             string          baseUrl   = Request.Url.GetLeftPart(UriPartial.Authority);
             List <string>   UserIds   = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
             List <Employee> EmpList   = new List <Employee>();
             if (UserIds.Count() > 0)
             {
                 var users = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (UserIds.Contains(p.Id))).ToList();
                 foreach (var userr in users)
                 {
                     Employee emp = db.Employees.Where(p => p.Email.Equals(userr.Email)).FirstOrDefault();
                     if (emp != null)
                     {
                         string emailContent = "Dear {0}, <BR/><BR/>There is a Annual Planning that need your approval. Please click on this <a href=\"{2}\" title=\"Annual Planning\">link</a> to show the Annual Planning.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                         string url          = baseUrl + "/AnnualPlannings/Details/" + annualPlanning.AnnualPlanningID;
                         emailTransact.SentEmailApproval(emp.Email, emp.Name, activname, emailContent, url);
                     }
                 }
             }
         }
         db.Entry(annualPlanning).State = EntityState.Modified;
         string username = User.Identity.Name;
         db.Configuration.ProxyCreationEnabled = false;
         AnnualPlanning oldData = db.AnnualPlannings.AsNoTracking().Where(p => p.AnnualPlanningID.Equals(annualPlanning.AnnualPlanningID)).FirstOrDefault();
         auditTransact.CreateAuditTrail("Update", annualPlanning.AnnualPlanningID, "AnnualPlanning", oldData, annualPlanning, username);
         db.SaveChanges();
         TempData["message"] = "Annual Planning successfully updated!";
         return(RedirectToAction("Index"));
     }
     ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", annualPlanning.ActivityID);
     return(View(annualPlanning));
 }
        public ActionResult Edit([Bind(Include = "ConsultingDraftAgreementID,NoRequest,NoSurat,RequesterID,Date_Start,ActivityStr,Tujuan,RuangLingkup,Peran,Status")] ConsultingDraftAgreement consultingDraftAgreement, string submit)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    consultingDraftAgreement.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    consultingDraftAgreement.Status = HelperController.GetStatusSendback(db, "Consulting Draft Agreement", consultingDraftAgreement.Status);
                }
                else if (submit == "Approve")
                {
                    consultingDraftAgreement.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    consultingDraftAgreement.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    consultingDraftAgreement.Status = "Pending for Approve by" + user;
                    string          baseUrl    = Request.Url.GetLeftPart(UriPartial.Authority);
                    List <string>   CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
                    List <Employee> CIAEmpList = new List <Employee>();
                    if (CIAUserIds.Count() > 0)
                    {
                        var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList();
                        foreach (var CIAUser in CIAUsers)
                        {
                            Employee empl = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault();

                            string emailContent = "Dear {0}, <BR/><BR/>Consulting Draft Agreement : {1} need your approval. Please click on this <a href=\"{2}\" title=\"CDA\">link</a> to show the Consulting Draft Agreement.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                            string urlRequest   = baseUrl + "/ConsultingDraftAgreements/Details/" + consultingDraftAgreement.ConsultingDraftAgreementID;
                            emailTransact.SentEmailApproval(empl.Email, empl.Name, consultingDraftAgreement.NoSurat, emailContent, urlRequest);
                        }
                    }
                }
                ConsultingDraftAgreement oldData = db.ConsultingDraftAgreements.AsNoTracking().Where(p => p.ConsultingDraftAgreementID.Equals(consultingDraftAgreement.ConsultingDraftAgreementID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", consultingDraftAgreement.ConsultingDraftAgreementID, "Consulting Draft Agreement", oldData, consultingDraftAgreement, username);
                db.Entry(consultingDraftAgreement).State = EntityState.Modified;
                db.SaveChanges();
                TempData["message"] = "Draft Agreement successfully updated!";
                return(RedirectToAction("Index"));
            }
            //ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", consultingDraftAgreement.ActivityID);
            return(View(consultingDraftAgreement));
        }
Пример #4
0
        public static string GetStatusSendback(ePatriaDefault db, string menuName, string OldStatus)
        {
            int idmenu     = db.Permissions.Where(d => d.PermissionName == menuName).Select(d => d.permissionID).FirstOrDefault();
            var iscreateId = db.PermissionRoles.Where(d => d.permissionID == idmenu && d.IsCreate == true).Select(d => d.roleID).FirstOrDefault();
            var issubmit1  = db.PermissionRoles.Where(d => d.permissionID == idmenu && d.IsSubmit1 == true).Select(d => d.roleID).FirstOrDefault();
            var issubmit2  = db.PermissionRoles.Where(d => d.permissionID == idmenu && d.IsSubmit2 == true).Select(d => d.roleID).FirstOrDefault();
            var isapprove  = db.PermissionRoles.Where(d => d.permissionID == idmenu && d.IsApprove == true).Select(d => d.roleID).FirstOrDefault();

            if (OldStatus != null && OldStatus != "")
            {
                if (OldStatus.Contains("Approve")) // approve
                {
                    //jika statusnya berkaitan approve
                    if (issubmit2 != null && issubmit2 != "")
                    {
                        return("Pending for Review by " + HelperController.getRoleName(issubmit2));
                    }
                    else if (issubmit1 != null && issubmit1 != "")
                    {
                        return("Pending for Review by " + HelperController.getRoleName(issubmit1));
                    }
                    else
                    {
                        //annualPlanning.Approval_Status = "Pending for Review by";
                        return("Draft");
                    }
                }
                else // submit 2
                {
                    if (issubmit1 != null && issubmit1 != "" && issubmit1 != iscreateId)
                    {
                        return("Pending for Review by " + HelperController.getRoleName(issubmit1));
                    }
                    else if (issubmit2 != null && issubmit2 != "" && issubmit2 != iscreateId)
                    {
                        return("Pending for Review by " + HelperController.getRoleName(issubmit2));
                    }
                    else if (isapprove != null && isapprove != "" && isapprove != iscreateId)
                    {
                        return("Pending for Approve by " + HelperController.getRoleName(isapprove));
                    }
                    else
                    {
                        return("Draft");
                    }
                }
            }
            return("Draft");
        }
        public ActionResult Create(string nomerapm, string membernull, string enggname, EngagementActivity engga, AuditPlanningMemorandum audit, [Bind(Include = "AuditPlanningMemorandumID,NomerAPM,PreliminaryID,Date_Start,Date_End,Status,ActivityID,TujuanAudit,RuangLingkupAudit,MetodologiAudit,DataDanDokumen,AttachmentMasterID,EntryMeetingDateStart,EntryMeetingDateEnd,WalktroughDateStart,WalktroughDateEnd,FieldWorkDateStart,FieldWorkDateEnd,ExitMeetingDateStart,ExitMeetingDateEnd,LHADateStart,LHADateEnd,PICID,SupervisorID,TeamLeaderID,MemberID,ReviewMasterID,Kesimpulan,ActualEngagement")] AuditPlanningMemorandum auditPlanningMemorandum, IEnumerable <HttpPostedFileBase> files, string submit, string[] members, string supervisor, string pic, string leader, string nomer, string activid)
        {
            if (ModelState.IsValid)
            {
                HttpServerUtilityBase server = Server;
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    auditPlanningMemorandum.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    HelperController.GetStatusSendback(db, "Audit Planning Memorandum", auditPlanningMemorandum.Status);
                }
                else if (submit == "Approve")
                {
                    auditPlanningMemorandum.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    auditPlanningMemorandum.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    auditPlanningMemorandum.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = auditPlanningMemorandum.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = auditPlanningMemorandum.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = auditPlanningMemorandum.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = auditPlanningMemorandum.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                }

                foreach (var mem in members)
                {
                    auditPlanningMemorandum.MemberID += mem + ";";
                }

                IQueryable <Preliminary> prel = db.Preliminaries.Where(p => p.NomorPreliminarySurvey.Equals(nomer));
                int preID = 0;
                if (prel.Count() > 0 || prel != null)
                {
                    preID = prel.Select(p => p.PreliminaryID).FirstOrDefault();
                }
                auditPlanningMemorandum.PreliminaryID = preID;
                auditPlanningMemorandum.SupervisorID  = supervisor;
                auditPlanningMemorandum.TeamLeaderID  = leader;
                auditPlanningMemorandum.PICID         = pic;

                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid));
                int actid = 0;
                if (act.Count() > 0 || act != null)
                {
                    actid = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                auditPlanningMemorandum.ActivityID = actid;
                auditPlanningMemorandum.NomerAPM   = nomerapm;
                db.AuditPlanningMemorandums.Add(auditPlanningMemorandum);
                db.SaveChanges();
                int i = 0;
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        i = i + 1;
                        bool addFile = filesTransact.addFile(auditPlanningMemorandum.NomerAPM.Replace("/", ""), i, file, server);
                    }
                }
                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "apm";
                rrm.Description = page + auditPlanningMemorandum.AuditPlanningMemorandumID;
                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();
                string username            = User.Identity.Name;
                AuditPlanningMemorandum au = new AuditPlanningMemorandum();
                auditTransact.CreateAuditTrail("Create", auditPlanningMemorandum.AuditPlanningMemorandumID, "AuditPlanningMemorandum", au, auditPlanningMemorandum, username);

                TempData["message"] = "Audit Planning Memorandum successfully created!";
                return(RedirectToAction("Index"));
            }
            return(View(auditPlanningMemorandum));
        }
        public ActionResult UpdateStatus(int id, string submit)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                context.Configuration.ProxyCreationEnabled = false;
                var    letter = context.ConsultingLetterOfCommands.Find(id);
                string user   = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letter.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letter.Status = HelperController.GetStatusSendback(context, "Consulting Surat Perintah", letter.Status);
                }
                else if (submit == "Approve")
                {
                    letter.Status = "Approve";
                    ConsultingFieldWork cFw = new ConsultingFieldWork();
                    cFw.ConsultingSuratPerintahID = id;
                    cFw.Status = "Draft";
                    context.ConsultingFieldWork.Add(cFw);
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letter.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letter.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letter.PicID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailCSP(userToSentEmail, letter);
                        }
                        else
                        {
                            sentEmailCSP(letter, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letter.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailCSP(userToSentEmail, letter);
                        }
                        else
                        {
                            sentEmailCSP(letter, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letter.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailCSP(userToSentEmail, letter);
                        }
                        else
                        {
                            sentEmailCSP(letter, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letter.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailCSP(userToSentEmail, letter);
                        }
                        else
                        {
                            sentEmailCSP(letter, user.Trim());
                        }
                    }
                }

                ConsultingLetterOfCommand oldData = context.ConsultingLetterOfCommands.AsNoTracking().Where(p => p.ConsultingSuratPerintahID.Equals(letter.ConsultingSuratPerintahID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", letter.ConsultingSuratPerintahID, "Consulting Letter Of Command", oldData, letter, username);
                context.Entry(letter).State = EntityState.Modified;
                context.SaveChanges();

                TempData["message"] = "Consulting Letter Of Command successfully updated!";
                return(RedirectToAction("Index"));
            }
            TempData["message"] = "Consulting Letter Of Command successfully updated!";
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "ConsultingSuratPerintahID,NomorSP,ConsultingRequestID,EngagementName,EngagementID,StartDate,EndDate,PicID,SupervisorID,TeamLeaderID,Menimbang,Penutup,MemberID,Remarks")] ConsultingLetterOfCommand consultingletterofcommand,
                                   EngagementActivity engagementActivity, string ActivityName, string submit,
                                   string[] member, string ConsultingRequest, ConsultingLetterOfCommandDetailDasar Ldasar,
                                   ConsultingLetterOfCommandDetailTembusan Ltembusan, ConsultingLetterOfCommandDetailUntuk Luntuk,
                                   string[] dasar, string[] tembusan, string[] untuk)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                IQueryable <ConsultingRequest> cr = context.ConsultingRequests.Where(p => p.NoRequest.Equals(ConsultingRequest));
                int ConsulId = 0;
                if (cr.Count() > 0 || cr != null)
                {
                    ConsulId = cr.Select(p => p.ConsultingRequestID).FirstOrDefault();
                }
                consultingletterofcommand.ConsultingRequestID = ConsulId;
                foreach (var mb in member)
                {
                    consultingletterofcommand.MemberID += mb + ";";
                }
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    consultingletterofcommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    consultingletterofcommand.Status = HelperController.GetStatusSendback(context, "Consulting Surat Perintah", consultingletterofcommand.Status);
                }
                else if (submit == "Approve")
                {
                    consultingletterofcommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    consultingletterofcommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    consultingletterofcommand.Status = "Pending for Approve by" + user;
                }

                context.ConsultingLetterOfCommands.Add(consultingletterofcommand);

                //Engagement Activity

                //IQueryable<Activity> act = context.Activities.Where(p => p.Name.Equals(ActivityName));
                //int ActivityID = 0;
                //if (act.Count() > 0 || act != null)
                //    ActivityID = act.Select(p => p.ActivityID).FirstOrDefault();
                engagementActivity.ActivityStr  = ActivityName;
                engagementActivity.Name         = consultingletterofcommand.EngagementName;
                engagementActivity.PICID        = consultingletterofcommand.PicID;
                engagementActivity.TeamLeaderID = consultingletterofcommand.TeamLeaderID;
                engagementActivity.SupervisorID = consultingletterofcommand.SupervisorID;
                engagementActivity.MemberID     = consultingletterofcommand.MemberID;
                context.EngagementActivities.Add(engagementActivity);

                //Letter of Command Dasar
                Ldasar.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID;
                Ldasar.Dasar = null;
                foreach (var ds in dasar)
                {
                    Ldasar.Dasar += ds + ";";
                }
                context.ConsultingLetterOfCommandDetailDasars.Add(Ldasar);

                //Letter of Command Untuk
                Luntuk.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID;
                Luntuk.Untuk = null;
                foreach (var utk in untuk)
                {
                    Luntuk.Untuk += utk + ";";
                }
                context.ConsultingLetterOfCommandDetailUntuks.Add(Luntuk);

                //Letter of Command Tembusan
                Ltembusan.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID;
                Ltembusan.Tembusan = null;
                foreach (var tmb in tembusan)
                {
                    Ltembusan.Tembusan += tmb + ";";
                }
                context.ConsultingLetterOfCommandDetailTembusans.Add(Ltembusan);

                context.SaveChanges();

                //assign engagementID in consulting SP
                consultingletterofcommand.EngagementID         = engagementActivity.EngagementID;
                context.Entry(consultingletterofcommand).State = EntityState.Modified;

                //Review Relation Master
                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "conleterdetail";
                rrm.Description = page + consultingletterofcommand.ConsultingSuratPerintahID;
                context.ReviewRelationMasters.Add(rrm);
                context.SaveChanges();
                ConsultingLetterOfCommand               conletcom      = new ConsultingLetterOfCommand();
                ConsultingLetterOfCommandDetailDasar    conletdasar    = new ConsultingLetterOfCommandDetailDasar();
                ConsultingLetterOfCommandDetailUntuk    conletuntuk    = new ConsultingLetterOfCommandDetailUntuk();
                ConsultingLetterOfCommandDetailTembusan conlettembusan = new ConsultingLetterOfCommandDetailTembusan();
                ConsultingLetterOfCommand               conletnew      = context.ConsultingLetterOfCommands.Find(consultingletterofcommand.ConsultingSuratPerintahID);
                auditTransact.CreateAuditTrail("Create", consultingletterofcommand.ConsultingSuratPerintahID, "Consulting Letter Of Command", conletcom, conletnew, username);
                auditTransact.CreateAuditTrail("Create", Ldasar.ConsultingLetterOfCommandDetailDasarID, "Consulting Letter Of Command Dasar", conletdasar, Ldasar, username);
                auditTransact.CreateAuditTrail("Create", Luntuk.ConsultingLetterOfCommandDetailUntukID, "Consulting Letter Of Command Untuk", conletuntuk, Luntuk, username);
                auditTransact.CreateAuditTrail("Create", Ltembusan.ConsultingLetterOfCommandDetailTembusanID, "Consulting Letter Of Command Tembusan", conlettembusan, Ltembusan, username);
                TempData["message"] = "Consulting Letter Of Command successfully created!";
                return(RedirectToAction("Index"));
            }

            return(View(consultingletterofcommand));
        }
        public ActionResult Edit(string submit, string requester, [Bind(Include = "ConsultingRequestID,NoRequest,NoSurat,RequesterID,Date_Start,EvaluationResult,Status,ActivityStr")] ConsultingRequest consultingRequest, IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                int i = 0;
                HttpServerUtilityBase server       = Server;
                List <string>         newFilesName = new List <string>();
                List <string>         paths        = new List <string>();
                UrlHelper             url          = Url;
                List <string>         keepImages   = new List <string>();
                //object imagesTemp = Session["Images"];
                var sessionImages = Session["Images"];
                if (sessionImages != null)
                {
                    Array arrKeepImages = (Array)sessionImages;
                    foreach (var arrKeepImage in arrKeepImages)
                    {
                        keepImages.Add(arrKeepImage.ToString());
                    }
                    bool          getFiles     = filesTransact.getFiles(consultingRequest.NoRequest.Replace("/", ""), out newFilesName, out paths, url, server);
                    List <string> deletedFiles = paths.Except(keepImages).ToList();
                    bool          deleteFiles  = filesTransact.deleteFiles(deletedFiles, server);

                    i = filesTransact.getLastNumberOfFiles(consultingRequest.NoRequest.Replace("/", ""), server);
                }
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        i = i + 1;
                        bool addFile = filesTransact.addFile(consultingRequest.NoRequest.Replace("/", ""), i, file, server);
                    }
                }
                Session.Remove("Images");



                IQueryable <Employee> emp = db.Employees.Where(p => p.Name.Equals(requester));
                int empId = 0;
                if (emp.Count() > 0 || emp != null)
                {
                    empId = emp.Select(p => p.EmployeeID).FirstOrDefault();
                }
                consultingRequest.RequesterID = empId;

                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    consultingRequest.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    consultingRequest.Status = HelperController.GetStatusSendback(db, "Consulting Request", consultingRequest.Status);
                }
                else if (submit == "Reject")
                {
                    consultingRequest.Status = "Reject";
                }
                else if (submit == "Approve")
                {
                    consultingRequest.Status = "Approve";
                    ConsultingDraftAgreement consultingDraftAgreement = new ConsultingDraftAgreement();
                    consultingDraftAgreement.NoRequest   = consultingRequest.NoRequest;
                    consultingDraftAgreement.NoSurat     = consultingRequest.NoSurat;
                    consultingDraftAgreement.RequesterID = consultingRequest.RequesterID;
                    consultingDraftAgreement.ActivityStr = consultingRequest.ActivityStr;
                    //consultingDraftAgreement.ActivityID = consultingRequest.ActivityID;
                    consultingDraftAgreement.Date_Start = consultingRequest.Date_Start;
                    //consultingDraftAgreement.Date_End = consultingRequest.Date_End;
                    consultingDraftAgreement.Status = "Draft";
                    db.ConsultingDraftAgreements.Add(consultingDraftAgreement);
                }
                else if (submit == "Submit For Review By" + user)
                {
                    consultingRequest.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    consultingRequest.Status = "Pending for Approve by" + user;
                    string          baseUrl    = Request.Url.GetLeftPart(UriPartial.Authority);
                    List <string>   CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
                    List <Employee> CIAEmpList = new List <Employee>();
                    if (CIAUserIds.Count() > 0)
                    {
                        var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList();
                        foreach (var CIAUser in CIAUsers)
                        {
                            Employee empl = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault();

                            string emailContent = "Dear {0}, <BR/><BR/>Consulting Request : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Consulting Request\">link</a> to show the Consulting Request.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                            string urlRequest   = baseUrl + "/ConsultingRequests/Details/" + consultingRequest.ConsultingRequestID;
                            emailTransact.SentEmailApproval(empl.Email, empl.Name, consultingRequest.NoRequest, emailContent, urlRequest);
                        }
                    }
                }
                ConsultingRequest oldData = db.ConsultingRequests.AsNoTracking().Where(p => p.ConsultingRequestID.Equals(consultingRequest.ConsultingRequestID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", consultingRequest.ConsultingRequestID, "Consulting Request", oldData, consultingRequest, username);
                db.Entry(consultingRequest).State = EntityState.Modified;
                db.SaveChanges();
                TempData["message"] = "Request successfully updated!";
                return(RedirectToAction("Index"));
            }
            //ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", consultingRequest.ActivityID);
            return(View(consultingRequest));
        }
        public ActionResult Edit([Bind(Include = "ConsultingSuratPerintahID,NomorSP,ConsultingRequestID,EngagementName,Status,StartDate,EndDate,PicID,SupervisorID,TeamLeaderID,Menimbang,Penutup,MemberID,Remarks,EngagementID")]
                                 ConsultingLetterOfCommand consultingletterofcommand, string ConsultingRequest, string enggname, string submit, string ActivityName, string[] member, string[] Dasar, string[] Untuk, string[] Tembusan)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                context.Configuration.ProxyCreationEnabled = false;
                IQueryable <ConsultingRequest> cr = context.ConsultingRequests.Where(p => p.NoRequest.Equals(ConsultingRequest));
                int ConsulId = 0;
                if (cr.Count() > 0 || cr != null)
                {
                    ConsulId = cr.Select(p => p.ConsultingRequestID).FirstOrDefault();
                }
                consultingletterofcommand.ConsultingRequestID = ConsulId;
                if (member != null)
                {
                    foreach (var mb in member)
                    {
                        consultingletterofcommand.MemberID += mb + ";";
                    }
                }
                else
                {
                    consultingletterofcommand.MemberID += ";";
                }
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    consultingletterofcommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    consultingletterofcommand.Status = HelperController.GetStatusSendback(context, "Consulting Surat Perintah", consultingletterofcommand.Status);
                }
                else if (submit == "Approve")
                {
                    consultingletterofcommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    consultingletterofcommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    consultingletterofcommand.Status = "Pending for Approve by" + user;
                }
                ConsultingLetterOfCommand oldData = context.ConsultingLetterOfCommands.AsNoTracking().Where(p => p.ConsultingSuratPerintahID.Equals(consultingletterofcommand.ConsultingSuratPerintahID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", consultingletterofcommand.ConsultingSuratPerintahID, "Consulting Letter Of Command", oldData, consultingletterofcommand, username);
                context.Entry(consultingletterofcommand).State = EntityState.Modified;
                context.SaveChanges();

                ConsultingLetterOfCommandDetailDasar ConsultingletterOfCommandDetailDasar = context.ConsultingLetterOfCommandDetailDasars.Where(p => p.ConsultingSuratPerintahID == consultingletterofcommand.ConsultingSuratPerintahID).FirstOrDefault();
                ConsultingletterOfCommandDetailDasar.Dasar = null;
                if (Dasar != null)
                {
                    foreach (var ab in Dasar)
                    {
                        ConsultingletterOfCommandDetailDasar.Dasar += ab + ";";
                    }
                }
                else
                {
                    ConsultingletterOfCommandDetailDasar.Dasar = ";";
                }

                ConsultingLetterOfCommandDetailUntuk ConsultingletterOfCommandDetailUntuk = context.ConsultingLetterOfCommandDetailUntuks.Where(p => p.ConsultingSuratPerintahID == consultingletterofcommand.ConsultingSuratPerintahID).FirstOrDefault();
                ConsultingletterOfCommandDetailUntuk.Untuk = null;
                if (Untuk != null)
                {
                    foreach (var cd in Untuk)
                    {
                        ConsultingletterOfCommandDetailUntuk.Untuk += cd + ";";
                    }
                }
                else
                {
                    ConsultingletterOfCommandDetailUntuk.Untuk = ";";
                }

                ConsultingLetterOfCommandDetailTembusan ConsultingletterOfCommandDetailTembusan = context.ConsultingLetterOfCommandDetailTembusans.Where(p => p.ConsultingSuratPerintahID == consultingletterofcommand.ConsultingSuratPerintahID).FirstOrDefault();
                ConsultingletterOfCommandDetailTembusan.Tembusan = null;
                if (Tembusan != null)
                {
                    foreach (var ef in Tembusan)
                    {
                        ConsultingletterOfCommandDetailTembusan.Tembusan += ef + ";";
                    }
                }
                else
                {
                    ConsultingletterOfCommandDetailTembusan.Tembusan = ";";
                }


                var eng = context.EngagementActivities.Find(consultingletterofcommand.EngagementID);
                eng.Name         = consultingletterofcommand.EngagementName;
                eng.PICID        = consultingletterofcommand.PicID;
                eng.TeamLeaderID = consultingletterofcommand.TeamLeaderID;
                eng.SupervisorID = consultingletterofcommand.SupervisorID;
                eng.MemberID     = consultingletterofcommand.MemberID;
                ConsultingLetterOfCommandDetailDasar    oldDataDasar    = context.ConsultingLetterOfCommandDetailDasars.AsNoTracking().Where(p => p.ConsultingLetterOfCommandDetailDasarID.Equals(ConsultingletterOfCommandDetailDasar.ConsultingLetterOfCommandDetailDasarID)).FirstOrDefault();
                ConsultingLetterOfCommandDetailUntuk    oldDataUntuk    = context.ConsultingLetterOfCommandDetailUntuks.AsNoTracking().Where(p => p.ConsultingLetterOfCommandDetailUntukID.Equals(ConsultingletterOfCommandDetailUntuk.ConsultingLetterOfCommandDetailUntukID)).FirstOrDefault();
                ConsultingLetterOfCommandDetailTembusan oldDataTembusan = context.ConsultingLetterOfCommandDetailTembusans.AsNoTracking().Where(p => p.ConsultingLetterOfCommandDetailTembusanID.Equals(ConsultingletterOfCommandDetailTembusan.ConsultingLetterOfCommandDetailTembusanID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", ConsultingletterOfCommandDetailDasar.ConsultingLetterOfCommandDetailDasarID, "Consulting Letter Of Command Dasar", oldDataDasar, ConsultingletterOfCommandDetailDasar, username);
                auditTransact.CreateAuditTrail("Update", ConsultingletterOfCommandDetailUntuk.ConsultingLetterOfCommandDetailUntukID, "Consulting Letter Of Command Untuk", oldDataUntuk, ConsultingletterOfCommandDetailUntuk, username);
                auditTransact.CreateAuditTrail("Update", ConsultingletterOfCommandDetailTembusan.ConsultingLetterOfCommandDetailTembusanID, "Consulting Letter Of Command Tembusan", oldDataTembusan, ConsultingletterOfCommandDetailTembusan, username);
                context.Entry(ConsultingletterOfCommandDetailDasar).State    = EntityState.Modified;
                context.Entry(ConsultingletterOfCommandDetailUntuk).State    = EntityState.Modified;
                context.Entry(ConsultingletterOfCommandDetailTembusan).State = EntityState.Modified;
                context.Entry(eng).State = EntityState.Modified;
                context.SaveChanges();
                TempData["message"] = "Consulting Letter Of Command successfully updated!";
                return(RedirectToAction("Index"));
            }
            return(View(consultingletterofcommand));
        }
        public async Task <ActionResult> UpdateBPM(string submit, int BPMID, int WalktroughID, int PrelimID)
        {
            string username = User.Identity.Name;

            db.Configuration.ProxyCreationEnabled = false;
            BPM         oldData  = db.BPMs.AsNoTracking().Where(p => p.BPMID.Equals(BPMID)).FirstOrDefault();
            BPM         bpm      = db.BPMs.Find(BPMID);
            int?        prelimId = PrelimID;
            Preliminary prelim   = db.Preliminaries.Find(prelimId);

            string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;

            if (submit == "Save")
            {
                bpm.Status = "Draft";
            }
            else if (submit == "Send Back")
            {
                bpm.Status = HelperController.GetStatusSendback(db, "BPM", bpm.Status);
            }
            else if (submit == "Approve")
            {
                bpm.Status = "Approve";
            }
            else if (submit == "Submit For Review By" + user)
            {
                bpm.Status = "Pending for Review by" + user;
            }
            else if (submit == "Submit For Approve By" + user)
            {
                bpm.Status = "Pending for Approve by" + user;
                string userToSentEmail = String.Empty;
                if (user.Trim() == "CIA")
                {
                    userToSentEmail = prelim.PICID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailBPM(userToSentEmail, bpm, WalktroughID);
                    }
                    else
                    {
                        sentEmailBPM(bpm, user.Trim(), WalktroughID);
                    }
                }
                else if (user.Trim() == "Pengawas")
                {
                    userToSentEmail = prelim.SupervisorID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailBPM(userToSentEmail, bpm, WalktroughID);
                    }
                    else
                    {
                        sentEmailBPM(bpm, user.Trim(), WalktroughID);
                    }
                }
                else if (user.Trim() == "Ketua Tim")
                {
                    userToSentEmail = prelim.TeamLeaderID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailBPM(userToSentEmail, bpm, WalktroughID);
                    }
                    else
                    {
                        sentEmailBPM(bpm, user.Trim(), WalktroughID);
                    }
                }
                else if (user.Trim() == "Member")
                {
                    userToSentEmail = prelim.MemberID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailBPM(userToSentEmail, bpm, WalktroughID);
                    }
                    else
                    {
                        sentEmailBPM(bpm, user.Trim(), WalktroughID);
                    }
                }
            }

            auditTransact.CreateAuditTrail("Update", bpm.WalktroughID, "BusinessProces", oldData, bpm, username);
            db.Entry(bpm).State = EntityState.Modified;
            await db.SaveChangesAsync();

            TempData["message"] = "BPM successfully updated!";
            return(RedirectToAction("Create", new { id = bpm.WalktroughID }));
        }
Пример #11
0
        public ActionResult Create([Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand,
                                   LetterOfCommandDetailDasar letterOfCommandDetailDasar, LetterOfCommandDetailUntuk letterOfCommandDetailUntuk,
                                   LetterOfCommandDetailTembusan letterOfCommandDetailTembusan, string letterno, string membernull,
                                   string activid, string[] members, string pic, string supervisor, string leader, string nomer,
                                   string submit, string[] dasar, string[] untuk, string[] tembusan)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;

                HttpServerUtilityBase server = Server;
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letterOfCommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status);
                }
                else if (submit == "Approve")
                {
                    letterOfCommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letterOfCommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letterOfCommand.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letterOfCommand.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letterOfCommand.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letterOfCommand.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letterOfCommand.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                }

                IQueryable <AuditPlanningMemorandum> apm = db.AuditPlanningMemorandums.Where(p => p.NomerAPM.Equals(nomer));
                int apmId = 0;
                if (apm.Count() > 0 || apm != null)
                {
                    apmId = apm.Select(p => p.AuditPlanningMemorandumID).FirstOrDefault();
                    letterOfCommand.AuditPlanningMemorandumID = apmId;
                }
                letterOfCommand.SupervisorID = supervisor;
                letterOfCommand.TeamLeaderID = leader;
                letterOfCommand.PICID        = pic;


                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid));
                int activ = 0;
                if (act.Count() > 0 || act != null)
                {
                    activ = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                letterOfCommand.ActivityID = activ;

                string   tahun1    = letterOfCommand.Date_Start.ToShortDateString().Split('/')[2] + ";";
                string   tahun2    = letterOfCommand.Date_End.ToShortDateString().Split('/')[2] + ";";
                Activity actLetter = db.Activities.Find(activ);
                if (actLetter.Tahun != null)
                {
                    if (tahun1 != tahun2)
                    {
                        if (!actLetter.Tahun.Contains(tahun1))
                        {
                            actLetter.Tahun += tahun1;
                        }
                        if (!actLetter.Tahun.Contains(tahun2))
                        {
                            actLetter.Tahun += tahun2;
                        }
                    }
                    else
                    {
                        if (!actLetter.Tahun.Contains(tahun1))
                        {
                            actLetter.Tahun += tahun1;
                        }
                    }
                }
                else
                {
                    if (tahun1 != tahun2)
                    {
                        actLetter.Tahun = tahun1 + tahun2;
                    }
                    else
                    {
                        actLetter.Tahun = tahun1;
                    }
                }
                db.Entry(actLetter).State = EntityState.Modified;
                letterOfCommand.NomorSP   = letterno;
                foreach (var mb in members)
                {
                    letterOfCommand.MemberID += mb + ";";
                }
                letterOfCommandDetailDasar.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailDasar.Dasar             = null;
                foreach (var ds in dasar)
                {
                    letterOfCommandDetailDasar.Dasar += ds + ";";
                }
                letterOfCommandDetailUntuk.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailUntuk.Untuk             = null;
                foreach (var utk in untuk)
                {
                    letterOfCommandDetailUntuk.Untuk += utk + ";";
                }
                letterOfCommandDetailTembusan.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailTembusan.Tembusan          = null;
                foreach (var tmb in tembusan)
                {
                    letterOfCommandDetailTembusan.Tembusan += tmb + ";";
                }
                db.LetterOfCommandDetailDasars.Add(letterOfCommandDetailDasar);
                db.LetterOfCommandDetailTembusans.Add(letterOfCommandDetailTembusan);
                db.LetterOfCommandDetailUntuks.Add(letterOfCommandDetailUntuk);
                db.LetterOfCommands.Add(letterOfCommand);
                db.SaveChanges();
                LetterOfCommand               let         = new LetterOfCommand();
                LetterOfCommandDetailDasar    letDasar    = new LetterOfCommandDetailDasar();
                LetterOfCommandDetailUntuk    letUntuk    = new LetterOfCommandDetailUntuk();
                LetterOfCommandDetailTembusan letTembusan = new LetterOfCommandDetailTembusan();
                auditTransact.CreateAuditTrail("Create", letterOfCommand.LetterOfCommandID, "LetterOfCommand", let, letterOfCommand, username);
                auditTransact.CreateAuditTrail("Create", letterOfCommandDetailDasar.ID, "LetterOfCommandDetailDasar", letDasar, letterOfCommandDetailDasar, username);
                auditTransact.CreateAuditTrail("Create", letterOfCommandDetailUntuk.ID, "LetterOfCommandDetailUntuk", letUntuk, letterOfCommandDetailUntuk, username);
                auditTransact.CreateAuditTrail("Create", letterOfCommandDetailTembusan.ID, "LetterOfCommandDetailTembusan", letTembusan, letterOfCommandDetailTembusan, username);
                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "letter";
                rrm.Description = page + letterOfCommand.LetterOfCommandID;

                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();
                TempData["message"] = "Letter Of Command successfully created!";
                return(RedirectToAction("Index"));
            }

            ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "NomorPreliminarySurvey", letterOfCommand.PreliminaryID);
            return(View(letterOfCommand));
        }
        public ActionResult Update(string submit, [Bind(Include = "AuditPlanningMemorandumID,NomerAPM,PreliminaryID,Date_Start,Date_End,Status,ActivityID,TujuanAudit,RuangLingkupAudit,MetodologiAudit,DataDanDokumen,AttachmentMasterID,EntryMeetingDateStart,EntryMeetingDateEnd,WalktroughDateStart,WalktroughDateEnd,FieldWorkDateStart,FieldWorkDateEnd,ExitMeetingDateStart,ExitMeetingDateEnd,LHADateStart,LHADateEnd,PICID,SupervisorID,TeamLeaderID,MemberID,ReviewMasterID,Kesimpulan,ActualEngagement")] AuditPlanningMemorandum auditPlanningMemorandum, IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                int i = 0;
                HttpServerUtilityBase server       = Server;
                List <string>         newFilesName = new List <string>();
                List <string>         paths        = new List <string>();
                UrlHelper             url          = Url;
                List <string>         keepImages   = new List <string>();
                //object imagesTemp = Session["Images"];
                var sessionImages = Session["Images"];
                if (sessionImages != null)
                {
                    Array arrKeepImages = (Array)sessionImages;
                    foreach (var arrKeepImage in arrKeepImages)
                    {
                        keepImages.Add(arrKeepImage.ToString());
                    }
                    bool          getFiles     = filesTransact.getFiles(auditPlanningMemorandum.NomerAPM.Replace("/", ""), out newFilesName, out paths, url, server);
                    List <string> deletedFiles = paths.Except(keepImages).ToList();
                    bool          deleteFiles  = filesTransact.deleteFiles(deletedFiles, server);

                    i = filesTransact.getLastNumberOfFiles(auditPlanningMemorandum.NomerAPM.Replace("/", ""), server);
                }
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        i = i + 1;
                        bool addFile = filesTransact.addFile(auditPlanningMemorandum.NomerAPM.Replace("/", ""), i, file, server);
                    }
                }
                Session.Remove("Images");

                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    auditPlanningMemorandum.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    auditPlanningMemorandum.Status = HelperController.GetStatusSendback(db, "Audit Planning Memorandum", auditPlanningMemorandum.Status);
                }
                else if (submit == "Approve")
                {
                    auditPlanningMemorandum.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    auditPlanningMemorandum.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    auditPlanningMemorandum.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = auditPlanningMemorandum.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = auditPlanningMemorandum.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = auditPlanningMemorandum.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = auditPlanningMemorandum.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum);
                        }
                        else
                        {
                            sentEmailAPM(auditPlanningMemorandum, user.Trim());
                        }
                    }
                }

                db.Entry(auditPlanningMemorandum).State = EntityState.Modified;
                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                AuditPlanningMemorandum oldData = db.AuditPlanningMemorandums.AsNoTracking().Where(p => p.AuditPlanningMemorandumID.Equals(auditPlanningMemorandum.AuditPlanningMemorandumID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", auditPlanningMemorandum.AuditPlanningMemorandumID, "AuditPlanningMemorandum", oldData, auditPlanningMemorandum, username);
                db.SaveChanges();
                TempData["message"] = "Audit Planning Memorandum successfully updated!";
                return(RedirectToAction("Index"));
            }
            return(View(auditPlanningMemorandum));
        }
Пример #13
0
        public async Task <ActionResult> Edit(string submit, string Status, string[] Dasar, string[] Untuk, string[] Tembusan, string activid, string memberName, string[] member, string pic, string supervisor, string leader, string nomer, [Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand)
        {
            if (ModelState.IsValid)
            {
                letterOfCommand.Status = Status;

                IQueryable <AuditPlanningMemorandum> apm = db.AuditPlanningMemorandums.Where(p => p.NomerAPM.Equals(nomer));
                int apmId = 0;
                if (apm.Count() > 0 || apm != null)
                {
                    apmId = apm.Select(p => p.AuditPlanningMemorandumID).FirstOrDefault();
                    letterOfCommand.AuditPlanningMemorandumID = apmId;
                }
                letterOfCommand.SupervisorID = supervisor;
                letterOfCommand.TeamLeaderID = leader;
                letterOfCommand.PICID        = pic;
                if (member != null)
                {
                    foreach (var mb in member)
                    {
                        letterOfCommand.MemberID += mb + ";";
                    }
                }
                else
                {
                    letterOfCommand.MemberID += ";";
                }
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letterOfCommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status);
                }
                else if (submit == "Approve")
                {
                    letterOfCommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letterOfCommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letterOfCommand.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letterOfCommand.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letterOfCommand.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letterOfCommand.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letterOfCommand.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                }

                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid));
                int activ = 0;
                if (act.Count() > 0 || act != null)
                {
                    activ = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                letterOfCommand.ActivityID = activ;

                db.Configuration.ProxyCreationEnabled = false;
                LetterOfCommandDetailDasar    letterOfCommandDetailDasar    = db.LetterOfCommandDetailDasars.AsNoTracking().Where(p => p.LetterOfCommandID == letterOfCommand.LetterOfCommandID).FirstOrDefault();
                LetterOfCommandDetailUntuk    letterOfCommandDetailUntuk    = db.LetterOfCommandDetailUntuks.AsNoTracking().Where(p => p.LetterOfCommandID == letterOfCommand.LetterOfCommandID).FirstOrDefault();
                LetterOfCommandDetailTembusan letterOfCommandDetailTembusan = db.LetterOfCommandDetailTembusans.AsNoTracking().Where(p => p.LetterOfCommandID == letterOfCommand.LetterOfCommandID).FirstOrDefault();
                letterOfCommandDetailDasar.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailDasar.Dasar             = null;
                if (Dasar != null)
                {
                    foreach (var ds in Dasar)
                    {
                        letterOfCommandDetailDasar.Dasar += ds + ";";
                    }
                }
                else
                {
                    letterOfCommandDetailDasar.Dasar = ";";
                }

                letterOfCommandDetailUntuk.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailUntuk.Untuk             = null;
                if (Untuk != null)
                {
                    foreach (var uk in Untuk)
                    {
                        letterOfCommandDetailUntuk.Untuk += uk + ";";
                    }
                }
                else
                {
                    letterOfCommandDetailUntuk.Untuk = ";";
                }

                letterOfCommandDetailTembusan.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailTembusan.Tembusan          = null;
                if (Tembusan != null)
                {
                    foreach (var ts in Tembusan)
                    {
                        letterOfCommandDetailTembusan.Tembusan += ts + ";";
                    }
                }
                else
                {
                    letterOfCommandDetailTembusan.Tembusan = ";";
                }

                string                        username        = User.Identity.Name;
                LetterOfCommand               oldData         = db.LetterOfCommands.AsNoTracking().Where(p => p.LetterOfCommandID.Equals(letterOfCommand.LetterOfCommandID)).FirstOrDefault();
                LetterOfCommandDetailDasar    oldDataDasar    = db.LetterOfCommandDetailDasars.AsNoTracking().Where(p => p.ID.Equals(letterOfCommandDetailDasar.ID)).FirstOrDefault();
                LetterOfCommandDetailUntuk    oldDataUntuk    = db.LetterOfCommandDetailUntuks.AsNoTracking().Where(p => p.ID.Equals(letterOfCommandDetailUntuk.ID)).FirstOrDefault();
                LetterOfCommandDetailTembusan oldDataTembusan = db.LetterOfCommandDetailTembusans.AsNoTracking().Where(p => p.ID.Equals(letterOfCommandDetailTembusan.ID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", letterOfCommand.LetterOfCommandID, "LetterOfCommand", oldData, letterOfCommand, username);
                auditTransact.CreateAuditTrail("Update", letterOfCommandDetailDasar.ID, "LetterOfCommandDasar", oldDataDasar, letterOfCommandDetailDasar, username);
                auditTransact.CreateAuditTrail("Update", letterOfCommandDetailUntuk.ID, "LetterOfCommandUntuk", oldDataUntuk, letterOfCommandDetailUntuk, username);
                auditTransact.CreateAuditTrail("Update", letterOfCommandDetailTembusan.ID, "LetterOfCommandTembusan", oldDataTembusan, letterOfCommandDetailTembusan, username);

                db.Entry(letterOfCommandDetailDasar).State    = EntityState.Modified;
                db.Entry(letterOfCommandDetailUntuk).State    = EntityState.Modified;
                db.Entry(letterOfCommandDetailTembusan).State = EntityState.Modified;
                db.Entry(letterOfCommand).State = EntityState.Modified;
                await db.SaveChangesAsync();

                TempData["message"] = "Letter Of Command successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "Type", letterOfCommand.PreliminaryID);
            return(View(letterOfCommand));
        }
Пример #14
0
        public async Task <ActionResult> Update(string submit, [Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand)
        {
            if (ModelState.IsValid)
            {
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letterOfCommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status);
                }
                else if (submit == "Approve")
                {
                    letterOfCommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letterOfCommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letterOfCommand.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letterOfCommand.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letterOfCommand.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letterOfCommand.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letterOfCommand.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                }

                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                LetterOfCommand oldData = db.LetterOfCommands.AsNoTracking().Where(p => p.LetterOfCommandID.Equals(letterOfCommand.LetterOfCommandID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", letterOfCommand.LetterOfCommandID, "LetterOfCommand", oldData, letterOfCommand, username);
                db.Entry(letterOfCommand).State = EntityState.Modified;
                await db.SaveChangesAsync();

                TempData["message"] = "Letter Of Command successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "Type", letterOfCommand.PreliminaryID);
            return(View(letterOfCommand));
        }
        public ActionResult UpdateAuditUniverse(string submit, Activity org, string Command)
        {
            if (!ModelState.IsValid)
            {
                return(View("EditAuditUniverse"));
            }
            else
            {
                Activity orgObj = new Activity();

                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    orgObj.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    orgObj.Status = HelperController.GetStatusSendback(db, "Audit Universe", org.Status);
                }
                else if (submit == "Approve")
                {
                    orgObj.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    orgObj.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    orgObj.Status = "Pending for Approve by" + user;
                    string          baseUrl    = Request.Url.GetLeftPart(UriPartial.Authority);
                    List <string>   CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
                    List <Employee> CIAEmpList = new List <Employee>();
                    if (CIAUserIds.Count() > 0)
                    {
                        var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList();
                        foreach (var CIAUser in CIAUsers)
                        {
                            Employee emp = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault();

                            string emailContent = "Dear {0}, <BR/><BR/>Audit Universe : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Audit Universe\">link</a> to show the Audit Universe.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                            string url          = baseUrl + "/AuditUniverses/Details?ActivityID=" + org.ActivityID;
                            //emailTransact.SentEmailApproval(emp.Email, emp.Name, org.Name, emailContent, url);
                        }
                    }
                }

                orgObj.ActivityID       = org.ActivityID;
                orgObj.ActivityParentID = org.ActivityParentID;
                orgObj.Name             = org.Name;
                //orgObj.Status = org.Status;
                orgObj.Tahun         = org.Tahun;
                orgObj.Description   = org.Description;
                orgObj.DepartementID = org.DepartementID;

                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                Activity oldData = db.Activities.AsNoTracking().Where(p => p.ActivityID.Equals(orgObj.ActivityID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", orgObj.ActivityID, "AuditUniverse", oldData, orgObj, username);

                bool IsSuccess = mobjModel.UpdateActivity(orgObj);
                if (IsSuccess)
                {
                    ModelState.Clear();
                    TempData["message"] = "Audit Universe successfully updated!";
                    return(RedirectToAction("Index"));
                }
            }

            return(View("EditAuditUniverse"));
        }
Пример #16
0
        public ActionResult Edit([Bind(Include = "ExitMeetingID,ActivityID,EngagementID,Date_Start,Date_End,Status,OrganizationID,LetterOfCommandID,Reviewer1,Reviewer2,StatusTanggapan")] ExitMeeting exitMeeting, string activname, string enggname, string submit, string organame, string nomersp, string period1, string period2)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activname));
                int actID = 0;
                if (act.Count() > 0 || act != null)
                {
                    actID = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                exitMeeting.ActivityID = actID;

                IQueryable <EngagementActivity> eng = db.EngagementActivities.Where(p => p.Name.Equals(enggname));
                int engID = 0;
                if (eng.Count() > 0 || eng != null)
                {
                    engID = eng.Select(p => p.EngagementID).FirstOrDefault();
                }
                exitMeeting.EngagementID = engID;
                exitMeeting.Date_Start   = Convert.ToDateTime(period1);
                exitMeeting.Date_End     = Convert.ToDateTime(period2);

                IQueryable <Organization> org = db.Organizations.Where(p => p.Name.Equals(organame));
                int orgID = 0;
                if (act.Count() > 0 || act != null)
                {
                    orgID = org.Select(p => p.OrganizationID).FirstOrDefault();
                }
                exitMeeting.OrganizationID = orgID;

                IQueryable <LetterOfCommand> letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp));
                int letterID = 0;
                if (letter.Count() > 0 || letter != null)
                {
                    letterID = letter.Select(p => p.LetterOfCommandID).FirstOrDefault();
                }
                exitMeeting.LetterOfCommandID = letterID;
                LetterOfCommand sp = db.LetterOfCommands.Find(exitMeeting.LetterOfCommandID);

                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    exitMeeting.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    exitMeeting.Status = HelperController.GetStatusSendback(db, "Exit Meeting", exitMeeting.Status);
                }
                else if (submit == "Approve")
                {
                    exitMeeting.Status          = "Approve";
                    exitMeeting.StatusTanggapan = "Closed";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    exitMeeting.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    exitMeeting.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = sp.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = sp.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = sp.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = sp.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                }
                ExitMeeting oldData = db.ExitMeetings.AsNoTracking().Where(p => p.ExitMeetingID.Equals(exitMeeting.ExitMeetingID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", exitMeeting.ExitMeetingID, "Exit Meeting", oldData, exitMeeting, username);
                db.Entry(exitMeeting).State = EntityState.Modified;
                db.SaveChanges();
                TempData["message"] = "Exit Meeting successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.nomersp   = db.LetterOfCommands.Where(p => p.LetterOfCommandID.Equals(exitMeeting.ExitMeetingID)).Select(p => p.NomorSP).FirstOrDefault();
            ViewBag.activname = db.Activities.Where(p => p.ActivityID.Equals(exitMeeting.ActivityID)).Select(p => p.Name).FirstOrDefault();
            ViewBag.enggname  = db.EngagementActivities.Where(p => p.EngagementID.Equals(exitMeeting.EngagementID)).Select(p => p.Name).FirstOrDefault();
            ViewBag.organame  = db.Organizations.Where(p => p.OrganizationID.Equals(exitMeeting.OrganizationID)).Select(p => p.Name).FirstOrDefault();
            return(View(exitMeeting));
        }
Пример #17
0
        public ActionResult Create([Bind(Include = "ExitMeetingID,ActivityID,EngagementID,Date_Start,Date_End,Status,OrganizationID,LetterOfCommandID,Reviewer1,Reviewer2")] ExitMeeting exitMeeting, string activname, string enggname, string submit, string organame, string nomersp, string period1, string period2)
        {
            if (ModelState.IsValid)
            {
                string username           = User.Identity.Name;
                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activname));
                int actID = 0;
                if (act.Count() > 0 || act != null)
                {
                    actID = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                exitMeeting.ActivityID = actID;

                IQueryable <EngagementActivity> eng = db.EngagementActivities.Where(p => p.Name.Equals(enggname));
                int engID = 0;
                if (eng.Count() > 0 || eng != null)
                {
                    engID = eng.Select(p => p.EngagementID).FirstOrDefault();
                }
                exitMeeting.EngagementID = engID;
                exitMeeting.Date_Start   = Convert.ToDateTime(period1);
                exitMeeting.Date_End     = Convert.ToDateTime(period2);

                IQueryable <Organization> org = db.Organizations.Where(p => p.Name.Equals(organame));
                int orgID = 0;
                if (act.Count() > 0 || act != null)
                {
                    orgID = org.Select(p => p.OrganizationID).FirstOrDefault();
                }
                exitMeeting.OrganizationID = orgID;

                IQueryable <LetterOfCommand> letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp));
                int letterID = 0;
                if (letter.Count() > 0 || letter != null)
                {
                    letterID = letter.Select(p => p.LetterOfCommandID).FirstOrDefault();
                }
                exitMeeting.LetterOfCommandID = letterID;
                LetterOfCommand sp   = db.LetterOfCommands.Find(exitMeeting.LetterOfCommandID);
                string          user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    exitMeeting.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    exitMeeting.Status = HelperController.GetStatusSendback(db, "Exit Meeting", exitMeeting.Status);
                }
                else if (submit == "Approve")
                {
                    exitMeeting.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    exitMeeting.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    exitMeeting.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = sp.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = sp.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = sp.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = sp.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                }
                exitMeeting.StatusTanggapan = "On Progress";
                db.ExitMeetings.Add(exitMeeting);
                db.SaveChanges();
                ExitMeeting exitmeet = new ExitMeeting();
                auditTransact.CreateAuditTrail("Create", exitMeeting.ExitMeetingID, "Exit Meeting", exitmeet, exitMeeting, username);

                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "exitmeet";
                rrm.Description = page + exitMeeting.ExitMeetingID;
                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();

                TempData["message"] = "Exit Meeting successfully created!";
                return(RedirectToAction("Index"));
            }

            //LetterOfCommand letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp)).FirstOrDefault();
            //var activId = letter.ActivityID;
            //var engId = letter.Preliminary.EngagementID;
            //var orgId = letter.Activity.DepartementID;
            //string activnam = db.Activities.Find(activId).Name;
            //string engname = db.EngagementActivities.Find(engId).Name;
            //string orgname = db.Organizations.Find(orgId).Name;
            //var data =  activnam + "," + engname + "," + orgname;
            return(View(exitMeeting));
        }
Пример #18
0
        public ActionResult Index()
        {
            string uid          = User.Identity.GetUserId();
            string roleId       = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(uid).Roles.Select(p => p.RoleId).FirstOrDefault();
            string roleName     = HttpContext.GetOwinContext().GetUserManager <ApplicationRoleManager>().FindById(roleId).Name;
            string loggedInName = HelperController.getNameByUserName(User.Identity.Name);

            ViewBag.AP         = new List <AnnualPlanning>();
            ViewBag.AU         = new List <Activity>();
            ViewBag.Questioner = new List <Questioner>();
            ViewBag.Prelim     = new List <Preliminary>();
            ViewBag.BPM        = new List <BPM>();
            ViewBag.RCM        = new List <RiskControlMatrix>();
            ViewBag.APM        = new List <AuditPlanningMemorandum>();
            ViewBag.SP         = new List <LetterOfCommand>();
            ViewBag.Fieldwork  = new List <FieldWork>();
            ViewBag.EM         = new List <ExitMeeting>();
            ViewBag.CR         = new List <ConsultingRequest>();
            ViewBag.CDA        = new List <ConsultingDraftAgreement>();
            ViewBag.CSP        = new List <ConsultingLetterOfCommand>();
            ViewBag.CFW        = new List <ConsultingFieldWork>();
            ViewBag.ListSp     = db.LetterOfCommands.Where(d => d.PICID == loggedInName || d.SupervisorID == loggedInName || d.TeamLeaderID == loggedInName).ToList();
            //yudha


            int dataCount = 0;

            ViewBag.ConsulFWIssue = new List <ConsultingRCMDetailRiskControlIssue>();
            List <PermissionRoles> permConsulFWIssue = HelperController.getPermission(uid, "Consulting Control Issue");

            if (permConsulFWIssue != null)
            {
                List <string> userPerm     = HelperController.getPermission(User.Identity.GetUserId(), "Consulting Control Issue").Select(d => d.roleID).ToList();
                List <string> ListroleName = new List <string>();
                bool          isUpdate     = permConsulFWIssue.Any(q => q.IsUpdate == true);
                List <ConsultingRCMDetailRiskControlIssue> data = new List <ConsultingRCMDetailRiskControlIssue>();
                foreach (string item in userPerm)
                {
                    string role_ = HttpContext.GetOwinContext().GetUserManager <ApplicationRoleManager>().FindById(item).Name;
                    ListroleName.Add(role_);
                    data.AddRange(db.ConsultingRCMDetailRiskControlIssue.Where(p => p.Status_App.Contains(role_) || (isUpdate ? p.Status_App.Equals("Draft") : p.Status_App.Equals(""))).ToList());
                }

                //List<BPM> bpm = db.BPMs.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                //List<ConsultingRCMDetailRiskControlIssue> datalist = new List<ConsultingRCMDetailRiskControlIssue>();
                //if (ListroleName.Contains("Ketua Tim"))
                //    datalist = data.Where(p => (? loggedInName.Contains(p.Walktrough.Preliminary.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                //else if (ListroleName.Contains("Pengawas"))
                //    datalist = data.Where(p => (? loggedInName.Contains(p.Walktrough.Preliminary.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                //else if (ListroleName.Contains("CIA"))
                //    datalist = data.Where(p => (p.Walktrough.Preliminary.PICID != null ? loggedInName.Contains(p.Walktrough.Preliminary.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                //else datalist = data;
                ViewBag.ConsulFWIssue = data;
                dataCount            += data.Count();
            }


            List <PermissionRoles> permAP = HelperController.getPermission(uid, "Annual Planning");

            if (permAP != null)
            {
                bool isUpdate = permAP.Any(q => q.IsUpdate == true);
                ViewBag.AP = db.AnnualPlannings.Where(p => p.Approval_Status.Contains(roleName) || (isUpdate ? p.Approval_Status.Equals("Draft") : p.Approval_Status.Equals(""))).ToList();
                dataCount += ViewBag.AP.Count;
            }

            List <PermissionRoles> permAU = HelperController.getPermission(uid, "Audit Universe");

            if (permAU != null)
            {
                bool isUpdate = permAU.Any(q => q.IsUpdate == true);
                ViewBag.AU = db.Activities.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                dataCount += ViewBag.AU.Count;
            }

            List <PermissionRoles> permQ = HelperController.getPermission(uid, "Questioner");

            if (permQ != null)
            {
                bool isUpdate = permQ.Any(q => q.IsUpdate == true);
                ViewBag.Questioner = db.Questioners.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                dataCount         += ViewBag.Questioner.Count;
            }

            List <PermissionRoles> permPrelim = HelperController.getPermission(uid, "Preliminary Survey");

            if (permPrelim != null)
            {
                bool isUpdate                 = permPrelim.Any(q => q.IsUpdate == true);
                List <Preliminary> prelim     = db.Preliminaries.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <Preliminary> prelimList = new List <Preliminary>();
                if (roleName == "Ketua Tim")
                {
                    prelimList = prelim.Where(p => (p.TeamLeaderID != null ? loggedInName.Contains(p.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    prelimList = prelim.Where(p => (p.SupervisorID != null ? loggedInName.Contains(p.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    prelimList = prelim.Where(p => (p.PICID != null ? loggedInName.Contains(p.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    prelimList = prelim;
                }
                ViewBag.Prelim = prelimList;
                dataCount     += prelimList.Count();
            }

            List <PermissionRoles> permBPM = HelperController.getPermission(uid, "BPM");

            if (permBPM != null)
            {
                List <string> userPerm     = HelperController.getPermission(User.Identity.GetUserId(), "BPM").Select(d => d.roleID).ToList();
                List <string> ListroleName = new List <string>();
                bool          isUpdate     = permBPM.Any(q => q.IsUpdate == true);
                List <BPM>    bpm          = new List <BPM>();
                foreach (string item in userPerm)
                {
                    string role_ = HttpContext.GetOwinContext().GetUserManager <ApplicationRoleManager>().FindById(item).Name;
                    ListroleName.Add(role_);
                    bpm.AddRange(db.BPMs.Where(p => p.Status.Contains(role_) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList());
                }

                //List<BPM> bpm = db.BPMs.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <BPM> bpmList = new List <BPM>();
                if (ListroleName.Contains("Ketua Tim"))
                {
                    bpmList = bpm.Where(p => (p.Walktrough.Preliminary.TeamLeaderID != null ? loggedInName.Contains(p.Walktrough.Preliminary.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (ListroleName.Contains("Pengawas"))
                {
                    bpmList = bpm.Where(p => (p.Walktrough.Preliminary.SupervisorID != null ? loggedInName.Contains(p.Walktrough.Preliminary.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (ListroleName.Contains("CIA"))
                {
                    bpmList = bpm.Where(p => (p.Walktrough.Preliminary.PICID != null ? loggedInName.Contains(p.Walktrough.Preliminary.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    bpmList = bpm;
                }
                ViewBag.BPM = bpmList;
                dataCount  += bpmList.Count();
            }

            List <PermissionRoles> permRCM = HelperController.getPermission(uid, "RCM");

            if (permRCM != null)
            {
                bool isUpdate = permRCM.Any(q => q.IsUpdate == true);
                List <RiskControlMatrix> rcm     = db.RiskControlMatrixs.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <RiskControlMatrix> rcmList = new List <RiskControlMatrix>();
                if (roleName == "Ketua Tim")
                {
                    rcmList = rcm.Where(p => (p.Walktrough.Preliminary.TeamLeaderID != null ? loggedInName.Contains(p.Walktrough.Preliminary.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    rcmList = rcm.Where(p => (p.Walktrough.Preliminary.SupervisorID != null ? loggedInName.Contains(p.Walktrough.Preliminary.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    rcmList = rcm.Where(p => (p.Walktrough.Preliminary.PICID != null ? loggedInName.Contains(p.Walktrough.Preliminary.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    rcmList = rcm;
                }
                ViewBag.RCM = rcmList;
                dataCount  += rcmList.Count();
            }

            List <PermissionRoles> permAPM = HelperController.getPermission(uid, "Audit Planning Memorandum");

            if (permAPM != null)
            {
                List <string> userPerm             = HelperController.getPermission(User.Identity.GetUserId(), "BPM").Select(d => d.roleID).ToList();
                List <string> ListroleName         = new List <string>();
                bool          isUpdate             = permAPM.Any(q => q.IsUpdate == true);
                List <AuditPlanningMemorandum> apm = new List <AuditPlanningMemorandum>();
                foreach (string item in userPerm)
                {
                    string role_ = HttpContext.GetOwinContext().GetUserManager <ApplicationRoleManager>().FindById(item).Name;
                    ListroleName.Add(role_);
                    apm.AddRange(db.AuditPlanningMemorandums.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList());
                }
                //bool isUpdate = permAPM.Any(q => q.IsUpdate == true);
                //List<AuditPlanningMemorandum> apm = db.AuditPlanningMemorandums.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <AuditPlanningMemorandum> apmList = new List <AuditPlanningMemorandum>();
                if (ListroleName.Contains("Ketua Tim"))
                {
                    apmList = apm.Where(p => (p.TeamLeaderID != null ? loggedInName.Contains(p.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (ListroleName.Contains("Pengawas"))
                {
                    apmList = apm.Where(p => (p.SupervisorID != null ? loggedInName.Contains(p.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (ListroleName.Contains("CIA"))
                {
                    apmList = apm.Where(p => (p.PICID != null ? loggedInName.Contains(p.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    apmList = apm;
                }
                ViewBag.APM = apmList;
                dataCount  += apmList.Count();
            }

            List <PermissionRoles> permSP = HelperController.getPermission(uid, "Surat Perintah");

            if (permSP != null)
            {
                bool isUpdate                 = permSP.Any(q => q.IsUpdate == true);
                List <LetterOfCommand> sp     = db.LetterOfCommands.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <LetterOfCommand> spList = new List <LetterOfCommand>();
                if (roleName == "Ketua Tim")
                {
                    spList = sp.Where(p => (p.TeamLeaderID != null ? loggedInName.Contains(p.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    spList = sp.Where(p => (p.SupervisorID != null ? loggedInName.Contains(p.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    spList = sp.Where(p => (p.PICID != null ? loggedInName.Contains(p.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    spList = sp;
                }
                ViewBag.SP = spList;
                dataCount += spList.Count();
            }

            List <PermissionRoles> permFW = HelperController.getPermission(uid, "FieldWork");

            if (permFW != null)
            {
                bool             isUpdate = permFW.Any(q => q.IsUpdate == true);
                List <FieldWork> fw       = db.FieldWorks.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <FieldWork> fwList   = new List <FieldWork>();
                if (roleName == "Ketua Tim")
                {
                    fwList = fw.Where(p => (p.LetterOfCommand.TeamLeaderID != null ? loggedInName.Contains(p.LetterOfCommand.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    fwList = fw.Where(p => (p.LetterOfCommand.SupervisorID != null ? loggedInName.Contains(p.LetterOfCommand.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    fwList = fw.Where(p => (p.LetterOfCommand.PICID != null ? loggedInName.Contains(p.LetterOfCommand.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    fwList = fw;
                }
                ViewBag.Fieldwork = fwList;
                dataCount        += fwList.Count();
            }

            List <PermissionRoles> permEM = HelperController.getPermission(uid, "Exit Meeting");

            if (permEM != null)
            {
                bool isUpdate             = permEM.Any(q => q.IsUpdate == true);
                List <ExitMeeting> em     = db.ExitMeetings.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <ExitMeeting> emList = new List <ExitMeeting>();
                if (roleName == "Ketua Tim")
                {
                    emList = em.Where(p => (p.LetterOfCommand.TeamLeaderID != null ? loggedInName.Contains(p.LetterOfCommand.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    emList = em.Where(p => (p.LetterOfCommand.SupervisorID != null ? loggedInName.Contains(p.LetterOfCommand.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    emList = em.Where(p => (p.LetterOfCommand.PICID != null ? loggedInName.Contains(p.LetterOfCommand.PICID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    emList = em;
                }
                ViewBag.EM = emList;
                dataCount += emList.Count();
            }

            List <PermissionRoles> permCR = HelperController.getPermission(uid, "Consulting Request");

            if (permCR != null)
            {
                bool isUpdate = permCR.Any(q => q.IsUpdate == true);
                ViewBag.CR = db.ConsultingRequests.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                dataCount += ViewBag.CR.Count;
            }

            List <PermissionRoles> permCDA = HelperController.getPermission(uid, "Consulting Draft Agreement");

            if (permCDA != null)
            {
                bool isUpdate = permCDA.Any(q => q.IsUpdate == true);
                ViewBag.CDA = db.ConsultingDraftAgreements.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                dataCount  += ViewBag.CDA.Count;
            }

            List <PermissionRoles> permCSP = HelperController.getPermission(uid, "Consulting Surat Perintah");

            if (permCSP != null)
            {
                bool isUpdate = permCSP.Any(q => q.IsUpdate == true);
                List <ConsultingLetterOfCommand> csp     = db.ConsultingLetterOfCommands.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <ConsultingLetterOfCommand> cspList = new List <ConsultingLetterOfCommand>();
                if (roleName == "Ketua Tim")
                {
                    cspList = csp.Where(p => (p.TeamLeaderID != null ? loggedInName.Contains(p.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    cspList = csp.Where(p => (p.SupervisorID != null ? loggedInName.Contains(p.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    cspList = csp.Where(p => (p.PicID != null ? loggedInName.Contains(p.PicID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    cspList = csp;
                }
                ViewBag.CSP = cspList;
                dataCount  += cspList.Count();
            }

            List <PermissionRoles> permCFW = HelperController.getPermission(uid, "Consulting Fieldwork");

            if (permCFW != null)
            {
                bool isUpdate = permCFW.Any(q => q.IsUpdate == true);
                List <ConsultingFieldWork> cfw     = db.ConsultingFieldWork.Where(p => p.Status.Contains(roleName) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                List <ConsultingFieldWork> cfwList = new List <ConsultingFieldWork>();
                if (roleName == "Ketua Tim")
                {
                    cfwList = cfw.Where(p => (p.ConsultingLetterOfCommand.TeamLeaderID != null ? loggedInName.Contains(p.ConsultingLetterOfCommand.TeamLeaderID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "Pengawas")
                {
                    cfwList = cfw.Where(p => (p.ConsultingLetterOfCommand.SupervisorID != null ? loggedInName.Contains(p.ConsultingLetterOfCommand.SupervisorID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else if (roleName == "CIA")
                {
                    cfwList = cfw.Where(p => (p.ConsultingLetterOfCommand.PicID != null ? loggedInName.Contains(p.ConsultingLetterOfCommand.PicID) : loggedInName.Contains("")) || (isUpdate ? p.Status.Equals("Draft") : p.Status.Equals(""))).ToList();
                }
                else
                {
                    cfwList = cfw;
                }
                ViewBag.CFW = cfwList;
                dataCount  += cfwList.Count();
            }

            ViewBag.dataCount = dataCount;
            ViewBag.assDraft  = getStatusTransaction("Draft", "Assurance");
            ViewBag.assCons   = getStatusTransaction("Draft", "Consulting");
            ViewBag.actCount  = getCount("Activity");
            return(View());
        }
Пример #19
0
        public ActionResult Create(string submit, [Bind(Include = "AnnualPlanningID,Date_Start,Date_End,Status,Approval_Status,Tahun,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] AnnualPlanning annualPlanning, string[] member, string supervisor, string pic, string leader, EngagementActivity engagementActivity)
        {
            if (ModelState.IsValid)
            {
                HttpServerUtilityBase server = Server;
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    annualPlanning.Approval_Status = "Draft";
                }
                else if (submit == "Approve")
                {
                    annualPlanning.Approval_Status = "Approve";
                }
                else if (submit == "Send Back")
                {
                    annualPlanning.Approval_Status = HelperController.GetStatusSendback(db, "Annual Planning", annualPlanning.Approval_Status);
                }
                else if (submit == "Submit For Review By" + user)
                {
                    annualPlanning.Approval_Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    annualPlanning.Approval_Status = "Pending for Approve by" + user;
                    string          activname = db.Activities.Where(p => p.ActivityID.Equals(annualPlanning.ActivityID)).Select(p => p.Name).FirstOrDefault();
                    string          baseUrl   = Request.Url.GetLeftPart(UriPartial.Authority);
                    List <string>   UserIds   = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
                    List <Employee> EmpList   = new List <Employee>();
                    if (UserIds.Count() > 0)
                    {
                        var users = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (UserIds.Contains(p.Id))).ToList();
                        foreach (var userr in users)
                        {
                            Employee emp = db.Employees.Where(p => p.Email.Equals(userr.Email)).FirstOrDefault();
                            if (emp != null)
                            {
                                string emailContent = "Dear {0}, <BR/><BR/>There is a Annual Planning that need your approval. Please click on this <a href=\"{2}\" title=\"Annual Planning\">link</a> to show the Annual Planning.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                                string url          = baseUrl + "/AnnualPlannings/Details/" + annualPlanning.AnnualPlanningID;
                                emailTransact.SentEmailApproval(emp.Email, emp.Name, activname, emailContent, url);
                            }
                        }
                    }
                }

                db.AnnualPlannings.Add(annualPlanning);
                db.SaveChanges();
                string         username = User.Identity.Name;
                AnnualPlanning an       = new AnnualPlanning();
                auditTransact.CreateAuditTrail("Create", annualPlanning.AnnualPlanningID, "AnnualPlanning", an, annualPlanning, username);

                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "apl";
                rrm.Description = page + annualPlanning.AnnualPlanningID;
                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();

                TempData["message"] = "Annual Planning successfully created!";
                return(RedirectToAction("Index"));
            }
            ActivityServices activity = new ActivityServices();
            var activities            = activity.GetActivity().Where(p => p.Status == "Approve");
            IEnumerable <SelectListItem> activityid = activities
                                                      .Select(d => new SelectListItem
            {
                Value = d.ActivityID.ToString(),
                Text  = d.Name
            });

            ViewBag.ActivityID = activityid;
            ViewBag.membereng  = new MultiSelectList(db.Employees, "EmployeeID", "Name");
            ViewBag.membereng1 = new MultiSelectList(db.Employees, "EmployeeID", "Name");
            return(View(annualPlanning));
        }
        public ActionResult Create(string noprelim, int?ActivityID, string EngagementNameNull, string EngagementName, int?UnActivityID, int?engid, [Bind(Include = "PreliminaryID,Type,Status,NomorPreliminarySurvey,Date_Start,Date_End,EmployeeID,EngagementID,PICID,SupervisorID,TeamLeaderID,MemberID")] Preliminary preliminary, IEnumerable <HttpPostedFileBase> files, string submit, string[] member,
                                   string pic, string supervisor, string leader, string[] members)
        {
            if (ModelState.IsValid)
            {
                if (member != null)
                {
                    foreach (var mem in member)
                    {
                        preliminary.EmployeeID += mem + ";";
                    }
                }

                preliminary.PICID        = pic;
                preliminary.SupervisorID = supervisor;
                preliminary.TeamLeaderID = leader;
                if (members != null)
                {
                    foreach (var mem in members)
                    {
                        preliminary.MemberID += mem + ";";
                    }
                }

                HttpServerUtilityBase server = Server;
                int a = 0;
                if (engid == 0 && a < ActivityID)
                {
                    EngagementActivity engagement = new EngagementActivity();

                    engagement.ActivityID = ActivityID.Value;
                    engagement.Name       = EngagementNameNull;
                    engagement.Date_Start = null;
                    engagement.Date_End   = null;
                    db.EngagementActivities.Add(engagement);
                    db.SaveChanges();

                    preliminary.ActivityID             = ActivityID.Value;
                    preliminary.EngagementID           = engagement.EngagementID;
                    preliminary.NomorPreliminarySurvey = noprelim;
                    int i = 0;
                    foreach (var file in files)
                    {
                        if (file != null)
                        {
                            i = i + 1;
                            var  pre     = preliminary.NomorPreliminarySurvey.Split('/')[0];
                            var  no      = preliminary.NomorPreliminarySurvey.Split('/')[1];
                            bool addFile = filesTransact.addFile(pre + no, i, file, server);
                        }
                    }

                    string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                    if (submit == "Save")
                    {
                        preliminary.Status = "Draft";
                    }
                    else if (submit == "Send Back")
                    {
                        preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status);
                    }
                    else if (submit == "Approve")
                    {
                        preliminary.Status = "Approve";
                    }
                    else if (submit == "Submit For Review By" + user)
                    {
                        preliminary.Status = "Pending for Review by" + user;
                    }
                    else if (submit == "Submit For Approve By" + user)
                    {
                        preliminary.Status = "Pending for Approve by" + user;
                        string userToSentEmail = String.Empty;
                        if (user.Trim() == "CIA")
                        {
                            userToSentEmail = preliminary.PICID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Pengawas")
                        {
                            userToSentEmail = preliminary.SupervisorID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Ketua Tim")
                        {
                            userToSentEmail = preliminary.TeamLeaderID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Member")
                        {
                            userToSentEmail = preliminary.MemberID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                    }
                    db.Preliminaries.Add(preliminary);
                    db.SaveChanges();
                    string      username = User.Identity.Name;
                    Preliminary pr       = new Preliminary();
                    auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username);

                    ReviewRelationMaster rrm = new ReviewRelationMaster();
                    string page = "prelim";
                    rrm.Description = page + preliminary.PreliminaryID;
                    db.ReviewRelationMasters.Add(rrm);
                    db.SaveChanges();
                }
                else
                if (preliminary.Type == "UnPlanned")
                {
                    EngagementActivity engagement = new EngagementActivity();


                    engagement.ActivityID = UnActivityID.Value;
                    engagement.Name       = EngagementName;
                    engagement.Date_Start = null;
                    engagement.Date_End   = null;
                    db.EngagementActivities.Add(engagement);
                    db.SaveChanges();

                    preliminary.ActivityID             = UnActivityID.Value;
                    preliminary.EngagementID           = engagement.EngagementID;
                    preliminary.NomorPreliminarySurvey = noprelim;
                    int i = 0;
                    foreach (var file in files)
                    {
                        if (file != null)
                        {
                            i = i + 1;
                            var  pre     = preliminary.NomorPreliminarySurvey.Split('/')[0];
                            var  no      = preliminary.NomorPreliminarySurvey.Split('/')[1];
                            bool addFile = filesTransact.addFile(pre + no, i, file, server);
                        }
                    }

                    string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                    if (submit == "Save")
                    {
                        preliminary.Status = "Draft";
                    }
                    else if (submit == "Send Back")
                    {
                        preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status);
                    }
                    else if (submit == "Approve")
                    {
                        preliminary.Status = "Approve";
                    }
                    else if (submit == "Submit For Review By" + user)
                    {
                        preliminary.Status = "Pending for Review by" + user;
                    }
                    else if (submit == "Submit For Approve By" + user)
                    {
                        preliminary.Status = "Pending for Approve by" + user;
                        string userToSentEmail = String.Empty;
                        if (user.Trim() == "CIA")
                        {
                            userToSentEmail = preliminary.PICID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Pengawas")
                        {
                            userToSentEmail = preliminary.SupervisorID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Ketua Tim")
                        {
                            userToSentEmail = preliminary.TeamLeaderID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Member")
                        {
                            userToSentEmail = preliminary.MemberID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                    }
                    db.Preliminaries.Add(preliminary);
                    db.SaveChanges();
                    string      username = User.Identity.Name;
                    Preliminary pr       = new Preliminary();
                    auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username);
                    ReviewRelationMaster rrm = new ReviewRelationMaster();
                    string page = "prelim";
                    rrm.Description = page + preliminary.PreliminaryID;
                    db.ReviewRelationMasters.Add(rrm);

                    db.SaveChanges();
                }
                else //Type == "Planned"
                {
                    EngagementActivity engagement = new EngagementActivity();

                    preliminary.ActivityID             = ActivityID.Value;
                    preliminary.EngagementID           = engid;
                    preliminary.NomorPreliminarySurvey = noprelim;
                    int i = 0;
                    foreach (var file in files)
                    {
                        if (file != null)
                        {
                            i = i + 1;
                            var  pre     = preliminary.NomorPreliminarySurvey.Split('/')[0];
                            var  no      = preliminary.NomorPreliminarySurvey.Split('/')[1];
                            bool addFile = filesTransact.addFile(pre + no, i, file, server);
                        }
                    }

                    string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                    if (submit == "Save")
                    {
                        preliminary.Status = "Draft";
                    }
                    else if (submit == "Send Back")
                    {
                        preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status);
                    }
                    else if (submit == "Approve")
                    {
                        preliminary.Status = "Approve";
                    }
                    else if (submit == "Submit For Review By" + user)
                    {
                        preliminary.Status = "Pending for Review by" + user;
                    }
                    else if (submit == "Submit For Approve By" + user)
                    {
                        preliminary.Status = "Pending for Approve by" + user;
                        string userToSentEmail = String.Empty;
                        if (user.Trim() == "CIA")
                        {
                            userToSentEmail = preliminary.PICID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Pengawas")
                        {
                            userToSentEmail = preliminary.SupervisorID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Ketua Tim")
                        {
                            userToSentEmail = preliminary.TeamLeaderID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                        else if (user.Trim() == "Member")
                        {
                            userToSentEmail = preliminary.MemberID;
                            if (userToSentEmail != null)
                            {
                                sentSingleEmailPrelim(userToSentEmail, preliminary);
                            }
                            else
                            {
                                sentEmailPrelim(preliminary, user.Trim());
                            }
                        }
                    }
                    db.Preliminaries.Add(preliminary);
                    db.SaveChanges();
                    string      username = User.Identity.Name;
                    Preliminary pr       = new Preliminary();
                    auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username);
                    ReviewRelationMaster rrm = new ReviewRelationMaster();
                    string page = "prelim";
                    rrm.Description = page + preliminary.PreliminaryID;
                    db.ReviewRelationMasters.Add(rrm);
                    db.SaveChanges();
                }
                TempData["message"] = "Preliminary successfully created!";
                return(RedirectToAction("Index"));
            }



            return(View(preliminary));
        }
Пример #21
0
        public ActionResult AutocompleteCIA(string term)
        {
            var users = HelperController.getUsersByRole("CIA");

            return(Autocomplete(users, term));
        }
        public ActionResult Update(string submit, [Bind(Include = "PreliminaryID,Type,Status,NomorPreliminarySurvey,Date_Start,Date_End,ReviewMasterID,ActivityID,EmployeeID,EngagementID,PICID,SupervisorID,TeamLeaderID,MemberID")] Preliminary preliminary, IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                int i = 0;
                HttpServerUtilityBase server       = Server;
                List <string>         newFilesName = new List <string>();
                List <string>         paths        = new List <string>();
                UrlHelper             url          = Url;
                List <string>         keepImages   = new List <string>();
                //object imagesTemp = Session["Images"];
                var sessionImages = Session["Images"];
                if (sessionImages != null)
                {
                    Array arrKeepImages = (Array)sessionImages;
                    foreach (var arrKeepImage in arrKeepImages)
                    {
                        keepImages.Add(arrKeepImage.ToString());
                    }
                    var           pre          = preliminary.NomorPreliminarySurvey.Split('/')[0];
                    var           no           = preliminary.NomorPreliminarySurvey.Split('/')[1];
                    bool          getFiles     = filesTransact.getFiles(pre + no, out newFilesName, out paths, url, server);
                    List <string> deletedFiles = paths.Except(keepImages).ToList();
                    bool          deleteFiles  = filesTransact.deleteFiles(deletedFiles, server);

                    i = filesTransact.getLastNumberOfFiles(pre + no, server);
                }
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        i = i + 1;
                        var  pre     = preliminary.NomorPreliminarySurvey.Split('/')[0];
                        var  no      = preliminary.NomorPreliminarySurvey.Split('/')[1];
                        bool addFile = filesTransact.addFile(pre + no, i, file, server);
                    }
                }
                Session.Remove("Images");

                string user = submit.Contains("By")  ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    preliminary.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status);
                }
                else if (submit == "Approve")
                {
                    preliminary.Status = "Approve";
                    Walktrough walktrough = new Walktrough();
                    walktrough.PreliminaryID = preliminary.PreliminaryID;
                    walktrough.ActivityID    = preliminary.ActivityID;
                    walktrough.Date_Start    = preliminary.Date_Start;
                    walktrough.Date_End      = preliminary.Date_End;
                    walktrough.Status        = "Approve";
                    db.Walktroughs.Add(walktrough);
                }
                else if (submit == "Submit For Review By" + user)
                {
                    preliminary.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    preliminary.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = preliminary.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailPrelim(userToSentEmail, preliminary);
                        }
                        else
                        {
                            sentEmailPrelim(preliminary, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = preliminary.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailPrelim(userToSentEmail, preliminary);
                        }
                        else
                        {
                            sentEmailPrelim(preliminary, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = preliminary.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailPrelim(userToSentEmail, preliminary);
                        }
                        else
                        {
                            sentEmailPrelim(preliminary, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = preliminary.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailPrelim(userToSentEmail, preliminary);
                        }
                        else
                        {
                            sentEmailPrelim(preliminary, user.Trim());
                        }
                    }
                }
                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                Preliminary oldData = db.Preliminaries.AsNoTracking().Where(p => p.PreliminaryID.Equals(preliminary.PreliminaryID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", preliminary.PreliminaryID, "Preliminary", oldData, preliminary, username);
                db.Entry(preliminary).State = EntityState.Modified;
                db.SaveChanges();
                TempData["message"] = "Preliminary successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", preliminary.ActivityID);
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "Type", preliminary.EmployeeID);
            return(View(preliminary));
        }
        public ActionResult UpdateRCMStatus(int rcmId, string status, int walktroughId, int prelimID)
        {
            //var RCM = db.RiskControlMatrixs.Find(rcmId);
            string username = User.Identity.Name;

            db.Configuration.ProxyCreationEnabled = false;
            RiskControlMatrix oldData = db.RiskControlMatrixs.AsNoTracking().Where(p => p.RiskControlMatrixID.Equals(rcmId)).FirstOrDefault();
            RiskControlMatrix risk    = db.RiskControlMatrixs.Find(rcmId);
            Preliminary       prelim  = db.Preliminaries.Find(prelimID);

            if (status == "Draft")
            {
                risk.Status = HelperController.GetStatusSendback(db, "RCM", risk.Status);
            }
            else
            {
                risk.Status = status;
            }


            auditTransact.CreateAuditTrail("Update", risk.WalktroughID, "RiskControlMatrix", oldData, risk, username);
            db.Entry(risk).State = EntityState.Modified;
            db.SaveChanges();
            if (status.Contains("Pending for Approve"))
            {
                string user            = status.Split('y')[1];
                string userToSentEmail = String.Empty;
                if (user.Trim() == "CIA")
                {
                    userToSentEmail = prelim.PICID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailRCM(userToSentEmail, risk, walktroughId);
                    }
                    else
                    {
                        sentEmailRCM(risk, user.Trim(), walktroughId);
                    }
                }
                else if (user.Trim() == "Pengawas")
                {
                    userToSentEmail = prelim.SupervisorID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailRCM(userToSentEmail, risk, walktroughId);
                    }
                    else
                    {
                        sentEmailRCM(risk, user.Trim(), walktroughId);
                    }
                }
                else if (user.Trim() == "Ketua Tim")
                {
                    userToSentEmail = prelim.TeamLeaderID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailRCM(userToSentEmail, risk, walktroughId);
                    }
                    else
                    {
                        sentEmailRCM(risk, user.Trim(), walktroughId);
                    }
                }
                else if (user.Trim() == "Member")
                {
                    userToSentEmail = prelim.MemberID;
                    if (userToSentEmail != null)
                    {
                        sentSingleEmailRCM(userToSentEmail, risk, walktroughId);
                    }
                    else
                    {
                        sentEmailRCM(risk, user.Trim(), walktroughId);
                    }
                }
            }

            var        listStatus           = db.RiskControlMatrixs.Where(p => p.WalktroughID.Equals(walktroughId)).Select(p => new { RCMStatus = p.Status }).ToList();
            SelectList listStatusSelectList = new SelectList(listStatus, "RCMStatus", "RCMStatus", 0);

            return(Json(listStatusSelectList));
        }
        public ActionResult Create(string submit, string requester, [Bind(Include = "ConsultingRequestID,NoRequest,NoSurat,RequesterID,Date_Start,EvaluationResult,Status,ActivityStr")] ConsultingRequest consultingRequest, IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                string username           = User.Identity.Name;
                IQueryable <Employee> emp = db.Employees.Where(p => p.Name.Equals(requester));
                int empId = 0;
                if (emp.Count() > 0 || emp != null)
                {
                    empId = emp.Select(p => p.EmployeeID).FirstOrDefault();
                }

                consultingRequest.RequesterID = empId;

                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    consultingRequest.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    consultingRequest.Status = HelperController.GetStatusSendback(db, "Consulting Request", consultingRequest.Status);
                }
                else if (submit == "Submit For Review By" + user)
                {
                    consultingRequest.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    consultingRequest.Status = "Pending for Approve by" + user;
                    string          baseUrl    = Request.Url.GetLeftPart(UriPartial.Authority);
                    List <string>   CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
                    List <Employee> CIAEmpList = new List <Employee>();
                    if (CIAUserIds.Count() > 0)
                    {
                        var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList();
                        foreach (var CIAUser in CIAUsers)
                        {
                            Employee empl = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault();

                            string emailContent = "Dear {0}, <BR/><BR/>Consulting Request : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Consulting Request\">link</a> to show the Consulting Request.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                            string urlRequest   = baseUrl + "/ConsultingRequests/Details/" + consultingRequest.ConsultingRequestID;
                            emailTransact.SentEmailApproval(empl.Email, empl.Name, consultingRequest.NoRequest, emailContent, urlRequest);
                        }
                    }
                }

                HttpServerUtilityBase server = Server;
                //var createFile = UploadFile(1234);
                int i = 0;
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        i = i + 1;
                        bool addFile = filesTransact.addFile(consultingRequest.NoRequest.Replace("/", ""), i, file, server);
                    }
                }

                db.ConsultingRequests.Add(consultingRequest);
                db.SaveChanges();
                ConsultingRequest conreq = new ConsultingRequest();
                auditTransact.CreateAuditTrail("Create", consultingRequest.ConsultingRequestID, "Consulting Request", conreq, consultingRequest, username);
                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "draft";
                rrm.Description = page + consultingRequest.ConsultingRequestID;
                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();
                TempData["message"] = "Request successfully created!";
                return(RedirectToAction("Index"));
            }

            //ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", consultingRequest.ActivityID);
            return(View(consultingRequest));
        }