<html>
    <head>
        <title><?php echo $b_header['title']; ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" media="all">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="<?php echo base_url(); ?>assets/ckeditor/plugins/ckeditor_wiris/integration/WIRISplugins.js?viewer=image"></script>
      
<style type="text/css">
body{max-height:350px !important;
page-break-after: always; margin-bottom:10px;} 
h3{margin:0;}
.relative{position:relative;}
.text-bold{font-weight:bold;}
h4,hr{margin:2px;}
.logo{height:100px;position:absolute;top:0;left:0;}
.page{box-sizing: border-box;border-radius:10px;height:100%;padding:5px;}
.table tr td{border:2px dotted #17a05e !important;}
.table-match tr td{border:1px solid #000 !important;padding:5px;}
.table-match tr th{text-align: center;border:1px solid #000 !important;padding:5px;}
.table-match {
      width:70%;
      margin:0 auto;
}
@media print{
.logo{height:80px;}
.page{page-break-after:always;}
}
    </style>
    </head>
    <body id="datatable-buttons">
      <?php
      $chapter=$data['chapter'];   
      $count=count($data['chapter']);
      $level=$data['level'];
      $class=$data['class'];
      ?>
<div class="watermark" style="width:100%;position:fixed;top:30%;opacity:0.1;"><img src="<?php echo base_url().$b_header['b_logo'];?>" style="display:block;margin:0 auto;width:600px;" alt="logo"></div>
        <div class="page">
        <div class="container-fluid">
          <div class="row header">
              <div class="col-md-12 col-sm-12 col-xs-12">
                  <div class="row">
                      <div class="col-md-2 col-sm-2 col-xs-2 relative"><img class="logo" src="<?php echo base_url().$b_header['b_logo'];?>"></div>
                      <div class="col-md-8 col-sm-8 col-xs-8 text-center">
                            <h4 class="wd-100"><?php echo $b_header['title']; ?></h4>
                            <h5 class="wd-100"><?php echo $b_header['tagline']; ?></h5>
                            <h5 class="wd-100"><?php echo $b_header['name']." - HALF YEARLY EXAMINATION 2017"; ?></h5>
                      </div>
                      <div class="col-md-2 col-sm-2 col-xs-2 relative"><img class="logo" src="<?php echo base_url().$b_header['b_logo'];?>"></div>
                  </div>  
              </div>
          </div>
          <div class="row header">
              <div class="col-md-12 col-sm-12 col-xs-12" style="padding:0;">
                  <div class="row upper-header" style="border-top:2px solid #17a05e;border-bottom:2px solid #17a05e;padding:5px;margin:5px;">
                              <div class="row">
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold">Class:</h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold"><?php echo $classes['class_name']; ?></h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold">Subject:</h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold"><?php echo $subject['name']; ?></h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold">Time:</h5>
                                    </div>
                                    <div class="col-md-2 col-sm-2 col-xs-2">
                                          <h5 class="text-bold"><?php echo $data['time']; ?></h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold">Date:</h5>
                                    </div>
                                    <div class="col-md-2 col-sm-2 col-xs-2">
                                          <h5 class="text-bold"><?php echo  date("d-m-Y", strtotime($data['dateofpaper'])); ?></h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold">T.Marks:</h5>
                                    </div>
                                    <div class="col-md-1 col-sm-1 col-xs-1">
                                          <h5 class="text-bold"><?php echo $data['totalmarks'];?></h5>
                                    </div>
                              </div>
                      </div>
                  </div>  
              </div>
          </div>
        
<!--//====================================draw Questions===============================================-->
 <?php if(!empty($data['mcq']) && !empty($data['mcq_marks']) ){
      $subject=$data['subject'];
      $c=0;
 foreach($chapter as $key=> $chap){
      $checkpara= $this->db->query("SELECT * FROM `drawing_question` where class=$class AND subject=$subject AND chapter=$chap AND  level='$level' ")->result_array();
      $c+=count($checkpara);
     }
     if($c>0)  {
       ?>
          <div class="row magic_hover">
              <div class="col-md-11 col-sm-11 col-xs-11 col-md-offset-1">
                  <h4 style="font-weight:bold;"><?php echo $data['mcq_tag']; ?></h4>
                  <div class="row" >
<?php
           $j=1;
           $mcq_limit=$data['mcq'];
           $this->db->select('*');
           $this->db->from('drawing_question');
           $this->db->join('chapters','drawing_question.chapter=chapters.id');
           $this->db->join('class','class.class_id=drawing_question.class');
           $this->db->join('subject','subject.id=drawing_question.subject');
           $this->db->where('drawing_question.is_delete',0);
           $this->db->where_in('drawing_question.chapter', $chapter);
           $dat['query_print']=$this->db->where('drawing_question.level',$level)->order_by('rand()')->limit($mcq_limit)->get()->result_array();
           //var_dump("<pre>",$query_print);die();
           foreach ( $dat['query_print'] as $value) {          
                          
                ?>
                        <div class="col-md-11 col-sm-11 col-xs-11"><span class="question "><b class="magic_question">(<?php echo $j++;?>)</b></span> <b> <?php echo $value['question'] ;?></b></div>
                        <div class="col-md-1 col-sm-1 col-xs-1 magic_swap"><b>(<?php echo $data['mcq_marks'] ;?>)</b></div>
                        <div class="clearfix"></div>
                       
    <div class="thumbnail">
      <img src="<?php echo base_url().$value['image']; ?>" alt="..." width="700px" height="500px" class="img-responsive" >
   
      
     
    </div>
  
                     
                     
            <?php }
             ?>
                  </div>  
              </div>
          </div>
 <?php  }}?>




     

          <br /><br /><br />
          <div class="col-xs-12 col-md-12 text-center">
                  <h4><i>The End | Best of Luck<i></h4>
              

                  <h5><i>This is a software generated paper<i></h5>
                  <div class="col-lg-12 col-md-12 text-center">
                        <img src="<?php echo base_url(); ?>assets/images/softvilla-logo.png" style="width:150px;" alt="logo"><span style="border:1px solid black;height:300px;margin:0 10px;padding:25 0;"></span><img src="<?php echo base_url(); ?>assets/images/slm-qr-code.jpg" style="width:80px;" alt="logo">
                  </div>
          </div>
        </div></div>
        <script>//window.print();</script>
    </body>
</html>
<script>
      $(window).on("load", function() {
            var button="<div class='col-lg-12 magic-align' style='display:none;'><button type='button' class='btn btn-primary btn-sm magic-align-btn'>Left/Right</button></div>";
            $('.magic_hover').prepend(button);
      });
      $(function(){
            $(document).on('mouseenter', '.magic_hover', function () {
                    $(this).find(".magic-align").show();
                }).on('mouseleave', '.magic_hover', function () {
                    $(this).find(".magic-align").hide();
                });
            $(document).on('click', '.magic-align-btn', function () {
                    var status=$(this).parent().parent().css('textAlign');
                    var div=$(this).parent().parent();
                    var swaps=div.find('.magic_swap');
                    var quest=div.find('.magic_question');
                    var quest_mirror=div.find('.magic_question_mirror');
                    var magic_arrange=div.find('.magic_arrange');
                    var magic_quest_no=div.find('.magic_quest_no');
                    if(status=='start' || status=='left'){
                        div.css('text-align','right');
                        quest.addClass('pull-right');
                        quest_mirror.addClass('pull-left');
                        quest_mirror.removeClass('pull-right');
                        for (i = 0; i < swaps.length; i++) { 
                             swaps.eq(i).prev().find('b').addClass('pull-right'); 
                             swaps.eq(i).insertBefore(swaps.eq(i).prev());
                        }
                        magic_arrange.addClass('pull-right');
                        magic_quest_no.find('b').addClass('pull-left');
                    }
                    else {
                        div.css('text-align','left'); 
                        quest.removeClass('pull-right');
                        quest_mirror.addClass('pull-right');
                        quest_mirror.removeClass('pull-left');
                        for (i = 0; i < swaps.length; i++) {
                              swaps.eq(i).next().find('b').removeClass("pull-right");  
                              swaps.eq(i).insertAfter(swaps.eq(i).next());
                        }
                        magic_arrange.removeClass('pull-right');
                        magic_quest_no.find('b').removeClass('pull-left');
                    }
            });
            
      });
</script>

<script>
function myFunctionn()
{
      var key = <?php echo json_encode($dat)?>;
      console.log(key);
      
 
         
    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", "yes");

   
       
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", "answer");
            hiddenField.setAttribute("value", JSON.stringify(key));

//console.log(hiddenField.getAttribute("value"));
            form.appendChild(hiddenField);
        


    document.body.appendChild(form);
    form.submit();
   
    
}
</script>






