<?php
////////////////////// CORE FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
if (!function_exists('check_decode')) {
function check_decode($text) { 

$enc=base64_encode($text);
	  $denc=base64_decode($text);
	  if($enc==$denc){
	  $rt=base64_decode($text);
	  } else { 
	  $rt=$text;
	  }

    return $rt;
} 
}
/////////////////////////// function ends /////////////////////////////////
////////////////////// CORE FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
if (!function_exists('exists')) {
function exists($table,$col,$id) { 

/////////////////////////// function ends /////////////////////////////////

$link=uplink();
$table_query=$link->query("SELECT update_id FROM $table where $col='$id'");
if($table_query){
$deal_count=mysqli_num_rows($table_query);
return $deal_count;
// close connection 
$link->close();
}
else{
$deal_count=0;
return $deal_count;	
}

}
}
//////////////////////////// function ends ///////////////////////////////////
////////////////////// CORE FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
if (!function_exists('user_exists')) {
function user_exists($table,$col,$col_id,$id) { 

/////////////////////////// function ends /////////////////////////////////

$link=uplink();
$table_query=$link->query("SELECT id FROM $table where $col='$col_id' AND id='$id'");
if($table_query){
$deal_count=mysqli_num_rows($table_query);
return $deal_count;
// close connection 
$link->close();
}
else{
$deal_count=0;
return $deal_count;	
}

}
}
//////////////////////////// function ends ///////////////////////////////////


////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('view_record_adv_with_updates_v2')) {
	function view_record_adv_with_updates_v2($parameters){
 if (array_key_exists('id', $parameters)) {
   $id=$parameters['id'];
   }   
 
 if (array_key_exists('btn_id', $parameters)) {
   $btn_id=$parameters['btn_id'];
   }   
 
 
 if (array_key_exists('settings', $parameters)) {
   $settings=$parameters['settings'];
   }   

 if (array_key_exists('fields', $parameters)) {
   $fields=$parameters['fields'];
   }   

 if (array_key_exists('remote_cols', $parameters)) {
   $remote_fields=$parameters['remote_cols'];
   }   
 
if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('ref', $settings)) {
   $ref=$settings['ref'];
   }		
   if (array_key_exists('id_col', $settings)) {
   $id_col=$settings['id_col'];
   }	

$tdsettings=array(
	'table'=>$table,
	'id_col'=>$id_col,
	'ref_value'=>$ref,
	'where_col'=>$id_col,
	'where_value'=>$id,
	'fields_array'=>$fields['fields'],
	'status_value'=>'Active',
	'order'=>'ASC',
	'order_col'=>id_col,
	'errors'=>"0",
	'echo'=>"0",
	'limit'=>1,
	'type'=>'wherecol_ref_status');

	$loaded=db_fetch($tdsettings);
	
///////////////////////////////////////////////////////////////////var_dump($loaded_values);
	?>
   
	

								<!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   <div id="page-right-content">
<!-- note this div closes in footer -->
                    <div class="container">
                        <div class="row">
                            <div class="col-sm-12">
   
<?php

	

echo "<h3>".$parameters['heading']."</h3> <hr />";


