2013-04-03 42 views
2

我試圖訪問使用PHP API的QuickBooks發票的行項目,如何使用PHP API

,這樣我可以做一些關於它的操作訪問QuickBooks的發票行項目.....

我能夠當我這樣做是爲了獲得發票數據...

<?php 
$Invoice = $InvoiceService->findById($Context, $realmID, $InvoiceID); 
pr($Invoice); 
?> 

得到如下結果

QuickBooks_IPP_Object_Invoice Object 
(
    [_data:protected] => Array 
     (
      [Id] => Array 
       (
        [0] => {QBO-52} 
       ) 

      [SyncToken] => Array 
       (
        [0] => 13 
       ) 

      [MetaData] => Array 
       (
        [0] => QuickBooks_IPP_Object_MetaData Object 
         (
          [_data:protected] => Array 
           (
            [CreateTime] => Array 
             (
              [0] => 2013-04-02T02:55:30-07:00 
             ) 

            [LastUpdatedTime] => Array 
             (
              [0] => 2013-04-03T04:15:53-07:00 
             ) 

           ) 

         ) 

       ) 

      [Header] => Array 
       (
        [0] => QuickBooks_IPP_Object_Header Object 
         (
          [_data:protected] => Array 
           (
            [TxnDate] => Array 
             (
              [0] => 2013-03-31-07:00 
             ) 

            [Msg] => Array 
             (
              [0] => Customer Message update via QB++ 
             ) 

            [CustomerId] => Array 
             (
              [0] => {QBO-35} 
             ) 

            [SubTotalAmt] => Array 
             (
              [0] => 15.00 
             ) 

            [TotalAmt] => Array 
             (
              [0] => 15.00 
             ) 

            [ToBePrinted] => Array 
             (
              [0] => false 
             ) 

            [ToBeEmailed] => Array 
             (
              [0] => false 
             ) 

            [DueDate] => Array 
             (
              [0] => 2013-04-29-07:00 
             ) 

            [BillAddr] => Array 
             (
              [0] => QuickBooks_IPP_Object_BillAddr Object 
               (
                [_data:protected] => Array 
                 (
                  [Line1] => Array 
                   (
                    [0] => Jeffery 
                   ) 

                  [Line2] => Array 
                   (
                    [0] => Ads India 
                   ) 

                  [Line3] => Array 
                   (
                    [0] => Jeffery trading Co Ltd 
                   ) 

                  [Line4] => Array 
                   (
                    [0] => Cochin 
                   ) 

                  [Line5] => Array 
                   (
                    [0] => Kerala 
India 
                   ) 

                  [GeoCode] => Array 
                   (
                    [0] => INVALID 
                   ) 

                 ) 

               ) 

             ) 

            [ShipAddr] => Array 
             (
              [0] => QuickBooks_IPP_Object_ShipAddr Object 
               (
                [_data:protected] => Array 
                 (
                  [Line1] => Array 
                   (
                    [0] => Jeffery 
                   ) 

                  [Line2] => Array 
                   (
                    [0] => Jeffery trading Co Ltd\\nJeffery traders\\nCochin\\nIndia 
                   ) 

                  [Line3] => Array 
                   (
                    [0] => Jeffery 
                   ) 

                  [Line4] => Array 
                   (
                    [0] => 0484232425 
                   ) 

                  [PostalCode] => Array 
                   (
                    [0] => 0 
                   ) 

                  [GeoCode] => Array 
                   (
                    [0] => INVALID 
                   ) 

                  [Tag] => Array 
                   (
                    [0] => CUSTOMER 
                   ) 

                 ) 

               ) 

             ) 

            [ShipMethodId] => Array 
             (
              [0] => {QBO-} 
             ) 

            [Balance] => Array 
             (
              [0] => 15.00 
             ) 

            [DiscountTaxable] => Array 
             (
              [0] => true 
             ) 

           ) 

         ) 

       ) 

      [Line] => Array 
       (
        [0] => QuickBooks_IPP_Object_Line Object 
         (
          [_data:protected] => Array 
           (
            [Desc] => Array 
             (
              [0] => TES15++ 
             ) 

            [Amount] => Array 
             (
              [0] => 15.00 
             ) 

            [Taxable] => Array 
             (
              [0] => false 
             ) 

            [ItemId] => Array 
             (
              [0] => {QBO-30} 
             ) 

           ) 

         ) 

        [1] => QuickBooks_IPP_Object_Line Object 
         (
          [_data:protected] => Array 
           (
            [Amount] => Array 
             (
              [0] => 0.00 
             ) 

            [Taxable] => Array 
             (
              [0] => false 
             ) 

            [ItemId] => Array 
             (
              [0] => {QBO-21} 
             ) 

           ) 

         ) 

       ) 

     ) 

) 

我可以得到發票編號,客戶ID respectivly如下

<?php 

pr($Invoice->getId()); 

pr($Invoice->getHeader()->getCustomerId()); 

?> 

我的問題是如何獲得的行項目的數量和其解壓縮到一個正常的陣列

我累pr($Invoice->getLine());它不給我整個數組,但只是數組中的第一個項目...

上午發現很難做到這一點....

+0

停止把我的名字在你的問題 - 我的名字有*不*做的問題,因此不應該成爲問題的一部分。如果你一直這樣做,你會被禁止的。 –

+0

對不起,這只是告訴你正在使用你的php api ... –

+0

不用擔心 - 只需把「QuickBooks PHP DevKit」或其他東西。 –

回答

5
$Invoice->getLine(0); 
$Invoice->getLine(1); 
$Invoice->getLine(2); 
$Invoice->getLine(3); 
etc. 

OR

$count = $Invoice->countLine(); 
for ($i = 0; $i < $count; $i++) 
{ 
    $Line = $Invoice->getLine($i); 
}