PHP code example of horstoeko / orderx

1. Go to this page and download the library: Download horstoeko/orderx library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

horstoeko / orderx example snippets


use horstoeko\orderx\OrderDocumentReader;

$document = OrderDocumentReader::readAndGuessFromFile(dirname(__FILE__) . "/order-x.xml");

$document->getDocumentInformation(
    $documentNo,
    $documentTypeCode,
    $documentDate,
    $documentCurrency,
    $documentName,
    $documentLanguageId,
    $documentEffectiveSpecifiedPeriod,
    $documentPurposeCode,
    $documentRequestedResponseTypeCode)

echo "The Order No. is {$documentno}" . PHP_EOL;

use horstoeko\orderx\OrderDocumentPdfReader;

$document = OrderDocumentPdfReader::readAndGuessFromFile(dirname(__FILE__) . "/order-x.pdf");

$document->getDocumentInformation(
    $documentNo,
    $documentTypeCode,
    $documentDate,
    $documentCurrency,
    $documentName,
    $documentLanguageId,
    $documentEffectiveSpecifiedPeriod,
    $documentPurposeCode,
    $documentRequestedResponseTypeCode)

echo "The Order No. is {$documentno}" . PHP_EOL;

use horstoeko\orderx\OrderProfiles;
use horstoeko\orderx\OrderDocumentBuilder;

$document = OrderDocumentBuilder::createNew(
    OrderProfiles::PROFILE_EXTENDED
);

