<?php if (!defined('sugarEntry')) { define('sugarEntry', true); } chdir("../../.."); require_once 'include/entryPoint.php'; require_once 'modules/oqc_Product/oqc_Product.php'; $p = new oqc_Product(); $field = "oqc_product.packaged_product_ids"; $where = "{$field} IS NOT NULL AND NOT {$field} = ''"; $all = $p->get_list("", $where); $all = $all['list']; $url = 'https://' . $sugar_conf['host_name'] . '/index.php?module=oqc_Product&action=DetailView&record='; foreach ($all as $packet) { if ("oqc_Product" === get_class($packet)) { // now we can be sure we look on a product instance.. echo "Paket {$packet->name} <br />"; $pairs = explode(' ', $packet->packaged_product_ids); $newPackagedProductValue = ""; foreach ($pairs as $pair) { list($count, $id) = explode(':', $pair); $referencedProduct = new oqc_Product(); if ($referencedProduct->retrieve($id)) { $unique = $referencedProduct->price > 0; $recurring = $referencedProduct->price_recurring > 0; $append = ''; if ($unique && $recurring) { $packetUrl = $url . $packet->id; echo "Paket {$packet->name} muss nochmals angefasst werden, da bereits laufende und einmalige Kosten festgelegt sind, siehe {$packetUrl} <br />"; continue;
if (array_key_exists('id', $_REQUEST)) { if (!defined('sugarEntry')) { define('sugarEntry', true); } chdir(".."); require_once 'include/entryPoint.php'; require_once 'modules/oqc_Product/oqc_Product.php'; $originatingProduct = new oqc_Product(); $id = $_REQUEST['id']; // the product id that we search in the packages if ($originatingProduct->retrieve($id, true, true)) { //Do not proceed for deleted products // $previousVersions = $originatingProduct->getAllPreviousVersions(); // $interestingProductIds = array_merge(array($id), $previousVersions); $p = new oqc_Product(); $products = $p->get_list('', 'is_latest = "1"'); $products = $products['list']; // foreach ($interestingProductIds as $productId) { // iterate over all products. add those to the jsonArray that are packages containing the product specified by $id for ($i = 0; $i < count($products); $i++) { if ($products[$i]->containsProductWithId($id)) { // package contains the product with given id // add its name and id to the packages array $jsonArray[] = array("Name" => $products[$i]->name, "Id" => $products[$i]->id); } } // } } } require_once 'include/utils.php'; $json = getJSONobj();