?>
   
   <p>&nbsp;</p>
   <div class="col-md-12">
   
   
   <div class="col-md-6">
      <p>
	  <?php if($loaded){ 
	foreach($loaded as $item){
	foreach (array_combine($fields['labels'], $fields['fields']) as $key => $field) {
	
    ?>
	  <strong><?php echo $key; ?> : </strong><?php 
	  echo check_decode($item[$field]);
	  
	  ?>
	  
	  
	  <br />
	  <br />
	  <?php } }  }
	  else {
		  echo "Not Working!";
		  
	  }
	?>
 
	 </p>
	  
	  
                        </div>
	
	
	
	<?php
	if (array_key_exists('remote_cols', $parameters)) {
 ?>
	<div class="col-md-6">
	<?php
	
	$tdsettings2=array(
	'table'=>$table,
	'id_col'=>$id_col,
	'ref_value'=>$ref,
	'where_col'=>$id_col,
	'where_value'=>$id,
	'fields_array'=>$remote_fields['fields'],
	'status_value'=>'Active',
	'order'=>'ASC',
	'order_col'=>id_col,
	'errors'=>"0",
	'echo'=>"0",
	'limit'=>1,
	'type'=>'wherecol_ref_status');

	
	 $loaded2=db_fetch($tdsettings2);
  ?>
	
	<p>
	  <?php if($loaded2){ 
	foreach($loaded2 as $item2){
	foreach (array_combine($remote_fields['labels'], $remote_fields['fields']) as $key2 => $remote_field) {
	
    ?>
	  <strong><?php echo $key2; ?> : </strong><?php 
	  
	  $zoor=db_ref($settings['child_table'],$settings['child_table_id_col'],$item2[$remote_field],$settings['child_table_title'],0,0);
	   
	  echo check_decode($zoor);
	  
	  
	  ?>
	  
	  
	  <br />
	  <br />
	  <?php } }  }
	?>
 
	 </p>
	  
</div>
	<?php } ?>