$document
    ->setIsDocumentCopy(false)
    ->setIsTestDocument(false)
    ->setDocumentBusinessProcessSpecifiedDocumentContextParameter("A1")

    ->setDocumentInformation("PO123456789", "220", new \DateTime(), "EUR", "Doc Name", null, new \DateTime(), "9", "AC")
    ->addDocumentNote("Content of Note", "AAI", "AAI")
    ->setDocumentBuyerReference("BUYER_REF_BU123")

    ->setDocumentSeller("SELLER_NAME", "SUPPLIER_ID_321654", "SELLER_ADD_LEGAL_INFORMATION")
    ->addDocumentSellerGlobalId("123654879", "0088")
    ->addDocumentSellerTaxRegistration("VA", "FR 32 123 456 789")
    ->addDocumentSellerTaxRegistration("FC", "SELLER_TAX_ID")
    ->setDocumentSellerAddress("SELLER_ADDR_1", "SELLER_ADDR_2", "SELLER_ADDR_3", "75001", "SELLER_CITY", "FR")
    ->setDocumentSellerLegalOrganisation("123456789", "0002", "SELLER_TRADING_NAME")
    ->setDocumentSellerContact("SELLER_CONTACT_NAME", "SELLER_CONTACT_DEP", "+33 6 25 64 98 75", null, "[email protected]", "SR")
    ->setDocumentSellerElectronicAddress("EM", "[email protected]")

    ->setDocumentBuyer("BUYER_NAME", "BY_ID_9587456")
    ->addDocumentBuyerGlobalId("98765432179", "0088")
    ->addDocumentBuyerTaxRegistration("VA", "FR 05 987 654 321")
    ->setDocumentBuyerAddress("BUYER_ADDR_1", "BUYER_ADDR_2", "BUYER_ADDR_3", "69001", "BUYER_CITY", "FR")
    ->setDocumentBuyerLegalOrganisation("987654321", "0002", "BUYER_TRADING_NAME")
    ->setDocumentBuyerContact("BUYER_CONTACT_NAME", "BUYER_CONTACT_DEP", "+33 6 65 98 75 32", null, "[email protected]", "LB")
    ->setDocumentBuyerElectronicAddress("EM", "[email protected]")

    ->setDocumentBuyerRequisitioner("BUYER_REQ_NAME", "BUYER_REQ_ID_25987")
    ->addDocumentBuyerRequisitionerGlobalId("654987321", "0088")
    ->addDocumentBuyerRequisitionerTaxRegistration("VA", "FR 92 654 987 321")
    ->setDocumentBuyerRequisitionerAddress("BUYER_REQ_ADDR_1", "BUYER_REQ_ADDR_2", "BUYER_REQ_ADDR_3", "69001", "BUYER_REQ_CITY", "FR")
    ->setDocumentBuyerRequisitionerLegalOrganisation("654987321", "0022", "BUYER_REQ_TRADING_NAME")
    ->setDocumentBuyerRequisitionerContact("BUYER_REQ_CONTACT_NAME", "BUYER_REQ_CONTACT_DEP", "+33 6 54 98 65 32", null, "[email protected]", "PD")
    ->setDocumentBuyerRequisitionerElectronicAddress("EM", "[email protected]")

    ->setDocumentDeliveryTerms("FCA", "Free Carrier", "7", "DEL_TERMS_LOC_ID", "DEL_TERMS_LOC_Name")

    ->setDocumentSellerOrderReferencedDocument("SALES_REF_ID_459875")
    ->setDocumentBuyerOrderReferencedDocument("PO123456789")
    ->setDocumentQuotationReferencedDocument("QUOT_125487")
    ->setDocumentContractReferencedDocument("CONTRACT_2020-25987")
    ->setDocumentRequisitionReferencedDocument("REQ_875498")
    ->addDocumentAdditionalReferencedDocument("916", "ADD_REF_DOC_ID", "ADD_REF_DOC_URIID", "ADD_REF_DOC_Desc")
    ->addDocumentAdditionalReferencedDocument("50", "TENDER_ID")
    ->addDocumentAdditionalReferencedDocument("130", "OBJECT_ID", null, null, "AWV")
    ->setDocumentBlanketOrderReferencedDocument("BLANKET_ORDER_OD", new \DateTime())
    ->setDocumentPreviousOrderChangeReferencedDocument("PREV_ORDER_C_ID", new \DateTime())
    ->setDocumentPreviousOrderResponseReferencedDocument("PREV_ORDER_R_ID", new \DateTime())
    ->setDocumentProcuringProject("PROJECT_ID", "Project Reference")

    ->setDocumentShipTo("SHIP_TO_NAME", "SHIP_TO_ID")
    ->addDocumentShipToGlobalId("5897546912", "0088")
    ->addDocumentShipToTaxRegistration("VA", "FR 66 951 632 874")
    ->setDocumentShipToAddress("SHIP_TO_ADDR_1", "SHIP_TO_ADDR_2", "SHIP_TO_ADDR_3", "69003", "SHIP_TO_CITY", "FR")
    ->setDocumentShipToLegalOrganisation("951632874", "0002", "SHIP_TO_TRADING_NAME")
    ->setDocumentShipToContact("SHIP_TO_CONTACT_NAME", "SHIP_TO_CONTACT_DEP", "+33 6 85 96 32 41", null, "[email protected]", "SD")
    ->setDocumentShipToElectronicAddress("EM", "[email protected]")

    ->setDocumentShipFrom("SHIP_FROM_NAME", "SHIP_FROM_ID")
    ->addDocumentShipFromGlobalId("875496123", "0088")
    ->addDocumentShipFromTaxRegistration("VA", "FR 16 548 963 127")
    ->setDocumentShipFromAddress("SHIP_FROM_ADDR_1", "SHIP_FROM_ADDR_2", "SHIP_FROM_ADDR_3", "75003", "SHIP_FROM_CITY", "FR")
    ->setDocumentShipFromLegalOrganisation("548963127", "0002", "SHIP_FROM_TRADING_NAME")
    ->setDocumentShipFromContact("SHIP_FROM_CONTACT_NAME", "SHIP_FROM_CONTACT_DEP", "+33 6 85 96 32 41", null, "[email protected]", "SD")
    ->setDocumentShipFromElectronicAddress("EM", "[email protected]")

    ->setDocumentRequestedDeliverySupplyChainEvent(new \DateTime(), new \DateTime(), new \DateTime())

    ->setDocumentInvoicee("INVOICEE_NAME", "INVOICEE_ID_9587456")
    ->addDocumentInvoiceeGlobalId("98765432179", "0088")
    ->addDocumentInvoiceeTaxRegistration("VA", "FR 05 987 654 321")
    ->addDocumentInvoiceeTaxRegistration("FC", "INVOICEE_TAX_ID")
    ->setDocumentInvoiceeAddress("INVOICEE_ADDR_1", "INVOICEE_ADDR_2", "INVOICEE_ADDR_3", "69001", "INVOICEE_CITY", "FR")
    ->setDocumentInvoiceeLegalOrganisation("987654321", "0002", "INVOICEE_TRADING_NAME")
    ->setDocumentInvoiceeContact("INVOICEE_CONTACT_NAME", "INVOICEE_CONTACT_DEP", "+33 6 65 98 75 32", null, "[email protected]", "LB")
    ->setDocumentInvoiceeElectronicAddress("EM", "[email protected]")

    ->setDocumentPaymentMean("30", "Credit Transfer")
    ->addDocumentPaymentTerm("PAYMENT_TERMS_DESC")
    ->addDocumentAllowanceCharge(31.00, false, "S", "VAT", 20, null, 10.00, 310.00, null, null, "64", "SPECIAL AGREEMENT")
    ->addDocumentAllowanceCharge(21.00, true, "S", "VAT", 20, null, 10.00, 210.00, null, null, "FC", "FREIGHT SERVICES")
    ->setDocumentSummation(310, 360, 21, 31, 300, 60)
    ->setDocumentReceivableSpecifiedTradeAccountingAccount("BUYER_ACCOUNT_REF")

    ->addNewPosition("1")
    ->setDocumentPositionNote("WEEE Tax of 0,50 euros per item 

use horstoeko\orderx\OrderProfiles;
use horstoeko\orderx\OrderDocumentBuilder;
use horstoeko\orderx\OrderDocumentPdfBuilder;

$document = OrderDocumentBuilder::createNew(
    OrderProfiles::PROFILE_EXTENDED
);

$document
    ->setIsDocumentCopy(false)
    ->setIsTestDocument(false)
    ->setDocumentBusinessProcessSpecifiedDocumentContextParameter("A1")

    ->setDocumentInformation("PO123456789", "220", new \DateTime(), "EUR", "Doc Name", null, new \DateTime(), "9", "AC");

    // Do some other stuff (see above)

$pdfDocument = new OrderDocumentPdfBuilder(
    $document,
    dirname(__FILE__) . "/../src/assets/empty.pdf"
);

$pdfDocument
    ->generateDocument()
    ->saveDocument(getcwd() . "/order-x.pdf");