Jump to content

Mam problem z modyfikacją standardowej faktury proforma w systemie PrestaShop 1.7.8.9


effectdesign

Recommended Posts

Witam,

Mam problem z modyfikacją standardowej faktury proforma w systemie PrestaShop 1.7.8.9

Aby w polu dane zrobić faktury widniały dane w postaci jak poniżej. 

Chciałbym, aby w danych na fakturze dodatkowo było zawarte słowo tel. (telefon) oraz NIP. Poprosze o pomoc. 

Czy można to zrobić jak poniżej oraz na załączonym screenie o naziwe proforma.jpg?


Adres dostawy:

Jan Kowalski
Moja Firma
ul. Jana Kowalskiego 10
01-234 Warszawa
Polska
tel. 123 456 789
NIP: 1234567891


Adres rozliczeniowy:

Jan Kowalski
Moja Firma
ul. Jana Kowalskiego 10
01-234 Warszawa
Polska
tel. 123 456 789
NIP: 1234567891

Dodatkowo przeanalizowałem foldery pdf orazclasss/pdf.

Z góry dziękuję.proforma.thumb.jpg.42040362a7b7d39d5ea0d37d3554a08c.jpg

Link to comment
Share on other sites

Musisz edytować klasę PaymentModule.php która jest w

classes/PaymentModule.php

----- Szukasz tego
'{delivery_address1}' => $delivery->address1,
'{delivery_address2}' => $delivery->address2,

Tam masz dwie zmienne smarty które pobierają dane, doda do tablicy kolejną zmienną.
Widok edytujesz w pdf/invoice.addresses-tab.tpl

  • Like 1
Link to comment
Share on other sites

Umieść zawartość w pliku /override/classes/AddressFormat.php

Powinno rozwiązać problem, wyczyść cache.

 

<?php

class AddressFormat extends AddressFormatCore {
        
    /**
     * Generates the full address text.
     *
     * @param Address $address
     * @param array $patternRules A defined rules array to avoid some pattern
     * @param string $newLine A string containing the newLine format
     * @param string $separator A string containing the separator format
     * @param array $style
     *
     * @return string
     */
    public static function generateAddress(Address $address, $patternRules = [], $newLine = self::FORMAT_NEW_LINE, $separator = ' ', $style = [])
    {
        $addressFields = AddressFormat::getOrderedAddressFields($address->id_country);
        $addressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($address, $addressFields);

        $addressText = '';
        foreach ($addressFields as $line) {
            if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY))) {
                $tmpText = '';
                foreach ($patternsList as $pattern) {
                    if ((!array_key_exists('avoid', $patternRules)) ||
                                (is_array($patternRules) && array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid']))) {

						// ---------------- dodane
                        if ($pattern == 'vat_number' && (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern]))) {
                            $tmpText .= 'NIP: ';
                        }
						
						if ($pattern == 'phone' && (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern]))) {
                            $tmpText .= 'Tel. ';
                        }
						// ---------------- 
            
                       
                        $tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ?
                                (((isset($style[$pattern])) ?
                                    (sprintf($style[$pattern], $addressFormatedValues[$pattern])) :
                                    $addressFormatedValues[$pattern]) . $separator) : '';
                    }
                }
                $tmpText = trim($tmpText);
                $addressText .= (!empty($tmpText)) ? $tmpText . $newLine : '';
            }
        }

        $addressText = preg_replace('/' . preg_quote($newLine, '/') . '$/i', '', $addressText);
        $addressText = rtrim($addressText, $separator);

        return $addressText;
    }
}

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, atomek said:

Umieść zawartość w pliku /override/classes/AddressFormat.php

Powinno rozwiązać problem, wyczyść cache.

 

<?php

class AddressFormat extends AddressFormatCore {
        
    /**
     * Generates the full address text.
     *
     * @param Address $address
     * @param array $patternRules A defined rules array to avoid some pattern
     * @param string $newLine A string containing the newLine format
     * @param string $separator A string containing the separator format
     * @param array $style
     *
     * @return string
     */
    public static function generateAddress(Address $address, $patternRules = [], $newLine = self::FORMAT_NEW_LINE, $separator = ' ', $style = [])
    {
        $addressFields = AddressFormat::getOrderedAddressFields($address->id_country);
        $addressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($address, $addressFields);

        $addressText = '';
        foreach ($addressFields as $line) {
            if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY))) {
                $tmpText = '';
                foreach ($patternsList as $pattern) {
                    if ((!array_key_exists('avoid', $patternRules)) ||
                                (is_array($patternRules) && array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid']))) {

						// ---------------- dodane
                        if ($pattern == 'vat_number' && (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern]))) {
                            $tmpText .= 'NIP: ';
                        }
						
						if ($pattern == 'phone' && (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern]))) {
                            $tmpText .= 'Tel. ';
                        }
						// ---------------- 
            
                       
                        $tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ?
                                (((isset($style[$pattern])) ?
                                    (sprintf($style[$pattern], $addressFormatedValues[$pattern])) :
                                    $addressFormatedValues[$pattern]) . $separator) : '';
                    }
                }
                $tmpText = trim($tmpText);
                $addressText .= (!empty($tmpText)) ? $tmpText . $newLine : '';
            }
        }

        $addressText = preg_replace('/' . preg_quote($newLine, '/') . '$/i', '', $addressText);
        $addressText = rtrim($addressText, $separator);

        return $addressText;
    }
}

 

Dziękuję bardzo za pomoc! Zadziałało dodanie NIP i Tel.

Mam jeszcze jedno pytanie.

Czy jest możliwe, aby przesunąć pole NIP: pod nazwę kraju lub pod numer telefonu?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...