<?php 
   
   if (array_key_exists('links', $parameters)) {
   
   form_button_simple($btn_id,$links); 
   
   }
   ?>
   
                        </div>
						
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php 
	$status_count=exists(updates_table,updates_table_lead_col,$id);
	
	if($status_count!=0){
			
?>
		<div id="start 2">
									<div class="row">
				
	
							

	
	
	
	
								<div class="tab-content">
                                <div class="tab-pane active" id="home-b1">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <!-- Personal-Information -->
                                            <div class="panel panel-default panel-fill">
                                                <div class="panel-heading" style="background-color:#d4f3ee;">
                                                    <h3 class="panel-title">Updates / Communications</h3>
                                                </div>
                                                <div class="panel-body">
                                                    
	<?php
	$update_cols=array(updates_table_id_col,updates_table_lead_col,
	updates_table_date_time_col,updates_table_type_col,updates_table_detail_col,
	updates_table_posted_by_col,updates_table_status_col,updates_table_ref_col,"type");
	
	$updatesettings=array(
	'table'=>updates_table,
	'id_col'=>updates_table_id_col,
	'ref_value'=>routine_update_alias,
	'ref_col'=>updates_table_ref_col,
	'where_col'=>updates_table_lead_col,
	'where_value'=>$id,
	'fields_array'=>$update_cols,
	'status_value'=>'Active',
	'status_col'=>updates_table_status_col,
	'order'=>'DESC',
	'order_col'=>updates_table_id_col,
	'errors'=>"1",
	'echo'=>"0",
	'limit'=>300,
	'type'=>'updates');

	$updatesettings_load=db_fetch($updatesettings);
		
	if($updatesettings_load){ 
	foreach($updatesettings_load as $update_item){
	
	     
				
	
		
?>	
													<div class="m-b-20">
														
		

	<strong>Update By</strong> : <?php echo $update_item[updates_table_posted_by_col]; ?><br />
	<p align="right"><strong>Dated</strong> : <?php echo date('M j Y g:i A', strtotime($update_item[updates_table_date_time_col]));  ?></p>
	<strong>Status Set to</strong> : <span style="color:red";><?php echo db_ref(sub_table,sub_table_id,$update_item["type"],sub_table_title); ?></span><br />
	<p>&nbsp;</p>
	<?php echo $update_item[updates_table_detail_col]; ?>
 
														<hr />
														
                                                        </div>
                                                    <?php
													}
													}
	                                                   ?>
                                                </div>
                                            </div>
                                            <!-- Personal-Information -->

                                            <!-- Social -->
                                            
                                            <!-- Social -->
                                        </div>



                                    </div>
                                </div>
                               </div>

	

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

else{	?>

<p>There are no updates for this Lead.</p>

<?php } ?>		
								
								<div class="text-center">
	  <button type="button" class="btn btn-danger m-t-10" onclick="history.go(-1);">Close View</button>
      
	  
   </div>
								
								
								
								</div>
								</div>
								</div>
								<p>&nbsp;</p>
								<p>&nbsp;</p>
								<p>&nbsp;</p>
							
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////

////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('view_record_adv')) {
	function view_record_adv($id,$settings,$array_cols){
if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('id_col', $settings)) {
   $id_col=$settings['id_col'];
   }
   if (array_key_exists('ref', $settings)) {
   $ref=$settings['ref'];
   }
   if (array_key_exists('no_rows', $settings)) {
   $rows=$settings['no_rows'];
   }
if (array_key_exists('child_table', $settings)) {
   $child_table=$settings['child_table'];
   }
   if (array_key_exists('child_table_id_col', $settings)) {
   $child_table_id_col=$settings['child_table_id_col'];
   }
   if (array_key_exists('child_table_title', $settings)) {
   $child_table_title=$settings['child_table_title'];
   }
   
   if(isset($array_cols) && !empty($array_cols)){
foreach ($array_cols as $arrayloop => $valloop2){
   
   
   $new_cols[]=$array_cols[$arrayloop]['field'];
   
}
   }
   
   
	$tdsettings=array(
	'table'=>$table,
	'id_col'=>$id_col,
	'ref_value'=>$ref,
	'where_col'=>$id_col,
	'where_value'=>$id,
	'fields_array'=>$new_cols,
	'status_value'=>'Active',
	'order'=>'ASC',
	'order_col'=>id_col,
	'errors'=>"1",
	'echo'=>"0",
	'limit'=>$rows,
	'type'=>'status_ref');

	
	$tdload=db_fetch($tdsettings);
	
	
	$loaded=$tdload[0];
	
	$loaded_keys=array_keys($loaded);
	$loaded_values=array_values($loaded);

//var_dump($loaded_values);

foreach($loaded as $litem =>$loppp){
$loaded_arr[]['value']=$loaded[$litem];

}


$array_cols=array_replace_recursive($array_cols,$loaded_arr);



	?>
   <!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   <div id="page-right-content" style="padding-top:40px !IMPORTANT;">

                    <div class="container">
                        <div class="row">
							<div class="col-sm-12">
								<div id="start">
									<div class="row">
				
	
							

	
	
	
	
								<div class="tab-content">
                                <div class="tab-pane active" id="home-b1">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <!-- Personal-Information -->
                                            <div class="panel panel-default panel-fill">
                                                <div class="panel-heading">
                                                    <h3 class="panel-title">Details</h3>
                                                </div>
                                                <div class="panel-body">
                                                    
	<?php if($array_cols){ 
	
	foreach($array_cols as $arraykey => $value_col) {
         
				
	
		
?>	
													<div class="m-b-20">
                                                        <?php 
														
		

if(isset($array_cols[$arraykey]['remote_col']) && $array_cols[$arraykey]['remote_col']!="0"){
$value=db_ref($settings['child_table'],$settings['child_table_id_col'],$array_cols[$arraykey]['value'],$settings['child_table_title']);	
}		
else{
$value=$array_cols[$arraykey]['value'];	
}


if(isset($array_cols[$arraykey]['enc']) && ($array_cols[$arraykey]['enc']!="0")){
$value=base64_decode($value);	
}														
if(isset($array_cols[$arraykey]['label']) && $array_cols[$arraykey]['label']!="0"){		
	echo "<strong>".$array_cols[$arraykey]['label']."</strong>"." : ".$value."<br />";
}	

														
														?>
                                                        </div>
	<?php 
	
	}
	}

 ?>
                                                    
                                                </div>
                                            </div>
                                            <!-- Personal-Information -->

                                            <!-- Social -->
                                            
                                            <!-- Social -->
                                        </div>



                                    </div>
                                </div>
                               </div>

	

								</div>
								</div>
								<div class="text-center">
	  <button type="button" class="btn btn-danger m-t-10" onclick="history.go(-1);">Close View</button>
      
	  
   </div>
								<p>&nbsp;</p>
								<p>&nbsp;</p>
								<p>&nbsp;</p>
								
								
								</div>
								</div>
								</div>
							
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
////////////////////// CORE FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
if (!function_exists('get_content2')) {
function get_content2($ref,$id_col,$array_cols,$table,$limit,$id) { 

$tdsettings=array(
	'table'=>$table,
	'id_col'=>$id_col,
	'ref_value'=>$ref,
	'where_col'=>$id_col,
	'where_value'=>$id,
	'fields_array'=>$array_cols,
	'status_value'=>'Active',
	'order'=>'ASC',
	'order_col'=>id_col,
	'errors'=>"0",
	'echo'=>"0",
	'limit'=>$limit,
	'type'=>'wherecol_ref_status');

	$tdload=db_fetch($tdsettings);
	

    return $tdload;
} 
}
/////////////////////////// function ends /////////////////////////////////


////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('form_button_adv')) {
function form_button_adv($id,$links_array){
  ?>
<div class="col-md-12">
  <div>  
<div class="input-group">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn-lg btn-primary dropdown-toggle" data-toggle="dropdown" style="overflow: hidden; position: relative;" aria-expanded="false">Action <span class="caret"></span></button>
                                                            <ul class="dropdown-menu">
<?php         
	foreach (array_combine($links_array['labels'], $links_array['urls']) as $label => $url) {
?>
		 <li><a href="<?php echo $url; ?>" target="_blank"><?php echo $label; ?></a></li>
	<?php } ?> 
		 </ul>
                                                        </div>
                                                    </div>
													</div>
													<p>&nbsp;</p>
													<p>&nbsp;</p>
														</div>
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
////// updated 28-3-2021
if (!function_exists('view_details_v2_old')) {
function view_details_v2_old($parameters){
 
 
 if (array_key_exists('id', $parameters)) {
   $id=$parameters['id'];
   }   
 
 if (array_key_exists('btn_id', $parameters)) {
   $btn_id=$parameters['btn_id'];
   }   
 
 
 if (array_key_exists('settings', $parameters)) {
   $settings=$parameters['settings'];
   }   

 if (array_key_exists('fields', $parameters)) {
   $fields=$parameters['fields'];
   }   

 if (array_key_exists('pw_fields', $parameters)) {
   $pw_fields=$parameters['pw_fields'];
   }   
 
 if (array_key_exists('url_fields', $parameters)) {
   $url_fields=$parameters['url_fields'];
   }   
 
 if (array_key_exists('remote_cols', $parameters)) {
   $remote_fields=$parameters['remote_cols'];
   }   
 
 if (array_key_exists('links', $parameters)) {
   $links=$parameters['links'];
   }   


if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('ref', $settings)) {
   $ref=$settings['ref'];
   }		
   if (array_key_exists('id_col', $settings)) {
   $id_col=$settings['id_col'];
   }	

	
   $loaded=get_content2($ref,$id_col,$fields['fields'],$table,"1",$id);
   
?>
   <!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   <div id="page-right-content">
<!-- note this div closes in footer -->
                    <div class="container">
                        <div class="row">
                            <div class="col-sm-12">
   
<?php
echo "<h3>".$parameters['heading']."</h3> <hr />";
?>
   
   <p>&nbsp;</p>
   <div class="col-md-12">
   <div class="col-md-6">
      <p>
	  <?php if($loaded){ 
	foreach($loaded as $item){
	foreach (array_combine($fields['labels'], $fields['fields']) as $key => $field) {
	
    ?>
	  <strong><?php echo $key; ?> : </strong><?php 
	  echo check_decode($item[$field]);
	  
	  ?>
	  
	  
	  <br />
	  <br />
	  <?php } }  }
	?>
 
	 </p>
	  
	  
                        </div>
	
	
	
	<?php
	if (array_key_exists('remote_cols', $parameters)) {
 ?>
	<div class="col-md-6">
	<?php
	 $loaded2=get_content2($ref,$id_col,$remote_fields['fields'],$table,"1",$id);
  ?>
	
	<p>
	  <?php if($loaded2){ 
	foreach($loaded2 as $item2){
	foreach (array_combine($remote_fields['labels'], $remote_fields['fields']) as $key2 => $remote_field) {
	
    ?>
	  <strong><?php echo $key2; ?> : </strong><?php 
	  
	  $zoor=db_ref($settings['child_table'],$settings['child_table_id_col'],$item2[$remote_field],$settings['child_table_title'],1,0);
	   
	  echo check_decode($zoor);
	  
	  
	  ?>
	  
	  
	  <br />
	  <br />
	  <?php } }  }
	?>
 
	 </p>
	  
</div>
	<?php } ?>


                        </div>
						<?php if (array_key_exists('pw_fields', $parameters)) {  ?>
						<div class="col-md-12">
						<div class="alert alert-success alert-dismissible fade in" role="alert" id="holo" style="display:none;">
                                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                                    <span aria-hidden="true">×</span>
                                                </button>
                                                <strong>Done!</strong> copied to clipboard.
                                            </div>
						<p>&nbsp;</p>
	<h4 class="m-t-0 header-title" style="color:red;"><b><?php echo $pw_fields['heading']; ?></b></h4>
	
	<div class="col-md-6" id="select_txt">
	
	
	<script type="text/javascript">
function copy_data(containerid) {
  var range = document.createRange();
  range.selectNode(containerid); //changed here
  window.getSelection().removeAllRanges(); 
  window.getSelection().addRange(range); 
  document.execCommand("copy");
  window.getSelection().removeAllRanges();
  //alert("data copied");
  //$('#holo').fadeOut(3000);  
 // $('#holo').hide();
  $('#holo').show(0).delay(5000).hide(0);
  //$('#holo').show();
 // $('#holo').fadeIn(3000);
}
  </script>
  

	
	
      <p>
	  <?php 
	  

	    $loaded3=get_content2($ref,$id_col,$pw_fields['pw_fields'],$table,"1",$id);
 
	  if($loaded3){ 
	foreach($loaded3 as $item4){
	foreach (array_combine($pw_fields['pw_labels'], $pw_fields['pw_fields']) as $pw_key => $pw_field) {
	
    ?>
	  <strong><?php echo $pw_key; ?> : </strong><?php
	   
	  echo check_decode($item4[$pw_field]);
	  
	  ?>
	  
	  
	  
	  <br />
	  <br />
	  <?php } }  }
	?>
    <strong>Login Url : </strong><h4><code><?php echo $url_fields['dir']; ?></code></h4>
	 
	 </p>
	  
	                    </div>
	
	<div class="col-md-6 text-right">
	
	<button type="button" class="btn btn-md btn-primary" onclick="copy_data(select_txt)">copy details</button>
    
	</div>					
						
						</div>
						<?php } ?>
<?php
if (array_key_exists('links', $parameters)) {
form_button_adv($btn_id,$links);
}
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="text-center">
	  <button type="button" class="btn btn-success m-t-10" onclick="history.go(-1);">Close View</button>
      
	  
   </div>
													<p>&nbsp;</p>
													<p>&nbsp;</p>
													<p>&nbsp;</p>
   
                        </div> <!-- end row -->
                    </div>

 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
////// updated 02-4-2021
if (!function_exists('email_adv')) {
function email_adv($parameters){
 
 
 if (array_key_exists('id', $parameters)) {
   $id=$parameters['id'];
   }   
 
 
 
 if (array_key_exists('settings', $parameters)) {
   $settings=$parameters['settings'];
   }   

 if (array_key_exists('fields', $parameters)) {
   $fields=$parameters['fields'];
   }   

 if (array_key_exists('body_fields', $parameters)) {
   $body_fields=$parameters['body_fields'];
   }   
 
 if (array_key_exists('header_fields', $parameters)) {
   $header_fields=$parameters['header_fields'];
   }   
 
 if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('ref', $settings)) {
   $ref=$settings['ref'];
   }		
   if (array_key_exists('id_col', $settings)) {
   $id_col=$settings['id_col'];
   }	

	
   $loaded=get_content2($ref,$id_col,$fields['fields'],$table,"1",$id);
   
?>
   <!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   
   
	<?php 
	 if(isset($fields) && !empty($fields)) {
		 $type=$fields['type'];
	 if($type=='cart') {
		 

$abc = '<table border="2" align="center" cellpadding="2" cellspacing="20px"';
 
	        
            $abc.='<tr>';
			if($loaded){
			foreach($loaded as $item){
	foreach (array_combine($fields['labels'], $fields['fields']) as $key => $field) {
$abc.='    
			<th style="padding:10px">'.$key.'</th>';
			} } }
	$abc.='</tr>';
	
    
		$abc.='<tr>';
		if($loaded){
foreach($loaded as $item){
	foreach (array_combine($fields['labels'], $fields['fields']) as $key => $field2) {
$abc.='
			<td style="padding:10px">'.$item[$field2].'</td>';
		}} }
$abc.='</tr>';	
			
			
        $abc.='</table>';

	 
	 }  
	///////////////////////////////////////////////// 
	///////////////////////////////////////////////// 
	///////////////////////////////////////////////// 
	///////////////////////////////////////////////// 
	 else{
		 
		$abc = '<table border="2" cellpadding="2" cellspacing="20px" <tbody>';
 
	        if($loaded){
			foreach($loaded as $item){
	foreach (array_combine($fields['labels'], $fields['fields']) as $key => $field2) {

            $abc.='<tr>';
			
$abc.='    
			<td style="padding:10px"><strong>'.$key.'</strong></td>';
$abc.=		'<td style="padding:10px">'.$item[$field2].'</td>';
	$abc.='</tr>';				
			} 
			
			
	
	} }
    
			
			
        $abc.='</tbody></table>';
	
	 
	 } 
		 
	 }
	 
	 
	  /// isset fields
	  
	?>
	 <div id="page-right-content">
<!-- note this div closes in footer -->
                    <div class="container">
                        <div class="row">
                            <div class="col-sm-12">

	<?php
 //echo $abc;
 if($body_fields['greeting_name']==1){	 
 $greeting='Dear <strong>'.ucwords(db_ref($table,id_col,$id,$body_fields['greeting_name_field'])). "</strong> ,";
 }
 else{
$greeting=$body_fields['greeting'];	 
 }
 
$email_list=$header_fields['email_list'];

if($header_fields['subject_name']=='1'){
$ename=ucwords(db_ref($table,id_col,$id,$body_fields['greeting_name_field']));
$sub=$ename.", ".$header_fields['subject'];	
}
else{
$sub=$header_fields['subject'];	
}

$email_list=$header_fields['email_list'];
$email_subject=$sub;


$email_message = "

$greeting.


<br /><br />


".$body_fields['greeting_sub']." 

<br />
<br />
".$abc."

<br />
<br />
<br />

".$body_fields['regards']."

";

$mail_headers = "From: ".$header_fields['from_name']." < ".$header_fields['from']." >\r\n"; 
$mail_headers .= "Cc: ".$header_fields['cc']."" . "\r\n";
$mail_headers .= "Reply-To: ".$header_fields['reply_to']."\r\n";
$mail_headers .= "Bcc: ".$email_list."\r\n";

//$send=mail ($email_id , $email_subject, $email_message,$mail_headers);

?>
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////

//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
if (!function_exists('make_update')) {
function make_update($values,$encoding,$lead_id) {
if (array_key_exists('texts', $values)) {
   $text=$values['texts'];
   }

if (array_key_exists('dropdowns', $values)) {
   $dropdown=$values['dropdowns'];
   }

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

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'];
   }
 
?>

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

                    <div class="container">
                        <div class="row">
                            <div class="col-sm-12">
																				
                                <h4 class="header-title m-t-0 m-b-20"><?php echo $form_heading; ?></h4>
	  </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">

<h4 align="center">Updating : <span style="color:red;">IMS-<?php echo $lead_id; ?></span></h4>



<?php

$company_name=db_ref(table,id_col,$lead_id,title);
$cell_number=db_ref(table,id_col,$lead_id,cell);



?>

<h5>Company Name : <span style="color:red;"><?php echo $company_name; ?></span></h5>
<p>&nbsp;</p>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($dropdown) && !empty($dropdown)){
$editing=array(
'editing'=>'0');
foreach ($dropdown as $droploop => $valloop){
	
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;
}


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

</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,
'id'=>$lead_id
);

$text_fields=form_control($parameters);
}
?>
</div>
<div class="row">
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($disableds) && !empty($disableds)){
$parametersd=array(
'text'=>$disableds,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'id_col'=>$id_col,
'id'=>$lead_id,
'table'=>$table
);
$disableds_fields=form_control($parametersd);
}
?>
</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
  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' ] ]
        ]
  //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">

      
<textarea name="<?php echo $wysiwygitem[$wysiwyg1]['fname']."_name"; ?>" id="<?php echo $wysiwygitem[$wysiwyg1]['fname']."_div"; ?>"></textarea>
          </div>


    
		
		

<?php
	  
}
}
?>
</div>
<div class="row">
</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-success 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-success 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>
				  </form>
				  
				  
				  
				  
				  
				  </div>
				  </div>
