<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminKW | Initialize Branch Inventory</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="adminlte/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="adminlte/plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="adminlte/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="adminlte/dist/css/skins/_all-skins.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
    
    <!-- Site wrapper -->
    <div class="wrapper">

      <header class="main-header">
        <!-- Logo -->
        <a href="<?php site_url(); ?>" class="logo">
          <!-- mini logo for sidebar mini 50x50 pixels -->
          <span class="logo-mini"><b>A</b>KW</span>
          <!-- logo for regular state and mobile devices -->
          <span class="logo-lg"><b><?php echo $this->session->user["branch"]; ?></b>&nbsp;Branch</span>
        </a>
        
        <?php $this->load->view('pages/topnav'); ?>

      </header>

      <!-- Left navigation -->
      <?php $this->load->view('pages/leftnav'); ?>

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Initialize Branch Inventory
            <small>Starting a new inventory</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="<?php echo site_url(); ?>"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Examples</a></li>
            <li class="active">Initial Branch Inventory</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">

          <?php 
            if($errorMessage != "")
            {
          ?>
          <div class="alert alert-danger alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <h4><i class="icon fa fa-ban"></i> Opppppps!</h4>
            <?php echo $errorMessage; ?>
          </div>
          <?php } ?>

          <div class="box box-info">
              <?php echo form_open_multipart("initialbranchinventory"); ?>
              <div class="box-body">
                <div class="row">
                    <div class="col-xs-12">
                        <h3>The purpose of inventory initialization</h3>
                        <p>This initialization will be performed only once in order to start your branch inventory. Intented only for new branches or if you need to redo your entire inventory. Take note that performing this will delete the entire inventory and will be replaced by the uploaded data.</p>
                    </div>    
                </div>
                <div class="row">
                  <div class="col-xs-12">
                    <div class="form-group">
                      <label for="fileUpload">Upload data in CSV format</label>
                      <div class="input-group">
                        <div class="input-group-addon">
                          <i class="fa fa-file"></i>
                        </div>
                        <input id="fileUpload" name="fileUpload" type="file" class="btn btn-default btn-flat" />
                      </div>
                      <!-- /.input group -->
                    </div>
                  </div>
                </div>
              </div>
              <div class="box-footer">
                <input id="btnUploadData" name="btnUploadData" class="btn btn-primary btn-flat" type="submit" value="Upload File" />
              </div>
              </form>
          </div>

          <!-- Default box -->
          <div class="box">
            
          <?php echo form_open("initialBranchInventoryApply"); ?>
              <div class="box-header with-border">
                <h3 class="box-title">Uploaded Data</h3>
              </div>
              <div class="box-body">
                <div class="row">
                  <div class="col-xs-12">
                  <table class="table table-bordered">
                    <thead><th style="width:200px;">Item Code</th><th>Model No</th><th style="width:150px;">Beginning Qty</th></thead>
                    <tbody>
                    <?php 
                    
                    if(isset($uploadedData))
                    {
                      if($uploadedData["status"] == "failed")
                        echo '<tr><td colspan="2">'.$uploadedData["error"].'</td></tr>';
                      else
                        echo $uploadedData["upload_data"];
                    }
                    else
                      echo '<tr><td>-</td><td>-</td><td>-</td></tr>';

                    ?>
                    </tbody>
                  </table>
                  </div>
                </div>
              </div><!-- /.box-body -->
              <div class="box-footer">
                <input type="submit" class="btn btn-primary" <?php if(isset($btnDisabled)) echo $btnDisabled; ?> value="Save Beginning Inventory" /> &nbsp;
                <input type="hidden" name="sourceFilename" value="<?php if(isset($uploadedData["sourceFilename"])) echo $uploadedData["sourceFilename"]; ?>">
                <a class="btn btn-warning"  href="/initialbranchinventory">Reset Beginning Inventory</a>
              </div><!-- /.box-footer-->
          </form>

          </div><!-- /.box -->

        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->

      <?php $this->load->view('pages/footer'); ?>

    </div><!-- ./wrapper -->

    <!-- jQuery 2.1.4 -->
    <script src="adminlte/plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="adminlte/bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
    <script src="adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="adminlte/plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="adminlte/plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="adminlte/dist/js/app.min.js"></script>
    
  </body>
</html>
