├── .github └── workflows │ ├── codestyle.yml │ └── composer.yml ├── .php-cs-fixer.dist.php ├── LICENSE ├── README.md ├── SAMPLES.md ├── composer.json └── src └── Generator ├── Aperak.php ├── Base.php ├── Calinf.php ├── Codeco.php ├── Codeco └── Container.php ├── Cohaor.php ├── Coparn.php ├── Copino.php ├── Coprar.php ├── Coprar └── Container.php ├── Coreor.php ├── Desadv.php ├── Desadv └── Item.php ├── EdiFactNumber.php ├── EdifactCurrency.php ├── EdifactDate.php ├── EdifactException.php ├── Iftmbf.php ├── Iftmbf └── Container.php ├── Iftmin.php ├── Interchange.php ├── Invoic.php ├── Invoic └── Item.php ├── Message.php ├── Movins.php ├── Movins └── Container.php ├── Orders.php ├── Orders └── Item.php ├── Ordrsp.php ├── Ordrsp └── Item.php ├── Segment.php ├── Segment ├── BeginningOfMessage.php ├── ControlTotal.php ├── DateTimePeriod.php ├── EquipmentDetails.php ├── FreeText.php ├── Measurements.php ├── NameAndAddress.php ├── PercentageDetails.php ├── PlaceLocationIdentification.php ├── RangeDetails.php ├── Reference.php ├── Temperature.php └── TransportInformation.php ├── Traits ├── ContactPerson.php ├── Item.php ├── ItemPrice.php ├── NameAndAddress.php ├── Segments.php ├── TransportData.php └── VatAndCurrency.php ├── Vermas.php ├── Vermas └── Container.php ├── Westim.php └── Westim └── Damage.php /.github/workflows/codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Codestyle 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: [ $default-branch ] 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v3 17 | 18 | - name: Cache Composer packages 19 | id: composer-cache 20 | uses: actions/cache@v3 21 | with: 22 | path: vendor 23 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }} 24 | restore-keys: | 25 | ${{ runner.os }}-php- 26 | 27 | - name: Install dependencies 28 | run: composer install --prefer-dist --no-progress 29 | 30 | - name: Check code style 31 | run: composer run-script codestyle:lint 32 | -------------------------------------------------------------------------------- /.github/workflows/composer.yml: -------------------------------------------------------------------------------- 1 | name: PHP Composer 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: [ $default-branch ] 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v3 17 | 18 | - name: Validate composer.json and composer.lock 19 | run: composer validate --strict 20 | 21 | - name: Cache Composer packages 22 | id: composer-cache 23 | uses: actions/cache@v3 24 | with: 25 | path: vendor 26 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }} 27 | restore-keys: | 28 | ${{ runner.os }}-php- 29 | 30 | - name: Install dependencies 31 | run: composer install --prefer-dist --no-progress 32 | 33 | - name: Run test suite 34 | run: composer run-script test 35 | -------------------------------------------------------------------------------- /.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | in('src') 5 | ->append([__FILE__]) 6 | ; 7 | 8 | $config = new PhpCsFixer\Config(); 9 | 10 | return $config 11 | ->setRules([ 12 | '@PSR12' => true, 13 | 'array_syntax' => ['syntax' => 'short'], 14 | ]) 15 | ->setFinder($finder) 16 | ; 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The classes provided by this package give a fluent interface 2 | which simplifies the encoding of an EDI (mainly UN/EDIFACT) message. 3 | 4 | The resulting array can be encoded in a valid message with EDI\Encoder class provided 5 | by [https://github.com/PHPEdifact/edifact](https://github.com/PHPEdifact/edifact). 6 | 7 | Each message type extends a generic Message class which provides common helpers. 8 | 9 | See [SAMPLES.md](SAMPLES.md) for code examples using this library. 10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "php-edifact/edifact-generator", 3 | "description": "EDIFACT message generators", 4 | "keywords": ["EDI", "EDIFACT", "message", "generator"], 5 | "homepage": "https://github.com/php-edifact/edifact-generator", 6 | "license": "LGPL-3.0-or-later", 7 | "autoload": { 8 | "psr-4": { 9 | "EDI\\Generator\\": "src/Generator/" 10 | } 11 | }, 12 | "scripts": { 13 | "test": "vendor/bin/phpunit", 14 | "codestyle:fix": "vendor/bin/php-cs-fixer fix", 15 | "codestyle:lint": "vendor/bin/php-cs-fixer fix --dry-run" 16 | }, 17 | "require-dev": { 18 | "sabas/edifact": "^1.0", 19 | "phpunit/phpunit": "~11.0", 20 | "friendsofphp/php-cs-fixer": "^3.9.5" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Generator/Aperak.php: -------------------------------------------------------------------------------- 1 | dtmSend = self::dtmSegment(137, date('YmdHi')); 44 | $this->references = []; 45 | $this->errors = []; 46 | } 47 | 48 | /** 49 | * @param $number 50 | * @return $this 51 | */ 52 | public function setPreviousMessage($number) 53 | { 54 | $this->previousMessage = self::rffSegment('ACW', $number); 55 | 56 | return $this; 57 | } 58 | 59 | /** 60 | * @param $qualifier data element 1153 (BM bill of lading, BN booking, SQ sequence, AAQ container, AAB proforma invoice) 61 | * @param $data value 62 | * @return $this 63 | */ 64 | public function addReference($qualifier, $data) 65 | { 66 | $this->references[] = self::rffSegment($qualifier, $data); 67 | 68 | return $this; 69 | } 70 | 71 | /** 72 | * 73 | * @param $errorCode 74 | * @param $errorMessage 75 | * @return \EDI\Generator\Aperak 76 | */ 77 | public function addError($errorCode, $errorMessage = null) 78 | { 79 | $this->errors[] = ['ERC', $errorCode]; 80 | if ($errorMessage !== null) { 81 | $this->errors[] = self::addFTXSegment($errorMessage, 'AAO'); 82 | } 83 | 84 | return $this; 85 | } 86 | 87 | /** 88 | * Compose. 89 | * 90 | * @param mixed $sMessageFunctionCode (1225) 91 | * @param mixed $sDocumentNameCode (1001) 92 | * @param mixed $sDocumentIdentifier (1004) 93 | * 94 | * @return \EDI\Generator\Message ::compose() 95 | * @throws \EDI\Generator\EdifactException 96 | */ 97 | public function compose(?string $sMessageFunctionCode = "5", ?string $sDocumentNameCode = "34", ?string $sDocumentIdentifier = null): parent 98 | { 99 | $this->messageContent = [ 100 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode], 101 | ]; 102 | 103 | if ($this->dtmSend !== null) { 104 | $this->messageContent[] = $this->dtmSend; 105 | } 106 | if ($this->previousMessage !== null) { 107 | $this->messageContent[] = $this->previousMessage; 108 | } 109 | 110 | foreach ($this->references as $rff) { 111 | $this->messageContent[] = $rff; 112 | } 113 | 114 | foreach ($this->errors as $err) { 115 | $this->messageContent[] = $err; 116 | } 117 | 118 | return parent::compose(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/Generator/Base.php: -------------------------------------------------------------------------------- 1 | composeKeys[] = $keyName; 31 | } 32 | 33 | /** 34 | * compose message by keys given in an ordered array 35 | * 36 | * @param array $keys 37 | * 38 | * @return array 39 | * @throws EdifactException 40 | */ 41 | public function composeByKeys($keys = null) 42 | { 43 | if ($keys === null) { 44 | $keys = $this->composeKeys; 45 | } 46 | foreach ($keys as $key) { 47 | if (property_exists($this, $key)) { 48 | if ($this->{$key} !== null) { 49 | $value = $this->{$key}; 50 | if ($value) { 51 | $this->messageContent[] = $value; 52 | } else { 53 | throw new EdifactException("key " . $key . " returns no array structure"); 54 | } 55 | } 56 | } else { 57 | throw new EdifactException( 58 | 'key: ' . $key . ' not found for composeByKeys in ' . get_class($this) . '->' . 59 | debug_backtrace()[1]['function'] 60 | ); 61 | } 62 | } 63 | 64 | return $this->messageContent; 65 | } 66 | 67 | /** 68 | * @return array 69 | */ 70 | public function getComposed() 71 | { 72 | return $this->composed; 73 | } 74 | 75 | /** 76 | * Crop String to max char length 77 | * 78 | * @param string $string 79 | * @param int $length 80 | * 81 | * @return string 82 | */ 83 | protected static function maxChars($string, $length = 35) 84 | { 85 | if (empty($string)) { 86 | return ''; 87 | } 88 | 89 | return mb_substr($string, 0, $length); 90 | } 91 | 92 | /** 93 | * 94 | * @param $value 95 | * @param $array 96 | * @param $errorMessage 97 | * 98 | * @throws EdifactException 99 | */ 100 | protected function isAllowed($value, $array, $errorMessage = null) 101 | { 102 | if ($errorMessage === null) { 103 | $errorMessage = 'value: ' . $value . ' is not in allowed values: ' . 104 | ' [' . implode(', ', $array) . '] in ' . get_class($this) . '->' . 105 | debug_backtrace()[1]['function']; 106 | } 107 | if (!in_array($value, $array, true)) { 108 | throw new EdifactException($errorMessage); 109 | } 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/Generator/Calinf.php: -------------------------------------------------------------------------------- 1 | dtmSend = self::dtmSegment(137, date('YmdHi')); 49 | } 50 | 51 | /** 52 | * Date of the message submission 53 | * @param $dtm 54 | * @return \EDI\Generator\Calinf 55 | */ 56 | public function setDTMMessageSendingTime($dtm) 57 | { 58 | $this->dtmSend = self::dtmSegment(137, $dtm); 59 | 60 | return $this; 61 | } 62 | 63 | /** 64 | * Message sender (usually the vessel agent) 65 | * @param $code 66 | * @param $name 67 | * @return \EDI\Generator\Calinf 68 | */ 69 | public function setSender($code, $name) 70 | { 71 | $this->messageSender = ['NAD', 'MS', $code, $name]; 72 | 73 | return $this; 74 | } 75 | 76 | /** 77 | * Message receiver (usually the terminal) 78 | * @param $code 79 | * @param $name 80 | * @return \EDI\Generator\Calinf 81 | */ 82 | public function setReceiver($code, $name) 83 | { 84 | $this->messageReceiver = ['NAD', 'MR', $code, $name]; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Vessel call information 91 | * @param $extVoyage 92 | * @param $line 93 | * @param $imoNumber 94 | * @param $vslName 95 | * @param $callsign 96 | * @return \EDI\Generator\Calinf 97 | */ 98 | public function setVessel($extVoyage, $line, $imoNumber, $vslName, $callsign) 99 | { 100 | $this->vessel = ['TDT', 20, $extVoyage, '', '', [$line, 172, 20], '', '', [$imoNumber, 146, 54, $vslName]]; 101 | $this->callsign = self::rffSegment('VM', $callsign); 102 | 103 | return $this; 104 | } 105 | 106 | /** 107 | * Estimated Time of Arrival 108 | * @param $dtm 109 | * @return \EDI\Generator\Calinf 110 | */ 111 | public function setEta($dtm) 112 | { 113 | $this->eta = self::dtmSegment(132, $dtm); 114 | 115 | return $this; 116 | } 117 | 118 | /** 119 | * Estimated Time of Departure 120 | * @param $dtm 121 | * @return \EDI\Generator\Calinf 122 | */ 123 | public function setEtd($dtm) 124 | { 125 | $this->etd = self::dtmSegment(133, $dtm); 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Compose. 132 | * 133 | * @param mixed $sMessageFunctionCode (1225) 134 | * @param mixed $sDocumentNameCode (1001) 135 | * @param mixed $sDocumentIdentifier (1004) 136 | * 137 | * @return \EDI\Generator\Message ::compose() 138 | * @throws \EDI\Generator\EdifactException 139 | */ 140 | public function compose(?string $sMessageFunctionCode = '5', ?string $sDocumentNameCode = '96', ?string $sDocumentIdentifier = null): parent 141 | { 142 | $this->messageContent = [ 143 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode], 144 | ]; 145 | 146 | $this->messageContent[] = $this->dtmSend; 147 | $this->messageContent[] = $this->messageSender; 148 | $this->messageContent[] = $this->messageReceiver; 149 | $this->messageContent[] = $this->vessel; 150 | $this->messageContent[] = $this->eta; 151 | $this->messageContent[] = $this->etd; 152 | $this->messageContent[] = $this->callsign; 153 | 154 | return parent::compose(); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/Generator/Codeco.php: -------------------------------------------------------------------------------- 1 | messageSender = ['NAD', 'MS', $messageSender]; 53 | $this->messageReceiver = ['NAD', 'MR', $messageReceiver]; 54 | 55 | return $this; 56 | } 57 | 58 | /** 59 | * $line: Master Liner Codes List 60 | * @param $line 61 | * @return \EDI\Generator\Codeco 62 | */ 63 | public function setCarrier($line) 64 | { 65 | $this->messageCF = ['NAD', 'CF', [$line, 160, 166]]; 66 | 67 | return $this; 68 | } 69 | 70 | /** 71 | * @param \EDI\Generator\Codeco\Container $container 72 | * @return $this 73 | */ 74 | public function addContainer(Codeco\Container $container) 75 | { 76 | $this->containers[] = $container; 77 | 78 | return $this; 79 | } 80 | 81 | /** 82 | * Compose. 83 | * 84 | * @param mixed $sMessageFunctionCode (1225) 85 | * @param mixed $sDocumentNameCode (1001) 86 | * @param mixed $sDocumentIdentifier (1004) 87 | * 88 | * @return \EDI\Generator\Message ::compose() 89 | * @throws \EDI\Generator\EdifactException 90 | */ 91 | public function compose(?string $sMessageFunctionCode = "5", ?string $sDocumentNameCode = "34", ?string $sDocumentIdentifier = null): parent 92 | { 93 | $this->messageContent = [ 94 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode], 95 | ]; 96 | 97 | if ($this->messageSender !== null) { 98 | $this->messageContent[] = $this->messageSender; 99 | } 100 | if ($this->messageReceiver !== null) { 101 | $this->messageContent[] = $this->messageReceiver; 102 | } 103 | if ($this->messageCF !== null) { 104 | $this->messageContent[] = $this->messageCF; 105 | } 106 | 107 | foreach ($this->containers as $cntr) { 108 | $content = $cntr->compose(); 109 | foreach ($content as $segment) { 110 | $this->messageContent[] = $segment; 111 | } 112 | } 113 | 114 | $this->messageContent[] = ['CNT', [16, count($this->containers)]]; 115 | 116 | return parent::compose(); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Generator/Codeco/Container.php: -------------------------------------------------------------------------------- 1 | cntr = \EDI\Generator\Message::eqdSegment('CN', $number, [$size, '6346', '306'], '', $statusCode, $fullEmptyIndicator); 37 | 38 | return $this; 39 | } 40 | 41 | /** 42 | * @param $booking 43 | *@param $sequence 44 | * @return \EDI\Generator\Codeco\Container 45 | */ 46 | public function setBooking($booking, $sequence = null) 47 | { 48 | $this->bkg = \EDI\Generator\Message::rffSegment('BN', $booking); 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param $bl 55 | * @return \EDI\Generator\Codeco\Container 56 | */ 57 | public function setBillOfLading($bl) 58 | { 59 | $this->bkg = \EDI\Generator\Message::rffSegment('BM', $bl); 60 | 61 | return $this; 62 | } 63 | 64 | /** 65 | * $seal = free text 66 | * $sealIssuer = DE 9303 67 | * @param $seal 68 | * @param $sealIssuer 69 | * @return \EDI\Generator\Codeco\Container 70 | */ 71 | public function setSeal($seal, $sealIssuer) 72 | { 73 | $this->seal = ['SEL', [$seal, $sealIssuer]]; 74 | 75 | return $this; 76 | } 77 | 78 | /** 79 | * Date of the equipment event 80 | *@param $date 81 | * @return \EDI\Generator\Codeco\Container 82 | */ 83 | public function setEffectiveDate($date = null) 84 | { 85 | if ($date === null) { 86 | $date = date('YmdHi'); 87 | } 88 | $this->effectiveDate = \EDI\Generator\Message::dtmSegment(7, $date); 89 | 90 | return $this; 91 | } 92 | 93 | /** 94 | * $transportMode = DE 8067 (2 = rail, 3 = road) 95 | * $transportMeans = DE 8179 (25 = train, 31 = truck) 96 | * @param $transportMode 97 | * @param $transportMeans 98 | * @return \EDI\Generator\Codeco\Container 99 | */ 100 | public function setModeOfTransport($transportMode, $transportMeans) 101 | { 102 | $this->modeOfTransport = \EDI\Generator\Message::tdtShortSegment(1, '', $transportMode, $transportMeans); 103 | 104 | return $this; 105 | } 106 | 107 | /** 108 | * $type = 165 (place of delivery) 109 | * @param $locode 110 | * @return \EDI\Generator\Codeco\Container 111 | */ 112 | public function setLocation($locode) 113 | { 114 | $this->destination = \EDI\Generator\Message::locSegment(165, [$locode, 139, 6]); 115 | 116 | return $this; 117 | } 118 | 119 | /** 120 | * Weight information 121 | * $type = G (gross mass), VGM (verified gross mass) 122 | * @param $type 123 | * @param $weight 124 | * @return \EDI\Generator\Codeco\Container 125 | */ 126 | public function setWeight($type, $weight) 127 | { 128 | $this->weight = ['MEA', 'AAE', $type, ['KGM', $weight]]; 129 | 130 | return $this; 131 | } 132 | 133 | /** 134 | * @return array 135 | */ 136 | public function compose() 137 | { 138 | $composed = [$this->cntr]; 139 | if ($this->bkg !== null) { 140 | $composed[] = $this->bkg; 141 | } 142 | $composed[] = $this->effectiveDate; 143 | if ($this->destination !== null) { 144 | $composed[] = $this->destination; 145 | } 146 | if ($this->weight !== null) { 147 | $composed[] = $this->weight; 148 | } 149 | if ($this->seal !== null) { 150 | $composed[] = $this->seal; 151 | } 152 | if ($this->modeOfTransport !== null) { 153 | $composed[] = $this->modeOfTransport; 154 | } 155 | 156 | return $composed; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/Generator/Cohaor.php: -------------------------------------------------------------------------------- 1 | aSegmentGroups[$iSegmentGroupNumber][] = $aSegments; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * Compose. 57 | * 58 | * @param mixed $sMessageFunctionCode (1225) 59 | * @param mixed $sDocumentNameCode (1001) 60 | * @param mixed $sDocumentIdentifier (1004) 61 | * 62 | * @return \EDI\Generator\Message ::compose() 63 | * @throws \EDI\Generator\EdifactException 64 | */ 65 | public function compose(?string $sMessageFunctionCode = null, ?string $sDocumentNameCode = null, ?string $sDocumentIdentifier = null): parent 66 | { 67 | // BGM - Beginning of message 68 | 69 | $this->messageContent = [ 70 | ['BGM', $sDocumentNameCode, $sDocumentIdentifier, $sMessageFunctionCode], 71 | ]; 72 | 73 | // Segment Groups 74 | 75 | if (count($this->aSegmentGroups) > 0) { 76 | foreach ($this->aSegmentGroups as $iSegmentGroupNumber => $aSegmentGroup) { 77 | foreach ($aSegmentGroup as $aSegments) { 78 | foreach ($aSegments as $aSegment) { 79 | $this->messageContent[] = $aSegment; 80 | } 81 | } 82 | } 83 | } 84 | 85 | return parent::compose(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Generator/Copino.php: -------------------------------------------------------------------------------- 1 | sender = ['NAD', 'MS', $sender]; 57 | $this->receiver = ['NAD', 'MR', $receiver]; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * trucker 64 | * @param $transRef 65 | * @param $modeOfTransport 66 | * @param $meansOfTransport 67 | * @param $carrierName 68 | * @param $plate 69 | * @param $driver 70 | * @return \EDI\Generator\Copino 71 | */ 72 | public function setTransporter($transRef, $modeOfTransport, $meansOfTransport, $carrierName, $plate, $driver) 73 | { 74 | $this->transporter = self::tdtSegment(1, $transRef, $modeOfTransport, $meansOfTransport, $carrierName, '', '', [$plate, 146, '', $driver]); 75 | 76 | return $this; 77 | } 78 | 79 | /** 80 | * vessel 81 | * @param $carrierName 82 | * @param $callsign 83 | * @param $vesselName 84 | * @return \EDI\Generator\Copino 85 | */ 86 | 87 | public function setVessel($carrierName, $callsign, $vesselName) 88 | { 89 | $this->vessel = self::tdtSegment(20, '', 1, 13, $carrierName, '', '', [$callsign, 103, '', $vesselName]); 90 | 91 | return $this; 92 | } 93 | 94 | /** 95 | *$type = 7 (actual date time), 132 (estimated date time) 96 | * @param $dtm 97 | * @return \EDI\Generator\Copino 98 | */ 99 | public function setDTM($dtm) 100 | { 101 | $this->dtm = self::dtmSegment(132, $dtm); 102 | 103 | return $this; 104 | } 105 | 106 | /** 107 | * $size = 22G1, 42G1, ecc 108 | * 2 = export, 5 = full 109 | * @param $number 110 | * @param $size 111 | * @param $booking 112 | * @param $sequence 113 | * @return \EDI\Generator\Copino 114 | */ 115 | public function setContainer($number, $size, $booking, $sequence) 116 | { 117 | $cntr = []; 118 | $cntr[] = ['SGP', $number]; 119 | $cntr[] = self::eqdSegment('CN', $number, [$size, '102', '5'], '', 2, 5); 120 | $cntr[] = self::rffSegment('BN', $booking); 121 | $cntr[] = self::rffSegment('SQ', $sequence); 122 | $this->cntr = $cntr; 123 | 124 | return $this; 125 | } 126 | 127 | /** 128 | * $weightMode = DE 6313 129 | * $weight = free text 130 | * $unit = KGM or LBS 131 | * @param $weightMode 132 | * @param $weight 133 | * @param string $unit 134 | * @return \EDI\Generator\Copino 135 | */ 136 | public function setMeasures($weightMode, $weight, $unit = 'KGM') 137 | { 138 | $this->measures = ['MEA', 'AAE', $weightMode, [$unit, $weight]]; 139 | 140 | return $this; 141 | } 142 | 143 | /** 144 | * $type = 88 (place of receipt) 145 | * @param $locode 146 | * @param $terminal 147 | * @return \EDI\Generator\Copino 148 | */ 149 | public function setPort($locode, $terminal) 150 | { 151 | $this->port = self::locSegment(88, [$locode, 139, 6], [$terminal, 72, 306]); 152 | 153 | return $this; 154 | } 155 | 156 | /** 157 | * $type = 7 (place of delivery) 158 | * @param $locode 159 | * @return \EDI\Generator\Copino 160 | */ 161 | public function setDestination($locode) 162 | { 163 | $this->destination = self::locSegment(7, [$locode, 139, 6]); 164 | 165 | return $this; 166 | } 167 | 168 | /** 169 | * Compose. 170 | * 171 | * @param mixed $sMessageFunctionCode (1225) 172 | * @param mixed $sDocumentNameCode (1001) 173 | * @param mixed $sDocumentIdentifier (1004) 174 | * 175 | * @return \EDI\Generator\Message ::compose() 176 | * @throws \EDI\Generator\EdifactException 177 | */ 178 | public function compose(?string $sMessageFunctionCode = "9", ?string $sDocumentNameCode = "661", ?string $sDocumentIdentifier = null): parent 179 | { 180 | $this->messageContent = [ 181 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode], 182 | self::rffSegment('XXX', 1), 183 | ]; 184 | 185 | if (count($this->transporter) > 0) { 186 | $this->messageContent[] = $this->transporter; 187 | } 188 | 189 | $this->messageContent[] = $this->port; 190 | $this->messageContent[] = $this->dtm; 191 | $this->messageContent[] = $this->sender; 192 | $this->messageContent[] = $this->receiver; 193 | $this->messageContent[] = ['GID', 1]; 194 | 195 | foreach ($this->cntr as $segment) { 196 | $this->messageContent[] = $segment; 197 | } 198 | 199 | $this->messageContent[] = $this->measures; 200 | $this->messageContent[] = $this->vessel; 201 | $this->messageContent[] = $this->destination; 202 | $this->messageContent[] = ['CNT', [16, 1]]; 203 | 204 | return parent::compose(); 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /src/Generator/Coprar.php: -------------------------------------------------------------------------------- 1 | messageDate = self::dtmSegment(137, date('YmdHi')); 48 | } 49 | 50 | /** 51 | * Message date 52 | * @param $dtm 53 | * @return \EDI\Generator\Coprar 54 | */ 55 | public function setMessageDate($dtm) 56 | { 57 | $this->messageDate = self::dtmSegment(137, $dtm); 58 | 59 | if ($dtm === null) { 60 | $this->messageDate = null; 61 | } 62 | 63 | return $this; 64 | } 65 | 66 | /** 67 | * $line: Master Liner Codes List 68 | * @param $line 69 | * @return \EDI\Generator\Coprar 70 | */ 71 | public function setCarrier($line) 72 | { 73 | $this->messageCA = ['NAD', 'CA', [$line, 160, 20]]; 74 | 75 | return $this; 76 | } 77 | 78 | /** 79 | * Vessel call information 80 | * @param $extVoyage 81 | * @param $line 82 | * @param $vslName 83 | * @param $callsign 84 | * @return \EDI\Generator\Coprar 85 | */ 86 | public function setVessel($extVoyage, $line, $vslName, $callsign) 87 | { 88 | $this->vessel = self::tdtSegment(20, $extVoyage, 1, '', [$line, 172, 20], '', '', [$callsign, 103, '', $vslName]); 89 | 90 | return $this; 91 | } 92 | 93 | /** 94 | * $type = 9 (port of loading), 11 (port of discharge) 95 | * @param $type 96 | * @param $locode 97 | * @param $terminal 98 | * @return \EDI\Generator\Coprar 99 | */ 100 | public function setPort($type, $locode, $terminal = null) 101 | { 102 | if ($terminal === null) { 103 | $this->port = self::locSegment($type, [$locode, 139, 6]); 104 | } else { 105 | $this->port = self::locSegment($type, [$locode, 139, 6], [$terminal, "TER", "ZZZ"]); 106 | } 107 | 108 | return $this; 109 | } 110 | 111 | /** 112 | * Estimated Time of Arrival 113 | * @param $dtm 114 | * @return \EDI\Generator\Coprar 115 | */ 116 | public function setEta($dtm) 117 | { 118 | $this->eta = self::dtmSegment(132, $dtm); 119 | 120 | return $this; 121 | } 122 | 123 | /** 124 | * Estimated Time of Departure 125 | * @param $dtm 126 | * @return \EDI\Generator\Coprar 127 | */ 128 | public function setEtd($dtm) 129 | { 130 | $this->etd = self::dtmSegment(133, $dtm); 131 | 132 | return $this; 133 | } 134 | 135 | /** 136 | * @param \EDI\Generator\Coprar\Container $container 137 | * @return $this 138 | */ 139 | public function addContainer(Coprar\Container $container) 140 | { 141 | $this->containers[] = $container; 142 | 143 | return $this; 144 | } 145 | 146 | /** 147 | * @param $container 148 | * @return $this 149 | */ 150 | public function addContainerSegments($container) 151 | { 152 | $this->containers[] = $container; 153 | 154 | return $this; 155 | } 156 | 157 | /** 158 | * Compose. 159 | * 160 | * @param mixed $sMessageFunctionCode (1225) 161 | * @param mixed $sDocumentNameCode (1001) in D00B 118 discharge, 121 loading, in D95B 43 discharge, 45 loading 162 | * @param mixed $sDocumentIdentifier (1004) 163 | * 164 | * @return \EDI\Generator\Message ::compose() 165 | * @throws \EDI\Generator\EdifactException 166 | */ 167 | public function compose(?string $sMessageFunctionCode = "9", ?string $sDocumentNameCode = "121", ?string $sDocumentIdentifier = null): parent 168 | { 169 | $this->messageContent = [ 170 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode], 171 | self::rffSegment('XXX', 1), 172 | ]; 173 | 174 | if ($this->messageDate !== null) { 175 | $this->messageContent[] = $this->messageDate; 176 | } 177 | $this->messageContent[] = $this->vessel; 178 | $this->messageContent[] = $this->port; 179 | $this->messageContent[] = $this->eta; 180 | $this->messageContent[] = $this->etd; 181 | $this->messageContent[] = $this->messageCA; 182 | 183 | foreach ($this->containers as $cntr) { 184 | $content = $cntr; 185 | 186 | if (is_a($cntr, 'EDI\Generator\Coprar\Container')) { 187 | $content = $cntr->compose(); 188 | } 189 | 190 | foreach ($content as $segment) { 191 | $this->messageContent[] = $segment; 192 | } 193 | } 194 | 195 | $this->messageContent[] = ['CNT', [16, count($this->containers)]]; 196 | 197 | return parent::compose(); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /src/Generator/Coprar/Container.php: -------------------------------------------------------------------------------- 1 | cntr = \EDI\Generator\Message::eqdSegment('CN', $number, [$size, '102', '5'], '', $statusCode, $fullEmptyIndicator); 46 | 47 | return $this; 48 | } 49 | 50 | /** 51 | * @param $booking 52 | *@param $sequence 53 | * @return \EDI\Generator\Coprar\Container 54 | */ 55 | public function setBooking($booking, $sequence = null) 56 | { 57 | $this->bkg = \EDI\Generator\Message::rffSegment('BN', $booking); 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * @param $bl 64 | * @return \EDI\Generator\Coprar\Container 65 | */ 66 | public function setBillOfLading($bl) 67 | { 68 | $this->bkg = \EDI\Generator\Message::rffSegment('BM', $bl); 69 | 70 | return $this; 71 | } 72 | 73 | /** 74 | * Port of Discharge 75 | * @param $loc 76 | * @return \EDI\Generator\Coprar\Container 77 | */ 78 | public function setPOL($loc) 79 | { 80 | $this->pol = \EDI\Generator\Message::locSegment(9, [$loc, 139, 6]); 81 | 82 | return $this; 83 | } 84 | 85 | /** 86 | * Port of Discharge 87 | * @param $loc 88 | * @return \EDI\Generator\Coprar\Container 89 | */ 90 | public function setPOD($loc) 91 | { 92 | $this->pod = \EDI\Generator\Message::locSegment(11, [$loc, 139, 6]); 93 | 94 | return $this; 95 | } 96 | 97 | /** 98 | * Final destination 99 | * @param $loc 100 | * @return \EDI\Generator\Coprar\Container 101 | */ 102 | public function setFND($loc) 103 | { 104 | $this->fnd = \EDI\Generator\Message::locSegment(7, [$loc, 139, 6]); 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * VGM information 111 | * @param $weight 112 | * @param $weightTime 113 | * @return \EDI\Generator\Coprar\Container 114 | */ 115 | public function setVGM($weight, $weightTime) 116 | { 117 | $this->weight = ['MEA', 'AAE', 'VGM', ['KGM', $weight]]; 118 | $this->weightTime = \EDI\Generator\Message::dtmSegment(798, $weightTime); 119 | 120 | return $this; 121 | } 122 | 123 | /** 124 | * Weight information 125 | * @param $weight 126 | * @return \EDI\Generator\Coprar\Container 127 | */ 128 | public function setGrossWeight($weight) 129 | { 130 | $this->weight = ['MEA', 'AAE', 'G', ['KGM', $weight]]; 131 | 132 | return $this; 133 | } 134 | 135 | /** 136 | * Weight information 137 | * $type = T (tare), AET (gross weight) 138 | * @param $weight 139 | * @return \EDI\Generator\Coreor 140 | */ 141 | public function setTare($weight) 142 | { 143 | $this->tare = ['MEA', 'AAE', 'T', ['KGM', $weight]]; 144 | 145 | return $this; 146 | } 147 | 148 | /** 149 | * $seal = free text 150 | * $sealIssuer = DE 9303 151 | * @param $seal 152 | * @param $sealIssuer 153 | * @return \EDI\Generator\Coprar\Container 154 | */ 155 | public function setSeal($seal, $sealIssuer) 156 | { 157 | $this->seal = ['SEL', [$seal, $sealIssuer]]; 158 | 159 | return $this; 160 | } 161 | 162 | /** 163 | * Cargo category 164 | * @param $text 165 | * @return \EDI\Generator\Coprar\Container 166 | */ 167 | public function setCargoCategory($text) 168 | { 169 | $this->cargo = ['FTX', 'AAA', '', '', $text]; 170 | 171 | return $this; 172 | } 173 | 174 | /** 175 | * Special instructions 176 | * @param $text 177 | * @return \EDI\Generator\Coprar\Container 178 | */ 179 | public function setSpecialInstructions($text) 180 | { 181 | $this->specialInstructions = ['FTX', 'SIN', '', '', $text]; 182 | 183 | return $this; 184 | } 185 | 186 | /** 187 | * DEPRECATED 188 | * @param $hazardClass 189 | * @param $hazardCode 190 | * @return \EDI\Generator\Coprar\Container 191 | */ 192 | public function setDangerous($hazardClass, $hazardCode) 193 | { 194 | $this->addDangerous($hazardClass, $hazardCode); 195 | 196 | return $this; 197 | } 198 | 199 | /** 200 | * @param $hazardClass 201 | * @param $hazardCode 202 | *@param $flashpoint 203 | *@param $packingGroup 204 | * @return $this 205 | */ 206 | public function addDangerous($hazardClass, $hazardCode, $flashpoint = null, $packingGroup = null) 207 | { 208 | if ($this->dangerous === null) { 209 | $this->dangerous = []; 210 | } 211 | 212 | $dgs = ['DGS', 'IMD', $hazardClass, $hazardCode]; 213 | if ($flashpoint !== null) { 214 | if ($flashpoint != '') { 215 | $flashpoint = [$flashpoint, 'CEL']; 216 | } 217 | $dgs[] = $flashpoint; 218 | if ($packingGroup !== null) { 219 | $dgs[] = $packingGroup; 220 | } 221 | } 222 | 223 | $this->dangerous[] = $dgs; 224 | 225 | return $this; 226 | } 227 | 228 | /** 229 | * @param $addInfo 230 | * @return $this 231 | */ 232 | public function setDangerousAdditionalInfo($addInfo) 233 | { 234 | $this->dgsAac = ['FTX', 'AAC', '', '', $addInfo]; 235 | 236 | return $this; 237 | } 238 | 239 | /** 240 | * @param $setDegrees 241 | * @return $this 242 | */ 243 | public function setTemperature($setDegrees) 244 | { 245 | $this->temperature = ['TMP', '2', [$setDegrees, 'CEL']]; 246 | 247 | return $this; 248 | } 249 | 250 | /** 251 | * @param string $front 252 | * @param string $back 253 | * @param string $right 254 | * @param string $left 255 | * @param string $height 256 | * @return $this 257 | */ 258 | public function setOverDimensions($front = '', $back = '', $right = '', $left = '', $height = '') 259 | { 260 | $this->dim = []; 261 | if ($front !== '') { 262 | $this->dimensions[] = ['DIM', '5', ['CMT', $front]]; 263 | } 264 | if ($back !== '') { 265 | $this->dimensions[] = ['DIM', '6', ['CMT', $back]]; 266 | } 267 | if ($right !== '') { 268 | $this->dimensions[] = ['DIM', '7', ['CMT', '', $right]]; 269 | } 270 | if ($left !== '') { 271 | $this->dimensions[] = ['DIM', '8', ['CMT', '', $left]]; 272 | } 273 | if ($height !== '') { 274 | $this->dimensions[] = ['DIM', '13', ['CMT', '', '', $height]]; 275 | } 276 | 277 | return $this; 278 | } 279 | 280 | /** 281 | * $line: Master Liner Codes List 282 | * @param $line 283 | * @return \EDI\Generator\Coprar\Container 284 | */ 285 | public function setContainerOperator($line) 286 | { 287 | $this->containerOperator = ['NAD', 'CF', [$line, 160, 20]]; 288 | 289 | return $this; 290 | } 291 | 292 | /** 293 | * @param $handlingCode 294 | * @return $this 295 | */ 296 | public function addHandling($handlingCode) 297 | { 298 | if ($this->handling === null) { 299 | $this->handling = []; 300 | } 301 | 302 | $this->dangerous[] = ['HAN', $handlingCode]; 303 | 304 | return $this; 305 | } 306 | 307 | /** 308 | * @return array 309 | */ 310 | public function compose() 311 | { 312 | $composed = [$this->cntr]; 313 | if ($this->bkg !== null) { 314 | $composed[] = $this->bkg; 315 | } 316 | if ($this->weightTime !== null) { 317 | $composed[] = $this->weightTime; 318 | } 319 | if ($this->pol !== null) { 320 | $composed[] = $this->pol; 321 | } 322 | if ($this->pod !== null) { 323 | $composed[] = $this->pod; 324 | } 325 | $composed[] = $this->fnd; 326 | $composed[] = $this->weight; 327 | if ($this->tare !== null) { 328 | $composed[] = $this->tare; 329 | } 330 | if ($this->seal !== null) { 331 | $composed[] = $this->seal; 332 | } 333 | if ($this->dimensions !== null) { 334 | foreach ($this->dimensions as $segment) { 335 | $composed[] = $segment; 336 | } 337 | } 338 | if ($this->temperature !== null) { 339 | $composed[] = $this->temperature; 340 | } 341 | if ($this->cargo !== null) { 342 | $composed[] = $this->cargo; 343 | } 344 | if ($this->specialInstructions !== null) { 345 | $composed[] = $this->specialInstructions; 346 | } 347 | if ($this->dangerous !== null) { 348 | foreach ($this->dangerous as $segment) { 349 | $composed[] = $segment; 350 | } 351 | } 352 | if ($this->dgsAac !== null) { 353 | $composed[] = $this->dgsAac; 354 | } 355 | 356 | if ($this->handling !== null) { 357 | foreach ($this->handling as $segment) { 358 | $composed[] = $segment; 359 | } 360 | } 361 | 362 | $composed[] = $this->containerOperator; 363 | 364 | return $composed; 365 | } 366 | } 367 | -------------------------------------------------------------------------------- /src/Generator/Desadv.php: -------------------------------------------------------------------------------- 1 | items = []; 77 | } 78 | 79 | /** 80 | * @param $item Item 81 | */ 82 | public function addItem($item) 83 | { 84 | $this->items[] = $item; 85 | } 86 | 87 | 88 | /** 89 | * Set deliver note number 90 | * @param string $documentType 91 | * @param $number 92 | * @return $this 93 | * @throws EdifactException 94 | */ 95 | public function setDeliveryNoteNumber($documentType, $number) 96 | { 97 | $this->isAllowed($documentType, [ 98 | self::DELIVERY_ADVICE, 99 | self::DELIVER_NOTE, 100 | self::DELIVERY_NOTE_ADVICE 101 | ]); 102 | $this->deliveryNoteNumber = ['BGM', $documentType, $number]; 103 | return $this; 104 | } 105 | 106 | /** 107 | * @return array 108 | */ 109 | public function getDeliverNoteNumber() 110 | { 111 | return $this->deliveryNoteNumber; 112 | } 113 | 114 | /** 115 | * @return array 116 | */ 117 | public function getShippingDate() 118 | { 119 | return $this->shippingDate; 120 | } 121 | 122 | /** 123 | * @param string|\DateTime $shippingDate 124 | * @return $this 125 | * @throws EdifactException 126 | */ 127 | public function setShippingDate($shippingDate) 128 | { 129 | $this->shippingDate = $this->addDTMSegment($shippingDate, '17'); 130 | return $this; 131 | } 132 | 133 | /** 134 | * @return array 135 | */ 136 | public function getDeliveryDate() 137 | { 138 | return $this->deliveryDate; 139 | } 140 | 141 | /** 142 | * @param string|\DateTime $deliveryDate 143 | * @return $this 144 | * @throws EdifactException 145 | */ 146 | public function setDeliveryDate($deliveryDate) 147 | { 148 | $this->deliveryDate = $this->addDTMSegment($deliveryDate, '11'); 149 | return $this; 150 | } 151 | 152 | /** 153 | * @return array 154 | */ 155 | public function getDeliveryNoteDate() 156 | { 157 | return $this->deliveryNoteDate; 158 | } 159 | 160 | /** 161 | * @param string|\DateTime $deliveryNoteDate 162 | * @return $this 163 | * @throws EdifactException 164 | */ 165 | public function setDeliveryNoteDate($deliveryNoteDate) 166 | { 167 | $this->deliveryNoteDate = $this->addDTMSegment($deliveryNoteDate, '137'); 168 | return $this; 169 | } 170 | 171 | 172 | /** 173 | * @return $this 174 | * @throws EdifactException 175 | */ 176 | public function compose() 177 | { 178 | $this->composeByKeys(); 179 | 180 | foreach ($this->items as $item) { 181 | $composed = $item->compose(); 182 | foreach ($composed as $entry) { 183 | $this->messageContent[] = $entry; 184 | } 185 | } 186 | 187 | parent::compose(); 188 | 189 | return $this; 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /src/Generator/Desadv/Item.php: -------------------------------------------------------------------------------- 1 | format($dateFormat); 70 | } 71 | 72 | /** 73 | * @param string|\DateTime $date 74 | * @param integer $format 75 | * 76 | * @return bool|\DateTime 77 | */ 78 | public static function parseFormat($date, $format = self::DATE) 79 | { 80 | if ($date instanceof \DateTime) { 81 | return $date; 82 | } 83 | 84 | $parseFormat = 'Y-m-d'; 85 | switch ($format) { 86 | case self::DATE: 87 | $date = substr($date, 0, 10); 88 | break; 89 | case 90 | 91 | self::DATETIME: 92 | $parseFormat = 'Y-m-d H:i:s'; 93 | if (strlen($date) === 16) { 94 | $parseFormat = 'Y-m-d H:i'; 95 | } 96 | break; 97 | } 98 | 99 | return \DateTime::createFromFormat($parseFormat, $date); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Generator/EdifactException.php: -------------------------------------------------------------------------------- 1 | goodsID = $goodsID; 24 | } 25 | 26 | /** 27 | * $size = 22G1, 42G1, etc; 306 = smdg, 6436 = ISO spec 28 | * $statusCode = 1 (Continental), 2 (Export), 3 (Import) 29 | * $fullEmptyIndicator = 4 (Empty), 5 (Full) 30 | * @param $size 31 | * @return \EDI\Generator\Iftmbf\Container 32 | */ 33 | public function setContainer($size) 34 | { 35 | $this->cntr = \EDI\Generator\Message::eqdSegment('CN', $this->goodsID, [$size, '102', '5'], '', 2, 5); 36 | 37 | return $this; 38 | } 39 | 40 | /** 41 | * Add the array counter as id for this group 42 | * @param $id 43 | * @return \EDI\Generator\Iftmbf\Container 44 | */ 45 | public function setGoodsID($id) 46 | { 47 | $this->goodsID = $id; 48 | 49 | return $this; 50 | } 51 | 52 | /** 53 | * Goods description 54 | * @param $description 55 | * @return \EDI\Generator\Iftmbf\Container 56 | */ 57 | public function setGoodsDescription($description) 58 | { 59 | $description = str_split($description, 35); 60 | $this->goodsDescription = ['FTX', 'AAA', '', '', $description]; 61 | 62 | return $this; 63 | } 64 | 65 | /** 66 | * Goods weight 67 | * @param $weight 68 | * @param string $unit 69 | * @return \EDI\Generator\Iftmbf\Container 70 | */ 71 | public function setWeight($weight, $unit = 'KGM') 72 | { 73 | $this->weight = ['MEA', 'AAE', 'G', [$unit, $weight]]; 74 | $this->weightEq = ['MEA', 'AAE', 'AAL', [$unit, $weight]]; 75 | 76 | return $this; 77 | } 78 | 79 | /** 80 | * Goods pick up location 81 | * $code Code identifying the pick up location 82 | * $name Company name (max 70 chars) 83 | * $address Address (max 105 chars) 84 | * $postalCode ZIP Code 85 | * @param $code 86 | * @param $name 87 | * @param $address 88 | * @param $postalCode 89 | * @return \EDI\Generator\Iftmbf\Container 90 | */ 91 | public function setShipFrom($code, $name, $address, $postalCode) 92 | { 93 | $name = str_split($name, 35); 94 | $address = str_split($address, 35); 95 | 96 | $this->shipFrom = ['NAD', 'SF', [$code, 160, 'ZZZ'], array_merge($name, $address), '', '', '', '', $postalCode]; 97 | 98 | return $this; 99 | } 100 | 101 | /** 102 | * @param $date 103 | * @return $this 104 | */ 105 | public function setShipDate($date) 106 | { 107 | $this->shipDate = self::dtmSegment(200, $date); 108 | 109 | return $this; 110 | } 111 | 112 | /** 113 | * $cntType: RP = responsible person (DE 3139) 114 | * $cntTitle: free text 115 | * $comData: free text 116 | * $comType: DE 3155 117 | * @param $cntType 118 | * @param $cntTitle 119 | *@param $comType 120 | *@param $comData 121 | * @return \EDI\Generator\Iftmbf\Container 122 | */ 123 | public function setShipContact($cntType, $cntTitle, $comType = null, $comData = null) 124 | { 125 | $this->shipContact = []; 126 | $this->shipContact[] = ['CTA', $cntType, ['', $cntTitle]]; 127 | if ($comType !== null) { 128 | $this->shipContact[] = ['COM', [$comData, $comType]]; 129 | } 130 | 131 | return $this; 132 | } 133 | 134 | /** 135 | * @return array 136 | */ 137 | public function composeGoods() 138 | { 139 | $composed = [ 140 | ['GID', $this->goodsID], 141 | $this->goodsDescription, 142 | $this->weight, 143 | ]; 144 | 145 | return $composed; 146 | } 147 | 148 | /** 149 | * @return array 150 | */ 151 | public function composeEquipment() 152 | { 153 | $composed = [ 154 | $this->cntr, 155 | ['EQN', 1], 156 | $this->weightEq, 157 | ]; 158 | if ($this->shipFrom !== null) { 159 | $composed[] = $this->shipFrom; 160 | if ($this->shipContact !== null) { 161 | $composed[] = $this->shipContact[0]; 162 | if (isset($this->shipContact[1])) { 163 | $composed[] = $this->shipContact[1]; 164 | } 165 | } 166 | } 167 | 168 | return $composed; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/Generator/Iftmin.php: -------------------------------------------------------------------------------- 1 | dtmSend = self::dtmSegment(137, date('YmdHi')); 42 | 43 | $this->containers = []; 44 | } 45 | 46 | /** 47 | * @param string $name 48 | * @param $email 49 | * @return $this|\EDI\Generator\Message 50 | */ 51 | public function setSenderInformation($name, $email) 52 | { 53 | $this->messageSender = ['CTA', 'BK', ['', $name]]; 54 | $this->messageSenderInformation = ['COM', [$email, 'EM']]; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param $earliest 60 | * @param $latest 61 | * @return $this 62 | */ 63 | public function setPickupDateRange($earliest, $latest) 64 | { 65 | $this->pickupDate = [self::dtmSegment(234, $earliest), self::dtmSegment(235, $latest)]; 66 | return $this; 67 | } 68 | 69 | /** 70 | * @param $earliest 71 | * @param $latest 72 | * @return $this 73 | */ 74 | public function setDeliveryDateRange($earliest, $latest) 75 | { 76 | $this->deliveryDate = [self::dtmSegment(64, $earliest), self::dtmSegment(63, $latest)]; 77 | return $this; 78 | } 79 | 80 | /** 81 | * @param $date 82 | * @return $this 83 | */ 84 | public function setDeliveryDate($date) 85 | { 86 | $this->deliveryDate = self::dtmSegment(2, $date); 87 | return $this; 88 | } 89 | 90 | /** 91 | * $currency ISO 4217-3 92 | * @param $price 93 | * @param $currency 94 | * @return \EDI\Generator\Iftmin 95 | */ 96 | public function setAgreedAmount($price, $currency) 97 | { 98 | $this->agreedAmount = ['MOA', [121, $price, $currency]]; 99 | return $this; 100 | } 101 | 102 | /** 103 | * Free text instructions 104 | * $ftx Max 512*5 chars 105 | * @param $ftx 106 | * @return \EDI\Generator\Iftmin 107 | */ 108 | public function setFreeTextInstructions($ftx) 109 | { 110 | $this->freeTextInstructions = ['FTX', 'AAI', '', '', str_split($ftx, 512)]; 111 | return $this; 112 | } 113 | 114 | /** 115 | * Estimated weight in tonnes 116 | * @param $weight 117 | * @return \EDI\Generator\Iftmin 118 | */ 119 | public function setEstimatedWeight($weight) 120 | { 121 | $this->weight = ['CNT', ['7', $weight, 'TNE']]; 122 | $this->weightKg = ['MEA', 'WT', 'AET', ['KGM', $weight]]; 123 | return $this; 124 | } 125 | 126 | /** 127 | * Cargo nature 128 | * $cargo DE 7085 129 | * @param $cargo 130 | * @return \EDI\Generator\Iftmin 131 | */ 132 | public function setCargoNature($cargo) 133 | { 134 | $this->cargoNature = ['GDS', $cargo]; 135 | return $this; 136 | } 137 | 138 | /** 139 | * @param $adn 140 | * @return $this 141 | */ 142 | public function setTransportOrderNumber($adn) 143 | { 144 | $this->transportOrderNumber = self::rffSegment('ADN', $adn); 145 | return $this; 146 | } 147 | 148 | /** 149 | * @param $booking 150 | * @param string $bookingType 151 | *@param $sequence 152 | * @return $this 153 | */ 154 | public function setBooking($booking, $bookingType = 'BN', $sequence = null) 155 | { 156 | $this->booking = self::rffSegment($bookingType, $booking); 157 | if ($sequence !== null) { 158 | $this->bookingSequence = self::rffSegment('SQ', $sequence); 159 | } 160 | return $this; 161 | } 162 | 163 | /** 164 | * Vessel call information 165 | * @param $extVoyage 166 | * @param $line 167 | * @param $vslName 168 | * @param $callsign 169 | * @return \EDI\Generator\Iftmin 170 | */ 171 | public function setVessel($extVoyage, $line, $vslName, $callsign) 172 | { 173 | $this->vessel = self::tdtSegment(20, $extVoyage, '', '', [$line, 172, 20], '', '', [$callsign, 146, 11, $vslName]); 174 | return $this; 175 | } 176 | 177 | /** 178 | * Consignee / Consignor 179 | * 180 | * $what = CN (Consignee) / CZ (Consignor) 181 | * $code = usually VAT 182 | * $name 183 | * $address 184 | * @param $what 185 | * @param $code 186 | * @param $name 187 | * @param $address 188 | * @param $postalCode 189 | * @return \EDI\Generator\Iftmin 190 | */ 191 | public function setConsignment($what, $code, $name, $address, $postalCode) 192 | { 193 | $name = str_split($name, 35); 194 | $address = str_split($address, 35); 195 | 196 | $this->forwarder = ['NAD', $what, $code, '', $name, $address, '', '', $postalCode]; 197 | return $this; 198 | } 199 | 200 | /** 201 | * @param string|null $sMessageFunctionCode 202 | * @param string|null $sDocumentNameCode 203 | * @param string|null $sDocumentIdentifier 204 | * @return \EDI\Generator\Message 205 | * @throws \EDI\Generator\EdifactException 206 | */ 207 | public function compose(?string $sMessageFunctionCode = "5", ?string $sDocumentNameCode = "171", ?string $sDocumentIdentifier = null): parent 208 | { 209 | $this->messageContent = [ 210 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode] 211 | ]; 212 | $this->messageContent[] = $this->messageSender; 213 | $this->messageContent[] = $this->messageSenderInformation; 214 | $this->messageContent[] = $this->dtmSend; 215 | if (isset($this->pickupDate)) { 216 | $this->messageContent[] = $this->pickupDate[0]; 217 | $this->messageContent[] = $this->pickupDate[1]; 218 | } 219 | if (isset($this->deliveryDate)) { 220 | if (count($this->deliveryDate) > 2) { 221 | $this->messageContent[] = $this->deliveryDate[0]; 222 | $this->messageContent[] = $this->deliveryDate[1]; 223 | } else { 224 | $this->messageContent[] = $this->deliveryDate; 225 | } 226 | } 227 | if ($this->agreedAmount !== null) { 228 | $this->messageContent[] = $this->agreedAmount; 229 | } 230 | if ($this->freeTextInstructions !== null) { 231 | $this->messageContent[] = $this->freeTextInstructions; 232 | } 233 | if ($this->weight !== null) { 234 | $this->messageContent[] = $this->weight; 235 | } 236 | if ($this->cargoNature !== null) { 237 | $this->messageContent[] = $this->cargoNature; 238 | } 239 | if ($this->transportOrderNumber !== null) { 240 | $this->messageContent[] = $this->transportOrderNumber; 241 | } 242 | if ($this->booking !== null) { 243 | $this->messageContent[] = $this->booking; 244 | } 245 | if ($this->bookingSequence !== null) { 246 | $this->messageContent[] = $this->bookingSequence; 247 | } 248 | if ($this->vessel !== null) { 249 | $this->messageContent[] = $this->vessel; 250 | 251 | } 252 | if ($this->weightKg !== null) { 253 | $this->messageContent[] = $this->weightKg; 254 | } 255 | return parent::compose(); 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /src/Generator/Interchange.php: -------------------------------------------------------------------------------- 1 | messages = []; 30 | 31 | if ($interchangeCode === null) { 32 | $this->interchangeCode = 'I' . strtoupper(uniqid()); 33 | } else { 34 | $this->interchangeCode = $interchangeCode; 35 | } 36 | 37 | $this->sender = $sender; 38 | $this->receiver = $receiver; 39 | if ($date === null) { 40 | $this->date = date('ymd'); 41 | } else { 42 | $this->date = $date; 43 | } 44 | if ($time === null) { 45 | $this->time = date('Hi'); 46 | } else { 47 | $this->time = $time; 48 | } 49 | 50 | $this->charset = ['UNOA', 2]; 51 | } 52 | 53 | /** 54 | * Change the default character set 55 | * $identifier Syntax identifier 56 | * $version Syntax version 57 | * @param $identifier 58 | * @param $version 59 | * @return $this 60 | */ 61 | public function setCharset($identifier, $version) 62 | { 63 | $this->charset = [$identifier, $version]; 64 | 65 | return $this; 66 | } 67 | 68 | /** 69 | * Set the application reference 70 | * $appref Application reference 71 | * @param $appref 72 | * @return $this 73 | */ 74 | public function setApplicationReference($appref) 75 | { 76 | $this->appref = $appref; 77 | 78 | return $this; 79 | } 80 | 81 | /** 82 | * Add a Message to the Interchange 83 | * @param $msg 84 | * @return $this 85 | */ 86 | public function addMessage($msg) 87 | { 88 | $this->messages[] = $msg; 89 | 90 | return $this; 91 | } 92 | 93 | /** 94 | * Return the messages array 95 | * @return array 96 | */ 97 | public function getMessages() 98 | { 99 | return $this->messages; 100 | } 101 | 102 | /** 103 | * Format the Interchange segments 104 | * @return $this 105 | */ 106 | public function compose() 107 | { 108 | $temp = []; 109 | $unb = ['UNB', $this->charset, $this->sender, $this->receiver, [$this->date, $this->time], $this->interchangeCode]; 110 | if ($this->appref !== null) { 111 | $unb[] = ''; 112 | $unb[] = $this->appref; 113 | } 114 | 115 | $temp[] = $unb; 116 | foreach ($this->messages as $msg) { 117 | $msgContent = $msg->getComposed(); 118 | if ($msgContent === null) { 119 | $msgContent = $msg->compose()->getComposed(); 120 | } 121 | foreach ($msgContent as $i) { 122 | $temp[] = $i; 123 | } 124 | } 125 | $temp[] = ['UNZ', (string)count($this->messages), $this->interchangeCode]; 126 | $this->composed = $temp; 127 | 128 | return $this; 129 | } 130 | 131 | /** 132 | * Return composed message as array 133 | * @return array 134 | */ 135 | public function getComposed() 136 | { 137 | if ($this->composed === null) { 138 | $this->compose(); 139 | } 140 | 141 | return $this->composed; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/Generator/Invoic.php: -------------------------------------------------------------------------------- 1 | items = []; 102 | } 103 | 104 | 105 | /** 106 | * @param $item Item 107 | */ 108 | public function addItem($item) 109 | { 110 | $this->items[] = $item; 111 | } 112 | 113 | 114 | /** 115 | * @return $this 116 | * @throws EdifactException 117 | */ 118 | public function compose() 119 | { 120 | $this->composeByKeys(); 121 | 122 | foreach ($this->items as $item) { 123 | $composed = $item->compose(); 124 | foreach ($composed as $entry) { 125 | $this->messageContent[] = $entry; 126 | } 127 | } 128 | 129 | $this->setPositionSeparator(); 130 | $this->composeByKeys([ 131 | 'positionSeparator', 132 | 'totalPositionsAmount', 133 | 'basisAmount', 134 | 'taxableAmount', 135 | 'payableAmount', 136 | 'tax', 137 | 'taxAmount', 138 | ]); 139 | 140 | parent::compose(); 141 | return $this; 142 | } 143 | 144 | /** 145 | * @return array 146 | */ 147 | public function getInvoiceNumber() 148 | { 149 | return $this->invoiceNumber; 150 | } 151 | 152 | /** 153 | * @param string $invoiceNumber 154 | * @param string $documentType 155 | * @return Invoic 156 | * @throws EdifactException 157 | */ 158 | public function setInvoiceNumber($invoiceNumber, $documentType = self::TYPE_INVOICE) 159 | { 160 | $this->isAllowed($documentType, [ 161 | self::TYPE_INVOICE, 162 | self::TYPE_CREDIT_NOTE, 163 | self::TYPE_SERVICE_CREDIT, 164 | self::TYPE_SERVICE_INVOICE, 165 | self::TYPE_BONUS 166 | ]); 167 | $this->invoiceNumber = self::addBGMSegment($invoiceNumber, $documentType); 168 | return $this; 169 | } 170 | 171 | /** 172 | * @return array 173 | */ 174 | public function getInvoiceDate() 175 | { 176 | return $this->invoiceDate; 177 | } 178 | 179 | /** 180 | * @param string $invoiceDate 181 | * @return Invoic 182 | * @throws EdifactException 183 | */ 184 | public function setInvoiceDate($invoiceDate) 185 | { 186 | $this->invoiceDate = $this->addDTMSegment($invoiceDate, '3'); 187 | return $this; 188 | } 189 | 190 | /** 191 | * @return array 192 | */ 193 | public function getDeliveryDate() 194 | { 195 | return $this->deliveryDate; 196 | } 197 | 198 | /** 199 | * @param $deliveryDate 200 | * @return Invoic 201 | * @throws EdifactException 202 | */ 203 | public function setDeliveryDate($deliveryDate) 204 | { 205 | $this->deliveryDate = $this->addDTMSegment($deliveryDate, '35'); 206 | return $this; 207 | } 208 | 209 | /** 210 | * @return array 211 | */ 212 | public function getReductionOfFeesText() 213 | { 214 | return $this->reductionOfFeesText; 215 | } 216 | 217 | /** 218 | * @param string $reductionOfFeesText 219 | * @return Invoic 220 | */ 221 | public function setReductionOfFeesText($reductionOfFeesText) 222 | { 223 | $this->reductionOfFeesText = self::addFTXSegment($reductionOfFeesText, 'OSI', 'HAE'); 224 | return $this; 225 | } 226 | 227 | 228 | 229 | /** 230 | * @return array 231 | */ 232 | public function getInvoiceDescription() 233 | { 234 | return $this->invoiceDescription; 235 | } 236 | 237 | /** 238 | * @param string $invoiceDescription 239 | * @return Invoic 240 | */ 241 | public function setInvoiceDescription($invoiceDescription) 242 | { 243 | $this->invoiceDescription = self::addFTXSegment($invoiceDescription, 'OSI'); 244 | return $this; 245 | } 246 | 247 | /** 248 | * @return Invoic 249 | */ 250 | public function setPositionSeparator() 251 | { 252 | $this->positionSeparator = ['UNS', 'S']; 253 | return $this; 254 | } 255 | 256 | /** 257 | * @return array 258 | */ 259 | public function getTotalPositionsAmount() 260 | { 261 | return $this->totalPositionsAmount; 262 | } 263 | 264 | /** 265 | * @param string|float $totalPositionsAmount 266 | * @return Invoic 267 | */ 268 | public function setTotalPositionsAmount($totalPositionsAmount) 269 | { 270 | $this->totalPositionsAmount = self::addMOASegment('79', $totalPositionsAmount); 271 | return $this; 272 | } 273 | 274 | /** 275 | * @return array 276 | */ 277 | public function getBasisAmount() 278 | { 279 | return $this->basisAmount; 280 | } 281 | 282 | /** 283 | * @param string|float $basisAmount 284 | * @return Invoic 285 | */ 286 | public function setBasisAmount($basisAmount) 287 | { 288 | $this->basisAmount = self::addMOASegment('56', $basisAmount); 289 | return $this; 290 | } 291 | 292 | /** 293 | * @return array 294 | */ 295 | public function getTaxableAmount() 296 | { 297 | return $this->taxableAmount; 298 | } 299 | 300 | /** 301 | * @param string|float $taxableAmount 302 | * @return Invoic 303 | */ 304 | public function setTaxableAmount($taxableAmount) 305 | { 306 | $this->taxableAmount = self::addMOASegment('125', $taxableAmount); 307 | return $this; 308 | } 309 | 310 | /** 311 | * @return array 312 | */ 313 | public function getPayableAmount() 314 | { 315 | return $this->payableAmount; 316 | } 317 | 318 | /** 319 | * @param string|float $payableAmount 320 | * @return Invoic 321 | */ 322 | public function setPayableAmount($payableAmount) 323 | { 324 | $this->payableAmount = self::addMOASegment('9', $payableAmount); 325 | return $this; 326 | } 327 | 328 | /** 329 | * @param string|float $value 330 | * @param string|float $amount 331 | * @return $this 332 | */ 333 | public function setTax($value, $amount) 334 | { 335 | $this->tax = [ 336 | 'TAX', 337 | '7', 338 | 'VAT', 339 | '', 340 | '', 341 | [ 342 | '', 343 | '', 344 | '', 345 | EdiFactNumber::convert($value, 0) 346 | ], 347 | ]; 348 | $this->taxAmount = self::addMOASegment('150', $amount); 349 | return $this; 350 | } 351 | } 352 | -------------------------------------------------------------------------------- /src/Generator/Invoic/Item.php: -------------------------------------------------------------------------------- 1 | invoiceDescription; 38 | } 39 | 40 | /** 41 | * @param string $invoiceDescription 42 | * @return Item 43 | */ 44 | public function setInvoiceDescription($invoiceDescription) 45 | { 46 | $this->invoiceDescription = Message::addFTXSegment($invoiceDescription, 'INV'); 47 | $this->addKeyToCompose('invoiceDescription'); 48 | 49 | return $this; 50 | } 51 | 52 | 53 | /** 54 | * @param $qualifier 55 | * @param $value 56 | * @param int $priceBase 57 | * @param string $priceBaseUnit 58 | * @return array 59 | */ 60 | public static function addPRISegment($qualifier, $value, $priceBase = 1, $priceBaseUnit = 'PCE') 61 | { 62 | return [ 63 | 'PRI', 64 | [ 65 | $qualifier, 66 | EdiFactNumber::convert($value), 67 | '', 68 | '', 69 | (string)$priceBase, 70 | $priceBaseUnit 71 | ] 72 | ]; 73 | } 74 | 75 | /** 76 | * @return array 77 | */ 78 | public function getGrossPrice() 79 | { 80 | return $this->grossPrice; 81 | } 82 | 83 | /** 84 | * @param string $grossPrice 85 | * @return Item 86 | */ 87 | public function setGrossPrice($grossPrice) 88 | { 89 | $this->grossPrice = self::addPRISegment('GRP', $grossPrice); 90 | $this->addKeyToCompose('grossPrice'); 91 | return $this; 92 | } 93 | 94 | /** 95 | * @return array 96 | */ 97 | public function getNetPrice() 98 | { 99 | return $this->netPrice; 100 | } 101 | 102 | /** 103 | * @param string $netPrice 104 | * @return Item 105 | */ 106 | public function setNetPrice($netPrice) 107 | { 108 | $this->netPrice = self::addPRISegment('NTP', $netPrice); 109 | $this->addKeyToCompose('netPrice'); 110 | return $this; 111 | } 112 | 113 | /** 114 | * @param $value 115 | * @param string $discountType 116 | * @return Item 117 | */ 118 | public function addDiscount($value, $discountType = self::DISCOUNT_TYPE_PERCENT) 119 | { 120 | $index = 'discount' . $this->discountIndex++; 121 | $this->{$index} = [ 122 | 'ALC', 123 | floatval($value) > 0 ? 'C' : 'A', 124 | '', 125 | '', 126 | '', 127 | 'SF', 128 | ]; 129 | $this->addKeyToCompose($index); 130 | 131 | if ($discountType == self::DISCOUNT_TYPE_PERCENT) { 132 | $index = 'discount' . $this->discountIndex++; 133 | $this->{$index} = [ 134 | 'PCD', 135 | [ 136 | '', 137 | '3', 138 | EdiFactNumber::convert(abs($value)) 139 | ] 140 | ]; 141 | $this->addKeyToCompose($index); 142 | } 143 | 144 | $index = 'discount' . $this->discountIndex++; 145 | $this->{$index} = self::addMOASegment('8', abs($value)); 146 | $this->addKeyToCompose($index); 147 | 148 | return $this; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/Generator/Message.php: -------------------------------------------------------------------------------- 1 | messageType = [$identifier, $version]; 28 | 29 | if ($release !== null) { 30 | $this->messageType[] = $release; 31 | } 32 | 33 | if ($release !== null) { 34 | $this->messageType[] = $controllingAgency; 35 | } 36 | 37 | if ($association !== null) { 38 | $this->messageType[] = $association; 39 | } 40 | 41 | if ($messageID === null) { 42 | $this->messageID = 'M' . strtoupper(uniqid()); 43 | } else { 44 | $this->messageID = $messageID; 45 | } 46 | 47 | $this->messageContent = []; 48 | } 49 | 50 | public function setMessageContent($messageContent) 51 | { 52 | $this->messageContent = $messageContent; 53 | return $this; 54 | } 55 | 56 | public function getMessageContent() 57 | { 58 | return $this->messageContent; 59 | } 60 | 61 | public function addSegment($segment) 62 | { 63 | $this->messageContent[] = $segment; 64 | return $this; 65 | } 66 | 67 | public function getMessageID() 68 | { 69 | return $this->messageID; 70 | } 71 | 72 | public function setMessageID($messageId) 73 | { 74 | $this->messageID = $messageId; 75 | return $this; 76 | } 77 | 78 | /** 79 | * Compose. 80 | * @throws \EDI\Generator\EdifactException 81 | */ 82 | public function compose() 83 | { 84 | $aComposed = []; 85 | 86 | // Message Header 87 | $aComposed[] = ['UNH', $this->messageID, $this->messageType]; 88 | 89 | if (count($this->messageContent) == 0) { 90 | throw new EdifactException('no content available for message'); 91 | } 92 | 93 | // Segments 94 | foreach ($this->messageContent as $i) { 95 | if ($i instanceof \EDI\Generator\Segment) { 96 | $i = $i->compose()->getComposed(); 97 | } 98 | $aComposed[] = $i; 99 | } 100 | 101 | // Message Trailer 102 | $aComposed[] = ['UNT', (string)(2 + count($this->messageContent)), $this->messageID]; 103 | 104 | $this->composed = $aComposed; 105 | 106 | return $this; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/Generator/Movins.php: -------------------------------------------------------------------------------- 1 | messageDate = self::dtmSegment(137, date('YmdHi')); 47 | $this->handling = []; 48 | } 49 | 50 | /** 51 | * Date of the message submission 52 | * @param $dtm 53 | * @return \EDI\Generator\Movins 54 | */ 55 | public function setMessageDate($dtm) 56 | { 57 | $this->messageDate = self::dtmSegment(137, $dtm, 101); 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Vessel call information 64 | * @param $extVoyage 65 | * @param $line 66 | * @param $vslName 67 | * @param $callsign 68 | * @return \EDI\Generator\Movins 69 | */ 70 | public function setVessel($extVoyage, $line, $vslName, $callsign) 71 | { 72 | $this->vessel = self::tdtSegment(20, $extVoyage, '', '', [$line, 172, 20], '', '', [$callsign, 103, 11, $vslName]); 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * Place of Departure 79 | * @param $loc 80 | * @return \EDI\Generator\Movins 81 | */ 82 | public function setPlaceOfDeparture($loc) 83 | { 84 | $this->placeOfDeparture = self::locSegment(5, [$loc, 139, 6]); 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Estimated Time of Arrival 91 | * @param $dtm 92 | * @return \EDI\Generator\Movins 93 | */ 94 | public function setEta($dtm) 95 | { 96 | $this->eta = self::dtmSegment(101, $dtm); 97 | 98 | return $this; 99 | } 100 | 101 | /** 102 | * @param $number 103 | * @return \EDI\Generator\Movins 104 | */ 105 | public function setVoyageNumber($number) 106 | { 107 | $this->voyageNumber = self::rffSegment('VON', $number); 108 | 109 | return $this; 110 | } 111 | 112 | public function addHandlingGroup($handlingType) { 113 | $this->handling[$handlingType] = []; 114 | 115 | return $this; 116 | } 117 | 118 | public function addContainer($handlingType, $containerGroup) 119 | { 120 | $this->handling[$handlingType][] = $containerGroup; 121 | 122 | return $this; 123 | } 124 | 125 | /** 126 | * Compose. 127 | * 128 | * @param mixed $sMessageFunctionCode (1225) 129 | * @param mixed $sDocumentNameCode (1001) 130 | * @param mixed $sDocumentIdentifier (1004) 131 | * 132 | * @return \EDI\Generator\Message ::compose() 133 | * @throws \EDI\Generator\EdifactException 134 | */ 135 | public function compose(?string $sMessageFunctionCode = "9", ?string $sDocumentNameCode = "121", ?string $sDocumentIdentifier = null): parent 136 | { 137 | $this->messageContent = [ 138 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode] 139 | ]; 140 | 141 | $this->messageContent[] = $this->messageDate; 142 | $this->messageContent[] = $this->vessel; 143 | $this->messageContent[] = $this->placeOfDeparture; 144 | $this->messageContent[] = $this->eta; 145 | $this->messageContent[] = $this->voyageNumber; 146 | 147 | foreach ($this->handling as $handlingCode => $container) { 148 | $this->messageContent[] = ['HAN', $handlingCode]; 149 | foreach ($container as $cntr) { 150 | $content = $cntr->compose(); 151 | foreach ($content as $segment) { 152 | $this->messageContent[] = $segment; 153 | } 154 | } 155 | } 156 | 157 | return parent::compose(); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/Generator/Movins/Container.php: -------------------------------------------------------------------------------- 1 | bayPosition = \EDI\Generator\Message::locSegment(147, $position); 41 | 42 | return $this; 43 | } 44 | 45 | /** 46 | * Weight information 47 | * @param $weight 48 | * @return \EDI\Generator\Movins\Container 49 | */ 50 | public function addWeight($weight, $qualifier = "WT") 51 | { 52 | if ($this->weight === null) { 53 | $this->weight = []; 54 | } 55 | 56 | $this->weight[] = ['MEA', $qualifier, '', ['KGM', $weight]]; 57 | 58 | return $this; 59 | } 60 | 61 | /** 62 | * Weight information 63 | * @param $ftx 64 | * @return \EDI\Generator\Movins\Container 65 | */ 66 | public function addFreeText($freeText) 67 | { 68 | if ($this->freeText === null) { 69 | $this->freeText = []; 70 | } 71 | 72 | $this->freeText[] = ['FTX', 'AAA', '', '', $freeText]; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * $size = 22G1, 42G1, etc; 306 = smdg, 6436 = ISO spec 79 | * $statusCode = 1 (Continental), 2 (Export), 3 (Import) 80 | * $fullEmptyIndicator = 4 (Empty), 5 (Full) 81 | * @param $number 82 | * @param $size 83 | * @param $statusCode 84 | * @param $fullEmptyIndicator 85 | * @return \EDI\Generator\Movins\Container 86 | */ 87 | public function setContainer($number, $size, $statusCode, $fullEmptyIndicator) 88 | { 89 | $this->cntr = \EDI\Generator\Message::eqdSegment('CN', $number, $size, '', $statusCode, $fullEmptyIndicator); 90 | 91 | return $this; 92 | } 93 | 94 | /** 95 | * $line: Master Liner Codes List 96 | * @param $line 97 | * @return \EDI\Generator\Movins\Container 98 | */ 99 | public function setCarrier($line, $codeListQualifier = null, $codeListResponsibleAgencyCoded = null) 100 | { 101 | $this->carrier = ['NAD', 'CA', $line]; 102 | if ($codeListQualifier !== null) { 103 | $this->carrier = ['NAD', 'CA', [$line, $codeListQualifier, $codeListResponsibleAgencyCoded] ]; 104 | } 105 | 106 | return $this; 107 | } 108 | 109 | 110 | /** 111 | * $type = 9 (place of load) 112 | * @param $locode 113 | * @return \EDI\Generator\Movins\Container 114 | */ 115 | public function setPOL($locode) 116 | { 117 | $this->pol = \EDI\Generator\Message::locSegment(9, $locode); 118 | 119 | return $this; 120 | } 121 | 122 | /** 123 | * $type = 11 (place of unload) 124 | * @param $locode 125 | * @return \EDI\Generator\Movins\Container 126 | */ 127 | public function setPOD($locode) 128 | { 129 | $this->pod = \EDI\Generator\Message::locSegment(11, $locode); 130 | 131 | return $this; 132 | } 133 | 134 | /** 135 | * $type = 76 (place of first load) 136 | * @param $locode 137 | * @return \EDI\Generator\Movins\Container 138 | */ 139 | public function setFL($locode) 140 | { 141 | $this->fl = \EDI\Generator\Message::locSegment(76, $locode); 142 | 143 | return $this; 144 | } 145 | 146 | /** 147 | * $type = 83 (place of final delivery) 148 | * @param $locode 149 | * @return \EDI\Generator\Movins\Container 150 | */ 151 | public function setFND($locode) 152 | { 153 | $this->fnd = \EDI\Generator\Message::locSegment(83, $locode); 154 | 155 | return $this; 156 | } 157 | 158 | /** 159 | * $type = ISO stowage location 160 | * @param $position 161 | * @return \EDI\Generator\Movins\Container 162 | */ 163 | public function setDestinationStowageISO($position) 164 | { 165 | $this->dsi = \EDI\Generator\Message::rffSegment('DSI', $position); 166 | 167 | return $this; 168 | } 169 | 170 | /** 171 | * @param $hazardClass 172 | * @param $hazardCode 173 | * @param $flashpoint 174 | * @param $packingGroup 175 | * @return $this 176 | */ 177 | public function addDangerous($hazardClass, $hazardCode, $flashpoint = null, $packingGroup = null) 178 | { 179 | if ($this->dangerous === null) { 180 | $this->dangerous = []; 181 | } 182 | 183 | $dgs = ['DGS', 'IMD', $hazardClass, $hazardCode]; 184 | if ($flashpoint !== null) { 185 | if ($flashpoint != '') { 186 | $flashpoint = [$flashpoint, 'CEL']; 187 | } 188 | $dgs[] = $flashpoint; 189 | if ($packingGroup !== null) { 190 | $dgs[] = $packingGroup; 191 | } 192 | } 193 | 194 | $this->dangerous[] = $dgs; 195 | 196 | return $this; 197 | } 198 | 199 | /** 200 | * @param $setDegrees 201 | * @return $this 202 | */ 203 | public function setTemperature($setDegrees) 204 | { 205 | $this->temperature = ['TMP', '2', [$setDegrees, 'CEL']]; 206 | 207 | return $this; 208 | } 209 | 210 | /** 211 | * @param $min 212 | * @param $max 213 | * @return $this 214 | */ 215 | public function setRange($min, $max) 216 | { 217 | $this->range = ['RNG', '4', ['CEL', $min, $max]]; 218 | 219 | return $this; 220 | } 221 | 222 | 223 | /** 224 | * @param $ventilation 225 | * @return $this 226 | */ 227 | public function setVentilation($ventilation) 228 | { 229 | $this->ventilation = ['MEA', 'AAE', 'AAS', ['CBM', $ventilation]]; 230 | 231 | return $this; 232 | } 233 | 234 | /** 235 | * @param $humidity 236 | * @return $this 237 | */ 238 | public function setHumidity($humidity) 239 | { 240 | $this->humidity = ['MEA', 'AAE', 'AAO', ['PCT', $humidity]]; 241 | 242 | return $this; 243 | } 244 | 245 | /** 246 | * @param string $front 247 | * @param string $back 248 | * @param string $right 249 | * @param string $left 250 | * @param string $height 251 | * @return $this 252 | */ 253 | public function setOverDimensions($front = '', $back = '', $right = '', $left = '', $height = '') 254 | { 255 | $this->dimensions = []; 256 | if ($front !== '') { 257 | $this->dimensions[] = ['DIM', '5', ['CMT', $front]]; 258 | } 259 | if ($back !== '') { 260 | $this->dimensions[] = ['DIM', '6', ['CMT', $back]]; 261 | } 262 | if ($right !== '') { 263 | $this->dimensions[] = ['DIM', '7', ['CMT', '', $right]]; 264 | } 265 | if ($left !== '') { 266 | $this->dimensions[] = ['DIM', '8', ['CMT', '', $left]]; 267 | } 268 | if ($height !== '') { 269 | $this->dimensions[] = ['DIM', '13', ['CMT', '', '', $height]]; 270 | } 271 | 272 | return $this; 273 | } 274 | 275 | public function addAttachedEquipment($eqpType, $eqpNumber) 276 | { 277 | if ($this->attachedEquipment === null) { 278 | $this->attachedEquipment = []; 279 | } 280 | 281 | $eqp = ['EQA', $eqpType, $eqpNumber]; 282 | 283 | $this->attachedEquipment[] = $eqp; 284 | 285 | return $this; 286 | } 287 | 288 | /** 289 | * @return array 290 | */ 291 | public function compose() 292 | { 293 | $composed = [ 294 | $this->bayPosition 295 | ]; 296 | 297 | if ($this->freeText !== null) { 298 | foreach ($this->freeText as $segment) { 299 | $composed[] = $segment; 300 | } 301 | } 302 | 303 | if ($this->weight !== null) { 304 | foreach ($this->weight as $segment) { 305 | $composed[] = $segment; 306 | } 307 | } 308 | 309 | if ($this->ventilation !== null) { 310 | $composed[] = $this->ventilation; 311 | } 312 | 313 | if ($this->humidity !== null) { 314 | $composed[] = $this->humidity; 315 | } 316 | 317 | if ($this->dimensions !== null) { 318 | foreach ($this->dimensions as $segment) { 319 | $composed[] = $segment; 320 | } 321 | } 322 | 323 | if ($this->temperature !== null) { 324 | $composed[] = $this->temperature; 325 | } 326 | 327 | if ($this->range !== null) { 328 | $composed[] = $this->range; 329 | } 330 | 331 | if ($this->pol !== null) { 332 | $composed[] = $this->pol; 333 | } 334 | if ($this->pod !== null) { 335 | $composed[] = $this->pod; 336 | } 337 | if ($this->fl !== null) { 338 | $composed[] = $this->fl; 339 | } 340 | if ($this->fnd !== null) { 341 | $composed[] = $this->fnd; 342 | } 343 | 344 | $composed[] = \EDI\Generator\Message::rffSegment('BM', '1'); 345 | 346 | if ($this->dsi !== null) { 347 | $composed[] = $this->dsi; 348 | } 349 | 350 | if ($this->cntr !== null) { 351 | $composed[] = $this->cntr; 352 | } 353 | 354 | if ($this->attachedEquipment !== null) { 355 | foreach ($this->attachedEquipment as $segment) { 356 | $composed[] = $segment; 357 | } 358 | } 359 | 360 | if ($this->carrier !== null) { 361 | $composed[] = $this->carrier; 362 | } 363 | 364 | if ($this->dangerous !== null) { 365 | foreach ($this->dangerous as $segment) { 366 | $composed[] = $segment; 367 | } 368 | } 369 | 370 | return $composed; 371 | } 372 | } 373 | -------------------------------------------------------------------------------- /src/Generator/Orders/Item.php: -------------------------------------------------------------------------------- 1 | items[] = $item; 109 | } 110 | 111 | /** 112 | * @return $this 113 | * @throws EdifactException 114 | */ 115 | public function compose() 116 | { 117 | $this->composeByKeys(); 118 | 119 | foreach ($this->items as $item) { 120 | $composed = $item->compose(); 121 | foreach ($composed as $entry) { 122 | $this->messageContent[] = $entry; 123 | } 124 | } 125 | 126 | $this->messageContent[] = [ 127 | 'UNS', 128 | 'S', 129 | ]; 130 | parent::compose(); 131 | 132 | return $this; 133 | } 134 | 135 | /** 136 | * @return array 137 | */ 138 | public function getOrderConfirmationNumber() 139 | { 140 | return $this->orderConfirmationNumber; 141 | } 142 | 143 | 144 | /** 145 | * @param string $orderConfirmationNumber 146 | * @param string $documentType 147 | * 148 | * @return Ordrsp 149 | */ 150 | public function setOrderConfirmationNumber($orderConfirmationNumber, $documentType = '231') 151 | { 152 | $this->orderConfirmationNumber = [ 153 | 'BGM', 154 | $documentType, 155 | $orderConfirmationNumber, 156 | ]; 157 | return $this; 158 | } 159 | 160 | /** 161 | * @return array 162 | */ 163 | public function getOrderConfirmationDate() 164 | { 165 | return $this->orderConfirmationDate; 166 | } 167 | 168 | /** 169 | * @param string|\DateTime $orderConfirmationDate 170 | * 171 | * @return Ordrsp 172 | * @throws EdifactException 173 | */ 174 | public function setOrderConfirmationDate($orderConfirmationDate) 175 | { 176 | $this->orderConfirmationDate = $this->addDTMSegment($orderConfirmationDate, '4'); 177 | return $this; 178 | } 179 | 180 | /** 181 | * @return array 182 | */ 183 | public function getDeliveryDate() 184 | { 185 | return $this->deliveryDate; 186 | } 187 | 188 | /** 189 | * @param string|\DateTime $deliveryDate 190 | * @param int $type 191 | * @param int $formatQuantifier 192 | * 193 | * @return Ordrsp 194 | * @throws EdifactException 195 | */ 196 | public function setDeliveryDate($deliveryDate, $type = EdifactDate::TYPE_DELIVERY_DATE_REQUESTED, $formatQuantifier = EdifactDate::DATE) 197 | { 198 | $this->deliveryDate = $this->addDTMSegment($deliveryDate, $type, $formatQuantifier); 199 | return $this; 200 | } 201 | 202 | /** 203 | * @return array 204 | */ 205 | public function getOrderNumber() 206 | { 207 | return $this->orderNumber; 208 | } 209 | 210 | /** 211 | * @param string $orderNumber 212 | * 213 | * @return Ordrsp 214 | */ 215 | public function setOrderNumber($orderNumber) 216 | { 217 | $this->orderNumber = $this->addRFFSegment('VN', $orderNumber); 218 | return $this; 219 | } 220 | 221 | /** 222 | * @return array 223 | */ 224 | public function getPositionSeparator() 225 | { 226 | return $this->positionSeparator; 227 | } 228 | 229 | /** 230 | * @return Ordrsp 231 | */ 232 | public function setPositionSeparator() 233 | { 234 | $this->positionSeparator = [ 235 | 'UNS', 236 | 'S', 237 | ]; 238 | return $this; 239 | } 240 | 241 | /** 242 | * @return array 243 | */ 244 | public function getOrderInstruction() 245 | { 246 | return $this->orderInstruction; 247 | } 248 | 249 | /** 250 | * @param string $orderInstruction 251 | * 252 | * @return Ordrsp 253 | */ 254 | public function setOrderInstruction($orderInstruction) 255 | { 256 | $this->orderInstruction = self::addFTXSegment($orderInstruction, 'ORI'); 257 | return $this; 258 | } 259 | 260 | /** 261 | * @return array 262 | */ 263 | public function getAdditionalReferenceNumber() 264 | { 265 | return $this->additionalReferenceNumber; 266 | } 267 | 268 | /** 269 | * @param string $additionalReferenceNumber 270 | * 271 | * @return Ordrsp 272 | */ 273 | public function setAdditionalReferenceNumber($additionalReferenceNumber) 274 | { 275 | $this->additionalReferenceNumber = self::addRFFSegment('ACD', $additionalReferenceNumber); 276 | return $this; 277 | } 278 | 279 | /** 280 | * @return array 281 | */ 282 | public function getTransportDocumentNumber() 283 | { 284 | return $this->transportDocumentNumber; 285 | } 286 | 287 | /** 288 | * @param string $transportDocumentNumber 289 | * 290 | * @return Ordrsp 291 | */ 292 | public function setTransportDocumentNumber($transportDocumentNumber) 293 | { 294 | $this->transportDocumentNumber = self::addRFFSegment('AAS', $transportDocumentNumber); 295 | return $this; 296 | } 297 | 298 | /** 299 | * @return array 300 | */ 301 | public function getProjectNumber() 302 | { 303 | return $this->projectNumber; 304 | } 305 | 306 | /** 307 | * @param string $projectNumber 308 | * 309 | * @return Ordrsp 310 | */ 311 | public function setProjectNumber($projectNumber) 312 | { 313 | $this->projectNumber = self::addRFFSegment('AEP', $projectNumber); 314 | return $this; 315 | } 316 | 317 | /** 318 | * @return array 319 | */ 320 | public function getBeneficiaryReference() 321 | { 322 | return $this->beneficiaryReference; 323 | } 324 | 325 | /** 326 | * @param string $beneficiaryReference 327 | * 328 | * @return Ordrsp 329 | */ 330 | public function setBeneficiaryReference($beneficiaryReference) 331 | { 332 | $this->beneficiaryReference = self::addRFFSegment('AFO', $beneficiaryReference); 333 | return $this; 334 | } 335 | 336 | /** 337 | * @return array 338 | */ 339 | public function getBeneficiaryReference2() 340 | { 341 | return $this->beneficiaryReference2; 342 | } 343 | 344 | /** 345 | * @param string $beneficiaryReference2 346 | * 347 | * @return Ordrsp 348 | */ 349 | public function setBeneficiaryReference2($beneficiaryReference2) 350 | { 351 | $this->beneficiaryReference2 = self::addRFFSegment('AFP', $beneficiaryReference2); 352 | return $this; 353 | } 354 | } 355 | -------------------------------------------------------------------------------- /src/Generator/Ordrsp/Item.php: -------------------------------------------------------------------------------- 1 | aComposed 18 | */ 19 | public function getComposed(): array 20 | { 21 | return $this->aComposed; 22 | } 23 | 24 | /** 25 | * Set Composed. 26 | * 27 | * @param array $aComposed 28 | */ 29 | public function setComposed(array $aComposed): void 30 | { 31 | $this->aComposed = $aComposed; 32 | } 33 | 34 | /** 35 | * Compose. 36 | * 37 | * @return self 38 | */ 39 | public function compose(): self 40 | { 41 | return $this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Generator/Segment/BeginningOfMessage.php: -------------------------------------------------------------------------------- 1 | aDocument = $aDocument; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Set Document Identification (C106). 64 | * 65 | * @param string|null $sDocumentIdentifier 66 | * @param string|null $sVersionIdentifier 67 | * @param string|null $sRevisionIdentifier 68 | * 69 | * @return self 70 | */ 71 | public function setDocumentIdentification( 72 | ?string $sDocumentIdentifier = null, 73 | ?string $sVersionIdentifier = null, 74 | ?string $sRevisionIdentifier = null 75 | ): self { 76 | $aDocumentIdentification = []; 77 | 78 | if ($sDocumentIdentifier !== null) { 79 | $aDocumentIdentification[] = $sDocumentIdentifier; 80 | } 81 | 82 | if ($sVersionIdentifier !== null) { 83 | $aDocumentIdentification[] = $sVersionIdentifier; 84 | } 85 | 86 | if ($sRevisionIdentifier !== null) { 87 | $aDocumentIdentification[] = $sRevisionIdentifier; 88 | } 89 | 90 | $this->aDocumentIdentification = $aDocumentIdentification; 91 | 92 | return $this; 93 | } 94 | 95 | /** 96 | * Set Message Function Code. 97 | * 98 | * @param string $sMessageFunctionCode 99 | * 100 | * @return self 101 | */ 102 | public function setMessageFunctionCode(string $sMessageFunctionCode): self 103 | { 104 | $this->sMessageFunctionCode = $sMessageFunctionCode; 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * Set Response Type Code. 111 | * 112 | * @param string $sResponseTypeCode 113 | * 114 | * @return self 115 | */ 116 | public function setResponseTypeCode(string $sResponseTypeCode): self 117 | { 118 | $this->sResponseTypeCode = $sResponseTypeCode; 119 | 120 | return $this; 121 | } 122 | 123 | /** 124 | * Set Document Status Code. 125 | * 126 | * @param string $sDocumentStatusCode 127 | * 128 | * @return self 129 | */ 130 | public function setDocumentStatusCode(string $sDocumentStatusCode): self 131 | { 132 | $this->sDocumentStatusCode = $sDocumentStatusCode; 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * Set Language Name Code. 139 | * 140 | * @param string $sLanguageNameCode 141 | * 142 | * @return self 143 | */ 144 | public function setLanguageNameCode(string $sLanguageNameCode): self 145 | { 146 | $this->sLanguageNameCode = $sLanguageNameCode; 147 | 148 | return $this; 149 | } 150 | 151 | /** 152 | * Compose. 153 | * 154 | * @return self 155 | */ 156 | public function compose(): self 157 | { 158 | $aComposed = [self::SEGMENT_NAME]; 159 | 160 | if (!empty($this->aDocument)) { 161 | $aComposed[] = $this->aDocument; 162 | } 163 | 164 | if (!empty($this->aDocumentIdentification)) { 165 | $aComposed[] = $this->aDocumentIdentification; 166 | } 167 | 168 | if ($this->sMessageFunctionCode !== null) { 169 | $aComposed[] = $this->sMessageFunctionCode; 170 | } 171 | 172 | if ($this->sResponseTypeCode !== null) { 173 | $aComposed[] = $this->sResponseTypeCode; 174 | } 175 | 176 | if ($this->sDocumentStatusCode !== null) { 177 | $aComposed[] = $this->sDocumentStatusCode; 178 | } 179 | 180 | if ($this->sLanguageNameCode !== null) { 181 | $aComposed[] = $this->sLanguageNameCode; 182 | } 183 | 184 | $this->setComposed($aComposed); 185 | 186 | return $this; 187 | } 188 | } -------------------------------------------------------------------------------- /src/Generator/Segment/ControlTotal.php: -------------------------------------------------------------------------------- 1 | sControlTotalTypeCodeQualifier = $sControlTotalTypeCodeQualifier; 30 | 31 | return $this; 32 | } 33 | 34 | /** 35 | * Set Control Total Quantity. 36 | * 37 | * @param string $sControlTotalQuantity (6066) 38 | * 39 | * @return self $this 40 | */ 41 | public function setControlTotalQuantity(string $sControlTotalQuantity): self 42 | { 43 | $this->sControlTotalQuantity = $sControlTotalQuantity; 44 | 45 | return $this; 46 | } 47 | 48 | /** 49 | * Set Measurement Unit Code. 50 | * 51 | * @param string $sMeasurementUnitCode 52 | * @return self $this 53 | */ 54 | public function setMeasurementUnitCode(string $sMeasurementUnitCode): self 55 | { 56 | $this->sMeasurementUnitCode = sMeasurementUnitCode; 57 | 58 | return $this; 59 | } 60 | 61 | /** 62 | * Compose. 63 | * 64 | * @return self $this 65 | */ 66 | public function compose(): self 67 | { 68 | $aComposed[] = self::SEGMENT_NAME; 69 | 70 | // Control Total Type Code Qualifier 71 | $aControl[] = $this->sControlTotalTypeCodeQualifier; 72 | 73 | // Control Total Quantity 74 | $aControl[] = $this->sControlTotalQuantity; 75 | 76 | // Measurement Unit Code 77 | 78 | if ($this->sMeasurementUnitCode !== null) { 79 | $aControl[] = $this->sMeasurementUnitCode; 80 | } 81 | 82 | if (count($aControl) > 0) { 83 | $aComposed[] = $aControl; 84 | } 85 | 86 | $this->setComposed($aComposed); 87 | 88 | return $this; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Generator/Segment/DateTimePeriod.php: -------------------------------------------------------------------------------- 1 | sDateOrTimeOrPeriodFunctionCodeQualifier = $sDateOrTimeOrPeriodFunctionCodeQualifier; 30 | 31 | return $this; 32 | } 33 | 34 | /** 35 | * Set Date Or Time Or Period Text. 36 | * 37 | * @param string $sDateOrTimeOrPeriodText (2380) 38 | * 39 | * @return self $this 40 | */ 41 | public function setDateOrTimeOrPeriodText(string $sDateOrTimeOrPeriodText): self 42 | { 43 | $this->sDateOrTimeOrPeriodText = $sDateOrTimeOrPeriodText; 44 | 45 | return $this; 46 | } 47 | 48 | /** 49 | * Set Date Or Time Or Period Format Code. 50 | * 51 | * @param string $sDateOrTimeOrPeriodFormatCode (2379) 52 | * 53 | * @return self $this 54 | */ 55 | public function setDateOrTimeOrPeriodFormatCode(string $sDateOrTimeOrPeriodFormatCode): self 56 | { 57 | $this->sDateOrTimeOrPeriodFormatCode = $sDateOrTimeOrPeriodFormatCode; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Compose. 64 | * 65 | * @return self $this 66 | */ 67 | public function compose(): self 68 | { 69 | $aComposed[] = self::SEGMENT_NAME; 70 | 71 | // Date Or Time Or Period Function Code Qualifier 72 | $aDateTimePeriod[] = $this->sDateOrTimeOrPeriodFunctionCodeQualifier; 73 | 74 | // Date Or Time Or Period Text 75 | 76 | if ($this->sDateOrTimeOrPeriodText !== null) { 77 | $aDateTimePeriod[] = $this->sDateOrTimeOrPeriodText; 78 | } 79 | 80 | // Date Or Time Or Period Format Code 81 | 82 | if ($this->sDateOrTimeOrPeriodFormatCode !== null) { 83 | $aDateTimePeriod[] = $this->sDateOrTimeOrPeriodFormatCode; 84 | } 85 | 86 | if (count($aDateTimePeriod) > 0) { 87 | $aComposed[] = $aDateTimePeriod; 88 | } 89 | 90 | $this->setComposed($aComposed); 91 | 92 | return $this; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Generator/Segment/EquipmentDetails.php: -------------------------------------------------------------------------------- 1 | sEquipmentTypeCodeQualifier = $sEquipmentTypeCodeQualifier; 34 | 35 | return $this; 36 | } 37 | 38 | /** 39 | * Set Equipment Identification (C237). 40 | * 41 | * @param mixed $sEquipmentIdentifier (8260) 42 | * @param mixed $sCodeListIdentificationCode (1131) 43 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 44 | * @param mixed $sCountryIdentifier (3207) 45 | * 46 | * @return self $this 47 | */ 48 | public function setEquipmentIdentification( 49 | ?string $sEquipmentIdentifier = null, 50 | ?string $sCodeListIdentificationCode = null, 51 | ?string $sCodeListResponsibleAgencyCode = null, 52 | ?string $sCountryIdentifier = null 53 | ): self { 54 | $aEquipmentIdentification = []; 55 | 56 | // Equipment Identifier 57 | 58 | if ($sEquipmentIdentifier !== null) { 59 | $aEquipmentIdentification[] = $sEquipmentIdentifier; 60 | } 61 | 62 | // Code List Identification Code 63 | 64 | if ($sCodeListIdentificationCode !== null) { 65 | $aEquipmentIdentification[] = $sCodeListIdentificationCode; 66 | } 67 | 68 | // Code List Responsible Agency Code 69 | 70 | if ($sCodeListResponsibleAgencyCode !== null) { 71 | $aEquipmentIdentification[] = $sCodeListResponsibleAgencyCode; 72 | } 73 | 74 | // Country Identifier 75 | 76 | if ($sCountryIdentifier !== null) { 77 | $aEquipmentIdentification[] = $sCountryIdentifier; 78 | } 79 | 80 | $this->aEquipmentIdentification = $aEquipmentIdentification; 81 | 82 | return $this; 83 | } 84 | 85 | /** 86 | * Set Equipment Size And Type (C224). 87 | * 88 | * @param mixed $sEquipmentSizeAndTypeDescriptionCode (8155) 89 | * @param mixed $sCodeListIdentificationCode (1131) 90 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 91 | * @param mixed $sEquipmentSizeAndTypeDescription (8154) 92 | * 93 | * @return self $this 94 | */ 95 | public function setEquipmentSizeAndType( 96 | ?string $sEquipmentSizeAndTypeDescriptionCode = null, 97 | ?string $sCodeListIdentificationCode = null, 98 | ?string $sCodeListResponsibleAgencyCode = null, 99 | ?string $sEquipmentSizeAndTypeDescription = null 100 | ) { 101 | if (empty($sEquipmentSizeAndTypeDescriptionCode)) { 102 | return $this; 103 | } 104 | 105 | $aEquipmentSizeAndType = []; 106 | 107 | // Equipment Size and Type Description Code 108 | 109 | if ($sEquipmentSizeAndTypeDescriptionCode !== null) { 110 | $aEquipmentSizeAndType[] = $sEquipmentSizeAndTypeDescriptionCode; 111 | } 112 | 113 | // Code List Identification Code 114 | 115 | if ($sCodeListIdentificationCode !== null) { 116 | $aEquipmentSizeAndType[] = $sCodeListIdentificationCode; 117 | } 118 | 119 | // Code List Responsible Agency Code 120 | 121 | if ($sCodeListResponsibleAgencyCode !== null) { 122 | $aEquipmentSizeAndType[] = $sCodeListResponsibleAgencyCode; 123 | } 124 | 125 | // Equipment Size and Type Description 126 | 127 | if ($sEquipmentSizeAndTypeDescription !== null) { 128 | $aEquipmentSizeAndType[] = $sEquipmentSizeAndTypeDescription; 129 | } 130 | 131 | $this->aEquipmentSizeAndType = $aEquipmentSizeAndType; 132 | 133 | return $this; 134 | } 135 | 136 | /** 137 | * Set Equipment Supplier Code. 138 | * 139 | * @param string $sEquipmentSupplierCode (8077) 140 | * 141 | * @return self $this 142 | */ 143 | public function setEquipmentSupplierCode(string $sEquipmentSupplierCode): self 144 | { 145 | $this->sEquipmentSupplierCode = $sEquipmentSupplierCode; 146 | 147 | return $this; 148 | } 149 | 150 | /** 151 | * Set Equipment Status Code. 152 | * 153 | * @param string $sEquipmentStatusCode (8249) 154 | * 155 | * @return self $this 156 | */ 157 | public function setEquipmentStatusCode(string $sEquipmentStatusCode): self 158 | { 159 | $this->sEquipmentStatusCode = $sEquipmentStatusCode; 160 | 161 | return $this; 162 | } 163 | 164 | /** 165 | * Set Full Or Empty Indicator Code. 166 | * 167 | * @param string $sFullOrEmptyIndicatorCode (8169) 168 | * 169 | * @return self $this 170 | */ 171 | public function setFullOrEmptyIndicatorCode(string $sFullOrEmptyIndicatorCode): self 172 | { 173 | $this->sFullOrEmptyIndicatorCode = $sFullOrEmptyIndicatorCode; 174 | 175 | return $this; 176 | } 177 | 178 | /** 179 | * Set Marking Instructions Code. 180 | * 181 | * @param string $sMarkingInstructionsCode (4233) 182 | * 183 | * @return self $this 184 | */ 185 | public function setMarkingInstructionsCode(string $sMarkingInstructionsCode): self 186 | { 187 | $this->sMarkingInstructionsCode = $sMarkingInstructionsCode; 188 | 189 | return $this; 190 | } 191 | 192 | /** 193 | * Compose. 194 | * 195 | * @return self $this 196 | */ 197 | public function compose(): self 198 | { 199 | $aComposed[] = self::SEGMENT_NAME; 200 | 201 | // Equipment Type Code Qualifier 202 | 203 | if ($this->sEquipmentTypeCodeQualifier !== null) { 204 | $aComposed[] = $this->sEquipmentTypeCodeQualifier; 205 | } 206 | 207 | // Equipment Identification 208 | 209 | if (count($this->aEquipmentIdentification) > 0) { 210 | $aComposed[] = $this->aEquipmentIdentification; 211 | } 212 | 213 | // Equipment Size and Type 214 | 215 | if (count($this->aEquipmentSizeAndType) > 0) { 216 | $aComposed[] = $this->aEquipmentSizeAndType; 217 | } 218 | 219 | // Equipment Supplier Code 220 | 221 | if ($this->sEquipmentSupplierCode !== null) { 222 | $aComposed[] = $this->sEquipmentSupplierCode; 223 | } 224 | 225 | // Equipment Status Code 226 | 227 | if ($this->sEquipmentStatusCode !== null) { 228 | $aComposed[] = $this->sEquipmentStatusCode; 229 | } 230 | 231 | // Full Or Empty Indicator Code 232 | 233 | if ($this->sFullOrEmptyIndicatorCode !== null) { 234 | $aComposed[] = $this->sFullOrEmptyIndicatorCode; 235 | } 236 | 237 | // Marking Instructions Code 238 | 239 | if ($this->sMarkingInstructionsCode !== null) { 240 | $aComposed[] = $this->sMarkingInstructionsCode; 241 | } 242 | 243 | $this->setComposed($aComposed); 244 | 245 | return $this; 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /src/Generator/Segment/FreeText.php: -------------------------------------------------------------------------------- 1 | sTextSubjectCodeQualifier = $sTextSubjectCodeQualifier; 33 | 34 | return $this; 35 | } 36 | 37 | /** 38 | * Set Free Text Function Code. 39 | * 40 | * @param string $sFreeTextFunctionCode (4453) 41 | * 42 | * @return self $this 43 | */ 44 | public function setFreeTextFunctionCode(string $sFreeTextFunctionCode): self 45 | { 46 | $this->sFreeTextFunctionCode = $sFreeTextFunctionCode; 47 | 48 | return $this; 49 | } 50 | 51 | /** 52 | * Set Text Reference (C107). 53 | * 54 | * @param string $sFreeTextDescriptionCode (4441) 55 | * @param mixed $sCodeListIdentificationCode (1131) 56 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 57 | * 58 | * @return self $this 59 | */ 60 | public function setTextReference( 61 | string $sFreeTextDescriptionCode = '', 62 | ?string $sCodeListIdentificationCode = null, 63 | ?string $sCodeListResponsibleAgencyCode = null 64 | ): self { 65 | $aTextReference = []; 66 | 67 | // Free Text Description Code 68 | $aTextReference[] = $sFreeTextDescriptionCode; 69 | 70 | // Code List Identification Code 71 | 72 | if ($sCodeListIdentificationCode !== null) { 73 | $aTextReference[] = $sCodeListIdentificationCode; 74 | } 75 | 76 | // Code List Responsible Agency Code 77 | 78 | if ($sCodeListResponsibleAgencyCode !== null) { 79 | $aTextReference[] = $sCodeListResponsibleAgencyCode; 80 | } 81 | 82 | $this->aTextReference = $aTextReference; 83 | 84 | return $this; 85 | } 86 | 87 | /** 88 | * Set Text Literal (C108). 89 | * 90 | * @param array $aTextLiteral (4440) 91 | * @return \EDI\Generator\Segment\FreeText 92 | */ 93 | public function setTextLiteral(array $aTextLiteral): self 94 | { 95 | $this->aTextLiteral = $aTextLiteral; 96 | 97 | return $this; 98 | } 99 | 100 | /** 101 | * Set Language Name Code. 102 | * 103 | * @param string $sLanguageNameCode (4451) 104 | * 105 | * @comment ISO 639-1 106 | * 107 | * @return self $this 108 | */ 109 | public function setLanguageNameCode(string $sLanguageNameCode): self 110 | { 111 | $this->sLanguageNameCode = $sLanguageNameCode; 112 | 113 | return $this; 114 | } 115 | 116 | /** 117 | * Set Free Text Format Code. 118 | * 119 | * @param string $sFreeTextFormatCode (4447) 120 | * 121 | * @return self $this 122 | */ 123 | public function setFreeTextFormatCode(string $sFreeTextFormatCode): self 124 | { 125 | $this->sFreeTextFormatCode = $sFreeTextFormatCode; 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Compose. 132 | * 133 | * @return self $this 134 | */ 135 | public function compose(): self 136 | { 137 | $aComposed[] = self::SEGMENT_NAME; 138 | 139 | // Text Subject Code Qualifier 140 | $aComposed[] = $this->sTextSubjectCodeQualifier; 141 | 142 | // Free Text Function Code 143 | 144 | if ($this->sFreeTextFunctionCode !== null) { 145 | $aComposed[] = $this->sFreeTextFunctionCode; 146 | } 147 | 148 | // Text Reference 149 | 150 | if (count($this->aTextReference) > 0) { 151 | $aComposed[] = $this->aTextReference; 152 | } 153 | 154 | // Text Literal 155 | 156 | if (count($this->aTextLiteral) > 0) { 157 | $aComposed[] = $this->aTextLiteral; 158 | } 159 | 160 | // Language Name Code 161 | 162 | if ($this->sLanguageNameCode !== null) { 163 | $aComposed[] = $this->sLanguageNameCode; 164 | } 165 | 166 | // Free Text Format Code 167 | 168 | if ($this->sFreeTextFormatCode !== null) { 169 | $aComposed[] = $this->sFreeTextFormatCode; 170 | } 171 | 172 | // dd($aComposed); 173 | 174 | $this->setComposed($aComposed); 175 | 176 | return $this; 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /src/Generator/Segment/Measurements.php: -------------------------------------------------------------------------------- 1 | sMeasurementPurposeCodeQualifier = $sMeasurementPurposeCodeQualifier; 31 | 32 | return $this; 33 | } 34 | 35 | /** 36 | * Set Measurement Details (C502). 37 | * 38 | * @param mixed $sMeasuredAttributeCode (6313) 39 | * @param mixed $sMeasurementSignificanceCode (6321) 40 | * @param mixed $sNonDiscreteMeasurementNameCode (6155) 41 | * @param mixed $sNonDiscreteMeasurementName (6154) 42 | * 43 | * @return self $this 44 | */ 45 | public function setMeasurementDetails( 46 | ?string $sMeasuredAttributeCode = null, 47 | ?string $sMeasurementSignificanceCode = null, 48 | ?string $sNonDiscreteMeasurementNameCode = null, 49 | ?string $sNonDiscreteMeasurementName = null 50 | ) { 51 | $aMeasurementDetails = []; 52 | 53 | // Measured Attribute Code 54 | 55 | if ($sMeasuredAttributeCode !== null) { 56 | $aMeasurementDetails[] = $sMeasuredAttributeCode; 57 | } 58 | 59 | // Measurement Significance code 60 | 61 | if ($sMeasurementSignificanceCode !== null) { 62 | $aMeasurementDetails[] = $sMeasurementSignificanceCode; 63 | } 64 | 65 | // Non-discrete Measurement Name Code 66 | 67 | if ($sNonDiscreteMeasurementNameCode !== null) { 68 | $aMeasurementDetails[] = $sNonDiscreteMeasurementNameCode; 69 | } 70 | 71 | // Non-discrete Measurement Name 72 | 73 | if ($sNonDiscreteMeasurementName !== null) { 74 | $aMeasurementDetails[] = $sNonDiscreteMeasurementName; 75 | } 76 | 77 | $this->aMeasurementDetails = $aMeasurementDetails; 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Set Value Range (C174). 84 | * 85 | * @param mixed $sMeasurementUnitCode 86 | * @param mixed $sMeasure 87 | * @param mixed $sRangeMinimumQuantity 88 | * @param mixed $sRangeMaximumQuantity 89 | * @param mixed $sSignificantDigitsQuantity 90 | * 91 | * @return self $this 92 | */ 93 | public function setValueRange( 94 | ?string $sMeasurementUnitCode = null, 95 | ?string $sMeasure = null, 96 | ?string $sRangeMinimumQuantity = null, 97 | ?string $sRangeMaximumQuantity = null, 98 | ?string $sSignificantDigitsQuantity = null 99 | ) { 100 | $aValueRange = []; 101 | 102 | // Measurement Unit Code 103 | 104 | if ($sMeasurementUnitCode !== null) { 105 | $aValueRange[] = $sMeasurementUnitCode; 106 | } 107 | 108 | // Measure 109 | 110 | if ($sMeasure !== null) { 111 | $aValueRange[] = $sMeasure; 112 | } 113 | 114 | // Range Minimum Quantity 115 | 116 | if ($sRangeMinimumQuantity !== null) { 117 | $aValueRange[] = $sRangeMinimumQuantity; 118 | } 119 | 120 | // Range Maximum Quantity 121 | 122 | if ($sRangeMaximumQuantity !== null) { 123 | $aValueRange[] = $sRangeMaximumQuantity; 124 | } 125 | 126 | // Significant Digits Quantity 127 | 128 | if ($sSignificantDigitsQuantity !== null) { 129 | $aValueRange[] = $sSignificantDigitsQuantity; 130 | } 131 | 132 | $this->aValueRange = $aValueRange; 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * Set Surface Or Layer Code. 139 | * 140 | * @param string $sSurfaceOrLayerCode (7383) 141 | * 142 | * @return self $this 143 | */ 144 | public function setSurfaceOrLayerCode(string $sSurfaceOrLayerCode): self 145 | { 146 | $this->sSurfaceOrLayerCode = $sSurfaceOrLayerCode; 147 | 148 | return $this; 149 | } 150 | 151 | /** 152 | * Compose. 153 | * 154 | * @return self $this 155 | */ 156 | public function compose(): self 157 | { 158 | $aComposed[] = self::SEGMENT_NAME; 159 | 160 | // Measurement Purpose Code Qualifier 161 | $aComposed[] = $this->sMeasurementPurposeCodeQualifier; 162 | 163 | // Measurement Details 164 | 165 | if (count($this->aMeasurementDetails) > 0) { 166 | $aComposed[] = $this->aMeasurementDetails; 167 | } 168 | 169 | // Value / Range 170 | 171 | if (count($this->aValueRange) > 0) { 172 | $aComposed[] = $this->aValueRange; 173 | } 174 | 175 | // Surface Or Layer Code 176 | 177 | if ($this->sSurfaceOrLayerCode !== null) { 178 | $aComposed[] = $this->sSurfaceOrLayerCode; 179 | } 180 | 181 | $this->setComposed($aComposed); 182 | 183 | return $this; 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /src/Generator/Segment/NameAndAddress.php: -------------------------------------------------------------------------------- 1 | sPartyFunctionCodeQualifier = $sPartyFunctionCodeQualifier; 37 | 38 | return $this; 39 | } 40 | 41 | /** 42 | * Set Party Identification Details (C082). 43 | * 44 | * @param string $sPartyIdentifier (3039) 45 | * @param mixed $sCodeListIdentificationCode (1131) 46 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 47 | * 48 | * @return self $this 49 | */ 50 | public function setPartyIdentificationDetails( 51 | string $sPartyIdentifier, 52 | ?string $sCodeListIdentificationCode = null, 53 | ?string $sCodeListResponsibleAgencyCode = null 54 | ): self { 55 | $aPartyIdentificationDetails = []; 56 | 57 | // Party Identifier 58 | $aPartyIdentificationDetails[] = $sPartyIdentifier; 59 | 60 | // Code List Identification Code 61 | 62 | if ($sCodeListIdentificationCode !== null) { 63 | $aPartyIdentificationDetails[] = $sCodeListIdentificationCode; 64 | } 65 | 66 | // Code List Responsible Agency Code 67 | 68 | if ($sCodeListResponsibleAgencyCode !== null) { 69 | $aPartyIdentificationDetails[] = $sCodeListResponsibleAgencyCode; 70 | } 71 | 72 | $this->aPartyIdentificationDetails = $aPartyIdentificationDetails; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * Set Name And Address (C058). 79 | * 80 | * @param array $aNameAndAddressDescription (3124) 81 | * 82 | * @return self $this 83 | */ 84 | public function setNameAndAddress(array $aNameAndAddressDescription): self 85 | { 86 | $this->aNameAndAddress = $aNameAndAddressDescription; 87 | 88 | return $this; 89 | } 90 | 91 | /** 92 | * Set Party Name (C080). 93 | * 94 | * @param array $aPartyName (3036) 95 | * 96 | * @return self $this 97 | */ 98 | public function setPartyName(array $aPartyName): self 99 | { 100 | $this->aPartyName = $aPartyName; 101 | 102 | return $this; 103 | } 104 | 105 | /** 106 | * Set Party Name Format Code. 107 | * 108 | * @param string $sPartyNameFormatCode (3045) 109 | * 110 | * @return self $this 111 | */ 112 | public function setPartyNameFormatCode(string $sPartyNameFormatCode): self 113 | { 114 | $this->sPartyNameFormatCode = $sPartyNameFormatCode; 115 | 116 | return $this; 117 | } 118 | 119 | /** 120 | * Set Street (C059). 121 | * 122 | * @param array $aStreet (3042) 123 | * 124 | * @return self $this 125 | */ 126 | public function setStreet(array $aStreet): self 127 | { 128 | $this->aStreet = $aStreet; 129 | 130 | return $this; 131 | } 132 | 133 | /** 134 | * Set City Name. 135 | * 136 | * @param string $sCityName (3164) 137 | * 138 | * @return self $this 139 | */ 140 | public function setCityName(string $sCityName): self 141 | { 142 | $this->sCityName = $sCityName; 143 | 144 | return $this; 145 | } 146 | 147 | /** 148 | * Set Country Subdivision Details. (C819). 149 | * 150 | * @param mixed $sCountrySubdivisionIdentifier (3229) 151 | * @param mixed $sCodeListIdentificationCode (1131) 152 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 153 | * @param mixed $sCountrySubdivisionName (3228) 154 | * 155 | * @return self $this 156 | */ 157 | public function setCountrySubdivisionDetails( 158 | ?string $sCountrySubdivisionIdentifier = null, 159 | ?string $sCodeListIdentificationCode = null, 160 | ?string $sCodeListResponsibleAgencyCode = null, 161 | ?string $sCountrySubdivisionName = null 162 | ) { 163 | $aCountrySubdivisionDetails = []; 164 | 165 | if ($sCountrySubdivisionIdentifier !== null) { 166 | $aCountrySubdivisionDetails[] = $sCountrySubdivisionIdentifier; 167 | } 168 | 169 | if ($sCodeListIdentificationCode !== null) { 170 | $aCountrySubdivisionDetails[] = $sCodeListIdentificationCode; 171 | } 172 | 173 | if ($sCodeListResponsibleAgencyCode !== null) { 174 | $aCountrySubdivisionDetails[] = $sCodeListResponsibleAgencyCode; 175 | } 176 | 177 | if ($sCountrySubdivisionName !== null) { 178 | $aCountrySubdivisionDetails[] = $sCountrySubdivisionName; 179 | } 180 | 181 | $this->aCountrySubdivisionDetails = $aCountrySubdivisionDetails; 182 | 183 | return $this; 184 | } 185 | 186 | /** 187 | * Set Postal Identification Code. 188 | * 189 | * @param string $sPostalIdentificationCode (3251) 190 | * 191 | * @return self $this 192 | */ 193 | public function setPostalIdentificationCode(string $sPostalIdentificationCode): self 194 | { 195 | $this->sPostalIdentificationCode = $sPostalIdentificationCode; 196 | 197 | return $this; 198 | } 199 | 200 | /** 201 | * Set Country Identifier. 202 | * 203 | * @param string $sCountryIdentifier (3207) 204 | * 205 | * @comment ISO 3166-1 two alpha country code 206 | * 207 | * @return self $this 208 | */ 209 | public function setCountryIdentifier(string $sCountryIdentifier): self 210 | { 211 | $this->sCountryIdentifier = $sCountryIdentifier; 212 | 213 | return $this; 214 | } 215 | 216 | /** 217 | * Compose. 218 | * 219 | * @return self $this 220 | */ 221 | public function compose(): self 222 | { 223 | $aComposed[] = self::SEGMENT_NAME; 224 | 225 | // Party Function Code Qualifier 226 | 227 | if ($this->sPartyFunctionCodeQualifier !== null) { 228 | $aComposed[] = $this->sPartyFunctionCodeQualifier; 229 | } 230 | 231 | // Party Identification Details 232 | 233 | if (count($this->aPartyIdentificationDetails) > 0) { 234 | $aComposed[] = $this->aPartyIdentificationDetails; 235 | } 236 | 237 | // Name And Address 238 | 239 | if (count($this->aNameAndAddress) > 0) { 240 | $aComposed[] = $this->aNameAndAddress; 241 | } 242 | 243 | // Party Name 244 | 245 | if (count($this->aPartyName) > 0) { 246 | $aPartyName = $this->aPartyName; 247 | 248 | if ($this->sPartyNameFormatCode !== null) { 249 | $aPartyName[] = $this->sPartyNameFormatCode; 250 | } 251 | 252 | $aComposed[] = $aPartyName; 253 | } 254 | 255 | // Street 256 | 257 | if (count($this->aStreet) > 0) { 258 | $aComposed[] = $this->aStreet; 259 | } 260 | 261 | // City Name 262 | 263 | if ($this->sCityName !== null) { 264 | $aComposed[] = $this->sCityName; 265 | } 266 | 267 | // Country Subdivision Details 268 | 269 | if (count($this->aCountrySubdivisionDetails) > 0) { 270 | $aComposed[] = $this->aCountrySubdivisionDetails; 271 | } 272 | 273 | // Postal Identification Code 274 | 275 | if ($this->sPostalIdentificationCode !== null) { 276 | $aComposed[] = $this->sPostalIdentificationCode; 277 | } 278 | 279 | // Country Identifier 280 | 281 | if ($this->sCountryIdentifier !== null) { 282 | $aComposed[] = $this->sCountryIdentifier; 283 | } 284 | 285 | $this->setComposed($aComposed); 286 | 287 | return $this; 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /src/Generator/Segment/PercentageDetails.php: -------------------------------------------------------------------------------- 1 | aPercentageDetails = $aPercentageDetails; 70 | 71 | return $this; 72 | } 73 | 74 | /** 75 | * Set Status Description Code 76 | * 77 | * @param mixed $sStatusDescriptionCode (4405) 78 | * 79 | * @return self $this 80 | */ 81 | public function setStatusDescriptionCode($sStatusDescriptionCode) 82 | { 83 | $this->sStatusDescriptionCode = $sStatusDescriptionCode; 84 | 85 | return $this; 86 | } 87 | 88 | /** 89 | * Compose. 90 | * 91 | * @return self $this 92 | */ 93 | public function compose(): self 94 | { 95 | $aComposed[] = self::SEGMENT_NAME; 96 | 97 | // Percentage Details 98 | $aComposed[] = $this->aPercentageDetails; 99 | 100 | // Status Description Code 101 | 102 | if ($this->sStatusDescriptionCode !== null) { 103 | $aComposed[] = $this->sStatusDescriptionCode; 104 | } 105 | 106 | $this->setComposed($aComposed); 107 | 108 | return $this; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Generator/Segment/PlaceLocationIdentification.php: -------------------------------------------------------------------------------- 1 | sLocationFunctionCodeQualifier = $sLocationFunctionCodeQualifier; 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Set Location Identification (C517). 38 | * 39 | * @param mixed $sLocationIdentifier (3225) 40 | * @param mixed $sCodeListIdentificationCode (1131) 41 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 42 | * @param mixed $sLocationName (3224) 43 | * 44 | * @return self $this 45 | */ 46 | public function setLocationIdentification( 47 | ?string $sLocationIdentifier = null, 48 | ?string $sCodeListIdentificationCode = null, 49 | ?string $sCodeListResponsibleAgencyCode = null, 50 | ?string $sLocationName = null 51 | ) { 52 | $aLocationIdentification = []; 53 | 54 | // Location Identifier 55 | 56 | if ($sLocationIdentifier !== null) { 57 | $aLocationIdentification[] = $sLocationIdentifier; 58 | } 59 | 60 | // Code List Identification Code 61 | 62 | if ($sCodeListIdentificationCode !== null) { 63 | $aLocationIdentification[] = $sCodeListIdentificationCode; 64 | } 65 | 66 | // Code List Responsible Agency Code 67 | 68 | if ($sCodeListResponsibleAgencyCode !== null) { 69 | $aLocationIdentification[] = $sCodeListResponsibleAgencyCode; 70 | } 71 | 72 | // Location Name 73 | 74 | if ($sLocationName !== null) { 75 | $aLocationIdentification[] = $sLocationName; 76 | } 77 | 78 | $this->aLocationIdentification = $aLocationIdentification; 79 | 80 | return $this; 81 | } 82 | 83 | /** 84 | * Set Related Location One Identification (C519). 85 | * 86 | * @param mixed $sFirstRelatedLocationIdentifier (3223) 87 | * @param mixed $sCodeListIdentificationCode (1131) 88 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 89 | * @param mixed $sFirstRelatedLocationName (3222) 90 | * 91 | * @return self $this 92 | */ 93 | public function setRelatedLocationOneIdentification( 94 | ?string $sFirstRelatedLocationIdentifier = null, 95 | ?string $sCodeListIdentificationCode = null, 96 | ?string $sCodeListResponsibleAgencyCode = null, 97 | ?string $sFirstRelatedLocationName = null 98 | ) { 99 | $aRelatedLocationOneIdentification = []; 100 | 101 | // First Related Location Identifier 102 | 103 | if ($sFirstRelatedLocationIdentifier !== null) { 104 | $aRelatedLocationOneIdentification[] = $sFirstRelatedLocationIdentifier; 105 | } 106 | 107 | // Code List Identification Code 108 | 109 | if ($sCodeListIdentificationCode !== null) { 110 | $aRelatedLocationOneIdentification[] = $sCodeListIdentificationCode; 111 | } 112 | 113 | // Code List Responsible Agency Code 114 | 115 | if ($sCodeListResponsibleAgencyCode !== null) { 116 | $aRelatedLocationOneIdentification[] = $sCodeListResponsibleAgencyCode; 117 | } 118 | 119 | // First Related Location Name 120 | 121 | if ($sFirstRelatedLocationName !== null) { 122 | $aRelatedLocationOneIdentification[] = $sFirstRelatedLocationName; 123 | } 124 | 125 | $this->aRelatedLocationOneIdentification = $aRelatedLocationOneIdentification; 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Set Related Location Two Identification (C553). 132 | * 133 | * @param mixed $sSecondRelatedLocationIdentifier (3233) 134 | * @param mixed $sCodeListIdentificationCode (1131) 135 | * @param mixed $sCodeListResponsibleAgencyCode (3055) 136 | * @param mixed $sSecondRelatedLocationName (3232) 137 | * 138 | * @return self $this 139 | */ 140 | public function setRelatedLocationTwoIdentification( 141 | ?string $sSecondRelatedLocationIdentifier = null, 142 | ?string $sCodeListIdentificationCode = null, 143 | ?string $sCodeListResponsibleAgencyCode = null, 144 | ?string $sSecondRelatedLocationName = null 145 | ) { 146 | $aRelatedLocationTwoIdentification = []; 147 | 148 | // Second Related Location Identifier 149 | 150 | if ($sSecondRelatedLocationIdentifier !== null) { 151 | $aRelatedLocationTwoIdentification[] = $sSecondRelatedLocationIdentifier; 152 | } 153 | 154 | // Code List Identification Code 155 | 156 | if ($sCodeListIdentificationCode !== null) { 157 | $aRelatedLocationTwoIdentification[] = $sCodeListIdentificationCode; 158 | } 159 | 160 | // Code List responsible Agency Code 161 | 162 | if ($sCodeListResponsibleAgencyCode !== null) { 163 | $aRelatedLocationTwoIdentification[] = $sCodeListResponsibleAgencyCode; 164 | } 165 | 166 | // Second Related Location Name 167 | 168 | if ($sSecondRelatedLocationName !== null) { 169 | $aRelatedLocationTwoIdentification[] = $sSecondRelatedLocationName; 170 | } 171 | 172 | $this->aRelatedLocationTwoIdentification = $aRelatedLocationTwoIdentification; 173 | 174 | return $this; 175 | } 176 | 177 | /** 178 | * Set Relation Code. 179 | * 180 | * @param string $sRelationCode (5479) 181 | * 182 | * @return self $this 183 | */ 184 | public function setRelationCode(string $sRelationCode): self 185 | { 186 | $this->sRelationCode = $sRelationCode; 187 | 188 | return $this; 189 | } 190 | 191 | /** 192 | * Compose. 193 | * 194 | * @return self $this 195 | */ 196 | public function compose(): self 197 | { 198 | $aComposed[] = self::SEGMENT_NAME; 199 | 200 | // Location Function Code Qualifier 201 | $aComposed[] = $this->sLocationFunctionCodeQualifier; 202 | 203 | // Location Identification 204 | 205 | if (count($this->aLocationIdentification) > 0) { 206 | $aComposed[] = $this->aLocationIdentification; 207 | } 208 | 209 | // Related Location One Identification 210 | 211 | if (count($this->aRelatedLocationOneIdentification) > 0) { 212 | $aComposed[] = $this->aRelatedLocationOneIdentification; 213 | } 214 | 215 | // Related Location Two Identification 216 | 217 | if (count($this->aRelatedLocationTwoIdentification) > 0) { 218 | $aComposed[] = $this->aRelatedLocationTwoIdentification; 219 | } 220 | 221 | // Relation Code 222 | 223 | if ($this->sRelationCode !== null) { 224 | $aComposed[] = $this->sRelationCode; 225 | } 226 | 227 | $this->setComposed($aComposed); 228 | 229 | return $this; 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/Generator/Segment/RangeDetails.php: -------------------------------------------------------------------------------- 1 | sRangeTypeCodeQualifier = $sRangeTypeCodeQualifier; 31 | 32 | return $this; 33 | } 34 | 35 | /** 36 | * Set Measurement Unit Code. 37 | * 38 | * @param string $sMeasurementUnitCode (6411) 39 | * 40 | * @return self $this 41 | */ 42 | public function setMeasurementUnitCode(string $sMeasurementUnitCode): self 43 | { 44 | $this->sMeasurementUnitCode = $sMeasurementUnitCode; 45 | 46 | return $this; 47 | } 48 | 49 | /** 50 | * Set Range Minimum Quantity. 51 | * 52 | * @param string $sRangeMinimumQuantity (6162) 53 | * 54 | * @return self $this 55 | */ 56 | public function setRangeMinimumQuantity(string $sRangeMinimumQuantity): self 57 | { 58 | $this->sRangeMinimumQuantity = $sRangeMinimumQuantity; 59 | 60 | return $this; 61 | } 62 | 63 | /** 64 | * Set Range Maximum Quantity. 65 | * 66 | * @param string $sRangeMaximumQuantity (6152) 67 | * 68 | * @return self $this 69 | */ 70 | public function setRangeMaximumQuantity(string $sRangeMaximumQuantity): self 71 | { 72 | $this->sRangeMaximumQuantity = $sRangeMaximumQuantity; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * Compose. 79 | * 80 | * @return self $this 81 | */ 82 | public function compose(): self 83 | { 84 | $aComposed[] = self::SEGMENT_NAME; 85 | 86 | // Range Type Code Qualifier 87 | $aComposed[] = $this->sRangeTypeCodeQualifier; 88 | 89 | // Measurement Unit Code 90 | $aRange[] = $this->sMeasurementUnitCode; 91 | 92 | // Range Minimum Quantity 93 | 94 | if ($this->sRangeMinimumQuantity !== null) { 95 | $aRange[] = $this->sRangeMinimumQuantity; 96 | } 97 | 98 | // Range Maximum Quantity 99 | 100 | if ($this->sRangeMaximumQuantity !== null) { 101 | $aRange[] = $this->sRangeMaximumQuantity; 102 | } 103 | 104 | if (count($aRange) > 0) { 105 | $aComposed[] = $aRange; 106 | } 107 | 108 | $this->setComposed($aComposed); 109 | 110 | return $this; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/Generator/Segment/Reference.php: -------------------------------------------------------------------------------- 1 | sReferenceCodeQualifier = $sReferenceCodeQualifier; 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Set Reference Identifier. 38 | * 39 | * @param string $sReferenceIdentifier (1154) 40 | * 41 | * @return self $this 42 | */ 43 | public function setReferenceIdentifier(string $sReferenceIdentifier): self 44 | { 45 | $this->sReferenceIdentifier = $sReferenceIdentifier; 46 | 47 | return $this; 48 | } 49 | 50 | /** 51 | * Set Document Line Identifier. 52 | * 53 | * @param string $sDocumentLineIdentifier (1156) 54 | * 55 | * @return self $this 56 | */ 57 | public function setDocumentLineIdentifier(string $sDocumentLineIdentifier): self 58 | { 59 | $this->sDocumentLineIdentifier = $sDocumentLineIdentifier; 60 | 61 | return $this; 62 | } 63 | 64 | /** 65 | * Set Version Identifier. 66 | * 67 | * @param string $sVersionIdentifier (1056) 68 | * 69 | * @return self $this 70 | */ 71 | public function setVersionIdentifier(string $sVersionIdentifier): self 72 | { 73 | $this->sVersionIdentifier = $sVersionIdentifier; 74 | 75 | return $this; 76 | } 77 | 78 | /** 79 | * Set Revision Identifier. 80 | * 81 | * @param string $sRevisionIdentifier (1060) 82 | * 83 | * @return self $this 84 | */ 85 | public function setRevisionIdentifier(string $sRevisionIdentifier): self 86 | { 87 | $this->sRevisionIdentifier = $sRevisionIdentifier; 88 | 89 | return $this; 90 | } 91 | 92 | /** 93 | * Compose. 94 | * 95 | * @return self $this 96 | */ 97 | public function compose(): self 98 | { 99 | $aComposed[] = self::SEGMENT_NAME; 100 | 101 | // Reference Code Qualifier 102 | $aReference[] = $this->sReferenceCodeQualifier; 103 | 104 | // Reference Identifier 105 | 106 | if ($this->sReferenceIdentifier !== null) { 107 | $aReference[] = $this->sReferenceIdentifier; 108 | } 109 | 110 | // Document Line Identifier 111 | 112 | if ($this->sDocumentLineIdentifier !== null) { 113 | $aReference[] = $this->sDocumentLineIdentifier; 114 | } 115 | 116 | // Version Identifier 117 | 118 | if ($this->sVersionIdentifier !== null) { 119 | $aReference[] = $this->sVersionIdentifier; 120 | } 121 | 122 | // Revision Identifier 123 | 124 | if ($this->sRevisionIdentifier !== null) { 125 | $aReference[] = $this->sRevisionIdentifier; 126 | } 127 | 128 | if (count($aReference) > 0) { 129 | $aComposed[] = $aReference; 130 | } 131 | 132 | $this->setComposed($aComposed); 133 | 134 | return $this; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/Generator/Segment/Temperature.php: -------------------------------------------------------------------------------- 1 | sTemperatureTypeCodeQualifier = $sTemperatureTypeCodeQualifier; 29 | 30 | return $this; 31 | } 32 | 33 | /** 34 | * Set Temperature Setting (C239). 35 | * 36 | * @param mixed $sTemperatureDegree (6246) 37 | * @param mixed $sMeasurementUnitCode (6411) 38 | * 39 | * @return self $this 40 | */ 41 | public function setTemperatureSetting( 42 | ?string $sTemperatureDegree = null, 43 | ?string $sMeasurementUnitCode = null 44 | ) { 45 | $aTemperatureSetting = []; 46 | 47 | // Temperature Degree 48 | 49 | if ($sTemperatureDegree !== null) { 50 | $aTemperatureSetting[] = $sTemperatureDegree; 51 | } 52 | 53 | // Measurement Unit Code 54 | 55 | if ($sMeasurementUnitCode !== null) { 56 | $aTemperatureSetting[] = $sMeasurementUnitCode; 57 | } 58 | 59 | $this->aTemperatureSetting = $aTemperatureSetting; 60 | 61 | return $this; 62 | } 63 | 64 | /** 65 | * Compose. 66 | * 67 | * @return self $this 68 | */ 69 | public function compose(): self 70 | { 71 | $aComposed[] = self::SEGMENT_NAME; 72 | 73 | // Temperature Type Code Qualifier 74 | 75 | $aComposed[] = $this->sTemperatureTypeCodeQualifier; 76 | 77 | // Temperature Setting 78 | 79 | if (count($this->aTemperatureSetting) > 0) { 80 | $aComposed[] = $this->aTemperatureSetting; 81 | } 82 | 83 | $this->setComposed($aComposed); 84 | 85 | return $this; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Generator/Traits/ContactPerson.php: -------------------------------------------------------------------------------- 1 | contactPerson; 27 | } 28 | 29 | /** 30 | * @param string $contactPerson 31 | * @param string $section 32 | *@param|string $prefix used for prefixing the variableName deliveryAddressContactPerson 33 | * 34 | * @return $this 35 | */ 36 | public function setContactPerson($contactPerson, $section = '', $prefix = null) 37 | { 38 | $var = "contactPerson"; 39 | if ($prefix) { 40 | $var = $prefix . ucfirst($var); 41 | } 42 | 43 | $this->{$var} = [ 44 | 'CTA', 45 | $section, 46 | [ 47 | $section, 48 | $contactPerson, 49 | ], 50 | ]; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return array 57 | */ 58 | public function getMailAddress() 59 | { 60 | return $this->mailAddress; 61 | } 62 | 63 | /** 64 | * @param string $mailAddress 65 | * 66 | *@param|string $prefix 67 | * 68 | * @return $this 69 | */ 70 | public function setMailAddress($mailAddress, $prefix = null) 71 | { 72 | $var = "mailAddress"; 73 | if ($prefix) { 74 | $var = $prefix . ucfirst($var); 75 | } 76 | $this->{$var} = [ 77 | 'COM', 78 | [ 79 | $mailAddress, 80 | 'EM', 81 | ], 82 | ]; 83 | return $this; 84 | } 85 | 86 | /** 87 | * @return array 88 | */ 89 | public function getPhoneNumber() 90 | { 91 | return $this->phoneNumber; 92 | } 93 | 94 | /** 95 | * @param string $phoneNumber 96 | * 97 | *@param|string $prefix 98 | * 99 | * @return $this 100 | */ 101 | public function setPhoneNumber($phoneNumber, $prefix = null) 102 | { 103 | $var = "phoneNumber"; 104 | if ($prefix) { 105 | $var = $prefix . ucfirst($var); 106 | } 107 | $this->{$var} = [ 108 | 'COM', 109 | [ 110 | $phoneNumber, 111 | 'TE', 112 | ], 113 | ]; 114 | return $this; 115 | } 116 | 117 | /** 118 | * @return array 119 | */ 120 | public function getFaxNumber() 121 | { 122 | return $this->faxNumber; 123 | } 124 | 125 | /** 126 | * @param string $faxNumber 127 | * 128 | *@param|string $prefix 129 | * 130 | * @return $this 131 | */ 132 | public function setFaxNumber($faxNumber, $prefix = null) 133 | { 134 | $var = "faxNumber"; 135 | if ($prefix) { 136 | $var = $prefix . ucfirst($var); 137 | } 138 | 139 | $this->{$var} = [ 140 | 'COM', 141 | [ 142 | $faxNumber, 143 | 'FX', 144 | ], 145 | ]; 146 | return $this; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/Generator/Traits/ItemPrice.php: -------------------------------------------------------------------------------- 1 | grossPrice; 50 | } 51 | 52 | /** 53 | * @param string $grossPrice 54 | * @param string $format 55 | * @param int $decimals 56 | * @return $this 57 | */ 58 | public function setGrossPrice($grossPrice, $format = EdiFactNumber::DECIMAL_COMMA, $decimals = 2) 59 | { 60 | $this->grossPrice = self::addPRISegment('AAB', $grossPrice, 1, 'PCE', $decimals, $format); 61 | $this->addKeyToCompose('grossPrice'); 62 | 63 | return $this; 64 | } 65 | 66 | /** 67 | * @return array 68 | */ 69 | public function getNetPrice() 70 | { 71 | return $this->netPrice; 72 | } 73 | 74 | /** 75 | * @param string $netPrice 76 | * @param string $format 77 | * @param int $decimals 78 | * @return $this 79 | */ 80 | public function setNetPrice($netPrice, $format = EdiFactNumber::DECIMAL_COMMA, $decimals = 2) 81 | { 82 | $this->netPrice = self::addPRISegment('AAA', $netPrice, 1, 'PCE', $decimals, $format); 83 | $this->addKeyToCompose('netPrice'); 84 | 85 | return $this; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Generator/Traits/Segments.php: -------------------------------------------------------------------------------- 1 | 5) { 141 | $textLines = array_slice($textLines, 0, 5); 142 | } 143 | 144 | return ['FTX', $qualifier, '', [$reference, '89'], $textLines]; 145 | } 146 | 147 | /** 148 | * SEGMENT UTILITIES 149 | */ 150 | 151 | /** 152 | * @param string, $functionCode 153 | * @param $identifier 154 | * 155 | * @return array|bool 156 | */ 157 | protected static function addRFFSegment($functionCode, $identifier) 158 | { 159 | if (empty($identifier)) { 160 | return false; 161 | } 162 | 163 | return [ 164 | 'RFF', 165 | [ 166 | $functionCode, 167 | self::maxChars($identifier, 35), 168 | ], 169 | ]; 170 | } 171 | 172 | /** 173 | * @param string|\DateTime $date 174 | * @param string $type 175 | * @param int $formatQualifier 176 | * 177 | * @return array 178 | * @throws EdifactException 179 | * @see http://www.unece.org/trade/untdid/d96a/trsd/trsddtm.htm 180 | */ 181 | protected static function addDTMSegment($date, $type, $formatQualifier = EdifactDate::DATE) 182 | { 183 | $data = []; 184 | $data[] = (string) $type; 185 | if (!empty($date)) { 186 | $data[] = EdifactDate::get($date, $formatQualifier); 187 | $data[] = (string) $formatQualifier; 188 | } 189 | 190 | return ['DTM', $data]; 191 | } 192 | 193 | /** 194 | * @param $documentNumber 195 | * @param $type 196 | * 197 | * @return array 198 | */ 199 | public static function addBGMSegment($documentNumber, $type) 200 | { 201 | return [ 202 | 'BGM', 203 | [ 204 | $type, 205 | '', 206 | '89', 207 | ], 208 | $documentNumber, 209 | ]; 210 | } 211 | 212 | /** 213 | * @param $qualifier 214 | * @param $value 215 | * 216 | * @return array 217 | */ 218 | public static function addMOASegment($qualifier, $value) 219 | { 220 | return [ 221 | 'MOA', 222 | [ 223 | '', 224 | (string) $qualifier, 225 | EdiFactNumber::convert($value), 226 | ], 227 | ]; 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /src/Generator/Traits/TransportData.php: -------------------------------------------------------------------------------- 1 | transportData; 20 | } 21 | 22 | /** 23 | * @param string $trackingCode 24 | * @param int $type 25 | * @return self 26 | */ 27 | public function setTransportData($trackingCode, $type = 30) 28 | { 29 | $this->isAllowed($type, [ 30 | 10, 31 | 20, 32 | 30, 33 | 40, 34 | 50, 35 | 60, 36 | 90 37 | ]); 38 | $this->transportData = ['TDT', '13', $trackingCode, (string)$type]; 39 | 40 | return $this; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Generator/Traits/VatAndCurrency.php: -------------------------------------------------------------------------------- 1 | vatNumber; 29 | } 30 | 31 | /** 32 | * @param string $vatNumber 33 | * 34 | * @return $this 35 | */ 36 | public function setVatNumber($vatNumber) 37 | { 38 | $this->vatNumber = self::addRFFSegment('VA', str_replace(' ', '', $vatNumber)); 39 | 40 | return $this; 41 | } 42 | 43 | /** 44 | * @return array 45 | */ 46 | public function getCurrency() 47 | { 48 | return $this->currency; 49 | } 50 | 51 | /** 52 | * @param string $currency 53 | * @param string $qualifier 54 | * @return $this 55 | */ 56 | public function setCurrency($currency = 'EUR', $qualifier = EdifactCurrency::CURRENCY_ORDER) 57 | { 58 | $this->currency = [ 59 | 'CUX', 60 | [ 61 | '2', 62 | $currency, 63 | $qualifier 64 | ] 65 | ]; 66 | 67 | return $this; 68 | } 69 | 70 | /** 71 | * @param string $currency 72 | * @return $this 73 | */ 74 | public function setSupplierCurrency($currency = 'EUR') 75 | { 76 | $this->setCurrency($currency, EdifactCurrency::CURRENCY_SUPPLIER); 77 | 78 | return $this; 79 | } 80 | 81 | /** 82 | * @param string $currency 83 | * @return $this 84 | */ 85 | public function setInvoiceCurrency($currency = 'EUR') 86 | { 87 | $this->setCurrency($currency, EdifactCurrency::CURRENCY_INVOICING); 88 | 89 | return $this; 90 | } 91 | 92 | /** 93 | * @param string $currency 94 | * @return $this 95 | */ 96 | public function setQuotationCurrency($currency = 'EUR') 97 | { 98 | $this->setCurrency($currency, EdifactCurrency::CURRENCY_QUOTATION); 99 | 100 | return $this; 101 | } 102 | 103 | /** 104 | * @param string $currency 105 | * @return $this 106 | */ 107 | public function setAccountCurrency($currency = 'EUR') 108 | { 109 | $this->setCurrency($currency, EdifactCurrency::CURRENCY_ACCOUNT); 110 | 111 | return $this; 112 | } 113 | 114 | /** 115 | * @param string $currency 116 | * @return $this 117 | */ 118 | public function setPaymentCurrency($currency = 'EUR') 119 | { 120 | $this->setCurrency($currency, EdifactCurrency::CURRENCY_PAYMENT); 121 | 122 | return $this; 123 | } 124 | 125 | /** 126 | * @return array 127 | */ 128 | public function getExcludingVatText() 129 | { 130 | return $this->excludingVatText; 131 | } 132 | 133 | /** 134 | * @param string $excludingVatText 135 | * 136 | * @return $this 137 | */ 138 | public function setExcludingVatText($excludingVatText) 139 | { 140 | $this->excludingVatText = self::addFTXSegment($excludingVatText, 'OSI', 'ROU'); 141 | 142 | return $this; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/Generator/Vermas.php: -------------------------------------------------------------------------------- 1 | dtmSend = self::dtmSegment(137, date('YmdHi')); 48 | } 49 | 50 | /** 51 | * Date of the message submission 52 | * @param $dtm 53 | * @return \EDI\Generator\Vermas 54 | */ 55 | public function setDTMMessageSendingTime($dtm) 56 | { 57 | $this->dtmSend = self::dtmSegment(137, $dtm); 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * $line: Master Liner Codes List 64 | * @param $line 65 | * @return \EDI\Generator\Vermas 66 | */ 67 | public function setCarrier($line) 68 | { 69 | $this->messageLine = ['NAD', 'CA', [$line, 'LINES', 306]]; 70 | 71 | return $this; 72 | } 73 | 74 | /** 75 | * $cntFunctionCode: DE 3139 76 | * $cntIdentifier: free text 77 | * $cntName: free text 78 | * @param $companyName 79 | * @return \EDI\Generator\Vermas 80 | */ 81 | public function setMessageSenderCompany($companyName) 82 | { 83 | $this->messageSenderCompany = ['NAD', 'TB', $companyName]; 84 | 85 | return $this; 86 | } 87 | 88 | /** 89 | * $cntFunctionCode: DE 3139 90 | * $cntIdentifier: free text 91 | * $cntName: free text 92 | * @param $cntFunctionCode 93 | * @param $cntIdentifier 94 | * @param $cntName 95 | * @return \EDI\Generator\Vermas 96 | */ 97 | public function setMessageSender($cntFunctionCode, $cntIdentifier, $cntName) 98 | { 99 | $this->messageSender = ['CTA', $cntFunctionCode, [$cntIdentifier, $cntName]]; 100 | 101 | return $this; 102 | } 103 | 104 | /** 105 | * $comType: DE 3155 106 | * $comData: free text 107 | * @param $comType 108 | * @param $comData 109 | * @return \EDI\Generator\Vermas 110 | */ 111 | public function setMessageSenderInformation($comType, $comData) 112 | { 113 | $this->messageSenderInformation = ['COM', [$comData, $comType]]; 114 | 115 | return $this; 116 | } 117 | 118 | /** 119 | * @param \EDI\Generator\Vermas\Container $container 120 | * @return $this 121 | */ 122 | public function addContainer(Vermas\Container $container) 123 | { 124 | $this->containers[] = $container; 125 | 126 | return $this; 127 | } 128 | 129 | /** 130 | * Compose. 131 | * 132 | * @param mixed $sMessageFunctionCode (1225) 133 | * @param mixed $sDocumentNameCode (1001) 134 | * @param mixed $sDocumentIdentifier (1004) 135 | * 136 | * @return \EDI\Generator\Message ::compose() 137 | * @throws \EDI\Generator\EdifactException 138 | */ 139 | public function compose(?string $sMessageFunctionCode = "5", ?string $sDocumentNameCode = "749", ?string $sDocumentIdentifier = null): parent 140 | { 141 | $this->messageContent = [ 142 | ['BGM', $sDocumentNameCode, $this->messageID, $sMessageFunctionCode], 143 | ]; 144 | 145 | /* message creation date and time */ 146 | $this->messageContent[] = $this->dtmSend; 147 | 148 | $this->messageContent[] = $this->messageSenderCompany; 149 | 150 | /* carrier line */ 151 | if ($this->messageLine !== '') { 152 | $this->messageContent[] = $this->messageLine; 153 | } 154 | 155 | /* sender information */ 156 | if ($this->messageSender !== '') { 157 | $this->messageContent[] = $this->messageSender; 158 | } 159 | if ($this->messageSenderInformation !== '') { 160 | $this->messageContent[] = $this->messageSenderInformation; 161 | } 162 | 163 | /* equipment and vgm information */ 164 | foreach ($this->containers as $cntr) { 165 | $content = $cntr->compose(); 166 | foreach ($content as $segment) { 167 | $this->messageContent[] = $segment; 168 | } 169 | } 170 | 171 | return parent::compose(); 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /src/Generator/Vermas/Container.php: -------------------------------------------------------------------------------- 1 | cntr = \EDI\Generator\Message::eqdSegment('CN', $number, [$size, '6346', '306']); 35 | if ($fixedFields) { 36 | $this->cntr = \EDI\Generator\Message::eqdSegment('CN', $number, [$size, '6346', '306'], '', '', 5); 37 | } 38 | 39 | return $this; 40 | } 41 | 42 | /** 43 | * @param $booking 44 | *@param $sequence 45 | * @return \EDI\Generator\Vermas\Container 46 | */ 47 | public function setBooking($booking, $sequence = null) 48 | { 49 | $bkg = []; 50 | $bkg[] = \EDI\Generator\Message::rffSegment('BN', $booking); 51 | if ($sequence !== null) { 52 | $bkg[] = \EDI\Generator\Message::rffSegment('SQ', $sequence); 53 | } 54 | $this->bkg = $bkg; 55 | 56 | return $this; 57 | } 58 | 59 | /** 60 | * $seal = free text 61 | * $sealIssuer = DE 9303 62 | * @param $seal 63 | * @param $sealIssuer 64 | * @return \EDI\Generator\Vermas\Container 65 | */ 66 | public function setSeal($seal, $sealIssuer) 67 | { 68 | $this->seal = ['SEL', [$seal, $sealIssuer]]; 69 | 70 | return $this; 71 | } 72 | 73 | /** 74 | * $weightMode = DE 6313 75 | * $weight = free text 76 | * $unit = KGM or LBS 77 | * @param $weightMode 78 | * @param $weight 79 | * @param string $unit 80 | * @return \EDI\Generator\Vermas\Container 81 | */ 82 | public function setMeasures($weightMode, $weight, $unit = 'KGM') 83 | { 84 | $this->measures = ['MEA', 'AAE', $weightMode, [$unit, $weight]]; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * $type = SM1 | SM2 91 | * $cert = documentation identification 92 | * @param $type 93 | * @param $cert 94 | * @return \EDI\Generator\Vermas\Container 95 | */ 96 | public function setWeighMethod($type, $cert) 97 | { 98 | $this->weighMethod = ['DOC', [$type, 'VGM', 306], $cert]; 99 | 100 | return $this; 101 | } 102 | 103 | /** 104 | * $type = SM1 | SM2 105 | * $cert = documentation identification 106 | *@param $date 107 | * @return \EDI\Generator\Vermas\Container 108 | */ 109 | public function setWeighDate($date = null) 110 | { 111 | if ($date === null) { 112 | $date = date('YmdHi'); 113 | } 114 | $this->weighDate = \EDI\Generator\Message::dtmSegment(798, $date); 115 | 116 | return $this; 117 | } 118 | 119 | /** 120 | * $spcShipper = SOLAS verified gross mass responsible party 121 | * @param $spcWpa 122 | * @return \EDI\Generator\Vermas\Container 123 | */ 124 | public function setWeighingStationId($spcWpa) 125 | { 126 | $this->spcWpa = ['NAD', 'WPA', $spcWpa]; 127 | 128 | return $this; 129 | } 130 | 131 | /** 132 | * $spcShipper = SOLAS verified gross mass responsible party 133 | * @param $spcShipper 134 | *@param $spcCity 135 | * @return \EDI\Generator\Vermas\Container 136 | */ 137 | public function setShipper($spcShipper, $spcCity = null) 138 | { 139 | $this->shipper = ['NAD', 'SPC', '', '', $spcShipper]; 140 | if ($spcCity !== null) { 141 | $this->shipper[] = ''; 142 | $this->shipper[] = $spcCity; 143 | } 144 | 145 | return $this; 146 | } 147 | 148 | /** 149 | * $cntType: RP = responsible person (DE 3139) 150 | * $cntTitle: free text 151 | * $comData: free text 152 | * $comType: DE 3155 153 | * @param $cntType 154 | * @param $cntTitle 155 | *@param $comType 156 | *@param $comData 157 | * @return \EDI\Generator\Vermas\Container 158 | */ 159 | public function setSpcContact($cntType, $cntTitle, $comType = null, $comData = null) 160 | { 161 | $this->spcContact = []; 162 | $this->spcContact[] = ['CTA', $cntType, ['', $cntTitle]]; 163 | if ($comType !== null) { 164 | $this->spcContact[] = ['COM', [$comData, $comType]]; 165 | } 166 | 167 | return $this; 168 | } 169 | 170 | /** 171 | * @return array 172 | */ 173 | public function compose() 174 | { 175 | $composed = []; 176 | if ($this->cntr !== null) { 177 | $composed[] = $this->cntr; 178 | } 179 | if ($this->bkg !== null) { 180 | $composed[] = $this->bkg[0]; 181 | if (isset($this->bkg[1])) { 182 | $composed[] = $this->bkg[1]; 183 | } 184 | } 185 | if ($this->seal !== null) { 186 | $composed[] = $this->seal; 187 | } 188 | if ($this->measures !== null) { 189 | $composed[] = $this->measures; 190 | } 191 | if ($this->weighDate !== null) { 192 | $composed[] = $this->weighDate; 193 | } 194 | if ($this->weighMethod !== null) { 195 | $composed[] = $this->weighMethod; 196 | } 197 | if ($this->spcWpa !== null) { 198 | $composed[] = $this->spcWpa; 199 | } 200 | if ($this->shipper !== null) { 201 | $composed[] = $this->shipper; 202 | } 203 | if ($this->spcContact !== null) { 204 | $composed[] = $this->spcContact[0]; 205 | if (isset($this->spcContact[1])) { 206 | $composed[] = $this->spcContact[1]; 207 | } 208 | } 209 | 210 | return $composed; 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /src/Generator/Westim.php: -------------------------------------------------------------------------------- 1 | _estimateReference = $sMessageReferenceNumber; 55 | 56 | $this->_damages = []; 57 | } 58 | 59 | /** 60 | * $day = YYMMDD (used also in RFF+EST) 61 | * @param $day 62 | * @param $time 63 | * @return \EDI\Generator\Westim 64 | */ 65 | public function setTransactionDate($day, $time = null) 66 | { 67 | $this->_day = $day; 68 | $dt = $day; 69 | if ($time !== null) { 70 | $dt = [$day, $time]; 71 | } 72 | $this->_dtmATR = ['DTM', 'ATR', $dt]; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * $currency = XXX (three letter code) 79 | * @param $currency 80 | * @return \EDI\Generator\Westim 81 | */ 82 | public function setCurrency($currency) 83 | { 84 | $this->_currency = ['ACA', $currency, ['STD', 0]]; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * $labourRate = \d+.\d{2} 91 | * @param $labourRate 92 | * @return \EDI\Generator\Westim 93 | */ 94 | public function setLabourRate($labourRate) 95 | { 96 | $this->_labourRate = ['LBR', $labourRate]; 97 | 98 | return $this; 99 | } 100 | 101 | /** 102 | * Can be equal to the sender and receiver ID in UNH 103 | * @param $from 104 | * @param $to 105 | * @return \EDI\Generator\Westim 106 | */ 107 | public function setPartners($from, $to) 108 | { 109 | $this->_nadDED = ['NAD', 'DED', $from]; 110 | $this->_nadLED = ['NAD', 'LED', $to]; 111 | 112 | return $this; 113 | } 114 | 115 | /** 116 | * Container number separated between letters and numbers 117 | * @param $ownerCode 118 | * @param $serial 119 | * @param $isoSize 120 | * @param int $maximumGrossWeight 121 | * @return \EDI\Generator\Westim 122 | */ 123 | public function setContainer($ownerCode, $serial, $isoSize, $maximumGrossWeight = 0) 124 | { 125 | $this->_equipment = ['EQF', 'CON', [$ownerCode, $serial], $isoSize, ['MGW', $maximumGrossWeight, 'KGM']]; 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Full or Empty 132 | * @param $fullEmpty 133 | * @return \EDI\Generator\Westim 134 | */ 135 | public function setFullEmpty($fullEmpty) 136 | { 137 | $this->_fullEmpty = ['CUI', '', '', 'E']; 138 | 139 | return $this; 140 | } 141 | 142 | /** 143 | * Full or Empty 144 | * @param \EDI\Generator\Westim\Damage $damage 145 | * @return \EDI\Generator\Westim 146 | */ 147 | public function addDamage(Westim\Damage $damage) 148 | { 149 | $this->_damages[] = $damage; 150 | 151 | return $this; 152 | } 153 | 154 | /** 155 | * @param $responsibility 156 | * @param $labour 157 | * @param $material 158 | * @param $handling 159 | * @param $tax 160 | * @param $invoiceAmount 161 | * @return \EDI\Generator\Westim 162 | */ 163 | public function setCostTotals($responsibility, $labour, $material, $handling, $tax, $invoiceAmount) 164 | { 165 | $this->_costTotals = ['CTO', $responsibility, $labour, $material, $handling, $tax, $invoiceAmount]; 166 | 167 | return $this; 168 | } 169 | 170 | /** 171 | * @param $grandTotal 172 | * @param $authorizedAmount 173 | * @param $taxRate 174 | * @return \EDI\Generator\Westim 175 | */ 176 | public function setTotalMessageAmounts($grandTotal, $authorizedAmount = null, $taxRate = null) 177 | { 178 | $this->_totalMessageAmounts = ['TMA', $grandTotal]; 179 | if ($authorizedAmount !== null) { 180 | $this->_totalMessageAmounts[] = ['TMA', $grandTotal, '', '', '', '', $authorizedAmount]; 181 | } 182 | if ($taxRate !== null) { 183 | $this->_totalMessageAmounts[] = ['TMA', $grandTotal, '', '', '', '', $authorizedAmount, '', $taxRate]; 184 | } 185 | 186 | return $this; 187 | } 188 | 189 | /** 190 | * Compose. 191 | * 192 | * @param mixed $sMessageFunctionCode (1225) 193 | * @param mixed $sDocumentNameCode (1001) 194 | * @param mixed $sDocumentIdentifier (1004) 195 | * 196 | * @return \EDI\Generator\Message ::compose() 197 | * @throws \EDI\Generator\EdifactException 198 | */ 199 | public function compose(?string $sMessageFunctionCode = null, ?string $sDocumentNameCode = null, ?string $sDocumentIdentifier = null): parent 200 | { 201 | $this->messageContent = []; 202 | 203 | $this->messageContent[] = $this->_dtmATR; 204 | $this->messageContent[] = ['RFF', 'EST', $this->_estimateReference, $this->_day]; 205 | $this->messageContent[] = $this->_currency; 206 | $this->messageContent[] = $this->_labourRate; 207 | $this->messageContent[] = $this->_nadLED; 208 | $this->messageContent[] = $this->_nadDED; 209 | $this->messageContent[] = $this->_equipment; 210 | 211 | if ($this->_fullEmpty !== null) { 212 | $this->messageContent[] = $this->_fullEmpty; 213 | } 214 | 215 | $this->messageContent[] = ['ECI', 'D']; 216 | 217 | foreach ($this->_damages as $damage) { 218 | $content = $damage->compose(); 219 | 220 | foreach ($content as $segment) { 221 | $this->messageContent[] = $segment; 222 | } 223 | } 224 | 225 | $this->messageContent[] = $this->_costTotals; 226 | $this->messageContent[] = $this->_totalMessageAmounts; 227 | 228 | return parent::compose(); 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /src/Generator/Westim/Damage.php: -------------------------------------------------------------------------------- 1 | _damage = ['DAM', $line, $damageLocationCode, $componentCode, $damageTypeCode, $componentMaterialCode]; 31 | 32 | return $this; 33 | } 34 | 35 | /** 36 | * @param $repairMethodCode 37 | * @param $measureUnit 38 | * @param $length 39 | * @param $width 40 | * @param $height 41 | * @param $quantity 42 | * @return \EDI\Generator\Westim\Damage 43 | */ 44 | public function setWork($repairMethodCode, $measureUnit, $length, $width, $height, $quantity) 45 | { 46 | $this->_work = ['WOR', $repairMethodCode, [$measureUnit, $length, $width, $height], $quantity]; 47 | 48 | return $this; 49 | } 50 | 51 | /** 52 | * @param $manHours 53 | * @param $materialCost 54 | * @param $responsibility 55 | * @param $labourRate 56 | * @return \EDI\Generator\Westim\Damage 57 | */ 58 | public function setCost($manHours, $materialCost, $responsibility, $labourRate) 59 | { 60 | $this->_cost = ['COS', 00, $manHours, $materialCost, $responsibility, $labourRate, 'N']; 61 | 62 | return $this; 63 | } 64 | 65 | /** 66 | * @return array 67 | */ 68 | public function compose() 69 | { 70 | $composed = []; 71 | $composed[] = $this->_damage; 72 | $composed[] = $this->_work; 73 | $composed[] = $this->_cost; 74 | 75 | return $composed; 76 | } 77 | } 78 | --------------------------------------------------------------------------------