<h4 align="center">Updating : <span style="color:red;">IMS-<?php echo $lead_id; ?></span></h4>

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

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);
}


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



if(isset($droparray) && !empty($droparray)) {
$array_one=$droparray;
//$status_text=db_ref(sub_table,sub_table_id,$droparray['type'],sub_table_title);
//helloworld($status_text);
}

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($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);
}



//var_dump($array_one);	
//var_dump($array_two);
//exit();	
$adddata=db_insertdata($form_table,$array_two,$array_one,0,$alias);
/////////////
$rec_id=$adddata;
//////


if($adddata){
    
$fields1=array(
response_type=>$_POST['response_type_dropname']
);

$editdata=db_editdata(main_table,id_col,$fields1,$lead_id,"lead_entry");
    

if(isset($redirect) && !empty($redirect)){
app_redirect_adv($redirect);
}
else{
$redirect2=$redirect2."/".$rec_id;
app_redirect_adv($redirect2);	
}

}
else{
return;
}

}


}


?>
<?php
    
} 

/////////////////////////// function ends /////////////////////////////////
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
if (!function_exists('make_appointment')) {
function make_appointment($values,$encoding,$lead_id) {
if (array_key_exists('texts', $values)) {
   $text=$values['texts'];
   }

if (array_key_exists('dropdowns', $values)) {
   $dropdown=$values['dropdowns'];
   }

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

if (array_key_exists('extra_dated', $values)) {
   $dated=$values['extra_dated'];
   }
if (array_key_exists('disableds', $values)) {
   $disableds=$values['disableds'];
   }

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'];
   }
 
?>

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

                    <div class="container">
                        <div class="row">
                            <div class="col-sm-12">
																				
                                <h4 class="header-title m-t-0 m-b-20"><?php echo $form_heading; ?></h4>
	  </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">

<h4 align="center">Appointment For : <span style="color:red;">IMS-<?php echo $lead_id; ?></span></h4>



<?php

$company_name=db_ref(table,id_col,$lead_id,company_name);
$cell_number=db_ref(table,id_col,$lead_id,cell_number);



?>

<h5>Company Name : <span style="color:red;"><?php echo $company_name; ?></span></h5>
<p>&nbsp;</p>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($dropdown) && !empty($dropdown)){
$editing=array(
'editing'=>'0');
foreach ($dropdown as $droploop => $valloop){
	
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;
}


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

</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,
'id'=>$lead_id
);

