
<?php
//this page brings out a static form editing a event  



if($_POST['act'] == 'edit_events')
{
	  $id_array = $_POST['event']; // return array
	  $id_count = count($_POST['event']); // count array
	  
	
	  
?>


<div class="well">

      <ul class="tabs"> 
        <li><a href="#view1">Events Details</a></li> 
      </ul> 
      <div class="tabcontents"> 
        <div id="view1" class="row">
        

        <?php 
		
		for($i=0; $i < $id_count; $i++) 
		{
		  $id = $id_array[$i];
		  $q = "SELECT * FROM events WHERE id = '$id'";
		  $r = mysqli_query(dbc(),$q);
				
		  if(!$r) { die(mysql_error()); }
		
			  
			  if(mysqli_num_rows($r) > 0)
			  {//begin if result exist
				  while($row = mysql_fetch_array($r, MYSQLI_ASSOC))
				  {//begin while
		?>
        	<div class="col-lg-12">
            
            	<div class="col-lg-6">
            
             		<input type="hidden" name="MAX_FILE_SIZE" value="MAX_FILE_SIZE" />
             	
             			<fieldset> 
                            <legend><span class="ast">*</span> indicate required fields </legend>
      

                                                  
                        <div class="form-group">
                              <label for="title" class="col-sm-3 control-label">Title </label>
                              <div class="col-sm-9">
                              	<div class="input-group">
                                <input  id="title" class="form-control input-sm" type="text" placeholder="Title"  name="title" 
                                value="<?php  echo $row['title']; ?>" required></input>
                                <div class="input-group-addon"> <span class="ast">*</span></div>
                                </div>
                                 
                              </div>
                           </div>
                           
                           
                           
                              <div class="form-group">
                                <label class="col-sm-3 control-label" for="image"> Image</label>
                                <div class="col-sm-9">
                                
                                <input    name="image" class="form-control input-sm"  type="file" ></input>
                               
                                <span class="help-block"> Upload  Image less than 50kb. </span>
                            
                                
                                </div>
                              </div>
                        
                           
                        
                           
                           
                         <div class="form-group">
                          <label class="col-sm-3 control-label" for="description">Note / Description</label>
                            <div class="col-sm-9">
                            
                              <textarea class="form-control input-sm rte1" id="" rows="7"  name="description" action="#" >
                             <?php 
								echo $row['description']; ?>
                              </textarea>
                            </div>
                          </div>
                          
                          
                          
                                                      
                        <div class="form-group">
                              <label for="venue" class="col-sm-3 control-label">Venue </label>
                              <div class="col-sm-9">
                              	<div class="input-group">
                                <input  id="venue" class="form-control input-sm" type="text" placeholder="Venue"  name="venue" 
                                value="<?php if(isset($row['venue'])) echo $row['venue']; ?>" required></input>
                                <div class="input-group-addon"> <span class="ast">*</span></div>
                                </div>

                                 
                              </div>
                           </div>
                           
                           <div class="form-group">
                              <label for="date" class="col-sm-3 control-label">Date</label>
                              <div class="col-sm-9">
                               <div class="input-group">
                                <input id="datepicker4" class="form-control input-sm" type="text" placeholder="Event Date" name="date" required
                                
                               value="<?php if(isset($row['event_date'])) echo $row['event_date'];?>"></input>
                                <div class="input-group-addon"> <span class="ast">*</span></div>
                              
                                </div>
                                
                              </div>
                           </div>
                           
                                                      
                        <div class="form-group">
                              <label for="start_time" class="col-sm-3 control-label">Start Time </label>
                              <div class="col-sm-9">
                              	<div class="input-group">
                                <input  id="start_time" class="form-control input-sm" type="text" placeholder="Start Time"  name="start_time" 
                                value="<?php if(isset($row['start_time'])) echo $row['start_time']; ?>" required></input>
                                <div class="input-group-addon"> <span class="ast">*</span></div>
                                </div>
                                 
                              </div>
                           </div>
                           
                           
                            <div class="form-group">
                              <label for="end_time" class="col-sm-3 control-label">End Time </label>
                              <div class="col-sm-9">
                              	<div class="input-group">
                                <input  id="end_time" class="form-control input-sm" type="text" placeholder="End Time"  name="end_time" 
                                value="<?php if(isset($row['end_time'])) echo $row['end_time']; ?>" required></input>
                                <div class="input-group-addon"> <span class="ast">*</span></div>
                                </div>
                                 
                              </div>
                           </div>
                        
                        
                                   
                         <div class="form-group">
                          <label class="col-sm-3 control-label" for="gender">Status</label>
                          <div class="col-sm-9">
                          
                            <select id="status" class="form-control input-sm" name="status" required>
                              
                            <?php  echo select_status($row['status']); ?>
                              
                             </select>
                          
                             
                          </div>
                          
                        </div>	
                
                                
                                
                                <input type="hidden" value="update_events" name="act" />
                                <input type="hidden" value="TRUE" name="update_events" /><!-- pass value for editing -->
                                <input type="hidden" value="<?php echo $row['id']; ?>" name="events" id='events' />
                                <!-- pass id value incase he didnt fill well den bring bk for editing -->
                                
                                 <input type="hidden" value="TRUE" name="upload" /> <!-- for picture -->
                  
		  
								</table>
							  </div><!-- /col-lg- 6 -->
                              <div class="col-lg-6 help-block">
                              
                                <h4>Instructions on how to add  Event & Event Image</h4>
                                
                                <ol class="list-group">
                                <li class="list-group-item">1 -  Title of the event is a required field which must contain a caption</li>
                                <li class="list-group-item">2 -  Here, Image is not necessary, but incase of upload, see below: 
                                    <br/>
                                    <ul class="list-list-group">
                                      <li class="list-group-item"> 2a - Image must be less than 50kb </li>
                                      <li class="list-group-item"> 2b - image must be atleast 400px to 350px </li>
                                    </ul> 
                                
                                </li>
                                <li class="list-group-item">3- All images to be uploaded must have the website logo and website address labeled on it before upload</li>
                                <li class="list-group-item">4- Users must beware of status functionality - when to publish and when not to publish.</li>
                                </ol>
                              
                              
                              </div><!-- /col-lg- 6 -->
                  </fieldset>
              
              
                
               
			</div><!-- / col-lg -12 -->
							
 		</form>


	<?php
				  }//end of if
				  }//end of while
	
			  }//end of for loop
	?>

        
        </div> 
         
      </div>
</div>
<?php 

}//end of if post editevents
?>
