<?php


if (!function_exists('img_control')) {
	function img_control($settings){
	if (array_key_exists('img', $settings)) {
   $img=$settings['img'];
   }
    if (array_key_exists('form_name', $settings)) {
   $fname=$settings['form_name'];
   }
   if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('table_ref', $settings)) {
   $table_ref=$settings['table_ref'];
   }
   if (array_key_exists('form_submit_id', $settings)) {
   $add_item=$settings['form_submit_id'];
   }
   if (array_key_exists('edit', $settings)) {
   $edit=$settings['edit'];}
   if (array_key_exists('id', $settings)) {
   $id=$settings['id'];
   }
   	
   ?>
 <script type="text/javascript">
  $(document).ready(function() {
$('.dropify').dropify({
    error: {
        'fileSize': 'The file size is too big ({{ value }} max).',
        'minWidth': 'The image width is too small ({{ value }}}px min).',
        'maxWidth': 'The image width is too big ({{ value }}}px max).',
        'minHeight': 'The image height is too small ({{ value }}}px min).',
        'maxHeight': 'The image height is too big ({{ value }}px max).',
        'imageFormat': 'The image format is not allowed ({{ value }} only).'
    },
messages: {
        'default': 'Drag and drop a file here or click',
        'replace': 'Drag and drop or click to replace',
        'remove':  'Remove',
        'error':   'Ooops, something wrong happended.'
    }	
});
	  
$("#subbtn").click(function(){
$("#subbtn").text("Please Wait...");

	  });
  });
  </script>
 
   <!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   <?php
   
   if(isset($edit) && $edit!="0"){

foreach ($text as $tycol1 => $colvalue) {
    $fetches[] = $text[$tycol1][$fname];

    
}	

$db_settings=array(
'id'=>$id,
'fields_array'=>$fetches,
'type'=>'select all yes array',
'order'=>'ASC',
'echo'=>'0',
'table'=>$table,
'ref_col'=>ref,
'ref_value'=>$table_ref);

$db_fetched=db_fetch($db_settings);


foreach ($text as $tycoladd => $valueadd){
foreach ($db_fetched as $editadd){
$text[$tycoladd]['fetched']=$editadd[$tycoladd];
}
}


///////////////// isset edit
}


   
   if(isset($img)){
       

foreach ($img as $ty1 => $value){


	
$img1[] = $img[$ty1][$fname];

if(isset($_POST[$add_item])){
$found=$img[$ty1][$fname]."_img_name";
$found2=$_POST[$found];
$img2[] = $found2;

  
  <?php }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




	  
}
}
?>

<?php if (!isset($img[$ty1]['class'])) { ?>
				 <div class="col-md-6">
				 	 <?php } 
				 else{ ?>
				<div class="<?php echo $img[$ty1]['class']; ?>">
				 <?php } ?>	 
				 <p>&nbsp;</p>
<h4><?php echo $heading; ?></h4>                    
					 	<input type="file" data-max-file-size="<?php echo $img[$ty1]['limit']; ?>" data-allowed-file-extensions="jpg png" 
						class="dropify" name="<?php echo $img[$ty1]['field']."_img_name"; ?>" id="upload_file_id" 
						<?php  
						if(isset($photo) && $photo!=""){
						?> 
						 data-default-file="<?php echo SITE_IMAGES.$setup['upload_folder_title']."/".$photo; ?>" 
						<?php  
                    }
						?>
						/>
				<?php if (isset($img[$ty1]['hint'])) { 
			?>			
			<small style="color:red;"><strong>
				<?php 		
	       			echo $img[$ty1]['hint'];  ?>
						
						</strong></small>
				<?php } ?>
					


    	</div>	

$output=array(
'fields'=>$img1,
'posts'=>$img2);
return $output;
   
?>
   
 // PAGE FUNCTION ENDS (c) i2d Technologies Website Engine //   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
























?>