get('invoicing_enable') === 'true'; if (!$invoicingEnable) { api_not_allowed(true, $plugin->get_lang('NoInvoiceEnable')); } $saleId = isset($_GET['invoice']) ? (int) $_GET['invoice'] : 0; $isService = isset($_GET['is_service']) ? (int) $_GET['is_service'] : 0; $globalParameters = $plugin->getGlobalParameters(); $infoSale = $plugin->getDataSaleInvoice($saleId, $isService); $buyer = api_get_user_info($infoSale['user_id']); $extraUserInfoData = UserManager::get_extra_user_data($infoSale['user_id']); $infoInvoice = $plugin->getDataInvoice($saleId, $isService); $taxAppliesTo = $globalParameters['tax_applies_to']; $taxEnable = $plugin->get('tax_enable') === 'true' && ($taxAppliesTo == BuyCoursesPlugin::TAX_APPLIES_TO_ALL || ($taxAppliesTo == BuyCoursesPlugin::TAX_APPLIES_TO_ONLY_COURSE && !$isService) || ($taxAppliesTo == BuyCoursesPlugin::TAX_APPLIES_TO_ONLY_SESSION && $isService)); $htmlText = ''; $htmlText .= ''; $htmlText .= ''; $htmlText .= ''; $organization = ChamiloApi::getPlatformLogo('', [], true); // Use custom logo image. $pdfLogo = api_get_setting('pdf_logo_header'); if ($pdfLogo === 'true') { $visualTheme = api_get_visual_theme(); $img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png'; if (file_exists($img)) { $organization = ""; } } $htmlText .= $organization; // Seller and customer info $htmlText .= ''; $htmlText .= ''; $htmlText .= ''; $htmlText .= ''; $htmlText .= ''; $htmlText .= '
'; $htmlText .= ''.$globalParameters['seller_name'].'
'; $htmlText .= $globalParameters['seller_id'].'
'; $htmlText .= $globalParameters['seller_address'].'
'; $htmlText .= $globalParameters['seller_email'].'
'; $htmlText .= '
'; $htmlText .= ''.$buyer['complete_name'].'
'; $htmlText .= ($extraUserInfoData['buycourses_company'] ? $extraUserInfoData['buycourses_company'].'
' : ''); $htmlText .= ($extraUserInfoData['buycourses_vat'] ? $extraUserInfoData['buycourses_vat'].'
' : ''); $htmlText .= ($extraUserInfoData['buycourses_address'] ? $extraUserInfoData['buycourses_address'].'
' : ''); $htmlText .= ($buyer['phone'] ? $buyer['phone'].'
' : ''); $htmlText .= ($buyer['email'] ? $buyer['email'].'
' : ''); $htmlText .= '
'; $htmlText .= '

'; $htmlText .= '

'; $htmlText .= $plugin->get_lang('InvoiceDate').': ' .api_convert_and_format_date($infoInvoice['date_invoice'], DATE_TIME_FORMAT_LONG_24H).'
'; $htmlText .= $plugin->get_lang('InvoiceNumber').': ' .$infoInvoice['serie'].$infoInvoice['year'].'/'.$infoInvoice['num_invoice'].'
'; $htmlText .= '



'; $header = [ $plugin->get_lang('OrderReference'), $plugin->get_lang('ProductType'), $plugin->get_lang('Price'), ]; if ($taxEnable) { $header[] = $globalParameters['tax_name']; $header[] = $plugin->get_lang('Total'); } $data = []; $row = [ $infoSale['reference'], $infoSale['product_name'], ]; //var_dump($infoSale);exit; $isoCode = $plugin->getCurrency($infoSale['currency_id'])['iso_code']; if ($taxEnable) { $row[] = $plugin->getPriceWithCurrencyFromIsoCode($infoSale['price_without_tax'], $isoCode); $row[] = $plugin->getPriceWithCurrencyFromIsoCode($infoSale['tax_amount'], $isoCode).' ('.(int) $infoSale['tax_perc'].'%)'; } $totalPrice = $plugin->getPriceWithCurrencyFromIsoCode( $infoSale['price'], $plugin->getCurrency($infoSale['currency_id'])['iso_code'] ); $row[] = $totalPrice; $data[] = $row; $totalPrice = $plugin->getPriceWithCurrencyFromIsoCode( $infoSale['price'], $plugin->getCurrency($infoSale['currency_id'])['iso_code'] ); if ($taxEnable) { $row = [ '', '', '', $plugin->get_lang('TotalPayout'), $totalPrice, ]; } else { $row = [ '', $plugin->get_lang('TotalPayout'), $totalPrice, ]; } $data[] = $row; $attr = []; $attr['class'] = 'table table-hover table-striped data_table'; $attr['width'] = '100%'; $htmlText .= Display::table($header, $data, $attr); $htmlText .= ''; $fileName = $infoInvoice['serie'].$infoInvoice['year'].'-'.$infoInvoice['num_invoice']; $fileName = api_replace_dangerous_char($fileName); $params = [ 'filename' => $fileName, 'pdf_title' => $plugin->get_lang('Invoice'), 'pdf_description' => '', 'format' => 'A4', 'orientation' => 'P', ]; $pdf = new PDF($params['format'], $params['orientation'], $params); @$pdf->content_to_pdf($htmlText, '', $fileName, null, 'D', false, null, false, false, false); exit;