<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Document_Operations.aspx.vb" Inherits="FinIQWebApp.Document_Operations" MasterPageFile="~/FiniqAppMasterPage.Master" %>

<%@ Register Src="~/PitchBookSubMenu.ascx" TagPrefix="uc1" TagName="PitchBookSubMenu" %>


<asp:Content runat="server" ID="CPmain" ContentPlaceHolderID="MainContent">
      <asp:ScriptManagerProxy ID="ScriptManagerProxy11" runat="server">
    </asp:ScriptManagerProxy>
    <script>
        function DocList(id, name, tag, validfrom, validtill, usedincount) {
            if (usedincount == 0) {
                var str = '<tr><td><input id="' + id + '" type="checkbox" name="read1" ></td><td align="center" style="padding: 5px;width:50px;"><a href="#">' + usedincount + '</td><td id="' + id + '" class="BookName" onclick="BookDetails(this,\'' + tag + '\',\'' + validfrom + '\',\'' + validtill + '\')" style="padding: 5px;width:200px;">' + name + '</td><td style="padding: 5px; width:200px;">' + tag + '</td><td  style="padding: 5px; width:80px;">' + validfrom + '</td><td style="padding: 5px; width:80px;">' + validtill + '</td></tr>';
            } else {
                //var str = '<tr><td><input id="' + id + '" type="checkbox" name="read1" disabled></td><td align="center"><a href="#">' + usedincount + '</td><td id="' + id + '" class="BookName" onclick="BookDetails(this,\'' + tag + '\',\'' + validfrom + '\',\'' + validtill + '\')">' + name + '</td><td>' + tag + '</td><td  style="padding: 5px;">' + validfrom + '</td><td>' + validtill + '</td></tr>';
                var str = '<tr><td><input id="' + id + '" type="checkbox" name="read1"></td><td align="center"><a href="#">' + usedincount + '</td><td id="' + id + '" class="BookName" onclick="BookDetails(this,\'' + tag + '\',\'' + validfrom + '\',\'' + validtill + '\')">' + name + '</td><td>' + tag + '</td><td  style="padding: 5px;">' + validfrom + '</td><td>' + validtill + '</td></tr>';
            }
            $('#table1').append(str);
        }
    </script>
    <style>
        .BookName 
        {
            cursor: pointer;
            text-decoration: underline;
            color: blue;
            width:333px;
        }
      body
        {
        	font-family: verdana;
        	font-size:12px;
        }
        .Username
        {
            border-bottom: 1px solid #DDDDDD;
            border-collapse:collapse;
            font: normal 12px verdana;
            background-color: #FFFFFF;
            cursor:pointer;
        }
        .commonTbl
        {
            border-collapse: collapse;
        }
        .commonTbl td
        {
            padding: 4px;
        }
        #table1 td
        {
        	/*background-color:#FFFFFF;*/ /*Removed by Anjali T for black theme INT1FIN47-357*/
        	border: solid 1px #DDDDDD;
        	border-collapse:collapse;
        	padding:8px;
        }
        #table1 td:first-child 
        {
        	padding:5px;
        }
        #table2 td
        {
        	/*background-color:#FFFFFF;*/ /*Removed by Anjali T for black theme INT1FIN47-357*/
        	border: solid 1px #DDDDDD;
        	border-collapse:collapse;
        }
        th 
        {
        	color:#333333 !important;
        	/*background-color:#FFFFFF !important;*/ /*Removed by Anjali T for black theme INT1FIN47-357*/
        	border: solid 1px #DDDDDD;
        	border-collapse:collapse;
        }
        
        #toggle
        {
            background-image: url(  "img/arrowIn.png" );
            height: 740px;
            width: 10px;
            border: 1px solid #F7F7F7;
            border-collapse:collapse;
            border-radius: 5px;
            float: left;
            cursor: pointer;
        }
        #toggle:hover
        {
            box-shadow: 0 3px 10px #2b56af;
            background-color: #f2f2f2;
        }
    
    .SlideToggleDocShow
        {
            float: left;
            overflow-y: scroll;
            border: 1px solid #DDDDDD;
            border-collapse:collapse;
            padding: 6px;
            background-color: #FFFFFF;
            width: 300px;
            height: 730px;
        }
        .SearchIcon
        {
            height: 20px;
            width: 20px;
        }

    .permission{

	    margin-top: 10px;
	    height:730px;
	        width: 1587px;

    }
    #tablecon1 
    {
    	border: 1px solid #DDDDDD;
        border-collapse:collapse;
        padding-top:6px;
    	float:left;
    	height:730px;
    	max-height:730px;
    	/*background-color:#FFF;*/ /*Removed by Anjali T for black theme INT1FIN47-357*/
    	overflow-y:auto;
    	width:auto;
    	border-radius: 5px;
    	 -moz-box-shadow: 4px 4px 4px #d5d4d4;
            -webkit-box-shadow: 4px 4px 4px #d5d4d4;
             box-shadow: 4px 4px 4px #dddddd;
            -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=1, Direction=135, Color='#dddddd')";
            filter: progid:DXImageTransform.Microsoft.Shadow(Strength=1, Direction=135, Color='#dddddd');
        font-family: Verdana !important;
    }
    #tablecon2 
    {
    	height:300px;
    	max-height:730px;
    	width:600px;
    	float:right;
    	background-color:#FFF;
    	border-radius: 5px;
    	border: 1px solid #DDDDDD;
        border-collapse:collapse;
	    padding-top: 6px;
	     -moz-box-shadow: 4px 4px 4px #d5d4d4;
            -webkit-box-shadow: 4px 4px 4px #d5d4d4;
             box-shadow: 4px 4px 4px #dddddd;
            -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#dddddd')";
            filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#dddddd');
        font-family: Verdana !important;
    }
    
    #table1{
	    float:left;
	    border:solid 1px #DDDDDD;
	    border-collapse:collapse;
	   
    }
    #table2{
	    float:right;
	    border:solid 1px #DDDDDD;
	    border-collapse:collapse;
    }

    .MenuControlNoHover a:hover
        {
            color: #F8F7F4;
        }
         #menuContainer a:link, #menuContainer a:hover, #menuContainer a:visited
        {
            width: 120px;
            border-collapse: collapse;
            vertical-align: middle;
            padding: 5px;
            text-align: center;
            color: #888888;
        }

        #menuContainer
        {
	        background-color: #F7F7F7;
	        /*width:1850px;*/
	        height:24px;
	         padding: 2px;
        }
        
         
         .MenuItemStyleParent, .MenuItemStyleParent a:link, .MenuItemStyleParent a:hover, .MenuItemStyleParent a:visited
        {
             
            color: #00ADEF !important;
         	background-color:#F7F7F7;
         	Font:normal 12px/24px verdana;
         	
            
        }
        
        .MenuItemStyleParent a:link, .MenuItemStyleParent a:hover, .MenuItemStyleParent a:visited 
        {
        	padding-left:12px;
        }
        
         .DynamicMenuItemStyle, .DynamicMenuItemStyle a:link, .DynamicMenuItemStyle a:hover, .DynamicMenuItemStyle a:visited
        {
             
            border-right: none 0px #4d80af !important;  
            border-collapse:collapse;                    
            color: #00ADEF !important;
            background-color:#F5F5F5;
            Font:normal 12px/18px verdana;
            width:130px;
            height:28px;
            border-bottom:solid 1px #FFFFFF;
            padding-left:5px;
            
        }
        .DynamicMenuItemStyle 
        {
        	border-bottom:solid 1px #DDDDDD;
        }
        .FinIQ_lblFormName, .FinIQ_lblFormName span, .FinIQ_lblFormName span div 
        {
        	display:none;
        }
        #permissionTables 
        {
        	width:1850px;
        	text-align:center;
        }
        h1 
        {
        	font-size:20px !important;
        	color: #6e6f72;
        }
        h2
        {
        	font-size:14px !important;
        	color: #6e6f72;
        }
        b
        {
        	color: #6e6f72;
        }
        #Status 
        {
        	color:Green;
        	height:3px;
        }
        #SearchBook
        {
            width:788px;
            margin-top:6px;
        	margin-bottom:6px;
            margin-top:6px;
        	margin-bottom:6px;
                margin-left: 9px;
        }
        #SearchFile
        {
        	width:550px;
        }
        input[type=button]
        {
        	border:none;
            font:normal 11px verdana;
            background-color:#DDDDDD;
            height:20px;
            color:#333333;
            cursor:pointer;
            margin:20px;
        }
        #SaveBlock 
        {
        	width:1670px;
        	text-align:center;
        	margin-top:20px;
        }
        #SearchText 
        {
        	width:340px;
        }
        #Username 
        {
        	font-size:12px !important;
        }
         #saveButton
        {
        	border:none;
            font:normal 11px/24px verdana;
            background-color:#E7E7E7;
            color:#333333;
            cursor:pointer;
            margin-top:6px;
            width:120px;
            height:30px;
            background-image:url("img/Save.png");
            background-repeat:no-repeat;
            width:120px;
            margin-left:0px;
            background-position: 5% 20%; 
        }
        #DetailsForm 
        {
        	margin-left:50px;
        	margin-top:19px;
        }
        #DetailsTable td
        {
        	padding:10px;
        }
        .DetailsInput 
        {
        	width:300px;
        }
        .validTo
        {
        	width:300px;
        }
        .validFrm 
        {
        	width:300px;
        }
             #menuContainer ul
        {
            background-color: none !important;
        }

        #ctl00_MainContent_PitchBookSubMenu_Menu1 ul li a:link:hover
        {
            background-color: #DDDDDD !important;
        }
