<!DOCTYPE html>
<html lang="en-us">
	<head>
		<meta charset="utf-8">
		<!--<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->

		<title> <?php echo 'knalpot'; ?> </title>
		<meta name="description" content="">
		<meta name="author" content="">
			
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<!-- Basic Styles -->
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/font-awesome.min.css">

		<!-- SmartAdmin Styles : Please note (smartadmin-production.css) was created using LESS variables -->
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/smartadmin-production.css">
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/smartadmin-skins.css">

		<!-- SmartAdmin RTL Support is under construction
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/smartadmin-rtl.css"> -->

		<!-- We recommend you use "your_style.css" to override SmartAdmin
		     specific styles this will also ensure you retrain your customization with each SmartAdmin update.
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/your_style.css"> -->

		<!-- Demo purpose only: goes with demo.js, you can delete this css when designing your own WebApp -->
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/demo.css">

		<!-- FAVICONS -->
		<link rel="shortcut icon" href="<?php echo base_url(); ?>template/backend_default/ico/favicon.ico" type="image/x-icon">
		<link rel="icon" href="<?php echo base_url(); ?>template/backend_default/ico/favicon.ico" type="image/x-icon">

		<!-- GOOGLE FONT -->
		<!--<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,300,400,700">-->

		<!-- Specifying a Webpage Icon for Web Clip 
			 Ref: https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html -->
		<link rel="apple-touch-icon" href="<?php echo base_url(); ?>template/backend_default/img/splash/sptouch-icon-iphone.png">
		<link rel="apple-touch-icon" sizes="76x76" href="<?php echo base_url(); ?>template/backend_default/img/splash/touch-icon-ipad.png">
		<link rel="apple-touch-icon" sizes="120x120" href="<?php echo base_url(); ?>template/backend_default/img/splash/touch-icon-iphone-retina.png">
		<link rel="apple-touch-icon" sizes="152x152" href="<?php echo base_url(); ?>template/backend_default/img/splash/touch-icon-ipad-retina.png">
        
        <link rel="stylesheet" href="<?php echo base_url(); ?>template/backend_default/plugins/upload_script/file-uploader.css">
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/js/plugin/datatables/10/dataTables.responsive.css">
		<!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		
		<!-- Startup image for web apps -->
		<link rel="apple-touch-startup-image" href="<?php echo base_url(); ?>template/backend_default/img/splash/ipad-landscape.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)">
		<link rel="apple-touch-startup-image" href="<?php echo base_url(); ?>template/backend_default/img/splash/ipad-portrait.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
		<link rel="apple-touch-startup-image" href="<?php echo base_url(); ?>template/backend_default/img/splash/iphone.png" media="screen and (max-device-width: 320px)">

	</head>
	<body class="">
		<!-- POSSIBLE CLASSES: minified, fixed-ribbon, fixed-header, fixed-width
			 You can also add different skin classes such as "smart-skin-1", "smart-skin-2" etc...-->
		
		<!-- HEADER -->
		<header id="header">
			<div id="logo-group">

				<!-- PLACE YOUR LOGO HERE -->
				<span id="logo" style="font-size:14px;"><img src="" style="width:188px" alt="Logo"></span>
				<!-- END LOGO PLACEHOLDER -->

				<!-- Note: The activity badge color changes when clicked and resets the number to 0
				Suggestion: You may want to set a flag when this happens to tick off all checked messages / notifications -->
				<span id="activity" class="activity-dropdown"> <i class="fa fa-user"></i> <b class="badge"> 21 </b> </span>

				<!-- AJAX-DROPDOWN : control this dropdown height, look and feel from the LESS variable file -->
				<div class="ajax-dropdown">

					<!-- the ID links are fetched via AJAX to the ajax container "ajax-notifications" -->
					<div class="btn-group btn-group-justified" data-toggle="buttons">
						<label class="btn btn-default">
							<input type="radio" name="activity" id="ajax/notify/mail.html">
							New Ticket (14) </label>
						<!--<label class="btn btn-default">
							<input type="radio" name="activity" id="ajax/notify/notifications.html">
							notify (3) </label>
						<label class="btn btn-default">
							<input type="radio" name="activity" id="ajax/notify/tasks.html">
							Tasks (4) </label>-->
					</div>

					<!-- notification content -->
					<div class="ajax-notifications custom-scroll">

						<div class="alert alert-transparent">
							<h4>Click a button to show messages here</h4>
							This blank page message helps protect your privacy, or you can show the first message here automatically.
						</div>

						<i class="fa fa-lock fa-4x fa-border"></i>

					</div>
					<!-- end notification content -->

					<!-- footer: refresh area -->
					<span> Last updated on: 12/12/2013 9:43AM
						<button type="button" data-loading-text="<i class='fa fa-refresh fa-spin'></i> Loading..." class="btn btn-xs btn-default pull-right">
							<i class="fa fa-refresh"></i>
						</button> </span>
					<!-- end footer -->

				</div>
				<!-- END AJAX-DROPDOWN -->
			</div>

			

			<!-- pulled right: nav area -->
			<div class="pull-right">

				<!-- collapse menu button -->
				<div id="hide-menu" class="btn-header pull-right">
					<span> <a href="javascript:void(0);" title="Collapse Menu"><i class="fa fa-reorder"></i></a> </span>
				</div>
				<!-- end collapse menu -->

				<!-- logout button -->
				<div id="logout" class="btn-header transparent pull-right">
					<span> <a href="login/logmeout" title="Sign Out" data-logout-msg="You can improve your security further after logging out by closing this opened browser"><i class="fa fa-sign-out"></i></a> </span>
				</div>
				<!-- end logout button -->

				<!-- search mobile button (this is hidden till mobile view port) -->
				<div id="search-mobile" class="btn-header transparent pull-right">
					<span> <a href="javascript:void(0)" title="Search"><i class="fa fa-search"></i></a> </span>
				</div>
				<!-- end search mobile button -->

				<!-- input: search field -->
				<!--<form action="#ticket_list/search" class="header-search pull-right">
					<input type="text" name="param" placeholder="Find tickets" id="search-fld">
					<button type="submit">
						<i class="fa fa-search"></i>
					</button>
					<a href="javascript:void(0);" id="cancel-search-js" title="Cancel Search"><i class="fa fa-times"></i></a>
				</form>-->
				<!-- end input: search field -->

				<!-- fullscreen button -->
				<div id="fullscreen" class="btn-header transparent pull-right">
					<span> <a href="javascript:void(0);" onclick="launchFullscreen(document.documentElement);" title="Full Screen"><i class="fa fa-fullscreen"></i></a> </span>
				</div>
				<!-- end fullscreen button -->

				<!-- multiple lang dropdown : find all flags in the image folder -->
				<!--<ul class="header-dropdown-list hidden-xs">
					<li>
						<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img alt="" src="img/flags/us.png"> <span> US </span> <i class="fa fa-angle-down"></i> </a>
						<ul class="dropdown-menu pull-right">
							<li class="active">
								<a href="javascript:void(0);"><img alt="" src="img/flags/us.png"> US</a>
							</li>
							<li>
								<a href="javascript:void(0);"><img alt="" src="img/flags/es.png"> Spanish</a>
							</li>
							<li>
								<a href="javascript:void(0);"><img alt="" src="img/flags/de.png"> German</a>
							</li>
						</ul>
					</li>
				</ul>-->
				<!-- end multiple lang -->

			</div>
			<!-- end pulled right: nav area -->

		</header>
		<!-- END HEADER -->

		<!-- Left panel : Navigation area -->
		<!-- Note: This width of the aside area can be adjusted through LESS variables -->
		<aside id="left-panel">

			<!-- User info -->
			<div class="login-info">
				<span> <!-- User image size is adjusted inside CSS, it should stay as it --> 
					
					<a href="javascript:void(0);" id="show-shortcut">
						<img src="<?php echo base_url(); ?>template/backend_default/img/avatars/male.png" alt="me" class="online" /> 
						<span>
							<?php echo "Username"; //echo $this->session->userdata('username');?> 
						</span>
						<i class="fa fa-angle-down"></i>
					</a> 
					
				</span>
			</div>
			<!-- end user info -->

			<!-- NAVIGATION : This navigation is also responsive

			To make this navigation dynamic please make sure to link the node
			(the reference to the nav > ul) after page load. Or the navigation
			will not initialize.
			-->
			<nav>
				<!-- NOTE: Notice the gaps after each icon usage <i></i>..
				Please note that these links work a bit different than
				traditional href="" links. See documentation for details.
				-->

				<ul>
					
					<?php
					//echo getMenuList();
					?>
					
					<li>
						<a href="#"><i class="fa fa-lg fa-fw fa-table"></i> <span class="menu-item-parent">Tables</span></a>
						<ul>
							<li>
								<a href="ajax/table.html">Normal Tables</a>
							</li>
							<li>
								<a href="ajax/datatables.html">Data Tables</a>
							</li>
						</ul>
					</li>
					<li>
						<a href="#"><i class="fa fa-lg fa-fw fa-pencil-square-o"></i> <span class="menu-item-parent">Forms</span></a>
						<ul>
							<li>
								<a href="ajax/form-elements.html">Smart Form Elements</a>
							</li>
							<li>
								<a href="ajax/form-templates.html">Smart Form Layouts</a>
							</li>
							<li>
								<a href="ajax/validation.html">Smart Form Validation</a>
							</li>
							<li>
								<a href="ajax/bootstrap-forms.html">Bootstrap Form Elements</a>
							</li>
							<li>
								<a href="ajax/plugins.html">Form Plugins</a>
							</li>
							<li>
								<a href="ajax/wizard.html">Wizards</a>
							</li>
							<li>
								<a href="ajax/other-editors.html">Bootstrap Editors</a>
							</li>
							<li>
								<a href="ajax/dropzone.html">Dropzone <span class="badge pull-right inbox-badge bg-color-yellow">new</span></a>
							</li>
						</ul>
					</li>
					<li>
						<a href="#"><i class="fa fa-lg fa-fw fa-desktop"></i> <span class="menu-item-parent">UI Elements</span></a>
						<ul>
							<li>
								<a href="ajax/general-elements.html">General Elements</a>
							</li>
							<li>
								<a href="ajax/buttons.html">Buttons</a>
							</li>
							<li>
								<a href="#">Icons</a>
								<ul>
									<li>
										<a href="ajax/fa.html"><i class="fa fa-plane"></i> Font Awesome</a>
									</li>
									<li>
										<a href="ajax/glyph.html"><i class="glyphicon glyphicon-plane"></i> Glyph Icons</a>
									</li>
								</ul>
							</li>
							<li>
								<a href="ajax/grid.html">Grid</a>
							</li>
							<li>
								<a href="ajax/treeview.html">Tree View</a>
							</li>
							<li>
								<a href="ajax/nestable-list.html">Nestable Lists</a>
							</li>
							<li>
								<a href="ajax/jqui.html">JQuery UI</a>
							</li>
						</ul>
					</li>
					<li>
						<a href="ajax/calendar.html"><i class="fa fa-lg fa-fw fa-calendar"><em>3</em></i> <span class="menu-item-parent">Calendar</span></a>
					</li>
					<li>
						<a href="#"><i class="fa fa-lg fa-fw fa-windows"></i> <span class="menu-item-parent">Miscellaneous</span></a>
						<ul>
							<li>
								<a href="ajax/typography.html">Typography</a>
							</li>
							<li>
								<a href="ajax/pricing-table.html">Pricing Tables</a>
							</li>
							<li>
								<a href="ajax/invoice.html">Invoice</a>
							</li>
							<li>
								<a href="login.html" target="_top">Login</a>
							</li>
							<li>
								<a href="register.html" target="_top">Register</a>
							</li>
							<li>
								<a href="lock.html" target="_top">Locked Screen</a>
							</li>
							<li>
								<a href="ajax/error404.html">Error 404</a>
							</li>
							<li>
								<a href="ajax/error500.html">Error 500</a>
							</li>
							<li>
								<a href="ajax/blank_.html">Blank Page</a>
							</li>
							<li>
								<a href="ajax/email-template.html">Email Template</a>
							</li>
							<li>
								<a href="ajax/search.html">Search Page</a>
							</li>
							<li>
								<a href="ajax/ckeditor.html">CK Editor</a>
							</li>
						</ul>
					</li>
					<li>
						<a href="#"><i class="fa fa-lg fa-fw fa-file"></i> <span class="menu-item-parent">Other Pages</span></a>
						<ul>
							<li>
								<a href="ajax/forum.html">Forum Layout</a>
							</li>
							<li>
								<a href="ajax/profile.html">Profile</a>
							</li>
							<li>
								<a href="ajax/timeline.html">Timeline</a>
							</li>
						</ul>	
					</li>
					
				</ul>
			</nav>
			<span class="minifyme"> <i class="fa fa-arrow-circle-left hit"></i> </span>

		</aside>
		<!-- END NAVIGATION -->

		<!-- MAIN PANEL -->
		<div id="main" role="main">

			<!-- RIBBON -->
			<div id="ribbon">

				<span class="ribbon-button-alignment"> <span id="refresh" class="btn btn-ribbon" data-title="refresh"  
				rel="tooltip" data-placement="bottom" data-original-title="<i class='text-warning fa fa-warning'>
				</i> Warning! This will reset all your widget settings." data-html="true" data-reset-msg="Would you like to RESET all your saved widgets and clear LocalStorage?">
				<i class="fa fa-refresh"></i></span> </span>

				<!-- breadcrumb -->
				<ol class="breadcrumb">
					<!-- This is auto generated -->
				</ol>
				<!-- end breadcrumb -->

				<!-- You can also add more buttons to the
				ribbon for further usability

				Example below:

				<span class="ribbon-button-alignment pull-right">
				<span id="search" class="btn btn-ribbon hidden-xs" data-title="search"><i class="fa-grid"></i> Change Grid</span>
				<span id="add" class="btn btn-ribbon hidden-xs" data-title="add"><i class="fa-plus"></i> Add</span>
				<span id="search" class="btn btn-ribbon" data-title="search"><i class="fa-search"></i> <span class="hidden-mobile">Search</span></span>
				</span> -->

			</div>
			<!-- END RIBBON -->

			<!-- MAIN CONTENT -->
			<div id="content">
					
			</div>
			<!-- END MAIN CONTENT -->

		</div>
		<!-- END MAIN PANEL -->

		<!-- SHORTCUT AREA : With large tiles (activated via clicking user name tag)
		Note: These tiles are completely responsive,
		you can add as many as you like
		-->
		<div id="shortcut">
			
		</div>
		
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">Add Ticket History</h4>
			</div>
			<div class="modal-body">                                                                                                                              
				<div class="row">
					<div class="col-md-12" id="ModalContent">
						<form action="ticket_list/InsertWorkHistory" id="wh_form" class="smart-form" novalidate="novalidate" method="POST">
							<ul class="nav nav-tabs bordered" id="ticketTabs">
								<li id="ticket_detail" class="active">
									<a data-toggle="tab" href="#formContent"><i class="fa fa-fw fa-lg fa-gear"></i> Ticket Detail </a>
								</li>
								<li id="work_history" class="">
									<a data-toggle="tab" href="#workContent"><i class="fa fa-fw fa-lg fa-calendar"></i> Work History</a>
								</li>
							</ul>
								<div class="tab-content padding-10" id="myTabContent1">
									<div id="formContent" class="tab-pane fade active in">
										
									</div>
									<div id="workContent" class="tab-pane fade">
										
									</div>
								</div>
								<input type="hidden" name="pos" id="pos" value="" />
								<input type="hidden" name="STICKET_ID" id="STICKET_ID" value="" />
						</form>
					</div>
				</div>

			</div>
			<input type="hidden" id="hiddenElement" value="true"/>
			<div class="modal-footer" id="buttonList">

			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>


