Remove Header and Footer to add new extra page - laravel

I',m using Laravel 5.5 to create a PDF file using barryvdh/laravel-snappy.
I want to generate a PDF with and extra page without header and footer. It is to print terms and conditions at the end of my budget.
I can generate the first 2 page with the products , price, header , footer... but when I add the terms and contiditons I have the footer and header and the pdf options ( marging...)
I have tried to remove header and footer using javascript when I loadView removing header and footer with css but I have a white space in those places but I need all the page.
$presupuesto = ExpedientePresupuesto::findOrFail($id_presupuesto);
$now = Carbon::now('Europe/Madrid');
$header = \View::make('expedientes.pdf.cabeceraPresupuesto', compact('now', 'request', 'presupuesto') )->render();
$footerHTML = Footer::footerHtml($now);
$footer = \View::make('expedientes.pdf.piePresupuesto', compact( 'footerHTML', 'request', 'presupuesto') )->render();
$pdf= \PDF::loadView('expedientes.pdf.cuerpoPresupuesto', compact('presupuesto', 'request'));
return view('expedientes.pdf.cabeceraPresupuesto', compact('now', 'presupuesto', 'request'));
$pdf->setPaper('a4');
$pdf->setOption('header-html', $header );
$pdf->setOption('footer-html', $footer );
$pdf->setOption('footer-spacing', 10 );
My question is it possible to add other page with differents optios in the same PDF? I mean, the first part of the PDF has header footer and anything I want and the last part has no header, other spacing...
Somenting like that ( does not working)
$pdf.= \PDF::loadView('expedientes.pdf.terms', compact('presupuesto', 'request'));
$pdf->setPaper('a4');
$pdf->setOption('header-html', '' );
$pdf->setOption('footer-html', '');
$pdf->setOption('footer-spacing', 10 );
return $pdf->stream( $now . '-PresupuestoFP.pdf');

Related

Magento 2 - wrong number of digits between separators for prices in Indian Rupees

