Get all Estimates fitting Custom Criteria

Usage

Prototype

getEstimates($filters = array(), $or = false, $fields = array(), $start = 0, $max = -1, $order = array())

Examples

//--------------------------------------------------------------------------------------------------
//Get 15 estimates, sorted by TotalAmount, starting at result 500
$Estimates = $QB->getEstimates(array(), QUICKBOOKS_SQL_API_AND, array(), 500, 15, array( array("TotalAmount", "ASC") ));
	
	foreach($Estimates as $Estimate)
		echo "&nbsp;&nbsp;&nbsp;&nbsp;".$Estimate->TotalAmount."<br />";
//--------------------------------------------------------------------------------------------------
//Get all estimates who's PONumber starts with "20"
$filters = array( "PONumber" => array("LIKE", "20%") );

$Estimates = $QB->getEstimates($filters);
	
	foreach($Estimates as $Estimate)
		echo "&nbsp;&nbsp;&nbsp;&nbsp;".$Estimate->Name."<br />";
//--------------------------------------------------------------------------------------------------
//Get all estimates who are active, and have a subtotal greater than zero.
$filters = array( "IsActive" => "1", "SubTotal" => array( ">", "0" ) );

$Estimates = $QB->getEstimates($filters);
	
	foreach($Estimates as $Estimate)
		echo "Name: ".$Estimate->Name."<br />
		      Fax:  ".$Estimate->Balance."<br />";

Parameters

  • $filters = array() – An array of filters to limit which estimate records are retrieved. If array is empty, all estimates will be returned.
	Entries in the array can have several forms:
	
		$field_name => $value -- Equivalent to: "WHERE $field_name = $value "
		
		$field_name => "IS NULL" -- Equivalent to: "WHERE $field_name IS NULL "
		
		$field_name => "IS NOT NULL" -- Equivalent to: "WHERE $field_name IS NOT NULL "
		
		$field_name => array( $operator, $value ) -- Equivalent to: "WHERE $field_name $operator $value "
	
	Example:  array( "TxnID" => "12345-6789", "TotalAmount" => array( ">", "0")  )
  • $or = false – If false, query will match ALL criteria, if true, query will match ANY critera
  • $fields = array() – List of fields to return. If array is empty, all fields will be returned.
  • $start = 0 – How many records to skip, skips zero by default.
  • $max = -1 – Number of records to return, if number is less than zero all results will be retrieved (default).
  • $order = array() – An array of criteria to order the result by.
	Each entry in the array must be another array with this structure:
	
		array( "Field_Name", "ASC") -- Equivalent to: "ORDER BY  $field_name ASC "
		
		array( "Field_Name", "DESC") -- Equivalent to: "ORDER BY  $field_name DESC "
	
	Example:  array( array( "TotalAmount", "ASC" ), array( "SubTotal", "DESC" )  )
			
			Equivalent to: "ORDER BY  LastName ASC, FirstName DESC "

Returns

  • FALSE if no estimates were found.
  • Otherwise returns an array of Database Objects.

Source

public function getEstimates($filters = array(), $or = false, $fields = array(), $start = 0, $max = -1, $order = array())
{
	//get($tables, $filters = array(), $or = false, $union = false, $fields = array(), $start = 0, $max = -1, $order = array())
	$this->DB->get("qb_estimate", $filters, $or, false, $fields, $start, $max, $order);
	return $this->DB->allToObjects();
}
	
getestimates.txt · Last modified: 2013/01/21 12:44 (external edit)