<?php

//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////



if (!function_exists('form_control')) {
	function form_control($settings){
	   /// updated with json 10/3/2020
	if (array_key_exists('text', $settings)) {
	$text=$settings['text'];}
   if (array_key_exists('form_name', $settings)) {
   $fname=$settings['form_name'];
   }
   if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('class', $settings)) {
   $class=$settings['class'];
   }
   else{
	$class="input-md";   
   }
   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() {
  $(":input[data-inputmask-mask]").inputmask();
	  });
  </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'=>'id_status_ref',
'order'=>'ASC',
'echo'=>'0',
'errors'=>'0',
'table'=>$table,
'ref_col'=>ref,
'ref_value'=>$table_ref);

$db_fetched=db_fetch($db_settings);
//echo "var_dump";
//var_dump($db_fetched);

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


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

   
   if(isset($text)){
       

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


	
$text1[] = $text[$ty1][$fname];

if(isset($_POST[$add_item])){
$found=$text[$ty1][$fname]."_name";
$found2=$_POST[$found];

if(isset($text[$ty1]['encoding']) && $text[$ty1]['encoding']!=0){
$text2[] = encode($found2);
}
else{
$text2[] = $found2;	
}
if(isset($text[$ty1]['format']) && $text[$ty1]['format']!=0){
$text2[] = ucwords($found2);	
}	

}
else{
$temp=array();	
$text2[] = $temp;	
}	



?>

				 <?php if (isset($text[$ty1]['class'])) { 
				 $cl=$text[$ty1]['class'];
				  ?>
				 <?php } 
				 else{ 
				 $cl="col-md-4";
				 ?>
				 <?php } ?>
<div class="<?php echo $cl; ?>">				 
                    <div class="form-group">
                        <label class="control-label"><h5><?php echo $text[$ty1]['label']; ?></h5></label>
						
						
						<?php if (isset($text[$ty1]['addon'])) { ?>
						<div class="input-group">
						<span class="input-group-addon"><?php echo $text[$ty1]['addon']; ?></span>
						<?php } ?>
						
						<?php if (isset($text[$ty1]['colorpicker'])) { ?>
						
						<div data-color-format="rgb" data-color="#4AA88C" class="colorpicker-default input-group">
						
						<?php } ?>
						
						
						
                      <input type="text" class="form-control <?php echo $class; ?>" 
					  
					  name="<?php echo $text[$ty1]['fname']."_name"; ?>" 
					  
					  <?php if (isset($text[$ty1]['json'])) { ?>
					  
					  id="<?php echo $text[$ty1]['json_id']; ?>"
					  
					  <?php } ?>
					  
					  maxlength="300"
					  
					  <?php
					  if(isset($text[$ty1]['required']) && $text[$ty1]['required']!=0)
					  {  ?>
					  
					  required="required" 
					  
					  <?php
                       } 
					   if(isset($text[$ty1]['fetched']) && $text[$ty1]['fetched']!="empty value!") { 
					   if(isset($text[$ty1]['encoding']) && $text[$ty1]['encoding']!=0) { ?> 
					   value="<?php echo decode($text[$ty1]['fetched']); ?>"
					   <?php }  else { ?>
					   value="<?php echo $text[$ty1]['fetched']; ?>"
					   <?php
					   } 
					   }
else{
	if (isset($text[$ty1]['placeholder'])) {
	?>
 value="<?php echo $text[$ty1]['placeholder']; ?>"	
<?php
	}
 }					   
					     if(isset($text[$ty1]['masking']) && $text[$ty1]['masking']!=="off"){ 
						
					 ?>
					   data-inputmask="<?php echo $text[$ty1]['masking']; ?>"
					   id="PHONE" data-val="true"
					   
					   <?php }

					   ?>
					  />
					  
					  <?php if (isset($text[$ty1]['colorpicker'])) { ?>
					  	
					  	<span class="input-group-append add-on">
    <button class="btn btn-default" type="button">
   <i style="background-color: rgb(124, 66, 84);margin-top: 2px;"></i>
                                                        </button>
                                                    </span>
                                                </div>
					  	<?php } ?>
					  	
					  <?php if (isset($text[$ty1]['addon'])) { ?>
                    </div>
					  <?php } ?>
					  <?php if (isset($text[$ty1]['hint'])) { ?>
					  <small><?php echo $text[$ty1]['hint'] ?></small>
					  <?php } ?>
					  
					  <?php if (isset($text[$ty1]['json'])) { ?>
					  <small><br /><span id="<?php echo $text[$ty1]['json_id'] ?>_status"></span></small>
					  <?php } ?>
					  
					  
					  </div>
                  </div>


<?php if (isset($text[$ty1]['colorpicker'])) { ?>


<script type="text/javascript">
  $(document).ready(function() {

//colorpicker start

$('.colorpicker-default').colorpicker({
    format: 'hex'
});
$('.colorpicker-rgba').colorpicker();

	  });
  </script>
  
<?php } ?>


  <?php if (isset($text[$ty1]['json'])) { ?>

  	<script type="text/javascript">
$(document).ready(function()
{
console.log( "ready!" );
$("#<?php echo $text[$ty1]['json_id']; ?>").keyup(function() 
{ 
$("#<?php echo $text[$ty1]['json_id'] ?>_status").html("start");    
   
var username = $("#<?php echo $text[$ty1]['json_id']; ?>").val();
var msgbox = $("#<?php echo $text[$ty1]['json_id'] ?>_status");

if(username.length > 1)
{
$("#<?php echo $text[$ty1]['json_id'] ?>_status").html('Checking availability...');


$.ajax({  
    type: "POST",  
    
		ContentType : "application/json; charset=utf-8",
		 
		dataType: 'text',

		cache	: false,
		
    url: 'perl.txt',
    
    data: 'user='+ username +'&id_col=<?php echo $id; ?>&table=<?php echo $table; ?>&matching_col=<?php echo $text[$ty1]['json_matching_col']; ?>&section_flag=live_check&encoding=<?php echo $text[$ty1]['encoding']; ?>',  


    
    success: function(msg){  
	msg = $.trim(msg);
    
console.log(msg);    
 
 
   
	if(msg == 'free')
	{ 
	    
	    
	    $("#<?php echo $text[$ty1]['json_id']; ?>").removeClass("red");
	    $("#<?php echo $text[$ty1]['json_id']; ?>").addClass("green");
	    $("#subbtn").prop("disabled", false);
		$("#<?php echo $text[$ty1]['json_id'] ?>_status").html('Name is Available.');
		
	}  
	else  
	{  
	    $("#<?php echo $text[$ty1]['json_id']; ?>").removeClass("green");
		 $("#<?php echo $text[$ty1]['json_id']; ?>").addClass("red");
		$("#<?php echo $text[$ty1]['json_id'] ?>_status").html('<font color="#cc0000">Sorry this name already exists!</font>'); 
	     $("#subbtn").prop("disabled", true);
		}  
   
  
   },
  
  
   error: (function(res) {
        console.log(res); 
        /*
        console.log("error " + textStatus);
        console.log("thrown " + errorThrown);
        console.log("incoming Text " + jqXHR.responseText);
 */
    })
  
 }); 

}
else
{
// $("#<?php echo $text[$ty1]['json_id']; ?>").addClass("red");
$("#<?php echo $text[$ty1]['json_id'] ?>_status").html('<font color="#cc0000">Enter min 4 letter User Name</font>');
}



return false;
});

});
</script>


<style>
#status
{
font-size:11px;
margin-left:10px;
}
.green
{
background-color:#CEFFCE;
}
.red
{
background-color:#FFD9D9;
}
</style>

  
  <?php }

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




	  
}
}

