<?php
require_once('include/MVC/View/views/view.list.php');

class outr_global_loggerViewList extends ViewList
{
	function display()
    {
		$logger_setting = outright_logger_setting("outr_global_logger");
		$log_imp="Log Important";
		$log_all="Log Everything";
		if($logger_setting['logger_level']>1){
		$log_imp .=" >>";
		}
		else{
		$log_all .=" >>";
		}		
		echo outright_logger_status_message('outr_global_logger');
		$cbutton=" <div class='sidenav'><a></a><a></a><a></a><a></a><a></a><a></a><a></a><a></a><a></a><a href='index.php?module=outr_global_logger&action=start_logger'>Start Logger</a><a href='index.php?module=outr_global_logger&action=stop_logger'>Stop Logger</a><a href='index.php?module=outr_global_logger&action=clear_logs'>Clean All logs</a><a  href='index.php?module=outr_global_logger&action=change_logger_setting&level=3'>".$log_imp."</a><a href='index.php?module=outr_global_logger&action=change_logger_setting&level=1'>".$log_all."</a><a id='outright_get_suitecrm_log' style='cursor: pointer;'>SuiteCRM Log</a><a href='index.php?module=outr_global_logger&action=download_suitecrm&file=suitecrm.log'>Download SUITECRM.LOG</a><a></a><a href='index.php?module=outr_global_logger&action=remove_suitecrm&file=suitecrm.log'>Remove SUITECRM.LOG</a><a></a><a></a><a href='index.php?module=outr_global_logger&action=index'>REFRESH</a></div>";
		echo '<script>$("document").ready(function(){if ( $(".button-toggle-expanded")[0] ) {$(".button-toggle-expanded").click();}$(".sidebar_container").after("'.$cbutton.'");$(".sidebar_container").css("display","none")});</script>';
		?>
		<script>
			$("document").ready(function(){
				setInterval(function(){
					$.ajax({
						url: 'index.php?module=outr_global_logger&action=outright_logger_action&to_pdf=1',
						type:"POST",
						data:{clg:"check_new_log"},
						success: function(data){
							if($.trim(data)=='yes'){
								window.location.reload();
							}
						}
					});
				},1000);
			$(".moduleTitle").hide();
				$("#outright_get_suitecrm_log").on("click",function(e) {
					var model='<div id="myModal1" class="modal fade" role="dialog">  <div class="modal-dialog">    <div class="modal-content">      <div class="modal-header">       <button type="button" class="close" data-dismiss="modal">&times;</button>        <h4 class="modal-title">Modal Header</h4>      </div>      <div class="modal-body">        Enter Lines: <input type="text" name="log_lines" id="log_lines" value="10">    </div>      <div class="modal-footer">       <button type="button"  id="fetch_suitecrm_log" class="btn btn-default fetch_suitecrm_log">Fetch SuiteCRM Log</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>      </div>    </div>  </div></div>';
					$(".send_cstm_mail").after(model);
					$('#myModal1').modal('show');
					$(".fetch_suitecrm_log").on("click",function(e) {
						
						var lines=$("#log_lines").val();
						$.ajax({
						url: 'index.php?module=outr_global_logger&action=outright_logger_action&to_pdf=1',
						type:"POST",
						data:{clg:"get_suitecrm_log_file_data",lines:lines},
						success: function(data){
							alert(data);
						}
					});
						
					});
				});
				
			
		});
			$("document").ready(function(){
				$(".copy_trello").on("click",function(e) {
				$(".copy_trello").attr("title","Copy to clipboard");
				$(".copy_trello").css("background","#f08377");
				$(".copy_trello").text("Copy");
				
						var myCode=$("input#"+this.id+"_outright").val();
						var fulldata = document.createElement("textarea");
						document.body.appendChild(fulldata);
						fulldata.value = myCode;
						fulldata.select();
						try {
							document.execCommand("copy", false);
							fulldata.remove();
							$("a#"+this.id).text("Copied");
							$("a#"+this.id).attr("title","Copied to clipboard!");
							$("a#"+this.id).css("background","#9cd7e8");
						  }
						  catch (err) {
						  fulldata.remove();
							alert("unable to copy text");
						  }
					});
			});
			$("document").ready(function(){
				var model='<div id="myModal" class="modal fade" role="dialog">  <div class="modal-dialog">    <div class="modal-content">      <div class="modal-header">       <button type="button" class="close" data-dismiss="modal">&times;</button>        <h4 class="modal-title">Modal Header</h4>      </div>      <div class="modal-body">        Enter Email: <input type="email" name="email_id" id="email_id"><br><br>          Select User: <select id="users_list"></select> <input type="hidden" id="send_mail_id">    </div>      <div class="modal-footer">       <button type="button" class="btn btn-default" data-dismiss="modal">Send on Mail</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>      </div>    </div>  </div></div>';
				$(".send_cstm_mail").after(model);
				$(".send_cstm_mail").on("click",function(e) {
					$('#myModal').modal('show');
					var id=this.id;
					var in_input=id.split("send_mail_");
					$('#send_mail_id').val('');
					$('#send_mail_id').val(in_input[1]);
					$.ajax({
						url: 'index.php?module=outr_global_logger&action=outright_logger_action&to_pdf=1',
						type:"POST",
						data:{clg:"get_user_options"},
						success: function(data){
							$('#users_list').find('option').remove();
							$('#users_list').append(data);
						}
					});
				
				});
			});
		</script>
		
	
		<style>
			body {
			  font-family: "Lato", sans-serif;
			}

			.sidenav {
			  height: 100%;
			  width: 190px;
			  position: fixed;
			  z-index: 1;
			  top: 0;
			  left: 0;
			  background-color: #534d64;
			  overflow-x: hidden;
			  padding-top: 20px;
			}

			.sidenav a {
			  padding: 6px 8px 6px 16px;
			  text-decoration: none;
			  font-size: 20px;
			  color: #fff;
			  display: block;
			}

			.sidenav a:hover {
			  color: #d5a6a6;
			}

			.main {
			  margin-left: 160px; /* Same as the width of the sidenav */
			  font-size: 28px; /* Increased text to enable scrolling */
			  padding: 0px 10px;
			}

			@media screen and (max-height: 450px) {
			  .sidenav {padding-top: 15px;}
			  .sidenav a {font-size: 18px;}
			}
		</style>
		
		<?php
		 parent::display();
    }
}


