Your file is ready and now you can <a href="frzng_lst.csv" type="application/octet-stream">download</a><br /><br />
<a href="pat_3.php">Click here to go back....</a>
<?php
include 'dbcon.php';
$result = mysqli_query($conn, "SELECT a.pat_id, b.pat_name, a.due_date_act, a.term_date, a.strow_no, a.nosoocyt, a.exchngstrw, a.contnrno, a.canistrno, a.goblet, a.viscotube, a.cryocolor, a.user_id, a.outwrdresn from actvty_trans_frzng_embryo a, cycle_lst b where a.pat_id=b.pat_mrn order by a.pat_id, date(a.term_date) DESC");
if (!$result) die('Couldn\'t fetch records');
$csv_fields=[];
$csv_fields[] = 'Patient MRN';
$csv_fields[] = 'Name';
$csv_fields[] = 'Register Date';
$csv_fields[] = 'Due Date';
$csv_fields[] = 'Straw No.';
$csv_fields[] = 'Nos Emb.';
$csv_fields[] = 'Ext. Straw';
$csv_fields[] = 'Tank';
$csv_fields[] = 'Canister';
$csv_fields[] = 'Goblet';
$csv_fields[] = 'Visco tube';
$csv_fields[] = 'Cryo color';
$csv_fields[] = 'User';
$csv_fields[] = 'Remark';
$fp = fopen('frzng_lst.csv', 'w');
if ($fp && $result) {
fputcsv($fp, $csv_fields);
    while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
		$row['pat_id'] = $row['pat_id'];
		$row['pat_name'] = $row['pat_name'];
		$row['due_date_act'] = $row['due_date_act'];
		$row['term_date'] = $row['term_date'];
		$row['strow_no'] = $row['strow_no'];
		$row['nosoocyt'] = $row['nosoocyt'];
		$row['exchngstrw'] = $row['exchngstrw'];
		$row['contnrno'] = $row['contnrno'];
		$row['canistrno'] = $row['canistrno'];
			if($row["goblet"]==="1"){
			$row["goblet"]="Orange";
			}else if ($row["goblet"]==="2"){
			$row["goblet"]="Blue";
			}else if ($row["goblet"]==="3"){
			$row["goblet"]="White";
			}else if ($row["goblet"]==="4"){
			$row["goblet"]="Yellow";
			}else if ($row["goblet"]==="5"){
			$row["goblet"]="Red";
			}else if ($row["goblet"]==="6"){
			$row["goblet"]="Purple";
			}else if ($row["goblet"]==="7"){
			$row["goblet"]="Light Blue";
			}else{
			$row["goblet"]="";
			}
	
			if($row["viscotube"]==="1"){
			$row["viscotube"]="Orange";
			}else if ($row["viscotube"]==="2"){
			$row["viscotube"]="Blue";
			}else if ($row["viscotube"]==="3"){
			$row["viscotube"]="Red";
			}else if ($row["viscotube"]==="4"){
			$row["viscotube"]="Yellow";
			}else if ($row["viscotube"]==="5"){
			$row["viscotube"]="Black";
			}else if ($row["viscotube"]==="6"){
			$row["viscotube"]="Light Blue";
			}else if ($row["viscotube"]==="7"){
			$row["viscotube"]="Grey";
			}else if ($row["viscotube"]==="8"){
			$row["viscotube"]="Green";
			}else if ($row["viscotube"]==="9"){
			$row["viscotube"]="Pink";
			}else if ($row["viscotube"]==="10"){
			$row["viscotube"]="Purple";
			}else{
			$row["viscotube"]="";
			}
			if($row["cryocolor"]==="1"){
			$row["cryocolor"]="Green";
			}else if ($row["cryocolor"]==="2"){
			$row["cryocolor"]="Blue";
			}else if ($row["cryocolor"]==="3"){
			$row["cryocolor"]="White";
			}else if ($row["cryocolor"]==="4"){
			$row["cryocolor"]="Red";
			}else if ($row["cryocolor"]==="5"){
			$row["cryocolor"]="Yellow";
			}else{
			$row["cryocolor"]="";
			}
		if($row["outwrdresn"]==="1"){
		$row["outwrdresn"]="Used for procedure";
		}else if ($row["outwrdresn"]==="2"){
		$row["outwrdresn"]="Non Viable";
		}else if ($row["outwrdresn"]==="3"){
		$row["outwrdresn"]="Non-renewal";
		}else if ($row["outwrdresn"]==="4"){
		$row["outwrdresn"]="Patient consent to discard";
		}else if ($row["outwrdresn"]==="5"){
		$row["outwrdresn"]="Tube added by mistake";
		}else{
		$row["outwrdresn"]="";
		}

		fputcsv($fp, array_values($row));
    }
//    die;
}
fclose($fp);

//include_once('class.phpmailer.php');
//$mail = new PHPMailer();
//$mail->IsSMTP();
//$mail->Host = "localhost";
//$mail->SMTPDebug = 1;
//$mail->SMTPAuth = true;
//$mail->Username = "noreply@novaivf.in";
//$mail->Password = "N3%9Gw[d*n)v";
//$mail->From       = "noreply@novaivf.in";
//$mail->FromName   = "RFID EWS - NOVA IVF";
//$mail->Subject = "Freezing data - Gorakhpur";
//$mail->addAddress('chetan.solanki@novaivffertility.com', 'Freezing data - Gorakhpur');
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
//$mail->MsgHTML($data);
//if(!$mail->Send()){
//  echo "Mailer Error: " . $mail->ErrorInfo;
//} else {
//} //
?>
