  | 
                       | 
          
            
               
                 code 
<?php 
// begin our session 
session_start();  
$check=0; 
/* creates a compressed zip file */ 
function create_zip($files = array(),$destination = '',$overwrite = false) { 
	//if the zip file already exists and overwrite is false, return false 
	if(file_exists($destination) && !$overwrite) { return false; } 
	//vars 
	$valid_files = array(); 
	//if files were passed in... 
	if(is_array($files)) { 
		//cycle through each file 
		foreach($files as $file) { 
			//make sure the file exists 
			if(file_exists($file)) { 
				$valid_files[] = $file; 
			} 
		} 
	} 
 
	//if we have good files... 
	if(count($valid_files)) { 
		//create the archive 
		$zip = new ZipArchive(); 
		if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { 
			return false; 
		} 
		//add the files 
		foreach($valid_files as $file) { 
			$zip->addFile($file,$file); 
		} 
		//debug 
		//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; 
		//close the zip -- done! 
		$zip->close(); 
		//check to make sure the file exists 
		return file_exists($destination); 
	} 
	else 
	{ 
		return false; 
	} 
}//end function 
 
//-- SMTP Mail Function  By Aditya Bhatt 
$rec_name = $_POST["rec_name"]; 
$rec_room = $_POST["rec_room"]; 
$rec_floor = $_POST["rec_floor"]; 
if($rec_floor == ""){$rec_floor = "-";} 
$rec_building = $_POST["rec_building"]; 
$rec_address = $_POST["rec_address"]; 
$rec_phone = $_POST["rec_phone"]; 
$rec_fax = $_POST["rec_fax"]; 
 
    $billaddress1_1 = ""; 
	$billaddress2_1 = ""; 
	$billaddress3_1 = ""; 
	$billaddress4_1 = ""; 
	$province1 = ""; 
	$postcode1 = ""; 
 
    $billaddress1_2 = ""; 
	$billaddress2_2 = ""; 
	$billaddress3_2 = ""; 
	$billaddress4_2 = ""; 
	$province2 = ""; 
	$postcode2 = ""; 
 
    $billaddress1_3 = ""; 
	$billaddress2_3 = ""; 
	$billaddress3_3 = ""; 
	$billaddress4_3 = ""; 
	$province3 = ""; 
	$postcode3 = ""; 
 
    $billaddress1_4 = ""; 
	$billaddress2_4 = ""; 
	$billaddress3_4 = ""; 
	$billaddress4_4 = ""; 
	$province4 = ""; 
	$postcode4 = ""; 
 
	$billaddress1_5 = ""; 
	$billaddress2_5 = ""; 
	$billaddress3_5 = ""; 
	$billaddress4_5 = ""; 
	$province5 = ""; 
	$postcode5 = ""; 
 
if($_POST["billaddress1_1"]!="") 
{ 
	$billaddress1_1 = $_POST["billaddress1_1"]; 
	$billaddress2_1 = $_POST["billaddress2_1"]; 
	$billaddress3_1 = $_POST["billaddress3_1"]; 
	$billaddress4_1 = $_POST["billaddress4_1"]; 
	$province1 = $_POST["province1"]; 
 
 
	$postcode1 = $_POST["postcode1"]; 
} 
 
if( $_POST["billaddress1_2"]!="") 
{ 
$billaddress1_2 = $_POST["billaddress1_2"]; 
$billaddress2_2 = $_POST["billaddress2_2"]; 
$billaddress3_2 = $_POST["billaddress3_2"]; 
$billaddress4_2 = $_POST["billaddress4_2"]; 
$province2 = $_POST["province2"]; 
$postcode2 = $_POST["postcode2"]; 
} 
 
if($_POST["billaddress1_3"]!="") 
{ 
$billaddress1_3 = $_POST["billaddress1_3"]; 
$billaddress2_3 = $_POST["billaddress2_3"]; 
$billaddress3_3 = $_POST["billaddress3_3"]; 
$billaddress4_3 = $_POST["billaddress4_3"]; 
$province3 = $_POST["province3"]; 
$postcode3 = $_POST["postcode3"]; 
} 
 
if($_POST["billaddress1_4"]!="") 
{ 
$billaddress1_4 = $_POST["billaddress1_4"]; 
$billaddress2_4 = $_POST["billaddress2_4"]; 
$billaddress3_4 = $_POST["billaddress3_4"]; 
$billaddress4_4 = $_POST["billaddress4_4"]; 
$province4 = $_POST["province4"]; 
$postcode4 = $_POST["postcode4"]; 
} 
 
if($_POST["billaddress1_5"]!="") 
{ 
$billaddress1_5 = $_POST["billaddress1_5"]; 
$billaddress2_5 = $_POST["billaddress2_5"]; 
$billaddress3_5 = $_POST["billaddress3_5"]; 
$billaddress4_5 = $_POST["billaddress4_5"]; 
$province5 = $_POST["province5"]; 
$postcode5 = $_POST["postcode5"]; 
} 
 
$track = $_POST["fedex"]; 
$tracktype = ""; 
 
if($track == "tracking") 
{ 
$trackno = $_POST["areaCode"]."-".$_POST["firstNum"]."-".$_POST["secNum"]; 
$tracktype = "T"; 
}else{ 
$trackno = "Fedex Matching"; 
$tracktype = "M"; 
} 
 
if(isset($_POST['cash']) && $_POST['cash'] == 'cash') 
{ 
    $cash = "เงินสด ลด 2 %"; 
}else{ 
    $cash = "-"; 
} 
 
