通过使用php打印出来生成文档的硬拷贝

时间:2016-09-11 15:40:27

标签: php printing

只需单击打印按钮,需要调用或包含哪些必要的脚本函数或代码才能打印收据,报告等文档。这是我想打印的示例文档 - 请点击此处Document to be printed

如果是这样,那些脚本/代码应放在代码中的哪个位置?这是我的代码:

    echo'<div class = "cust" style = "float:left;margin-left:20%;margin-top:1%;width:60%"><table>
<div style = "margin-left: 40%;">NEW BATCH MARKETING</div>
        <tr><td>Customer Name:</td><td>'.$customer_name.'</td><td colspan = "3">DELIVERY ID:</td><td>'.$delivery_id.'</td></tr>
        <tr><td>Customer Address:</td><td>'.$customer_address.'</td><td colspan = "3">Delivery date:</td><td>'.$delivery_date.'</td></tr>
        <tr><td>Customer No.:</td><td>'.$customer_contact_number.'</td><td colspan = "3">ORDER ID:</td><td>'.$order_id.'</td></tr>
        <tr><td>Agent Name:</td><td>'.$agent_name.'</td><td colspan = "3">ORDER DATE:</td><td>'.$order_date.'</td></tr>
        <tr><td>Agent No.:</td><td>'.$agent_num.'</td><td colspan = "3">Delivered by:</td><td>'.$delivered_by.'</td></tr>
        <tr><td>TRANSACTION ID:</td><td>'.$_SESSION['payment_transaction_id'].'</td><td colspan = "3">Processed by:</td><td>'.$processed_by.'</td></tr>
    </table></div>';

$get_acoount_details = $new_batch_marketing->query("SELECT pd.OR,pd.date,pd.amount_paid,p.amount_payable,co.delivery_date FROM customer_order AS co
    INNER JOIN payment AS p on p.customer_order_id = co.purchase_order_id
    INNER JOIN payment_details AS pd ON pd.transaction_id = p.transaction_id
    WHERE co.purchase_order_id = '".$_SESSION['payment_order_id']."'");
foreach($get_acoount_details as $key){
    $delivery_date = $key['delivery_date'];
    $aging = (strtotime($current_date) - strtotime($delivery_date))/86400;
    $aging = round(abs($aging));
    if($aging > 30){
        $aging = 30;
    }
    $principal = $key['amount_payable'];
}


 echo'<div class = "cust" style = "float:left;margin-left:20%;margin-top:1%;width:60%"><table>';
 echo'<div style = "margin-left: 43%;">STATEMENT OF ACCOUNT</div>';
 echo'<tr><td colspan = "2">AGING:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$aging.'&nbsp;day/s</td><td colspan = "3">PRINCIPAL AMOUNT:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$principal.'</td></tr>';
 echo'<tr><td>OFFICIAL RECIEPT</td><td>AMOUNT</td><td>BALANCE</td><td>PENALTY</td><td>DATE</td></tr></table></div></br>';

 echo'<div class = "rep" style = "float:left;margin-left:20%;margin-top:-9%;width:60%;"><table>';

$new_balance = $principal;
$or = '';
$a_paid = '';
$date_flag = '';
$decrementor = 0;
while($aging >0){
$inc_date = strtotime('+'.$decrementor.' day',strtotime($delivery_date));
$temp_date = date('Y-m-d',$inc_date);

if($decrementor == 11){
        $interest = $new_balance * 0.05;
        $interest = round($interest,2,PHP_ROUND_HALF_UP);
        $new_balance = $new_balance + $interest;
}else if($decrementor > 25 && $decrementor <= 30){
    $interest = (($new_balance * 0.05)+($new_balance * 0.03 ));
    $interest = round($interest,2,PHP_ROUND_HALF_UP);
    $new_balance = $new_balance + $interest;
}else{
    $interest = '';
}

foreach($get_acoount_details as $key){
    if($key['date'] == $temp_date){
        $or = $key['OR'];
        $a_paid = $key['amount_paid'];
        $new_balance = $new_balance - $a_paid;
        $date_flag = $key['date'];
        echo'<tr><td>'.$or.'</td><td>'.$a_paid.'</td><td>'.$new_balance.'</td><td>'.$interest.'</td><td>'.$temp_date.'</td></tr>';
    }else{
        $or = '';
        $a_paid = '';

    }
}
if($date_flag == $temp_date){
    #do nothing...
}else{
    echo'<tr><td>'.$or.'</td><td>'.$a_paid.'</td><td>'.$new_balance.'</td><td>'.$interest.'</td><td>'.$temp_date.'</td></tr>';
}
$aging--;
$decrementor++;
}
echo'</table></div></br></br>';

0 个答案:

没有答案