private static function get_items($selected_item) { self::init_api(); $items = new FreshBooks_Item(); $result = array(); $result_info = array(); $str = "<option value=''></option>"; $current_page = 1; do { $items->listing($result, $result_info, $current_page, 100); $pages = $result_info["pages"]; foreach ($result as $line_item) { $selected = $line_item->itemId == $selected_item ? "selected='selected'" : ""; $str .= "<option value='{$line_item->itemId}' {$selected}>{$line_item->name}</option>"; } $current_page++; } while ($current_page <= $pages); return $str; }
/** * process XML string response from LIST server method */ protected function _internalListing($responseStatus, &$XMLObject, &$rows, &$resultInfo) { $rows = array(); $resultInfo = array(); $items = $XMLObject->items; $resultInfo['page'] = (string) $items['page']; $resultInfo['perPage'] = (string) $items['per_page']; $resultInfo['pages'] = (string) $items['pages']; $resultInfo['total'] = (string) $items['total']; foreach ($items->children() as $key => $currXML) { $thisItem = new FreshBooks_Item(); $thisItem->_internalLoadXML($currXML); $rows[] = $thisItem; } }
public function get_item_name($item_id) { $this->init_api(); $item = new FreshBooks_Item(); $item->get($item_id); $item_name = $item->name; return $item_name; }