<?php



//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
if (!function_exists('make_form')) {
function make_form($values,$encoding,$edit_settings=0) {
if (array_key_exists('texts', $values)) {
   $text=$values['texts'];
   }
if (array_key_exists('img_2021', $values)) {
   $img_2021=$values['img_2021'];
   }
if (array_key_exists('integers', $values)) {
   $integer=$values['integers'];
   }
if (array_key_exists('dropdowns', $values)) {
   $dropdown=$values['dropdowns'];
   }
if (array_key_exists('dropdowns2', $values)) {
   $dropdown2=$values['dropdowns2'];
   }
if (array_key_exists('checkboxes', $values)) {
   $checkboxes=$values['checkboxes'];
   }
if (array_key_exists('timepicks', $values)) {
   $timepicks=$values['timepicks'];
   }

   if (array_key_exists('directfields', $values)) {
   $directfields=$values['directfields'];
   }
   
if (array_key_exists('wysiwygs', $values)) {
   $wysiwygitem=$values['wysiwygs'];
   }

if (array_key_exists('wysiwygs_choice', $values)) {
   $wysiwygitem_choice=$values['wysiwygs_choice'];
   }   
   
if (array_key_exists('disableds', $values)) {
   $disableds=$values['disableds'];
   }
if (array_key_exists('dates', $values)) {
   $dates=$values['dates'];
   }
if (array_key_exists('datedfield', $values)) {
   $datedfield=$values['datedfield'];
   }
if (array_key_exists('alias', $values)) {
   $alias=$values['alias'];
   }
   if (array_key_exists('redirect', $values)) {
   $redirect=$values['redirect'];
   }
if (array_key_exists('redirect_adv', $values)) {
   $redirect2=$values['redirect_adv'];
   }
if (array_key_exists('form_heading', $values)) {
   $form_heading=$values['form_heading'];
   }
if (array_key_exists('form_table', $values)) {
   $form_table=$values['form_table'];
   }

if (array_key_exists('edit', $edit_settings)) {
   $edit=$edit_settings['edit'];
   }
if (array_key_exists('lead_id', $edit_settings)) {
   $lead_id=$edit_settings['lead_id'];
   }
if (array_key_exists('table', $edit_settings)) {
   $etable=$edit_settings['table'];
   }
if (array_key_exists('e_ref', $edit_settings)) {
   $e_ref=$edit_settings['e_ref'];
   }
 
if (array_key_exists('update_settings', $values)) {
   $update_settings=$values['update_settings'];
   }
   
if (array_key_exists('old_deal_card', $values)) {
   $old_deal_card=$values['old_deal_card'];
   } 
?>



<script type="text/javascript">
$(document).ready(function() {
  $(window).keydown(function(event){
    if(event.keyCode == 13) {
      event.preventDefault();
      return false;
    }
  });
});
</script>



<script type="text/javascript">
 $(document).ready(function() {
$("#subbtn").click(function(){
//$("#subbtn").text("Please Wait...");

	  });
	  
  });
  </script>

 <div id="page-right-content">

                    <div class="container">
                        <div class="row">
                            <div class="col-sm-12">
																				<?php
if(isset($edit) && $edit!="0"){
	?>
                                <h4 class="header-title m-t-0 m-b-20"><?php echo "Update ".$form_heading; ?></h4>
<?php } 
else { ?>
                                <h4 class="header-title m-t-0 m-b-20"><?php echo "Add New ".$form_heading; ?></h4>
<?php } ?>      

<?php 
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
?>
	  </div>
                        </div> <!-- end row -->


                        <div class="row">
               <div class="col-12">



<form role="form" enctype="multipart/form-data" method="post">
<div class="p-20 m-b-20">
<div class="row">


<?php
if(isset($datedfield)){
if(isset($edit) && $edit!="0"){
if(isset($values['dated_table'])){
$date_settings=array(
'table'=>$values['dated_table'],
'id'=>$lead_id,
'type'=>'0',
'to_find'=>$values['datedfield']);
$found_date=db_fetch($date_settings);
dater2($found_date);
//echo "<h4>Entry Date is ".$found_date."</h4>";
?>
<h3 align="center"><span style="color:red;"><?php echo $values['prefix'].$lead_id; ?></span></h3>
<?php
}
}	
else{
dater2();	
}
}
?>
</div>
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($dropdown2) && !empty($dropdown2)){
foreach ($dropdown2 as $droploop2 => $valloop2){
	
if(isset($edit) && $edit!="0"){

$this_field2=db_ref($dropdown2[$droploop2]['prim_table'],id_col,$lead_id,$dropdown2[$droploop2]['this_table_field']);

	
$db_settings32=array(
'table'=>$dropdown2[$droploop2]['sub_table'],
'id'=>$this_field2,
'type'=>'0',
'to_find'=>$dropdown2[$droploop2]['remote_tbl_title_col']);

$drop32=db_fetch($db_settings32);

//helloworld($drop32);

$this_field2b=db_ref($dropdown2[$droploop2]['prim_table'],id_col,$lead_id,$dropdown2[$droploop2]['this_table_field2']);

$db_settings42=array(
'table'=>$dropdown2[$droploop2]['sub_table'],
'id'=>$this_field2b,
'type'=>'0',
'to_find'=>$dropdown2[$droploop2]['remote_tbl_title_col']);

$drop42=db_fetch($db_settings42);

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


}
?>
<?php
if(isset($edit) && $edit!="0"){
$editing2=array(
'editing'=>'1',
'selected_id'=>$this_field2,
'selected_text'=>$drop32,
'selected_id2'=>$this_field2b,
'selected_text2'=>$drop42
);
}
else{
$editing2=array(
'editing'=>'0');	
}
dynamicdrop_adv_multi($dropdown2[$droploop2]['label'],$dropdown2[$droploop2]['encoding'],$editing2,$dropdown2[$droploop2]['ref'],$dropdown2[$droploop2]['ref2'],$dropdown2[$droploop2]['prim_table'],$dropdown2[$droploop2]['sub_table'],$dropdown2[$droploop2]['table_title'],$dropdown2[$droploop2]['table_id_col'],$dropdown2[$droploop2]['table_parent_col'],$dropdown2[$droploop2]['parent_add'],$dropdown2[$droploop2]['child_add'],$dropdown2[$droploop2]['label2']);
?> 
<?php
if(isset($_POST['add_item'])){
$dropfound22=$dropdown2[$droploop2]['ref']."_multi_dropname";
$dropfound222=$_POST[$dropfound22];
$droparray2[$dropdown2[$droploop2]['this_table_field']] = $dropfound222;

$dropfound22_sub=$dropdown2[$droploop2]['ref2']."_multi_dropname";
$dropfound222_sub=$_POST[$dropfound22_sub];
$droparray2_sub[$dropdown2[$droploop2]['this_table_field2']] = $dropfound222_sub;



}


}
}
?>

<div class="row">
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($dropdown) && !empty($dropdown)){
foreach ($dropdown as $droploop => $valloop){
	
if(isset($edit) && $edit!="0"){	

$this_field1=db_ref($form_table,id_col,$lead_id,$dropdown[$droploop]['this_table_field']);

//helloworld($this_field1);

$db_settings3=array(
'table'=>$dropdown[$droploop]['table'],
'id'=>$this_field1,
'type'=>'0',
'to_find'=>$dropdown[$droploop]['remote_tbl_title_col']);


$drop3=db_fetch($db_settings3);

}
?>
<?php
if(isset($edit) && $edit!="0"){
$editing=array(
'editing'=>'1',
'selected_id'=>$this_field1,
'selected_text'=>$drop3);
}
else{
$editing=array(
'editing'=>'1');	
}
dynamicdrop_adv($dropdown[$droploop]['label'],$dropdown[$droploop]['encoding'],$editing,$dropdown[$droploop]['ref'],$dropdown[$droploop]['table'],$dropdown[$droploop]['table_title'],$dropdown[$droploop]['table_id_col'],$dropdown[$droploop]['add_new'],$dropdown[$droploop]['other_id_col']);
?> 
<?php
if(isset($_POST['add_item'])){
$dropfound=$dropdown[$droploop]['ref']."_dropname";
$dropfound2=$_POST[$dropfound];
$droparray[$dropdown[$droploop]['this_table_field']] = $dropfound2;
}


}
}
?>
</div>
<!------i2d Technologies v3.0 ----     ---------------->
<!------i2d Technologies v3.0 ----     ---------------->
<!------i2d Technologies v3.0 ----     ---------------->
<div class="row">
<?php
if(isset($text) && !empty($text)){
$parameters=array(
'text'=>$text,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'table'=>$etable,
'table_ref'=>$e_ref,
'edit'=>$edit,
'id'=>$lead_id
);

$text_fields=form_control($parameters);
}
?>
</div>
<div class="row">
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($img_2021) && !empty($img_2021)){

}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($integer) && !empty($integer)){
$parameters2=array(
'text'=>$integer,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'edit'=>$edit,
'id'=>$lead_id
);
$integer_fields=form_control($parameters2);

}
?>
</div>
<div class="row">
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($disableds) && !empty($disableds)){
$parametersd=array(
'text'=>$disableds,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'edit'=>$edit,
'id_col'=>$id_col,
'id'=>$lead_id,
'table'=>$table
);
$disableds_fields=form_control($parametersd);
}
?>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($checkboxes) && !empty($checkboxes)){
$parametersch=array(
'text'=>$checkboxes,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'edit'=>$edit,
'id'=>$lead_id
);
$checkbox_fields=form_check_box($parametersch);
}
?>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($timepicks) && !empty($timepicks)){
$parameterstm=array(
'text'=>$timepicks,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'edit'=>$edit,
'id'=>$lead_id
);
$timepick_fields=form_time_pick($parameterstm);
}
?>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($wysiwygitem) && !empty($wysiwygitem)){
foreach ($wysiwygitem as $wysiwyg1 => $wysiwygv){
$wysiwygarray1[] = $wysiwygitem[$wysiwyg1]['fname'];
?>
<script type="text/javascript">
  $(document).ready(function() {
$('#<?php echo $wysiwygitem[$wysiwyg1]['fname']."_div"; ?>').summernote({
  height: 100,                 // set editor height
  minHeight: null,             // set minimum height of editor
  maxHeight: null,             // set maximum height of editor
  
  <?php if(isset($wysiwygitem[$wysiwyg1]['toolbar']) && $wysiwygitem[$wysiwyg1]['toolbar']=="all") {  ?> 
  
  toolbar: [
            [ 'style', [ 'style' ] ],
            [ 'font', [ 'bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'clear'] ],
            [ 'fontname', [ 'fontname' ] ],
            [ 'fontsize', [ 'fontsize' ] ],
            [ 'color', [ 'color' ] ],
            [ 'para', [ 'ol', 'ul', 'paragraph', 'height' ] ],
            [ 'table', [ 'table' ] ],
            [ 'insert', [ 'link'] ],
            [ 'view', [ 'undo', 'redo', 'fullscreen', 'codeview', 'help' ] ]
        ] 
		
  <?php }  else { ?>		
		
		toolbar: [
            [ 'font', [ 'bold', 'italic', 'underline', 'strikethrough','clear'] ],
            [ 'fontsize', [ 'fontsize' ] ],
            [ 'view', [ 'undo', 'redo', 'fullscreen'] ]
        ]
		
  <?php } ?>
		
  //focus: true                  // set focus to editable area after initializing summernote
});
  });
  </script>
  



              <h4 class="m-b-30 m-t-0 header-title"><strong><?php echo $wysiwygitem[$wysiwyg1]['label']; ?></strong></h4>
            
                 
				 

<div class="col-md-12">
<?php
if(isset($edit) && $edit!="0"){
if(isset($values['form_table'])){
$wys_settings=array(
'table'=>$values['form_table'],
'id'=>$lead_id,
'type'=>'0',
'to_find'=>$wysiwygitem[$wysiwyg1]['fname']);
$found_wys=db_fetch($wys_settings);
}
}
?>

      
<textarea name="<?php echo $wysiwygitem[$wysiwyg1]['fname']."_name"; ?>" id="<?php echo $wysiwygitem[$wysiwyg1]['fname']."_div"; ?>">
<?php 
if(isset($edit) && $edit!="0"){
echo $found_wys;
}
else{
	if(isset($wysiwygitem[$wysiwyg1]['placeholder'])){
echo $wysiwygitem[$wysiwyg1]['placeholder']; 
}} ?>	
</textarea>
          </div>


    
		
		

<?php
	  
}
}
?>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($wysiwygitem_choice) && !empty($wysiwygitem_choice)){
foreach ($wysiwygitem_choice as $wysiwyg1_choice => $wysiwygv_choice){
$wysiwygarray1_choice[] = $wysiwygitem_choice[$wysiwyg1_choice]['fname'];

$select_name=$wysiwygitem_choice[$wysiwyg1_choice]['fname']."_sel";
$text_area_name=$wysiwygitem_choice[$wysiwyg1_choice]['fname']."_text_area";
$tags_div_name=$wysiwygitem_choice[$wysiwyg1_choice]['fname']."_tags_div";


if(isset($wysiwygitem_choice[$wysiwyg1_choice]['drop_down']) && $wysiwygitem_choice[$wysiwyg1_choice]['drop_down']!=0 && $edit==0) {



//helloworld($syg_val_choice);

$select_update_cols=array($wysiwygitem_choice[$wysiwyg1_choice]['drop_table_title'],$wysiwygitem_choice[$wysiwyg1_choice]['drop_table_value'],$wysiwygitem_choice[$wysiwyg1_choice]['drop_table_status'],$wysiwygitem_choice[$wysiwyg1_choice]['drop_table_ref']);
	
	$updatesettings=array(
	'table'=>$wysiwygitem_choice[$wysiwyg1_choice]['drop_table'],
	'id_col'=>$wysiwygitem_choice[$wysiwyg1_choice]['drop_table_id'],
	'ref_value'=>$wysiwygitem_choice[$wysiwyg1_choice]['select_alias'],
	'ref_col'=>$wysiwygitem_choice[$wysiwyg1_choice]['drop_table_ref'],
	'fields_array'=>$select_update_cols,
	'status_value'=>'Active',
	'status_col'=>$wysiwygitem_choice[$wysiwyg1_choice]['drop_table_status'],
	'errors'=>"0",
	'echo'=>"0",
	'limit'=>1500,
	'type'=>'dropdown_select');

	$updatesettings_load=db_fetch($updatesettings);
	
	//var_dump($updatesettings_load);

}

if(isset($edit) && !empty($edit)){
$syg_val_choice=db_ref($wysiwygitem_choice[$wysiwyg1_choice]['table'],$wysiwygitem_choice[$wysiwyg1_choice]['table_id'],$lead_id,$wysiwygitem_choice[$wysiwyg1_choice]['fname']);	
}


?>


<!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   
<?php
if(isset($wysiwygitem_choice[$wysiwyg1_choice]['drop_down']) 
&& $wysiwygitem_choice[$wysiwyg1_choice]['drop_down']!=0 && $edit==0) {
?>
      
   <script type="text/javascript">
  $(document).ready(function() {
$('#<?php echo $select_name; ?>').on('change', function(){
var $option = $(<?php echo $select_name; ?>).find('option:selected');
var rt = $option.val();//to get content of "value" attrib
//alert(rt);
var rtarray = rt.split(',');
$('#<?php echo $text_area_name; ?>').tagsinput('removeAll');
$.each(rtarray, function(rtindex, rtvalue) {
console.log(rtvalue);
$('#<?php echo $text_area_name; ?>').tagsinput('add', rtvalue);
});

});

    
});
	  
  </script>

<?php } ?>
<?php
if(isset($edit) && !empty($edit)){ ?>


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

$('#<?php echo $text_area_name; ?>').tagsinput('add', <?php echo $syg_val_choice; ?>);
    
});
	  
  </script>

<?php } ?>

              <h4 class="m-b-30 m-t-30 header-title"><strong><?php echo $wysiwygitem_choice[$wysiwyg1_choice]['text_area_label']; ?></strong></h4>  
              
  
  <div class="form-group">
                        <label class="control-label"><h5><?php echo $wysiwygitem_choice[$wysiwyg1_choice]['select_label']; ?></h5></label>
	
 <?php
if(isset($wysiwygitem_choice[$wysiwyg1_choice]['drop_down']) && $wysiwygitem_choice[$wysiwyg1_choice]['drop_down']!=0 && $edit==0) {
?> 
  <select class="form-control" id="<?php echo $select_name; ?>">
<?php 
foreach ($updatesettings_load as $updateitem){
?>
	<option value="<?php echo $updateitem[select_value]; ?>" style="font-size:14px;"><?php echo $updateitem[select_title]; ?></option>

<?php } ?>    
	</select>
															<p>&nbsp;</p>
<?php } ?>

				<div class="col-md-12">




<div class="tags-default">

<?php
if(isset($edit) && !empty($edit)){ ?>
  <input type="text" data-role="tagsinput" value="<?php echo $syg_val_choice; ?>" placeholder="add more tags" id="<?php echo $text_area_name; ?>" name="<?php echo $text_area_name; ?>"/>
<?php 
}
else {
?>
  <input type="text" data-role="tagsinput" value="waiting" placeholder="add more tags" id="<?php echo $text_area_name; ?>" name="<?php echo $text_area_name; ?>"/>
<?php } ?>

                                    </div>      



          </div>
          
          </div>


    
		
		

<?php
	  
}
}
?>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($dates) && !empty($dates)){
foreach ($dates as $dates1 => $datesval){
$datesarray1[] = $dates[$dates1]['fname'];
dater3($dates[$dates1]['label'],$dates[$dates1]['fname'],$dates[$dates1]['date']);
}
}
?>
</div>
<div class="row">
<p>&nbsp;</p>
<div class="col-md-12 text-center gap-items-5">
                                                    <button type="reset" class="btn btn-lg btn-danger waves-effect m-l-5"
													onclick="history.go(-1);">
                                                        Cancel<label><i class="fa fa-tick"></i></label>
                                                    </button>
													<?php