I am using Magento 2.2.3. my default currency is INR, but it shows in the wrong format:
But it should be ₹77,65,000.00. How do we correct price format? Currently its wrong... like USD.
You can set the currency format by following code.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); // Instance of Pricing Helper
$price = 1000; //Your Price
$formattedPrice = $priceHelper->currency($price, true, false);
?>
File path: vendor/magento/zendframework1/library/Zend/Locale/Data/en.xml
On line number 3353, under section currencyFormat and type = "standard", change the pattern from <pattern>¤#,##0.00</pattern> to <pattern>¤ #,##,##0.00</pattern>
Still, on PDP page and cart page summary the price format does not change because the prize format is coming from the JS in which Magento using a RegExp function for only US price format.
For that, please change the code in the below file.
File path: vendor/magento/module-catalog/view/base/web/js/price-utils.js (First extend this file in your theme directory and do the respected changes)
Under the function formatPrice below this line comment all the line in the respective function.
i = parseInt(
amount = Number(Math.round(Math.abs(+amount || 0) + 'e+' + precision) + ('e-' + precision)),
10
) + '';
And add this set of code below the above line.
var x=i;
x=x.toString();
var afterPoint = '';
if(x.indexOf('.') > 0)
afterPoint = x.substring(x.indexOf('.'),x.length);
x = Math.floor(x);
x=x.toString();
var lastThree = x.substring(x.length-3);
var otherNumbers = x.substring(0,x.length-3);
if(otherNumbers != '')
lastThree = ',' + lastThree;
var response = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree + afterPoint;
return pattern.replace('%s', response);
deploy and `rm -rf var/cache/*
And then you're done. For Example: A price previously displayed like 453,453, will now display in the Indian manner like 4,53,453.

How to change the language in timespan() function in codeigniter

Im using codeigniter to pull blog posts from my database and I want to display how much time has elapsed since the post is posted. By default codeigniters timespan() function is displaying for example:
1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes
but i want to translate the words Year,Months,Weeks,Days,Hours,Minutes in other language, for example Bosnian,Croatian or Serbian.
How can I translate it?
I found the answer. You need to go to the application/language/english folder and create a file called date_lang.php. In my case I just want to have one language on my website, so i made the file in the default (english) folder. If you have more languages you can change the language in the application/config/config.php and change the $config['language'] = 'english' to whatever language you made in the application/language/YOURLANGUAGE.php file.
I added this piece of code in my date_lang.php file and it works well.
<?php
$lang['date_year'] = 'Godinu';
$lang['date_years'] = 'Godina';
$lang['date_month'] = 'Mjesec';
$lang['date_months'] = 'Mjeseci';
$lang['date_week'] = 'Sedmica';
$lang['date_weeks'] = 'Sedmice';
$lang['date_day'] = 'Dan';
$lang['date_days'] = 'Dana';
$lang['date_hour'] = 'Sat';
$lang['date_hours'] = 'Sat';
$lang['date_minute'] = 'Minute';
$lang['date_minutes'] = 'Minuta';
$lang['date_second'] = 'Sekundu';
$lang['date_seconds'] = 'Sekunde';
?>

TYPO3 6.1 : config.disablePrefixComment=1 not working

Hello I'm wondering why this setting is not working in my TYPO3 6.1
I'm trying to remove typo3's automatic comments like
<!-- header end-->
<!--###main zerogrid### end --></div>
<!--###body2### end --></div>
<!--###body1### end --></div>
<div class="body3"><!--###body3### begin -->
<div class="main zerogrid"><!--###main zerogrid### begin -->
and so on.
FYI, I wrote config.disablePrefixComment=1 in the main TS template setup.
I read typo3 latest reference docs but it's only a simple boolean setting.
Here the TS setup:
config.disablePrefixComment = 1
config.no_cache = 1
config.baseURL = http://xxxx.yyyy.net
# Main TEMPLATE cObject for the BODY
temp.mainTemplate = TEMPLATE
temp.mainTemplate {
# Feeding the content from the Auto-parser to the TEMPLATE cObject:
template =< plugin.tx_automaketemplate_pi1
# Select only the content between the <body>-tags
workOnSubpart = DOCUMENT_BODY
subparts.content < styles.content.get
}
# Main TEMPLATE cObject for the HEAD
temp.headTemplate = TEMPLATE
temp.headTemplate {
# Feeding the content from the Auto-parser to the TEMPLATE cObject:
template =< plugin.tx_automaketemplate_pi1
# Select only the content between the <head>-tags
workOnSubpart = DOCUMENT_HEADER
}
page = PAGE
page.typeNum = 0
page.10 < temp.mainTemplate
# Copying the content from TEMPLATE for <head>-section:
page.headerData.100 < temp.headTemplate
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.value= page1
page.bodyTagCObject.wrap = <body id="|">
plugin.tx_automaketemplate_pi1 {
content = FILE
content.file = fileadmin/templates/zp/index.html
elements {
BODY.all = 1
BODY.all.subpartMarker = DOCUMENT_BODY
HEAD.all = 1
HEAD.all.subpartMarker = DOCUMENT_HEADER
HEAD.rmTagSections = title
TD.all = 1
TABLE.all = 1
TR.all = 1
DIV.all = 1
}
relPathPrefix = fileadmin/templates/zp/
relPathPrefix.A = ./
}
Where am I doing wrong?
Browse with the template analysis your ts. Maybe it gets overwritten somehow?
This setting will only affect comments that are touched by TYPO3 CMS. If you do not replace the blocks, nothing will happen and those comments stay.
The comments are inserted by automaketemplate and have nothing to do with TYPO3 CMS. TYPO3 CMS just sees the parsed template file with all comments and will remove the comments of the replace blocks.
Untouched blocks remain untouched.

Magento: How to remove the price for bundled product options on the shopping cart page, checkout etc

Please help me removing the price for bundled product options on the shopping cart page, checkout, etc. Here is a pic.
What do i need to do?
To remove this edit:
Mage_Bundle_Block_Checkout_Cart_Item_Renderer
Look for the _getBundleOptions() method and at around line 77 change it as follows
//$option['value'][] = $this->_getSelectionQty($bundleSelection->getSelectionId()).' x '. $this->htmlEscape($bundleSelection->getName()). ' ' .Mage::helper('core')->currency($this->_getSelectionFinalPrice($bundleSelection));
//New line
$option['value'][] = $this->_getSelectionQty($bundleSelection->getSelectionId()).' x '. $this->htmlEscape($bundleSelection->getName());
Then edit:
Mage_Bundle_Block_Sales_Order_Items_Renderer
Look for the getValueHtml() method at around line 115 change the code as follows
public function getValueHtml($item)
{
if ($attributes = $this->getSelectionAttributes($item)) {
//Old code
/*
return sprintf('%d', $attributes['qty']) . ' x ' .
$this->htmlEscape($item->getName()) .
" " . $this->getOrder()->formatPrice($attributes['price']);
*/
return sprintf('%d', $attributes['qty']) . ' x ' .
$this->htmlEscape($item->getName());
} else {
return $this->htmlEscape($item->getName());
}
}
The usual caveats about not editing core code and using local or module rewrites apply!
let me know if i can help you more.
OR Also you can hide with css like below
Assuming that you want to remove it from all items regardless of the price, then you could add this css
#shopping-cart-table dd span.price{
display:none;
}
If you only want to remove the price if it is zero,you can also do in this way
/app/design/frontend/default/{theme path}/template/checkout/cart/item/default.phtml (around line # 46)
Figure out where it is add the price and only append the price if it is greater than 0
or
Do a find a replace str_replace("$0.00", "", $_formatedOptionValue['value']) on the string that display that line (make sure to add the currency sign so that $10.00 dont get replace)
I found another way to do it. Hopefully it will help somebody.
1 - Go to /public_html/app/code/core/Mage/Bundle/Helper/Catalog/Product
2 - open the file Configuration.php
3 - from about line 119 till about 127 you will find this code:
foreach ($bundleSelections as $bundleSelection) {
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName())
. ' ' . Mage::helper('core')->currency(
$this->getSelectionFinalPrice($item, $bundleSelection)
);
}
}
Change that with this code:
foreach ($bundleSelections as $bundleSelection) {
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $this->escapeHtml($bundleSelection->getName());
}
}
One caution note, be careful about editing the core file. You can also use local or module rewrites.

Laravel multiple PDF generation

I am using Laravel-pdf package package to generate pdf. I want to generating two pdfs with different contents. But this package does not allow me to create second pdf with different content. I am getting first content in the second pdf.
This is my code
$pdf = PDF::loadView('pdf.bill', $data);
return $pdf->save('invoice.pdf');
$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->save('agreement.pdf');
I have solved the issue by changing PDFWrapper class's save method as below
public function save($filename) {
$mpdf=new \mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->WriteHTML($this->html);
return $mpdf->Output($filename, 'F');
}

Resources