<?php include '../header.php'; ?>
<?php include '../sidemenu.php'; ?>
<link rel="stylesheet" href="<?=$app_url;?>upload/css/blueimp-gallery.min.css">
<link rel="stylesheet" href="<?=$app_url;?>upload/css/jquery.fileupload.css">
<link rel="stylesheet" href="<?=$app_url;?>upload/css/jquery.fileupload-ui.css">
<noscript><link rel="stylesheet" href="<?=$app_url;?>upload/css/jquery.fileupload-noscript.css"></noscript>
<noscript><link rel="stylesheet" href="<?=$app_url;?>upload/css/jquery.fileupload-ui-noscript.css"></noscript>  
<style>
.fade:not(.show) {
    opacity: 100%;
}
.progress{
    background-color: #fff;
}
</style>
<div class="content-wrapper">
     <!-- Content Header (Page header) -->
     <section class="content-header">
        <h1>
           <?php 
            if($_GET['for']=="spareparts"){
        ?>
                <h1 class="page-header">Photo Upload</h1>
        <?php
            }
        ?>
        </h1>
        <ol class="breadcrumb">
          
        </ol>
     </section>
     <!-- Main content -->
     <section class="content">
        <!-- Default box -->
        <div class="row">
            <div class="col-md-12">
               <div class="card card-outline card-primary">
                  <div class="card-header with-border">
                     <h3 class="card-title">Photos for Stock Issue No.: <b><?php echo $_GET['id'] ?></b></h3>
                  </div>
                  <form id="fileupload" action="" method="POST" enctype="multipart/form-data">
                        <input type="hidden" id="id" name="id" value="<?php echo $_GET['id'] ?>" />
                        <input type="hidden" id="for" name="for" value="<?php echo $_GET['for'] ?>" />
                        <div class="row fileupload-buttonbar">
                            <div class="col-md-7" style="padding-left:20px;padding-top:10px">
                                <span class="btn btn-success fileinput-button">
                                    <i class="glyphicon glyphicon-plus"></i>
                                    <span>Add files</span>
                                    <input type="file" name="files[]" multiple>
                                </span>
                                <button type="submit" class="btn btn-primary start">
                                    <i class="glyphicon glyphicon-upload"></i>
                                    <span>Start upload</span>
                                </button>
                                <button type="reset" class="btn btn-warning cancel">
                                    <i class="glyphicon glyphicon-ban-circle"></i>
                                    <span>Cancel upload</span>
                                </button>
                                <button type="button" class="btn btn-danger delete">
                                    <i class="glyphicon glyphicon-trash"></i>
                                    <span>Delete</span>
                                </button>
                                <input type="checkbox" class="toggle">
                                <span class="fileupload-process"></span>
                            </div>
                            <div class="col-md-5 fileupload-progress fade" style="padding-right:20px;">
                                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                                    <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                                </div>
                                <div class="progress-extended">&nbsp;</div>
                            </div>
                        </div>
                        <table style="margin-top: 24px;" role="presentation" class="table table-striped table-bordered"><tbody class="files"></tbody></table>
                    </form>
                </div>
            </div>
        </div>
        
        <!-- /.box -->
        <div class="modal fade" tabindex="-1" role="dialog" id="myModal">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
            <div class="modal-header">
                <h3 class="card-title" style="text-align: left;">Photo</h3>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>    
            </div>
            <div class="modal-body">
                <center><img id="sf_img_large"/></center>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
     </section>
     <!-- /.content -->
    </div>
  <?php include '../footer.php'; ?>
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-upload fade">
        <td>
            <span class="preview"></span>
        </td>
        <td>
            <p class="name">{%=file.name%}</p>
            <strong class="error text-danger"></strong>
        </td>
        <td>
            <p class="size">Processing...</p>
            <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
        </td>
        <td>
            {% if (!i && !o.options.autoUpload) { %}
                <button class="btn btn-primary start" disabled>
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Start</span>
                </button>
            {% } %}
            {% if (!i) { %}
                <button class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel</span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">
        <td>
            <span class="preview">
                {% if (file.thumbnailUrl) { %}
                    <div onclick='showImage(this)' style=''><img style="width:80px;heigh:auto;" src="{%=file.thumbnailUrl%}"></div>
                {% } %}
            </span>
        </td>
        <td>
            <p class="name">
                {% if (file.url) { %}
                    <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
                {% } else { %}
                    <span>{%=file.name%}</span>
                {% } %}
            </p>
            {% if (file.error) { %}
                <div><span class="label label-danger">Error</span> {%=file.error%}</div>
            {% } %}
        </td>
        <td>
            <span class="size">{%=o.formatFileSize(file.size)%}</span>
        </td>
        <td>
            {% if (file.deleteUrl) { %}
                <button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                    <i class="glyphicon glyphicon-trash"></i>
                    <span>Delete</span>
                </button>
                <input type="checkbox" name="delete" value="1" class="toggle">
            {% } else { %}
                <button class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel</span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
<script>
    function showImage(obj){
        $("#sf_img_large").attr("src", $(obj).find("img").eq(0).attr("src").replace(/thumbnail\//g, ""));
        // $("#sf_img_large").attr("src", $(obj).attr("src").replace(/thumbnail\//g, "") );
        $(".modal-body img").each(function() { 
            $(this).css("width","50%");
            $(this).css("height","auto");
        });
        $("#myModal").modal('show');
   }
</script>
<script src="<?=$app_url;?>upload/js/common.js"></script>
<script src="<?=$app_url;?>upload/js/tmpl.min.js"></script>
<script src="<?=$app_url;?>upload/js/load-image.all.min.js"></script>
<script src="<?=$app_url;?>upload/js/canvas-to-blob.min.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.blueimp-gallery.min.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.iframe-transport.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload-process.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload-image.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload-audio.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload-video.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload-validate.js"></script>
<script src="<?=$app_url;?>upload/js/jquery.fileupload-ui.js"></script>
<script src="<?=$app_url;?>upload/js/main.js"></script>
