/**
  * Ensures that the filter follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array('string' => 0, '1' => 1, '-1' => -1, '1.1' => 1, '-1.1' => -1, '0.9' => 0, '-0.9' => 0);
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $this->_filter->filter($input));
     }
 }
 private function setSphinxValues($class_config, $class_name, $class_xml)
 {
     if (array_key_exists("childs", $class_config) && is_array($class_config["childs"])) {
         $filter = new Zend_Filter_Int();
         foreach ($class_config["childs"] as $child) {
             $this->setSphinxValues($child, $class_name, $class_xml);
             if ($child["index_sphinx"] == 1) {
                 $weight = $filter->filter($child["weight_sphinx"]);
                 switch ($child["fieldtype"]) {
                     case "input":
                     case "checkbox":
                     case "date":
                     case "datetime":
                     case "numeric":
                     case "textarea":
                     case "time":
                     case "wysiwyg":
                         $node = $class_xml->{$class_name}->addChild($child["fieldtype"]);
                         $node->addAttribute("name", $child["name"]);
                         if ($weight > 1) {
                             // 1 is default
                             $node->addAttribute("weight", $weight);
                         }
                         break;
                     default:
                         break;
                 }
             }
         }
     }
 }
 protected function _prepareCollection()
 {
     $filter = new Zend_Filter_Int();
     $product_id = $filter->filter($this->getRequest()->getParam('id'));
     $roster_collection = Mage::getModel('icc_tec/roster')->getCollection()->addFieldToSelect('*')->addFieldToFilter('main_table.product_id', $product_id)->join(array('ord_item' => 'sales/order_item'), 'main_table.order_item_id = ord_item.item_id')->join(array('order' => 'sales/order'), 'ord_item.order_id = order.entity_id', array('order.entity_id AS order_entity_id', 'order.customer_email AS customer_email'))->join(array('address' => 'sales/order_address'), 'order.billing_address_id = address.entity_id AND address.address_type = \'billing\' ', array('address.telephone AS telephone', 'address.email AS address_email', 'CONCAT(address.street, \' \', address.city, \', \', address.region, \' \', address.postcode, \' \', address.country_id) as full_address'));
     $roster_collection->getSelect()->where('( ord_item.qty_canceled + ord_item.qty_refunded ) < ord_item.qty_ordered');
     //echo $roster_collection->getSelect();
     //die();
     $this->setCollection($roster_collection);
     return parent::_prepareCollection();
 }
 public function showProductsAction()
 {
     $integer = new Zend_Filter_Int();
     $tagIds = array();
     $productIds = array();
     $tagItems = array();
     $tagName = '';
     if ($this->_hasParam('tag')) {
         $tagName = $this->_getParam('tag');
         foreach (Axis::single('tag/customer')->findByTag($tagName) as $tag) {
             $tagIds[] = $tag['id'];
         }
         $this->setCanonicalUrl($this->view->url(array('tag' => $tagName), 'tag_products'));
         $this->view->showRemove = false;
     } else {
         $tagId = $integer->filter($this->_getParam('tagId', 0));
         if (!$tagId) {
             $this->_redirect('/tag');
             return;
         }
         $tagIds[] = $tagId;
         $this->view->showRemove = (bool) Axis::getCustomerId();
         if (!($row = Axis::single('tag/customer')->find($tagId)->current())) {
             return $this->_forward('not-found', 'Error', 'Axis_Core');
         }
         $tagName = $row->name;
     }
     $this->setTitle(Axis::translate('tag')->__("Products associated with tag '%s'", $tagName));
     foreach ($tagIds as $tagId) {
         $rowset = Axis::single('tag/customer')->findProductsByTagId($tagId);
         $items = array();
         foreach ($rowset->toArray() as $item) {
             $productIds[] = $item['product_id'];
             $items[$item['product_id']] = $item;
         }
         $tagItems = $items + $tagItems;
     }
     $this->view->tagItems = $tagItems;
     if (count($productIds)) {
         $products = Axis::single('catalog/product')->select('*')->addCommonFields()->addFinalPrice()->where('cp.id IN (?)', $productIds)->fetchProducts($productIds);
         $this->view->products = $products;
     }
     $this->render();
 }
 /**
  * Remove tag item for current user
  * @return void
  */
 public function removeItemAction()
 {
     $model = Axis::single('tag/product');
     $integer = new Zend_Filter_Int();
     $id = $integer->filter($this->_getParam('itemId'));
     $row = $model->find($id)->current();
     if (!$row) {
         return $this->_redirect('account/tag');
     }
     $rowCustomer = $row->findParentRow('Axis_Tag_Model_Customer');
     if ($rowCustomer->customer_id != Axis::getCustomerId() || $rowCustomer->site_id != Axis::getSiteId()) {
         return $this->_redirect('account/tag');
     }
     $row->delete();
     if (!$model->weightTag($rowCustomer->id)) {
         $rowCustomer->delete();
         return $this->_redirect('account/tag');
     }
     $this->_redirect('tag/index/show-products/tagId/' . $rowCustomer->id);
 }
 /**
  * LogBook Add New Record
  */
 function myAddRecord($logDateCreate, $logTxt)
 {
     // Returns (int) $value
     Zend_Loader::loadClass('Zend_Filter_Int');
     $intf = new Zend_Filter_Int();
     // Returns the string $value, removing all but alphabetic characters.
     // This filter includes an option to also allow white space characters.
     Zend_Loader::loadClass('Zend_Filter_Digits');
     $digit = new Zend_Filter_Digits();
     $digit->allowWhiteSpace = true;
     $logTypeId = $intf->filter(trim($this->_request->getPost('logTypeId')));
     $logbook = new wbLogBook();
     $data = array('logDateCreate' => $logDateCreate, 'logTxt' => $logTxt, 'logTypeId' => $logTypeId);
     $this->id_insert = $logbook->insert($data);
     if ($this->id_insert) {
         $email = new MyClass_SendEmail();
         // $from_email, $from_name, $to_email, $to_name, $subj, $body
         $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook Add record'), $this->view->translate->_('Create record :') . " " . $data['logDateCreate'] . "\n" . $this->view->translate->_('Type record :') . " " . $data['logTypeId'] . "\n" . $this->view->translate->_("Text :") . "\n-------\n" . $data['logTxt'] . "\n-------\n\n");
     }
 }
 public function processAction()
 {
     $f = new Zend_Filter_Int();
     $id = $f->filter($this->getRequest()->getParam('id'));
     if (!$id) {
         $this->getSession()->addError('No id sent to find queue to process.');
         $this->_redirect('*/*/list');
     }
     $queue = Mage::getModel('gorilla_queue/queue');
     $queue->load($id, 'queue_id');
     $queue->process();
     $this->_redirect('*/*/list');
 }
