<div class="row" id="info-content" style="display:block">
    <div class="col-md-12">
        <div class="portlet box green-haze" style="position:relative">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-user"></i> Informasi Pasien
                </div>
            </div>
            <div class="portlet-body form">
                <form class="form-horizontal form-bordered form-row-stripped" role="form">
                    <div class="form-body">
                        <div class="form-group">
                            <div class="col-md-6">
                                <div class="row">
                                    <label class="form-control-static col-md-4">Nomor Rekam Medis </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; BBMC-<?=$this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nrm')?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Nama Pasien </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nama_pasien'))?>  / <?=$this->Content_m->get_tipe_pasien($id_re_pasien)?>
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Umur  </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'umur_tahun'))?> TAHUN <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'umur_bulan'))?> BULAN
                                    </p>
                                </div>
                                <div class="row">
                                     <div style="padding:0px; <?=$get_kunjungan->id_dokter_jaga!='-1'?'display: block':'display: none'?>">
                                          <label class="form-control-static col-md-4">Dokter </label>
                                          <p class="form-control-static col-md-8">
                                              : &nbsp; 
                                              <?php 
                                              $id_dokter_jaga = $this->Content_m->get_value('bbmc_tr_kunjungan','id_re_kunjungan',$id_re_kunjungan,'id_dokter_jaga');
                                              echo "<b>".$this->Content_m->get_value('bbmc_re_staff_medis','id_staff_medis',$id_dokter_jaga,'staff_medis')."</b>";
                                              ?>  
                                          </p>
                                      </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="row">
                                    <label class="form-control-static col-md-4">Pendidikan  </label>
                                    <p class="form-control-static col-md-8">
                                        <?php $id_pendidikan = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_pendidikan');
                                        $pendidikan = $this->Content_m->get_value('bbmc_re_jenjang_pendidikan','id_jenj_didik',$id_pendidikan,'nm_jenj_didik');
                                        ?>
                                        : &nbsp; <?=strtoupper($pendidikan)?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Pekerjaan  </label>
                                    <p class="form-control-static col-md-8">
                                        <?php $id_pekerjaan = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_pekerjaan');
                                        $pendidikan = $this->Content_m->get_value('bbmc_re_pekerjaan','id_pekerjaan',$id_pekerjaan,'nm_pekerjaan');
                                        ?>
                                        : &nbsp; <?=strtoupper($pendidikan)?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Alamat  </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'alamat'))?> 
                                    </p>
                                </div>
                            </div>
                        </div>                                    
                    </div>
                </form>

                
            </div>
            
        </div>
    </div>
</div>

<?php if($get_kunjungan->id_dokter_jaga == '0'){ ?>
<div class="alert alert-danger">
Silahkan isi pemeriksaan utama terlebih dahulu.
</div>
<?php }else{ ?>
<div class="row" id="portlet-content">
    <div class="col-md-12">
        <div class="portlet light" style="position:relative">           
            <div class="portlet-body form" id="page-content" style="display:none">
              <form action="#" method="post" id="<?=$controller?>" enctype="multipart/form-data" class="horizontal-form">
               
                <div class="form-body">
                  <div class="alert alert-danger display-hide" style="display:none;" id="error">
                    <button class="close" data-close="alert"></button>
                    <span id="error-text"></span>
                  </div>

                 

                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="icd">
                        <h4 class="form-section" style="margin:0px 0px 5px 0px !important; padding-bottom:10px !important; font-size:13px !important"><i class="fa fa-file-text-o"></i><strong> Foto  </strong><hr style="margin:10px 0px 0px 0px !important">

                         </h4>
                          

                        
                        <div class="table-responsive">
                        <table class="table">
                          <thead>
                              <tr>
                                  <th>File</th>
                                  <th class="text-left"><span class="hide_mobile">Upload </span></th>
                              </tr>
                          </thead>
                          <tbody>
                              <?php 
                              $arr_file = array();
                              $this->db->where('id_reg_pd',$id_re_pasien);
                              $this->db->where('id_re_kunjungan',$id_re_kunjungan);
                              foreach ($this->M_general->select_db('bbmc_tr_laboratorium_dokumen')->result() as $key) {
                                $arr_file[] = $key->file;
                              }


                              ?>
                              <?php for ($i=0; $i < 5 ; $i++) {  ?>
                              
                              <tr>
                                  <td>File foto #<?=$i+1?></td>
                                  <td class="text-left">
                                      <?php 
                                      $file = "foto".($i+1)."_".$id_re_pasien.".jpg";
                                     
                                      if(in_array($file, $arr_file)){ ?>
                                      <img style="width: 200px" src="<?=base_url()?>/media/hasil_lab/<?=$file?>?<?=date('ymdhis')?>"><br>
                                      &nbsp;<a href="<?=site_url()?>/front_office/ugd_dir/ugd/delete_foto/<?=$file?>" onclick="return confirm('anda yakin?')" style="color:red">Delete</a><br><br>
                                      <?php }?>
                                      <input type="file" name="file" class="sel-file" data-id="<?=$i?>"  data-dokumen="foto<?=$i+1?>" data-kunjungan="<?=$id_re_kunjungan?>" accept=".pdf,.png,.jpg,.jpeg;capture=camera"/>
                                      <div style="width:100%; height:10px; margin-top: 5px; background:silver; display: none;" class="progres_bar1_div_foto<?=$i+1?>">
                                          <div class="progress mb-3">
                                              <div class="progress-bar_foto<?=$i+1?> progress-bar-striped bg-primary" role="progressbar" style="" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
                                          </div> 
                                      </div>
                                  </td>
                              </tr>
                              <?php }?>
                          </tbody>
                        </table>
                        </div>

                </div>
                <div class="form-actions right">
                  <a type="button" class="btn default" href="<?= site_url('front_office/'.$controller_dir.$controller) ?>">Kembali</a>
                  <?php if($get_kunjungan->status_resep != '3'){ ?>
                  <button type="submit" class="btn blue"><i class="fa fa-check"></i> Simpan</button>
                  <?php }?>
                </div>
              </form>
            </div>
            <?php $this->load->view('front_office/include/loading');?>
        </div>
    </div>
</div>
<?php }?>