<!-- end widget grid -->
<input type="hidden" id="hiddenElement" value="true"/>
		<!-- END SHORTCUT AREA -->

		<!--================================================== -->

		<!-- PACE LOADER - turn this on if you want ajax loading to show (caution: uses lots of memory on iDevices)
		<script data-pace-options='{ "restartOnRequestAfter": true }' src="<?php echo base_url(); ?>template/backend_default/js/plugin/pace/pace.min.js"></script>-->

		<!-- Link to Google CDN's jQuery + jQueryUI; fall back to local -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/libs/jquery-2.0.2.min.js"></script>
		
		<script src="<?php echo base_url(); ?>template/backend_default/js/libs/jquery-ui-1.10.3.min.js"></script>
		
		<script src="<?php echo base_url(); ?>template/backend_default/js/jquery.multi-select.js"></script>
		<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/multi-select.css">
		<script src="<?php echo base_url(); ?>template/backend_default/js/jquery.quicksearch.js"></script>
		<!--<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>template/backend_default/css/quicksearch.css">-->
		
		<!-- JS TOUCH : include this plugin for mobile drag / drop touch events
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/jquery-touch/jquery.ui.touch-punch.min.js"></script> -->

		<!-- BOOTSTRAP JS -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/bootstrap/bootstrap.min.js"></script>

		<!-- CUSTOM NOTIFICATION -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/notification/SmartNotification.min.js"></script>

		<!-- JARVIS WIDGETS -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/smartwidgets/jarvis.widget.min.js"></script>

		<!-- EASY PIE CHARTS -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/easy-pie-chart/jquery.easy-pie-chart.min.js"></script>

		<!-- SPARKLINES -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/sparkline/jquery.sparkline.min.js"></script>

		<!-- JQUERY VALIDATE -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/jquery-validate/jquery.validate.min.js"></script>

		<!-- JQUERY MASKED INPUT -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/masked-input/jquery.maskedinput.min.js"></script>

		<!-- JQUERY SELECT2 INPUT -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/select2/select2.min.js"></script>

		<!-- JQUERY UI + Bootstrap Slider -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/bootstrap-slider/bootstrap-slider.min.js"></script>

		<!-- browser msie issue fix -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/msie-fix/jquery.mb.browser.min.js"></script>

		<!-- FastClick: For mobile devices: you can disable this in app.js
		<script src="<?php echo base_url(); ?>template/backend_default/js/plugin/fastclick/fastclick.js"></script> -->

		<!--[if IE 7]>

		<h1>Your browser is out of date, please update your browser by going to www.microsoft.com/download</h1>

		<![endif]-->

		<!-- Demo purpose only -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/demo.js"></script>

		<!-- MAIN APP JS FILE -->
		<script src="<?php echo base_url(); ?>template/backend_default/js/app.js"></script>

		<!-- Your GOOGLE ANALYTICS CODE Below -->
		<script type="text/javascript">
		base_url = '<?php echo base_url();?>';
		
		function loadDashboardTables() {

			loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/jquery.dataTables.min.js", dt_1);
			loadScript("<?php echo ASSETS_URL.TEMPLATE?>/js/plugin/jquery-form/jquery.form.js");
		
			function dt_1() {
				loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/dataTables.fixedColumns.min.js", dt_2);
			}
			
			function dt_2() {
				loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/dataTables.tableTools.min.js", dt_3);
			}
			
			function dt_3() {
				loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/dataTables.responsive.min.js", dt_4);
			}
			
			function dt_4(){
				loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/dataTables.colReorder.min.js", dt_5);
			}
			
			function dt_5(){
				loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/dataTables.colVis.min.js", dt_7);
			}
			
			function dt_7() {
				loadScript("<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/DT_bootstrap_10.js", runDsTables);
			}

		}
		
		function runDsTables() {
			$('#wh_table').DataTable({
				
				sDom: 'T<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"pull-right"ip>>>',
				PaginationType : "bootstrap",
				responsive : true,
				oLanguage: { "sSearch": "", 
					"sLengthMenu" : "_MENU_ &nbsp;"},
				tableTools: {
					"sSwfPath": "<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/swf/copy_csv_xls_pdf.swf",
					"aButtons": [{
							"sExtends":    "collection",
							"sButtonText": "Save",
							"aButtons":    [ "csv", "xls", "pdf" ]
						}]
				} 
			});		
			$('.dataTables_filter input').attr("placeholder", "Search"); 
			/* $('#wh_table').dataTable({
				"aaSorting":[[0,"desc"]],
				"sPaginationType" : "bootstrap_full"
			}); */
		}

		function updateProgram(id){
			$.ajax({
				url:"<?php echo BASE_URL?>home/updateProgram",
				type: "POST",
				data: "id="+id,
				dataType:"html",
				success : function(msg){
					window.location.reload();
				}
			});
		}
		
		function updateLang(lang){
			$.ajax({
				url:"<?php echo BASE_URL?>home/updateLanguage",
				type: "POST",
				data: "id="+lang,
				dataType:"html",
				success : function(msg){
					window.location.reload();
				}
			});
		}
		
		function loadPage(module_name,module_title){
		    $("#loading_anim").show();
			$.ajax({
				url:"<?php echo BASE_URL?>"+module_name,
				type: "POST",
				dataType:"html",
				success : function(msg){
					$("#content").html(msg);
					$('li[id*="mod"]').removeClass();
					$('li[id*="mod"]').find("i").removeClass("icon-white");
					$("#mod_"+module_name).addClass('active');
					$("#mod_"+module_name).find("i").addClass('icon-white');
					document.title = "<?php echo APP_NAME;?> - "+module_title;
					$("#loading_anim").hide();
				},
				error :function(msg){
					$("#content").html("<span class='label label-important'>Error : Modules <i>"+module_name+"</i> not found </span>");
					$('li[id*="mod"]').removeClass();
					$('li[id*="mod"]').find("i").removeClass("icon-white");
					$("#mod_"+module_name).addClass('active');
					$("#mod_"+module_name).find("i").addClass('icon-white');
					$("#loading_anim").hide();
				}
			});
	  }
		
		function loadPage2(module_name,block_content,controller_name,tab,id){
			if(typeof controller_name =="undefined"){
				var controller_name = "";
			}
            if(typeof tab =="undefined"){
				var tab = "";
			}
            if(typeof id =="undefined"){
				var id = "";
			}
            
		    $("#loading_anim").show();
			$.ajax({
				url:"<?php echo BASE_URL?>"+module_name+controller_name,
				type: "POST",
                data:"tab=" + tab + "&id="+id,
				dataType:"html",
				success : function(msg){
					$("#"+block_content).html(msg);
					$('li[id*="mod"]').removeClass();
					$('li[id*="mod"]').find("i").removeClass("icon-white");
					$("#mod_"+module_name).addClass('active');
					$("#mod_"+module_name).find("i").addClass('icon-white');
					//document.title = "<?php echo APP_NAME;?> - "+module_name;
					$("#loading_anim").hide();
				},
				error :function(msg){
					$("#"+block_content).html("<span class='label label-important'>Error : Modules <i>"+module_name+"</i> not found </span>");
					$('li[id*="mod"]').removeClass();
					$('li[id*="mod"]').find("i").removeClass("icon-white");
					$("#mod_"+module_name).addClass('active');
					$("#mod_"+module_name).find("i").addClass('icon-white');
					$("#loading_anim").hide();
				}
			});
	  }
		/*
		  var _gaq = _gaq || [];
		  _gaq.push(['_setAccount', 'UA-43548732-3']);
		  _gaq.push(['_trackPageview']);
		
		  (function() {
		    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		  })();
		*/
		
		
	function addActionModal(id){
		$("#STICKET_ID").val(id);
		$.ajax({
            type:"POST",
            url:"<?php echo BASE_URL ?>ticket_list/addAction/",
            data:"ticket_id="+id,
            dataType :"html",
            success:function(msg){
		       var data = msg.split('######');
               $("#formContent").html(data[0]);
               $("#buttonList").html(data[1]);
			   $("#pos").val("form");
			   $("#hiddenElement").val("true");
			   $(".fa-spin").remove();
			   $("button[type=button]").removeAttr("disabled");
			   viewWorkHistory();
               setTimeout('runFormValidation', 500);
            }
        });
		$("#myModal").modal('show');
	}
	

	function runFormValidation() {
		
		var $checkoutForm = $('#wh_form').validate({
			rules : {
				RESPONSE : {
					required : true
				}
			},
			messages : {
				RESPONSE : {
					required : 'Response is required'
				}
			},
			submitHandler : function(form) {
				var once = $("#hiddenElement").val();
				if (once == "true") {
					$(form).ajaxSubmit({
						beforeSerialize:function($Form, options){
                            return true; 
                        },
						beforeSubmit: function() {
							if(confirm("Add work history?")){
								$("#hiddenElement").val("false");
								$("#cancel").attr("disabled","disabled");
								$("button[type=button]").attr("disabled","disabled");
								$("button[type=button]").append('<i class="fa fa-gear fa-1x fa-spin"></i>');
							}
							else{
								return false;
							}
						},
						dataType: 'json',
						success : function(msg) {
							if (msg.msg == "noauth") {
								window.location = base_url;
							}
							else if (msg.error == true) {
								write_error_html(msg.field);
								//button manipulating
								$("#hiddenElement").val("true");
								$(".fa-spin").remove();
								$("#cancel").removeAttr("disabled");
								$("button[type=button]").removeAttr("disabled");
							} else {
								id = $("#STICKET_ID").val();
								$("#RESPONSE").val("");
								$("#hiddenElement").val("true");
								$(".fa-spin").remove();
								$("#cancel").removeAttr("disabled");
								$("button[type=button]").removeAttr("disabled");
								addActionModal(id);
								$("#work_history").attr("class","active");
								$("#ticket_detail").removeAttr("class");
								$("#formContent").attr("class","tab-pane");
								$("#workContent").attr("class","tab-pane fade active in");
							}
						}
					});
				}
			},
			errorPlacement : function(error, element) {
				error.insertAfter(element.parent());
			}
		});
	}
	
	function addWorkHistory(){
		runFormValidation();
		$("#wh_form").submit();
	}
	
	function viewWorkHistory(action){
		id = $("#STICKET_ID").val();
		$.ajax({
            type:"POST",
            url:"<?php echo BASE_URL ?>ticket_list/viewWorkHistory/",
            data:"ticket_id="+id,
            dataType :"html",
            success:function(msg){
               $("#workContent").html(msg);
			   $("#pos").val("list");
			   $("#wh_table").unbind();
			   loadDashboardTables();
            }
        });
	}
	
	function resolveTicket(id){
		if(confirm("Solve this ticket?")){
			id = $("#STICKET_ID").val();
			reason = $("#RESPONSE").val();
			resolution = $("#RESOLUTION").val();
			var error = false;
			if(reason==''){	
				var msg = new Array();
				msg['field'] = new Array();
				msg['field'][0] = {"name":"RESPONSE","message":"Resolve reason is required"};
				error = true;
			}
			if(resolution ==''){
				var msg = new Array();
				msg['field'] = new Array();
				msg['field'][1] = {"name":"RESOLUTION","message":"Resolve resolution is required"};
				error = true;
			}
			if(error == true){
				write_error_html(msg.field);
				return false;
			}
			$.ajax({
				type:"POST",
				url:"<?php echo BASE_URL ?>ticket_list/resolveTicket/",
				data:"ticket_id="+id+"&reason="+reason+"&resolution="+resolution,
				dataType :"html",
				success:function(msg){
				  if(msg=="no_priv"){
						alert("You don't have privilege to act this action");
					}
					else if(msg=="ok"){
						addActionModal(id);
					}
					else{
						var errmsg = new Array();
						errmsg['field'] = new Array();
						errmsg['field'][0] = {"name":"RESPONSE","message":msg};
						write_error_html(errmsg.field);
					}
				}
			});
		}
	}
	
	function closeTicket(id){
		if(confirm("Close this ticket?")){
			id = $("#STICKET_ID").val();
			reason = $("#RESPONSE").val();
			resolution = $("#RESOLUTION").val();
			var error = false;
			var msg = new Array();
			msg['field'] = new Array();
			if(reason==''){	
				msg['field'][0] = {"name":"RESPONSE","message":"Close reason is required"};
				error = true;
			}
			if(resolution ==''){
				msg['field'][1] = {"name":"RESOLUTION","message":"Close resolution is required"};
				error = true;
			}
			if(error == true){
				write_error_html(msg.field);
				return false;
			}
			
			$.ajax({
				type:"POST",
				url:"<?php echo BASE_URL ?>ticket_list/closeTicket/",
				data:"ticket_id="+id+"&reason="+reason+"&resolution="+resolution,
				dataType :"html",
				success:function(msg){
					if(msg=="no_priv"){
						alert("You don't have privilege to act this action");
					}
					else if(msg=="ok"){
						addActionModal(id);
					}
					else{
						var errmsg = new Array();
						errmsg['field'] = new Array();
						errmsg['field'][0] = {"name":"RESPONSE","message":msg};
						write_error_html(errmsg.field);
					}
				}
			});
		}
	}
	
	function escalateTicket(){
		if(confirm("Escalate this ticket?")){
			id = $("#STICKET_ID").val();
			reason = $("#RESPONSE").val();
			var error = false;
			if(reason==''){	
				var msg = new Array();
				msg['field'] = new Array();
				msg['field'][0] = {"name":"RESPONSE","message":"Escalate reason is required"};
				error = true;
			}
			if(error == true){
				write_error_html(msg.field);
				return false;
			}
			$.ajax({
				type:"POST",
				url:"<?php echo BASE_URL ?>ticket_list/escalateTicket/",
				data:"ticket_id="+id+"&reason="+reason,
				dataType :"html",
				success:function(msg){
					if(msg=="no_priv"){
						alert("You don't have privilege to act this action");
					}
					else if(msg=="ok"){
						//alert("Hello Hell");
						addActionModal(id);
						$("#ticket_detail").attr("class","");
						$("#work_history").attr("class","active");
						$("#formContent").attr("class","tab-pane");
						$("#workContent").attr("class","tab-pane fade active in");
					}
					else{
						var errmsg = new Array();
						errmsg['field'] = new Array();
						errmsg['field'][0] = {"name":"RESPONSE","message":msg};
						write_error_html(errmsg.field);
					}
				}
			});
		}
	}
	
	function reOpenTicket(id){
		if(confirm("Re-Open this ticket?")){
			id = $("#STICKET_ID").val();
			reason = $("#RESPONSE").val();
			var error = false;
			if(reason==''){	
				var msg = new Array();
				msg['field'] = new Array();
				msg['field'][0] = {"name":"RESPONSE","message":"Re-Open reason is required"};
				error = true;
			}
			if(error == true){
				write_error_html(msg.field);
				return false;
			}
			$.ajax({
				type:"POST",
				url:"<?php echo BASE_URL ?>ticket_list/reOpenTicket/",
				data:"ticket_id="+id+"&reason="+reason,
				dataType :"html",
				success:function(msg){
					if(msg=="no_priv"){
						alert("You don't have privilege to act this action");
					}
					else if(msg=="ok"){
						addActionModal(id);
					}
					else{
						var errmsg = new Array();
						errmsg['field'] = new Array();
						errmsg['field'][0] = {"name":"RESPONSE","message":msg};
						write_error_html(errmsg.field);
					}
				}
			});
		}
	}
	
		</script>


	</body>

</html>