if(isset($edit) && $edit!="0"){
	?>
													
													<button type="submit" name="add_itembtn" id="subbtn" 
													class="btn btn-lg btn-primary waves-effect waves-light">
                                                        Update Item<label><i class="fa fa-tick"></i></label>
                                                    </button>
<?php } 
else { 
?>
													<button type="submit" name="add_itembtn" id="subbtn" 
													class="btn btn-lg btn-primary waves-effect waves-light">
                                                        Insert Item<label><i class="fa fa-tick"></i></label>
                                                    </button>

<?php } ?>
                                                    <input type="hidden" name="add_item" value="add_item">
                    <hr class="d-lg-none">
                    
                                                </div>


			
				  </div>
				  
				  
				  
				  
				  
				  
				  
				  
				  
				  </div>
				  <input type='submit' style="display: none;">
				  </form>
				  
				  
				  
				  
				  
				  </div>
				  </div>
				  
				  

				  <?php
///////////////////////////////////////////////////////////////////
if(isset($_POST['add_item'])){
	
	//var_dump($_POST);
	
$text1=$text_fields['fields'];
$text2=$text_fields['posts'];
$text3=array_combine($text1, $text2);

if(isset($integer_fields) && !empty($integer_fields)){
$integer1=$integer_fields['fields'];
$integer2=$integer_fields['posts'];
$integer3=array_combine($integer1, $integer2);
}


if(isset($wysiwygitem)  && !empty($wysiwygitem)){
foreach ($wysiwygitem as $wysiwyg1 => $wysiwygv){
$wysiwygfound=$wysiwygitem[$wysiwyg1]['fname']."_name";
$wysiwygfound2=$_POST[$wysiwygfound];
$wysiwygarray2[] = $wysiwygfound2;
}
$wysiwyg3=array_combine($wysiwygarray1, $wysiwygarray2);
}

if(isset($wysiwygitem_choice)  && !empty($wysiwygitem_choice)){
foreach ($wysiwygitem_choice as $wysiwyg1_choice => $wysiwygv_choice){
$wysiwygfound_choice=$wysiwygitem_choice[$wysiwyg1_choice]['fname']."_name";
$wysiwygfound2_choice=$_POST[$text_area_name];
$wysiwygarray2_choice[] = $wysiwygfound2_choice;
}
$wysiwyg3_choice=array_combine($wysiwygarray1_choice, $wysiwygarray2_choice);
}

//helloworld($wysiwygfound2_choice);

//var_dump($wysiwyg3_choice);


if(isset($dates)  && !empty($dates)){
foreach ($dates as $dates1 => $datesval){
$datefound=$dates[$dates1]['fname'];
$datefound2=$_POST[$datefound];
$datefoundnewdate = strtotime($datefound2);
$datefoundnewdate = date("Y-m-d", $datefoundnewdate);
$datesarray2[] = $datefoundnewdate ;
}
$dates3=array_combine($datesarray1, $datesarray2);
}

if(isset($datedfield)){
$datedfield1=$_POST[insertion_date];
$newdate2 = strtotime($datedfield1);
// Convert timestamp into formatted date
$newdate = date("Y-m-d", $newdate2);
$array_date=array(insertion_date=>$newdate);
}

$extra=array(status=>'Active',ref=>$alias);

if(isset($integer3) && !empty($integer3)) {
$array_one=array_merge($extra,$integer3);
}
else{
$array_one=$extra;	
}
if(isset($array_date) && !empty($array_date)) {
$array_one=array_merge($array_one, $array_date);
}
if(isset($droparray) && !empty($droparray)) {
$array_one=array_merge($array_one,$droparray);
}
if(isset($droparray2) && !empty($droparray2)) {
$array_one=array_merge($array_one,$droparray2);
}

if(isset($droparray2_sub) && !empty($droparray2_sub)) {
$array_one=array_merge($array_one,$droparray2_sub);
}

if(isset($dates3) && !empty($dates3)) {
$array_one=array_merge($array_one,$dates3);
}

if(isset($checkboxes) && !empty($checkboxes)) {
$array_one=array_merge($array_one,$checkboxes);
}

if(isset($timepicks) && !empty($timepicks)) {
$array_one=array_merge($array_one,$timepicks);
}

	
$array_one=array_merge($array_one,$timepicks);


if(isset($text3) && !empty($text3) && isset($wysiwyg3) && !empty($wysiwyg3)) {
$array_two=array_merge($text3,$wysiwyg3);
}

elseif(isset($text3) && !isset($wysiwyg3)){
$array_two=$text3;	
}
elseif(!isset($text3) && isset($wysiwyg3)){
$array_two=$wysiwyg3;	
}
else{
$array_two=array();	
}

if(isset($wysiwyg3_choice) && !empty($wysiwyg3_choice) && isset($wysiwyg3) && !empty($wysiwyg3)) {
$array_two=array_merge($wysiwyg3_choice,$wysiwyg3);
}

elseif(isset($wysiwyg3_choice) && !isset($wysiwyg3)){
$array_two=$wysiwyg3_choice;	
}
elseif(!isset($wysiwyg3_choice) && isset($wysiwyg3)){
$array_two=$wysiwyg3;	
}
else{
$array_two=array();	
}

if(isset($directfields) && !empty($directfields)) {
foreach ($directfields as $d1 => $dvalue){
$direct1[] = $directfields[$d1]['fname'];
$direct2[] = $directfields[$d1]['value'];
}
	
$direct3=array_combine($direct1, $direct2);

$array_two=array_merge($array_two,$direct3);
}

if(isset($text3) && !empty($text3)){
$array_two=array_merge($array_two,$text3);
}

if(isset($edit) && $edit!="0"){
$array_three=array_merge($array_one,$array_two);


$editdata=db_editdata($form_table,id_col,$array_three,$lead_id,$alias);
if(isset($update_settings) && !empty($update_settings)){
add_updatev2($update_settings['update_flag'],$lead_id,$_SESSION['user'],$update_settings['update_ref'],$update_settings['update_email']);
}
	


$img_id=$lead_id;
//////
}

else{	
$editdata=db_insertdata($form_table,$array_two,$array_one,0,$alias);

$img_id=$editdata;
//////
}

if($editdata){

if(isset($redirect) && !empty($redirect)){
app_redirect_adv($redirect);
echo "Inserted / updated ! ";
}
else{
echo "error";	
$redirect2=$redirect2."/".$img_id;
app_redirect_adv($redirect2);	
}

}
else{
return;
}




}


?>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<?php
    
} 
}
/////////////////////////// function ends /////////////////////////////////



























?>