public function getAllCategories() { $categories = array(); $ids = explode(" ", trim($this->category_ids)); foreach ($ids as $id) { $c = new oqc_Category(); if ($c->retrieve($id)) { $categories[] = array('category' => $c, 'subcategories' => $c->getSubCategories()); } } return $categories; }
private function removeCategories() { $deletedCategoryIds = explode(' ', trim($_POST['deletedCategories'])); $deletedCategoryIds = array_diff($deletedCategoryIds, array(" ", "")); // remove empty elements from the array $category = new oqc_Category(); foreach ($deletedCategoryIds as $id) { if ($category->retrieve($id)) { $category->mark_deleted($id); } } }
function getCategoryNameHtml($focus, $name, $value, $view) { if ('DetailView' != $view) { return ""; // skip the rest of the method if another view calls this method } $category = new oqc_Category(); if ($category->retrieve($focus->relatedcategory_id)) { return $category->name; } else { return ""; } }
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."; } }
function action_save() { $isDuplicate = empty($_REQUEST['record']) && empty($_REQUEST['return_id']); // check if there are any modifications $modified = hasBeenModified($this->bean, array()); if (!$isDuplicate && !$modified) { return; // skip save if this is not a duplicate and nothing been modified } //2.0 We determine to what catalog category belongs if (!empty($this->bean->relatedcategory_id)) { $category = new oqc_Category(); if ($category->retrieve($this->bean->relatedcategory_id)) { $this->bean->catalog_id = $category->catalog_id; } } // save id of user that created the old version global $timedate; $dateCreated = $timedate->to_db($this->bean->date_entered); $createdById = $this->bean->created_by; $old_id = $this->begin_new_version(); parent::action_save(); $this->end_new_version($old_id); $this->initializeUniqueIdentifier(); $this->save_packaged_products(); $this->saveAttachedDocuments(); $this->saveProductOptions(); $this->saveImageWithResize(); $this->updateRelatedProducts($old_id); //$GLOBALS['log']->error("Dates are: ". $this->bean->date_entered ); // the new contract should have the same creator and creation date as the previous version, fix for #486 if ($dateCreated) { $this->bean->date_entered = $dateCreated; } if ($createdById) { $this->bean->created_by = $createdById; } if (!isset($_POST['assigned_user_id'])) { $this->bean->assigned_user_id = $this->bean->created_by; } //2.1 set this only if it is not in $_POST parent::action_save(); }
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(); } }
public static function getFromId($id) { $category = new oqc_Category(); return $category->retrieve($id); }