
<script type="text/javascript">
    function loadSubCategories(catId){
        //alert(catId);//return false;
        if(catId!=''){
            $.ajax({
            type: "POST",
            url: "<?php echo ConfigUrl::base('business');?>ads/loadSubCategories",
            data: {
                categoryId: catId
            },
            success: function(html) {
                //alert(html);
                $('#sub').html(html);
            }
        });
        }
    }
    function cancel(){
        document.location = "<?php echo ConfigUrl::base('business');?>ads/index";
    }
    </script>
<script>
    $(document).ready(function(){
        $("#frmPostads").validate({
            rules: {
                planid: {required: true},
                email : {required: true},
                category : {required: true}

            },
            messages: {
                planid: {required:"Enter Plan Name"},
                email: {required:"Enter Email Address"},
                category : {required:"Select Category"}

            }
        });
    }
)
</script>
<div class="full_width">
     <div class="row">
    <div class="col-xs-12 col-sm-2 col-md-2"></div>
    <div class="col-xs-12 col-sm-8 col-md-8">
		<form method="post" name="frmPostads" id="frmPostads" action="<?php echo ConfigUrl::base(); ?>ads/edit" enctype="multipart/form-data">
        <input type="hidden" name="BusId" value="<?php echo $this->fieldValuesArr[0]->nBusId ?>">
			<div class="form_main_outer">
				<h1>Edit Ads</h1>
				<div class="clear"></div>
				<?php
					if(!empty($this->error) || !empty($this->message)) {
						$messageClass = (!empty($this->error)) ? 'red' : 'green';
						$flashMessage = (!empty($this->error)) ? $this->error : $this->message;
				?>
				<div class="messageBox"><span class="<?php echo $messageClass ?>"><?php echo $flashMessage; ?></span></div>
				<?php
					} //
				?>
				
				<div class="clear"></div>
				
				<?php                       
				if(!empty($this->activeFields)) {
					//Title Field
					if(strtolower($this->activeFields[0]->vFldname)==strtolower('Title')) {
						$fieldName = $this->activeFields[0]->vFldname;
					?>
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $this->activeFields[0]->vFlddesc ?><?php if($this->activeFields[0]->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="text" class="form-control" name="<?php echo $this->activeFields[0]->vFldname ?>" value="<?php echo stripslashes($this->fieldValuesArr[0]->$fieldName); ?>">
						</div>
					</div>
				<div class="clear"></div>
				</div>
				 <?php
				} //Title Field End

				?> 
				
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label>Select Category<span class="red">*</span></label>
							<!--<select class="select_drpbx" name="select">
								<option>Category</option>
							</select>-->
							<?php                 
							if(!empty($this->category_title)) { asort($this->category_title); }
							?>                    
							<?php echo $this->select('category', $this->category_title,$this->parentCategory, 'form-control','','category',' size="10" onChange = loadSubCategories(this.value)'); ?>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label>Select subcategory</label>
							 <div id ="sub">
								 <?php
								if($this->parentCategory>0){
								  echo $this->select('subcategory', $this->subCategoryList,$this->SubCategory, 'select_drpbx','','subcategory',' size="4"');   
								}else{
								   echo $this->select('subcategory','', $this->fieldValuesArr[0]->nCatid, 'select_drpbx','','subcategory',' size="4"'); 
								}
								  ?>  
							  </div>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				
				
				
                <?php
                foreach($this->activeFields as $activeFld) {
                    $fieldName = '';
                    $fieldName = $activeFld->vFldname;
                    if(in_array($activeFld->vFldname, $this->staticFieldArr)) {

                        switch(strtolower($activeFld->vFldname)) {
                            case 'title':
                                break;
                            case 'description':
                                
                ?>              
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<textarea class="form-control" name="<?php echo $activeFld->vFldname; ?>"><?php echo stripslashes($this->fieldValuesArr[0]->$fieldName); ?></textarea>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
					break;
					case 'image':
				?>
				            
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="file" class="txt_area" name="<?php echo $activeFld->vFldname; ?>">                   
							   <?php                   
									if(!empty($this->fieldValuesArr[0]->$fieldName)) {
										$imageName = $this->fieldValuesArr[0]->$fieldName;
										$imageParts=pathinfo($imageName);
										$imageNameArr = explode("_302x302", $imageName);                            
										$imageNameThumb = $imageNameArr[0].'_151x151.'.$imageParts['extension'];                       
									$postImage=ConfigUrl::uploadimageroot().$imageNameThumb;
									if(is_file($postImage)) {                                                       
								?>
								<img src="<?php echo ConfigUrl::base('default').'uploads/image/'.$imageNameThumb; ?>" alt="Image" /><br>
								<?php
										} // Thumb View                           
									} // Image Field Value Exists
								?>
							 <span class="grey">Allowed image type : jpg/jpeg</span>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
					break;
					case 'video':
				?>
				
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="file" class="txt_area" name="<?php echo $activeFld->vFldname; ?>">
							<?php
								if(!empty($this->fieldValuesArr[0]->$fieldName)) {
									$fileName = $this->fieldValuesArr[0]->$fieldName;
									$fileParts=pathinfo($fileName);
									$imageNameThumb = $imageParts['filename'].'.jpeg';
									$postFile = ConfigUrl::uploadvideoroot().$imageNameThumb;
								if(is_file($postFile)) {
							?>
							<img src="<?php echo ConfigUrl::base('default').'uploads/video/'.$imageNameThumb; ?>" alt="Image" /><br>
							<?php
									} // Thumb View
								} // Image Field Value Exists
							?>
								<span class="grey">Supported video formats : mp4,webm,ogv,flv
								<br>Maximum File Upload Size allowed by your server - <?php echo ini_get('upload_max_filesize'); ?>
								</span>
								<?php if(trim($this->fieldValuesArr[0]->$fieldName) <> ""){ ?>
							 
							<a href="<?php echo ConfigUrl::root().'uploads/video/'.stripslashes($this->fieldValuesArr[0]->$fieldName); ?>" target="_blank" style="color:#F00;">Download Video Now</a>
							<?php } ?>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
					break;
					case 'videourl':
				?>
				         
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="text" class="form-control" name="<?php echo $activeFld->vFldname; ?>" value="<?php echo $this->fieldValuesArr[0]->$fieldName; ?>">
						</div>
					</div>
				<div class="clear"></div>
				</div>
				 <?php
						break;
						case 'zipcode':
					?> 
                                
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="text" class="form-control" name="<?php echo $activeFld->vFldname; ?>" value="<?php echo stripslashes($this->fieldValuesArr[0]->$fieldName); ?>">
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
					break;
				case 'address':
					?>

				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<textarea class="form-control" name="<?php echo $activeFld->vFldname; ?>"><?php echo stripslashes($this->fieldValuesArr[0]->$fieldName); ?></textarea>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
							break;
					} //End Switch

				} // End If

				   if(!in_array($activeFld->vFldname, $this->staticFieldArr)) {
					switch(($activeFld->vInType)) {
						case 'text':
				?>
				
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="text" class="form-control" name="<?php echo $activeFld->vFldname; ?>" value="<?php echo stripslashes($this->fieldValuesArr[0]->$fieldName); ?>">
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
					break;
				
				case 'textarea':
					?>
				                
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<textarea class="form-control" name="<?php echo $activeFld->vFldname; ?>"><?php echo stripslashes($this->fieldValuesArr[0]->$fieldName); ?></textarea>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php
					break;
				case 'file-doc/txt':
					?>
				
                               
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<input type="file" class="txt_area" name="<?php echo $activeFld->vFldname; ?>">
							 <?php
								if(!empty($this->fieldValuesArr[0]->$fieldName)) {
								 $fileName = $this->fieldValuesArr[0]->$fieldName;                     
								 $postFile = ConfigUrl::uploaddocroot().$fileName;
								if(is_file($postFile)) {
								   
							 ?>
							 <a href="<?php echo ConfigUrl::base() ?>ads/downloaddoc/<?php echo $fileName ?>"></a><br>
							 <?php
										} // Download Files
									} // Image Field Value Exists
							 ?>
							<br><span class="grey">Supported file formats : doc,pdf,xls</span>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				 <?php
					break;
				case 'checkbox':
					?> 
                                
				<div class="form_main_inner">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
							<?php echo $this->checkbox($activeFld->vFldname, '1', $this->fieldValuesArr[0]->$fieldName, 'chkbx_manage',$activeFld->vFldname); ?>
						</div>
					</div>
				<div class="clear"></div>
				</div>
				<?php                                
                                break;
                            
                        } // End Switch
                    } // End If

                } //
            } // End If
            ?>
				
				<div class="form_main_btt_outer">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<input name="" class="button" value="POST AD" type="submit">
                       		<input name="" class="button_secondery" value="CANCEL" type="button" onclick="cancel();">
						</div>
					</div>
				<div class="clear"></div>
				</div>
				  
			</div>
		</form>
	</div>
    <div class="col-xs-12 col-sm-2 col-md-2"></div>
    </div>
	
	<div class="clear"></div>
</div>


<div class="clear"></div>
</div>
<!-- Inner Content Wrap End -->
<div class="clear"></div>
</div>
