Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. imageId="";
  3. canvasId="";
  4. phpUrl="";
  5. var mapid_glo="";
  6. var editFaid="";
  7. var deleteFAid="";
  8. arrphp = new Array();
  9. arrbtn =new Array();
  10. var arr= new Array();
  11. var yes="yes";
  12. var decIDlot="";
  13.  
  14. function getSelinHome(){
  15.     $("#theme").empty();
  16.     $.ajax({
  17.         type:"POST",
  18.         url:"include/function.php",
  19.         data:{"code":"getSelinHome"},
  20.         dataType:"json",
  21.         cache:false,
  22.         success:function(data){
  23.             var arr=data;
  24.             var sel=$("#theme");
  25.             for(var i=0;i<arr.length;i++){
  26.                 var option=$("<option>"+arr[i]+"</option>");
  27.                 sel.append(option);
  28.             }
  29.             sel.append("<option>new</option>");
  30.         }
  31.     });
  32. }
  33. function readyDec(td){
  34.     $("#declotspub").empty();
  35.     var id=$(td).attr("id");
  36.     var option=$("<option title='newDec'>deceased</option>");
  37.                             $("#declotspub").append(option);
  38.     $.ajax({
  39.                     type:"POST",
  40.                     url:"include/function.php",
  41.                     data:{code:"readyDec",id:id},
  42.                     dataType:"json",
  43.                     cache:false,
  44.                     success:function(data){
  45.  
  46.                         for(var i=0;i<data.length;i++){
  47.                             var option=$("<option title='"+data[i][0]+"'>"+data[i][1]+"</option>");
  48.                             $("#declotspub").append(option);
  49.                         }
  50.  
  51.                        
  52.                     }
  53.                 });
  54.  
  55. }
  56. function removePX(position){
  57.     var temp="";
  58.     for(var i=0;i<position.length;i++){
  59.         if(!isNaN(position.charAt(i))){
  60.             temp=temp+""+position.charAt(i);
  61.         }
  62.     }
  63.     return parseInt(temp);
  64. }
  65. function findDec(){
  66.     $("#conmap").animate({
  67.             scrollTop:0,
  68.             scrollLeft:0,
  69.  
  70.         },'slow');
  71.     $("#slider").slider('value',7);
  72.     $("#maptest").animate({zoom:"0.0"},1);
  73.     $(".selectelement").removeClass("selectelement");
  74.     var option=document.getElementById("resultdec").selectedIndex;
  75.     var id=$("#resultdec option:eq("+option+")").attr("title");
  76.     alert(id);
  77.     var position = $("#"+id).position();
  78.     var mapwidth=removePX($("#maptest").css("width"));
  79.     var mapheight=removePX($("#maptest").css("height"));
  80.     var top=0;
  81.     var left=0;
  82.     $.ajax({
  83.         type:"POST",
  84.         url:"include/function.php",
  85.         data:{code:"getTopLeft",id:id},
  86.         success:function(data){
  87.             var arr=data.split("+");
  88.  
  89.             top=parseInt(arr[0])-300;
  90.             left=parseInt(arr[1])-(removePX($("#conmap").css("width"))/2);
  91.          //top=Math.round((top/mapheight)*100);
  92.         //left=Math.round((left/mapwidth)*100);
  93.    
  94.             if(top <= 0){
  95.                 top=0;
  96.             }
  97.             if(left <= 0){
  98.                 left=0;
  99.             }
  100.     var div=document.getElementById("conmap");
  101.    
  102.     $("#"+id).find("img").addClass("selectelement");
  103.     $("#conmap").animate({
  104.             scrollTop:top+"%",
  105.             scrollLeft:left+"%",
  106.  
  107.         },'slow');
  108.         }
  109.     });
  110.     var div=document.getElementById("conmap");
  111.     //alert(top+" "+left+" "+$("#conmap").css("width"));
  112.     $("#"+id).find("img").addClass("selectelement");
  113.     $("#conmap").animate({
  114.             scrollTop:top+"px",
  115.             scrollLeft:left+"px",
  116.  
  117.         },'slow');
  118. }
  119. function findOwner(){
  120.     $("#conmap").animate({
  121.             scrollTop:0,
  122.             scrollLeft:0,
  123.  
  124.         },'slow');
  125.     $("#slider").slider('value',7);
  126.     $("#maptest").animate({zoom:"0.0"},1);
  127.     $(".selectelement").removeClass("selectelement");
  128.     var option=document.getElementById("resultOwner").selectedIndex;
  129.     var id=$("#resultOwner option:eq("+option+")").attr("title");
  130.     var position = $("#"+id).position();
  131.     var mapwidth=removePX($("#maptest").css("width"));
  132.     var mapheight=removePX($("#maptest").css("height"));
  133.  
  134.     var top=0;
  135.     var left=0;
  136.     $.ajax({
  137.         type:"POST",
  138.         url:"include/function.php",
  139.         data:{code:"getTopLeft",id:id},
  140.         success:function(data){
  141.             var arr=data.split("+");
  142.  
  143.             top=parseInt(arr[0])-300;
  144.             left=parseInt(arr[1])- (removePX($("#conmap").css("width"))/2);
  145.          //top=Math.round((top/mapheight)*100);
  146.         //left=Math.round((left/mapwidth)*100);
  147.    
  148.             if(top <= 0){
  149.                 top=0;
  150.             }
  151.             if(left <= 0){
  152.                 left=0;
  153.             }
  154.     var div=document.getElementById("conmap");
  155.    
  156.     $("#"+id).find("img").addClass("selectelement");
  157.     $("#conmap").animate({
  158.             scrollTop:top+"%",
  159.             scrollLeft:left+"%",
  160.  
  161.         },'slow');
  162.         }
  163.     });
  164.    
  165. }
  166. function loadFA(){
  167.    
  168.     $("#txtfa").val("");
  169.     $("#listFA li").remove();
  170.     $.ajax({
  171.         url:"include/function.php",
  172.         type:"POST",
  173.         data:{code:"getAllFA"},
  174.         dataType:"json",
  175.         cache:false,
  176.         success:function(data){
  177.             var arr="";
  178.             arr=data;
  179.            
  180.             for(var i=0;i<arr.length;i++){
  181.                 var li=$("<li class='list-group-item'>"+arr[i][1]+"<div class='pull-right'><button class='btn btn-success' onClick='editFA("+arr[i][0]+")'><span class='glyphicon glyphicon-edit' style='color:white;'></span></button>&nbsp;&nbsp;<button class='btn btn-danger' onClick='deleteFA("+arr[i][0]+")'><span class='glyphicon glyphicon-trash' style='color:white;'></span></button></div></li>");
  182.                 $("#listFA").append(li);
  183.             }
  184.         }
  185.     });
  186.  
  187. }
  188. function deleteFA(id){
  189.     $("#loaddeleteFA").click();
  190.     deleteFAid=id;
  191.    
  192. }
  193. function editFA(id){
  194.     editFaid=id;
  195.     $("#faText").removeClass("error");
  196.     $("#loadFA").click();
  197.     $.ajax({
  198.         url:"include/function.php",
  199.         type:"POST",
  200.         data:{code:"getFA",id:id},
  201.         success:function(data){
  202.             $("#faText").val(data);
  203.         }
  204.     });
  205.    
  206. }
  207. function Lot_Information(td){
  208.     //var ownerid="false";
  209.     //var decid="false";
  210.     readyDec(td);
  211.     lot_typeID=$(td).attr("id");
  212.     decIDlot=td;
  213.     $.ajax({
  214.         url:"include/function.php",
  215.         type:"POST",
  216.         data:{code:"getLotInfo",id:$(td).attr("id")},
  217.         success:function(data){
  218.            
  219.             if(data[0] == 0){
  220.                 // $("#imgowner").attr("src","img/700x450.gif");
  221.                 // $("#btnimgowner").val("NO RECORD");
  222.                 // $("#txtfname").val("NO RECORD");
  223.                 // $("#txtlname").val("NO RECORD");
  224.                 // $("#txtmname").val("NO RECORD");
  225.                 // $("#txtaddress").val("NO RECORD");
  226.                 // $("#txtemail").val("NO RECORD");
  227.                 // $("#txtnumber").val("NO RECORD");
  228.                  $("#ownerimg").attr("src","img/placeholder.png");
  229.                 $("#ownername").html("NO RECORD");
  230.                 $("#owneradd").html("NO RECORD");
  231.                 $("#ownercon").html("NO RECORD");
  232.                 $("#owneremail").html("NO RECORD");
  233.             }else{
  234.                 var arr=data.split("+");   
  235.                 // $("#imgowner").attr("src",arr[7]);
  236.                 // $("#btnimgowner").val("");
  237.                 // $("#txtfname").val(arr[1]);
  238.                 // $("#txtlname").val(arr[2]);
  239.                 // $("#txtmname").val(arr[3]);
  240.                 // $("#txtaddress").val(arr[5]);
  241.                 // $("#txtemail").val(arr[4]);
  242.                 // $("#txtnumber").val(arr[6]);
  243.  
  244.                 $("#ownerimg").attr("src",arr[7]);
  245.                 $("#ownername").html(arr[1]+" "+arr[3]+" "+arr[2]);
  246.                 $("#owneradd").html(arr[5]);
  247.                 $("#ownercon").html(arr[6]);
  248.                 $("#owneremail").html(arr[4]);
  249.                 ownerid=arr[0];
  250.             }
  251.            
  252.  
  253.         }
  254.     });
  255.    
  256.     // $.ajax({
  257.     //  url:"include/function.php",
  258.     //  type:"POST",
  259.     //  data:{code:"getLotInfoDec",id:$(td).attr("id")},
  260.     //  success:function(data){
  261.            
  262.     //      if(data[0] == 0){
  263.     //          // $("#imgdeceased").attr("src","img/700x450.gif");
  264.     //          // $("#btnimgdeceased").val("");
  265.     //          // $("#fnamedec").val("");
  266.     //          // $("#lnamedec").val("");
  267.     //          // $("#mnamedec").val("");
  268.     //          // $("#birthdec").val("");
  269.     //          // $("#deathdec").val("");
  270.     //          // $("#burialdec").val("");
  271.  
  272.                 $("#decimg").attr("src","placeholder.png");
  273.                 $("#decname").html("NO RECORD");
  274.                 $("#decbirth").html("NO RECORD");
  275.                 $("#decdeath").html("NO RECORD");
  276.                 $("#decburial").html("NO RECORD");
  277.     //      }else{
  278.     //          var arr=data.split("+");   
  279.     //          // $("#imgdeceased").attr("src",arr[7]);
  280.     //          // $("#btnimgdeceased").val("");
  281.     //          // $("#fnamedec").val(arr[1]);
  282.     //          // $("#lnamedec").val(arr[2]);
  283.     //          // $("#mnamedec").val(arr[3]);
  284.     //          // $("#deathdec").val(arr[5]);
  285.     //          // $("#birthdec").val(arr[4]);
  286.     //          // $("#burialdec").val(arr[6]);
  287.  
  288.     //          $("#decimg").attr("src",arr[7]);
  289.     //          $("#decname").html(arr[1]+" "+arr[3]+" "+arr[2]);
  290.     //          $("#decbirth").html(arr[4]);
  291.     //          $("#decdeath").html(arr[5]);
  292.     //          $("#decburial").html(arr[6]);
  293.     //          decid=arr[0];
  294.     //      }
  295.            
  296.  
  297.     //  }
  298.     // });
  299.     $( "#dialog-confirm" ).dialog({
  300.                               resizable: true,
  301.                               width:800,
  302.                               modal: true,
  303.                            
  304.     });
  305.  
  306.    
  307. }
  308. function clickLot(id){
  309.     $(".divselect").removeClass("divselect");
  310.     $(".tblblocksel").removeClass("tblblocksel");
  311.     $("#"+id).find("table").addClass("tblblocksel");
  312.     $("#"+id).addClass("divselect");
  313.     //tdid=$(td).attr("id");
  314.     //$("#"+tdid+":parent").zoomTarget();
  315.     //$(td).zoomTo({targetsize:0.75, duration:600});
  316.         //evt.stopPropagation();
  317. }
  318. function loadGrid(mapw,maph,table){
  319.     //var w=$("#maptest").width();
  320.     //var h=$("#maptest").height();
  321.     var l=parseInt(maph)/900;
  322.     var w=parseInt(mapw)/900;
  323.     if(l == 0){l=1;}
  324.     if(w == 0){w=1;}
  325.     lmap=l;
  326.     wmap=w;
  327.     //alert(l+w);  
  328.     $("#maptest").empty();
  329.     //var table=$("<table id='tblmap'  border='1' style='position:absolute;'></table>");
  330.      //w=w+mapw;
  331.      //h=h+maph;
  332.     //$("#maptest").css({"width":mapw+"px","height":maph+"px"});
  333.     //var w=Math.round($("#maptest").width()/30);
  334.     //var h=Math.round($("#maptest").height()/30);
  335.     //alert($("#maptest").height());
  336.     /*for(var i=0;i<30*w;i++){
  337.         var tr=$("<tr></tr>");
  338.         for(var x=0;x<30*l;x++){
  339.             var td=$("<td onmouseover='tdover(this)' onClick='tool(this)' onmouseout='tdout(this)' style='width:30px;height:30px;' id='tr"+i+"td"+x+"'></td>");
  340.             tr.append(td);
  341.         }
  342.         table.append(tr);
  343.     }
  344.     $("#maptest").append(table);*/
  345. }
  346. function loadElement(top,left,width,height,img,classes,title,id){
  347.     if(classes == "elementtext"){
  348.         var div=$("<div  id='"+id+"'></div>");
  349.         div.css({"top":top+"px","left":left+"px","position":"absolute","width":width+"px","height":height+"px"});
  350.         div.addClass(classes);
  351.         $.ajax({
  352.             url:"include/function.php",
  353.             type:"POST",
  354.             data:{code:"getText",id:id},
  355.             success:function(data){
  356.                 div.append("<p style='color:#fff;'>"+data+"</p>");
  357.             }
  358.         })
  359.         $("#maptest").append(div); 
  360.     }else if(title != "block"){
  361.             var div=$("<div id='"+id+"'></div>");
  362.         div.css({"top":top+"px","left":left+"px","position":"absolute","width":width+"px","height":height+"px"});
  363.         //div.draggable({ containment: "#maptest", scroll: false,snap:true,grid:[30,30],cursor:"none"});
  364.         div.addClass(classes);
  365.         if(title != "other" && title != "block" && title !="walknon" && title !="waynon"){
  366.             //div.resizable({grid: 30,containment: "#maptest"});   
  367.            
  368.         }
  369.         div.append("<img src='img/mapimg/"+img+".png' style='width:100%;height:100%;' />");
  370.         $("#maptest").append(div); 
  371.     }else{
  372.         $.ajax({
  373.             url:"include/function.php",
  374.             type:"POST",
  375.             data:{code:"getElementLot",id:id},
  376.             dataType:"json",
  377.             cache:false,
  378.             success:function(data){
  379.                 var arr=data;
  380.                 var div=$("<div id='"+id+"'></div>");
  381.                 div.css({"top":top+"px","left":left+"px","position":"absolute","width":(width)+"px","height":(height)+"px"});
  382.                 //div.draggable({ containment: "#maptest", scroll: false,snap:true,grid:[30,30]});
  383.                 div.addClass("elementblock");
  384.                 var arrtemp=arr.length-1;
  385.  
  386.                 var row=parseInt(arr[arrtemp][1]);
  387.                 var col=parseInt(arr[arrtemp][2])/row;
  388.                 var index=0;
  389.                
  390.                 var tbl=$("<table  style='position:absolute;' class='tblblock'  onClick='clickLot("+id+")'></table>");
  391.                 for(var i=0;i<row;i++){
  392.                     var tr=$("<tr></tr>");
  393.                     for(var x=0;x<col;x++){
  394.                         if(arr[index][0] != "remove lot"){
  395.                             var td=$("<td id='"+arr[index][3]+"' ondblClick='Lot_Information(this)'></td>");
  396.                             td.append("<img src='img/mapimg/"+arr[index][0]+".png' style='width:30px;height:30px;'/>");
  397.                                
  398.                         }else{
  399.                             var td=$("<td></td>");
  400.                         }
  401.                         tr.append(td);
  402.                         index++;
  403.                        
  404.                     }
  405.                     tbl.append(tr);
  406.                 }
  407.                 //div.draggable({ containment: "#maptest", scroll: false,snap:true,grid:[30,30],cursor:"none"});
  408.                 div.append(tbl);
  409.                 $("#maptest").append(div);
  410.             }
  411.         });
  412.        
  413.     }
  414.    
  415.  
  416. }
  417. function updateStaff(id){
  418.     $("#btnimgstaff").val("");
  419.     $("#txtfnamestaff").val("");
  420.     $("#txtlaststaff").val("");
  421.     $("#txtmiddlestaff").val("");
  422.     $("#txtbranchstaff").val("");
  423.     $("#txtpositionstaff").val("");
  424.     $("#imgstaff").attr("src","img/700x450.gif");
  425.     $.ajax({
  426.         url:"include/function.php",
  427.         type:"POST",
  428.         data:{code:"getStaffbyID",id:id},
  429.         dataType:"json",
  430.         cache:false,
  431.         success:function(data){
  432.             var arr=data;
  433.             $("#txtfnamestaff").val(arr[1]);
  434.             $("#txtlaststaff").val(arr[0]);
  435.             $("#txtmiddlestaff").val(arr[2]);
  436.             $("#txtpositionstaff").val(arr[3]);
  437.             $("#txtbranchstaff").val(arr[5]);
  438.             $("#imgstaff").attr("src",arr[4]);
  439.         }
  440.     });
  441.    
  442.     $( "#dialog-updatestaff" ).dialog({
  443.                 resizable: true,
  444.                 height:500,
  445.                 width:700,
  446.                 modal: true,
  447.                 buttons: {
  448.  
  449.                     Update: function() {
  450.                         var fname=$("#txtfnamestaff").val();
  451.                         var lname=$("#txtlaststaff").val();
  452.                         var branch=$("#txtbranchstaff").val();
  453.                         var mname=$("#txtmiddlestaff").val();
  454.                         var position=$("#txtpositionstaff").val();
  455.                         if(fname != "" && lname != "" && mname != "" && position != "" && branch != ""){
  456.                             var form=new FormData(document.getElementById('updatestaff'));
  457.                             form.append("code","updateStaff");
  458.                             form.append("id",id);
  459.                             $.ajax({
  460.                                 url:"include/function.php",
  461.                                 type:"POST",
  462.                                 data:form,
  463.                                 contentType: false,       // The content type used when sending data to the server.
  464.                                 cache: false,             // To unable request pages to be cached
  465.                                 processData:false,        // To send DOMDocument or non processed data file it is set to false
  466.                                 success:function(data){
  467.                                     $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data+"");
  468.                                     $( "#dialog-confirm" ).dialog({
  469.                                         resizable: true,
  470.                                         height:266,
  471.                                         width:759,
  472.                                         modal: true,
  473.                                         buttons: {
  474.                                             Close: function() {
  475.  
  476.                                                 $( this ).dialog( "close" );
  477.                                             }
  478.                                         }
  479.                                     });
  480.                                 getStaff();
  481.                                 }
  482.                             });
  483.                             $("#btnimgstaff").val("");
  484.                             $("#txtfnamestaff").val("");
  485.                             $("#txtlaststaff").val("");
  486.                             $("#txtmiddlestaff").val("");
  487.                             $("#txtpositionstaff").val("");
  488.                             $("#txtbranchstaff").val("");
  489.                             $("#imgstaff").attr("src","img/700x450.gif");
  490.                             //getStaff();
  491.                             $( this ).dialog( "close" );
  492.                         }else{
  493.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error! You need to Fillup all of the information.");
  494.                             $( "#dialog-confirm" ).dialog({
  495.                                 resizable: true,
  496.                                 height:180,
  497.                                 width:300,
  498.                                 modal: true,
  499.                                 buttons: {
  500.                                     Close: function() {
  501.                                         $( this ).dialog( "close" );
  502.                                     }
  503.                                 }
  504.                             });
  505.                         }
  506.                        
  507.                     },
  508.                     Close:function(){
  509.                         $( this ).dialog( "close" );
  510.                     }
  511.                    
  512.                 }
  513.             });
  514.  
  515. }
  516. function getStaff(){
  517.     //var indx=$("#divaddstaff > div").length;
  518.     $("#divaddstaff > div:gt(0)").remove();
  519.     $.ajax({
  520.         url:"include/function.php",
  521.         type:"POST",
  522.         data:{code:"getStaff"},
  523.         dataType: "json",
  524.         cache: false,
  525.         success:function(data){
  526.  
  527.             var arr= data;
  528.             //alert(arr.length);
  529.                 for(var i=0;i<arr.length;i++){
  530.             $("#divaddstaff").append($("<div class='col-md-4' style='height:430px;' id='divstaff"+arr[i][0]+"'><button class='btn btn-danger pull-right' onClick='deleteStaff("+arr[i][0]+")'>X</button><div class='thumbnail text-center btn' onClick='updateStaff("+arr[i][0]+")'><img src='"+arr[i][5]+"' style='height:300px; width:350px;' class='img-responsive img-rounded'><div class='caption'><h3>"+arr[i][1]+","+arr[i][2]+" "+arr[i][3]+".<br /><small>"+arr[i][6]+"</small><br /><small>"+arr[i][4]+"</small></h3></div></div></div>"));
  531.             }
  532.             $("#divaddstaff").append("<div class='col-md-4' ><div class='thumbnail text-center'><button class='btn btn-primary ' onClick='addStaff()' style='height:345px;width:100%;'><span style='font-size:250px;'>+</span></button></div></div>");
  533.  
  534.         }
  535.     });
  536.    
  537.    
  538. }
  539. function addStaff(){
  540.         $("#btnimgstaffadd").val("");
  541.         $("#txtfnamestaffadd").val("");
  542.         $("#txtlaststaffadd").val("");
  543.         $("#txtmiddlestaffadd").val("");
  544.         $("#txtbranchstaffadd").val("");
  545.         $("#txtpositionstaffadd").val("");
  546.         $("#imgstaffadd").attr("src","img/700x450.gif");
  547.         $( "#dialog-addstaff" ).dialog({
  548.                 resizable: true,
  549.                 height:500,
  550.                 width:700,
  551.                 modal: true,
  552.                 buttons: {
  553.  
  554.                     Add: function() {
  555.                         var fname=$("#txtfnamestaffadd").val();
  556.                         var lname=$("#txtlaststaffadd").val();
  557.                         var mname=$("#txtmiddlestaffadd").val();
  558.                         var branch=$("#txtbranchstaffadd").val();
  559.                         var position=$("#txtpositionstaffadd").val();
  560.                         //var desc=$("#txtdescstaff").val();
  561.                         var img=$("#btnimgstaffadd").val();
  562.                         if(fname != "" && lname != "" && mname != "" && position != ""  && img != ""  && branch != ""){
  563.                             var form=new FormData(document.getElementById('addstaff'));
  564.                             form.append("code","addStaff");
  565.                             $.ajax({
  566.                                 url:"include/function.php",
  567.                                 type:"POST",
  568.                                 data:form,
  569.                                 contentType: false,       // The content type used when sending data to the server.
  570.                                 cache: false,             // To unable request pages to be cached
  571.                                 processData:false,        // To send DOMDocument or non processed data file it is set to false
  572.                                 success:function(data){
  573.                                     $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data+"");
  574.                                     $( "#dialog-confirm" ).dialog({
  575.                                         resizable: true,
  576.                                         height:266,
  577.                                         width:759,
  578.                                         modal: true,
  579.                                         buttons: {
  580.                                             Close: function() {
  581.                                                 $( this ).dialog( "close" );
  582.                                             }
  583.                                         }
  584.                                     });
  585.                                     getStaff();
  586.                                 }
  587.                             });
  588.                             //phpUrl="imgstaff.php";
  589.                             //imageId="btnimgstaff";
  590.                             //uploadFile();
  591.                             $("#btnimgstaffadd").val("");
  592.                             $("#txtfnamestaffadd").val("");
  593.                             $("#txtlaststaffadd").val("");
  594.                             $("#txtmiddlestaffadd").val("");
  595.                             $("#txtpositionstaffadd").val("");
  596.                             $("#imgstaffadd").attr("src","img/700x450.gif");
  597.  
  598.                             $( this ).dialog( "close" );
  599.                         }else{
  600.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error! You need to Fillup all of the information.");
  601.                             $( "#dialog-confirm" ).dialog({
  602.                                 resizable: true,
  603.                                 height:180,
  604.                                 width:300,
  605.                                 modal: true,
  606.                                 buttons: {
  607.                                     Close: function() {
  608.                                         $( this ).dialog( "close" );
  609.                                     }
  610.                                 }
  611.                             });
  612.                         }
  613.                        
  614.                     },
  615.                     Close:function(){
  616.                         $( this ).dialog( "close" );
  617.                     }
  618.                    
  619.                 }
  620.             });
  621.  
  622.        
  623.        
  624. }
  625.  
  626.  
  627. function deleteStaff(id){
  628.     $.ajax({
  629.         type:"POST",
  630.         url:"include/function.php",
  631.         data:{code:"deleteStaff",id:id},
  632.  
  633.     });
  634.     $("#divstaff"+id).remove();
  635. }
  636. function getString(data){
  637.  
  638.     var temp=data;
  639.     var val="";
  640.     var index=0;
  641.     arr= new Array();
  642.     for(var i=0;i<temp.length;i++){
  643.         if(temp.charAt(i) == '+'){
  644.             arr[index]=val;
  645.             val="";
  646.             index++;
  647.         }else{
  648.             val=val+temp.charAt(i);
  649.         }
  650.     }
  651.     return arr;
  652. }
  653. function getCategory(){
  654.     indx=document.getElementById("cat1").selectedIndex;
  655.     $("#spinloaditem").show();
  656.         $.ajax({
  657.             type:"POST",
  658.             url:"include/function.php",
  659.             data:{code:"getCategoryID"},
  660.             dataType: "json",
  661.             cache: false,
  662.             success:function(data){
  663.  
  664.                 var arr= new Array();
  665.                 arr=data;  
  666.                 var id=arr[indx];
  667.  
  668.                 $.ajax({
  669.                     type:"POST",
  670.                     url:"include/function.php",
  671.                     data:{code:"getCategoryItem",id:id},
  672.                     dataType: "json",
  673.                     cache: false,
  674.                     success:function(data){
  675.                         /*var temp=data;
  676.                         var val="";
  677.                         var index=0;
  678.                         var index1=0;
  679.                          arr= new Array();
  680.                          //arr=data;
  681.                         for(var i=0;i<temp.length;i++){
  682.                             if(temp.charAt(i) == '+'){
  683.                                 arr[index1-1][index]=val;
  684.                                 val="";
  685.                                 index++;
  686.                             }else if(temp.charAt(i) == '-'){
  687.                                 arr[index1]=new Array();
  688.                                 index1++;
  689.                                 index=0;
  690.                             }else{
  691.                                 val=val+temp.charAt(i);
  692.                             }
  693.                         }*/
  694.                         arr= new Array();
  695.                          arr=data;
  696.                        
  697.                         $("#tblcat tr:gt(0)").remove();
  698.                        
  699.                         for(var i=0;i<arr.length;i++){
  700.                             var tr=$("<tr></tr>");
  701.                             for(var x=0;x<arr[i].length;x++){
  702.                                 if(x == 0){
  703.                                     tr.append($("<td>"+(i+1)+".</td>"));
  704.                                 }else{
  705.                                     tr.append($("<td>"+arr[i][x]+"</td>"));
  706.                                 }
  707.                             }
  708.                             tr.append($("<td><button class='btn btn-primary' onClick='UpdateItem("+arr[i][0]+")'>View</button></td>"));
  709.                             $("#tbody").append(tr);
  710.                         }
  711.                         $("#spinloaditem").hide();
  712.                     }
  713.                 });
  714.             }
  715.         });
  716. }
  717. function getcatName(){
  718.  
  719.     $("#cat1").empty();
  720.     $("#cat2").empty();
  721.     $.ajax({
  722.                 type:"POST",
  723.                 url:"include/function.php",
  724.                 data:{code:"getCategory"},
  725.                 dataType: "json",
  726.                 cache: false,
  727.                 success:function(data){
  728.                 var arr=data;
  729.                     for(var i=0;i<arr.length;i++){
  730.                         $("#cat1").append($("<option>"+arr[i]+"</option>"));
  731.                         $("#cat2").append($("<option>"+arr[i]+"</option>"));
  732.                     }
  733.                     getCategory();
  734.                 }
  735.             });
  736. }
  737. function UpdateItem(id){
  738.  
  739.     $.ajax({
  740.         type:"POST",
  741.         url:"include/function.php",
  742.         data:{code:"getItem",id:id},
  743.         dataType: "json",
  744.         cache: false,
  745.         success:function(data){
  746.             //dito tayo
  747.             var arr= new Array();
  748.             arr=data;
  749.  
  750.                 $("#item_img").attr("src",arr[0]);
  751.                 $("#item_img2").attr("src",arr[3]);
  752.                 $("#item_img3").attr("src",arr[4]);
  753.                 $("#item_name").val(arr[1]);
  754.                 $("#item_desc").val(arr[2]);
  755.  
  756.         }
  757.     });
  758.     var name=$("#item_name").val();
  759.     var desc=$("#item_desc").val();
  760.    
  761.  
  762.     $("#dialog-messagesss").dialog({
  763.     modal: true,
  764.     width:900,
  765.     height:631,
  766.     buttons: {
  767.     Update: function() {
  768.         var name=$("#item_name").val();
  769.     var desc=$("#item_desc").val();
  770.     if(name != "" && desc != ""){
  771.  
  772.         var form=new FormData(_("updateItem"));
  773.         form.append("code","updateItem");
  774.         form.append("id",id);
  775.             //alert(name+""+desc+""+id+""+img);
  776.                 $.ajax({
  777.                     url:"include/function.php",
  778.                     type:"POST",
  779.                     data:form,
  780.                     contentType: false,       // The content type used when sending data to the server.
  781.                     cache: false,             // To unable request pages to be cached
  782.                     processData:false,
  783.                     success:function(data){
  784.                         $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data);
  785.                         $( "#dialog-confirm" ).dialog({
  786.                               resizable: true,
  787.                               height:200,
  788.                               width:300,
  789.                               modal: true,
  790.                             buttons: {
  791.                             Close: function() {
  792.                                 $( this ).dialog( "close" );
  793.                                 $( this ).dialog( "destroy" );
  794.                                  $("#dialog-messagesss").dialog( "close" );
  795.                             }
  796.                             }
  797.                         });
  798.  
  799.                     }
  800.                 });
  801.                 //if($("#itemfile").val() != ""){
  802.                     //phpUrl="saveItem.php";
  803.                     //imageId="itemfile";
  804.                     //uploadFile();
  805.                 //}
  806.                 getCategory();
  807.                 //alert("Item successfully Updated!");
  808.              
  809.         }else{
  810.             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Fillup all of the information.");
  811.                         $( "#dialog-confirm" ).dialog({
  812.                               resizable: true,
  813.                               height:200,
  814.                               width:300,
  815.                               modal: true,
  816.                             buttons: {
  817.                             Close: function() {
  818.                                 $( this ).dialog( "close" );
  819.                                 $( this ).dialog( "destroy" );
  820.                             }
  821.                             }
  822.                         });
  823.         }
  824.             },
  825.     Delete:function(){
  826.         var con=confirm("are you sure you want to delete this item ?");
  827.         if(con){
  828.             $.ajax({
  829.                 type:"POST",
  830.                 url:"include/function.php",
  831.                 data:{code:"deleteItem",id:id},
  832.  
  833.             });
  834.             //alert("Item successfully Deleted!");
  835.             getCategory();
  836.              $("#dialog-messagesss").dialog( "close" );
  837.         }
  838.     }
  839.         }
  840.     });
  841. }
  842. function _(elementID){
  843.         return document.getElementById(elementID);
  844.     }
  845. function uploadFile(){
  846.         var formdata = new FormData();
  847.         var file = _(imageId).files[0];
  848.         formdata.append(imageId, file);
  849.         var ajax = new XMLHttpRequest();
  850.         ajax.open("POST", phpUrl);
  851.         ajax.send(formdata);
  852.     }
  853.     function showImage(){
  854.         var input=_(imageId);
  855.         var fReader = new FileReader();
  856.         var imageObj = new Image();
  857.         fReader.readAsDataURL(input.files[0]);
  858.         fReader.onloadend = function(event){
  859.             $("#"+canvasId).attr("src",event.target.result);
  860.         }
  861.     }
  862.  
  863.     function addAdmin(username,password,retype){
  864.     if(username == "" || password == "" || retype == ""){
  865.         var modal = $("#dialog-message")
  866.         var pTag = $("<p style='color:red;'>Input all the fields first.</p>");
  867.         $("#dialog-message > p").remove();
  868.         modal.append(pTag);
  869.         modal.dialog("open");
  870.     }
  871.     else if(password != retype){
  872.         var modal = $("#dialog-message")
  873.         var pTag = $("<p style='color:red;'>Password does not match.</p>");
  874.         $("#dialog-message > p").remove();
  875.         modal.append(pTag);
  876.         modal.dialog("open");
  877.     }
  878.     else{
  879.         $.ajax({
  880.             type:"POST",
  881.             url:"include/function.php",
  882.             data:{code:"addAdmin",username:username,password:password},
  883.             success:function(data){
  884.                 if(data == "True"){
  885.                     var modal = $("#dialog");
  886.                     modal.dialog("open");
  887.                     $("#txtAdminUsername").val("");
  888.                     $("#txtAdminPass").val("");
  889.                     $("#txtRetype").val("");   
  890.                 }
  891.                 else{
  892.                     var modal = $("#dialog-message")
  893.                     var pTag = $("<p style='color:red;'>The username is already exist! Please try another one.</p>");
  894.                     $("#dialog-message > p").remove();
  895.                     modal.append(pTag);
  896.                     modal.dialog("open");
  897.                 }
  898.             }
  899.         });//end of ajax.
  900.     }
  901. }
  902.  
  903. function updateAdmin(username,password,retype,id){
  904.     if(username == "" || password == "" || retype == ""){
  905.         var modal = $("#dialog-message")
  906.         var pTag = $("<p style='color:red;'>Input all the fields first.</p>");
  907.         $("#dialog-message > p").remove();
  908.         modal.append(pTag);
  909.         modal.dialog("open");
  910.     }
  911.     else if(password != retype){
  912.         var modal = $("#dialog-message")
  913.         var pTag = $("<p style='color:red;'>Password does not match.</p>");
  914.         $("#dialog-message > p").remove();
  915.         modal.append(pTag);
  916.         modal.dialog("open");
  917.     }
  918.     else{
  919.         $.ajax({
  920.             type:"POST",
  921.             url:"include/function.php",
  922.             data:{code:"updateAdmin",username:username,password:password,id:id},
  923.             success:function(data){
  924.                 if(data == "True"){
  925.                     var modal = $("#dialog");
  926.                     var pTag = $("<p>Account is successfully updated.</p>");
  927.                     $("#dialog > p").remove();
  928.                     modal.append(pTag);
  929.                     modal.dialog("open");
  930.                     $("#adminUsername").val("");
  931.                     $("#adminPass").val("");
  932.                     $("#adminRe").val("");
  933.                 }
  934.                 else{
  935.                     var modal = $("#dialog-message")
  936.                     var pTag = $("<p style='color:red;'>The username is already exist! Please try another one.</p>");
  937.                     $("#dialog-message > p").remove();
  938.                     modal.append(pTag);
  939.                     modal.dialog("open");
  940.                 }
  941.             }
  942.         });//end of ajax.
  943.     }
  944. }
  945.  
  946.  
  947. function setId(id){
  948.     this.id = id;
  949. }
  950.  
  951. function getId(){
  952.     var id_admin = id;
  953.     $.ajax({
  954.         type:"POST",
  955.         url:"include/function.php",
  956.         data:{code:"adminDelete",id:id_admin},
  957.         success:function(data){
  958.             if(data == "True"){
  959.                 window.location.href="adminManage.php";
  960.             }
  961.         }
  962.     });
  963. }
  964. $(document).ready(function(){
  965.     //$(".text-editor").summernote();
  966.     //$("#searchdec").hide();
  967.      $("#dialog-messagesss").hide();
  968.     $("#alertsuc").hide();
  969.     $("#alertdan").hide();
  970.     $("#btnsearchdec").click(function(){
  971.         $("#alertinfo").hide();
  972.         $("#alertsuc").hide();
  973.         $("#alertdan").hide();
  974.         var search=$("#txtsearchdec").val();
  975.         $(".selectelement").removeClass("selectelement");
  976.         if(search == ""){
  977.             alert("input name of the deceased first!");
  978.         }else if(mapid_glo == ""){
  979.             alert("Select Branch first!");
  980.         }else{
  981.            
  982.             $.ajax({
  983.                     type:"POST",
  984.                     url:"include/function.php",
  985.                     data:{code:"searchDec",dec:search,id:mapid_glo},
  986.                     dataType: "json",
  987.                     cache: false,
  988.                     success:function(data){
  989.                        
  990.  
  991.                         if(data == "no match found!"){
  992.                             $("#alertinfo").hide();
  993.                             $("#alertsuc").hide();
  994.                             $("#alertdan").show();
  995.                         }else{
  996.                             $("#resultdec").empty();
  997.                             $("#resultOwner").empty();
  998.                             $("#alertinfo").hide();
  999.                             $("#alertsuc").show();
  1000.                             $("#alertdan").hide();
  1001.                             $("#renum").html(data.length);
  1002.                             $("#sertxt").html(search);
  1003.                             $("#resultdec").append($("<option></option>"));
  1004.                             $("#resultOwner").append($("<option id='first'>result</option>"));
  1005.                             var countd=0;
  1006.                             var counto=0;
  1007.                             for(var i=0;i<data.length;i++){
  1008.                                 var option=$("<option title='"+data[i][0]+"'>"+data[i][1]+"</option>");
  1009.                                 // if(data[i][2] == 'dec'){
  1010.                                 //  $("#resultdec").append(option);
  1011.                                 //  countd++;
  1012.                                 // }else{
  1013.                                     $("#resultOwner").append(option);
  1014.                                 //  counto++;
  1015.                                 // }
  1016.                             }
  1017.                             $("#countO").html("("+counto+")");
  1018.                             $("#countD").html("("+countd+")");
  1019.                             //$("#resultdec option:last").remove();
  1020.                            
  1021.                             //$("#resultOwner").empty();
  1022.                         }
  1023.                        
  1024.                     }
  1025.                 });
  1026.         }
  1027.     });
  1028.     $("#btnsearchowner").click(function(){
  1029.         var search=$("#txtsearchowner").val();
  1030.         $(".selectelement").removeClass("selectelement");
  1031.         if(search == ""){
  1032.             alert("input name of the deceased first!");
  1033.         }else{
  1034.             $.ajax({
  1035.                     type:"POST",
  1036.                     url:"include/function.php",
  1037.                     data:{code:"searchOwner",owner:search},
  1038.                     dataType: "json",
  1039.                     cache: false,
  1040.                     success:function(data){
  1041.                         if(data == "no match found!"){
  1042.                             alert(data);
  1043.                         }else{
  1044.                             for(var i=0;i<data.length;i++){
  1045.                                 $("#"+data[i]).find("img").addClass("selectelement");
  1046.                             }
  1047.                         }
  1048.                        
  1049.                     }
  1050.                 });
  1051.         }
  1052.     });
  1053.  
  1054.     $("#searchowner").hide();
  1055.     $("#searchblock").hide();
  1056.     $("#searchby").change(function(){
  1057.         var search=document.getElementById("searchby").selectedIndex;
  1058.        
  1059.         if(search == 0){
  1060.             $("#searchdec").show();
  1061.             $("#searchowner").hide();
  1062.             $("#searchblock").hide();
  1063.         }
  1064.         if(search == 1){
  1065.             $("#searchdec").hide();
  1066.             $("#searchowner").show();
  1067.             $("#searchblock").hide();
  1068.         }
  1069.         if(search == 2){
  1070.             $("#searchdec").hide();
  1071.             $("#searchowner").hide();
  1072.             $("#searchblock").show();
  1073.         }
  1074.  
  1075.     });
  1076.  
  1077.     $("#maptest").draggable({ scroll: true,cursor:"move"});
  1078.     $("#dialog-confirm").hide();
  1079. $("#dialog-message").hide();
  1080. /*$("#dialog-messageEdit").dialog({
  1081.     modal: true,
  1082.     width:73+"%"});*/
  1083. $("#dialog-messageEdit").hide();
  1084. $("#spinloaditem").hide();
  1085.     $(".spin").hide();
  1086.     $("#spinsavecat").hide();
  1087.     $("#spinsaveitem").hide();
  1088.     $("#dialog-addstaff").hide();
  1089.     $("#dialog-updatestaff").hide();
  1090.     $("#tdiv").hide();
  1091.     // choose theme
  1092.    
  1093.     $("#theme").change(function(){
  1094.         $(".spin").show();
  1095.         //$("#img1").hide();
  1096.         var indx=document.getElementById("theme").selectedIndex;
  1097.         var id=0;
  1098.         $("#img1title").val("");
  1099.                 $("#img2title").val("");
  1100.                 $("#img3title").val("");
  1101.                 $("#img4title").val("");
  1102.                 $("#img1desc").val("");
  1103.                 $("#img2desc").val("");
  1104.                 $("#img3desc").val("");
  1105.                 $("#img4desc").val("");
  1106.        
  1107.         $.ajax({
  1108.             type:"POST",
  1109.             url:"include/function.php",
  1110.             data:{code:"getThemeID",id:id},
  1111.             dataType: "json",
  1112.             cache: false,
  1113.             success:function(data){
  1114.             var arr=data;
  1115.                 id=arr[indx];
  1116.                
  1117.                 $.ajax({
  1118.             type:"POST",
  1119.             url:"include/function.php",
  1120.             data:{code:"getTheme",id:id},
  1121.             success:function(data){
  1122.                 var arr=getString(data);
  1123.                 $("#themename").val(arr[0]);
  1124.                 $("#img1").attr("src",arr[1]);
  1125.                 $("#img2").attr("src",arr[2]);
  1126.                 $("#img3").attr("src",arr[3]);
  1127.                 $("#img4").attr("src",arr[4]);
  1128.                 $("#staffimg").attr("src",arr[5]);
  1129.                 $("#img1title").val(arr[6]);
  1130.                 $("#img2title").val(arr[7]);
  1131.                 $("#img3title").val(arr[8]);
  1132.                 $("#img4title").val(arr[9]);
  1133.                 $("#img1desc").val(arr[10]);
  1134.                 $("#img2desc").val(arr[11]);
  1135.                 $("#img3desc").val(arr[12]);
  1136.                 $("#img4desc").val(arr[13]);
  1137.                 $(".spin").hide();
  1138.  
  1139.             },
  1140.         });
  1141.            
  1142.             }
  1143.         });
  1144.        
  1145.         //$("#img1").show();
  1146.        
  1147.     });
  1148.     // end choose theme
  1149.  
  1150.     //change pic
  1151.     $("#file1").on("change",function(){
  1152.          imageId="file1";
  1153.          canvasId="img1";
  1154.         // phpUrl="imageUpdate.php";
  1155.         showImage();
  1156.         //uploadFile();
  1157.     });
  1158.     $("#file2").on("change",function(){
  1159.          imageId="file2";
  1160.          canvasId="img2";
  1161.        
  1162.         showImage();
  1163.         //uploadFile();
  1164.     });
  1165.     $("#file3").on("change",function(){
  1166.          imageId="file3";
  1167.          canvasId="img3";
  1168.         // phpUrl="imageUpdate.php";
  1169.         showImage();
  1170.         //uploadFile();
  1171.     });
  1172.     $("#file4").on("change",function(){
  1173.          imageId="file4";
  1174.          canvasId="img4";
  1175.         // phpUrl="imageUpdate.php";
  1176.         showImage();
  1177.         //uploadFile();
  1178.     });
  1179.     $("#stafffile").on("change",function(){
  1180.          imageId="stafffile";
  1181.          canvasId="staffimg";
  1182.          phpUrl="imageUpdate.php";
  1183.         showImage();
  1184.         //uploadFile();
  1185.     });
  1186.    
  1187.     //end change pic
  1188.  
  1189.     //save home
  1190.         $("#btnsavehome").click(function(){
  1191.  
  1192.             var indx=document.getElementById("theme").selectedIndex;
  1193.             var id=0;
  1194.             arrbtn[0]="file1";
  1195.             arrbtn[1]="file2";
  1196.             arrbtn[2]="file3";
  1197.             arrbtn[3]="file4";
  1198.             arrbtn[4]="stafffile";
  1199.  
  1200.             var theme=$("#themename").val();
  1201.             //var features=$("#txtf").val();
  1202.             //var faq=$("#txtfaq").val();
  1203.             //var management=$("#txtm").val();
  1204.                 var title1="";
  1205.                 var title2="";
  1206.                 var title3="";
  1207.                 var title4="";
  1208.                 var descript1="";
  1209.                 var descript2="";
  1210.                 var descript3="";
  1211.                 var descript4="";
  1212.             arrphp[0]="image1.php";
  1213.             arrphp[1]="image2.php";
  1214.             arrphp[2]="image3.php";
  1215.             arrphp[3]="image4.php";
  1216.             arrphp[4]="image5.php";
  1217.             if($("#theme").val() == "new"){
  1218.                 if($("#file1").val() != "" && $("#file2").val() != "" && $("#file3").val() != "" && $("#file4").val() != "" && $("#themename").val() != ""){
  1219.                     $("#code").attr("value","saveTheme");
  1220.                     var form=new FormData(document.getElementById('adminHome'));
  1221.                     //form.append("code","saveTheme");
  1222.                 $.ajax({
  1223.                         url:"include/function.php",
  1224.                         type:"POST",
  1225.                         data:form,
  1226.                         contentType: false,       // The content type used when sending data to the server.
  1227.                         cache: false,             // To unable request pages to be cached
  1228.                         processData:false,
  1229.                         success:function(data){
  1230.                             getSelinHome();
  1231.                         $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data);
  1232.                         $("#file1").val("");
  1233.                         $("#file2").val("");
  1234.                         $("#file3").val("");
  1235.                         $("#file4").val("");
  1236.                         $("#stafffile").val("");
  1237.                     $( "#dialog-confirm" ).dialog({
  1238.                         resizable: true,
  1239.                       height:180,
  1240.                       width:300,
  1241.                       modal: true,
  1242.                     buttons: {
  1243.                     Close: function() {
  1244.                         $( this ).dialog( "close" );
  1245.                     }
  1246.                     }
  1247.                     });
  1248.                         }
  1249.                     });
  1250.                    
  1251.                 }else{
  1252.                     $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error in Craeting the theme. Complete the theme before saving.");
  1253.                     $( "#dialog-confirm" ).dialog({
  1254.                       resizable: true,
  1255.                       height:180,
  1256.                       width:300,
  1257.                       modal: true,
  1258.                     buttons: {
  1259.                     Close: function() {
  1260.                         $( this ).dialog( "close" );
  1261.                     }
  1262.                     }
  1263.                 });
  1264.                 }
  1265.                 $("#code").attr("value","updateTheme");
  1266.             }else{
  1267.                 //if($("#themename").val() != "" && title1 != "" && title2 != "" && title3 != "" && title4 != "" && descript1 != "" && descript2 != "" && descript3 != "" && descript4 != ""){
  1268.                 if($("#themename").val() != ""){   
  1269.                     $.ajax({
  1270.             type:"POST",
  1271.             url:"include/function.php",
  1272.             data:{code:"getThemeID",id:id},
  1273.             dataType:"json",
  1274.             cache:false,
  1275.             success:function(data){
  1276.                 var arr=data;
  1277.                 id=arr[indx];
  1278.                
  1279.                 var form=new FormData(_('adminHome'));
  1280.                 //form.append("code","updateTheme");
  1281.                 form.append("id",id);
  1282.                 form.append("img1title","");
  1283.                 form.append("img2title","");
  1284.                 form.append("img3title","");
  1285.                 form.append("img4title","");
  1286.                 form.append("img1desc","");
  1287.                 form.append("img2desc","");
  1288.                 form.append("img3desc","");
  1289.                 form.append("img4desc","");
  1290.                     $.ajax({
  1291.                         url:"include/function.php",
  1292.                         type:"POST",
  1293.                         data:form,
  1294.                         contentType: false,       // The content type used when sending data to the server.
  1295.                         cache: false,             // To unable request pages to be cached
  1296.                         processData:false,
  1297.                         success:function(data){
  1298.                             getSelinHome();
  1299.                             $("#file1").val("");
  1300.                             $("#file2").val("");
  1301.                             $("#file3").val("");
  1302.                             $("#file4").val("");
  1303.                             $("#stafffile").val("");
  1304.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>"+data);
  1305.                             $( "#dialog-confirm" ).dialog({
  1306.                                   resizable: true,
  1307.                                   height:200,
  1308.                                   width:300,
  1309.                                   modal: true,
  1310.                                 buttons: {
  1311.                                 Close: function() {
  1312.                                     $( this ).dialog( "close" );
  1313.                                 }
  1314.                                 }
  1315.                             });
  1316.                         }
  1317.                     });
  1318.                     //document.getElementById("dialog-confirm").setAttribute("title","Success");
  1319.                    
  1320.                    
  1321.                 }
  1322.                 });
  1323.                 }else{
  1324.                    
  1325.                     $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error in updating the theme. Complete the theme before saving.");
  1326.                     $( "#dialog-confirm" ).dialog({
  1327.                       resizable: true,
  1328.                       height:200,
  1329.                       width:300,
  1330.                       modal: true,
  1331.                     buttons: {
  1332.                     Close: function() {
  1333.                         $( this ).dialog( "close" );
  1334.                         $( this ).dialog( "destroy" );
  1335.                     }
  1336.                     }
  1337.                 });
  1338.                 }
  1339.             }
  1340.         });
  1341.     //end save home
  1342.  
  1343.     //add category
  1344.     $("#categoryfile").on("change",function(){
  1345.          imageId="categoryfile";
  1346.          canvasId="catimg";
  1347.         showImage();
  1348.     });
  1349.     $("#btnaddcat").click(function(){
  1350.         var name=$("#txtcat").val();
  1351.         var descript=$("#txtdesc").val();
  1352.         if(name != "" && $("#categoryfile").val() != "" && descript != ""){
  1353.             $("#spinsavecat").show();
  1354.             var form=new FormData(_("addCategory"));
  1355.             form.append("code","saveCategory");
  1356.             form.append("name",name);
  1357.             form.append("descript",descript);
  1358.             $.ajax({
  1359.                 url:"include/function.php",
  1360.                 type:"POST",
  1361.                 data:form,
  1362.                 contentType: false,       // The content type used when sending data to the server.
  1363.                 cache: false,             // To unable request pages to be cached
  1364.                 processData:false,
  1365.                 success:function(data){
  1366.                     $("#spinsavecat").hide();
  1367.                     $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data);
  1368.                     $( "#dialog-confirm" ).dialog({
  1369.                       resizable: true,
  1370.                       height:200,
  1371.                       width:300,
  1372.                       modal: true,
  1373.                     buttons: {
  1374.                     Close: function() {
  1375.                         $( this ).dialog( "close" );
  1376.                         $( this ).dialog( "destroy" );
  1377.                     }
  1378.                     }
  1379.                 });
  1380.                     getcatName();
  1381.                 }  
  1382.             });
  1383.             //phpUrl="saveCategory.php";
  1384.             //imageId="categoryfile";
  1385.             //uploadFile();
  1386.             $("#txtcat").val("");
  1387.             $("#txtdesc").val("");
  1388.             $("#categoryfile").val("");
  1389.             $("#catimg").attr("src","img/1000x300-700x300.gif");
  1390.            
  1391.  
  1392.            
  1393.            
  1394.         }else{
  1395.             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Failed! You need to Input the image and the title of the new Category.");
  1396.                     $( "#dialog-confirm" ).dialog({
  1397.                       resizable: true,
  1398.                       height:200,
  1399.                       width:300,
  1400.                       modal: true,
  1401.                     buttons: {
  1402.                     Close: function() {
  1403.                         $( this ).dialog( "close" );
  1404.                         $( this ).dialog( "destroy" );
  1405.                     }
  1406.                     }
  1407.                 });
  1408.         }
  1409.     });
  1410.     //end add category
  1411.  
  1412.     //search and delete category
  1413.     $("#cat1").change(function(){
  1414.         getCategory();
  1415.     });
  1416.     $("#txtsearch").keyup(function(){
  1417.         var item=$("#txtsearch").val();
  1418.         //if(evt.which == 8){
  1419.             if(item == ""){
  1420.                 getCategory();
  1421.                 //alert("Wwasak"); 
  1422.             }
  1423.     });
  1424.     $("#txtsearch").keypress(function(evt){
  1425.        
  1426.                
  1427.         //}
  1428.         if(evt.which == 13){
  1429.             indx=document.getElementById("cat1").selectedIndex;
  1430.             var item=$("#txtsearch").val();
  1431.             if(item == ""){
  1432.  
  1433.                 $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Input first!");
  1434.                     $( "#dialog-confirm" ).dialog({
  1435.                       resizable: true,
  1436.                       height:200,
  1437.                       width:300,
  1438.                       modal: true,
  1439.                     buttons: {
  1440.                     Close: function() {
  1441.                         $( this ).dialog( "close" );
  1442.                         $( this ).dialog( "destroy" );
  1443.                     }
  1444.                     }
  1445.                 });
  1446.             }else{
  1447.                 $("#spinloaditem").show();
  1448.                 $.ajax({
  1449.             type:"POST",
  1450.             url:"include/function.php",
  1451.             data:{code:"getCategoryID"},
  1452.             dataType: "json",
  1453.             cache: false,
  1454.             success:function(data){
  1455.                 var arr= new Array();
  1456.                 arr=data;
  1457.                 var id=arr[indx];
  1458.                 $.ajax({
  1459.                     type:"POST",
  1460.                     url:"include/function.php",
  1461.                     data:{code:"searchItem",item:item,id:id},
  1462.                     dataType: "json",
  1463.                     cache: false,
  1464.                     success:function(data){
  1465.                             arr= new Array();
  1466.                             arr=data;
  1467.                             //var temp=data;
  1468.                             if(arr.length != 0){
  1469.                         var val="";
  1470.                         var index=0;
  1471.                         var index1=0;
  1472.                          
  1473.                         $("#tblcat tr:gt(0)").remove();
  1474.                         for(var i=0;i<arr.length;i++){
  1475.                             var tr=$("<tr></tr>");
  1476.                             for(var x=0;x<arr[i].length;x++){
  1477.                                 if(x == 0){
  1478.                                     tr.append($("<td>"+(i+1)+".</td>"));
  1479.                                 }else{
  1480.                                     tr.append($("<td>"+arr[i][x]+"</td>"));
  1481.                                 }
  1482.                                
  1483.                             }
  1484.                             tr.append($("<td><button class='btn btn-primary' onClick='UpdateItem("+arr[i][0]+")'>View</button></td>"));
  1485.                             $("#tbody").append(tr);
  1486.                         }
  1487.                         $("#spinloaditem").hide();
  1488.                         }else{
  1489.                             $("#spinloaditem").hide();
  1490.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> No Result Found!");
  1491.                     $( "#dialog-confirm" ).dialog({
  1492.                       resizable: true,
  1493.                       height:200,
  1494.                       width:300,
  1495.                       modal: true,
  1496.                     buttons: {
  1497.                     Close: function() {
  1498.                         $( this ).dialog( "close" );
  1499.                         $( this ).dialog( "destroy" );
  1500.                     }
  1501.                     }
  1502.                 });
  1503.                         }
  1504.  
  1505.                     }
  1506.                 });
  1507.                 }
  1508.                 });
  1509.             }
  1510.         }
  1511.     });
  1512. $( "#tabs" ).tabs();
  1513.     $("#dialog-confirm").hide();
  1514.     $("#btnsearch").click(function(){
  1515.         indx=document.getElementById("cat1").selectedIndex;
  1516.             var item=$("#txtsearch").val();
  1517.             if(item == ""){
  1518.  
  1519.                 $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Input first!");
  1520.                     $( "#dialog-confirm" ).dialog({
  1521.                       resizable: true,
  1522.                       height:200,
  1523.                       width:300,
  1524.                       modal: true,
  1525.                     buttons: {
  1526.                     Close: function() {
  1527.                         $( this ).dialog( "close" );
  1528.                         $( this ).dialog( "destroy" );
  1529.                     }
  1530.                     }
  1531.                 });
  1532.             }else{
  1533.                 $.ajax({
  1534.             type:"POST",
  1535.             url:"include/function.php",
  1536.             data:{code:"getCategoryID"},
  1537.             dataType: "json",
  1538.             cache: false,
  1539.             success:function(data){
  1540.                 var arr= new Array();
  1541.                 arr=data;
  1542.                 var id=arr[indx];
  1543.                 $.ajax({
  1544.                     type:"POST",
  1545.                     url:"include/function.php",
  1546.                     data:{code:"searchItem",item:item,id:id},
  1547.                     dataType: "json",
  1548.                     cache: false,
  1549.                     success:function(data){
  1550.                             //var temp=data;
  1551.                              arr= new Array();
  1552.                              arr=data;
  1553.                             if(arr.length != 0){
  1554.                         var val="";
  1555.                         var index=0;
  1556.                         var index1=0;
  1557.                        
  1558.                         $("#tblcat tr:gt(0)").remove();
  1559.                        
  1560.                         for(var i=0;i<arr.length;i++){
  1561.                             var tr=$("<tr></tr>");
  1562.                             for(var x=0;x<arr[i].length;x++){
  1563.                                 if(x == 0){
  1564.                                     tr.append($("<td>"+(i+1)+".</td>"));
  1565.                                 }else{
  1566.                                     tr.append($("<td>"+arr[i][x]+"</td>"));
  1567.                                 }
  1568.                             }
  1569.                             tr.append($("<td><button class='btn btn-primary' onClick='UpdateItem("+arr[i][0]+")'>View</button></td>"));
  1570.                             $("#tbody").append(tr);
  1571.                         }
  1572.                         }else{
  1573.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> No Result Found!");
  1574.                     $( "#dialog-confirm" ).dialog({
  1575.                       resizable: true,
  1576.                       height:200,
  1577.                       width:300,
  1578.                       modal: true,
  1579.                     buttons: {
  1580.                     Close: function() {
  1581.                         $( this ).dialog( "close" );
  1582.                         $( this ).dialog( "destroy" );
  1583.                     }
  1584.                     }
  1585.                 });
  1586.                         }
  1587.                     }
  1588.                 });
  1589.                 }
  1590.                 });
  1591.             }
  1592.  
  1593.     });
  1594.     //end search and delete category
  1595.     //update Item
  1596.     $("#itemfile").change(function(){
  1597.          imageId="itemfile";
  1598.          canvasId="item_img";
  1599.         showImage();
  1600.     });
  1601.     $("#itemfile2").change(function(){
  1602.          imageId="itemfile2";
  1603.          canvasId="item_img2";
  1604.         showImage();
  1605.     });
  1606.     $("#itemfile3").change(function(){
  1607.          imageId="itemfile3";
  1608.          canvasId="item_img3";
  1609.         showImage();
  1610.     });
  1611.     //end update Item
  1612.  
  1613.     //add category item
  1614.     $("#addItemfile").change(function(){
  1615.          imageId="addItemfile";
  1616.          canvasId="imgaddItem";
  1617.         showImage();
  1618.     });
  1619.     $("#addItemfile2").change(function(){
  1620.          imageId="addItemfile2";
  1621.          canvasId="imgaddItem2";
  1622.         showImage();
  1623.     });
  1624.     $("#addItemfile3").change(function(){
  1625.          imageId="addItemfile3";
  1626.          canvasId="imgaddItem3";
  1627.         showImage();
  1628.     });
  1629.     $("#editcatfile").change(function(){
  1630.          imageId="editcatfile";
  1631.          canvasId="editcat_img";
  1632.         showImage();
  1633.     });
  1634.     $("#btnaddItem").click(function(){
  1635.         var title=$("#cat_title").val();
  1636.         var item_img=$("#addItemfile").val();
  1637.         var item_img2=$("#addItemfile2").val();
  1638.         var item_img3=$("#addItemfile3").val();
  1639.         var desc=$("#desc_item").val();
  1640.         if(title != "" && item_img != "" && desc != "" && item_img2 != ""  && item_img3 != "" ){
  1641.             $("#spinsaveitem").show();
  1642.             var indx=document.getElementById("cat2").selectedIndex;
  1643.             var form=new FormData(_("addItem"));
  1644.             form.append("code","addItem");
  1645.             form.append("id",indx);
  1646.                     $.ajax({
  1647.                         url:"include/function.php",
  1648.                         type:"POST",
  1649.                         data:form,
  1650.                         contentType: false,       // The content type used when sending data to the server.
  1651.                         cache: false,             // To unable request pages to be cached
  1652.                         processData:false,
  1653.                         success:function(data){
  1654.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data);
  1655.                             $( "#dialog-confirm" ).dialog({
  1656.                                     resizable: true,
  1657.                                   height:180,
  1658.                                   width:300,
  1659.                                   modal: true,
  1660.                                 buttons: {
  1661.                                 Close: function() {
  1662.                                     $( this ).dialog( "close" );
  1663.                                 }
  1664.                                 }
  1665.                             });            
  1666.                             getCategory();
  1667.                             $("#spinsaveitem").hide();
  1668.                         }
  1669.  
  1670.                     });
  1671.                    
  1672.                     //phpUrl="addItem.php";
  1673.                     //imageId="addItemfile";
  1674.                     //uploadFile();
  1675.            
  1676.            
  1677.  
  1678.             $("#cat_title").val("");
  1679.             $("#desc_item").val("");
  1680.             $("#addItemfile").val("");
  1681.             $("#addItemfile2").val("");
  1682.             $("#addItemfile3").val("");
  1683.             $("#imgaddItem").attr("src","img/700x450.gif");
  1684.             $("#imgaddItem2").attr("src","img/700x450.gif");
  1685.             $("#imgaddItem3").attr("src","img/700x450.gif");
  1686.            
  1687.         }else{
  1688.             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error! You need to Fillup all of the information.");
  1689.                     $( "#dialog-confirm" ).dialog({
  1690.                         resizable: true,
  1691.                       height:180,
  1692.                       width:300,
  1693.                       modal: true,
  1694.                     buttons: {
  1695.                     Close: function() {
  1696.                         $( this ).dialog( "close" );
  1697.                     }
  1698.                     }
  1699.                     });
  1700.            
  1701.         }
  1702.  
  1703.     });
  1704.     //end add category item
  1705.  
  1706.     //delete category
  1707.     $("#btndeletecat").click(function(){
  1708.         $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Deleting the category may also delete the category item.<br/> are you sure you want to delete this category?");
  1709.                     $( "#dialog-confirm" ).dialog({
  1710.                         resizable: true,
  1711.                       height:250,
  1712.                       width:300,
  1713.                       modal: true,
  1714.                     buttons: {
  1715.                     Yes: function() {
  1716.                         var indx=document.getElementById("cat1").selectedIndex;
  1717.                         $.ajax({
  1718.                             type:"POST",
  1719.                             url:"include/function.php",
  1720.                             data:{code:"deleteCategory",id:indx},
  1721.                             success:function(data){
  1722.                                 //alert(data);
  1723.                                 getcatName();
  1724.                                
  1725.                             }
  1726.                         });
  1727.                        
  1728.                         $( this ).dialog( "close" );
  1729.                     },
  1730.                     No: function() {
  1731.                         $( this ).dialog( "close" );
  1732.                     }
  1733.                     }
  1734.                     });
  1735.     });
  1736.     //end of delete category
  1737.  
  1738.     //about page
  1739.     $("#btnimgstaff").change(function(){
  1740.          imageId="btnimgstaff";
  1741.          canvasId="imgstaff";
  1742.         showImage();
  1743.     });
  1744.     $("#btnimgstaffadd").change(function(){
  1745.          imageId="btnimgstaffadd";
  1746.          canvasId="imgstaffadd";
  1747.         showImage();
  1748.     });
  1749.     $("#fileabout").change(function(){
  1750.          imageId="fileabout";
  1751.          canvasId="about_img";
  1752.         showImage();
  1753.     });
  1754.     $("#btnsaveabout").click(function(){
  1755.         var btnimg=$("#fileabout").val();
  1756.         var desc=$("#txtareaAbout").val();
  1757.         if( desc != ""){
  1758.             var form=new FormData(_("saveAbout"));
  1759.             form.append("code","saveAbout");
  1760.             $.ajax({
  1761.                 url:"include/function.php",
  1762.                 type:"POST",
  1763.                 data: form,
  1764.                 contentType:false,
  1765.                 cache:false,
  1766.                 processData:false,
  1767.                 success:function(data){
  1768.                             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data);
  1769.                             $( "#dialog-confirm" ).dialog({
  1770.                                     resizable: true,
  1771.                                   height:180,
  1772.                                   width:300,
  1773.                                   modal: true,
  1774.                                 buttons: {
  1775.                                 Close: function() {
  1776.                                     $( this ).dialog( "close" );
  1777.                                 }
  1778.                                 }
  1779.                             });    
  1780.                 }
  1781.             });
  1782.         }else{
  1783.             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error! you must insert the image and the description.");
  1784.                             $( "#dialog-confirm" ).dialog({
  1785.                                     resizable: true,
  1786.                                   height:180,
  1787.                                   width:300,
  1788.                                   modal: true,
  1789.                                 buttons: {
  1790.                                 Close: function() {
  1791.                                     $( this ).dialog( "close" );
  1792.                                 }
  1793.                                 }
  1794.                             });
  1795.         }
  1796.     });
  1797.     //end about page
  1798.    
  1799.     //contact page
  1800.     $("#filecontact").change(function(){
  1801.          imageId="filecontact";
  1802.          canvasId="imgcontact";
  1803.         showImage();
  1804.     });
  1805.     $("#btnsavecontact").click(function(){
  1806.         var phone=$("#contactphone").val();
  1807.         var hours=$("#contacthours").val();
  1808.         var email=$("#contactemail").val();
  1809.         var details=$("#contactdetails").val();
  1810.         if(phone != "" && hours != "" && email != "" && details != ""){
  1811.             var form=new FormData(_("updateContact"));
  1812.             form.append("code","updateContact")
  1813.             $.ajax({
  1814.                 url:"include/function.php",
  1815.                 type:"POST",
  1816.                 data: form,
  1817.                 contentType:false,
  1818.                 cache:false,
  1819.                 processData:false,
  1820.                 success:function(data){
  1821.                     $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> "+data);
  1822.                             $( "#dialog-confirm" ).dialog({
  1823.                                     resizable: true,
  1824.                                   height:180,
  1825.                                   width:300,
  1826.                                   modal: true,
  1827.                                 buttons: {
  1828.                                 Close: function() {
  1829.                                     $( this ).dialog( "close" );
  1830.                                 }
  1831.                                 }
  1832.                             });
  1833.                 }
  1834.             });
  1835.         }else{
  1836.             $("#txtp").html("<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span> Error! you must complete the details for contact page.");
  1837.                             $( "#dialog-confirm" ).dialog({
  1838.                                     resizable: true,
  1839.                                   height:180,
  1840.                                   width:300,
  1841.                                   modal: true,
  1842.                                 buttons: {
  1843.                                 Close: function() {
  1844.                                     $( this ).dialog( "close" );
  1845.                                 }
  1846.                                 }
  1847.                             });
  1848.         }
  1849.     });
  1850.  
  1851.     //end contact page
  1852.  
  1853.     //login and logout
  1854.     /*$("#btnlogin").click(function(){
  1855.         var username=$("#txtusername").val();
  1856.         var pass=$("#txtpassword").val();
  1857.         if(username != "" && pass != ""){
  1858.            
  1859.             $.ajax({
  1860.                 url:"include/function.php",
  1861.                 type:"POST",
  1862.                 data:{code:"login",username:username,pass:pass},
  1863.                 success:function(data){
  1864.                    
  1865.                     var arr=getString(data);
  1866.                     if(arr[0] == "true"){
  1867.                         document.location.href="adminHome.php";
  1868.                     }else{
  1869.                         alert("incorrect password or username.!");
  1870.                     }
  1871.                 }
  1872.             });
  1873.         }else{
  1874.             alert("fill-up first!");
  1875.         }
  1876.     });*/
  1877.  
  1878.     $("#txtpassword").keyup(function(event){
  1879.         if(event.keyCode == 13)
  1880.         {
  1881.             // alert("successfully login");
  1882.             $("#btnlogin").click();
  1883.         }
  1884.     });
  1885.  
  1886.     $("#btnlogin").click(function(){
  1887.         var username=$("#txtusername").val();
  1888.         var pass=$("#txtpassword").val();
  1889.         if(username != "" && pass != ""){
  1890.            
  1891.             $.ajax({
  1892.                 url:"include/function.php",
  1893.                 type:"POST",
  1894.                 data:{code:"login",username:username,pass:pass},
  1895.                 success:function(data){
  1896.                    
  1897.                     var arr=getString(data);
  1898.                     if(arr[0] == "true"){
  1899.                         document.location.href="adminHome.php";
  1900.                     }else{
  1901.                         alert("incorrect password or username.!");
  1902.                     }
  1903.                 }
  1904.             });
  1905.         }else{
  1906.             alert("fill-up first!");
  1907.         }
  1908.     });
  1909.     $("#btnlogout").click(function(){
  1910.         $.ajax({
  1911.             url:"include/function.php",
  1912.             type:"POST",
  1913.             data:{code:"logout"},
  1914.             success:function(data){
  1915.                 document.location.href="index.php";
  1916.             }
  1917.         });
  1918.     });
  1919.     //end of login and logout
  1920.  
  1921.     //select map
  1922.     $("#selectMap").change(function(){
  1923.         var indx=document.getElementById("selectMap").selectedIndex;
  1924.         var id=$(this).find("option:eq("+indx+")").attr("id");
  1925.         mapid_glo=id;
  1926.         if(id == "defult"){
  1927.  
  1928.         }else{
  1929.             $("#maptest").empty();
  1930.             $("#maptest").draggable({ containment: "#maptest", scroll: false,snap:true,grid:[30,30],cursor:"none"});
  1931.             $("#maptest").animate({zoom:"0.5"},1);
  1932.             $.ajax({
  1933.             type:"POST",
  1934.             url:"include/function.php",
  1935.             data:{code:"loadMap",id:id},
  1936.             success:function(data){
  1937.                 var arr=getString(data);
  1938.                 //loadGrid(parseInt(arr[0]),parseInt(arr[1]));
  1939.                
  1940.                 $.ajax({
  1941.                     type:"POST",
  1942.                     url:"include/function.php",
  1943.                     data:{code:"loadElement",id:arr[2]},
  1944.                     success:function(data){
  1945.                        
  1946.                         var index=0;
  1947.                         var arr=getString(data);
  1948.                         var num=parseInt(arr[0]);
  1949.                         for(var i=0;i<num;i++){
  1950.                             loadElement(arr[index+1],arr[index+2],arr[index+3],arr[index+4],arr[index+5],arr[index+6],arr[index+7],arr[index+8]);
  1951.                             index=index+8;
  1952.                         }
  1953.                     }
  1954.                 });
  1955.                
  1956.             }
  1957.         });
  1958.         }
  1959.     });
  1960.     //end of select map
  1961.  
  1962.     //add features and amenities
  1963.  
  1964.     $("#btnfa").click(function(){
  1965.         var txt=$("#txtfa").val();
  1966.  
  1967.         if(txt != ""){
  1968.             $.ajax({
  1969.                     type:"POST",
  1970.                     url:"include/function.php",
  1971.                     data:{code:"addFA",txt:txt},
  1972.                     success:function(data){
  1973.                        
  1974.                        
  1975.                     }
  1976.                 });
  1977.             loadFA();
  1978.         }else{
  1979.             alert("input first!");
  1980.         }
  1981.     });
  1982.    
  1983.     // end add features and amenities
  1984.  
  1985.     //edit cat
  1986.     $("#btneditcat").click(function(){
  1987.        
  1988.         $("#editcat_img").attr("src","img/700x450.gif");
  1989.         $("#editcat_name").val("");
  1990.         $("#editcat_desc").val("");
  1991.         var indx=document.getElementById("cat1").selectedIndex;
  1992.         //alert(indx);
  1993.         $.ajax({
  1994.             type:"POST",
  1995.             url:"include/function.php",
  1996.             data:{code:"editCategory",id:indx},
  1997.            
  1998.             success:function(data){
  1999.                 var arr=getString(data);
  2000.                 $("#editcat_img").attr("src",arr[2]);
  2001.                 $("#editcat_name").val(arr[0]);
  2002.                 $("#editcat_desc").val(arr[1]);
  2003.                 $("#dialog-messageEdit").dialog({
  2004.                     modal: true,
  2005.                     width:73+"%",
  2006.                     buttons: {
  2007.                         Update: function() {
  2008.                             var name=$("#editcat_name").val();
  2009.                             var desc=$("#editcat_desc").val();
  2010.                             if(name != "" && desc != ""){
  2011.                                
  2012.                                 var indx=document.getElementById("cat1").selectedIndex;
  2013.                                 var form=new FormData(_("editCat"));
  2014.                                 form.append("id",indx);
  2015.                                 form.append("code","updateCategory");
  2016.                                
  2017.                                 $.ajax({
  2018.                                     type:"POST",
  2019.                                     url:"include/function.php",
  2020.                                     data:form,
  2021.                                     contentType: false,       // The content type used when sending data to the server.
  2022.                                     cache: false,             // To unable request pages to be cached
  2023.                                     processData:false,
  2024.                                     success:function(data){
  2025.                                         alert(data);
  2026.                                         $("#dialog-messageEdit").dialog( "close" );
  2027.                                     }
  2028.                                 });
  2029.                                 //$( this ).dialog( "close" );
  2030.                             }else{
  2031.                                 alert("complete the form first!");
  2032.                             }
  2033.                            
  2034.                         }
  2035.                     }
  2036.                 });
  2037.                 //getcatName();
  2038.                                
  2039.             },
  2040.            
  2041.         });
  2042.     });
  2043.     // end edit cat
  2044.         $( "#dialog-message" ).dialog({
  2045.             autoOpen: false,
  2046.             modal: true,
  2047.             buttons: {
  2048.                 Ok: function() {
  2049.                     $(this).dialog( "close" );
  2050.                 }
  2051.             }
  2052.         });
  2053.  
  2054.     $( "#dialog" ).dialog({
  2055.             autoOpen: false,
  2056.             modal: true,
  2057.             buttons: {
  2058.                 Ok: function() {
  2059.                     $(this).dialog( "close" );
  2060.                 }
  2061.             }
  2062.         });
  2063.  
  2064.     $( "#dialog3" ).dialog({
  2065.             autoOpen: false,
  2066.             modal: true,
  2067.             buttons: {
  2068.                 Ok: function(data) {
  2069.                     getId();
  2070.                 },
  2071.                 Cancel: function(data){
  2072.                     $(this).dialog("close");
  2073.                 }
  2074.             }
  2075.         });
  2076.  
  2077.     $( "#accordion" ).accordion({
  2078.             collapsible: true
  2079.     });
  2080.  
  2081.     $("#btnAddAdmin").click(function(){
  2082.         var username = $("#txtAdminUsername").val();
  2083.         var password = $("#txtAdminPass").val();
  2084.         var retype = $("#txtRetype").val();
  2085.         addAdmin(username,password,retype);
  2086.     });
  2087.  
  2088.     $("#btnUpdateAdmin").click(function(){
  2089.         // var username = $("#adminUsername").val();
  2090.         var password = $("#adminPass").val();
  2091.         // var retype = $("#adminRe").val();
  2092.         var admin_id = $("#id").val();
  2093.         updateAdmin(password,admin_id);
  2094.     });
  2095.  
  2096.     $(".btnAdminDel").click(function(){
  2097.         var admin_id =$(this).closest('tr').children('td:first').text();
  2098.         setId(admin_id);
  2099.         $("#dialog3").dialog("open");
  2100.     });
  2101.     var temps=4;
  2102.     $( "#slider" ).slider({
  2103.             value:0,
  2104.             max: 13,
  2105.             step: 1,
  2106.             slide: function( event, ui ) {
  2107.                 var s=ui.value;
  2108.                 //alert(s+" "+temps);
  2109.                 if(temps <= s){
  2110.                     $("#maptest").animate({zoom:"+=0.1"},1);
  2111.                     temps=s;
  2112.                 }else{
  2113.                     $("#maptest").animate({zoom:"-=0.1"},1);
  2114.                     temps=s;
  2115.                 }
  2116.                 // if(s >= 4 && s<= 7){
  2117.                 //  $("#maptest").animate({zoom:"+=0.1"},400); 
  2118.                 // }
  2119.                 // //$("#maptest").animate({zoom:ui.value*0.1},400);
  2120.                 //$( "#amount" ).val( "$" + ui.value );
  2121.             }
  2122.         });
  2123.     $("#declotspub").change(function(){
  2124.        
  2125.         var declots=document.getElementById("declotspub").selectedIndex;
  2126.         declots=$("#declotspub option:eq("+declots+")").attr("title");
  2127.         if(declots == "newDec"){
  2128.             $("#decimg").attr("src","img/placeholder.png");
  2129.                 $("#decname").html("NO RECORD");
  2130.                 $("#decbirth").html("NO RECORD");
  2131.                 $("#decdeath").html("NO RECORD");
  2132.                 $("#decburial").html("NO RECORD");
  2133.             }else{
  2134.                     $.ajax({
  2135.                         url:"include/function.php",
  2136.                         type:"POST",
  2137.                         data:{code:"getLotInfoDec",decID:declots,id:$(decIDlot).attr("id")},
  2138.                         success:function(data){
  2139.                            
  2140.                                 var arr=data.split("+");
  2141.                                 $("#decimg").attr("src",arr[7]);
  2142.                                 $("#decname").html(arr[1]+" "+arr[3]+" "+arr[2]);
  2143.                                 $("#decbirth").html(arr[4]);
  2144.                                 $("#decdeath").html(arr[5]);
  2145.                                 $("#decburial").html(arr[6]);
  2146.                                 decid=arr[0];
  2147.                             }
  2148.                            
  2149.  
  2150.                        
  2151.                     });
  2152.             }
  2153.    
  2154.     });
  2155.     $("#btnokedit").click(function(){
  2156.         $("#faText").removeClass("error");
  2157.         var txt=$("#faText").val();
  2158.         if(txt != ""){
  2159.             $.ajax({
  2160.                 url:"include/function.php",
  2161.                 type:"POST",
  2162.                 data:{code:"setFA",id:editFaid,txt:txt},
  2163.                 success:function(data){
  2164.                     $("#btncloseedit").click();
  2165.                    
  2166.                 }
  2167.             });
  2168.             loadFA();  
  2169.         }else{
  2170.             $("#faText").addClass("error");
  2171.         }
  2172.     });
  2173.     $("#btnokdelete").click(function(){
  2174.        
  2175.         $.ajax({
  2176.             url:"include/function.php",
  2177.             type:"POST",
  2178.             data:{code:"deleteFA",id:deleteFAid},
  2179.             success:function(data){
  2180.                 $("#loadFAtemp").click();
  2181.                
  2182.                 $("#btnclosedelete").click();  
  2183.                    
  2184.             }
  2185.         });
  2186.            
  2187.     });
  2188. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement