feleena Ответов: 0

Как заархивировать файл перед его загрузкой?





Я использовал флажок для извлечения всех данных из базы данных, когда я нажимаю один флажок выбранные конкретные детали загружаются как pdf, но когда я нажимаю флажок selectall ( все данные выбраны и извлечены ) загружается только один выбор, а не все выборки(pdf) загружаются

Что я уже пробовал:

<?php
require('fpdf.php');

//db connection
require("custconnect.php");

//get invoices data

/*class PDF extends FPDF 
{

	function Header(){
		$this->SetFont('Arial','B',15);
		$this->Cell(100,10,'this is header',0,1);
}	

	function Footer(){
		$this->SetFont('Arial','B',15);
		$this->Cell(100,10,'this is Footer',0,1);
}	
}*/
//A4 width : 219mm
//default margin : 10mm each side
//writable horizontal : 219-(10*2)=189mm

if(isset($_POST['check']))
{
    //$checkbox = $_POST['check'];
    $checkbox = $_POST['check'];

	for($i=0;$i<count($checkbox);$i++){
		$del_id = $checkbox[$i];
		
		$query1="SELECT * FROM `customer` WHERE id='".$del_id."'";
		$result1=mysqli_query($connec,$query1);
//$query="SELECT * FROM `customer`";
//$result=mysqli_query($connec,$query);



while($row = mysqli_fetch_assoc($result1))
{
	 $zip = new ZipArchive();
                $filename = "export_" . $row . ".zip";

                if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
                    echo "Cannot Open for writing";
                }


                $ext = $row['name'] . ".xml"; // taking file name from DB and adding extension separately
                $zip->addFromString($ext, $row['name']); //adding blob data from DB
                $zip->close();

             header("Content-disposition: inline; filename='.$filename'");
            header('Content-type: application/zip');
            readfile($filename);
            unlink($filename);
            }
        }

    // Free the mysqli resources     
        mysqli_free_result($result);
         mysqli_close($dbLink);

}



