D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
view-company-invoice-details.php
back
Copy
<style> .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(0,0,0,.05); } </style> <?php ob_start(); session_start(); require ('config.php'); $id = $_GET['id']; // php number function // function numberTowords($num) // { // $ones = array( // 0 =>"ZERO", // 1 => "ONE", // 2 => "TWO", // 3 => "THREE", // 4 => "FOUR", // 5 => "FIVE", // 6 => "SIX", // 7 => "SEVEN", // 8 => "EIGHT", // 9 => "NINE", // 10 => "TEN", // 11 => "ELEVEN", // 12 => "TWELVE", // 13 => "THIRTEEN", // 14 => "FOURTEEN", // 15 => "FIFTEEN", // 16 => "SIXTEEN", // 17 => "SEVENTEEN", // 18 => "EIGHTEEN", // 19 => "NINETEEN", // "014" => "FOURTEEN" // ); // $tens = array( // 0 => "ZERO", // 1 => "TEN", // 2 => "TWENTY", // 3 => "THIRTY", // 4 => "FORTY", // 5 => "FIFTY", // 6 => "SIXTY", // 7 => "SEVENTY", // 8 => "EIGHTY", // 9 => "NINETY" // ); // $hundreds = array( // "HUNDRED", // "THOUSAND", // "MILLION", // "BILLION", // "TRILLION", // "QUARDRILLION" // ); /*limit t quadrillion */ // $num = number_format($num,2,".",","); // $num_arr = explode(".",$num); // $wholenum = $num_arr[0]; // $decnum = $num_arr[1]; // $whole_arr = array_reverse(explode(",",$wholenum)); // krsort($whole_arr,1); // $rettxt = ""; // foreach($whole_arr as $key => $i){ // while(substr($i,0,1)=="0") // $i=substr($i,1,5); // if($i < 20){ // /* echo "getting:".$i; */ // $rettxt .= $ones[$i]; // }elseif($i < 100){ // if(substr($i,0,1)!="0") $rettxt .= $tens[substr($i,0,1)]; // if(substr($i,1,1)!="0") $rettxt .= " ".$ones[substr($i,1,1)]; // }else{ // if(substr($i,0,1)!="0") $rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0]; // if(substr($i,1,1)!="0")$rettxt .= " ".$tens[substr($i,1,1)]; // if(substr($i,2,1)!="0")$rettxt .= " ".$ones[substr($i,2,1)]; // } // if($key > 0){ // $rettxt .= " ".$hundreds[$key]." "; // } // } // if($decnum > 0){ // $rettxt .= " POINT "; // if($decnum < 20){ // $rettxt .= $ones[$decnum]; // }elseif($decnum < 100){ // $rettxt .= $tens[substr($decnum,0,1)]; // $rettxt .= " ".$ones[substr($decnum,1,1)]; // } // } // return $rettxt; // } function numberTowords($num){ $decones = array( '01' => "One", '02' => "Two", '03' => "Three", '04' => "Four", '05' => "Five", '06' => "Six", '07' => "Seven", '08' => "Eight", '09' => "Nine", 10 => "Ten", 11 => "Eleven", 12 => "Twelve", 13 => "Thirteen", 14 => "Fourteen", 15 => "Fifteen", 16 => "Sixteen", 17 => "Seventeen", 18 => "Eighteen", 19 => "Nineteen" ); $ones = array( 0 => " ", 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Nine", 10 => "Ten", 11 => "Eleven", 12 => "Twelve", 13 => "Thirteen", 14 => "Fourteen", 15 => "Fifteen", 16 => "Sixteen", 17 => "Seventeen", 18 => "Eighteen", 19 => "Nineteen" ); $tens = array( 0 => "", 2 => "Twenty", 3 => "Thirty", 4 => "Forty", 5 => "Fifty", 6 => "Sixty", 7 => "Seventy", 8 => "Eighty", 9 => "Ninety" ); $hundreds = array( "Hundred", "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ); //limit t quadrillion $num = number_format($num,2,".",","); $num_arr = explode(".",$num); $wholenum = $num_arr[0]; $decnum = $num_arr[1]; $whole_arr = array_reverse(explode(",",$wholenum)); krsort($whole_arr); $rettxt = ""; foreach($whole_arr as $key => $i){ if($i < 20){ $rettxt .= $ones[$i]; } elseif($i < 100){ $rettxt .= $tens[substr($i,0,1)]; $rettxt .= " ".$ones[substr($i,1,1)]; } else{ $rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0]; $rettxt .= " ".$tens[substr($i,1,1)]; $rettxt .= " ".$ones[substr($i,2,1)]; } if($key > 0){ $rettxt .= " ".$hundreds[$key]." "; } } if($decnum > 0){ $rettxt .= " "; if($decnum < 20){ $rettxt = $rettxt." and "; $rettxt .= $decones[$decnum]; } elseif($decnum < 100){ $rettxt = $rettxt." and "; $rettxt .= $tens[substr($decnum,0,1)]; $rettxt .= " ".$ones[substr($decnum,1,1)]; } $rettxt = $rettxt. " Only"; } else{ $rettxt = $rettxt. " Only"; } return $rettxt;} // company data fetch $companyd = mysqli_query($conn,"SELECT * FROM `company_details`"); $companyrow = mysqli_fetch_assoc($companyd); $contact_person = $companyrow['contact_person']; $company_name = $companyrow['company_name']; $company_logo = $companyrow['company_logo']; $GSTIN = $companyrow['GSTIN']; $phone = $companyrow['phone']; $company_email = $companyrow['email']; $address = $companyrow['address']; $city = $companyrow['city']; $state = $companyrow['state']; $country = $companyrow['country']; $account_name = $companyrow['account_name']; $account_no = $companyrow['account_no']; $bank_name = $companyrow['bank_name']; $ifsc = $companyrow['ifsc']; $shift = $companyrow['shift']; $branch = $companyrow['branch']; $company_color = $companyrow['company_color']; $currency = $companyrow['currency']; $invoice_prifix = $companyrow['invoice_prifix']; $default_invoice = $companyrow['default_invoice']; $signature = $companyrow['signature']; $invoice_note = $companyrow['invoice_note']; $space=''; $totatdebetAmt = 0.00; $creditAmt = 0.00; $remainAmt = 0.00; $sqlAssign1 = "SELECT * FROM generate_invoice LEFT JOIN payment ON generate_invoice.id = payment.invoiceRow_ID WHERE generate_invoice.bill_pay_name = '$id' AND generate_invoice.data_delete = 'NO' AND generate_invoice.marge_status = 'no' GROUP BY generate_invoice.id ORDER BY generate_invoice.id DESC"; $resultAssign1 = mysqli_query($conn, $sqlAssign1); if (mysqli_num_rows($resultAssign1) > 0) { while($rows = mysqli_fetch_assoc($resultAssign1)) { $gen_inv_id=$rows['id']; $aa=$rows['date']; $bb=$rows['proforma_id']; $cc=$rows['invoice_Id']; $dd=$rows['invoice_reference']; $ee=$rows['amount_paid']; $bank_charge=$rows['bank_charge']; $bill_pay_name=$rows['bill_pay_name']; $totatAmt=sprintf('%0.2f', ($ee)); $totatdebetAmt=sprintf('%0.2f', ($totatdebetAmt+$ee)); $inv_date_date = date_create($aa); $inv_date_date = date_format($inv_date_date,"d-m-Y"); $transaction_reference = $rows['transaction_reference_no']; $iidks_items .='<tr style="width:100%"> <td class="font12" style="padding:10px;width:20%"> '.$inv_date_date.' </td> <td class="font12" style="padding:10px;width:20%">'.$cc.'</td> <td class="font12" style="padding:10px;width:20%"> </td> <td class="font12" style="padding:10px;width:20%;text-align:right"> <strong style="font-weight:bold;color:#000">'.$totatAmt.'</strong></td> <td class="font12" style="padding:10px;width:20%"> </td> </tr>'; $sqlGetPaidAmount = "SELECT * FROM payment WHERE transaction_reference_no = '$transaction_reference' AND company_id='$id' AND transaction_type = 'Credit' AND is_deleted = 'NO'"; $resultGetPaidAmount = mysqli_query($conn, $sqlGetPaidAmount); if($resultGetPaidAmount){ if(mysqli_num_rows($resultGetPaidAmount) > 0){ while($rowGetPaidAmount = mysqli_fetch_assoc($resultGetPaidAmount)){ $payment_id = $rowGetPaidAmount["id"] ; $amountq = $rowGetPaidAmount["amount"] ; $pmode = $rowGetPaidAmount["mode"] ; $payment_date = $rowGetPaidAmount["payment_date"] ; $transaction_reference_no = $rowGetPaidAmount["transaction_reference_no"] ; if(!empty($transaction_reference_no)){ $transaction_reference_no='Ref. No. '.$transaction_reference_no; }else{ $transaction_reference_no=''; } $creditAmt1=sprintf('%0.2f', ($amountq)); $creditAmt=sprintf('%0.2f', ($creditAmt+$amountq)); $pay_date_date = date_create($payment_date); $pay_date_date = date_format($pay_date_date,"d-m-Y"); $iidks_items .='<tr style="width:100%"> <td class="font12" style="padding:10px;width:20%"> '.$pay_date_date.' </td> <td class="font12" style="padding:10px;width:20%">'.$cc.'</td> <td class="font12" style="padding:10px;width:20%"> '.$pmode.' </td> <td class="font12" style="padding:10px;width:20%"> </td> <td class="font12" style="padding:10px;width:20%;font-weight:600;text-align:right"> <strong style="font-weight:bold;color:#000">'.$creditAmt1.'</strong><br><small>'.$transaction_reference_no.'</small></td> </tr>'; } } } } } // echo"<pre>"; // print_r($iidks_items) ; // die(); //die; $remainAmt=sprintf('%0.2f', ($totatdebetAmt-$creditAmt)); // Invoice Data Fetch $sql = " SELECT * FROM generate_invoice where bill_pay_name = '$id' and data_delete = 'NO'"; $result = mysqli_query($conn,$sql); $row = mysqli_fetch_array($result); $bill_pay_name = $row['bill_pay_name']; $invoice_id = $row['invoice_Id']; $proforma_id = $row['proforma_id']; $pincode = $row['pincode']; $date = $row['date']; $terms = $row['terms']; $due_date = $row['due_date']; $deliver_address = $row['deliver_address']; $billingAddress = $row['billingAddress']; $client_name = $row['client_name']; $mobile_no = $row['mobile_no']; $email = $row['email']; $gstin = $row['gstin']; $type = $row['type']; $buyer_reference = $row['buyer_reference']; $delivery_type = $row['delivery_type']; $delivery_terms = $row['delivery_terms']; $mode_of_shipment = $row['mode_of_shipment']; $shipping_date = $row['shipping_date']; $port_of_loading = $row['port_of_loading']; $port_of_delivery = $row['port_of_delivery']; $payment_method = $row['payment_method']; $hs_code = $row['hs_code']; $terms_of_payment = $row['terms_of_payment']; $bank_details = $row['bank_details']; $foreign_charges = $row['foreign_charges']; $foreign_rate = $row['foreign_rate']; $discount_percent = $row['discount_percent']; $discount = $row['discount']; $other_charges = $row['other_charges']; $memo = $row['memo']; $other_price = $row['other_price']; $subtotal_price = $row['subtotal_price']; $amount_paid = $row['amount_paid']; $comment = $row['comment']; $invoice_reference = $row['invoice_reference']; $bank_charges = $row['bank_charge']; $other_charge_msg = $row['other_charge_msg']; // Getting Contact Details $contactsql = mysqli_query($conn,"SELECT * FROM `contact` where id='$bill_pay_name' and data_delete !='yes'"); $contactrow = mysqli_fetch_assoc($contactsql); $customer_type = $contactrow['customer_type']; $bill_display_name = $contactrow['bill_display_name']; $contact_person_name = $contactrow['contact_person_name']; $contact_person_designation = $contactrow['contact_person_designation']; // billing address $getad_b = mysqli_query($conn,"SELECT * FROM `contact_address` where id='$billingAddress'"); $getadrow_b = mysqli_fetch_assoc($getad_b); $address_get_b = $getadrow_b['address'] .', '. $getadrow_b['city'] .', '. $getadrow_b['state'] .', '. $getadrow_b['country']; // getting address $getad = mysqli_query($conn,"SELECT * FROM `contact_address` where id='$deliver_address'"); $getadrow = mysqli_fetch_assoc($getad); $address_get = $getadrow['address'] .', '. $getadrow['city'] .', '. $getadrow['state'] .', '. $getadrow['country']; $iecno = $getadrow['iecno']; $getitemsql = mysqli_query($conn,"SELECT * FROM invoice_item a left join inventory b on a.item_id = b.id where a.invoice_reference = '$invoice_reference'"); while($item_row = mysqli_fetch_assoc($getitemsql)){ $item_image = $item_row['item_image']; if(!empty($item_image)){ $if_image = '<img src="inventory/'.$item_image.'" width="20">'; }else{ $if_image = ''; } $ii_items .='<tr style="width:100%"> <td class="font12" style="padding:2px;width:10%"> '.$item_row['item_code'].' </td> <td class="font12" style="padding:2px;width:10%">'.$if_image.'</td> <td class="font12" style="padding:2px;width:20%"> '.$item_row['name'].' </td> <td class="font12" style="padding:2px;width:10%"> '.$item_row['size'].'</td> <td class="font12" style="padding:2px;width:15%"> '.$item_row['color'].'</td> <td class="font12" style="padding:2px;width:5%"> '.$item_row['qty'].'</td> <td class="font12" style="padding:2px;width:5%"> '.$item_row['unit_of_measure'].'</td> <td class="font12" style="padding:2px;width:15%"> '.$item_row['price'].'</td> <td class="font12" style="padding:2px;width:10%"> '.$item_row['row_total'].'</td> </tr>'; } // Other Charges Hae To $other_charges_h = ''; if(!empty($other_price)){ $other_charges_h = "<tr> <td class='py-0'></td> <td class='py-0'></td> <td class='py-0'></td> <td class='py-0'></td> <td class='py-0'></td> <td class='py-0'></td> <td class='py-0'></td> <td class='font12 py-0' style='padding:2px;'><strong>Other <small>($other_charge_msg)<small></strong></td> <td class='font12 py-0' style='padding:2px;'>$other_price</td> </tr> "; } $html = "<!DOCTYPE html> <html lang='en'> <body> <br> <section class='invoice-page'> <div class='container-fluid'> <div class='row pt-1'> <div class='col-md-12 text-center'> <h3 class='mb-0' ><strong style='color:#000'>".ucfirst($bill_display_name)."</strong></h3> <p class='mb-0 font12'> $address_get_b </p> <p class='mb-0 font12'>Zip Code : $pincode</p> <p class='mb-0 font12'>GSTIN : $gstin</p> <p class='mb-0 font12'>IEC No.: $iecno </p> <p class='mb-0 font12'>Contact Person: $contact_person_name</p> <p class='mb-0 font12'>Contact No.: $mobile_no</p> </div> </div> <div class='row pt-3'> <table class='table table-striped'> <thead> <tr style='width:100%'> <th class='bac_color font14' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;'>Date</th> <th class='bac_color font14' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;'>Invoice Id</th> <th class='bac_color font14' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;'>Payment Mode</th> <th class='bac_color font14' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;text-align:center'>Debit</th> <th class='bac_color font14' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;text-align:right'>Credit</th> </tr> </thead> <tbody> $iidks_items <tr> <td class='py-0' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;'></td> <td class='py-0' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;'></td> <td class='py-0' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;'><strong >Sub Total</strong></td> <td class='font12 py-0' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;text-align:right'><strong style='font-weight:bold;color:#000;font-size:16px'>$totatdebetAmt</strong></td> <td class='font12 py-0' style='border-top:1px solid #afafaf;border-bottom:1px solid #afafaf;background: #fff !important; color:#444; padding:8px;text-align:right'><strong style='font-weight:bold;color:#000;font-size:16px'>$creditAmt</strong></td> </tr> <tr> <td class='py-0' style='padding:8px;'></td> <td class='py-0' style='padding:8px;'></td> <td class='py-0' style='padding:8px;'></td> <td class='font12 py-0' style='padding:8px;'><strong>Balance Amount </strong><small>($currency)</small></td> <td class='font12 py-0' style='padding:8px;'><strong style='font-weight:bold;color:#000;font-size:18px'>$remainAmt</strong></td> </tr> </tbody> </table> <div class='col-md-12 p-0'> <p style='display:block;background:#afafaf;text-align:center;color:#fff;font-size:13px;'>Balance Amount in $currency - ".numberTowords("$remainAmt")."</p> </div> <div> <div class='row pt-4'> <div class='col-md-6 float-left'> </div> <div class='col-md-6 float-right'> <p class='text-center m-0 font12'>For <strong>$company_name</strong><p> <p class='text-center'><img src='signature/$signature' width='95'></p> <p class='text-center'>Authorized Signatory</p> </div> </div> </div> </section> </body> </html>"; require ("mpdf/mpdf.php"); $mpdf = new mPDF('A4'); $mpdf->allow_charset_conversion = true; $stylesheet = file_get_contents('bootstrap.min.css'); $mpdf->WriteHTML($stylesheet,1); $stylesheet1 = file_get_contents('styleInvoice3.css'); $mpdf->WriteHTML($stylesheet1,1); $mpdf->showImageErrors = true; $mpdf->SetDisplayMode('fullpage'); $mpdf->WriteHTML($html); $mpdf->Output(); //track record $logindk_usersId=$_SESSION["login_usersId"]; $logindk_emailId=$_SESSION["login_email"]; $sqlGetCompanyContactDetail = "SELECT * FROM `contact` WHERE `id`='$bill_pay_name'"; $resultGetCompanyContactDetail = mysqli_query($conn, $sqlGetCompanyContactDetail); if($resultGetCompanyContactDetail){ if(mysqli_num_rows($resultGetCompanyContactDetail) > 0){ while($rowdks = mysqli_fetch_assoc($resultGetCompanyContactDetail)){ $companyDkName = $rowdks["bill_display_name"]; } } } // $sqltrackrecord ="INSERT INTO `user_action_track`(`user_id`, `date`,`user_action`, `comments`, `user_email`) VALUES ('$logindk_usersId','$currentsDate','Print Invoice of $companyDkName And Proforma id $proforma_id And Invoice id is $invoice_id','$invoice_id','$logindk_emailId')"; // $resuttrackrecord = $conn->query($sqltrackrecord); exit; ?>