$output=array(
'fields'=>$text1,
'posts'=>$text2);
return $output;
   ?>
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('form_check_box')) {
	function form_check_box($settings){
	if (array_key_exists('text', $settings)) {
	$text=$settings['text'];}
   if (array_key_exists('form_name', $settings)) {
   $fname=$settings['form_name'];
   }
   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() {
  $(":input[data-inputmask-mask]").inputmask();
	  });
  </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',
'ref_col'=>ref,
'ref_value'=>main_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($text)){
       

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


	
$text1[] = $text[$ty1][$fname];

if(isset($_POST[$add_item])){
$found=$text[$ty1][$fname]."_name";
$found2=$_POST[$found];

if(isset($text[$ty1]['encoding']) && $text[$ty1]['encoding']!=0){
$text2[] = encode($found2);
}
else{
$text2[] = $found2;	
}
if(isset($text[$ty1]['format']) && $text[$ty1]['format']!=0){
$text2[] = ucwords($found2);	
}	

}
else{
$temp=array();	
$text2[] = $temp;	
}	



?>

				 <?php if (isset($text[$ty1]['class'])) { 
				 $cl=$text[$ty1]['class'];
				  ?>
				 <?php } 
				 else{ 
				 $cl="col-md-4";
				 ?>
				 <?php } ?>
<div class="<?php echo $cl; ?>">				 
            			
					<div class="checkbox checkbox-success checkbox-inline">
                       
					 	
						
                      
                      <input type="checkbox" id="inlineCheckbox2"
                      
					  name="<?php echo $text[$ty1]['fname']."_name"; ?>" 
					  <?php
					   if(isset($text[$ty1]['fetched']) && $text[$ty1]['fetched']!="Empty Value!") { 
					   if(isset($text[$ty1]['encoding']) && $text[$ty1]['encoding']!=0) { ?> 
					   value="<?php echo decode($text[$ty1]['fetched']); ?>" checked="1"
					   <?php }  else { ?>
					   value="<?php echo $text[$ty1]['fetched']; ?>" checked="1"
					   <?php
					   } 
					   } 
					   ?>  
					  />
					 <label for="inlineCheckbox1"><strong><?php echo $text[$ty1]['label']; ?></strong></label>
					  	
						
						
					</div>
					  <?php if (isset($text[$ty1]['hint'])) { ?>
					  <small><?php echo $text[$ty1]['hint'] ?></small>
					  <?php } ?>
					</div>
                

    	
		

<?php
	  
}
}