//start
{
$pdf = new FPDF('P','mm','A4');

$pdf->AddPage('P','A4');



//$pdf->Image('shop.jpg',0,0);
//$pdf->Image('shop.jpg',20,60,180,20,'JPG','www.plus2net.com');


//$pdf->SetTextColor( 123,79,443);
$pdf->SetFont( 'Arial', '', 17 );
//$pdf->Cell( 0, 15, "INVOICE", 0, 1, 'C' );
$pdf->Cell( 145, 15, "INVOICE", 0, 1,'C' );
//set font to arial, bold, 14pt






//$pdf->SetFont('Arial','B',24);

$pdf->SetFont('Arial','B',12);

//Cell(width , height , text , border , end line , [align] )

$pdf->Cell(180	,5,'InvoiceNo:',0,1);
//$pdf->Cell(59	,5,'INVOICE',0,1);//end of line
 

//set font to arial, regular, 12pt
$pdf->SetFont('Arial','',10);

$pdf->Cell(130	,5,$row['date'],0,0);
$pdf->Cell(59	,5,'',0,1);//end of line

$pdf->Cell(130	,5,'[Monday]',0,0);
//end of line



//make a dummy empty cell as a vertical spacer
$pdf->Cell(189	,10,'',0,1);//end of line

//billing address

$pdf->Cell(15	,8,' ______________________________________________________________________________________________',0,1);
$pdf->SetFont('Arial','',10);
$pdf->Cell( 180, 15, "GST", 0, 1,'C' );
//$pdf->Cell(1	,5,'GST',0,1);

$pdf->rect(140,75,68,50);
$pdf->Cell(189	,10,'',0,1);//
$pdf->Cell(130	,0,'',0,0);
$pdf->Cell(90	,5,$row['name'],0,1);
$pdf->Cell(130	,5,'',0,0);
$pdf->Cell(90	,5,$row['address'],0,1);
$pdf->Cell(130	,5,'',0,0);

$pdf->Cell(90	,5,$row['cn1'],0,1);
$pdf->rect(10,80,60,50);
//add dummy cell at beginning of each line for indentation
$pdf->Cell(14	,5,'Reymoro Ecommerce Private',0,1);
$pdf->Cell(25	,5,'Limited,',0,1);
$pdf->Cell(50	,5,'Saran Chambers, Vellayambalam, ',0,1);
$pdf->Cell(50	,5,'Trivandrum District, ',0,1);
$pdf->Cell(50	,5,'Ph- +91-9388499941, ',0,1);
$pdf->Cell(50	,5,'Kerala,GSTIN-33ALAPG6547R2ZP ',0,1);
$pdf->Cell(50	,5,'email : zshopy.shipment@gmail.com .',0,1);

$pdf->Cell(189	,10,'',0,1);//

//$pdf->stroke();


//make a dummy empty cell as a vertical spacer
$pdf->Cell(189	,10,'',0,1);//end of line
//invoice contents
$pdf->SetFont('Arial','B',12);

$pdf->Cell(34	,5,'CommedityItem',1,0);
$pdf->Cell(21	,5,'UnitPrice',1,0);
$pdf->Cell(20	,5,'Quantity',1,0);
$pdf->Cell(25	,5,'GrossValue',1,0);
$pdf->Cell(24	,5,'TaxPercent',1,0);
$pdf->Cell(29	,5,'TaxAmount',1,0);
$pdf->Cell(23	,5,'Total',1,1);


$pdf->Image('fish.jpg',150,30,19);




//end of line

$pdf->SetFont('Arial','',12);


 
$tax = 0; //total tax
$amount = 0; //total amount

//display the items; //total amount

//display the items

	$pdf->Cell(34	,5,$row['product'],1,0);
	//add thousand separator using number_format function
	$pdf->Cell(21	,5,number_format($row['price']),1,0);
	$pdf->Cell(20	,5,number_format($row['quantity']),1,0);
	$pdf->Cell(25	,5,number_format($row['GrossValue']),1,0);
	$pdf->Cell(24	,5,number_format($row['Taxpercent']),1,0);
	$pdf->Cell(29	,5,number_format($row['txamount']),1,0);
	$pdf->Cell(23	,5,number_format($row['Total']),1,1);
	
//$pdf -> Line(2500, 250, 2500, 0);
	
//$width=$pdf -> 15; // Width of Current Page
//$height=$pdf -> 12; 
//$pdf -> Line(250, 250,0,0);// Height of Current Page
//$i=0;
//for($i=0;$i<=$height;$i +=10){
//$pdf -> Line(0,0,  $pdf -> w, $i);

	//end of line
	//accumulate tax and amount
	

//summary
$pdf->SetFont('Arial','',10);
$pdf->Cell(15	,14,'
SOLD GOODS WILL NOT BE REFUNDED',0,1);
$pdf->Cell(15	,8,'I here by acknowledge that the product is received In good condition.',0,1);
$pdf->Cell(15	,8,'Customers Signature: _______________________ Receivers Sigunature: _______________________',0,1);
$pdf->Cell(15	,8,'System Generated Invoice. Signature not required.',0,1);
$pdf->Cell(15	,8,'Warranty Terms and condition:-',0,1);
$pdf->Cell(15,8,' Product once sold could not be refunded.  Product sold covers under return policies within 10 days from',0,1); $pdf->Cell(15,2,'the date of delivery. Product covers under Service Warranty as per our warranty policies',0,1);
//$pdf->Cell(15 ,8,'  Product covers under Service Warranty as per our warranty policies',0,1);
$pdf->Cell(15,8,'Return policies:- If in case the product delivered to the customer is in damage condition or have any size variation.',0,1);
$pdf->Cell(15,8,'Product should retuned back to address mentioned in the bill directly or through Courier within 10 days of delivery.',0,1);
 $pdf->Cell(15,2,'Product should returned back with all its packing/Stickers. Product should be in unused condition as like as new one.',0,1);  
$pdf->Cell(15,8,'Product should retuned back in customers own cost. Replacement delivery will be done under non chargeable Basis.',0,1);
$pdf->Cell(15,8,'Warranty policies:- Customers should visit nearest showroom/Service centre for getting serviced.',0,1);
$pdf->Cell(15,8,'Company is not responsible if we could not rectify the products after completion of warranty.',0,1);

 $pdf->Cell(15,8,'Damage due to Fire, Electricity fluctuation, Misuse or improper handling will not covered under warranty. ',0,1);
$pdf->Cell(15,8,'Defective Spare parts will be taken back even if it falls under chargeable Service.
',0,1);







//https://youtu.be/CSFQC0LVN10/video url
//https://www.plus2net.com/php_tutorial/pdf-image.phpif (substr($image, 0, 3) == 'II*'){ // TIF file
       




$pdf->Output();
	
}







?>

Bryian Tan

это может помочь : Функции PHP Zip файлов[^]

0 Ответов