public function getProduct() { $this->onExecuteBefore('getProduct'); $row = KSMProducts::getProduct($this->_id); if (!empty($row)) { $row->rate = KSMProducts::getProductRate($row->id); $row->manufacturer = KSMProducts::getProductManufacturer($row->manufacturer); $row->add_link_cart = KSFunctions::getAddToCartLink(); $row->comments = $this->getProductComments($row->id); $row->sets = $this->getProductRelations($row->id); $this->_product = $row; KSMProducts::incProductHit($this->_id); $this->onExecuteAfter('getProduct', array(&$row)); return $row; } JError::raiseError(404, 'Товара не существует'); }
public static function getProduct($id) { self::onExecuteBefore(array(&$id)); global $ext_name; $old_ext_name = $ext_name; $ext_name = 'ksenmart'; $db = JFactory::getDBO(); $params = JComponentHelper::getParams('com_ksenmart'); $query = $db->getQuery(true); $query = KSMProducts::setProductMainImageToQuery($query); $query->select('`p`.*')->select($db->qn(array('m.title', 'u.form1'), array('manufacturer_title', 'unit')))->from($db->qn('#__ksenmart_products', 'p'))->leftjoin($db->qn('#__ksenmart_manufacturers', 'm') . ' ON ' . $db->qn('p.manufacturer') . '=' . $db->qn('m.id'))->leftjoin($db->qn('#__ksenmart_product_units', 'u') . ' ON ' . $db->qn('p.product_unit') . '=' . $db->qn('u.id'))->where($db->qn('p.id') . '=' . $db->q($id))->group($db->qn('p.id')); $db->setQuery($query); $row = $db->loadObject(); if ($row && !empty($row)) { $row->properties = KSMProducts::getProperties($id); if (empty($row->folder)) { $row->folder = 'products'; } if (empty($row->filename)) { $row->filename = 'no.jpg'; } if ($row->product_packaging == 0) { $row->product_packaging = 1; } $row->product_packaging = rtrim(rtrim($row->product_packaging, '0'), '.'); if ($row->parent_id > 0) { $row->parent = self::getProduct($row->parent_id); } self::productPricesTransform($row); $row->link = JRoute::_('index.php?option=com_ksenmart&view=product&id=' . $row->id . ':' . $row->alias . '&Itemid=' . KSSystem::getShopItemid()); $row->mini_small_img = KSMedia::resizeImage($row->filename, $row->folder, $params->get('mini_thumb_width'), $params->get('mini_thumb_height'), json_decode($row->params, true)); $row->small_img = KSMedia::resizeImage($row->filename, $row->folder, $params->get('thumb_width'), $params->get('thumb_height'), json_decode($row->params, true)); $row->img = KSMedia::resizeImage($row->filename, $row->folder, $params->get('middle_width'), $params->get('middle_height'), json_decode($row->params, true)); $row->img_link = KSMedia::resizeImage($row->filename, $row->folder, $params->get('full_width', 900), $params->get('full_height', 900)); $row->rate = KSMProducts::getProductRate($row->id); $row->add_link_cart = KSFunctions::getAddToCartLink($row->price, 2); $row->tags = new JHelperTags(); $row->tags->getItemTags('com_ksenmart.product', $row->id); } $ext_name = $old_ext_name; self::onExecuteAfter(array(&$row)); return $row; }
echo $this->item->comment; ?> </a> <p> <a rel='{"x":"90%","y":"90%"}' href="<?php echo JRoute::_('index.php?option=com_ksenmart&view=comments&layout=comment&id=' . $this->item->id . '&tmpl=component'); ?> " class="edit km-modal"><?php echo JText::_('ksm_edit'); ?> </a> </p> </div> </td> <td class="comment_date"><?php echo KSFunctions::getStandartDate($this->item->date_add); ?> </td> <td class="stat" align="center"><input type="checkbox" class="status" name="items[<?php echo $this->item->id; ?> ][published]" value="1" <?php echo $this->item->published == 1 ? 'checked' : ''; ?> /></td> <td class="del"><a href="#"></a></td> <input type="hidden" class="id" name="items[<?php echo $this->item->id; ?> ][id]" value="<?php echo $this->item->id;
function saveManufacturer($data) { $this->onExecuteBefore('saveManufacturer', array(&$data)); $data['alias'] = KSFunctions::CheckAlias($data['alias'], $data['id']); if ($data['alias'] == '') { $data['alias'] = KSFunctions::GenAlias($data['title']); } $data['country'] = isset($data['country']) ? $data['country'] : 0; $table = $this->getTable('manufacturers'); if (!$table->bindCheckStore($data)) { $this->setError($table->getError()); return false; } $id = $table->id; KSMedia::saveItemMedia($id, $data, 'manufacturer', 'manufacturers'); $on_close = 'window.parent.ManufacturersModule.refresh();'; $return = array('id' => $id, 'on_close' => $on_close); $this->onExecuteAfter('saveManufacturer', array(&$return)); return $return; }
function getImportInfo() { $this->onExecuteBefore('getImportInfo'); $encoding = $this->getState('encoding'); if ($encoding == 'cp1251') { setLocale(LC_ALL, 'ru_RU.CP1251'); } if ($_FILES['photos_zip']['tmp_name'] != '') { $import_dir = JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'import' . DS; JFolder::delete($import_dir); JFolder::create($import_dir, 0777); copy($_FILES['photos_zip']['tmp_name'], $import_dir . 'import.zip'); $result = JArchive::extract(JPath::clean($import_dir . 'import.zip'), JPath::clean($import_dir)); } $unic = JRequest::getVar('unic'); $f = fopen(JPATH_COMPONENT . DS . 'tmp' . DS . 'import.csv', "rt") or die("Ошибка!"); $info = array('insert' => '', 'update' => ''); $relatives = array(); for ($k = 0; $data = fgetcsv($f, 10000, ";"); $k++) { if ($k == 0) { $headers = $data; continue; } $product_data = array(); if ($k > 0) { if (isset($_POST['title']) && $_POST['title'] != '') { $product_data['title'] = $this->encode($data[$_POST['title']]); } if (isset($_POST['parent_id']) && $_POST['parent_id'] != '') { $product_data['parent_id'] = $this->encode($data[$_POST['parent_id']]); } if (isset($_POST['categories']) && $_POST['categories'] != '') { $product_data['categories'] = $this->encode($data[$_POST['categories']]); } if (isset($_POST['childs_group']) && $_POST['childs_group'] != '') { $product_data['childs_group'] = $this->encode($data[$_POST['childs_group']]); } if (isset($_POST['price']) && $_POST['price'] != '') { $product_data['price'] = str_replace(' ', '', $this->encode($data[$_POST['price']])); } if (isset($_POST['promotion_price']) && $_POST['promotion_price'] != '') { $product_data['promotion_price'] = (double) str_replace(' ', '', $this->encode($data[$_POST['promotion_price']])); } if (isset($_POST['price_type']) && $_POST['price_type'] != '') { $product_data['price_type'] = str_replace(' ', '', $this->encode($data[$_POST['price_type']])); } if (isset($_POST['product_code']) && $_POST['product_code'] != '') { $product_data['product_code'] = $this->encode($data[$_POST['product_code']]); } if (isset($_POST['product_packaging']) && $_POST['product_packaging'] != '') { $product_data['product_packaging'] = (double) str_replace(' ', '', $this->encode($data[$_POST['product_packaging']])); } if (isset($_POST['product_unit']) && $_POST['product_unit'] != '') { $product_data['product_unit'] = str_replace(' ', '', $this->encode($data[$_POST['product_unit']])); } if (isset($_POST['in_stock']) && $_POST['in_stock'] != '') { $product_data['in_stock'] = (double) $this->encode($data[$_POST['in_stock']]); } if (isset($_POST['promotion']) && $_POST['promotion'] != '') { $product_data['promotion'] = $this->encode($data[$_POST['promotion']]); } if (isset($_POST['manufacturer']) && $_POST['manufacturer'] != '') { $product_data['manufacturer'] = $this->encode($data[$_POST['manufacturer']]); } if (isset($_POST['country']) && $_POST['country'] != '') { $product_data['country'] = $this->encode($data[$_POST['country']]); } if (isset($_POST['content']) && $_POST['content'] != '') { $product_data['content'] = $this->encode($data[$_POST['content']]); } if (isset($_POST['photos']) && $_POST['photos'] != '') { $product_data['photos'] = $this->encode($data[$_POST['photos']]); } if (isset($_POST['relative']) && $_POST['relative'] != '') { $product_data['relative'] = $this->encode($data[$_POST['relative']]); } if (isset($_POST['tags']) && $_POST['tags'] != '') { $product_data['tags'] = $this->encode($data[$_POST['tags']]); } if (isset($_POST['metatitle']) && $_POST['metatitle'] != '') { $product_data['metatitle'] = $this->encode($data[$_POST['metatitle']]); } else { $product_data['metatitle'] = ''; } if (isset($_POST['metadescription']) && $_POST['metadescription'] != '') { $product_data['metadescription'] = $this->encode($data[$_POST['metadescription']]); } else { $product_data['metadescription'] = ''; } if (isset($_POST['metakeywords']) && $_POST['metakeywords'] != '') { $product_data['metakeywords'] = $this->encode($data[$_POST['metakeywords']]); } else { $product_data['metakeywords'] = ''; } $product_data['type'] = 'product'; $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_properties')->order('ordering'); $this->_db->setQuery($query); $properties = $this->_db->loadObjectList(); foreach ($properties as $property) { if (isset($_POST['property_' . $property->id]) && $_POST['property_' . $property->id] != '') { $product_data['property_' . $property->id] = $this->encode($data[$_POST['property_' . $property->id]]); } } $query = $this->_db->getQuery(true); $query->select('id')->from('#__ksenmart_currencies')->where('`default`=1'); $this->_db->setQuery($query); $def_price_type = $this->_db->loadResult(); $query = $this->_db->getQuery(true); $query->select('id')->from('#__ksenmart_product_units'); $this->_db->setQuery($query, 0, 1); $def_unit = $this->_db->loadResult(); if (isset($product_data['parent_id']) && $product_data['parent_id'] != '') { $query = $this->_db->getQuery(true); $query->select('id')->from('#__ksenmart_products')->where($unic . '=' . $this->_db->quote($product_data['parent_id']))->where('parent_id=0'); $this->_db->setQuery($query); $parent_id = $this->_db->loadResult(); if (empty($parent_id)) { $product_data['parent_id'] = 0; } else { $product_data['type'] = 'child'; $product_data['parent_id'] = $parent_id; $query = $this->_db->getQuery(true); $query->update('#__ksenmart_products')->set('is_parent=1')->where('id=' . $parent_id); $this->_db->setQuery($query); $this->_db->query(); } } else { $product_data['parent_id'] = 0; } if (isset($product_data['childs_group']) && $product_data['childs_group'] != '' && $product_data['parent_id'] != 0) { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_products_child_groups')->where('title like ' . $this->_db->quote($product_data['childs_group']))->where('product_id=' . $product_data['parent_id']); $this->_db->setQuery($query); $childs_group = $this->_db->loadObject(); if (count($childs_group) == 0) { $qvalues = array($this->_db->quote($product_data['childs_group']), $product_data['parent_id']); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_products_child_groups')->columns('title,product_id')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $childs_group_id = $this->_db->insertid(); $product_data['childs_group'] = $childs_group_id; } else { $product_data['childs_group'] = $childs_group->id; } } else { $product_data['childs_group'] = 0; } if (isset($product_data['price_type']) && $product_data['price_type'] != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_currencies')->where('title=' . $this->_db->quote($product_data['price_type'])); $this->_db->setQuery($query); $price_type = $this->_db->loadObject(); if (count($price_type) == 0) { $product_data['price_type'] = $def_price_type; } else { $product_data['price_type'] = $price_type->id; } } else { $product_data['price_type'] = $def_price_type; } if (isset($product_data['product_unit']) && $product_data['product_unit'] != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_product_units')->where('form1=' . $this->_db->quote($product_data['product_unit'])); $this->_db->setQuery($query); $unit = $this->_db->loadObject(); if (count($unit) == 0) { $qvalues = array($this->_db->quote($product_data['product_unit']), $this->_db->quote($product_data['product_unit']), $this->_db->quote($product_data['product_unit'])); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_product_units')->columns('form1,form2,form5')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $unit_id = $this->_db->insertid(); $product_data['product_unit'] = $unit_id; } else { $product_data['product_unit'] = $unit->id; } } else { $product_data['product_unit'] = $def_unit; } if (isset($product_data['promotion_price']) && $product_data['promotion_price'] != '') { $product_data['promotion'] = 1; $product_data['old_price'] = $product_data['price']; $product_data['price'] = $product_data['promotion_price']; } else { $product_data['promotion'] = 0; $product_data['old_price'] = 0; } if (isset($product_data['country']) && $product_data['country'] != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_countries')->where('title=' . $this->_db->quote($product_data['country'])); $this->_db->setQuery($query); $country = $this->_db->loadObject(); if (count($country) == 0) { $alias = KSFunctions::GenAlias($product_data['country']); $qvalues = array($this->_db->quote($product_data['country']), $this->_db->quote($alias), 1, $this->_db->quote($product_data['country'])); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_countries')->columns('title,alias,published,metatitle')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $country_id = $this->_db->insertid(); $product_data['country'] = $country_id; } else { $product_data['country'] = $country->id; } } else { $product_data['country'] = 0; } if (isset($product_data['manufacturer']) && $product_data['manufacturer'] != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_manufacturers')->where('title=' . $this->_db->quote($product_data['manufacturer'])); $this->_db->setQuery($query); $manufacturer = $this->_db->loadObject(); if (count($manufacturer) == 0) { $alias = KSFunctions::GenAlias($product_data['manufacturer']); $qvalues = array($this->_db->quote($product_data['manufacturer']), $this->_db->quote($alias), $this->_db->quote($product_data['country']), 1, $this->_db->quote($product_data['manufacturer'])); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_manufacturers')->columns('title,alias,country,published,metatitle')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $manufacturer_id = $this->_db->insertid(); $product_data['manufacturer'] = $manufacturer_id; } else { $product_data['manufacturer'] = $manufacturer->id; } } else { $product_data['manufacturer'] = 0; } $categories = explode(';', $product_data['categories']); $prd_cats = array(); foreach ($categories as $cats) { $parent = 0; $prd_cat = 0; $cats = explode(':', $cats); foreach ($cats as $cat) { $cat = trim($cat); if ($cat != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_categories')->where('title=' . $this->_db->quote($cat))->where('parent_id=' . $parent); $this->_db->setQuery($query); $category = $this->_db->loadObject(); if (!$category) { $alias = KSFunctions::GenAlias($cat); $qvalues = array($this->_db->quote($cat), $this->_db->quote($alias), $parent, 1); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_categories')->columns('title,alias,parent_id,published')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $prd_cat = $this->_db->insertid(); $parent = $prd_cat; } else { $prd_cat = $category->id; $parent = $prd_cat; } $prd_cats[] = $prd_cat; } } } if ($product_data['parent_id'] != 0) { $prd_cats = array(); $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_products_categories')->where('product_id=' . $product_data['parent_id']); $this->_db->setQuery($query); $cats = $this->_db->loadObjectList(); foreach ($cats as $cat) { $prd_cats[] = $cat->category_id; } } if (!isset($product_data['price'])) { $product_data['price'] = 0; } if (!isset($product_data['product_code'])) { $product_data['product_code'] = ''; } if (!isset($product_data['product_packaging'])) { $product_data['product_packaging'] = 1; } if (!isset($product_data['in_stock'])) { $product_data['in_stock'] = 1; } if (!isset($product_data['content'])) { $product_data['content'] = ''; } if ($unic != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_products')->where($unic . '=' . $this->_db->quote($product_data[$unic]))->where('parent_id=' . $product_data['parent_id']); $this->_db->setQuery($query); $product = $this->_db->loadObjectList(); } if (count($product) == 0) { $alias = KSFunctions::GenAlias($product_data['title']); $values = array('parent_id' => $product_data['parent_id'], 'childs_group' => $product_data['childs_group'], 'title' => $this->_db->quote($product_data['title']), 'alias' => $this->_db->quote($alias), 'price' => $this->_db->quote($product_data['price']), 'old_price' => $this->_db->quote($product_data['old_price']), 'price_type' => $product_data['price_type'], 'in_stock' => $product_data['in_stock'], 'product_code' => $this->_db->quote($product_data['product_code']), 'product_packaging' => $product_data['product_packaging'], 'product_unit' => $product_data['product_unit'], 'content' => $this->_db->quote($product_data['content']), 'promotion' => $product_data['promotion'], 'manufacturer' => $product_data['manufacturer'], 'published' => 1, 'metatitle' => $this->_db->quote($product_data['metatitle']), 'metadescription' => $this->_db->quote($product_data['metadescription']), 'metakeywords' => $this->_db->quote($product_data['metakeywords']), 'date_added' => 'NOW()', 'type' => $this->_db->quote($product_data['type'])); $query = $this->_db->getQuery(true); $query->update('#__ksenmart_products')->set('ordering=ordering+1'); $this->_db->setQuery($query); $this->_db->query(); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_products')->columns(implode(',', array_keys($values)))->values(implode(',', $values)); $this->_db->setQuery($query); $this->_db->query(); $product_id = $this->_db->insertid(); $is_default = true; foreach ($prd_cats as $prd_cat) { $qvalues = array($product_id, $prd_cat, (int) $is_default); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_products_categories')->columns('product_id,category_id,is_default')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $is_default = false; } $info['insert']++; } else { $product_id = $product[0]->id; $to_update = array(); $to_update[] = 'date_added=NOW()'; if (isset($product_data['title'])) { $to_update[] = 'title=' . $this->_db->quote($product_data['title']); } if (isset($product_data['product_code'])) { $to_update[] = 'product_code=' . $this->_db->quote($product_data['product_code']); } if (isset($product_data['in_stock'])) { $to_update[] = 'in_stock=' . $this->_db->quote($product_data['in_stock']); } if (isset($product_data['content'])) { $to_update[] = 'content=' . $this->_db->quote($product_data['content']); } if (isset($product_data['introcontent'])) { $to_update[] = 'introcontent=' . $this->_db->quote($product_data['introcontent']); } if (isset($product_data['product_packaging'])) { $to_update[] = 'product_packaging=' . $this->_db->quote($product_data['product_packaging']); } if ($product_data['metatitle'] != '') { $to_update[] = 'metatitle=' . $this->_db->quote($product_data['metatitle']); } if ($product_data['metadescription'] != '') { $to_update[] = 'metadescription=' . $this->_db->quote($product_data['metadescription']); } if ($product_data['metakeywords'] != '') { $to_update[] = 'metakeywords=' . $this->_db->quote($product_data['metakeywords']); } if (isset($product_data['price'])) { $to_update[] = 'price=' . $this->_db->quote($product_data['price']); } if (isset($product_data['manufacturer'])) { $to_update[] = 'manufacturer=' . $this->_db->quote($product_data['manufacturer']); } if (isset($product_data['price_type'])) { $to_update[] = 'price_type=' . $this->_db->quote($product_data['price_type']); } if (isset($product_data['product_unit'])) { $to_update[] = 'product_unit=' . $this->_db->quote($product_data['product_unit']); } if (isset($product_data['old_price'])) { $to_update[] = 'old_price=' . $this->_db->quote($product_data['old_price']); } if (isset($product_data['promotion'])) { $to_update[] = 'promotion=' . $this->_db->quote($product_data['promotion']); } foreach ($prd_cats as $prd_cat) { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_products_categories')->where('product_id=' . $product_id)->where('category_id=' . $prd_cat); $this->_db->setQuery($query); $db_cat = $this->_db->loadObject(); if (count($db_cat) == 0) { $qvalues = array($product_id, $prd_cat); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_products_categories')->columns('product_id,category_id')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); } } $query = $this->_db->getQuery(true); $query->update('#__ksenmart_products')->set($to_update)->where('id=' . $product_id); $this->_db->setQuery($query); $this->_db->query(); if (isset($product_data['photos']) && $product_data['photos'] != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_files')->where(array("media_type='image'", "owner_type='product'", "owner_id=" . $product_id))->order('ordering'); $this->_db->setQuery($query); $images = $this->_db->loadObjectList('id'); $i = count($images); foreach ($images as $image) { $this->delPhoto($image->filename, $image->folder); } } $info['update']++; } if (isset($product_data['relative']) && $product_data['relative'] != '') { $relatives[$product_id] = $product_data['relative']; } if (isset($product_data['tags']) && $product_data['tags'] != '') { $product_data['tags'] = explode(',', $product_data['tags']); foreach ($product_data['tags'] as $key => $value) { $value = trim($value); $query = $this->_db->getQuery(true); $query->select('id')->from('#__tags')->where('title=' . $this->_db->quote($value)); $this->_db->setQuery($query); $tag_id = $this->_db->loadResult(); if (!empty($tag_id)) { $product_data['tags'][$key] = $tag_id; } else { $product_data['tags'][$key] = '#new#' . $value; } } $tableProducts = $this->getTable('Products'); JObserverMapper::attachAllObservers($tableProducts); JObserverMapper::addObserverClassToClass('JTableObserverTags', 'KsenmartTableProducts', array('typeAlias' => 'com_ksenmart.product')); $tableProducts->load($product_id); $tagsObserver = $tableProducts->getObserverOfClass('JTableObserverTags'); $result = $tagsObserver->setNewTags($product_data['tags'], true); } if (isset($product_data['photos']) && $product_data['photos'] != '') { $product_data['photos'] = explode(',', $product_data['photos']); $i = 1; foreach ($product_data['photos'] as $photo) { $photo = trim($photo); if (!empty($photo)) { $file = basename($photo); $nameParts = explode('.', $file); $file = microtime(true) . '.' . $nameParts[count($nameParts) - 1]; $copied = false; if (strpos($photo, 'http://') !== false) { if ($photo_content = file_get_contents($photo)) { if (file_put_contents(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'images' . DS . 'products' . DS . 'original' . DS . $file, $photo_content)) { $copied = true; } } } else { if (file_exists(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'import' . DS . $photo)) { if (copy(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'import' . DS . $photo, JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'images' . DS . 'products' . DS . 'original' . DS . $file)) { $copied = true; } } } if ($copied) { $mime = mime_content_type(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'images' . DS . 'products' . DS . 'original' . DS . $file); $qvalues = array($product_id, $this->_db->quote('image'), $this->_db->quote('product'), $this->_db->quote('products'), $this->_db->quote($file), $this->_db->quote($mime), $this->_db->quote(''), $i); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_files')->columns('owner_id,media_type,owner_type,folder,filename,mime_type,title,ordering')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $i++; } } } } foreach ($properties as $property) { if (isset($product_data['property_' . $property->id]) && $product_data['property_' . $property->id] != '') { switch ($property->type) { case 'text': if ($product_data['property_' . $property->id] != '') { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_property_values')->where('property_id=' . $property->id)->where('title=' . $this->_db->quote($product_data['property_' . $property->id])); $this->_db->setQuery($query); $prop_value = $this->_db->loadObject(); if (count($prop_value) == 0) { $alias = KSFunctions::GenAlias($product_data['property_' . $property->id]); $qvalues = array($property->id, $this->_db->quote($product_data['property_' . $property->id]), $this->_db->quote($alias)); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_property_values')->columns('property_id,title,alias')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $prop_value_id = $this->_db->insertid(); } else { $prop_value_id = $prop_value->id; } $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_product_properties_values')->where('product_id=' . $product_id)->where('property_id=' . $property->id)->where('value_id=' . $prop_value_id); $this->_db->setQuery($query); $prod_prop_value = $this->_db->loadObject(); if (count($prod_prop_value) == 0) { $qvalues = array($product_id, $property->id, $prop_value_id, $this->_db->quote($product_data['property_' . $property->id])); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_product_properties_values')->columns('product_id,property_id,value_id,text')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); } } break; default: $prop_vals = explode(';', $product_data['property_' . $property->id]); $prop_values = ''; foreach ($prop_vals as $prop_val) { if ($prop_val != '') { $val_parts = explode('=', $prop_val); if (count($val_parts) == 2) { $prop_val = $val_parts[0]; $val_price = $val_parts[1]; } else { $val_price = ''; } $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_property_values')->where('property_id=' . $property->id)->where('title=' . $this->_db->quote($prop_val)); $this->_db->setQuery($query); $prop_value = $this->_db->loadObject(); if (count($prop_value) == 0) { $alias = KSFunctions::GenAlias($prop_val); $qvalues = array($property->id, $this->_db->quote($prop_val), $this->_db->quote($alias)); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_property_values')->columns('property_id,title,alias')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); $prop_value_id = $this->_db->insertid(); } else { $prop_value_id = $prop_value->id; } $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_product_properties_values')->where('product_id=' . $product_id)->where('property_id=' . $property->id)->where('value_id=' . $prop_value_id); $this->_db->setQuery($query); $prod_prop_value = $this->_db->loadObject(); if (count($prod_prop_value) == 0) { $qvalues = array($product_id, $property->id, $prop_value_id, $this->_db->quote($val_price)); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_product_properties_values')->columns('product_id,property_id,value_id,price')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); } else { $query = $this->_db->getQuery(true); $query->update('#__ksenmart_product_properties_values')->set('price=' . $this->_db->quote($val_price))->where('id=' . $prod_prop_value->id); $this->_db->setQuery($query); $this->_db->query(); } } } } foreach ($prd_cats as $prd_cat) { $query = $this->_db->getQuery(true); $query->select('id')->from('#__ksenmart_product_categories_properties')->where('category_id=' . $prd_cat)->where('property_id=' . $property->id); $this->_db->setQuery($query); $res = $this->_db->loadResult(); if (empty($res)) { $qvalues = array($prd_cat, $property->id); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_product_categories_properties')->columns('category_id,property_id')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); } } } } } } foreach ($relatives as $product_id => $relative) { $relative = explode(';', $relative); foreach ($relative as $relative_title) { if (!empty($relative_title)) { $query = $this->_db->getQuery(true); $query->select('id')->from('#__ksenmart_products')->where('title like ' . $this->_db->quote($relative_title)); $this->_db->setQuery($query); $relative_id = $this->_db->loadResult(); if (!empty($relative_id)) { $query = $this->_db->getQuery(true); $query->select('*')->from('#__ksenmart_products_relations')->where('product_id=' . $product_id)->where('relative_id=' . $relative_id)->where('relation_type=' . $this->_db->quote('relation')); $this->_db->setQuery($query); $db_rel = $this->_db->loadObject(); if (count($db_rel) == 0) { $qvalues = array($product_id, $relative_id, $this->_db->quote('relation')); $query = $this->_db->getQuery(true); $query->insert('#__ksenmart_products_relations')->columns('product_id,relative_id,relation_type')->values(implode(',', $qvalues)); $this->_db->setQuery($query); $this->_db->query(); } } } } } fclose($f); $dir = scandir(JPATH_COMPONENT . DS . 'tmp' . DS); foreach ($dir as $d) { if ($d != '.' && $d != '..') { unlink(JPATH_COMPONENT . DS . 'tmp' . DS . $d); } } $this->onExecuteAfter('getImportInfo', array(&$info)); return $info; }
echo KSFunctions::stringView($this->order->cost); ?> , <?php echo $this->params->get('printforms_nds') != 0 ? 'в т.ч. НДС' : 'без налога (НДС)'; ?> </b></td> </tr> </table> </td> <td class="b_left b_top b_bottom" colspan="2">×</td> <td class="b_left b_top b_bottom rightAlign"><?php echo KSFunctions::stringView($this->order->cost * $this->params->get('printforms_nds') / 100); ?> </td> <td class="b_left b_top b_bottom rightAlign nobr"><?php echo KSFunctions::stringView($this->order->cost * (100 - $this->params->get('printforms_nds')) / 100); ?> </td> <td class="b_left b_top"> </td> <td class="b_top"> </td> <td class="b_top"> </td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0" class="mainTable_normal" width="100%"> <tr> <td> </td> </tr> <tr> <td> </td>
function saveRegion($data) { $this->onExecuteBefore('saveRegion', array(&$data)); $data['alias'] = KSFunctions::CheckAlias($data['alias'], $data['id']); $data['alias'] = $data['alias'] == '' ? KSFunctions::GenAlias($data['title']) : $data['alias']; $data['country_id'] = isset($data['country_id']) ? $data['country_id'] : 0; $table = $this->getTable('regions'); if (empty($data['id'])) { $query = $this->_db->getQuery(true); $query->update('#__ksenmart_regions')->set('ordering=ordering+1'); $this->_db->setQuery($query); $this->_db->query(); } if (!$table->bindCheckStore($data)) { $this->setError($table->getError()); return false; } $id = $table->id; KSMedia::saveItemMedia($id, $data, 'region', 'regions'); $on_close = 'window.parent.RegionsList.refreshList();'; $return = array('id' => $id, 'on_close' => $on_close); $this->onExecuteAfter('saveRegion', array(&$return)); return $return; }
<td></td> <td colspan=5 class=xl27><?php echo JText::_('KSM_CART_RECEIPT_TYPE'); ?> </td> <td></td> <td class=xl21></td> <td></td> </tr> <tr height=58 style='mso-height-source:userset;height:43.5pt'> <td height=58 class=xl22 width=78 style='height:43.5pt;width:59pt'><?php echo JText::_('KSM_CART_RECEIPT_SUM_LETTERS'); ?> </td> <td colspan=21 class=xl32 width=605 style='border-left:none;width:454pt'><?php echo KSFunctions::stringView($this->order->costs['total_cost']); ?> </td> </tr> <tr height=20 style='mso-height-source:userset;height:15.0pt'> <td colspan=5 height=20 class=xl33 style='height:15.0pt'> </td> <td colspan=5 class=xl34 width=192 style='width:144pt'> </td> <td colspan=2 rowspan=2 class=xl35><?php echo JText::_('KSM_CART_RECEIPT_SUM'); ?> </td> <td colspan=10 rowspan=2 class=xl36><?php echo $this->order->costs['total_cost_val']; ?> </td> </tr>
class="mainTable"> <tr> <td class="nobr">Приложение (паспорта, сертификаты, и т.п.)</td> <td width="80%" class=underlined> </td> <td>листах</td> </tr> </table> <table width="100%" border="0" cellpadding=0 cellspacing=0 class="mainTable"> <tr> <td class=leftAlign>Всего отпущено на сумму</td> </tr> <tr> <td class="underlined leftAlign"><b><?php echo KSFunctions::stringView($this->order->cost); ?> , <?php echo $this->params->get('printforms_nds') != 0 ? 'в т.ч. НДС' : 'без налога (НДС)'; ?> </b></td> </tr> <tr> <td class=separatorCell> </td> </tr> </table> <table width="100%" border="0" cellpadding=0 cellspacing=0 class="mainTable"> <tr> <td class="leftAlign nobr">Отпуск разрешил</td>
function saveProperty($data) { $this->onExecuteBefore('saveProperty', array(&$data)); $data['alias'] = KSFunctions::CheckAlias($data['alias'], $data['id']); $data['alias'] = $data['alias'] == '' ? KSFunctions::GenAlias($data['title']) : $data['alias']; $data['published'] = isset($data['published']) ? $data['published'] : 0; $data['edit_price'] = isset($data['edit_price']) ? $data['edit_price'] : 0; $table = $this->getTable('properties'); if (empty($data['id'])) { $query = $this->_db->getQuery(true); $query->update('#__ksenmart_properties')->set('ordering=ordering+1'); $this->_db->setQuery($query); $this->_db->query(); } if (!$table->bindCheckStore($data)) { $this->setError($table->getError()); return false; } $id = $table->id; $in = array(); foreach ($data['categories'] as $v) { $table = $this->getTable('PropertiesCategories'); $d = array('category_id' => $v, 'property_id' => $id); if ($table->load($d)) { $d['id'] = $table->id; } if (!$table->bindCheckStore($d)) { $this->setError($table->getError()); return false; } $in[] = $table->id; } $query = $this->_db->getQuery(true); $query->delete('#__ksenmart_product_categories_properties')->where('property_id=' . $id); if (count($in)) { $query->where('id not in (' . implode(', ', $in) . ')'); } $this->_db->setQuery($query); $this->_db->query(); $in = array(); foreach ($data['values'] as $k => $v) { $v['property_id'] = $id; $table = $this->getTable('PropertiesValues'); if ($k > 0) { $v['id'] = $k; } $v['alias'] = KSFunctions::CheckAlias($v['alias'], $v['id']); $v['alias'] = $v['alias'] == '' ? KSFunctions::GenAlias($v['title']) : $v['alias']; if (!$table->bindCheckStore($v)) { $this->setError($table->getError()); return false; } $in[] = $table->id; } $query = $this->_db->getQuery(true); $query->delete('#__ksenmart_property_values')->where('property_id=' . $id); if (count($in)) { $query->where('id not in (' . implode(',', $in) . ')'); } $this->_db->setQuery($query); $this->_db->query(); $query = $this->_db->getQuery(true); $query->delete('#__ksenmart_product_properties_values')->where('property_id=' . $id); if (count($in)) { $query->where('value_id not in (' . implode(',', $in) . ')'); } $this->_db->setQuery($query); $this->_db->query(); $on_close = 'window.parent.PropertiesList.refreshList();'; $return = array('id' => $id, 'on_close' => $on_close); $this->onExecuteAfter('saveProperty', array(&$return)); return $return; }
<td class="order_name name"> <div class="img"> <img class="min_img" rel="<?php echo $this->item->id; ?> " src="<?php echo $this->item->user->small_img; ?> " title="<?php echo $this->item->user->name; ?> "> </div> <?php echo $this->item->customer_info; ?> </td> <td class="order_cost" align="center"><?php echo KSMPrice::showPriceWithTransform($this->item->cost); ?> </td> <td class="order_date" align="center"><?php echo KSFunctions::formatDate($this->item->date_add); ?> </td> <td class="order_status" align="center"><?php echo $this->item->status_name; ?> </td> </tr>
public static function stringView($amount) { //разделить сумма на разряды: единицы, тысячи, миллионы, миллиарды (больше миллиардов не проверять :) ) $n = round($amount, 2); $billions = floor($n / 1000000000); $millions = floor(($n - $billions * 1000000000) / 1000000); $grands = floor(($n - $billions * 1000000000 - $millions * 1000000) / 1000); $roubles = floor($n - $billions * 1000000000 - $millions * 1000000 - $grands * 1000); //$n % 1000; //копейки $kop = round($n * 100 - round(floor($n) * 100)); //var_dump(array($n,$billions,$millions,$grands,$roubles,$kop)); if ($kop < 10) { $kop = "0" . (string) $kop; } $s = ""; if ($billions > 0) { $t = "ов"; $temp = $billions % 10; if (floor($billions % 100 / 10) != 1) { if ($temp == 1) { $t = ""; } else { if ($temp >= 2 && $temp <= 4) { $t = "а"; } } } $s .= KSFunctions::number2string($billions, 1) . " миллиард{$t} "; } if ($millions > 0) { $t = "ов"; $temp = $millions % 10; if (floor($millions % 100 / 10) != 1) { if ($temp == 1) { $t = ""; } else { if ($temp >= 2 && $temp <= 4) { $t = "а"; } } } $s .= KSFunctions::number2string($millions, 1) . " миллион{$t} "; } if ($grands > 0) { $t = ""; $temp = $grands % 10; if (floor($grands % 100 / 10) != 1) { if ($temp == 1) { $t = "а"; } else { if ($temp >= 2 && $temp <= 4) { $t = "и"; } } } $s .= KSFunctions::number2string($grands, 0) . " тысяч{$t} "; } if ($roubles > 0) { $rub = "ей"; $temp = $roubles % 10; if (floor($roubles % 100 / 10) != 1) { if ($temp == 1) { $rub = "ь"; } else { if ($temp >= 2 && $temp <= 4) { $rub = "я"; } } } $s .= KSFunctions::number2string($roubles, 1) . " рубл{$rub} "; } $kp = "ек"; $temp = $kop % 10; if (floor($kop % 100 / 10) != 1) { if ($temp == 1) { $kp = "йка"; } else { if ($temp >= 2 && $temp <= 4) { $kp = "йки"; } } } $s .= "{$kop} копе{$kp}"; /* //теперь сделать первую букву заглавной if ($roubles>0 || $grands>0 || $millions>0 || $billions>0) { $cnt=0; while(substr($s, $cnt, 1)==" ") $cnt++; $s = substr($s, $cnt, 1); $s[$cnt] = chr( ord($s[$cnt])- 32 ); } */ return $s; }