php - how to create a second a4 page in codeigniter? -



writing simple invoice web tool.
invoices should in size of a4.
controller:

$this->load->view('static/print_header'); $this->load->view('static/print_invoice', $data); $this->load->view('static/print_footer'); 

$data invoice items positions like:

header

pos ---- item ---- price
1 item1 10€
2 item2 10€
3 itemitem 20€

footer

if have many items (or have text) items go inside footer section , can't create right a4 page.

how can change controller this:

eg.: 2 pages if many items:

page1:
header

pos ---- item ---- price
1 item1 10€
2 item2 10€
3 itemitem 20€

footer

page2:
header

pos ---- item ---- price
4 item3 10€
5 itemitemitem 40€
6 itemitem1234 20€

footer

edit: add invoice code

  <div id="content">     <div><span style="font-size: x-large;"><strong>invoice</strong></span></div>     <hr />     <div>       <table style="width: 100%" id="invoice_task_list">         <tr style="background:#eee;">           <td style="width:8%;"><b>pos.</b></td>           <td style="width:47%;"><b>description</b></td>           <td style="width:15%;"><b>date</b></td>           <td style="width:20%;"><b>hours</b></td>           <td style="width:10%;"><b>sum</b></td>        <?php          $pos = 1;          foreach( $items $it): ?>          <tr>           <td style="width:8%;"><?php echo $pos; ?></td>           <td style="width:47%;"><?php echo $it->invoice_item_text; ?></td>           <td style="width:15%;">           <?php if ($it->invoice_item_type == 3) {$date = date('m y', strtotime($it->invoice_item_date)); } else { $date = date('d.m.y', strtotime($it->invoice_item_date)); } ?>             <?php echo $date; ?>           </td>           <td style="width:20%;"><?php if ($it->invoice_item_time != '0') { if ($it->invoice_item_type == 1 or $it->invoice_item_type == 2) echo gmdate('h:i', $it->invoice_item_time);}; ?></td>           <td style="width:10%;"><?php echo number_format($it->invoice_item_sum, 2, ',', ' '); ?> €</td>         </tr>         <?php $pos++; ?>         <?php endforeach; ?>          <tr>           <td colspan="3">&nbsp;</td>           <td> total (netto): </td>           <?php $netto = $sum['invoice_item_sum']; ?>           <td style="text-align: right;"><span class="currency"><?php echo number_format($netto, 2, ',', ' ') ?> €</span></td>         </tr>         <tr>           <td colspan="3">&nbsp;</td>           <td> tax 20.00% </td>           <td style="text-align: right;"><span class="currency">           <?php $tmptax = (($sum['invoice_item_sum'])/100)*$invoice['invoice_tax']; ?>            <?php echo number_format($tmptax, 2, ',', ' ')?> €</span></td>         </tr>         <tr>           <td colspan="3">&nbsp;</td>           <td> total (brutto): </td>           <td style="text-align: right;"><span class="currency" style="text-decoration: underline; font-weight: bold;">           <?php $total = ($sum['invoice_item_sum'])+((($sum['invoice_item_sum'])/100)*$invoice['invoice_tax']); ?>           <?php echo number_format($total, 2, ',', ' ')?> €</span></td>         </tr>       </table>      </div> </div> 

this sounds more of css issue php/codeigniter issue.

make sure have clearfix after invoice container:

.clearfix {     float:none;     clear:both; } 

and have correct page break settings printing.

@media print {     .footer {page-break-after: always;} } 

note a4 piece of paper 2480 x 3508 pixels, make sure css adjusted that!


edit (after clarifications):

there couple of different ways determine whether or not need additional header/footer page. i'm going go think simplest. if rows uniform in (20) rows make whole page, can simple check , loop views.

//note you'll have specify putting 20 records here if ($rows->num_rows() > 20) {     ($i = 0; $i < $rows->num_rows(); $i += 20) {         $data['start'] = $i;         $data['end' = $i + 20;         $this->load->view('static/print_header');         $this->load->view('static/print_invoice', $data);         $this->load->view('static/print_footer');    } } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -