<?php
include('iframe-header.php');
?>
 <?php
$maintitle="upload";
$page="upload.php";
$table="tbl_schedule_document";
$field_id="documentid";
$content_id=$_REQUEST['scheduleid'];

if(isset($_REQUEST['start'])){
$start=$_REQUEST['start']-1;
}
else {
$start=0;
}
?>
<?php
 
if(isset($_REQUEST['submit'])=="submit"){  
$values = $_POST;
unset($values['submit']);
unset($values['mode']);
$image=$helper->image_upload($_FILES['frm_filename'],"documents");
$document=array("filename"=>$image);
$values=array_merge($values,$document);
$message=$helper->insert($table,$values,array(),array());
}
?>
   
<section class="content">
    
              <div class="box-header with-border">
              <h3 class="box-title">Document Uploads</h3>
              </div>
              <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
              <div class="form-group">
               <input type="hidden" value="<?php echo $content_id;?>" name="scheduleid"/>
                  <label for="inputEmail3" class="col-sm-3 control-label">Title</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" value="" name="documentname"/>
                  </div>
                </div> 
               <div class="form-group">
              
                  <label for="inputEmail3" class="col-sm-3 control-label">Upload Document</label>
                  <div class="col-sm-8">
                    <input type="file" class="" name="frm_filename">
                  </div>
                </div> 
              
             
              <div class="box-footer">
                <input type="submit" name="submit" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-left"/> 
              </div>
              <!-- /.box-footer -->
            </form>
            <table class="table table-hover">
            <tr><td>Document Name</td><td>Download</td><td>Date</td></tr>
            <?php
			 $documents= $helper->select("tbl_schedule_document","*",array("scheduleid"=>$content_id),array("scheduleid"=>"desc"));
            if(count($documents>0)){
				foreach($documents as $document) {
				?>
                <tr><td><?php echo $document['documentname'];?></td><td><a target="_self" target="_blank" href="<?php echo $site_url;?>images/documents/download.php?file=<?php echo $document['filename'];?>">Download</a></td><td><?php echo date('d-m-Y', strtotime($document['str_date']));
					  ?></td></tr>
                <?php
				}
			}
             ?>
            </table>
          </div>
         
        </div>
        </div>
         

    </section>
   <?php
   include('iframe-footer.php');
   ?>