Exemple #8
0
 /**
  * Returns (int) value.
  *
  * @deprecated since 0.8.0
  * @param      mixed $value
  * @return     integer
  */
 public static function getInt($value)
 {
     require_once 'Zend/Filter/Int.php';
     $filter = new Zend_Filter_Int();
     return $filter->filter($value);
 }
 public function exportSearchExcelAction()
 {
     $content = $this->getLayout()->createBlock('icc_tec/adminhtml_roster_grid')->getExcelFile();
     $roster_rows = file($content['value']);
     // content is just an array of where the file (et al.) has been put
     $headings_row = array_shift($roster_rows);
     try {
         $conn = Mage::getSingleton('core/resource')->getConnection('core_write');
         $conn->beginTransaction();
         foreach ($roster_rows as $row) {
             $id = array_shift(explode(',', $row));
             // first element is the id of the roster row
             $roster = Mage::getModel('icc_tec/roster')->load($id);
             if (is_null($roster->getInitialExportDate())) {
                 $roster->setInitialExportDate(time());
                 $roster->save();
             }
         }
         $file_name = 'events.xml';
         $zf = new Zend_Filter_Int();
         $prod_id = $zf->filter($this->getRequest()->getParam('id'));
         $product = Mage::getModel('catalog/product')->load($prod_id);
         $zf = new Zend_Filter_Alnum();
         $file_name = $zf->filter('RosterFor' . $product->getName()) . '.xml';
         $this->_prepareDownloadResponse($file_name, $content);
         $conn->commit();
     } catch (Exception $e) {
         Mage::log('Could not download and uppdate download dates for roster with. Last roster id: ' . $id . ' with exception: ' . $e->getMessage(), null, 'export-event-excel-exception.log');
         $conn->rollback();
     }
 }
 private function setSphinxValues($class_config, $class_name, $class_xml)
 {
     if (array_key_exists("childs", $class_config) && is_array($class_config["childs"])) {
         $filter = new Zend_Filter_Int();
         foreach ($class_config["childs"] as $child) {
             $this->setSphinxValues($child, $class_name, $class_xml);
             if ($child["index_sphinx"] == 1) {
                 $weight = $filter->filter($child["weight_sphinx"]);
                 $field_type = $child["fieldtype"];
                 if (in_array($field_type, array("input", "checkbox", "date", "datetime", "numeric", "textarea", "time", "select", "superboxselect", "wysiwyg"))) {
                     $node = $class_xml->{$class_name}->addChild($child["fieldtype"]);
                     $node->addAttribute("name", $child["name"]);
                     if ($weight > 1) {
                         // 1 is default
                         $node->addAttribute("weight", $weight);
                     }
                     if ($child["store_sphinx"] == 1) {
                         switch ($field_type) {
                             case "input":
                             case "textarea":
                             case "wysiwyg":
                                 $node->addAttribute("field_type", "sql_field_string");
                                 break;
                             case "date":
                             case "datetime":
                             case "time":
                                 $node->addAttribute("field_type", "sql_attr_timestamp");
                                 break;
                             case "numeric":
                                 $node->addAttribute("field_type", "sql_attr_float");
                                 break;
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #11
0
 /**
  * Pobiera obiekt Logic_Interest z bezpośrednio przekazanymi danymi. Obiekt nie jest powiązany z żadną konkretną negocjacją.
  * @param $customerTypeId
  * @param $brandId
  * @param $engagement
  * @param $amount
  * @param $duration
  * @param $newMoney
  * @param $counterOfferNo
  * @param null|float $expectance
  * @return Logic_Interest
  */
 public static function getForDebug($customerTypeId, $brandId, $engagement, $amount, $duration, $newMoney, $counterOfferNo, $expectance = null)
 {
     $interest = new self();
     $interest->customerTypeId = $customerTypeId;
     $interest->brandId = $brandId;
     $interest->customer = new Logic_Customer_Mock($engagement);
     $interest->depositAmount = $amount;
     $filter = new Zend_Filter_Int();
     if (strpos($duration, 'M') !== false) {
         $months = $filter->filter($duration);
         $interest->depositDays = $months % 12 * 30 + ($months - $months % 12) / 12 * 365;
     } elseif (strpos($duration, 'D') !== false) {
         $interest->depositDays = $filter->filter($duration);
     } elseif (strpos($duration, 'Y') !== false) {
         $interest->depositDays = $filter->filter($duration) * 365;
     }
     $interest->newMoney = $newMoney;
     $interest->counterOfferNo = $counterOfferNo;
     $interest->customerExpectance = $expectance;
     $interest->_baseValue = 0.0;
     $interest->depInit();
     return $interest;
 }