guessous Posted April 1, 2014 Share Posted April 1, 2014 (edited) hay evrebody plz can you help me i want change invoice logo refering to language thanks you Edited April 2, 2014 by guessous (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted April 2, 2014 Share Posted April 2, 2014 Create all image paths in getHeader() function in /classes/pdf/HTMLTemplate.php. Then use a condition to switch between the paths according to the language in /pdf/header.tpl - replace {if $logo_path} <img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" /> {/if} 1 Link to comment Share on other sites More sharing options...
guessous Posted April 2, 2014 Author Share Posted April 2, 2014 Create all image paths in getHeader() function in /classes/pdf/HTMLTemplate.php. Then use a condition to switch between the paths according to the language in /pdf/header.tpl - replace {if $logo_path} <img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" /> {/if} thanks but how i cant create a condition to switch between the paths according to the language in /pdf/header.tpl - replace Link to comment Share on other sites More sharing options...
tuk66 Posted April 2, 2014 Share Posted April 2, 2014 Maybe easier solution is to create the condition right in the getHeader() function. $path_logo = $this->getLogo(); $id_lang = (int)Context::getContext()->language->id; if ($id_lang == 1) $path_logo = ..... here define the logo path for the first language elseif ($id_lang == 2) $path_logo = ..... here define the logo path for the second language .... 2 Link to comment Share on other sites More sharing options...
guessous Posted April 2, 2014 Author Share Posted April 2, 2014 Maybe easier solution is to create the condition right in the getHeader() function. $path_logo = $this->getLogo(); $id_lang = (int)Context::getContext()->language->id; if ($id_lang == 1) $path_logo = ..... here define the logo path for the first language elseif ($id_lang == 2) $path_logo = ..... here define the logo path for the second language .... thanks you so matsh mr tuk i hav one more question $path_logo = $this->getLogo(); so if i want change image paths you must create a new function to get url logo !!! Link to comment Share on other sites More sharing options...
guessous Posted April 2, 2014 Author Share Posted April 2, 2014 Like this protected function getLogo() { $logo = ''; $physical_uri = Context::getContext()->shop->physical_uri.'img/'; if (Configuration::get('PS_LOGO_INVOICE', null, null, (int)$this->order->id_shop) != false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_INVOICE', null, null, (int)$this->order->id_shop))) $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO_INVOICE', null, null, (int)$this->order->id_shop); elseif (Configuration::get('PS_LOGO', null, null, (int)$this->order->id_shop) != false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, (int)$this->order->id_shop))) $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, (int)$this->order->id_shop); return $logo; } protected function getLogo2() { $logo = ''; $physical_uri = Context::getContext()->shop->physical_uri.'img2/'; if (Configuration::get('PS_LOGO_INVOICE', null, null, (int)$this->order->id_shop) != false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_INVOICE', null, null, (int)$this->order->id_shop))) $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO_INVOICE', null, null, (int)$this->order->id_shop); elseif (Configuration::get('PS_LOGO', null, null, (int)$this->order->id_shop) != false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, (int)$this->order->id_shop))) $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, (int)$this->order->id_shop); return $logo; } and getHeader() public function getHeader() { $id_lang = (int)Context::getContext()->language->id; print $id_lang; if ($id_lang == 1){ $path_logo = $this->getLogo(); } elseif ($id_lang == 2){ $path_logo = $this->getLogo2(); } $shop_name = Configuration::get('PS_SHOP_NAME', null, null, (int)$this->order->id_shop); if ($id_lang == 1){ $path_logo = $this->getLogo(); } elseif ($id_lang == 2){ $path_logo = $this->getLogo2(); } $width = 0; $height = 0; if (!empty($path_logo)) list($width, $height) = getimagesize($path_logo); $this->smarty->assign(array( 'logo_path' => $path_logo, 'img_ps_dir' => 'http://'.Tools::getMediaServer(_PS_IMG_)._PS_IMG_, 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'title' => $this->title, 'date' => $this->date, 'shop_name' => $shop_name, 'width_logo' => $width, 'height_logo' => $height )); return $this->smarty->fetch($this->getTemplate('header')); } Link to comment Share on other sites More sharing options...
tuk66 Posted April 2, 2014 Share Posted April 2, 2014 If you have all logos in the /img folder just use: $path_logo = _PS_IMG_DIR_."your_logo_file_name_number_1.jpg"; in the condition. Link to comment Share on other sites More sharing options...
guessous Posted April 2, 2014 Author Share Posted April 2, 2014 (edited) If you have all logos in the /img folder just use: $path_logo = _PS_IMG_DIR_."your_logo_file_name_number_1.jpg"; in the condition. Like this ? public function getHeader() { $path_logo = $this->getLogo(); $id_lang = (int)Context::getContext()->language->id; $shop_name = Configuration::get('PS_SHOP_NAME', null, null, (int)$this->order->id_shop); if ($id_lang == 1){ $path_logo =_PS_IMG_DIR_."logo1.jpg";;} elseif ($id_lang == 2){ $path_logo =_PS_IMG_DIR_."logo2.jpg";;} $width = 0; $height = 0; if (!empty($path_logo)) list($width, $height) = getimagesize($path_logo); $this->smarty->assign(array( 'logo_path' => $path_logo, 'img_ps_dir' => 'http://'.Tools::getMediaServer(_PS_IMG_)._PS_IMG_, 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'title' => $this->title, 'date' => $this->date, 'shop_name' => $shop_name, 'width_logo' => $width, 'height_logo' => $height )); return $this->smarty->fetch($this->getTemplate('header')); } Edited April 2, 2014 by guessous (see edit history) Link to comment Share on other sites More sharing options...
guessous Posted April 2, 2014 Author Share Posted April 2, 2014 thank you ever so much for your help it's good now Link to comment Share on other sites More sharing options...
KonfiDD Posted December 15, 2014 Share Posted December 15, 2014 Hi ! Thank you for your topic and the clear answer. I just want to know how you choose the language to generate the invoice from back-office. There is a way to translate the PDF right from the back-office, regardless of the back-office language ? Thank you very much for your help. Link to comment Share on other sites More sharing options...
tuk66 Posted December 15, 2014 Share Posted December 15, 2014 As I know, there is no easy solution for that. You can switch the employee's language. The other solution is built-in in the M4 PDF Extensions module - http://www.presta-addons.com/3-86/pdf-extensions.jpg Link to comment Share on other sites More sharing options...
KonfiDD Posted December 15, 2014 Share Posted December 15, 2014 Thank you ! So I have to create an employee for each language I use on my shop. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now