public function getReport() { $curlURL = "https://162.250.124.167/vicidial/non_agent_api.php?"; $httparams = array("function" => "status_remote", "source" => "remup", "user" => "admin", "pass" => "Mad4itNOW", "remote_user" => $this->remote_user->vicidial_identification); $curlURL .= http_build_query($httparams); $curlres = curl_init($curlURL); curl_setopt($curlres, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlres, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curlres, CURLOPT_SSL_VERIFYPEER, false); $rawResult = curl_exec($curlres); $rawResult = explode("|", $rawResult); $finalData = array("success" => str_pos($rawResult[0], "SUCCESS") !== false ? true : false, "status_message" => isset($rawResult[0]) ? trim($rawResult[0]) : null, "remote_user" => isset($rawResult[1]) ? trim($rawResult[1]) : null, "username" => isset($rawResult[2]) ? trim($rawResult[2]) : null); return $finalData; }
function trim_text($text, $length, $marker) { $greater = str_pos($text, $marker, $length) + strlen($marker); $trimmed = substr($text, 0, $greater); return $trimmed; }
/** * Gets all the files from the user directory * @param zibo\library\security\SecurityManager $securityManager The security manager * @param array $filters Filters for the file browser when reading the contents of the user directory * @return array Array with the URL of the file as key and the label as value */ private function getTinyMCEFiles(SecurityManager $securityManager, array $filters = array()) { // read the files $userDirectory = $this->getUserDirectory(); $fileBrowser = new FileBrowser($userDirectory); $files = $fileBrowser->readDirectory(null, $filters, true); // initializes variables needed to generate the tinymce list $zibo = Zibo::getInstance(); $rootPath = $zibo->getRootPath(); $applicationPath = new File($rootPath, Zibo::DIRECTORY_APPLICATION); $applicationPath = $applicationPath->getAbsolutePath(); $request = $zibo->getRequest(); $baseUrl = $request->getBaseUrl(); // generate the tinymce list $list = array(); foreach ($files as $path => $file) { $file = new File($userDirectory, $file); $link = str_replace($applicationPath, $baseUrl, $file->getAbsolutePath()); if (str_pos($baseUrl, $link) === false) { // the file is not in the root of the installation, skip it continue; } $label = $fileBrowser->getPath($file); $list[$link] = $label; } // we're done here return $list; }
/** * Unparse (prepare data) loaded products * * @return Mage_Catalog_Model_Convert_Parser_Product */ public function unparse() { $entityIds = $this->getData(); foreach ($entityIds as $i => $entityId) { /*$allproduct = $this->getProductModel() ->setData(array()) ->load($entityId);*/ $product = $this->getProductModel()->reset()->setStoreId($this->getStoreId())->load($entityId); $this->setProductTypeInstance($product); /* Get Product Rating and Calculate Avrage */ $ratingResourceModel = new Celebros_Salesperson_Model_Mysql4_Qwiser(); $ratingPercents = $ratingResourceModel->getRateingByEntityId($product->getEntityId()); $productRating = 0; foreach ($ratingPercents as $rating) { $productRating += (int) $rating['percent']; } if ($productRating != 0) { $productRating /= count($ratingPercents); } if (str_pos($product->getAttributeText('visibility'), 'Search') !== false) { $this->setProductTypeInstance($product); /* @var $product Mage_Catalog_Model_Product */ $position = Mage::helper('catalog')->__('Line %d, SKU: %s', $i + 1, $product->getSku()); $this->setPosition($position); $row = array('store' => $this->getStore()->getCode(), 'websites' => '', 'attribute_set' => $this->getAttributeSetName($product->getEntityTypeId(), $product->getAttributeSetId()), 'type' => $product->getTypeId(), 'category' => '', 'status' => '', 'rating' => $productRating, 'id' => $product->getId(), 'price' => ''); /*product status*/ //$productStatus = $product->getData('status'); /*categories names */ $categoryNames = array(); foreach ($product->getCategoryIds() as $categoryId) { $categoryName = Mage::getModel('catalog/category')->load($categoryId)->getName(); $categoryNames[$categoryName] = $categoryName; } $row['category'] = join(',', $categoryNames); /*websites codes*/ if ($this->getStore()->getCode() == Mage_Core_Model_Store::ADMIN_CODE) { $websiteCodes = array(); foreach ($product->getWebsiteIds() as $websiteId) { $websiteCode = Mage::app()->getWebsite($websiteId)->getCode(); $websiteCodes[$websiteCode] = $websiteCode; } $row['websites'] = join(',', $websiteCodes); } else { $row['websites'] = $this->getStore()->getWebsite()->getCode(); if ($this->getVar('url_field')) { $row['url'] = $product->getProductUrl(false); } } if ($product->getData('type_id') == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { $resource = Mage::getSingleton('core/resource'); $DB = $resource->getConnection('catalog_read'); $prefix = Mage::getConfig()->getNode('global/resources/db/table_prefix'); $sql = "SELECT * FROM " . $prefix . "catalog_product_index_price WHERE `entity_id` ='" . $product->getId() . "' GROUP BY `entity_id`"; $result = $DB->fetchAll($sql); $row['price'] = $result[0]['min_price']; } else { $row['price'] = $product->getFinalPrice(); } foreach ($product->getData() as $field => $value) { if (in_array($field, $this->_systemFields) || is_object($value)) { continue; } $attribute = $this->getAttribute($field); if (!$attribute) { continue; } if ($attribute->usesSource()) { $option = $attribute->getSource()->getOptionText($value); if ($value && empty($option)) { $message = Mage::helper('catalog')->__("Invalid option id specified for %s (%s), skipping the record", $field, $value); $this->addException($message, Mage_Dataflow_Model_Convert_Exception::ERROR); continue; } if (is_array($option)) { $value = join(self::MULTI_DELIMITER, $option); } else { $value = $option; } unset($option); } elseif (is_array($value)) { continue; } $row[$field] = $value; } /* Check if there is an Indexable Attribute that is not selected and add it to the array*/ $attributes = $product->getAttributes(); foreach ($attributes as $attribute) { if ($attribute->getIsFilterable()) { if (key_exists($attribute->getData('attribute_code'), $row)) { $row[$attribute->getData('attribute_code')] = $row[$attribute->getData('attribute_code')] . '{{is_filterable}}'; } } if ($attribute->getIsSearchable()) { if (key_exists($attribute->getData('attribute_code'), $row)) { $row[$attribute->getData('attribute_code')] = $row[$attribute->getData('attribute_code')] . '{{is_searchable}}'; } } } if ($stockItem = $product->getStockItem()) { foreach ($stockItem->getData() as $field => $value) { if (in_array($field, $this->_systemFields) || is_object($value)) { continue; } $row[$field] = $value; } } foreach ($this->_imageFields as $field) { if (isset($row[$field]) && $row[$field] == 'no_selection') { $row[$field] = null; } } /* EXPORTS TIER PRICING */ #$_tierPrices = Mage::getModel('bundle/product_price')->getTierPrice("",$product); #print_r($product->getTierPrice()); $row['tier_prices'] = ""; #$incoming_tierps = $product->getTierPrice(); $incoming_tierps = $product->getData('tier_price'); #print_r($incoming_tierps); if (is_array($incoming_tierps)) { foreach ($incoming_tierps as $tier_str) { #print_r($tier_str); $row['tier_prices'] .= $tier_str['cust_group'] . "=" . round($tier_str['price_qty']) . "=" . $tier_str['price'] . "|"; } } $batchExport = $this->getBatchExportModel()->setId(null)->setBatchId($this->getBatchModel()->getId())->setBatchData($row)->setStatus(1)->save(); } } return $this; }