Commit 48680c56 authored by Яков's avatar Яков
Browse files

first

parents
<?php
/**
* review actions.
*
* @package sf
* @subpackage review
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class reviewActions extends sfActions
{
public function executeIndex(sfWebRequest $request)
{
$this->review_form = new wwwReviewForm();
if($request->isMethod('post')){
$params = $request->getParameter($this->review_form->getName());
$params['lang'] = $this->getUser()->getCulture();
$params['phone'] = preg_replace("/[^0-9]/", '', $params['phone']);
$this->review_form->bind($params);
$valid = $this->review_form->isValid();
if($valid){
$this->review_form->save();
}
echo $this->getPartial('review/review_form', array('review_form' => $this->review_form, 'valid' => $valid));
return sfView::NONE;
}else
{
$this->culture = $this->getUser()->getCulture();
$reviews = Doctrine_Query::create()
->select("name, body, file, lang, is_activated, created_at")
->from("Review")
->where("lang = ?", $this->getUser()->getCulture())
->andWhere("is_activated = 1")
->orderBy("created_at ASC")
->fetchArray();
$this->setLayout('layoutPage');
$count_reviews = count($reviews);
if ($request->getParameter('tag_id'))
{
$this->tag_id = $request->getParameter('tag_id');
}else
{
$this->tag_id = 'all';
}
if ($request->getParameter('tag_id') && $request->getParameter('tag_id') != 'all' && $count_reviews >= sfConfig::get('app_view_count_tag'))
{
unset($reviews);
$reviews_tags = Doctrine_Query::create()
->select('')
->from('Tag t')
->where('t.id = ?', $request->getParameter('tag_id'))
->leftJoin('t.ReviewTags rt WITH t.id = rt.tag_id')
->leftJoin('rt.Review r WITH rt.review_id = r.id')
->fetchArray();
$reviews = array();
foreach ($reviews_tags[0]['ReviewTags'] as $review)
{
$reviews[] = $review['Review'];
}
$this->forward404Unless($reviews);
}
$limit = ceil(count($reviews) / 3);
$counter = 0;
$arrKey = 0;
$tags = Doctrine_Query::create()
->select('t.*, rt.*, tt.*')
->from('Tag t')
->leftJoin('t.Translation tt WITH tt.lang = ?', $this->culture)
->leftJoin('t.ReviewTags rt WITH rt.tag_id = t.id')
->fetchArray();
$this->reviews_tags = array();
foreach ($tags as $tag)
{
if (count($tag['ReviewTags']) > 0 )
{
$this->reviews_tags[] = $tag;
}
}
$group_reviews = array();
foreach ($reviews as $review)
{
if ($counter == $limit)
{
$counter = 0;
$arrKey++;
}
$group_reviews[$arrKey][] = $review;
$counter++;
}
$this->reviews = $group_reviews;
if ($request->getParameter('tag_id') && $request->getParameter('ajax'))
{
sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
echo include_partial('review/review_index', array('reviews' => $this->reviews, 'die' => true));
}
}
}
}
<?php
class reviewComponents extends sfComponents
{
public function executeReview(sfWebRequest $request)
{
$this->culture = $this->getUser()->getCulture();
if ($request->getParameter('alias')) {
$productTags = Doctrine::getTable('Product')->findOneByAlias($request->getParameter('alias'))->getProductTags();
$idsTags = array();
foreach ($productTags as $tag) {
$idsTags[] = $tag->getTagId();
}
if (count($idsTags) > 0) {
$q = Doctrine_Query::create()
->select("r.name, r.body, r.file, r.lang, r.is_activated, r.created_at")
->from("Review r")
->where("r.is_activated = 1")
->andWhere("r.lang = ?", $this->getUser()->getCulture())
->orderBy("r.created_at DESC")
->innerJoin('r.ReviewTags rt')
->andWhereIn('rt.tag_id', $idsTags);
if (isset($this->limit) && $this->limit) {
$q->limit($this->limit);
}
$this->reviews = $q->fetchArray();
} else {
$q = array();
}
}else
{
$this->reviews = Doctrine_Query::create()
->select("r.name, r.body, r.file, r.lang, r.is_activated, r.created_at")
->from("Review r")
->where("r.is_activated = 1")
->andWhere("r.lang = ?", $this->getUser()->getCulture())
->orderBy("r.created_at DESC")
->fetchArray();
}
}
}
\ No newline at end of file
<?php
if(count($reviews) > 0){
$module_action = $sf_request->getParameter('module') . '_' . $sf_request->getParameter('action');
if($module_action == 'product_show') { ?>
<div class="product_section product__reviews background_lightgrey">
<div class="caption">
<a href="/<?php echo $culture; ?>/review/?tag_id=<?php echo $tag_id; ?>" class="green_link"><?php echo __('Отзывы клиентов'); ?></a>
</div>
<div class="max_width">
<?php } elseif($module_action == 'main_index') { ?>
<tr>
<td>
<div class="lending_area_4 lending_area_review background_lightgrey">
<div style="text-align: center" class="caption">
<a class="green_link" href="/<?php echo $culture; ?>/review/"><?php echo __('Отзывы клиентов'); ?></a>
</div>
<i class="br20"></i>
<?php } ?>
<div class="reviews_slideshow slideshow_wrap mobile_hide">
<div class="slideshow"
data-cycle-fx="scrollHorz"
data-cycle-swipe="true"
data-cycle-swipe-fx="scrollHorz"
data-cycle-slides="> .reviews_slideshow__item"
data-cycle-timeout="0"
data-cycle-prev=".for_reviews.slideshow_arrow.left"
data-cycle-next=".for_reviews.slideshow_arrow.right"
data-cycle-log="true"
data-cycle-pager=".for_reviews.cycle-pager"
data-cycle-pager-template="<li></li>">
<?php foreach ($reviews as $review) { ?>
<div class="reviews_slideshow__item">
<div class="reviews_slideshow__item_review">
<table class="to_div" cellspacing="0" cellpadding="0" width="100%">
<tbody align="left" valign="top">
<tr>
<td rowspan="2" class="reviews_slideshow__item_review_img">
<div class="reviews_item__image_slider" style="background-image: url(/u/i/<?php echo $review['file'] ?>);" ></div>
</td>
<td></td>
<td class="reviews_slideshow__item_review_text" <?php echo (strlen($review['file']) > 3 ? 'style="width: 70%"' : '') ?> >
<?php echo $review['body'] ?>
</td>
</tr>
<tr>
<td></td>
<td class="reviews_slideshow__item_author">
<?php echo $review['name'] ?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php } ?>
</div>
<div class="for_reviews slideshow_arrow left mobile_hide"></div>
<div class="for_reviews slideshow_arrow right mobile_hide"></div>
<ul class="for_reviews cycle-pager"></ul>
</div>
<div class="reviews_slideshow slideshow_wrap mobile">
<div class="slideshow"
data-cycle-fx="scrollHorz"
data-cycle-swipe="true"
data-cycle-swipe-fx="scrollHorz"
data-cycle-slides="> .reviews_slideshow__item"
data-cycle-timeout="0"
data-cycle-prev=".for_reviews.slideshow_arrow.left"
data-cycle-next=".for_reviews.slideshow_arrow.right"
data-cycle-log="true"
data-cycle-auto-height="container"
data-cycle-pager=".for_reviews.cycle-pager"
data-cycle-pager-template="<li></li>">
<?php foreach ($reviews as $review) { ?>
<div class="reviews_slideshow__item">
<div class="reviews_slideshow__item_review">
<table class="to_div" cellspacing="0" cellpadding="0" width="100%">
<tbody align="left" valign="top">
<tr>
<td rowspan="2" class="reviews_slideshow__item_review_img">
<div class="reviews_item__image_slider" style="background-image: url(/u/i/<?php echo $review['file'] ?>);" ></div>
</td>
<td></td>
<td class="reviews_slideshow__item_review_text" <?php echo (strlen($review['file']) > 3 ? 'style="width: 70%"' : '') ?> >
<?php echo $review['body'] ?>
</td>
</tr>
<tr>
<td></td>
<td class="reviews_slideshow__item_author">
<?php echo $review['name'] ?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php } ?>
</div>
<div class="for_reviews slideshow_arrow left mobile_hide"></div>
<div class="for_reviews slideshow_arrow right mobile_hide"></div>
<ul class="for_reviews cycle-pager"></ul>
</div>
<script type="text/javascript">
if(!$('.mobile').is(":visible")) {
$('.reviews_slideshow.mobile_hide .slideshow').cycle();
} else {
$('.reviews_slideshow.mobile .slideshow').cycle();
}
</script>
<?php if($module_action == 'product_show') { ?>
</div>
</div>
<?php } elseif($module_action == 'main_index') { ?>
</div>
</td>
</tr>
<?php }
}
?>
\ No newline at end of file
<?php
if(isset($valid) && $valid){
echo '<div class="reviews_form_success">' . __('Отзыв отправлен') . '!</div>';
}else{
$culture = $sf_user->getCulture();
?>
<form action="<?php echo url_for('@review'); ?>" method="post" onsubmit="review.submit($(this)); return false;">
<?php
echo $review_form->renderGlobalErrors();
echo $review_form->renderHiddenFields();
?>
<table class="reviews_form__table to_div" cellspacing="0" cellpadding="0" width="100%">
<tbody valign="top" align="left">
<tr>
<td class="reviews_form__title" colspan="3" align="center"><?php echo __('Оставьте свой отзыв');?></td>
</tr>
<tr>
<td width="50%" height="1">
<div class="callback_form__inp_wrap">
<input name="review[name]" type="text" class="form_type_1__input validate_it" placeholder="Имя" onkeyup="form_validator.check($(this))" data-check-rule="noempty" autocomplete="off" required>
</div>
</td>
<td rowspan="2" colspan="2">
<textarea rows="6" cols="70" required="1" style="resize:vertical;min-height:100px;" class="reviews_form_txa_msg validate_it" onkeyup="form_validator.check($(this))" data-check-rule="noempty" placeholder="Текст отзыва" autocomplete="off" name="review[body]" id="review_body"></textarea>
<div class="mobile_hide">
<?php echo $review_form['file']->render() . $review_form['file']->renderError(); ?>
</div>
</td>
</tr>
<tr>
<td valign="top">
<div class="callback_form__inp_wrap">
<input name="review[phone]" type="text" class="form_type_1__input validate_it" placeholder="Телефон" onkeyup="form_validator.check($(this))" data-check-rule="phone" autocomplete="off" required>
</div>
<div class="mobile">
<?php echo $review_form['file']->render() . $review_form['file']->renderError(); ?>
</div>
</td>
</tr>
<tr>
<td colspan="2" valign="middle">
<i class="br20"></i>
<div class="callback_form__checkbox">
<label class="checkbox">
<input type="checkbox" name="review[is_agree]" class="not_custom validater validate_it" onchange="form_validator.check($(this))" data-check-rule="checked" autocomplete="off" required >
<span class="checkbox_span"></span>
<span class="checkbox_text"><?php echo __('Я принимаю условия')?> <a href="<?php echo '/' . $culture . '/terms-of-use/' ?>" target="_blank"><?php echo __('пользовательского соглашения') ?></a><?php echo __(' и ') ?> <a href="<?php echo '/' . $culture . '/privacy-policy/' ?>" target="_blank"><?php echo __('политики конфиденциальности') ?></a></span>
</label>
</div>
</td>
<td width="1" valign="middle" class="align_center">
<i class="br20"></i>
<input type="submit" class="btn_all green_btn send btn_disabled" value="<?php echo __('Отправить');?>" disabled>
</td>
</tr>
</tbody>
</table>
</form>
<?php
}
?>
\ No newline at end of file
<?php function review_render($review) {
echo '<div class="reviews_item" style="position: relative; width: 100%;" ' . ($review['file'] ? 'onclick="review.showFile(\'/u/i/' . Page::replaceImageSize($review['file'], 'XL') . '\' , $(this));" style="cursor: pointer;"' : '') . '>';
if ($review['file']) {
$filename = Page::replaceImageSize($review['file'], 'M');
$file = sfConfig::get('sf_upload_dir') . '/i/' . $filename;
if (file_exists($file)) {
echo '<img width="100%" class="reviews_item__file" src="/u/i/' . $filename . '" />';
echo '<i class="br10"></i>';
}
}
echo '<div class="reviews_item__text">' . ($review['file'] && strlen($review['body']) > 335 ? substr($review['body'], 0, 335).'...' : $review['body']) . '</div>';
echo '<div class="reviews_item__text_for_popup">' . $review['body'] . '</div>';
echo '<div class="reviews_item__author">' . $review['name'] . '</div>';
echo '</div>';
echo '<i class="br10"></i>';
return false;
} ?>
<table class="to_div" cellpadding="0" cellspacing="0" width="100%">
<tbody align="left" valign="top">
<td width="32%">
<?php
if (count($reviews[0]) > 0) {
foreach ($reviews[0] as $review) {
review_render($review);
}
}
?>
</td>
<td width="2%"></td>
<td width="32%">
<?php
if (count($reviews[1]) > 0) {
foreach ($reviews[1] as $review) {
review_render($review);
}
}
?>
</td>
<td width="2%"></td>
<td width="32%">
<?php
if (count($reviews[0]) > 0) {
foreach ($reviews[2] as $review) {
review_render($review);
}
}
?>
</td>
</tbody>
</table>
<?php
if ($die)
die();
\ No newline at end of file
<?php
slot('title', __('Отзывы'));
use_javascript('masonry.pkgd.min.js');
?>
<div class="content__main">
<?php
include_partial('main/breadcrumbs');
echo '<h1 class="content_title">' . __('Отзывы') . '</h1>';
?>
<div class="reviews_wrap">
<div class="max_width">
<div class="reviews" style="visibility: visible">
<div class="reviews_item_gutter" style="width: 100%; text-align: center">
<?php
if (count($reviews) >= sfConfig::get('app_view_count_tag')) {
echo '<a data-tag-id="all" class="reviews_show_tag green_link active ' . (!$tag_id || $tag_id == 'all' ? 'active' : '') . '">Все</a>';
foreach ($reviews_tags as $tag) {
echo '<a class="reviews_show_tag green_link ' . ($tag_id == $tag['id'] ? 'active' : '') . '" data-tag-id="' . $tag['id'] . '">' . $tag['Translation'][$culture]['title'] . '</a>';
}
}
?>
</div>
<i class="br20 mobile_hide"></i>
<div class="reviews_index">
<?php
include_partial('review/review_index', array('reviews' => $reviews));
?>
</div>
</div>
</div>
</div>
</div>
<div class="reviews_form_wrap">
<div class="max_width">
<div class="reviews_form">
<?php
include_partial('review/review_form', array('review_form' => $review_form));
?>
</div>
</div>
</div>
<script type="text/javascript">
var culture = '<?php echo $culture ?>';
$('body').on('click', '.reviews_show_tag', function () {
_this = this;
$.ajax({
url: '/' + culture + '/review/',
type: 'get',
data: {tag_id : $(this).attr('data-tag-id'), ajax : 1},
success: function (html) {
$('.reviews_show_tag').removeClass('active');
$(_this).addClass('active');
$('.reviews_index').html(html);
setUrlHash('?tag_id='+$(_this).attr('data-tag-id'));
}
});
//alert($(this).attr('data-tag-id'));
});
var review = {
submit: function (form) {
$.post('<?php echo url_for('@review');?>', $(form).serialize(), function (html) {
$('.reviews_form').html(html).find('input[type="checkbox"]').customizeForm();
imgUpload.init();
});
},
showFile: function (src, _this) {
var text = _this.find('.reviews_item__text_for_popup').text();
var author = _this.find('.reviews_item__author').text();
// console.log(text);
// return false;
$('body')
.append('<div class="review_file_overlay_review" onclick="review.closeFile();">'
+ '<div class="review_file_overlay__item_review">'
+ '<div class="review_file_overlay__item_review_border"> '
+ '<div class="review_file_overlay__item__img__review" style="background-image: url(' + src + ');" ></div>'
+ '<div class="review_file_overlay__item__text"> '
+ '<div class="review_file_overlay__item__text_table">'
+ '<div class="review_file_overlay__item__text__review">' + text + '</div> '
+ '<div class="review_file_overlay__item__author__table"> '
+ '<div class="review_file_overlay__item__author__review">' + author + '</div> '
+ '</div></div></div></div></div><div class="review_file_overlay__close" onclick="review.closeFile();"></div></div>')
.addClass('scroll_hidden');
},
closeFile: function () {
var body = $('body');
$('.review_file_overlay_review').remove();
if(!body.hasClass('search_active')){
body.removeClass('scroll_hidden');
}
}
};
$(document).ready(function () {
var reviews = $('.reviews');
// reviews.on( 'layoutComplete', function( event, items ) {
// reviews.css('visibility', 'visible')
// });
// reviews.masonry({
// columnWidth: '.reviews_item',
// itemSelector: '.reviews_item',
// gutter: '.reviews_item_gutter',
// originLeft: true,
// percentPosition: true
// });
imgUpload.init();
});
</script>
\ No newline at end of file
<?php
/**
* search actions.
*
* @package sf
* @subpackage search
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class searchActions extends sfActions
{
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeSearch(sfWebRequest $request)
{
$this->res = array();
$this->rs = array();
$articles = $videos = $cats = $products = array();
$this->query = $this->getRequestParameter('q');
$this->page = $this->getRequestParameter('p', 1);
$this->total_found = 0;
$options = array(
'limit' => 100,
'offset' => ($this->page - 1) * 10,
'weights' => array(100, 1),
'sort' => sfSphinxClient::SPH_SORT_EXTENDED,
'sortby' => '@weight DESC',
);
if (!empty($this->query))
{
$culture = $this->getUser()->getCulture();
$this->sphinx = new sfSphinxClient($options);
$this->res = $this->sphinx->Query($this->query, 'stone_' . $culture);
if($this->res['total_found'] > 0) {
foreach ($this->res['matches'] as $matches) {
if ($matches['attrs']['row_type'] == 1) {
$articles[] = ($matches['id'] - 1) / 10;
} elseif ($matches['attrs']['row_type'] == 2) {
$videos[] = ($matches['id'] - 2) / 10;
} elseif ($matches['attrs']['row_type'] == 3) {
$cats[] = ($matches['id'] - 3) / 10;
} elseif ($matches['attrs']['row_type'] == 4) {
$products[] = ($matches['id'] - 4) / 10;
}
}
if(count($articles) > 0) {
$q = Doctrine_Query::create()
->select("a.id, a.alias, a.cover, a.created_at, t.*")
->from("Article a")
->innerJoin("a.Translation t")
->where("t.lang = ?", $this->getUser()->getCulture())
->andWhere("t.available = 1")
->andWhereIn("a.id", $articles)
->orderBy("a.created_at DESC")
->fetchArray();
if(count($q) > 0){
foreach($q as $r)
{
$this->rs[0]['article'][$r['id']] = array(
'title' => $r['Translation'][$culture]['title'],
'link' => 'article/show?alias=' . $r['alias'],
'body' => strip_tags($r['Translation'][$culture]['body']),
);
$this->total_found++;
}
}
}
if(count($videos) > 0) {
$q = Doctrine_Query::create()
->select("v.*, t.*")
->from("Video v")
->innerJoin("v.Translation t")
->where("t.lang = ?", $culture)
->andWhere("t.available = 1")
->andWhereIn("v.id", $videos)
->fetchArray();
if(count($q) > 0){
foreach($q as $r)
{
$code = Video::getYoutubeCode($r['vid']);
if($code){
$this->rs[0]['video'][$r['id']] = array(
'title' => $r['Translation'][$culture]['title'],
'link' => 'https://www.youtube.com/embed/' . $code . '?ecver=2'
);
$this->total_found++;
}
}
}
}
if(count($cats) > 0) {
$q = Doctrine_Query::create()
->select("c.alias, c.photo, c.parent_id, t.*")
->from("Cat c")
->innerJoin("c.Translation t")
->andWhereIn("c.id", $cats)
->fetchArray();
if(count($q) > 0){
foreach($q as $r)
{
$this->rs[0]['cat'][$r['id']] = array(
'title' => $r['Translation'][$culture]['title'],
'link' => 'catalog/show?alias=' . $r['alias']
);
$this->total_found++;
}
}
}
if(count($products) > 0) {
$q = Doctrine_Query::create()
->select("p.id, p.alias, p.product_img, p.is_detail, p.offer_count, t.id, t.lang, t.title")
->from("Product p")
->leftJoin("p.Translation t")
->whereIn("p.id", $products)
->andWhere("p.offer_count > 0")
->fetchArray();
if(count($q) > 0){
foreach($q as $r)
{
$this->rs[0]['product'][$r['id']] = array(
'title' => $r['Translation'][$culture]['title'],
'link' => 'product/show?alias=' . $r['alias']
);
$this->total_found++;
}
}
}
}
}
}
}
<?php
if(!$sf_request->isXmlHttpRequest()){
slot('title', __('Поиск'));
include_partial('main/breadcrumbs');
echo '<h1 class="content_title">' . __('Поиск') . '</h1>';
echo '<div class="search_wrap">';
echo '<div class="search_line">
<form action="' . url_for('@search') . '" method="get">
<input class="search_line__inp" type="text" name="q" value="' . (isset($_GET['q']) ? htmlspecialchars($_GET['q']) : '') . '" placeholder="' . __('Поиск') . '" />
</form>
</div>';
echo '<div class="search_result">';
}
if (!empty($query)) {
//print_r($total_found);
if ($total_found > 0) {
$crs = $rs->getRaw(0);
if (isset($crs['product']) && count($crs['product']) > 0) {
foreach ($crs['product'] as $product) {
echo '<div class="search_result__item">';
echo '<div class="search_result__item__cat">' . __('Товар') . '</div>';
echo '<a href="' . url_for($product['link']) . '" class="search_result__item__link search_result__item__link_product">' . $product['title'] . '</a>';
echo '</div>';
}
}
if (isset($crs['cat']) && count($crs['cat']) > 0) {
foreach ($crs['cat'] as $cat) {
echo '<div class="search_result__item">';
echo '<div class="search_result__item__cat">' . __('Категории') . '</div>';
echo '<a href="' . url_for($cat['link']) . '" class="search_result__item__link search_result__item__link_cat">' . $cat['title'] . '</a>';
echo '</div>';
}
}
if (isset($crs['article']) && count($crs['article']) > 0) {
foreach ($crs['article'] as $article) {
echo '<div class="search_result__item">';
echo '<div class="search_result__item__cat">' . __('Статья') . '</div>';
echo '<a href="' . url_for($article['link']) . '" class="search_result__item__link search_result__item__link_article">' . $article['title'] . '</a>';
echo '</div>';
}
}
if (isset($crs['video']) && count($crs['video']) > 0) {
foreach ($crs['video'] as $video) {
echo '<div class="search_result__item">';
echo '<div class="search_result__item__cat">' . __('Видео') . '</div>';
echo '<a data-src="' . $video['link'] . '" class="search_result__item__link search_result__item__link_video" onclick="video.open(this);">' . $video['title'] . '</a>';
echo '</div>';
}
}
} else {
echo '<div class="i">' . __('Ничего не найдено') . '</div>';
}
} else {
echo '<div class="i">' . __('Пустой поисковый запрос') . '</div>';
}
if(!$sf_request->isXmlHttpRequest()){
echo '</div>';
echo '</div>';
}
?>
\ No newline at end of file
<?php
class userActions extends sfActions
{
private $profile = null;
public function executeGen_xls($request)
{
$client_order = new ClientOrder();
$client_order->setUserId(1);
$client_order->setOrderStatusId(1);
$client_order->setComment('tmp');
$client_order->save();
if($request->hasParameter('json'))
{
$ids = array();
$order_items = json_decode($request->getParameter('json'), true);
foreach($order_items as $item)
{
if(isset($item['code']))
{
$product = Doctrine::getTable('Product')->findOneByProductCode($item['code']);
if($product)
{
$ids[$product->getId()] = $item['count'];
}
}
}
}
else
{
$ids = $request->getParameter('id');
}
if(is_array($ids))
{
foreach($ids as $code => $count)
{
$product = $request->hasParameter('code') ? Doctrine::getTable('Product')->findOneByProductCode($code) : Doctrine::getTable('Product')->find($code);
if($product)
{
$order_item = new OrderItem();
$order_item->setProductId($product->getId());
$order_item->setClientOrderId($client_order->getId());
$order_item->setProductCount($count);
$order_item->save();
}
}
}
if($request->hasParameter('json'))
{
$email_order = sfConfig::get('app_email_order', false);
if($email_order)
{
$tempnam = tempnam('/tmp', 'ie');
$objWriter = PHPExcel_IOFactory::createWriter($client_order->getExcel(), 'Excel5');
$objWriter->save($tempnam);
$second_level = implode('.', array_reverse(array_slice(array_reverse(explode('.', $request->getHost())), 0, 2)));
$order_user = $client_order->getUser();
$message = Swift_Message::newInstance()
->setFrom('app@' . $second_level)
->setTo($email_order)
->setSubject('Новый быстрый заказ от ' . $request->getParameter('phone'))
;
$message->setContentType('text/html; charset=UTF-8');
$body_lines = array();
if($request->getParameter('comment'))
{
$body_lines[] = '<b>Комментарий к заказу</b><br /><i>' . $request->getParameter('comment') . '</i>';
}
$body = file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_header.php') . implode('<br />', $body_lines) . file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_footer.php');
$message->setBody($body);
$attachment = Swift_Attachment::newInstance()
->setFilename('Быстрый заказ.xls')
->setContentType('application/vnd.ms-excel')
->setBody(file_get_contents($tempnam))
;
$message->attach($attachment);
//$this->getMailer()->send($message);
}
echo json_encode(array(
'state' => 'success',
'text' => 'Спасибо! Ваш заказ принят в обработку.',
));
}
else
{
$objWriter = PHPExcel_IOFactory::createWriter($client_order->getExcel(true), 'Excel5');
$objWriter->save('php://output');
$this->getResponse()->setHttpHeader('Content-type', 'application/octet-stream');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="Заказ.xls"');
}
$client_order->delete();
return sfView::NONE;
}
public function executeGet_profile($request)
{
$this->setLayout(false);
}
public function returnProfile($values, $user)
{
if(!$this->profile)
{
$profile = array();
$manager = $user->getManager();
$user_id = $user->getId();
$orders = array();
$user_order = Doctrine_Query::create()
->select("co.*, oi.*, os.*, p.*, pp.*, psc.*")
->from("ClientOrder co")
->leftJoin("co.OrderStatus os")
->innerJoin("co.OrderItems oi")
->leftJoin("oi.Product p")
->leftJoin("p.ProductPrice pp")
->innerJoin("p.ProductStockCount psc")
->where("co.user_id = ?", $user_id)
->andWhere("pp.price_type_id = 1")
->orderBy("co.created_at DESC")
->fetchArray()
;
foreach ($user_order as $order)
{
$goods = array();
$price = 0;
$count = 0;
foreach($order['OrderItems'] as $order_item)
{
$order_item_price = 0;
foreach($order_item['Product']['ProductPrice'] as $product_price)
{
$order_item_price = $product_price['value'];
}
foreach($order_item['Product']['ProductStockCount'] as $product_stock_count)
{
$order_item_stock_count = $product_stock_count['value'];
}
$goods[] = array(
'product_id' => $order_item['Product']['product_code'],
'product' => $order_item['Product']['title'],
'title' => $order_item['Product']['title'],
'count' => $order_item['product_count'],
'price' => ($user->getCurrentDiscount() > 0 ? round($order_item_price - ($order_item_price * $user->getCurrentDiscount() / 100), 2) : $order_item_price),
'code' => $order_item['Product']['product_code'],
'stock_count' => $order_item_stock_count,
'min_order' => $order_item['Product']['min_order'],
);
$price += $order_item_price * $order_item['product_count'];
$count += $order_item['product_count'];
}
$orders[] = array(
'id' => $order['id'],
'count' => $count,
'date' => ProjectUlils::rusDate($order['created_at'], false),
'price' => ($user->getCurrentDiscount() > 0 ? round($price - ($price * $user->getCurrentDiscount() / 100), 2) : $price),
'status' => $order['OrderStatus']['title'],
'goods' => $goods
);
}
$user_corr = Doctrine_Query::create()
->select("c.*, uf.*, ut.*")
->from("Correspondence c")
->leftJoin("c.UserFrom uf")
->leftJoin("c.UserTo ut")
->where("c.user_id_from = ?", $user_id)
->orWhere("c.user_id_to = ?", $user_id)
->orderBy("c.created_at", "ASC")
->fetchArray()
;
$correspondence = array();
foreach ($user_corr as $message)
{
if ($message['status'] == 'out')
{
$correspondence[] = array(
'name' => $message['UserFrom']['fname'] . ' ' . $message['UserFrom']['iname'],
'text' => $message['body'],
'date' => ProjectUlils::rusDate($message['created_at'], false, true),
'status' => 'in'
);
}
elseif ($message['status'] == 'in')
{
$correspondence[] = array(
'name' => $message['UserFrom']['organization'],
'text' => $message['body'],
'date' => ProjectUlils::rusDate($message['created_at'], false, true),
'status' => 'out'
);
}
}
$user_debt = Doctrine_Query::create()
->select("d.debt_sum, d.deadline")
->from("Debt d")
->where("d.user_id = ?", $user_id)
->fetchArray()
;
$debt_detail = array();
$overdue = 0;
foreach ($user_debt as $debt)
{
if ($debt['deadline'] < date('Y-m-d'))
{
$overdue += $debt['debt_sum'];
}
$debt_detail[] = array(
'debt_sum' => $debt['debt_sum'],
'deadline' => $debt['deadline'],
);
}
// $banners = array();
// $banners_q = Doctrine_Query::create()
// ->select("b.*")
// ->from("Banner b")
// ->where("b.is_activated = 1")
// ->fetchArray()
// ;
// foreach ($banners_q as $banner)
// {
// if(file_exists(sfConfig::get('sf_upload_dir') . '/' . $banner['file']))
// {
// $banners[] = array(
// 'cat_id' => $banner['cat_id']
// 'img' => base64_encode(file_get_contents(sfConfig::get('sf_upload_dir') . '/' . $banner['file']))
// );
// }
// }
$profile = array(
'auth' => 'true',
'username' => $values['user']['username'],
'organization' => $values['user']['organization'],
'phone' => $values['user']['phone_number'],
'city' => $values['user']['city'],
'address' => $values['user']['address'],
'email' => $values['user']['email'],
'orders_sum_last_month' => (isset($values['user']['orders_sum_last_month']) && $values['user']['orders_sum_last_month'] ? $values['user']['orders_sum_last_month'] : '0'),
'orders_sum_current' => (isset($values['user']['orders_sum_current']) && $values['user']['orders_sum_current'] ? $values['user']['orders_sum_current'] : '0'),
'sum_limit' => (isset($values['user']['limit_by_sum']) && $values['user']['limit_by_sum'] ? $values['user']['limit_by_sum'] : '0'),
'sum_discount' => str_replace(',', '.', isset($values['user']['current_discount']) && $values['user']['current_discount'] ? $values['user']['current_discount']: '0'),
'debt' => (isset($values['user']['current_debt']) && $values['user']['current_debt'] ? $values['user']['current_debt'] : '0'),
'manager' => $manager ? array(
'name' => $manager->getFname() . ' ' . $manager->getIname(),
'phone' => $manager->getPhoneNumber() ? $manager->getPhoneNumber() : 'отдел продаж',
) : 'null',
'debt_detail' => (empty($debt_detail)? 'null' : $debt_detail),
'overdue_payment' => $overdue,
'orders' => $orders,
'feedback' => $correspondence,
'cat_images_idx' => ($user->getCatIndx() == '') ? 'null' : unserialize($user->getCatIndx())
);
$this->profile = $profile;
}
return $this->profile;
}
public function executeFeedback($request)
{
if($request->hasParameter('text') && trim($request->getParameter('text')) != '')
{
$user = $this->getUser()->getAccount();
$feedback = new Correspondence();
$feedback->setUserIdFrom($user->getId());
if($user->getManagerId())
{
$feedback->setUserIdTo($user->getManagerId());
}
else
{
$feedback->setUserIdTo(1);
}
$feedback->setStatus('in');
$feedback->setBody(trim($request->getParameter('text')));
$second_level = implode('.', array_reverse(array_slice(array_reverse(explode('.', $request->getHost())), 0, 2)));
$email_order = sfConfig::get('app_email_order', false);
if($email_order)
{
$message = Swift_Message::newInstance()
->setFrom('app@' . $second_level)
->setTo($email_order)
->setSubject('Новое сообщение из формы обратной связи от ' . $user->getOrganization() . ' ИНН ' . $user->getUsername())
;
$message->setContentType('text/html; charset=UTF-8');
$body_lines = array();
if ($user->getEmail())
{
$body_lines[] = 'Эл. почта <b>' . $user->getEmail() . '</b>';
}
if ($user->getPhoneNumber())
{
$body_lines[] = 'Телефон <b>' . $user->getPhoneNumber() . '</b>';
}
$body_lines[] = '<b>Комментарий: <b><br /><i>' . trim($request->getParameter('text')) . '</i>';
$body = file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_header.php') . implode('<br />', $body_lines) . file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_footer.php');
$message->setBody($body);
$this->getMailer()->send($message);
}
try
{
$feedback->save();
$values['user'] = $user;
$profile = $this->returnProfile($values, $user);
echo json_encode(array(
'state' => 'success',
'profile' => $profile,
'text' => 'Ваше сообщение успешно отправлено'
));
}
catch (Doctrine_Validator_Exception $e)
{
$errorStack = $feedback->getErrorStack();
foreach ($errorStack as $field => $errors)
{
$message .= "$field (" . implode(", ", $errors) . "), ";
}
$message = trim($message, ', ');
echo json_encode(array(
'state' => 'error',
'errorText' => $message
));
}
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeUpman($request)
{
$manifest = sfConfig::get('sf_web_dir') . '/.manifest';
if (file_exists($manifest))
{
$man = file($manifest);
$ver = preg_replace('/[^0-9]/', '', $man[1]);
if ($ver > 1000)
{
$ver = 1;
}
else
{
$ver += 1;
}
$to_change = preg_replace('/[0-9]{1,}/',$ver, $man[1]);
$man[1] = $to_change;
$current = '';
foreach ($man as $row)
{
$current .= $row;
}
file_put_contents($manifest, $current);
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeOrder($request)
{
if($request->hasParameter('json'))
{
$order_items = json_decode($request->getParameter('json'), true);
if(is_array($order_items))
{
if($request->hasParameter('comment'))
{
$comment = $request->getParameter('comment');
}
$user_id = $this->getUser()->getUserId();
$client_order = new ClientOrder();
$client_order->setUserId($user_id);
$client_order->setOrderStatusId('1');
$client_order->setComment($comment);
if($this->getUser()->getAccount()->getCurrentDiscount())
{
$client_order->setDiscount($this->getUser()->getAccount()->getCurrentDiscount());
}
$client_order->save();
$c = 0;
$items_count = count($order_items);
$result_arr = array();
$product_err = array(
'state' => 'error',
'errorText' => 'Невозможно обработать заказ',
'errorCode' => 'o500',
'json' => array(),
'bitrix' => array(),
);
$json = array();
$bitrix = array();
$count_error = array();
$error = false;
$returndata = array();
foreach($order_items as $item)
{
$item['article'] = preg_replace('/[^0-9]/', '', $item['article']);
if(isset($item['code']))
{
$product = Doctrine::getTable('Product')->findOneByProductCode($item['code']);
if($product)
{
$item['id'] = $product->getId();
}
}
$q_prod = Doctrine_Query::create()
->select('p.*, (SELECT SUM(psc.value) FROM ProductStockCount psc WHERE psc.product_id = p.id) AS pcountv')
->from('Product p')
->where('p.id = ?', $item['id'])
->limit(1);
$product = $q_prod->execute();
if (count($product) == 0)
{
$returndata[$item['id']] = 0;
}
else
{
if($item['count'] > $product[0]['pcountv'])
{
$returndata[$item['id']] = intval($product[0]['pcountv']);
$bitrix[$product[0]['product_code']] = intval($product[0]['pcountv']);
$count_error[] = $product[0]['title'] . ', в наличии: ' . intval($product[0]['pcountv']);
}
else
{
$result_arr[$c] = array(
'product_id' => $product[0]['id'],
'product_art' => $product[0]['product_code'],
'product_descr' => $product[0]['title'],
'client_order_id' => $client_order->getId(),
'product_count' => $item['count']
);
$c++;
}
}
}
if (count($returndata) == 0)
{
foreach ($result_arr as $el)
{
$order_item = new OrderItem();
$order_item->setProductId($el['product_id']);
$order_item->setClientOrderId($el['client_order_id']);
$order_item->setProductCount($el['product_count']);
$order_item->save();
}
$email_order = sfConfig::get('app_email_order', false);
if($email_order)
{
$tempnam = tempnam('/tmp', 'ie');
$objWriter = PHPExcel_IOFactory::createWriter($client_order->getExcel(), 'Excel5');
$objWriter->save($tempnam);
$second_level = implode('.', array_reverse(array_slice(array_reverse(explode('.', $request->getHost())), 0, 2)));
$order_user = $client_order->getUser();
$message = Swift_Message::newInstance()
->setFrom('app@' . $second_level)
->setTo($email_order)
->setSubject('Новый заказ №' . $client_order->getId() . ' от ' . $order_user->getOrganization() . ' ИНН ' . $order_user->getUsername())
;
if($this->getUser()->getAccount()->getEmail() != '')
{
$message->setReplyTo(array($this->getUser()->getAccount()->getEmail()));
}
$message->setContentType('text/html; charset=UTF-8');
$body_lines = array();
$body_lines[] = 'ИНН <b>' . $order_user->getUsername() . '</b>';
$body_lines[] = 'Заказ от <b>' . $order_user->getOrganization() . '</b>';
if($order_user->getEmail())
{
$body_lines[] = 'Эл. почта <a href="mailto:' . $order_user->getEmail() . '"><b>' . $order_user->getEmail() . '</b></a>';
}
if($order_user->getPhoneNumber())
{
$body_lines[] = 'Телефон <b>' . $order_user->getPhoneNumber() . '</b>';
}
if($client_order->getComment())
{
$body_lines[] = '<b>Комментарий к заказу</b><br /><i>' . $client_order->getComment() . '</i>';
}
$body = file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_header.php') . implode('<br />', $body_lines) . file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_footer.php');
$body = str_replace('#TITLE#', 'Новый заказ №' . $client_order->getId() . ' ' . $order_user->getUsername(), $body);
$message->setBody($body);
$attachment = Swift_Attachment::newInstance()
->setFilename('Заказ №' . $client_order->getId() . '.xls')
->setContentType('application/vnd.ms-excel')
->setBody(file_get_contents($tempnam))
;
$message->attach($attachment);
//$this->getMailer()->send($message);
}
$user = $this->getUser()->getAccount();
$profile = $this->returnProfile(array('user' => $user), $user);
echo json_encode(array(
'state' => 'success',
'profile' => $profile,
'text' => 'Спасибо! Ваш заказ принят в обработку.<br /> Номер вашего заказа: ' . $client_order->getId(),
));
}
else
{
$client_order->delete();
echo json_encode(array(
'state' => 'error',
'errorText' => 'Невозможно обработать заказ. Превышено количество товара. ' . '<br />' . implode('<br />', $count_error),
'json' => $returndata,
'bitrix' => $bitrix,
));
}
}
}
$this->setLayout(false);
return sfView::NONE;
}
public function executePing($request)
{
echo time();
return sfView::NONE;
}
public function executeProfile($request)
{
$result = array('state' => 'redirect', 'hash' => $request->getParameter('back_hash') ? $request->getParameter('back_hash') : 'list');
if ($request->getHttpHeader('authorization'))
{
$authorization_str = base64_decode(str_replace('Basic ', '', $request->getHttpHeader('Authorization')));
$authorization_arr = explode(':', $authorization_str);
$user = PluginUserTable::getInstance()->getAuthenticatedUser($authorization_arr[0], $authorization_arr[1]);
if (!$user)
{
echo json_encode($result);
return sfView::NONE;
}
$user->setOpenPassword($authorization_arr[1]);
$user->save();
$this->getUser()->signIn($user, true);
$profile = $this->returnProfile(array('user' => $user), $user);
$result = array('profile' => $profile);
echo json_encode($result);
}
else
{
echo json_encode($result);
}
return sfView::NONE;
}
public function executeSignup($request)
{
if($request->isMethod('post') && $request->hasParameter('signup'))
{
$signup = $request->getParameter('signup');
$chars = "1234567890";
$max = 8;
$password = null;
$size = strLen($chars) - 1;
while($max--)
{
$password .= $chars[rand(0, $size)];
}
$signup['password'] = $password;
$signup['is_active'] = 1;
$form = false;
if (!empty($signup['username']))
{
$user = Doctrine::getTable('User')->findOneByUsername($signup['username']);
if($user)
{
$form = new CustomRegisterUserForm($user);
}
else
{
$form = new CustomRegisterUserForm();
}
}
if(!$form)
{
echo json_encode(array(
'state' => 'error',
'errorText' => 'Данный ИНН уже зарегистрирован'
));
}
else
{
$form->bind($signup, $request->getFiles('signup'));
if ($form->isValid())
{
$values = $form->getValues();
$user = $form->save();
$user->setRecoverySecret('/' . md5($values['username'] . $values['password'] . $values['email'] . '/'));
$user->save();
$second_level = implode('.', array_reverse(array_slice(array_reverse(explode('.', $request->getHost())), 0, 2)));
sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
get_component('pages', 'emailSender',
array(
'type' => 'userRegistration',
'emailTo' => $values['email'],
'param' => array(
'organization' => $values['organization'],
'username' => $values['username'],
'password' => $password
)
)
);
// $message = Swift_Message::newInstance()
// ->setFrom('app@' . $second_level)
// ->setTo($values['email'])
// ->setSubject('Регистрационные данные для входа в систему Имидж-электро')
// ;
//
// $message->setContentType('text/html; charset=UTF-8');
//
// $body = file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_header.php') . '<b>' . $values['organization'] . "</b><br /><br />Вы успешно прошли регистрацию на сайте компании Имидж-Электро.<br />Для входа в систему используйте учетные данные:<br />Логин: " . $values['username'] . "<br />Пароль: " . $password . file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_footer.php');
//
// $body = str_replace('#TITLE#', 'Регистрационные данные для входа в систему Имидж-электро', $body);
//
// $message->setBody($body);
//$this->getMailer()->send($message);
echo json_encode(array(
'state' => 'success',
'text' => 'Регистрация прошла успешно. Пароль отправлен на указанный Вами адрес электронной почты',
));
}
else
{
$errors = array();
if($form->hasGlobalErrors())
{
foreach($form->getGlobalErrors() as $error)
{
$errors[] = $error->__toString();
}
}
foreach($form as $field)
{
if($field->hasError())
{
$errors[] = $field->getError()->__toString();
}
}
echo json_encode(array(
'state' => 'error',
'errorText' => implode('<br />', $errors)
));
}
}
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeSignout($request)
{
$this->getUser()->signOut();
echo json_encode(array(
'state' => 'redirect',
'hash' => $request->getParameter('back_hash') ? $request->getParameter('back_hash') : 'list'
));
$this->setLayout(false);
return sfView::NONE;
}
public function executeSignin($request)
{
if (($request->isMethod('post') && $request->hasParameter('signin')) || isset($_SERVER['PHP_AUTH_USER']))
{
$fields = $request->hasParameter('signin') ? $request->getParameter('signin') : array('username' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']);
$form = new SigninForm();
$form->bind($fields, array());
$route = sfContext::getInstance()->getRouting()->findRoute($request->getPathInfo());
if ($form->isValid())
{
$values = $form->getValues();
$user = $values['user'];
$user->setOpenPassword($fields['password']);
$user->save();
$this->getUser()->signIn($values['user'], true);
if(isset($_SERVER['PHP_AUTH_USER']) && $route !== false && $route['parameters']['action'] != 'signin')
{
$route = sfContext::getInstance()->getRouting()->findRoute($request->getPathInfo());
if($route !== false && $route['parameters']['action'] != 'signin')
{
$this->forward($route['parameters']['module'], $route['parameters']['action']);
}
}
else
{
$user = $this->getUser()->getAccount();
$profile = $this->returnProfile(array('user' => $user), $user);
echo json_encode(array(
'state' => 'redirect',
'profile' => $profile,
'hash' => $request->getParameter('back_hash') ? $request->getParameter('back_hash') : 'list'
));
die();
}
}
else
{
if($route['parameters']['action'] == 'signin')
{
echo json_encode(array(
'state' => 'error',
'errorText' => 'Неправильная пара логин-пароль! Авторизоваться не удалось.'
));
}
else
{
echo json_encode(array(
'state' => 'redirect',
'hash' => $this->getUser()->isAuthenticated() ? 'profile' : 'overlay/authorization'
));
}
}
}
else
{
echo json_encode(array(
'state' => 'redirect',
'hash' => $this->getUser()->isAuthenticated() ? 'profile' : 'overlay/authorization'
));
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeCheckinn($request)
{
if($request->isMethod('post') && $request->hasParameter('signup'))
{
$checkinn = $request->getParameter('signup');
if (isset($checkinn['username']) && !empty($checkinn['username']))
{
$q = Doctrine::getTable('User')->findOneByUsername($checkinn['username']);
if (!empty($q['organization']) && empty($q['email']))
{
echo json_encode(array(
'state' => 'success_inn',
'organization' => $q['organization'],
));
}
elseif (!empty($q['organization']) && !empty($q['email']))
{
echo json_encode(array(
'state' => 'error',
'errorText' => 'Данный клиент уже зарегистрирован в базе данных'
));
}
else
{
echo json_encode(array(
'state' => 'error_inn_in_db'
));
}
}
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeSettings($request)
{
if($request->isMethod('post') && $request->hasParameter('settings'))
{
$settings = $request->getParameter('settings');
$settings['is_active'] = 1;
$user = $this->getUser()->getAccount();
$settings['username'] = $user->getUsername();
$settings['password'] = $user->getPassword();
$form = new CustomRegisterUserForm($user);
$form->bind($settings, $request->getFiles('settings'));
if ($form->isValid())
{
$form->save();
$values['user'] = $form->getValues();
$user = $this->getUser()->getAccount();
$profile = $this->returnProfile(array('user' => $user), $user);
echo json_encode(array(
'state' => 'success',
'profile' => $profile,
'text' => 'Данные профиля изменены'
));
}
else
{
$errors = array();
if($form->hasGlobalErrors())
{
foreach($form->getGlobalErrors() as $error)
{
$errors[] = $error->__toString();
}
}
foreach($form as $field)
{
if($field->hasError())
{
$errors[] = $field->getError()->__toString();
}
}
echo json_encode(array(
'state' => 'error',
'errorText' => implode('<br />', $errors)
));
}
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeRemindpassword($request)
{
if($request->isMethod('post') && $request->hasParameter('remind'))
{
$param = $request->getParameter('remind');
$user = Doctrine::getTable('User')->findOneByUsername($param['username']);
if ($user)
{
$user->setRecoverySecret(ProjectUlils::generateUuid());
$user->save();
$link_part = '/' . $user->getId() . '/' . $user->getRecoverySecret();
$second_level = implode('.', array_reverse(array_slice(array_reverse(explode('.', $request->getHost())), 0, 2)));
$message = Swift_Message::newInstance()
->setFrom('app@' . $second_level)
->setTo($user->getEmail())
->setSubject("Восстановление пароля от личного кабинета Имидж-Электро")
;
$message->setContentType('text/html; charset=UTF-8');
$body = file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_header.php');
$body .= 'Вы отправили запрос на восстановление пароля от личного кабинета на сайте Имидж-Электро.<br />Для того чтобы задать новый пароль, перейдите по ссылке: http://' . $request->getHost() . '/index.html#overlay/recovery_password' . $link_part . '<br /><br />Пожалуйста, проигнорируйте данное письмо, если оно попало к Вам по ошибке.';
$body .= file_get_contents(sfConfig::get('sf_app_template_dir') . '/mail_footer.php');
$body = str_replace('#TITLE#', 'Восстановление пароля от личного кабинета Имидж-Электро', $body);
$message->setBody($body);
$this->getMailer()->send($message);
$json = array(
'state' => 'redirect',
'back_hash' => 'list',
'text' => 'Ссылка для восстановления пароля отправлена на указанный при регистрации E-mail',
);
}
else
{
$json = array(
'state' => 'error',
'errorText' => 'Пользователь с данным E-mail не найден',
);
}
}
echo json_encode($json);
$this->setLayout(false);
return sfView::NONE;
}
public function executeRecovery_password($request)
{
$user = Doctrine::getTable('User')->findOneByIdAndRecoverySecret($request->getParameter('id'), $request->getParameter('recovery_secret'));
if ($user)
{
$json = array(
'state' => 'success',
'text' => 'user found',
);
if ($request->getParameter('password') && $request->getParameter('password_repeat'))
{
if ($request->getParameter('password') == $request->getParameter('password_repeat'))
{
$user->setPassword($request->getParameter('password'));
$user->save();
{
$json = array(
'state' => 'redirect',
'back_hash' => 'list',
'text' => 'Пароль успешно изменен',
);
}
$user->setRecoverySecret('');
$user->save();
}
else
{
$json = array(
'state' => 'error',
'errorText' => "Пароли не совпадают",
);
}
}
else
{
$json = array(
'state' => 'error',
'errorText' => 'Не все поля заполнены',
);
}
}
else
{
$json = array(
'state' => 'error',
'errorText' => 'Пользователь не найден',
);
}
echo json_encode($json);
$this->setLayout(false);
return sfView::NONE;
}
public function executeChangepassword($request)
{
if($request->isMethod('post') && $request->hasParameter('settings'))
{
$settings = $request->getParameter('settings');
$json = array(
'state' => 'error',
'errorText' => 'Старый пароль указан не верно',
);
$usera = Doctrine::getTable('User')->find($this->getUser()->getAccount()->getId());
$tmp_user = new User();
$tmp_user->setSalt($usera->getSalt());
$tmp_user->setPassword($settings['old_password']);
if($tmp_user->getPassword() == $usera->getPassword())
{
$form = new ChangePasswordForm();
$form->bind(array('password' => $settings['password']), array());
if ($form->isValid())
{
$usera->setPassword($settings['password']);
$usera->save();
$profile = $this->returnProfile(array('user' => $usera), $usera);
$json = array(
'state' => 'success',
'profile' => $profile,
'text' => 'Пароль успешно изменен ' . $settings['password'],
);
}
else
{
$errors = array();
if($form->hasGlobalErrors())
{
foreach($form->getGlobalErrors() as $error)
{
$errors[] = $error->__toString();
}
}
foreach($form as $key => $field)
{
if($field->hasError())
{
$errors[] = $field->getError()->__toString() . ': ' . $key;
}
}
$json['errorText'] = implode('<br />', $errors);
}
}
echo json_encode($json);
die();
}
$this->setLayout(false);
return sfView::NONE;
}
public function executeCat_images($request)
{
if($request->isMethod('post') && $request->hasParameter('cat_images'))
{
$cats = array_keys($request->getParameter('cat_images'));
$cat_idx = serialize(array_values($request->getParameter('cat_images')));
foreach ($cats as $cat)
{
$q = Doctrine_Query::create()
->select("cp.cat_id")
->from("CatParent cp")
->where("cp.parent_id = ?", $cat)
->fetchArray();
foreach ($q as $inner_cat)
{
$cats_arr[] = $inner_cat['cat_id'];
}
}
$cats = serialize($cats_arr);
$user = $this->getUser()->getAccount();
if ($user && $user->getCatsWithImages())
{
$temp_cats = $user->getCatsWithImages();
}
else
{
$temp_cats = '';
}
if ($temp_cats != $cats)
{
$user->setCatsWithImages($cats);
$user->setCatIndx($cat_idx);
$user->setManifestVersion($user->getManifestVersion() + 1);
$user->save();
}
}
else
{
$user = $this->getUser()->getAccount();
$user->setCatsWithImages('');
$user->setCatIndx('');
$user->setManifestVersion($user->getManifestVersion() + 1);
$user->save();
}
$user = $this->getUser()->getAccount();
$profile = $this->returnProfile(array('user' => $user), $user);
$json = array(
'state' => 'success',
'profile' => $profile,
'text' => 'Выбранные вами изображения успешно синхронизированы',
);
echo json_encode($json);
$this->setLayout(false);
return sfView::NONE;
}
public function executeManifest($request)
{
$user = $this->getUser()->getAccount();
$ver_num = ($user)? $user->getManifestVersion() : 0;
$manifest = "CACHE MANIFEST" . "\n";
$ver_text = "version ";
$version = $ver_text . $ver_num . "\n";
$manifest .= $version;
$manifest .= "index.html" . "\n" .
"css/fonts.css" . "\n" .
"css/g.css" . "\n" .
"css/p.css" . "\n".
"\n".
"js/jquery-2.0.3.min.js" . "\n".
"js/xlsx.js" . "\n".
"js/jquery.plugins.js" . "\n".
"js/controllers.js" . "\n".
"js/profile.js" . "\n".
"js/lstorage.js" . "\n".
"js/db.js" . "\n".
"js/ielectro.js" . "\n".
"js/init.d.js" . "\n".
"\n".
"i/no_photo.png" . "\n".
"i/counter_elem.png" . "\n".
"\n".
"\n".
"NETWORK:" . "\n".
"*" . "\n".
"\n".
"FALLBACK:" . "\n"
;
echo $manifest;
$this->setLayout(false);
return sfView::NONE;
}
//
public function executeDetect_lang(sfWebRequest $request)
{
//$culture = $request->getPreferredCulture(array('ru', 'en'));
$culture = $request->getPreferredCulture(array('ru'));
$this->getUser()->setCulture($culture);
$this->redirect('homepage');
return sfView::NONE;
}
}
default:
is_secure: true
signin:
is_secure: false
signout:
is_secure: false
signup:
is_secure: false
checkinn:
is_secure: false
remindpassword:
is_secure: false
recovery_password:
is_secure: false
manifest:
is_secure: false
gen_xls:
is_secure: false
detect_lang:
is_secure: false
var profile = {
<?php
if($sf_user->isAuthenticated())
{
$username = $sf_user->getUsername();
$user = $sf_user->getAccount();
$user_debt = $user->getDebt();
if ($user->getManagerId())
{
$manager = Doctrine::getTable('User')->findOneById($user->getManagerId());
}
$user_order = Doctrine_Query::create()
->select("oi.client_order_id AS order_id, oi.product_count, oi.id AS product_id, p.title AS title, pp.value AS cost, os.title AS status, co.created_at AS order_time")
->from("OrderItem oi")
->leftJoin("oi.ClientOrder co")
->leftJoin("co.OrderStatus os")
->leftJoin("oi.Product p")
->leftJoin("p.ProductPrice pp")
->where("co.user_id = ?", $user->getId())
->andWhere("pp.price_type_id = 1")
->orderBy("co.created_at DESC")
->fetchArray();
/* $user_order = Doctrine_Query::create()
->select("co.*,os.title as status")
->from("ClientOrder co")
->leftJoin("co.OrderStatus os")
->where("co.user_id = ?", $user->getId())
->orderBy("co.id", "ASC")
->execute();*/
/*print_r($user_order);
die();*/
$q_corr = Doctrine_Query::create()
->select("c.*, uf.*, ut.*")
->from("Correspondence c")
->leftJoin("c.UserFrom uf")
->leftJoin("c.UserTo ut")
->where("c.user_id_from = ?", $user->getId())
->orWhere("c.user_id_to = ?", $user->getId())
->orderBy("c.created_at", "ASC");
$corr = $q_corr->execute();
$order_detail = array();
$debt_detail = array();
echo "auth: true,\n";
echo "username: '" . $username . "',\n";
echo "organization: '" . $user->getOrganization() . "',\n";
echo "phone: '" . $user->getPhoneNumber() . "',\n";
echo "city: '" . $user->getCity() . "',\n";
echo "address: '" . $user->getAddress() . "',\n";
echo "email: '" . $user->getEmail() . "',\n";
echo "orders_sum_last_month: '" . $user->getOrdersSumLastMonth() . "',\n";
echo "orders_sum_current: '" . $user->getOrdersSumCurrent() . "',\n";
echo "sum_limit: '" . $user->getLimitBySum() . "',\n";
echo "sum_discount: '" . $user->getCurrentDiscount() . "',\n";
echo "debt: '" . $user->getCurrentDebt() . "',\n";
echo "manager:[";
if (isset($manager))
{
echo "{name: '" . $manager->getFname() . ' ' . $manager->getIname() . "',\n";
echo "phone: '" . $manager->getPhoneNumber() . "'},\n";
}
else
{
echo "{name: 'отдел продаж'},\n";
}
echo "],\n";
echo "debt_detail:[";
foreach ($user_debt as $debt)
{
echo "{debt_sum: '" . $debt->getDebtSum() . "',\n";
echo "deadline: '" . ProjectUlils::rusDate($debt->getDeadline()) . "'},\n";
}
echo "],\n";
/* echo "orders:[";
foreach ($user_order as $product)
{
echo "{id: '" . $product->getId() . "',\n";
echo "status: '" . $product->getStatus() . "',\n";
echo "date: '" . ProjectUlils::rusDate($product->getCreatedAt(), true) . "'},\n";
}
echo "],\n";*/
/*print_r($user_order);
die();*/
echo "orders:[";
if (count($user_order) > 0)
{
$order_id = 'any_string';
$order_count_prod = 0;
$order_price_prod = 0;
$count_help = 0;
for($i = 0; $i < count($user_order); $i++)
{
/*print_r($user_order);
die();*/
$c = $i;
if ($count_help != $user_order[$i]['order_id'])
{
$count_help = $user_order[$i]['order_id'];
while ($count_help == $user_order[$i]['order_id'])
{
//print_r($user_order[$i+1]['order_id']);
$order_count_prod += $user_order[$i]['product_count'];
$order_price_prod += $user_order[$i]['cost'] * $user_order[$i]['product_count'];
if (isset($user_order[$i+1]['order_id']))
{
$i++;
}
else
{
break;
}
}
}
$i = $c;
/*print_r($c);
die();*/
if ($order_id != $user_order[$i]['order_id'])
{
echo "{id: '" . $user_order[$i]['order_id'] . "',\n";
echo "count: '" . $order_count_prod . "',\n";
echo "date: '" . ProjectUlils::rusDate($user_order[$i]['order_time'], false) . "',\n";
echo "price: '" . $order_price_prod . "',\n";
echo "status: '" . $user_order[$i]['status']. "',\n";
echo "goods:[\n";
$order_id = $user_order[$i]['order_id'];
$order_count_prod = 0;
$order_price_prod = 0;
while ($order_id == $user_order[$c]['order_id'])
{
echo "{product_id: '" . $user_order[$c]['product_id'] . "',\n";
echo "product: '" . $user_order[$c]['title'] . "',\n";
echo "count: '" . $user_order[$c]['product_count'] . "',\n";
echo "price: '" . ($user_order[$c]['cost'] * $user_order[$c]['product_count']) . "'},\n";
$c++;
if (!isset($user_order[$c]['order_id']))
{
break;
}
}
$c = $i;
$order_id = $user_order[$i]['order_id'];
echo "]\n";
if (isset($user_order[$i + 1]['order_id']))
{
if ($order_id != $user_order[$i + 1]['order_id'])
{
echo "},\n";
}
elseif ($order_id == $user_order[$i + 1]['order_id'])
{
echo "},\n";
}
}
else
{
echo "},\n";
}
}
}
/*foreach ($user_order as $product)
{
if ($order_id != $product->getOrderId())
{
echo "{id: '" . $product->getOrderId() . "',\n";
echo "goods:[\n";
}
echo "{product_id: '" . $product->getProductId() . "',\n";
echo "product: '" . $product->getTitle() . "',\n";
echo "price: '" . $product->getCost() . "',\n";
echo "count: '" . $product->getProductCount() . "',\n";
echo "status: '" . $product->getStatus() . "',\n";
echo "date: '" . ProjectUlils::rusDate($product->getOrderTime(), false) . "'},\n";
if ($order_id != $product->getOrderId())
{
echo "{id: '" . $product->getOrderId() . "',\n";
echo "goods:[\n";
}
$order_id = $product->getOrderId();
}*/
}
echo "],\n";
echo 'feedBack:[';
foreach ($corr as $message)
{
if ($message['status'] == 'out')
{
echo "{name: '" . $message->getUserFrom()->getFname() . ' ' . $message->getUserFrom()->getIname() . "',\n";
echo "status: 'in',\n";
}
else
{
echo "{name: '" . $message->getUserFrom()->getOrganization() . "',\n";
echo "status: 'out',\n";
}
echo "text: '" . $message->getBody() . "',\n";
echo "date: '" . ProjectUlils::rusDate($message->getCreatedAt(), false, true) . "'},\n";
}
echo "],\n";
}
else
{
echo "auth:false\n";
}
?>
};
\ No newline at end of file
<?php
print_r("HERE");
die();
$children_clean = array();
$all_cats = array();
$catFolder_idx = array();
foreach($cat_parents as $cat_parent)
{
$children_clean[$cat_parent['parent_id']][] = $cat_parent;
$all_cats[$cat_parent['cat_id']][] = $cat_parent;
}
$root_cats = array();
foreach ($cats as $k => $cat)
{
$catFolder_idx[$cat['id']] = $k;
if(!$cat['parent_id'])
{
$root_cats[] = $k + 1;
}
}
$catFolder[] = "{id:0,title:'Каталог',parents:[0],children:[" . implode(',', $root_cats) . "],all_children:false}";
foreach ($cats as $k => $cat)
{
$children = array();
$parents = array();
$check_pr = array();
if(isset($children_clean[$cat['id']]))
{
foreach($children_clean[$cat['id']] as $child)
{
if($child['order_id'] == 0)
{
$children[] = $catFolder_idx[$child['cat_id']] + 1;
}
}
}
if(isset($all_cats[$cat['id']]))
{
foreach($all_cats[$cat['id']] as $record)
{
$parents[] = $catFolder_idx[$record['parent_id']] + 1;
}
$parents[] = $catFolder_idx[$cat['id']] + 1;
}
$catFolder[] = "{id:" . $cat['id'] . ",parent_id:" . ($cat['parent_id'] ? ($catFolder_idx[$cat['parent_id']] + 1) : '0') . ",title:'" . $cat['title'] . "',parents:[0," .(empty($parents)? ($catFolder_idx[$cat['id']] + 1) : implode(',', $parents)) . "],children:[" . implode(',', $children) . "]}";
}
$products_a = array();
$context = sfContext::getInstance();
$d = $context->getDatabaseManager()->getDatabase('doctrine');
$dsn = explode(';', $d->getParameter('dsn'));
$e = explode('=', $dsn[0]);
mysql_connect($e[1], $d->getParameter('username'), $d->getParameter('password'));
$e = explode('=', $dsn[1]);
mysql_select_db($e[1]);
mysql_query('SET CHARACTER SET utf8');
$q = "SELECT p.*, cp.*, pi.*, psc.value AS stock_count, pp.value AS price
FROM product AS p
INNER JOIN cat_product as cp ON p.id = cp.product_id
LEFT JOIN product_image as pi ON p.id = pi.product_id
LEFT JOIN product_stock_count as psc ON p.id = psc.product_id
INNER JOIN product_price as pp ON p.id = pp.product_id
WHERE (pp.price_type_id = 1)";
$res = mysql_query($q);
$idx = 1;
$cat_idx = array();
$product_idx = array();
while($product = mysql_fetch_assoc($res))
{
/*print_r($product);
die();*/
if (isset($product['src']) && $product['sizes'] != 0 && $product['src'] != 'no image')
{
$path = sfConfig::get('sf_data_dir') . '/1cbitrix/' . $product['src'];
/*print_r($path);
die();*/
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = base64_encode($data);
$products_a[] = "{id:" . $product['id'] . ",article:'" . $product['product_code'] . "',name:'" . addslashes($product['title']) . "',price:" . rand(1000, 10000) . ",image:'" . $base64 . "',min_purchase:1,number_product:" . $product['stock_count'] . "}";
}
else
{
$products_a[] = "{id:" . $product['id'] . ",article:'" . $product['product_code'] . "',name:'" . addslashes($product['title']) . "',price:" . rand(1000, 10000) . ",min_purchase:1,number_product:" . $product['stock_count'] . "}";
}
/* $products_a[] = "{id:" . $product['id'] . ",article:'" . $product['product_code'] . "',name:'" . addslashes($product['title']) . "',price:" . rand(100, 10000) . ",min_purchase:10,number_product:" . rand(1000, 10000) . "}";*/
$cat_idx[$product['cat_id']][$idx] = true;
$product_idx[$product['id']] = $idx;
$idx++;
}
$cat_idx_var = array('[]');
foreach($catFolder_idx as $catFolder_idx_k => $catFolder_idx)
{
$products = array();
if(isset($cat_idx[$catFolder_idx_k]))
{
$products = array_keys($cat_idx[$catFolder_idx_k]);
}
if(isset($children_clean[$catFolder_idx_k]))
{
foreach($children_clean[$catFolder_idx_k] as $child)
{
if(isset($cat_idx[$child['cat_id']]))
{
$products = array_merge($products, array_keys($cat_idx[$child['cat_id']]));
}
}
}
$cat_idx_var[] = '[' . implode(',', array_unique($products)) . ']';
}
$q = "SELECT k.* FROM keyword k ORDER BY k.rank DESC LIMIT 10000";
$res = mysql_query($q);
$idx = 0;
$keywords = array();
$keywords_idx = array();
while($keyword = mysql_fetch_assoc($res))
{
$keywords[] = "'" . $keyword['word'] . "'";
$pidx = array();
foreach(unserialize($keyword['ids']) as $id)
{
if(isset($product_idx[$id]))
{
$pidx[] = $product_idx[$id];
}
}
$keywords_idx[] = '[' . implode(',', $pidx) . ']';
}
?>
var db = {
catFolder: [
<?php echo implode(",\n", $catFolder);?>
],
cat: [
<?php echo implode(",\n", $products_a);?>
],
cat_idx: {
title: [
<?php echo implode(",\n", $cat_idx_var);?>
]
},
keywords: [<?php echo implode(",", $keywords);?>],
keywords_idx: [<?php echo implode(",", $keywords_idx);?>]
};
<?php
/**
* video actions.
*
* @package sf
* @subpackage video
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class videoActions extends sfActions
{
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->culture = $this->getUser()->getCulture();
$this->videos = Doctrine_Query::create()
->select("v.*, t.*")
->from("Video v")
->innerJoin("v.Translation t")
->where("t.lang = ?", $this->getUser()->getCulture())
->andWhere("t.available = 1")
->fetchArray();
$count_videos = count($this->videos);
if ($request->getParameter('tag_id'))
{
$this->tag_id = $request->getParameter('tag_id');
}else
{
$this->tag_id = 'all';
}
$tags = Doctrine_Query::create()
->select('t.*, tt.*, vt.*')
->from('Tag t')
->leftJoin('t.Translation tt WITH tt.lang = ?', $this->culture)
->leftJoin('t.VideoTags vt WITH vt.tag_id = t.id')
->fetchArray();
$this->videos_tags = array();
foreach ($tags as $tag)
{
if (count($tag['VideoTags']) > 0 )
{
$this->videos_tags[] = $tag;
}
}
if ($request->getParameter('tag_id') && $request->getParameter('tag_id') != 'all' && $count_videos >= sfConfig::get('app_view_count_tag')) {
unset($this->videos);
$videos = Doctrine_Query::create()
->select('')
->from('Tag t')
->where('t.id = ?', $request->getParameter('tag_id'))
->leftJoin('t.VideoTags at WITH t.id = at.tag_id')
->leftJoin('at.Video a WITH at.video_id = a.id')
->innerJoin("a.Translation ta")
->andwhere("ta.lang = ?", $this->culture)
->andWhere("ta.available = 1")
->fetchArray();
$this->videos = array();
foreach ($videos[0]['VideoTags'] as $video) {
$this->videos[] = $video['Video'];
}
$this->forward404Unless($this->videos);
}
if ($request->getParameter('tag_id') && $request->getParameter('ajax'))
{
sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
echo include_partial('video/video', array('videos' => $this->videos, 'die' => true));
}
}
}
<?php
class videoComponents extends sfComponents
{
public function executeVideo(sfWebRequest $request)
{
$this->culture = $this->getUser()->getCulture();
if ($request->getParameter('alias')) {
$productTags = Doctrine::getTable('Product')->findOneByAlias($request->getParameter('alias'))->getProductTags();
$idsTags = array();
foreach ($productTags as $tag) {
$idsTags[] = $tag->getTagId();
}
if (count($idsTags) > 0) {
$q = Doctrine_Query::create()
->select("v.*, t.*")
->from("Video v")
->innerJoin("v.Translation t")
->where("t.lang = ?", $this->getUser()->getCulture())
->andWhere("t.available = 1")
->innerJoin('v.VideoTags vt')
->andWhereIn('vt.tag_id', $idsTags);
if (isset($this->limit) && $this->limit) {
$q->limit($this->limit);
}
$this->videos = $q->fetchArray();
} else {
$q = array();
}
}else
{
$this->videos = Doctrine_Query::create()
->select("v.*, t.*")
->from("Video v")
->innerJoin("v.Translation t")
->where("t.lang = ?", $this->getUser()->getCulture())
->andWhere("t.available = 1")
->fetchArray();
}
//print_r($request->getParameter('alias'));
}
}
\ No newline at end of file
<?php
if(count($videos) > 0){
$module_action = $sf_request->getParameter('module') . '_' . $sf_request->getParameter('action');
if($module_action == 'product_show'){
echo '<div class="product_section product__video">';
echo '<div class="caption"><a class="green_link" href="/' . $culture . '/video/?tag_id=' . $tag_id . '"> ' . __('Видео') . '</a></div>';
echo '<div class="max_width">';
}
foreach ($videos as $key => $video){
$code = Video::getYoutubeCode($video['vid']);
if($code != ''){
$pos_class = '';
if(($key % 3) != 1){
$pos_class = ' video_item_' . (($key % 3) == 0 ? 'left' : 'right');
}
echo '<div class="video_item' . $pos_class . '">';
echo '<div class="video" data-src="https://www.youtube.com/embed/' . $code . '?ecver=2&autoplay=1&list=PLBLtydguylgB-9FPU63TY_vtsj0xYt5li" style="background-image: url(/u/i/' . Page::replaceImageSize($video['cover'], 'M') . ');" onclick="video.open(this);"></div>';
echo '<div class="video_title">' . $video['Translation'][$culture]['title'] . '</div>';
//var_dump($culture);
echo '</div>';
}
}
if($module_action == 'product_show'){
echo '</div>';
echo '</div>';
}
}
if ($die)
{
die();
}
if ($sf_request->getParameter('module') == 'product')
{
echo '<i class="br30 mobile_hide"></i>';
}
<?php
slot('title', __('Смотреть'));
include_partial('main/breadcrumbs');
echo '<h1 class="content_title">' . __('Смотреть') . '</h1>';
?>
<div class="video_item_gutter" style="width: 100%; text-align: center">
<?php
if (count($reviews) >= sfConfig::get('app_view_count_tag')) {
echo '<a data-tag-id="all" class="videos_show_tag green_link ' . (!$tag_id || $tag_id == 'all' ? 'active' : '') . '">Все</a>';
foreach ($videos_tags as $tag) {
echo '<a class="videos_show_tag green_link ' . ($tag_id == $tag['id'] ? 'active' : '') . '" data-tag-id="' . $tag['id'] . '">' . $tag['Translation'][$culture]['title'] . '</a>';
}
}
?>
</div>
<div class="videos_wrap">
<?php include_partial("video/video", array('videos' => $videos, 'culture' => $culture)); ?>
</div>
<script>
var culture = '<?php echo $culture ?>';
$('body').on('click', '.videos_show_tag', function () {
//alert('123');
_this = this;
$.ajax({
url: '/' + culture + '/video/',
type: 'get',
data: {tag_id : $(this).attr('data-tag-id'), ajax : 1},
success: function (html) {
$('.videos_show_tag').removeClass('active');
$(_this).addClass('active');
$('.videos_wrap').html(html);
setUrlHash('?tag_id='+$(_this).attr('data-tag-id'));
}
});
//alert($(this).attr('data-tag-id'));
});
</script>
\ No newline at end of file
</div></td></tr>
<tr>
<td class="root_table__bottom" align="center" colspan="2">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5">
<div class="footer_table_link background_grey">
<div class="max_width">
<table cellspacing="0" cellpadding="0" width="100%">
<tbody valign="top">
<tr>
<?php
Cat::menuInit();
$culture = $sf_user->getCulture();
$i = 0;
$single_menus = '';
$pathinfo = $sf_request->getPathInfo();
foreach (Cat::$menu as $menu_key => $menu){
$url = ($pathinfo == url_for('@catalog_show?alias=' . $menu['alias']) ? '' : url_for('@catalog_show?alias=' . $menu['alias']));
if($menu_key < 3){
echo '<td>';
echo '<ul class="footer_table_link__ul">';
echo '<li><' . ($url ? 'a href="' . $url . '"' : 'span') . ' class="black_link big">' . $menu['Translation'][$culture]['title'] . '</' . ($url ? 'a' : 'span') . '></li>';
if(strpos($menu['alias'], 'kamen') !== false && count($menu['Products']) > 0){
foreach ($menu['Products'] as $product){
if($product['offer_count'] > 0 && $product['is_detail']){
$url = ($pathinfo == url_for('@product_show?alias=' . $product['alias']) ? '' : url_for('@product_show?alias=' . $product['alias']));
echo '<li><' . ($url ? 'a href="' . $url . '"' : 'span') . ' class="black_link">' . $product['Translation'][$culture]['title'] . '</' . ($url ? 'a' : 'span') . '></li>';
}
}
}
if(count($menu['Children']) > 0){
foreach ($menu['Children'] as $cat){
$url = ($pathinfo == url_for('@catalog_show?alias=' . $cat['alias']) ? '' : url_for('@catalog_show?alias=' . $cat['alias']));
echo '<li><' . ($url ? 'a href="' . $url . '"' : 'span') . ' class="black_link">' . $cat['Translation'][$culture]['title'] . '</' . ($url ? 'a' : 'span') . '></li>';
}
echo '<li></li>';
}
echo '</ul>';
echo '</td>';
if(($i % 2) == 0){
echo '<td width="70">&nbsp;</td>';
$i--;
}
$i++;
}else{
$single_menus .= '<li><' . ($url ? 'a href="' . url_for('@catalog_show?alias=' . $menu['alias']) . '"' : 'span') . ' class="black_link big">' . $menu['Translation'][$culture]['title'] . '</' . ($url ? 'a' : 'span') . '></li>';
if(count($menu['Children']) > 0){
foreach ($menu['Children'] as $cat){
$url = ($pathinfo == url_for('@catalog_show?alias=' . $cat['alias']) ? '' : url_for('@catalog_show?alias=' . $cat['alias']));
$single_menus .= '<li><' . ($url ? 'a href="' . $url . '"' : 'span') . ' class="black_link">' . $cat['Translation'][$culture]['title'] . '</' . ($url ? 'a' : 'span') . '></li>';
}
$single_menus .= '<li><i class="br1"></i></li>';
}
}
}
if($single_menus != ''){
echo '<td><ul class="footer_table_link__ul">' . $single_menus . '</ul></td>';
if(($i % 2) == 0){
echo '<td width="70">&nbsp;</td>';
$i--;
}
$i++;
}
?>
<td>
<?php
include_component('main', 'menu', array('type' => 'bottom'));
?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="footer_table_main">
<div class="max_width">
<table class="footer_table_main__wrap to_div" cellspacing="0" cellpadding="0" width="100%">
<tbody valign="middle">
<tr>
<td width="1">
<img src="/i/logo-black.svg" class="mobile_hide" width="100" height="51"/>
</td>
<td width="30"></td>
<td width="140" style="color: #000000">
2017 © Иди в баню<br><?php echo __('Все права защищены');?>
</td>
<td width="80"></td>
<td>
<i class="br15 mobile"></i>
<a href="<?php echo csSettings::get('tg') ?>" class="icon_sc" target="_blank"><img src="/i/telegram.svg"></a>
<a href="<?php echo csSettings::get('vk') ?>" class="icon_sc" target="_blank"><img src="/i/vk.svg"></a>
<a href="<?php echo csSettings::get('yt') ?>" class="icon_sc" target="_blank"><img src="/i/youtube.svg"></a>
<a href="tel:<?php echo csSettings::get('ws') ?>" class="icon_sc" target="_blank"><img src="/i/whatsapp.svg"></a>
<a href="<?php echo csSettings::get('facebook') ?>" class="icon_sc" target="_blank"><img src="/i/facebook.svg"></a>
<a href="<?php echo csSettings::get('instagram') ?>" class="icon_sc" target="_blank"><img src="/i/instagram.svg"></a>
</td>
<td>
<nobr>
<?php
/*
foreach (array('tg', 'vk', 'tw', 'yt', 'ws') as $slug) {
if (csSettings::get($slug)) {
echo '<a href="' . csSettings::get($slug) . '" class="footer_table_main__link footer_table_main__link_contact footer_table_main__link_' . $slug . '"></a>';
}
}
*/
?>
</nobr>
</td>
<td width="80"></td>
<td align="right" class="mobile_hide">
<a href="https://atma.company" class="footer_table_main__link_atma black_link anb" target="_blank">
<img src="/i/atma.svg" width="59" height="21" alt="" />
<span style="color: #000000"><?php echo ($sf_user->getCulture() == 'ru' ? 'Сделано компанией<br>«Атма» в 2017 году' : 'Made it company <br>«Atma» in 2017');?></span>
</a>
</td>
</tr>
<tr>
<td colspan="8">
<i class="br20"></i>
<i class="br30 mobile_hide"></i>
</td>
</tr>
<tr>
<td colspan="6">
<div class="footer_table_main__policy">
ИП Кидрасов Ильнур Зиганшович ИНН 027363464428 ОГРН 317028000071294
<i class="br10"></i>
<?php
if($sf_user->getCulture() == 'ru'){
echo 'Обращаем ваше внимание на то, что
данный интернет-сайт носит исключительно информационный характер и ни при
каких условиях не является публичной офертой, определяемой положениями
Статьи 437 (2) Гражданского кодекса Российской Федерации';
}else{
echo 'Please note that this Internet site is for informational purposes only and under no circumstances is not a public offer defined by positions of Article 437 (2) of the Civil code of the Russian Federation';
}
?>
</div>
<i class="br15 mobile"></i>
</td>
<td></td>
<td align="right" width="1" class="align_left">
<div class="footer_table_main__copyright" style="color: #000000"><?php echo ($sf_user->getCulture() == 'ru' ? 'Использованы фото:<br>Олеси Келлер и Владимира Ляпина' : 'Used photos:<br>Olesya Keller and Vladimir Lyapina');?>
</div>
<i class="br20 mobile"></i>
<a href="https://atma.company" class="footer_table_main__link_atma black_link anb mobile" target="_blank">
<img src="/i/atma.svg" width="59" height="21" alt="" />
<span style="color: #000000"><?php echo ($sf_user->getCulture() == 'ru' ? 'Сделано компанией<br>«Атма» в 2017 году' : 'Made it company <br>«Atma» in 2017');?></span>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr></table></td></tr></table></div>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment