PHP code example of rolecode / php-minimax

1. Go to this page and download the library: Download rolecode/php-minimax 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/ */

    

rolecode / php-minimax example snippets


composer 

    $invoicesAll = $minimax->issuedInvoices->all();
    $invoiceRetrievedById = $minimax->issuedInvoices->retrieveById( "INSERT_ID" );

    // Create invoice.
    // First prepare invoice rows.
    $invoiceRows = [];
    $row = new IssuedInvoiceRow();
    $row->RowNumber = 1;
    $row->Item = new mMApiFkField( "INSERT_ITEM_ID" );
    $row->Quantity = 1;
    $row->Price = 1;
    $row->PriceWithVAT = 1.22;
    $row->Value = $row->PriceWithVAT;
    $row->VatRate = new mMApiFkField( $vatRateStandard->VatRateId );
    $row->VATPercent = $vatRateStandard->Percent;
    $invoiceRows[] = $row;


    // Prepare invoice payments.
    $invoicePayments = [];
    $row = new IssuedInvoicePaymentMethod();
    $row->PaymentMethod = new mMApiFkField( $paymentMethod->PaymentMethodId );
    $row->AlreadyPaid = "D";
    $invoicePayments[] = $row;

    // Prepare invoice object.
    $invoice = new IssuedInvoice();
    $invoice->InvoiceType = "R";
    $invoice->Customer = new mMApiFkField( $customer->CustomerId );
    $invoice->DateIssued = date( Date::DATE_FORMAT );
    $invoice->DateTransactionFrom = $invoice->DateIssued;
    $invoice->DateTransaction = $invoice->DateIssued;
    $invoice->DateDue = date( Date::DATE_FORMAT )( Date::DATE_FORMAT );
    $invoice->IssuedInvoiceRows = $invoiceRows;
    $invoice->IssuedInvoicePaymentMethods = $invoicePayments;

    // Create invoice.
    $invoice = $minimax->issuedInvoices->create( $invoice );

    // Issue and generate pdf for invoice.
    $invoice = $minimax->issuedInvoices->performAction( $invoice->IssuedInvoiceId, $invoice->RowVersion, "issueAndGeneratepdf" );

    // Retrieve invoice document pdf.
    $documentId = $invoice->Document->ID;
    $documentAttachmentId = $invoice->InvoiceAttachment->ID;
    $documentAttachment = $minimax->documentAttachments->retrieve( $documentId, $documentAttachmentId );

   // Save file to disk.
    file_put_contents($documentAttachment->FileName, $documentAttachment->getDecodedAttachmentData());