mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-24 15:18:40 +00:00
More EDI preparations
This commit is contained in:
parent
bd087c5083
commit
4b934cde35
45
Utils/EDI/AnsiX12/EDIAbstract.php
Normal file
45
Utils/EDI/AnsiX12/EDIAbstract.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
|
||||
|
||||
/**
|
||||
* EDI
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\Utils\Converter
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class EDIAbstract
|
||||
{
|
||||
private $header = null;
|
||||
|
||||
private $heading = null;
|
||||
|
||||
private $detail = null;
|
||||
|
||||
private $summary = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->header = new Header();
|
||||
}
|
||||
}
|
||||
|
|
@ -32,5 +32,149 @@ class FunctionalGroupHedaer
|
|||
{
|
||||
private $functionalGroupHeader = 'GS';
|
||||
|
||||
private $functionIdentiferCode = FunctionalIdentifierCode::PO;
|
||||
private $functionalIdentifierCode = FunctionalIdentifierCode::PO;
|
||||
|
||||
private $applicationSenderCode = '';
|
||||
|
||||
private $appicationReceiverCode = '';
|
||||
|
||||
private $date = null;
|
||||
|
||||
private $groupControlNumber = 0;
|
||||
|
||||
private $responsibleAgencyCode = '';
|
||||
|
||||
private $version = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date = new \DateTime();
|
||||
}
|
||||
|
||||
public function getFunctionalGroupHeader() : string
|
||||
{
|
||||
return $this->functionalGroupHeader;
|
||||
}
|
||||
|
||||
public function getFunctionalIdentifierCode() : string
|
||||
{
|
||||
return $this->functionalIdentifierCode;
|
||||
}
|
||||
|
||||
public function setFunctionalIdentifierCode(string $code) /* : void */
|
||||
{
|
||||
if(!FunctionalIdentifierCode::isValidValue($code)) {
|
||||
throw \Exception();
|
||||
}
|
||||
|
||||
$this->functionalIdentifierCode = $code;
|
||||
}
|
||||
|
||||
public function getApplicationSenderCode() : string
|
||||
{
|
||||
return str_pad((string) $this->applicationSenderCode, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function setApplicationSenderCode(string $code) /* : void */
|
||||
{
|
||||
if(strlen($code) < 2 || strlen($code) > 15) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$this->applicationSenderCode = $code;
|
||||
}
|
||||
|
||||
public function getApplicationReceiverCode() : string
|
||||
{
|
||||
return str_pad((string) $this->applicationReceiverCode, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function setApplicationReceiverCode(string $code) /* : void */
|
||||
{
|
||||
if(strlen($code) < 2 || strlen($code) > 15) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$this->applicationReceiverCode = $code;
|
||||
}
|
||||
|
||||
public function setDate(\DateTime $date) /* : void */
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function getDate() : string
|
||||
{
|
||||
return $this->date->format('d:m:y');
|
||||
}
|
||||
|
||||
public function getTime() : string
|
||||
{
|
||||
return $this->date->format('d:m:y');
|
||||
}
|
||||
|
||||
public function getGroupControlNumber() : int
|
||||
{
|
||||
return $this->groupControlNumber;
|
||||
}
|
||||
|
||||
public function setGroupControlNumber(int $number) /* : void */
|
||||
{
|
||||
if($number < 0) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$this->groupControlNumber = $number;
|
||||
}
|
||||
|
||||
public function getResponsibleAgencyCode() : int
|
||||
{
|
||||
return $this->responsibleAgencyCode;
|
||||
}
|
||||
|
||||
public function setResponsibleAgencyCode(int $code) /* : void */
|
||||
{
|
||||
if($code < 0 || $code > 99) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$this->responsibleAgencyCode = $code;
|
||||
}
|
||||
|
||||
public function getVersion() : string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function setVersion(string $version) /* : void */
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return $this->functionalGroupHeader . '*'
|
||||
. $this->getfunctionalIdentifierCode() . '*'
|
||||
. $this->getApplicationSenderCode() . '*'
|
||||
. $this->getApplicationReceiverCode() . '*'
|
||||
. $this->getDate() . '*'
|
||||
. $this->getTime() . '*'
|
||||
. $this->getGroupControlNumber() . '*'
|
||||
. $this->getResponsibleAgencyCode() . '*'
|
||||
. $this->getVersion() . '*' . self::COMPONENT_ELEMENT_SEPARATOR;
|
||||
}
|
||||
|
||||
public function unserialize($raw)
|
||||
{
|
||||
$split = explode($raw);
|
||||
|
||||
$this->setFunctionalGroupHeader(trim($split[0]));
|
||||
$this->setFunctionalIdentifierCode(trim($split[1]));
|
||||
$this->setApplicationSenderCode(trim($split[2]));
|
||||
$this->setApplicationReceiverCode(trim($split[3]));
|
||||
$this->setDate(new \DateTime(trim($split[4]) . '-' . trim($split[5])));
|
||||
$this->setGroupControlNumber(trim($split[6]));
|
||||
$this->setResponsibleAgencyCode((int) trim($split[7]));
|
||||
$this->setVersion(trim($split[8]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
Utils/EDI/AnsiX12/FunctionalIdentifierCode.php
Normal file
0
Utils/EDI/AnsiX12/FunctionalIdentifierCode.php
Normal file
|
|
@ -32,5 +32,11 @@ class Header
|
|||
{
|
||||
private $interchangeControlHeader = null;
|
||||
|
||||
private $functionGroupHeader = null;
|
||||
private $functionalGroupHeader = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->interchangeControlHeader = new InterchangeControlHeader();
|
||||
$this->functionalGroupHeader = new FunctionalGroupHeader();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
|
||||
|
||||
use phpOMS\Utils\EDI\AnsiX12\EDIAbstract;
|
||||
|
||||
/**
|
||||
* EDI 850 - Purchase order.
|
||||
*
|
||||
|
|
@ -28,13 +30,13 @@ namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EDI850
|
||||
class EDI850 extends EDIAbstract
|
||||
{
|
||||
private $header = null;
|
||||
|
||||
private $heading = null;
|
||||
|
||||
private $detail = [];
|
||||
|
||||
private $summary = null;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->heading = new EDIT850Heading();
|
||||
$this->detail = new EDIT850Detail();
|
||||
$this->summary = new EDI850Summary();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ namespace phpOMS\Utils\EDI\AnsiX12\Purchase;
|
|||
*/
|
||||
class EDI850Heading
|
||||
{
|
||||
private $headingTransactionSetHeader = '';
|
||||
private $headingTransactionSetHeader = null;
|
||||
|
||||
private $headingBeginningSegmentPO = '';
|
||||
private $headingBeginningSegmentPO = null;
|
||||
|
||||
private $headingCurrency = '';
|
||||
|
||||
|
|
@ -47,4 +47,9 @@ class EDI850Heading
|
|||
private $headingMarksNumbers = 0;
|
||||
|
||||
private $headingLoopId = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->headingTransactionSetHeader = new TransactionSetHeader();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
|
||||
|
||||
/**
|
||||
* EDI 850 - Purchase order.
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\Utils\Converter
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TransactionSetHeader
|
||||
{
|
||||
const IDENTIFIER = 'ST';
|
||||
|
||||
private $transactionSetIdentifierCode = 850;
|
||||
|
||||
private $transactionSetControlNumber = '';
|
||||
|
||||
public function getTransactionSetIdentiferCode() : int
|
||||
{
|
||||
return $this->transactionSetIdentifierCode;
|
||||
}
|
||||
|
||||
public function setTransactionIdentifierCode(int $code) /* : void */
|
||||
{
|
||||
$this->transactionSetIdentifierCode = $code;
|
||||
}
|
||||
|
||||
public function getTransactionSetControlNumber() : string
|
||||
{
|
||||
return str_pad((string) $this->transactionSetControlNumber, 9, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function setTransactionSetControlNumber(string $number) /* : void */
|
||||
{
|
||||
if(strlen($number) < 4 || strlen($number) > 9) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$this->transactionSetControlNumber = $number;
|
||||
}
|
||||
|
||||
public function unserialize($raw)
|
||||
{
|
||||
$split = explode($raw);
|
||||
|
||||
$this->setTransactionSetIdentifierCode((int) trim($split[1]));
|
||||
$this->setTransactionSetControlNumber(trim($split[2]));
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return self::IDENTIFIER . '*'
|
||||
. $this->getTransactionSetIdentifierCode() . '*'
|
||||
. $this->getTransactionSetControlNumber();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user