Пример #1
0
 /**
  * 
  * 
  * @param array $estimates
  * @return boolean
  */
 protected static function _integrateNewEstimates($estimates)
 {
     // Let's start with new estimates
     foreach ($estimates as $EstimateID) {
         $API->log('Analyzing estimate #' . $EstimateID, QUICKBOOKS_LOG_VERBOSE);
         $Estimate = $Integrator->getEstimate($EstimateID);
         QuickBooks_Callbacks_Integrator_Callbacks::_integrateEstimate($Estimate, $EstimateID);
         // Customer
         $CustomerID = $Estimate->getCustomerApplicationID();
         if ($ListID = $Estimate->getCustomerListID()) {
             // xxx Do nothing, already in QuickBooks
             // Add it again, just in case!
             //
             QuickBooks_Callbacks_Integrator_Callbacks::integrateAddCustomer($CustomerID);
         } else {
             if (true) {
                 // Try to fetch the customer by name
                 $API->getCustomerByName($Integrator->getCustomerNameForQuery($CustomerID), 'QuickBooks_Callbacks_Integrator_Callbacks::getCustomerByName', $CustomerID);
             }
         }
         /*else
         		{
         			// Add the customer to QuickBooks
         			
         			QuickBooks_Callbacks_Integrator_Callbacks::integrateAddCustomer($CustomerID);
         			//$extras = $Integrator->getCustomerExtras($CustomerID, __FILE__, __LINE__);
         			//$Customer = $Integrator->getCustomer($CustomerID, __FILE__, __LINE__);
         			//$this->_integrateCustomer($Customer, $CustomerID, $extras);
         		}*/
         $list = $Integrator->getEstimateItemsForEstimate($EstimateID);
         foreach ($list as $EstimateItem) {
             $ProductID = $EstimateItem->getItemApplicationID();
             if (!$EstimateID) {
                 continue;
             }
             //
             if ($ListID = $EstimateItem->getItemListID()) {
                 // Add it again anyway, just in case
                 $Product = $Integrator->getProduct($ProductID, __FILE__, __LINE__);
                 QuickBooks_Callbacks_Integrator_Callbacks::_integrateProduct($Product, $ProductID);
             } else {
                 if (true) {
                     //print('getbyname');
                     // Queue a request *for each type* of item
                     $API->getItemByName($Integrator->getProductNameForQuery($ProductID), 'QuickBooks_Callbacks_Integrator_Callbacks::getProductByName', $ProductID);
                 }
             }
             /*
             else
             {
             	//print('else');
             	$Product = $Integrator->getProduct($ProductID, __FILE__, __LINE__);
             	$this->_integrateProduct($Product, $ProductID);
             }
             */
         }
     }
 }