<?php

    $this->load->view('master/header');
    $this->load->view('master/sidebar');

?>  

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Add Software
        <!-- <small>it all starts here</small> -->
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Software</a></li>
        <li class="active">Add Software</li>
      </ol>
    </section>

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

      <?php if($this->session->flashdata('success')){ ?>

      <div class="alert alert-success alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa fa-check"></i> Alert!</h4>
        <?php echo $this->session->flashdata('success'); ?>.
      </div>

      <?php } ?>

      <?php if($this->session->flashdata('error')){ ?>

      <div class="alert alert-danger alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa fa-ban"></i> Alert!</h4>
        <?php echo $this->session->flashdata('error'); ?>.
      </div>

      <?php } ?>

      <!-- Default box -->
      <?php if(!isset($edit)){ ?>
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">Add Software</h3>

          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
                    title="Collapse">
              <i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
              <i class="fa fa-times"></i></button>
          </div>
        </div>
        <div class="box-body">
          <div class="row">
            <div class="col-md-6">
            <form class="form-vertical" method="post" action="<?= site_url('user/Software/submitSoftware'); ?>" enctype="multipart/form-data">
                  <div class="form-group">
                    <input class="form-control" name="title" type="text" placeholder="Title">
                  </div>
                  <div class="form-group">
                    <textarea class="form-control" name="description" placeholder="Description"></textarea>
                  </div>
                  <div class="form-group">
                    <input class="form-control-file" name="picture_path" type="file">
                  </div>
                  <div class="form-group">
                    <button class="btn btn-success">Save</button>
                  </div>
                </form>
            </div>

          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <?php }else{ ?>
        <div class="box">
          <div class="box-header with-border">
            <h3 class="box-title">Edit Software</h3>

            <div class="box-tools pull-right">
              <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
                      title="Collapse">
                <i class="fa fa-minus"></i></button>
              <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
                <i class="fa fa-times"></i></button>
            </div>
          </div>
          <div class="box-body">
            <div class="row">
              <div class="col-md-6">
              <form class="form-vertical" method="post" action="<?= site_url('user/Software/updateSoftware'); ?>" enctype="multipart/form-data">
                    <?php foreach($results as $result){ ?>
                    <div class="form-group">
                      <input class="form-control" name="title" type="text" value="<?= $result['title']; ?>" placeholder="Title">
                    </div>
                    <div class="form-group">
                      <textarea class="form-control" name="description" placeholder="Description"><?= $result['description']; ?></textarea>
                    </div>
                    <input type="hidden" name="softwareid" value="<?= $result['softwareid'] ?>">
                    <div class="form-group">
                      <button class="btn btn-success">Save</button>
                    </div>
                    <?php } ?>
                  </form>
              </div>

            </div>
          </div>
          <!-- /.box-body -->
        </div>
      <?php } ?>
      <!-- /.box -->

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


<?php

    $this->load->view('master/footer');

?>  