</style>



<%--    <div id="menuContainer">
           <%--   <uc1:PitchBookSubMenu runat="server" id="PitchBookSubMenu" />

    </div>--%>
    
    <div id="permissionTables">
    <h1>Document Operations</h1>
    <h2><span id="Username"></span></h2>
    <p id="Status"></p>
    
    <div id = "permission" class = "permission">
        
        <div id="tablecon1">
        <b></b>
        <table class="">
            <tr>
                <td>
                    <input type="text" id="SearchBook" placeholder="Search Document" />
                </td>
                <td>
                    <img src="img/search.png" class="SearchIcon" />
                </td>
                <td>
                    <input id="DeleteButton" type="button" value="Delete Selected" onclick="DeleteDocuments()"/>
                </td>
            </tr>
        </table>
        <table id = "table1" border = "1" padding = "100px">
        <tr>
            <th style="width:27px;"> <input id="SelectAll" type="checkbox"></th>
            <th style="padding: 5px;width:50px;">Used in (No. of blocks)</th>
            <th style="padding: 5px;width:100px;">Document Name</th>
            <th style="padding: 5px; width:200px;">Book Tag</th>
            <th style="padding: 5px; width:80px;">Valid From</th>
            <th style="padding: 5px; width:80px;">Valid Till</th>
        </tr>
        </table>
        </div>
        
        <div id="tablecon2">
        <b>Document Details</b>
        <div id="DetailsForm">
        <table id="DetailsTable">
        <tr>
        <td>Document Name</td><td><input id="NewBookName" type="text" class="DetailsInput"/></td>
        </tr>
        <tr>
        <td>Tag</td><td><input id="NewTagName" type="text" class="DetailsInput" /></td>
        </tr>
        <tr>
             <td>
           <%-- <asp:Label ID="validFrm" runat="server" Text="Valid From"></asp:Label>--%> Valid From</td>
          <td><input id="validFrmTxt" type="text"  Class="validFrm"/> <%--<input type="text" id="validFrmTxt" /></td></tr>--%>
              <%--<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="img/calender.png" />
            --%>
            
              <tr>
             <td>
              <%--<asp:Label ID="validTo" runat="server" Text="Valid To"></asp:Label>--%> Valid Till</td>
              <td>
                  <input id="validToTxt" type="text"  Class="validTo"/>
            </td></tr>
          
              <%--<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="img/calender.png" />--%>
            
              <tr>
                     <td></td><td><input id="saveButton" type="button" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Save Changes" onclick="SaveChanges()" /></td>
                  </tr>
        <%--<tr>
        <td><input id="DeleteButton" type="button" value="Delete Selected Documents" onclick="DeleteDocuments()"/></td><td><input id="saveButton" type="button" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Save Changes" /></td>
        </tr>--%>
        </table>
        </div>
        </div>
        
        
    </div>
        
    </div>

    
    
    <script>
        var cntslide = 0;
        var lastobject;
        var DocId;
        var TrObject;
        $("#SaveBlock").css("visibility", "hidden");
        //            if(cntslide == 1){
        //					$('.SlideToggleDocShow').hide("slide", {direction: "left"},1000);
        //					cntslide++;	
        //			}


        //			function SelectUser(User,id,object) {
        //			    if (typeof lastobject != "undefined") {
        //                            lastobject.style.backgroundColor = '#FFFFFF';
        //                            // do stuff
        //                }
        //			    $(".permission").css("visibility", "visible");
        //			    $("#SaveBlock").css("visibility", "visible");
        //			    $("#Status").empty();
        //			    $(".permission").find("input[type=checkbox]:checked").prop('checked', false);
        //			    UserId = id;
        //			    lastobject = object;
        //			    object.style.backgroundColor = '#F7F7F7';
        //			    $("#Username").text("User Name: " + User);
        //			    PageMethods.GetUserBooks(id,UpdateBooks);
        //			    PageMethods.GetUserDocs(id,UpdateDocs);
        //			}
        //			
        //			function UpdateBooks(response) {
        //			    //alert(response);
        //			    var BookId;
        //			    var read;
        //			    var modify;
        //			    for (index = 0; index < response.length; ++index) {
        //                    var res = response[index];
        //                    var str = res.split("##");
        //                    BookId = str[0];
        //                    read = str[1];
        //                    modify = str[2];
        //                    if(read =="Yes") {
        //			            $("#read"+BookId).prop('checked', true);
        //			        }
        //			        if(modify =="Yes") {
        //			            $("#modify"+BookId).prop('checked', true);
        //			        }
        //                }
        //			    
        //			}
        //			
        //			function UpdateDocs(response) {
        //			    //alert(response);
        //			    var DocId;
        //			    var access;
        //			    for (index = 0; index < response.length; ++index) {
        //                    var res = response[index];
        //                    var str = res.split("##");
        //                    DocId = str[0];
        //                    access = str[1];
        //                    if(access =="Yes") {
        //			            $("#access"+DocId).prop('checked', true);
        //			        }
        //                }
        //			    
        //			}
        //			
        //			function SaveChanges() {
        //			    PageMethods.DeletePermission(UserId,SavePermission);
        //			}
        //			
        function DeleteDocuments() {
            $("#table1 tr ").each(function () {
                var $this = $(this);
                var Id = 0;
                var updateflag = 0;
                var access = "No";
                $(this).children("td").each(function () {
                    var tempId = $(this).attr("id");
                    if (typeof tempId !== "undefined") {
                        Id = tempId;
                        // do stuff
                    } else {
                        $(this).children("input").each(function () {
                            if ($(this).is(":checked")) {

                                var id = ($(this).attr("id"));
                                updateflag = 1;
                                $("#Status").text("Please Wait...");
                                $("#Status").css("color", "red");
                            } else {

                            }
                        });
                    }


                });
                if (updateflag == 1) {
                    PageMethods.DeleteDoc(Id, DeleteAck);
                }
                updateflag = 0;
            });

        }

        function DeleteAck(response) {
            $("#" + response).parent().parent().remove();
            $("#Status").text("Deleted Successfully");
            $("#Status").css("color", "green");

        }

        function SaveChanges() {
            
            PageMethods.SaveChanges(DocId, $("#NewBookName").val(), $("#NewTagName").val(), $("#validFrmTxt").val(), $("#validToTxt").val(), SaveAck);
        }

        function SaveAck(response) {
            
            $(TrObject).html($("#NewBookName").val());
            $(TrObject).next().html($("#NewTagName").val());
            $(TrObject).next().next().html($("#validFrmTxt").val());
            $(TrObject).next().next().next().html($("#validToTxt").val());
            $("#Status").text("Saved Successfully");
            $("#Status").css("color", "green");
            window.location.reload();
        }

        function BookDetails(Nametd, tag, ValidFrm, ValidTo) {
            $("#tablecon2").show();
            TrObject = Nametd;
            DocId = $(Nametd).attr('id');
            $("#NewBookName").val($(Nametd).text());
            $("#NewTagName").val(tag);
            $(".validFrm").val(ValidFrm);
            $(".validTo").val(ValidTo);
        }
        //			
        //			$("#toggle").click(function(){
        //				
        //				if(cntslide != 1){
        //					$('.SlideToggleDocShow').toggle('slide', {
        //						direction: 'left'
        //					}, 800, function(){ $('#toggle').fadeIn();});
        //				}
        //				var click = $(this).data('clicks');

        //				if (click) {
        //				    $('#toggle').css("background-image","url('img/arrowIn.png')");
        //					
        //				}else{
        //					$('#toggle').css("background-image","url('img/arrowOut.png')");
        //				}

        //				$(this).data('clicks', !click); // you have to set it
        //			
        //			});
        //			
        //            $(document).ready(function () {
        //			/* initially hide list items */
        //				   

        //				//$("#SearchText").on("keyup click input", function () {
        //				$("#SearchText").keyup( function () {
        //					if (this.value.length > 0) {
        //					  $(".Username").css("border-bottom","0px");
        //					  $(".commonTbl tr").hide().filter(function () {
        //					    return $(this).text().toLowerCase().indexOf($("#SearchText").val().toLowerCase()) != -1;
        //					  }).show();
        //					}
        //					else {
        //					  $(".commonTbl tr").show();
        //					  $(".Username").css("border-bottom","1px solid #2b56af");
        //					}
        //				});

        $("#SearchBook").keyup(function () {
            if (this.value.length > 0) {
                //					  $(".Username").css("border-bottom","0px");
                $("#table1 tr").not(':first').hide().filter(function () {
                    return $(this).text().toLowerCase().indexOf($("#SearchBook").val().toLowerCase()) != -1;
                }).show();
            }
            else {
                $("#table1 tr").show();
                //					  $(".Username").css("border-bottom","1px solid #2b56af");
            }
        });

        //				$("#SearchFile").keyup( function () {
        //					if (this.value.length > 0) {
        ////					  $(".Username").css("border-bottom","0px");
        //					  $("#table2 tr").not(':first').hide().filter(function () {
        //					    return $(this).text().toLowerCase().indexOf($("#SearchFile").val().toLowerCase()) != -1;
        //					  }).show();
        //					}
        //					else {
        //					  $("#table2 tr").show();
        ////					  $(".Username").css("border-bottom","1px solid #2b56af");
        //					}
        //				});
        //				$( ".permission" ).mousedown(function() {
        //                    $("#Status").empty();
        //                });
        ////				$("#SearchText").blur(function () {
        ////					$(".commonTbl tr").show();
        ////					$(".commonDiv").css("border-bottom","1px solid #2b56af");
        ////				});

        //			});

        $(document).ready(function () {
            $("#tablecon2").hide();
        })

</script>

</asp:Content>