function action_CreatePdf()
 {
     if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
         $pdfCreator = new ProductCatalogPdfCreator();
         $productCatalog = new oqc_ProductCatalog();
         if ($productCatalog->retrieve($_REQUEST['record'])) {
             $pdfCreator->createPdf($productCatalog);
         } else {
             $this->post_save();
         }
     }
 }
 public static function activeCatalog()
 {
     $bean = new oqc_ProductCatalog();
     $catalog = $bean->get_full_list("", 'active=1');
     if (count($catalog) < 1) {
         trigger_error("no active catalog found!", E_USER_WARNING);
         return null;
     } else {
         if (count($catalog) > 1) {
             trigger_error("more than one active catalog found!", E_USER_WARNING);
         }
         return $catalog[0];
     }
 }
function getProductUsage($id)
{
    $productCatalog = new oqc_ProductCatalog();
    if ($productCatalog->retrieve($id)) {
        $frequency = array();
        $json = getJSONobj();
        $c = new oqc_Contract();
        $result = $c->get_list('', 'deleted=0');
        $allContracts = $result['list'];
        foreach ($allContracts as $contract) {
            // services of this contract
            $services = $contract->get_linked_beans('oqc_service', 'oqc_Service');
            foreach ($services as $service) {
                $product = new oqc_Product();
                // if the service refers to an existing product that is defined in this product catalog ...
                if ($product->retrieve($service->product_id) && $product->catalog_id == $id) {
                    // increase the frequency of the appearance of this product
                    $frequency[$product->name]['rate'] += $service->quantity;
                    if (!array_key_exists('category', $frequency[$product->name])) {
                        $category = new oqc_Category();
                        if ($category->retrieve($product->relatedcategory_id)) {
                            $frequency[$product->name]['category'] = $category->name;
                        }
                    }
                }
            }
        }
        $chartData = array();
        foreach ($frequency as $name => $frequencyArray) {
            $chartData[] = array('name' => $name, 'frequency' => $frequencyArray['rate'], 'category' => $frequencyArray['category']);
        }
        $encoded = $json->encode($chartData);
        echo $encoded;
    } else {
        echo "No Product Catalog with id='" + $id + "' found.";
    }
}
<?php

if (!defined('sugarEntry')) {
    define('sugarEntry', true);
}
chdir('..');
require_once 'include/entryPoint.php';
require_once 'modules/oqc_ProductCatalog/oqc_ProductCatalog.php';
echo oqc_ProductCatalog::activeCatalogId();
function getProductCategoriesHTML($focus, $name, $value, $view)
{
    global $app_list_strings;
    global $mod_strings;
    global $current_user;
    if ('EditView' != $view && 'DetailView' != $view) {
        return "";
        // skip the rest of the method if another view calls this method
    }
    if (empty($focus->id)) {
        $focus->id = "";
        // set id to empty string to enable search (getAllCategories)
    }
    $json = getJSONobj();
    $languageStringsJson = $json->encode($mod_strings);
    $smarty = new Sugar_Smarty();
    //tinyMCE languege file detection
    $langDefault = 'en';
    $lang = substr($GLOBALS['current_language'], 0, 2);
    if (file_exists('include/oqc/tinymce/langs/' . $lang . '.js')) {
        $langDefault = $lang;
    }
    //directionality detection
    $directionality = SugarThemeRegistry::current()->directionality;
    $productCatalog = new oqc_ProductCatalog();
    $productCatalog->retrieve($focus->id);
    $categoryArray = empty($focus->id) ? array() : $productCatalog->getAllCategories();
    $categoryJSONData = getCategoryJSONData($categoryArray, $view, $focus);
    //$GLOBALS['log']->error("product catalog: ". var_export($categoryJSONData,true));
    $smarty->assign("MOD", $mod_strings);
    $smarty->assign("categoryJSONData", $json->encode($categoryJSONData));
    $smarty->assign('lang', $langDefault);
    $smarty->assign("languageStrings", $languageStringsJson);
    $smarty->assign('directionality', $directionality);
    return $smarty->fetch('include/oqc/ProductCatalog/' . $view . '.html');
}
 function fill_in_additional_list_fields()
 {
     parent::fill_in_additional_list_fields();
     // fillin the category number field if possible
     if (!empty($this->relatedcategory_id)) {
         $category = new oqc_Category();
         if ($category->retrieve($this->relatedcategory_id)) {
             $this->category_number = $category->number;
         }
     }
     $catalog = new oqc_ProductCatalog();
     if ($catalog->retrieve($this->catalog_id)) {
         $this->catalog_name = $catalog->name;
     }
     if (isset($this->currency_id) && $this->currency_id != '') {
         $currency = new Currency();
         $currency->retrieve($this->currency_id);
         if ($currency->id != $this->currency_id || $currency->deleted == 1) {
             //			$this->amount = $this->amount_usdollar;
             $this->currency_id = $currency->id;
         }
     } else {
         $this->currency_id = '-99';
     }
     if ($this->force_load_details == true) {
         $this->fill_in_additional_detail_fields();
     }
 }