$Comments = $_POST["Comments"];  
 
  if(isset($_POST['Submit']) and $rec_name == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please fill out your recipient\'s name.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $rec_room == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please fill out your recipient\'s room.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $rec_building == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please fill out your recipient\'s building.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $rec_address == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please fill out your recipient\'s address.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $rec_phone == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please fill out your recipient\'s phone.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $billaddress1_1 == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please fill out your bill address.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $province1 == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please select your province.');  
   window.location = \"web_mform3_2.php\";  
   </script>"; 
  }elseif(isset($_POST['Submit']) and $postcode1 == ''){ 
   echo "<script language=\"javascript\" type=\"text/javascript\">  
   alert('Please select your postcode.');  
   window.location = \"web_mform3_2.php\"; 
   </script>"; 
  }else{//start  
          
        $email_to=""; 
		$email_subject=""; 
		$blacklist=false; 
		$email_subject=""; 
		$sale_num=0; 
   
          //Check black list 
       
		//Blacklist of roongrut 
		if(($rec_name=="อ.ดรศร%") | ($rec_address=="องค์การสวนสัตว์%") | ($rec_name=="วินธัย%") | ($rec_address=="โครงการพัฒนาพันธ์ข้าว%")|($rec_address=="ศูนย์วิทยาการสุขภาพเป็ด%")) 
		{ 
		    $email_subject = "This customer is BLACK_LIST!!! , "; 
            $email_to="[email protected] , "; 
			$blacklist=true; 
		} 
 
        //Blacklist of yaowaluk. 
        if(($rec_address=="คณะเทคโนโลยีชีวภาพ  ม.ขอนแก่น%"))   
		{ 
                $email_to="[email protected] , "; 
				$email_subject = "This customer is BLACK_LIST!!! , "; 
				$blacklist=true; 
		} 
 
        //Blacklist of chayalai. 
	    if(($rec_address=="สวนสัตว์เชียงใหม่%") | ($rec_address=="การปรับปรุงสายพันธ์แบคทีเรีย%")|($rec_address=="ม.เชียงใหม่%")|($rec_name=="กฤษฎา%")|($rec_name=="ดร.สุทธิชัย%")|($rec_name=="ดร.จินตนา%")) 
		{ 
                $email_to="[email protected] , "; 
				$email_subject = "This customer is BLACK_LIST!!! , "; 
				$blacklist=true; 
		} 
        
		//Blacklist of nittaya. 
		if(($rec_address=="ชีวเคมี  คณะวิทยาศาสตร์  ม.มหิดล%")|($rec_name=="นพ.จามร%")|($rec_address=="แพทยศาสตร์  มศว.%")| ( $rec_name=="จิตราภรณ์%")| ($rec_name=="เกรียรติพงษ์ %" ) | ( $rec_name=="อ.พิมพิณ%" ) | ($rec_address=="สัตว์แพทย์ศาสตร์ ม.มหิดล%") | ($rec_address=="ม.มหิดล%" ) | ($rec_name=="วรัญญา%") ) 
		{ 
                $email_to="[email protected] , "; 
				$email_subject = "This customer is BLACK_LIST!!! , "; 
				$blacklist=true; 
		} 
         
         
   //start send mail 
	  $myFile1 = $_FILES['txt_file1']; // This will make an array out of the file information that was stored. 
      $file1 = $myFile1['tmp_name'];  //Converts the array into a new string containing the path name on the server where your file is. 
      $myFileName1 = basename($_FILES['txt_file1']['name']); //Retrieve filename out of file path 
      $destination_file1 = "./" .$myFileName1 ;	   
 
      //echo $myFile1."1".$file1."-2-".$myFileName1."-3-".$destination_file1; 
 
      if($myFileName1 == ''){ 
	   echo "<script language=\"javascript\" type=\"text/javascript\">  
       alert('Please enter your attached file.');  
       window.location = \"web_mform3.php\";  
       </script>"; 
	  } 
 
	  $myFile2 = $_FILES['txt_file2']; // This will make an array out of the file information that was stored. 
      $file2 = $myFile2['tmp_name'];  //Converts the array into a new string containing the path name on the server where your file is. 
      $myFileName2 = basename($_FILES['txt_file2']['name']); //Retrieve filename out of file path 
      $destination_file2 = "./" .$myFileName2 ;	   
 
	  //echo $myFile2."1".$file2."-2-".$myFileName2."-3-".$destination_file2; 
 
	  $myFile3 = $_FILES['txt_file3']; // This will make an array out of the file information that was stored. 
      $file3 = $myFile3['tmp_name'];  //Converts the array into a new string containing the path name on the server where your file is. 
      $myFileName3 = basename($_FILES['txt_file3']['name']); //Retrieve filename out of file path 
      $destination_file3 = "./" .$myFileName3 ;	   
 
   //write data 
		$dbhost = 'mysql-5.5.chaiyohosting.com'; 
		$dbuser = 'admindb'; 
		$dbpass = 'ward1234'; 
		$db = 'warddb'; 
        
	    //'".$_SESSION['login_name']."'    :: [email protected] 
         
 
		$sql="INSERT INTO web_morder (login_name,rec_name,rec_room,rec_floor,rec_building,rec_address,rec_phone,rec_fax,billaddress1_1,billaddress2_1,billaddress3_1,billaddress4_1,province1,postcode1,tracktype,trackingno,cash,comments,create_date,billaddress1_2,billaddress2_2,billaddress3_2,billaddress4_2,province2,postcode2,billaddress1_3,billaddress2_3,billaddress3_3,billaddress4_3,province3,postcode3,billaddress1_4,billaddress2_4,billaddress3_4,billaddress4_4,province4,postcode4,billaddress1_5,billaddress2_5,billaddress3_5,billaddress4_5,province5,postcode5) VALUES 
		('".$_SESSION['login_name']."','".$rec_name."','".$rec_room."','".$rec_floor."','".$rec_building."','".$rec_address."','".$rec_phone."','".$rec_fax."','".$billaddress1_1."','".$billaddress2_1."','".$billaddress3_1."','".$billaddress4_1."','".$province1."','".$postcode1."','".$tracktype."','".$trackno."','".$cash."','".$Comments."',SYSDATE(),'".$billaddress1_2."','".$billaddress2_2."','".$billaddress3_2."','".$billaddress4_2."','".$province2."','".$postcode2."','".$billaddress1_3."','".$billaddress2_3."','".$billaddress3_3."','".$billaddress4_3."','".$province3."','".$postcode3."','".$billaddress1_4."','".$billaddress2_4."','".$billaddress3_4."','".$billaddress4_4."','".$province4."','".$postcode4."','".$billaddress1_5."','".$billaddress2_5."','".$billaddress3_5."','".$billaddress4_5."','".$province5."','".$postcode5."')"; 
		 
 
		//echo $sql; 
 
        $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $db); 
 
		if(! $conn ) 
		{ 
			die('Could not connect: ' . mysqli_connect_error()); 
		} 
 
		if (!mysqli_query($conn,$sql)) 
		{ 
			die('Error: ' . mysqli_error($conn)); 
		} 
 
		mysqli_close($conn);	   
        //end write data  
        
        #"/developers/uploadftp/aditya/".$myFileName;  //where you want to throw the file on the webserver (relative to your login dir) 
      // connection settings 
      $ftp_server = "f";  //address of ftp server. 
      $ftp_user_name = ""; // Username 
      $ftp_user_pass = "";   // Password 
      $conn_id = ftp_connect($ftp_server) or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftp_server</h2></span>");        // set up basic connection 
      #print_r($conn_id); 
      $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<span style='color:#FF0000'><h2>You do not have access to this ftp server!</h2></span>");   // login with username and password, or give invalid user message 
 
      if ((!$conn_id) || (!$login_result)) {  // check connection 
             // wont ever hit this, b/c of the die call on ftp_login 
             echo "<span style='color:#FF0000'><h2>FTP connection has failed! <br />"; 
             echo "Attempted to connect to $ftp_server for user $ftp_user_name</h2></span>"; 
             exit; 
         } else { 
         //    echo "Connected to $ftp_server, for user $ftp_user_name <br />"; 
      } 
      $upload = ftp_put($conn_id, $destination_file1, $file1, FTP_BINARY);  // upload the file(1) 
      if (!$upload) {  // check upload status 
         echo "<span style='color:#FF0000'><h2>FTP upload of $myFileName1 has failed!</h2></span> <br />"; 
      } else { 
         echo "<span style='color:#339900'><h2>Uploading $myFileName1 Completed Successfully!</h2></span><br /><br />"; 
      } 
 
	   if($myFileName2 != ''){//if file2 
	  $upload = ftp_put($conn_id, $destination_file2, $file2, FTP_BINARY);  // upload the file(2) 
      if (!$upload) {  // check upload status 
         echo "<span style='color:#FF0000'><h2>FTP upload of $myFileName2 has failed!</h2></span> <br />"; 
      } else { 
         echo "<span style='color:#339900'><h2>Uploading $myFileName2 Completed Successfully!</h2></span><br /><br />"; 
      } 
      }//end if file2 
 
	   if($myFileName3 != ''){//if file3 
      $upload = ftp_put($conn_id, $destination_file3, $file3, FTP_BINARY);  // upload the file(3) 
      if (!$upload) {  // check upload status 
         echo "<span style='color:#FF0000'><h2>FTP upload of $myFileName3 has failed!</h2></span> <br />"; 
      } else { 
         echo "<span style='color:#339900'><h2>Uploading $myFileName3 Completed Successfully!</h2></span><br /><br />"; 
      } 
      }//end if file3 
 
      ftp_close($conn_id); // close the FTP stream 
 
      $file = 'C:\Inetpub\vhosts\wardmedic.com\ward_ftp\\'.$myFileName1; 
	  $newfile = 'C:\Inetpub\vhosts\wardmedic.com\httpdocs\excel\\'.$myFileName1; 
	  if (!copy($file, $newfile)) { 
      echo "failed to copy $file...\n"; 
      }else{ 
		  	 unlink($file); 
	  } 
      
 
      if($myFileName2 != ''){//if file2 
   	  $file = 'C:\Inetpub\vhosts\wardmedic.com\ward_ftp\\'.$myFileName2; 
	  $newfile = 'C:\Inetpub\vhosts\wardmedic.com\httpdocs\excel\\'.$myFileName2; 
	  if (!copy($file, $newfile)) { 
      echo "failed to copy $file...\n"; 
      }else{ 
		  	 unlink($file); 
	  } 
      }//end if file2 
 
	  if($myFileName3 != ''){//if file3 
   	  $file = 'C:\Inetpub\vhosts\wardmedic.com\ward_ftp\\'.$myFileName3; 
	  $newfile = 'C:\Inetpub\vhosts\wardmedic.com\httpdocs\excel\\'.$myFileName3; 
	  if (!copy($file, $newfile)) { 
      echo "failed to copy $file...\n"; 
      }else{ 
		  	 unlink($file); 
	  } 
      }//end if file3 
 
    $billNO=1; 
       //write Requisit 
	   //first bill. 
	error_reporting(E_ALL); 
	date_default_timezone_set('Asia/Bangkok'); 
	$date = date('Y-m-d_i'); 
    $newfile = 'requisit_1_'.$date.'billNO'.$billNO.'.xlsx'; 
	require_once './Classes/PHPExcel/IOFactory.php'; 
	require_once './Classes/PHPExcel.php'; 
	$excel2 = PHPExcel_IOFactory::createReader('Excel2007'); 
	$excel2 = $excel2->load('requisit.xlsx'); // Empty Sheet 
 
     
	$excel2->setActiveSheetIndex(0); 
	$rec_name = "คุณ ".$rec_name; 
    $rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
	$rec_phone = "เบอร์โทร : ".$rec_phone; 
 
	$excel2->getActiveSheet()->setCellValue('A4', $rec_name) 
    ->setCellValue('A5', $rec_address) 
    ->setCellValue('A6', $rec_phone); 
 
    $billaddress1_1 = "ชื่อใบเสนอ/หัวบิล : ".$billaddress1_1; 
	$billaddress4_1 = $billaddress4_1."  ".$province1."  ".$postcode1; 
	$rec_fax = "FAX : ".$rec_fax; 	 
	$excel2->getActiveSheet()->setCellValue('A10', $billaddress1_1) 
    ->setCellValue('A11', $billaddress2_1) 
    ->setCellValue('A12', $billaddress3_1) 
    ->setCellValue('A13', $billaddress4_1); 
 
	$excel2->getActiveSheet()->setCellValue('A18', $rec_fax) 
    ->setCellValue('A45', $rec_fax) 
	->setCellValue('G11', $cash) 
	->setCellValue('G38', $cash); 
 
	$excel2->getActiveSheet()->setCellValue('A37', $billaddress1_1) 
    ->setCellValue('A38', $billaddress2_1) 
    ->setCellValue('A39', $billaddress3_1) 
    ->setCellValue('A40', $billaddress4_1); 
 
	$objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel2007'); 
	$objWriter->save($newfile); 
    $count_file=1; 
    //Create zip file 
 
	if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
	$files_to_zip = array( 
	$newfile, $myFileName1, $myFileName2, $myFileName3 
	); 
    }//end 1,2,3  
 
	if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
	$files_to_zip = array( 
	$newfile, $myFileName1, $myFileName3 
	); 
    }//end 1,3  
 
	if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
	$files_to_zip = array( 
	$newfile, $myFileName1, $myFileName2 
	); 
    }//end 1,2 
 
	if($myFileName2 == '' and $myFileName3 == ''){//if 1 
	$files_to_zip = array( 
	$newfile, $myFileName1 
	); 
    }//end 1 
 
     
	//if true, good; if false, zip creation failed 
	$zipfile = 'requisit_1_'.$date.'billNO'.$billNO.'.zip'; 
	$billNO=$billNO+1;  
	$zip1=$zipfile; 
	$result = create_zip($files_to_zip,$zipfile); 
	 
	//send mail first bill. : [email protected] , [email protected] , [email protected] , [email protected] 
	if(!$blacklist) 
      $email_to =$email_to."[email protected] , [email protected] , [email protected] , [email protected] , [email protected]  "; // The email you are sending to (example) 
    else 
	  $email_to =$email_to."[email protected] "; 
	$email_from = $_SESSION['login_name']; // The email you are sending from (example) 
	if($blacklist) 
	  $email_subject = "This is BlackList customer !!! , "; 
	$email_subject = $email_subject." Sequencing Order in the attached file"; // The Subject of the email 
	$email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
    $email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
	$email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
	$fileatt = $zipfile; // Path to the file (example) 
	$fileatt_type = "application/zip"; // File Type 
	$fileatt_name = $zipfile; // Filename that will be used for the file as the attachment 
 
	$file = fopen($fileatt,'rb'); 
	$data = fread($file,filesize($fileatt)); 
	fclose($file); 
	$semi_rand = md5(time()); 
	$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
	$headers="From: $email_from"; // Who the email is from (example) 
	$headers .= "\nMIME-Version: 1.0\n" . 
	"Content-Type: multipart/mixed;\n" . 
	" boundary=\"{$mime_boundary}\""; 
	$email_message = "This is a multi-part message in MIME format.\n\n" . 
	"--{$mime_boundary}\n" . 
	"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
	"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
	$email_message .= "\n\n"; 
	$data = chunk_split(base64_encode($data)); 
	$email_message .= "--{$mime_boundary}\n" . 
	"Content-Type: {$fileatt_type};\n" . 
	" name=\"{$fileatt_name}\"\n" . 
	"Content-Transfer-Encoding: base64\n\n" . 
	$data . "\n\n" . 
	"--{$mime_boundary}--\n"; 
	$flgSend = @mail($email_to,$email_subject,$email_message,$headers); 
	if($flgSend)   
	{  //if send 
	echo "Email send completed.";   
 
    //Delete files 
	if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
     unlink($newfile); 
     unlink($myFileName1); 
	 unlink($myFileName2); 
     unlink($myFileName3); 
    }//end 1,2,3  
 
	if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
	 unlink($newfile); 
     unlink($myFileName1); 
     unlink($myFileName3); 
    }//end 1,3  
 
	if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
     unlink($newfile); 
     unlink($myFileName1); 
	 unlink($myFileName2); 
    }//end 1,2 
 
	if($myFileName2 == '' and $myFileName3 == ''){//if 1 
     unlink($newfile); 
     unlink($myFileName1); 
    }//end 1 
	unlink($zipfile); 
	}  //end if send 
	else   
	{   
	echo "Cannot send mail.";   
	} //end att. 
    $check=1; 
 
 
    //second bill. 
    if($billaddress1_2!="") 
	{ 
        error_reporting(E_ALL); 
		date_default_timezone_set('Asia/Bangkok'); 
		$date = date('Y-m-d_i'); 
		$newfile = 'requisit_1_'.$date.'billNO'.$billNO.'.xlsx'; 
		require_once './Classes/PHPExcel/IOFactory.php'; 
		require_once './Classes/PHPExcel.php'; 
		$excel3 = PHPExcel_IOFactory::createReader('Excel2007'); 
		$excel3 = $excel3->load('requisit.xlsx'); // Empty Sheet 
 
		 
		$excel3->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
         
        $excel3->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
 
		$excel3->getActiveSheet()->setCellValue('A4', $rec_name) 
		->setCellValue('A5', $rec_address) 
		->setCellValue('A6', $rec_phone); 
 
		$billaddress1_2 = "ชื่อใบเสนอ/หัวบิล : ".$billadress1_2; 
		$billaddress4_2 = $billaddress4_2."  ".$province2."  ".$postcode2; 
		$rec_fax = "FAX : ".$rec_fax; 	 
		$excel3->getActiveSheet()->setCellValue('A10', $billaddress1_2) 
		->setCellValue('A11', $billaddress2_2) 
		->setCellValue('A12', $billaddress3_2) 
		->setCellValue('A13', $billaddress4_2); 
 
		$excel3->getActiveSheet()->setCellValue('A18', $rec_fax) 
		->setCellValue('A45', $rec_fax) 
		->setCellValue('G11', $cash) 
		->setCellValue('G38', $cash); 
 
		$excel3->getActiveSheet()->setCellValue('A37', $billaddress1_2) 
		->setCellValue('A38', $billaddress2_2) 
		->setCellValue('A39', $billaddress3_2) 
		->setCellValue('A40', $billaddress4_2); 
 
		$objWriter = PHPExcel_IOFactory::createWriter($excel3, 'Excel2007'); 
		$objWriter->save($newfile); 
        $count_file=2; 
 
        //Create zip file 
 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2, $myFileName3 
		); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName3 
		); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2 
		); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		$files_to_zip = array( 
		$newfile, $myFileName1 
		); 
		}//end 1 
 
		//if true, good; if false, zip creation failed 
       
		$zipfile = 'requisit_1_'.$date.'billNO'.$billNO.'.zip'; 
	    $billNO=$billNO+1;  
		$zip2=$zipfile; 
		$result = create_zip($files_to_zip,$zipfile); 
		 
	 
		//send mail second bill. 
		$email_to =$email_to."[email protected] "; // The email you are sending to (example) 
	    $email_from = $_SESSION['login_name']; // The email you are sending from (example) 
	    if($blacklist) 
	       $email_subject = "This is BlackList customer , "; 
	    $email_subject = $email_subject." Sequencing Order in the attached file"; // The Subject of the email 
		 
		$email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
		$email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
		$email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
		$fileatt = $zipfile; // Path to the file (example) 
		$fileatt_type = "application/zip"; // File Type 
		$fileatt_name = $zipfile; // Filename that will be used for the file as the attachment 
 
		$file = fopen($fileatt,'rb'); 
		$data = fread($file,filesize($fileatt)); 
		fclose($file); 
		$semi_rand = md5(time()); 
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
		$headers="From: $email_from"; // Who the email is from (example) 
		$headers .= "\nMIME-Version: 1.0\n" . 
		"Content-Type: multipart/mixed;\n" . 
		" boundary=\"{$mime_boundary}\""; 
		$email_message = "This is a multi-part message in MIME format.\n\n" . 
		"--{$mime_boundary}\n" . 
		"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
		"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
		$email_message .= "\n\n"; 
		$data = chunk_split(base64_encode($data)); 
		$email_message .= "--{$mime_boundary}\n" . 
		"Content-Type: {$fileatt_type};\n" . 
		" name=\"{$fileatt_name}\"\n" . 
		"Content-Transfer-Encoding: base64\n\n" . 
		$data . "\n\n" . 
		"--{$mime_boundary}--\n"; 
		$flgSend = @mail($email_to,$email_subject,$email_message,$headers); 
		if($flgSend)   
		{  //if send 
		echo "Email send completed.";   
 
		//Delete files 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		 unlink($myFileName3); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName3); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		 unlink($newfile); 
		 unlink($myFileName1); 
		}//end 1 
		unlink($zipfile); 
		}  //end if send 
		else   
		{   
		echo "Cannot send mail.";   
		} //end att. 
	} 
 
    //Third bill. 
    if($billaddress1_3!="") 
	{ 
        error_reporting(E_ALL); 
		date_default_timezone_set('Asia/Bangkok'); 
		$date = date('Y-m-d_i'); 
		$newfile = 'requisit_1_'.$date.'billNO'.$billNO.'.xlsx'; 
		require_once './Classes/PHPExcel/IOFactory.php'; 
		require_once './Classes/PHPExcel.php'; 
		$excel4 = PHPExcel_IOFactory::createReader('Excel2007'); 
		$excel4 = $excel4->load('requisit.xlsx'); // Empty Sheet 
 
		 
		$excel4->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
         
        $excel4->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
 
		$excel4->getActiveSheet()->setCellValue('A4', $rec_name) 
		->setCellValue('A5', $rec_address) 
		->setCellValue('A6', $rec_phone); 
 
		$billaddress1_3 = "ชื่อใบเสนอ/หัวบิล : ".$billadress1_3; 
		$billaddress4_3 = $billaddress4_3."  ".$province3."  ".$postcode3; 
		$rec_fax = "FAX : ".$rec_fax; 	 
		$excel4->getActiveSheet()->setCellValue('A10', $billaddress1_3) 
		->setCellValue('A11', $billaddress2_3) 
		->setCellValue('A12', $billaddress3_3) 
		->setCellValue('A13', $billaddress4_3); 
 
		$excel4->getActiveSheet()->setCellValue('A18', $rec_fax) 
		->setCellValue('A45', $rec_fax) 
		->setCellValue('G11', $cash) 
		->setCellValue('G38', $cash); 
 
		$excel4->getActiveSheet()->setCellValue('A37', $billaddress1_3) 
		->setCellValue('A38', $billaddress2_3) 
		->setCellValue('A39', $billaddress3_3) 
		->setCellValue('A40', $billaddress4_3); 
 
		$objWriter = PHPExcel_IOFactory::createWriter($excel4, 'Excel2007'); 
		$objWriter->save($newfile); 
        $count_file=3; 
 
        //Create zip file 
 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2, $myFileName3 
		); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName3 
		); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2 
		); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		$files_to_zip = array( 
		$newfile, $myFileName1 
		); 
		}//end 1 
 
		//if true, good; if false, zip creation failed 
		$zipfile = 'requisit_1_'.$date.'billNO'.$billNO.'.zip'; 
		$billNO=$billNO+1; 
		$zip3=$zipfile; 
		$result = create_zip($files_to_zip,$zipfile); 
 
		//send mail third bill. 
		$email_to =$email_to."[email protected] "; // The email you are sending to (example) 
	    $email_from = $_SESSION['login_name']; // The email you are sending from (example) 
	    if($blacklist) 
	       $email_subject = "This is BlackList customer , "; 
	    $email_subject = $email_subject." Sequencing Order in the attached file"; // The Subject of the email 
		$email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
		$email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
		$email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
		$fileatt = $zipfile; // Path to the file (example) 
		$fileatt_type = "application/zip"; // File Type 
		$fileatt_name = $zipfile; // Filename that will be used for the file as the attachment 
 
		$file = fopen($fileatt,'rb'); 
		$data = fread($file,filesize($fileatt)); 
		fclose($file); 
		$semi_rand = md5(time()); 
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
		$headers="From: $email_from"; // Who the email is from (example) 
		$headers .= "\nMIME-Version: 1.0\n" . 
		"Content-Type: multipart/mixed;\n" . 
		" boundary=\"{$mime_boundary}\""; 
		$email_message = "This is a multi-part message in MIME format.\n\n" . 
		"--{$mime_boundary}\n" . 
		"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
		"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
		$email_message .= "\n\n"; 
		$data = chunk_split(base64_encode($data)); 
		$email_message .= "--{$mime_boundary}\n" . 
		"Content-Type: {$fileatt_type};\n" . 
		" name=\"{$fileatt_name}\"\n" . 
		"Content-Transfer-Encoding: base64\n\n" . 
		$data . "\n\n" . 
		"--{$mime_boundary}--\n"; 
		$flgSend = @mail($email_to,$email_subject,$email_message,$headers); 
		if($flgSend)   
		{  //if send 
		echo "Email send completed.";   
 
		//Delete files 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		 unlink($myFileName3); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName3); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		 unlink($newfile); 
		 unlink($myFileName1); 
		}//end 1 
		unlink($zipfile); 
		}  //end if send 
		else   
		{   
		echo "Cannot send mail.";   
		} //end att. 
 
	} 
     
    //Fourth bill. 
    if($billaddress1_4!="") 
	{ 
        error_reporting(E_ALL); 
		date_default_timezone_set('Asia/Bangkok'); 
		$date = date('Y-m-d_i'); 
		$newfile = 'requisit_1_'.$date.'billNO'.$billNO.'.xlsx'; 
		require_once './Classes/PHPExcel/IOFactory.php'; 
		require_once './Classes/PHPExcel.php'; 
		$excel5 = PHPExcel_IOFactory::createReader('Excel2007'); 
		$excel5 = $excel5->load('requisit.xlsx'); // Empty Sheet 
 
		 
		$excel5->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
         
        $excel5->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
 
		$excel5->getActiveSheet()->setCellValue('A4', $rec_name) 
		->setCellValue('A5', $rec_address) 
		->setCellValue('A6', $rec_phone); 
 
		$billaddress1_4 = "ชื่อใบเสนอ/หัวบิล : ".$billadress1_4; 
		$billaddress4_4 = $billaddress4_4."  ".$province4."  ".$postcode4; 
		$rec_fax = "FAX : ".$rec_fax; 	 
		$excel5->getActiveSheet()->setCellValue('A10', $billaddress1_4) 
		->setCellValue('A11', $billaddress2_4) 
		->setCellValue('A12', $billaddress3_4) 
		->setCellValue('A13', $billaddress4_4); 
 
		$excel5->getActiveSheet()->setCellValue('A18', $rec_fax) 
		->setCellValue('A45', $rec_fax) 
		->setCellValue('G11', $cash) 
		->setCellValue('G38', $cash); 
 
		$excel5->getActiveSheet()->setCellValue('A37', $billaddress1_3) 
		->setCellValue('A38', $billaddress2_4) 
		->setCellValue('A39', $billaddress3_4) 
		->setCellValue('A40', $billaddress4_4); 
 
		$objWriter = PHPExcel_IOFactory::createWriter($excel5, 'Excel2007'); 
		$objWriter->save($newfile); 
        $count_file=4; 
 
        //Create zip file 
 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2, $myFileName3 
		); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName3 
		); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2 
		); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		$files_to_zip = array( 
		$newfile, $myFileName1 
		); 
		}//end 1 
 
		//if true, good; if false, zip creation failed 
		$zipfile = 'requisit_1_'.$date.'billNO'.$billNO.'.zip'; 
		$billNO=$billNO+1; 
        $zip4=$zipfile; 
		$result = create_zip($files_to_zip,$zipfile); 
		//send mail 
		$email_to = "[email protected] "; // The email you are sending to (example) 
		$email_from = $_SESSION['login_name']; // The email you are sending from (example) 
		$email_subject = "Sequencing Order in the attached file"; // The Subject of the email 
		$email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
		$email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
		$email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
		$fileatt = $zipfile; // Path to the file (example) 
		$fileatt_type = "application/zip"; // File Type 
		$fileatt_name = $zipfile; // Filename that will be used for the file as the attachment 
 
		$file = fopen($fileatt,'rb'); 
		$data = fread($file,filesize($fileatt)); 
		fclose($file); 
		$semi_rand = md5(time()); 
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
		$headers="From: $email_from"; // Who the email is from (example) 
		$headers .= "\nMIME-Version: 1.0\n" . 
		"Content-Type: multipart/mixed;\n" . 
		" boundary=\"{$mime_boundary}\""; 
		$email_message = "This is a multi-part message in MIME format.\n\n" . 
		"--{$mime_boundary}\n" . 
		"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
		"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
		$email_message .= "\n\n"; 
		$data = chunk_split(base64_encode($data)); 
		$email_message .= "--{$mime_boundary}\n" . 
		"Content-Type: {$fileatt_type};\n" . 
		" name=\"{$fileatt_name}\"\n" . 
		"Content-Transfer-Encoding: base64\n\n" . 
		$data . "\n\n" . 
		"--{$mime_boundary}--\n"; 
		$flgSend = @mail($email_to,$email_subject,$email_message,$headers); 
		if($flgSend)   
		{  //if send 
		echo "Email send completed.";   
 
		//Delete files 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		 unlink($myFileName3); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName3); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		 unlink($newfile); 
		 unlink($myFileName1); 
		}//end 1 
		unlink($zipfile); 
		}  //end if send 
		else   
		{   
		echo "Cannot send mail.";   
		} //end att. 
 
	}//End fourth bill. 
 
    //Fifth bill. 
    if($billaddress1_5!="") 
	{ 
        error_reporting(E_ALL); 
		date_default_timezone_set('Asia/Bangkok'); 
		$date = date('Y-m-d_i'); 
		$newfile = 'requisit_1_'.$date.'billNO'.$billNO.'.xlsx'; 
		require_once './Classes/PHPExcel/IOFactory.php'; 
		require_once './Classes/PHPExcel.php'; 
		$excel6 = PHPExcel_IOFactory::createReader('Excel2007'); 
		$excel6 = $excel6->load('requisit.xlsx'); // Empty Sheet 
 
		 
		$excel6->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
         
        $excel6->setActiveSheetIndex(0); 
		$rec_name = "คุณ ".$rec_name; 
		$rec_address = "สถานที่ : ".$rec_room." ".$rec_building." ".$rec_floor." ".$rec_address; 
		$rec_phone = "เบอร์โทร : ".$rec_phone; 
 
		$excel6->getActiveSheet()->setCellValue('A4', $rec_name) 
		->setCellValue('A5', $rec_address) 
		->setCellValue('A6', $rec_phone); 
 
		$billaddress1_5 = "ชื่อใบเสนอ/หัวบิล : ".$billadress1_5; 
		$billaddress4_5 = $billaddress4_5."  ".$province5."  ".$postcode5; 
		$rec_fax = "FAX : ".$rec_fax; 	 
		$excel6->getActiveSheet()->setCellValue('A10', $billaddress1_5) 
		->setCellValue('A11', $billaddress2_5) 
		->setCellValue('A12', $billaddress3_5) 
		->setCellValue('A13', $billaddress4_5); 
 
		$excel6->getActiveSheet()->setCellValue('A18', $rec_fax) 
		->setCellValue('A45', $rec_fax) 
		->setCellValue('G11', $cash) 
		->setCellValue('G38', $cash); 
 
		$excel6->getActiveSheet()->setCellValue('A37', $billaddress1_5) 
		->setCellValue('A38', $billaddress2_5) 
		->setCellValue('A39', $billaddress3_5) 
		->setCellValue('A40', $billaddress4_5); 
 
		$objWriter = PHPExcel_IOFactory::createWriter($excel6, 'Excel2007'); 
		$objWriter->save($newfile); 
		$count_file=5; 
 
        //Create zip file 
 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2, $myFileName3 
		); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName3 
		); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		$files_to_zip = array( 
		$newfile, $myFileName1, $myFileName2 
		); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		$files_to_zip = array( 
		$newfile, $myFileName1 
		); 
		}//end 1 
 
		//if true, good; if false, zip creation failed 
		$zipfile = 'requisit_1_'.$date.'billNO'.$billNO.'.zip'; 
		$billNO=$billNO+1; 
		$zip5=$zipfile; 
		$result = create_zip($files_to_zip,$zipfile); 
        $email_to=""; 
		$email_subject=""; 
		$blacklist=false; 
		 
 
		//send mail 
		$email_to =$email_to."[email protected] "; // The email you are sending to (example) 
		$email_from = $_SESSION['login_name']; // The email you are sending from (example) 
		//echo"<br> '".$blacklist."'"; 
		if($blacklist==true) 
			$email_subject="Black List mail!!! , "; 
		$email_subject =$email_subject."Sequencing Order in the attached file"; // The Subject of the email 
		$email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
		if($blacklist==true) 
			$email_txt=$email_txt."Black List mail!!! , "; 
		$email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
		$email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
		$fileatt = $zipfile; // Path to the file (example) 
		$fileatt_type = "application/zip"; // File Type 
		$fileatt_name = $zipfile; // Filename that will be used for the file as the attachment 
 
		$file = fopen($fileatt,'rb'); 
		$data = fread($file,filesize($fileatt)); 
		fclose($file); 
		$semi_rand = md5(time()); 
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
 
		$headers="From: $email_from"; // Who the email is from (example) 
		$headers .= "\nMIME-Version: 1.0\n" . 
		"Content-Type: multipart/mixed;\n" . 
		" boundary=\"{$mime_boundary}\""; 
 
		$email_message = "This is a multi-part message in MIME format.\n\n" . 
		"--{$mime_boundary}\n" . 
		"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
		"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
		$email_message .= "\n\n"; 
		$data = chunk_split(base64_encode($data)); 
		$email_message .= "--{$mime_boundary}\n" . 
		"Content-Type: {$fileatt_type};\n" . 
		" name=\"{$fileatt_name}\"\n" . 
		"Content-Transfer-Encoding: base64\n\n" . 
		$data . "\n\n" . 
		"--{$mime_boundary}--\n"; 
		$flgSend = @mail($email_to,$email_subject,$email_message,$headers); 
		if($flgSend)   
		{  //if send 
		echo "Email send completed.";   
 
		//Delete files 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		 unlink($myFileName3); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName3); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		 unlink($newfile); 
		 unlink($myFileName1); 
		}//end 1 
		unlink($zipfile); 
		}  //end if send 
		else   
		{   
		echo "Cannot send mail.";   
		} //end att. 
         
	   
 
 
 
 
	} //End fifth bill. 
     
	 
    	//------------------------------Test Attract all bills in one time email. 
		 
          /* 
		  $email_to = "[email protected] "; // The email you are sending to (example) 
		  $email_from = $_SESSION['login_name']; // The email you are sending from (example) 
		  $email_subject = "Test multi attracted file"; // The Subject of the email 
		  $email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
		  $email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
		  $email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
          $fileatt_type = "application/zip"; // File Type 
 
          if($count_file>1) 
	      {  
            if($count_file==2) 
               $files = array('$zip1','$zip2'); 
			else 
			{ 
               if($count_file==3) 
                  $files = array('$zip1','$zip2','$zip3'); 
               else 
			   { 
                  if($count_file==4) 
                     $files = array('$zip1','$zip2','$zip3','$zip4'); 
                  else 
					 $files = array('$zip1','$zip2','$zip3','$zip4','$zip5');  
			   }  
 
			}  
			 
            for($i=0;$i<count($files);$i++) 
			  { 
                    $file = fopen($files[$i],"rb"); 
					$data = fread($file,filesize($files[$i])); 
					fclose($file); 
					$data = chunk_split(base64_encode($data)); 
					$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$i]\"\n" . 
					"Content-Disposition: attachment;\n" . " filename=\"$files[$i]\"\n" . 
					"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; 
					$message .= "--{$mime_boundary}\n"; 
			  } 
                $headers="From: $email_from"; // Who the email is from (example) 
				$headers .= "\nMIME-Version: 1.0\n" . 
				"Content-Type: multipart/mixed;\n" . 
				" boundary=\"{$mime_boundary}\""; 
				$email_message = "This is a multi-part message in MIME format.\n\n" . 
				"--{$mime_boundary}\n" . 
				"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
				"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
				$email_message .= "\n\n"; 
				$data = chunk_split(base64_encode($data)); 
				$email_message .= "--{$mime_boundary}\n" . 
 
				"Content-Type: {$fileatt_type};\n" . 
				" name=\"{$fileatt_name}\"\n" . 
				"Content-Transfer-Encoding: base64\n\n" . 
				  
				$data . "\n\n" . 
				"--{$mime_boundary}--\n"; 
			    $ok = @mail($email_to, $email_subject, $message, $headers); 
				if ($ok) { 
					echo "<br>Mail sent multi files attracted already.</br>"; 
				} else { 
					echo "<br>Mail could not be sent multi files attracted.!</br>"; 
				} 
 
	      } 
 
         
        //send mail 
		$email_to = "[email protected] "; // The email you are sending to (example) 
		$email_from = $_SESSION['login_name']; // The email you are sending from (example) 
		$email_subject = "Multiple bills for a customer in one email , Sequencing Order in the attached file"; // The Subject of the email 
		$email_txt = "There is a new sequencing order from ".$_SESSION['login_name']." (Please find the attached file for new Sequencing Order.)  "; 
		$email_txt = $email_txt." Tracking Type : ".$trackno."  "; 
		$email_txt = $email_txt." Comments : ".$Comments."  "; // Message that the email has in it 
		 
        $fileatt = $zip1; // Path to the file (example) 
		$fileatt_type = "application/zip"; // File Type 
	 	$fileatt_name = $zip1; // Filename that will be used for the file as the attachment 
        $file = fopen($fileatt,'rb'); 
		$data = fread($file,filesize($fileatt)); 
		fclose($file);  
         
		$semi_rand = md5(time()); 
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
		$headers="From: $email_from"; // Who the email is from (example) 
		$headers .= "\nMIME-Version: 1.0\n" . 
		"Content-Type: multipart/mixed;\n" . 
		" boundary=\"{$mime_boundary}\""; 
		$email_message = "This is a multi-part message in MIME format.\n\n" . 
		"--{$mime_boundary}\n" . 
		"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
		"Content-Transfer-Encoding: 7bit\n\n" . $email_txt; 
		$email_message .= "\n\n"; 
		$data = chunk_split(base64_encode($data)); 
		$email_message .= "--{$mime_boundary}\n" . 
		"Content-Type: {$fileatt_type};\n" . 
		" name=\"{$fileatt_name}\"\n" . 
		"Content-Transfer-Encoding: base64\n\n" . 
		$data . "\n\n" . 
	    "--{$mime_boundary}--\n"; 
         
		echo "<br>attract 1 already."; 
         //Delete files 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		 unlink($myFileName3); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName3); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		 unlink($newfile); 
		 unlink($myFileName1); 
		}//end 1 
		 
		$flgSend = @mail($email_to,$email_subject,$email_message,$headers); //sending email command. 
		if($flgSend)   
		{  //if send 
		echo "Email send completed.";   
        //Delete files 
		if($myFileName2 != '' and $myFileName3 != ''){//if 1,2,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		 unlink($myFileName3); 
		}//end 1,2,3  
 
		if($myFileName2 == '' and $myFileName3 != ''){//if 1,3 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName3); 
		}//end 1,3  
 
		if($myFileName2 != '' and $myFileName3 == ''){//if 1,2 
		 unlink($newfile); 
		 unlink($myFileName1); 
		 unlink($myFileName2); 
		}//end 1,2 
 
		if($myFileName2 == '' and $myFileName3 == ''){//if 1 
		 unlink($newfile); 
		 unlink($myFileName1); 
		}//end 1 
		unlink($zipfile); 
		}  //end if send 
		else   
		{   
		echo "Cannot send mail.";   
		} //end att. 
    //end multiple 
	*/ 
 
	if($check!=0) 
	  { 
         echo "<script language=\"javascript\" type=\"text/javascript\"> 
	      alert('Your order complete!. Thank you for your cooperation.'); 
	      window.location = \"web_mmenu2.php\"; 
	      </script>"; 
	  } 
	  else 
	  { 
         echo "<script language=\"javascript\" type=\"text/javascript\"> 
	      alert('Your order complete!. Thank you for your cooperation.'); 
	      window.location = \"web_mform3_2.php\"; 
	      </script>"; 
	  } 
  }//End 
?>                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2015-06-19 10:39:04 | 
                        By :
                            aun23657 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             |