$output=array(
'fields'=>$text1,
'posts'=>$text2);
return $output;
   ?>
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('form_time_pick')) {
	function form_time_pick($settings){
	if (array_key_exists('text', $settings)) {
	$text=$settings['text'];}
   if (array_key_exists('form_name', $settings)) {
   $fname=$settings['form_name'];
   }
   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() {
  $(":input[data-inputmask-mask]").inputmask();
	  });
  </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',
'ref_col'=>ref,
'ref_value'=>main_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($text)){
       

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


	
$text1[] = $text[$ty1][$fname];

if(isset($_POST[$add_item])){
$found=$text[$ty1][$fname]."_name";
$found2=$_POST[$found];

if(isset($text[$ty1]['encoding']) && $text[$ty1]['encoding']!=0){
$text2[] = encode($found2);
}
else{
$text2[] = $found2;	
}
if(isset($text[$ty1]['format']) && $text[$ty1]['format']!=0){
$text2[] = ucwords($found2);	
}	

}
else{
$temp=array();	
$text2[] = $temp;	
}	



?>

				 <?php if (isset($text[$ty1]['class'])) { 
				 $cl=$text[$ty1]['class'];
				  ?>
				 <?php } 
				 else{ 
				 $cl="col-md-4";
				 ?>
				 <?php } ?>
<div class="<?php echo $cl; ?>">	
			 
<p>&nbsp;</p>			 
            			<div class="form-group">
                        <label class="control-label"><h5><?php echo $text[$ty1]['label']; ?></h5></label>
					
					   
					 	
						<div class="input-group">
                       <input id="<?php echo $text[$ty1]['t_id']; ?>" type="text" class="form-control tm" 
					   name="<?php echo $text[$ty1]['fname']."_name"; ?>" 
					  <?php
					   if(isset($text[$ty1]['fetched']) && $text[$ty1]['fetched']!="Empty Value!") { 
					   if(isset($text[$ty1]['encoding']) && $text[$ty1]['encoding']!=0) { ?> 
					   value="<?php echo decode($text[$ty1]['fetched']); ?>"
					   <?php }  else { ?>
					   value="<?php echo $text[$ty1]['fetched']; ?>"
					   <?php
					   } 
					   } 
					   ?>  
					  />
					  	
					  <span class="input-group-addon"><i class="mdi mdi-clock"></i></span>
                       </div>
                    	
						
					
					  <?php if (isset($text[$ty1]['hint'])) { ?>
					  <small><?php echo $text[$ty1]['hint'] ?></small>
					  <?php } ?>
					</div>
					</div>
    



	

    	

<?php
	  
}
}

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









?>