<?php
$amount7='';
	$something1='';
	   $sbada='';
	     $gbad24a='';
	     $bat='';
	     $jade_doc='';
	$form_ida='';
	$jade1a='';
	
	 $answerA=''; 
	     $display_uploads='';

	         $jade_doc3='';
	     $display_uploads3='';

	         $jade_doc1='';
	     $display_uploads1='';

$hap1=0;

$display_block18888=''; 



		 if ($jedID2U == 7) {



	$cust_id=$text_account3;///group_id ='$bgroup'
	
	$display_blockRA92='';
	
	
	

	     $sq112a="SELECT * FROM $table_name1005A WHERE dropdown_id ='1' AND status='1' AND survey_id = '$port_idz' Order by surveyQ_idK, surveyQ_id";

	///echo $sq112a;
	  $result112a = @mysqli_query($connection,$sq112a) or die(mysqli_error($connection));
	while ($row112a = mysqli_fetch_array($result112a)) {
	  $surveyQ_id=  $row112a['map_id'];
	 $stage[$surveyQ_id]=  $row112a['value'];
	$comment[$surveyQ_id]=  $row112a['dvalue'];
	$broad=  $row112a['van1'];


	   $sq112b="SELECT * FROM $table_name1005A Where dropdown_id ='2'AND status='1' AND  dvalue ='$comment[$surveyQ_id]' Order by surveyQ_idK, surveyQ_id";

	  $result112b = @mysqli_query($connection,$sq112b) or die(mysqli_error($connection));
	while ($row112b = mysqli_fetch_array($result112b)) {
	      $surveyA_id=  $row112b['map_id'];
	    // $test_type=  $row112b['test_type'];
	     $utf8text  =  $row112b['value'];

	       $utf8text = mb_convert_encoding($utf8text, 'HTML-ENTITIES', 'UTF-8');
	                   $answer["$surveyA_id"]  =$utf8text;
	$broad2  =  $row112b['buy'];//type of upload
	$app2  =  $row112b['app'];//number of Product Id
		$appName2  =  $row112b['zPersonalT'];//name Alternative
	$appSub2  =  $row112b['zDoctor'];//subtitle
	
	
	 $jade_doc1 ="Not Paid";
	$chap=0;
	
	$sq112abSz="SELECT * FROM $db_name.$table_name41 WHERE customer_id ='$text_account3' ";
	$result112abz = @mysqli_query($connection,$sq112abSz) or die(mysqli_error($connection));
	 $num3334bT29z = mysqli_num_rows($result112abz);

	if ($num3334bT29z>0) {
		
		    $result222abT9z = @mysqli_query($connection,$sq112abSz) or die(mysqli_error($connection));
		while ($row1bSz = mysqli_fetch_array($result222abT9z)) {
		    ///$order7=  stripslashes($row1bS['product_id']);
		 $order7=  $row1bSz['order_id'];
		
		$dateordr=$row1bSz['date_added'];
		$amount7=$row1bSz['total'];
	//$first7=  $row1bSz['firstname'];
	//$last7=  $row1bSz['lastname'];

	//echo "$cust_id44 $first7 $last7<br/>";
		
		 $sq112abS1z="SELECT * FROM $db_name.$table_name47 WHERE order_id ='$order7'  AND (product_id ='$app2' or product_id ='$appName2' )";
			$result112ab1z = @mysqli_query($connection,$sq112abS1z) or die(mysqli_error($connection));
			 $num3334bT291z = mysqli_num_rows($result112ab1z); 
		if ($num3334bT291z>0) {


	$sq112abS1ac="SELECT * FROM $db_name.$table_name42 WHERE order_id ='$order7'  AND order_status_id > '0'";
			$result112ab1ac = @mysqli_query($connection,$sq112abS1ac) or die(mysqli_error($connection));
	 $num3334bT291ac = mysqli_num_rows($result112ab1ac);
	if ($num3334bT291ac>0) {
$hap1=$hap1+1;
$chap=1;
	// $countPayPeops[$leader_id1]=$countPayPeops[$leader_id1]+1;
	//echo "l=$leader_id1 - order_id-$order7 - $first7 $last7 - $cust_id44 - $hap s=$hap2 -p=$hap1<br/>";
	$first7='';
	$last7='';
	
	 $jade_doc1 ="Paid";
	

	}	
			
			}	
			
			
			
			
			
		
		
		 }  //while
	    
	    } //if

	
	$broad2=0;
	
	
	 $sq112abS1zx="SELECT * FROM $db_name.$table_name54 WHERE product_id ='$app2' ";
				$result112ab1zx = @mysqli_query($connection,$sq112abS1zx) or die(mysqli_error($connection));
	while ($row1bSz111 = mysqli_fetch_array($result112ab1zx)) {
			    ///$order7=  stripslashes($row1bS['product_id']);
			 $price4=  $row1bSz111['price'];
			$Rtoday=date("Y-m-d h:i:s");
		 $sq112abS1zxa="SELECT * FROM $db_name.$table_name5409 WHERE product_id ='$app2' AND date_end>'$Rtoday' ";
						$result112ab1zxa = @mysqli_query($connection,$sq112abS1zxa) or die(mysqli_error($connection));
			while ($row1bSz111a = mysqli_fetch_array($result112ab1zxa)) {
				$price4=  $row1bSz111a['price'];
					}
			
			
	} ///just took out
	
	if ($price4>0){
	$price4=number_format("$price4",2);
	//$amount7=number_format("$amount7",2);
	}
	
	if ($amount7>0){
		//$price4=number_format("$price4",2);
		$amount7=number_format("$amount7",2);
		}
	
	
	
	$appName21=explode(",", $appName2);
	$appName21C=count($appName21);
	//$printAppEx="$appSub2";
$xr=0;
	if ($chap==0){
$printAppEx='<table width=\"700\">';

$printAppEx .="<tr><td colspan=\"3\"><b>$appSub2</b></td></tr>";////<td width=\"200\">$appName21[$xr]</td>

while($xr < $appName21C) {
$printAppEx .="
<tr>
<td width=\"200\">Payment Amount Due: $$price4</td><td>

<FORM  name=\"formcheck\"  METHOD=\"POST\" ACTION=\"$loc2/index.php?route=product/product&cc=$cc99&product_id=$app2\">

                 <input type=\"hidden\" name=\"gbad\" value=\"1\"  />
                 <input type=\"hidden\" name=\"survey_id\" value=\"21\"  />
                 <input type=\"hidden\" name=\"yummap\" value=\"100\" size=\"40\" />
               <input type=\"hidden\" name=\"gbadMod\" value=\"\"  />
                <button class=\"fsSubmitButtonsmall\" type=\"input\">$answer[$surveyA_id]</button>
         </form>


 </td><td>


 $jade_doc1</td></tr>
";

$jade_doc1='Not Paid';
$xr++;
}
$printAppEx.='</table>';

	}
	
	
	if ($chap>0){
		
		
////////		

//////		
$printAppEx='<table width=\"700\">';

$printAppEx .="<tr><td colspan=\"3\"><b>$appSub2</b></td></tr>";////<td width=\"200\">$appName21[$xr]</td>

while($xr < $appName21C) {
$printAppEx .="
<tr>
<td width=\"200\"><!--Total--> Paid <!---on Invoice: $$amount7 ---></td><td><!--- Invoice #: $order7---></td><td>

<!---Payment Date: $dateordr--->

 </td></tr>
";

$jade_doc1='Not Paid';
$xr++;
}
$printAppEx.='</table>';

	}	
	
	


	          $sz_C5[$surveyA_id]='';
	          $na1_C5[$surveyA_id]='';
	          $compl1_C5[$surveyA_id]='';

	             $sq112b1="SELECT * FROM $table_name806A Where customer_id ='$cust_id'AND  task_id ='$surveyA_id' AND status='1'";
	  $result112b1 = @mysqli_query($connection,$sq112b1) or die(mysqli_error($connection));
	 $num331 = mysqli_num_rows($result112b1);
	 if ($num331>0)  {
	   $sz_C5[$surveyA_id]='checked';
	 }


	              $sq112b1a="SELECT * FROM $table_name806A Where customer_id ='$cust_id'AND  task_id ='$surveyA_id' AND na1='2'";
	  $result112b1a = @mysqli_query($connection,$sq112b1a) or die(mysqli_error($connection));
	 $num331a = mysqli_num_rows($result112b1a);
	 if ($num331a>0)  {
	   $na1_C5[$surveyA_id]='checked';
	 }

	             $sq112b1b="SELECT * FROM $table_name806A Where customer_id ='$cust_id'AND  task_id ='$surveyA_id' AND compl1='1'";
	  $result112b1b = @mysqli_query($connection,$sq112b1b) or die(mysqli_error($connection));
	 $num331b = mysqli_num_rows($result112b1b);
	 if ($num331b>0)  {
	   $compl1_C5[$surveyA_id]='<img src="admin/GoTool/image/icon/check1.png" alt="" />';
	 }
if ($chap>0) {
	
	$compl1_C5[$surveyA_id]='<img src="admin/GoTool/image/icon/check1.png" alt="" />';
	$chap=0;
}


	         $status1='';
	  $sq112b1c="SELECT * FROM $table_name806A Where customer_id ='$cust_id' AND task_id ='$surveyA_id' AND (compl1='1') ORDER BY  date_added DESC LIMIT 1";
	 $result112b1c = @mysqli_query($connection,$sq112b1c) or die(mysqli_error($connection));
	while ($row112b1c = mysqli_fetch_array($result112b1c)) {
	$status1=$row112b1c['date_addedC'];
	//$status1=$row112b1c['date_added'];
	                $status1=date("m-d-Y", strtotime("$status1")); //date("Y-m-d H:i:s");
	                $status1="<font color=\"green\">$status1</font>";
	                }   //806
	  //  $commentA[$surveyA_id] =  $row112b['comment'];
	// $points[$surveyA_id]=  $row112b['A_points'];
	$status10='';  //we turned this off on front side.

	    //    $answerA .="<input type=\"checkbox\" value=\"1\" name=\"BT$surveyA_id\" $sz_C5[$surveyA_id]>  $answer[$surveyA_id] $status1   <br /> ";
	            $answerA .="<tr><!----<td><input type=\"radio\" value=\"1\" name=\"BT$surveyA_id\" $sz_C5[$surveyA_id]> </td><td><input type=\"radio\" value=\"2\" name=\"BT$surveyA_id\" $na1_C5[$surveyA_id]> </td><td><input type=\"radio\" value=\"0\" name=\"BT$surveyA_id\" > </td>---><td><b>$answer[$surveyA_id] </b> $printAppEx</td><td>$compl1_C5[$surveyA_id] $status1   </td></tr> ";

	         $status1='';
	   }

	$display_block18888 .="$stage[$surveyQ_id]<br/>
	     <table class=\"list\"><thead><tr><!---<td width=\"150\">$CAPz Classes to Complete</td><td width=\"150\"> Content Previously Completed</td><td width=\"30\">Reset</td>---><td>$roadwhatZ[$broad]</td><td width=\"150\">$CAPz Payment Satisfied</td></tr></thead>
	     $answerA </table><br/><br/>";
	     $answerA='';


	     }                                                                                                             //  AND


	  //          $sq112b1bd="SELECT * FROM $table_name806A Where customer_id ='$cust_id'AND (compl1='1'or status ='1' or na1='2')";

// $sq112bgt="SELECT * FROM $table_name1005A Where dropdown_id ='2'  AND group_id =' $group_id[$map_id]' AND status ='1'  AND survey_id = '$port_idz'    Order By map_id ASC";
	
	  $sq112bgt="SELECT * FROM $table_name1005A Where dropdown_id ='2'   AND status ='1'  AND survey_id = '$port_idz'    Order By map_id ASC";
	  $result112bgt = @mysqli_query($connection,$sq112bgt) or die(mysqli_error($connection));
	         $num331at = mysqli_num_rows($result112bgt);
	$num331bd =$num331at;

	//$result112b1bd = @mysqli_query($connection,$sq112b1bd) or die(mysqli_error($connection));
	// $num331bd = mysqli_num_rows($result112b1bd);

	    $sq112b1bde="SELECT * FROM $table_name806A Where customer_id ='$cust_id'AND ( compl1='1'  or na1='2')";
	  $result112b1bde = @mysqli_query($connection,$sq112b1bde) or die(mysqli_error($connection));
	 $num331bde = mysqli_num_rows($result112b1bde);


//echo "hap $hap1  and $num331bd";
	 ///      if ($num331bd>0){
		 if ($hap1>0 AND $num331bd>0){
		
	        $thinge=round($hap1/$num331bd*100);
	        }else{
	         $thinge=0;
	        }

	        if ($thinge==100){
	     ///   if( $num331bd != $num331bde){
		if( $num331bd != $hap1){
	         $thinge=99;
	        }
	        }
	          $thinge1='';
	          $thinge1=$thinge*8;                                                                                                  //token=$tok&log=$text_account3
	           // $num331bd-$num331bde-hap1=$hap1  annd $num331bd-$num331bde-
	   $chart="<br/><div align=\"center\">You are $thinge% complete.  <br/><table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">

	  <tr>
	   <td valign=\"bottom\" background=\"$loc2/admin/GoTool/image/roadway/track3.jpg\">

	    <div class=\"progress progress-striped active\">
						 <div class=\"progress-bar progress-bar-darkblue\" role=\"progressbar\" aria-valuenow=\"$thinge\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: $thinge%\"> <span><!---$thinge%--></span> </div>
				  </div>

	            </td></tr>

	</table>  </div>



	  ";


	 $display_blockRA92 =  " $chart<br/>

	                 $displayAdvice $something1
	                $startsaying    <br />
	          


	                $display_block18888
	            
	                
	                       ";

	  }?>