Jump to content

Recommended Posts

Using fpdf I am trying to create an invoice to send to clients. The products are sold in pricing tiers.

 

I've got it working so it only displays a tier if the quantity is greater than 0 but I end up with a bunch of empty rows in between.

 

Instead of for example:

 

1 $20

2 $30

3 $40

 

I am getting

 

1 $20

 

2 $30

 

 

3 $40

 

How can I get it so the row is advanced only if something is output?

 

	for ($j=0; $j<12; $j++)
{
	$data = Array();


		if($pricearray[$j] > 0){
		$data[0]['TEXT'] = $pricearray[$j];


		$data[1]['TEXT'] = $_POST['select'];
		$data[1]['TEXT'] .= " " . $pricedescriptionarray[$j];
		$data[2]['TEXT'] = "Description";
		$data[3]['TEXT'] = "20";
		$data[4]['TEXT'] = "100";
		}


	$fsize += 0.5;

	if ($fsize > 10) $fsize = 5;

	$rgb_b -= 10;
	$rgb_g -= 5;
	$rgb_b -= 20;

	if ($rgb_b < 150) $rgb_b = 255;
	if ($rgb_g < 150) $rgb_g = 255;
	if ($rgb_b < 150) $rgb_b = 255;	

	$pdf->tbDrawData($data);
}

Link to comment
https://forums.phpfreaks.com/topic/186343-creating-an-invoice/
Share on other sites

I don't know about creating PDFs, but I'll take a wild guess here...

 

$pdf->tbDrawData($data);

 

maybe only allow this line to execute if the the pricing tier you want is met? not sure how your code works exactly, but maybe this would work:

 

   for ($j=0; $j<12; $j++)
   {
      $data = Array();
      
      
         if($pricearray[$j] > 0)
        {
           $data[0]['TEXT'] = $pricearray[$j];
         
         
           $data[1]['TEXT'] = $_POST['select'];
           $data[1]['TEXT'] .= " " . $pricedescriptionarray[$j];
           $data[2]['TEXT'] = "Description";
           $data[3]['TEXT'] = "20";
           $data[4]['TEXT'] = "100";
           $fsize += 0.5;
      
           if ($fsize > 10) $fsize = 5;
      
           $rgb_b -= 10;
           $rgb_g -= 5;
           $rgb_b -= 20;
      
           if ($rgb_b < 150) $rgb_b = 255;
           if ($rgb_g < 150) $rgb_g = 255;
           if ($rgb_b < 150) $rgb_b = 255;   

           $pdf->tbDrawData($data);
        }
   }

Link to comment
https://forums.phpfreaks.com/topic/186343-creating-an-invoice/#findComment-984149
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.