<script type="text/javascript">
	$(document).ready(function() {
    //alert(1);
     /*-------------Datepicker-------------*/
    $(".sel2").select2({
      placeholder: "Pilih .. ",
      language: "id"
    });
    $("#loading-content,#loading").fadeOut("fast", function() {
      $("#page-content").fadeIn("fast");
    });
  });
</script>


<?php $this->load->view('front_office/script/form_data'); ?>



<script type="text/javascript">
    jQuery( document ).ready( function (){

       var id_reg_pd = "<?=@$id_re_pasien?>";
       
       $('.sel-file').change(function(){
            var dok = $(this).attr('data-dokumen');
            var id_kunjungan = $(this).attr('data-kunjungan');
            var id_tindakan = $(this).attr('data-tindakan');

            var i = $(this).attr('data-id');
            //alert(i);
            var file = $( '.sel-file' ).get( i ).files[0],
            formData = new FormData();

            //alert(i);
            //alert(file);
            
            //if(file.size > 1000000){
            if(file.size > 100000000){

                alert('File size melebihi kapasitas standar'); 
                //alert(file.size);
            }else{
                
                var newFileName = dok+"_"+id_reg_pd+".jpg";
                formData.append('file', file, newFileName);
                console.log( file );
                $.ajax( {
                    url        : "<?=site_url('front_office/ajax/upload_file_foto')?>"+'/'+id_reg_pd+'/'+id_kunjungan+'/'+id_tindakan,
                    type       : 'POST',
                    contentType: false,
                    cache      : false,
                    processData: false,
                    data       : formData,
                    xhr        : function ()
                    {
                        var jqXHR = null;
                        if ( window.ActiveXObject )
                        {
                            jqXHR = new window.ActiveXObject( "Microsoft.XMLHTTP" );
                        }
                        else
                        {
                            jqXHR = new window.XMLHttpRequest();
                        }

                        //Upload progress
                        jqXHR.upload.addEventListener( "progress", function ( evt )
                        {
                            if ( evt.lengthComputable )
                            {
                                var percentComplete = Math.round( (evt.loaded * 100) / evt.total );
                                //Do something with upload progress
                                $('.progres_bar1_div_'+dok).css('display','block');
                                //$('.ket1_'+dok).css('display','none');
                                //alert(dok);
                                $('.progress-bar_'+dok).css('width',percentComplete+'%');
                                $('.progress-bar_'+dok).css('border','5px solid green');
                                $('.text_hasil_'+dok).text('Hasil berhasil di upload');
                                
                                console.log( 'Uploaded percent', percentComplete );
                            }
                        }, false );

                        //Download progress
                        jqXHR.addEventListener( "progress", function ( evt )
                        {
                            if ( evt.lengthComputable )
                            {
                                var percentComplete = Math.round( (evt.loaded * 100) / evt.total );
                                //Do something with download progress
                                console.log( 'Downloaded percent', percentComplete );
                            }
                        }, false );

                        return jqXHR;
                    },
                    success    : function ( data )
                    {


                        //$('.sukses').css('display','block');
                        $('.sedang_diperiksa1_'+dok).css('display','table-cell');
                        $('.belum_diupload1_'+dok).css('display','none');
                        
                        
                        console.log( 'Completed.' );
                    }
                } );
            }
        });

    } );

</script>