$text_fields=form_control($parameters);
}
?>
</div>
<div class="row">
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($disableds) && !empty($disableds)){
$parametersd=array(
'text'=>$disableds,
'form_name'=>'fname',
'form_submit_id'=>'add_item',
'id_col'=>$id_col,
'id'=>$lead_id,
'table'=>$table
);
$disableds_fields=form_control($parametersd);
}
?>
</div>
<div class="row">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($dated)){
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>
<p>&nbsp;</p>
<?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
 toolbar: [
            [ 'font', [ 'bold', 'italic', 'underline', 'strikethrough','clear'] ],
            [ 'fontsize', [ 'fontsize' ] ],
            [ 'view', [ 'undo', 'redo', 'fullscreen'] ]
        ]
		 //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">

      
<textarea name="<?php echo $wysiwygitem[$wysiwyg1]['fname']."_name"; ?>" id="<?php echo $wysiwygitem[$wysiwyg1]['fname']."_div"; ?>"></textarea>
          </div>


    
		
		

<?php
	  
}
}
?>
</div>
<div class="row">
</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-success 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-success 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>
				  </form>
				  
				  
				  
				  
				  
				  </div>
				  </div>
<h4 align="center">Appointment For : <span style="color:red;">IMS-<?php echo $lead_id; ?></span></h4>

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

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);
}


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



if(isset($droparray) && !empty($droparray)) {
$array_one=$droparray;
//$status_text=db_ref(sub_table,sub_table_id,$droparray['type'],sub_table_title);
//helloworld($status_text);
}

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

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

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($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);
}



//var_dump($array_one);	
//var_dump($array_two);
//exit();	
$adddata=db_insertdata($form_table,$array_two,$array_one,0,$alias);
/////////////
$rec_id=$editdata;
//////


if($adddata){

if(isset($redirect) && !empty($redirect)){
app_redirect_adv($redirect);
}
else{
$redirect2=$redirect2."/".$rec_id;
app_redirect_adv($redirect2);	
}

}
else{
return;
}

}


}


?>
<?php
    
} 

/////////////////////////// function ends /////////////////////////////////
/////////////////////////////////////////////////////////////
function db_copy($dest_tbl,$cols,$id_col,$thisid){
$link= uplink();
$cols=implode(',',$cols);
//"SELECT $tofind from $remote_tbl WHERE $remote_col='$thisid'"
$q="INSERT INTO $dest_tbl ($cols) SELECT $cols from $dest_tbl WHERE $id_col='$thisid'";
$select_query=$link->query($q);


if($select_query){

// close connection 
$link->close();

}
else{
echo "error in copying records.";
}
}



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

////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('view_details_btn')) {
function view_details_btn($id,$settings,$fields){
if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   if (array_key_exists('ref', $settings)) {
   $ref=$settings['ref'];
   }		
   if (array_key_exists('id_col', $settings)) {
   $id_col=$settings['id_col'];
   }		
   		
   $loaded=get_content2($ref,$id_col,$fields['fields'],$table,"1",$id);
   
?>
   <!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   <div class="col-md-12">
      <p>
	  <?php if($loaded){ 
	foreach($loaded as $item){
	foreach (array_combine($fields['labels'], $fields['fields']) as $key => $field) {
	
    ?>
	  <strong><?php echo $key; ?> : </strong><?php 
	  if ( base64_encode(base64_decode($item[$field])) === $item[$field]){
	  echo base64_decode($item[$field]); } else { 
	  echo $item[$field];
	  }
	  ?>
	  
	  
	  <br />
	  <?php } }  }
	?>
 
	 </p>
	  
	  
                        </div>

 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////
























?>