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

first

parents
generator:
class: sfDoctrineGenerator
param:
model_class: BasketOrder
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: basket_order
with_doctrine_route: true
actions_base_class: sfActions
order: 5
hr: true
config:
actions: ~
fields:
id: {label: ' заказа'}
username: {label: 'Имя'}
phone: {label: 'Телефон'}
email: {label: 'Эл. почта'}
delivery_price: {label: 'Цена доставки'}
delivery_type: {label: 'Вид доставки'}
delivery_address: {label: 'Адрес доставки'}
comment: {label: 'Пожелание к заказу'}
payment_type: {label: 'Тип оплаты'}
total_sum: {label: 'Сумма'}
is_confirm: {label: 'Подтверждён'}
is_confirm_admin: {label: 'Подтверждение администратором'}
is_payed: {label: 'Оплачен'}
is_given: {label: 'Отгружен'}
created_at: {label: 'Дата'}
updated_at: {label: 'Дата обновления'}
list:
layout: ~
title: 'Заказы'
display: [id, username, phone, delivery_type, is_confirm, is_payed, is_given, created_at]
max_per_page: 100
sort: [created_at, DESC]
object_actions:
_delete: ~
_edit: ~
search:
fields: [username, phone]
export: false
filter:
display: [delivery_type]
form: ~
edit:
title: Редактирование заказа
new:
title: Добавление заказа
\ No newline at end of file
<?php
/**
* basket_order module configuration.
*
* @package sf
* @subpackage basket_order
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class basket_orderGeneratorConfiguration extends BaseBasket_orderGeneratorConfiguration
{
}
<?php
/**
* basket_order module helper.
*
* @package sf
* @subpackage basket_order
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class basket_orderGeneratorHelper extends BaseBasket_orderGeneratorHelper
{
}
<fieldset id="sf_fieldset_<?php echo preg_replace('/[^a-z0-9_]/', '_', strtolower($fieldset)) ?>">
<?php echo $form->renderHiddenFields(false) ?>
<?php if ('NONE' != $fieldset): ?>
<h2><?php echo __($fieldset, array(), 'messages') ?></h2>
<?php endif; ?>
<?php foreach ($fields as $name => $field): ?>
<?php if ((isset($form[$name]) && $form[$name]->isHidden()) || (!isset($form[$name]) && $field->isReal())) continue ?>
<?php
include_partial('basket_order/form_field', array(
'name' => $name,
'attributes' => $field->getConfig('attributes', array()),
'label' => $field->getConfig('label'),
'help' => $field->getConfig('help'),
'form' => $form,
'field' => $field,
'class' => 'sf_admin_form_row sf_admin_' . strtolower($field->getType()) . ' sf_admin_form_field_' . $name,
));
if($name == 'phone'){
echo '<i class="br1"></i>';
}
?>
<?php endforeach; ?>
<?php include_partial('basket_order/form_fieldset_footer', array('form' => $form)) ?>
</fieldset>
<?php
if (!$form->isNew()) {
$discount = Doctrine::getTable('DiscountPhone')->findOneByOrderId($form->getObject()->getId());
$offers = $form->getObject()->getOffers();
if (count($offers) > 0) {
?>
<div class="advanced_custom">
<?php
if ($discount) {
?>
<div>Использована скидка <?php echo $discount->getDiscount()->getTitle() . ' с ' . $discount->getActiveDiscount() . '%' ?></div>
<?php
}
?>
<div class="advanced_custom__h">Товарные предложения<sup>&nbsp;<?php echo count($offers);?></sup></div>
<div class="content">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th align="left" width="40%">Наименование</th>
<th align="right" width="20%">Количество</th>
<th align="right" width="20%">Цена</th>
<th align="right" width="20%">Сумма</th>
</tr>
<?php
$total = 0;
foreach ($offers as $offer) {
echo '<tr align="right"><td align="left">' . $offer['Offer']['Translation']['ru']['title'] . '</td><td>' . $offer['amount'] . '</td><td>' . number_format($offer['price']/$offer['amount'], 0, ',', ' ') . '&nbsp;₽</td><td><nobr>' . number_format($offer['price'], 0, ',', ' ') . '&nbsp;₽</nobr></td></tr>';
$total += $offer['price'];
}
echo '<tr class="advanced_custom__tr_divider_top"><td align="right" colspan="4"><nobr><b>Итого:&nbsp;</b>' . number_format($total, 0, ',', ' ') . '&nbsp;₽</nobr></td></tr>';
?>
</tbody>
</table>
</div>
</div>
<?php
}
}
?>
<script type="text/javascript">
$('#basket_order_delivery_type').change(function (e) {
$('.sf_admin_form_field_delivery_price').css('display', (e.target.value == 'Самовывоз' ? 'none' : 'inline-block'));
$('.sf_admin_form_field_delivery_address').css('display', (e.target.value == 'Самовывоз' ? 'none' : 'block'));
}).change();
</script>
\ No newline at end of file
<?php
require_once dirname(__FILE__).'/../lib/callbackGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/callbackGeneratorHelper.class.php';
/**
* callback actions.
*
* @package sf
* @subpackage callback
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class callbackActions extends autoCallbackActions
{
public function executeIndex(sfWebRequest $request)
{
// sorting
if ($request->getParameter('sort') && $this->isValidSortColumn($request->getParameter('sort')))
{
$this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
}
// pager
if ($request->getParameter('page'))
{
$this->setPage($request->getParameter('page'));
}
else
{
$this->setPage(1);
}
//search
if ($request->getParameter('q'))
{
$this->setSearch($request->getParameter('q'), ($request->hasParameter('checked') ? $request->getParameter('checked') : false));
}
else
{
$this->setSearch(false);
}
//checked
if ($request->getParameter('checked'))
{
$this->setChecked($request->getParameter('checked'));
}
else
{
$this->setChecked(false);
}
//tabs
if ($request->hasParameter('tab'))
{
$this->setTab($request->getParameter('tab'));
}
$this->pager = $this->getPager($request);
$this->sort = $this->getSort();
$this->tab = $this->getTab();
if($request->hasParameter('export'))
{
require_once sfConfig::get('sf_lib_dir') . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->setActiveSheetIndex(0);
$sheet->setCellValue('A1', 'Имя');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('A1')->applyFromArray($styleArray);
$sheet->setCellValue('B1', 'Телефон');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('B1')->applyFromArray($styleArray);
$sheet->setCellValue('C1', 'Позвонили');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('C1')->applyFromArray($styleArray);
$sheet->setCellValue('D1', 'Товар');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('D1')->applyFromArray($styleArray);
$sheet->setCellValue('E1', 'Дата');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('E1')->applyFromArray($styleArray);
foreach ($this->pager->getResults() as $i => $callback)
{
$value = '';
$method = 'getName';
if(is_callable(array($callback, 'getName')))
{
$method = $callback->$method();
if(is_object($method) && count($method) > 0)
{
$value = $method->__toString();
}
else
{
$value = $method;
}
}
$sheet->setCellValue('A' . ($i + 2), $value);
$sheet->getColumnDimension('A')->setAutoSize(true);
$value = '';
$method = 'getPhone';
if(is_callable(array($callback, 'getPhone')))
{
$method = $callback->$method();
if(is_object($method) && count($method) > 0)
{
$value = $method->__toString();
}
else
{
$value = $method;
}
}
$sheet->setCellValue('B' . ($i + 2), $value);
$sheet->getColumnDimension('B')->setAutoSize(true);
$value = '';
$method = 'getIsDone';
if(is_callable(array($callback, 'getIsDone')))
{
$method = $callback->$method();
if(is_object($method) && count($method) > 0)
{
$value = $method->__toString();
}
else
{
$value = $method;
}
}
$sheet->setCellValue('C' . ($i + 2), $value);
$sheet->getColumnDimension('C')->setAutoSize(true);
$value = '';
ob_start();
ob_implicit_flush(0);
try
{
require(sfConfig::get('sf_app_module_dir') . '/callback/templates/_offer_id.php');
}
catch (Exception $e)
{
ob_end_clean();
throw $e;
}
$value = ob_get_clean();
$sheet->setCellValue('D' . ($i + 2), $value);
$sheet->getColumnDimension('D')->setAutoSize(true);
$value = '';
$method = 'getCreatedAt';
if(is_callable(array($callback, 'getCreatedAt')))
{
$method = $callback->$method();
if(is_object($method) && count($method) > 0)
{
$value = $method->__toString();
}
else
{
$value = $method;
}
}
$value = date('d.m.Y', strtotime($value));
$sheet->setCellValue('E' . ($i + 2), $value);
$sheet->getColumnDimension('E')->setAutoSize(true);
}
$sheet->setAutoFilter('A1:E' . $i);
$sheet->setTitle('Обратный звонок');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$uuid = Page::generateUuid();
$objWriter->save('php://output');
$this->getResponse()->setHttpHeader('Content-type', 'application/octet-stream');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="Обратный звонок.xlsx"');
return sfView::NONE;
}
}
}
generator:
class: sfDoctrineGenerator
param:
model_class: Callback
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: callback
with_doctrine_route: true
actions_base_class: sfActions
config:
tabs:
0: { label: 'Обратный звонок', where: 'offer_id is null' }
1: { label: 'Узнать цену', where: 'offer_id is not null' }
actions: ~
fields:
id: {label: ''}
name: {label: 'Имя'}
phone: {label: 'Телефон'}
created_at: {label: 'Дата'}
updated_at: {label: ''}
offer_id: {label: 'Товар'}
is_done: {label: 'Позвонили'}
list:
layout: ~
title: 'Обратный звонок'
display: [name, phone, is_done, _offer_id, created_at]
max_per_page: 100
object_actions:
_delete: ~
_edit: ~
search:
fields: [name, phone]
export: false
sort: [created_at, DESC]
filter:
class: false
form: ~
edit:
title: Редактирование заявки
new:
title: Добавление заявки
\ No newline at end of file
<?php
/**
* callback module configuration.
*
* @package sf
* @subpackage callback
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class callbackGeneratorConfiguration extends BaseCallbackGeneratorConfiguration
{
}
<?php
/**
* callback module helper.
*
* @package sf
* @subpackage callback
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class callbackGeneratorHelper extends BaseCallbackGeneratorHelper
{
}
<?php
if (strlen($form->getObject()->getOfferId()) > 0)
{
echo '<span class="inline-label"><label><b>Товар</b></label></span>';
echo '<i class="br5"></i>';
$q = Doctrine_Query::create()
->select('p.*, o.*, ot.*')
->from('Product p')
->leftJoin('p.Offer o WITH o.product_id = p.id')
->where('o.id = ?', $form->getObject()->getOfferId())
->leftJoin('o.Translation ot WITH ot.lang = \'ru\'')
->fetchArray();
echo '<a href="/ru/product/' . $q[0]['alias'] . '/">' . $q[0]['Offer'][0]['Translation']['ru']['title'] . '</a>';
//print_r($q);
}
?>
<script>
$(document).ready(function () {
$('.sf_admin_form_field_offer_id').hide();
})
</script>
<?php if (!$pager->getNbResults()): ?>
<?php else: ?>
<table width="100%" cellspacing="0" cellpadding="3" border="0" class="lui__list_table lui__list_table_donor lui__list_table__sourse" id="lui__list_table_donor">
<thead>
<tr>
<th id="sf_admin_list_batch_actions" class="sf_admin_batch_checkbox__td"><input id="sf_admin_list_batch_checkbox" type="checkbox" onclick="$('.sf_admin_batch_checkbox').prop('checked', $(this).is(':checked'));" /></th>
<?php include_partial('callback/list_th_tabular', array('sort' => $sort, 'tab' => $tab)) ?>
<th id="sf_admin_list_th_actions">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach ($pager->getResults() as $i => $callback): $odd = fmod(++$i, 2) ? 'odd' : 'even' ?>
<tr class="sf_admin_row <?php echo $odd ?>" valign="top" data-href="<?php echo url_for('callback/edit?id=' . $callback->getPrimaryKey());?>">
<?php include_partial('callback/list_td_batch_actions', array('callback' => $callback, 'helper' => $helper)) ?>
<?php include_partial('callback/list_td_tabular', array('callback' => $callback, 'tab' => $tab)) ?>
<td>
<?php include_partial('callback/list_td_actions', array('callback' => $callback, 'helper' => $helper)) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<script>
$('.blank_product').on('click', function () {
var href = $(this).attr('href');
var win = window.open(href, '_blank');
if (win) {
win.focus();
}
return false;
});
</script>
<?php
if (isset($callback)):
include_partial('callback/list_footer', array('callback' => $callback, 'helper' => $helper));
endif;
?>
<td class="sf_admin_text sf_admin_list_td_name">
<?php echo $callback->getName() ?>
</td>
<td class="sf_admin_text sf_admin_list_td_phone">
<?php echo $callback->getPhone() ?>
</td>
<td class="sf_admin_boolean sf_admin_list_td_is_done">
<?php echo get_partial('callback/list_field_boolean', array('value' => $callback->getIsDone())) ?>
</td>
<?php
if ($tab == '1')
{
?>
<td class="sf_admin_text sf_admin_list_td_offer_id">
<?php echo get_partial('callback/offer_id', array('type' => 'list', 'callback' => $callback)) ?>
</td>
<?php
}
?>
<td class="sf_admin_date sf_admin_list_td_created_at">
<?php echo false !== strtotime($callback->getCreatedAt()) ? format_date($callback->getCreatedAt(), "g") : '&nbsp;' ?>
</td>
<?php $q = ($sf_request->hasParameter('q') && $sf_request->getParameter('q') != '' ? '&q=' . $sf_request->getParameter('q') : ''); ?>
<?php slot('sf_admin.current_header') ?>
<th class="sf_admin_text sf_admin_list_th_name">
<?php if ('name' == $sort[0]): ?>
<?php echo link_to(__('Имя', array(), 'messages'), '@callback', array('query_string' => 'sort=name&sort_type='.($sort[1] == 'asc' ? 'desc' : 'asc') . $q)) ?>
<?php echo ($sort[1] == 'asc' ? '▼' : '▲');?>
<?php else: ?>
<?php echo link_to(__('Имя', array(), 'messages'), '@callback', array('query_string' => 'sort=name&sort_type=desc' . $q)) ?>
<?php endif; ?>
</th>
<?php end_slot(); ?>
<?php include_slot('sf_admin.current_header') ?><?php $q = ($sf_request->hasParameter('q') && $sf_request->getParameter('q') != '' ? '&q=' . $sf_request->getParameter('q') : ''); ?>
<?php slot('sf_admin.current_header') ?>
<th class="sf_admin_text sf_admin_list_th_phone">
<?php if ('phone' == $sort[0]): ?>
<?php echo link_to(__('Телефон', array(), 'messages'), '@callback', array('query_string' => 'sort=phone&sort_type='.($sort[1] == 'asc' ? 'desc' : 'asc') . $q)) ?>
<?php echo ($sort[1] == 'asc' ? '▼' : '▲');?>
<?php else: ?>
<?php echo link_to(__('Телефон', array(), 'messages'), '@callback', array('query_string' => 'sort=phone&sort_type=desc' . $q)) ?>
<?php endif; ?>
</th>
<?php end_slot(); ?>
<?php include_slot('sf_admin.current_header') ?><?php $q = ($sf_request->hasParameter('q') && $sf_request->getParameter('q') != '' ? '&q=' . $sf_request->getParameter('q') : ''); ?>
<?php slot('sf_admin.current_header') ?>
<th class="sf_admin_boolean sf_admin_list_th_is_done">
<?php if ('is_done' == $sort[0]): ?>
<?php echo link_to(__('Позвонили', array(), 'messages'), '@callback', array('query_string' => 'sort=is_done&sort_type='.($sort[1] == 'asc' ? 'desc' : 'asc') . $q)) ?>
<?php echo ($sort[1] == 'asc' ? '▼' : '▲');?>
<?php else: ?>
<?php echo link_to(__('Позвонили', array(), 'messages'), '@callback', array('query_string' => 'sort=is_done&sort_type=desc' . $q)) ?>
<?php endif; ?>
</th>
<?php end_slot(); ?>
<?php
if ($tab == '1') {
include_slot('sf_admin.current_header') ?><?php $q = ($sf_request->hasParameter('q') && $sf_request->getParameter('q') != '' ? '&q=' . $sf_request->getParameter('q') : ''); ?>
<?php slot('sf_admin.current_header') ?>
<th class="sf_admin_text sf_admin_list_th_offer_id">
<?php if ('offer_id' == $sort[0]): ?>
<?php echo link_to(__('Товар', array(), 'messages'), '@callback', array('query_string' => 'sort=offer_id&sort_type=' . ($sort[1] == 'asc' ? 'desc' : 'asc') . $q)) ?>
<?php echo($sort[1] == 'asc' ? '▼' : '▲'); ?>
<?php else: ?>
<?php echo link_to(__('Товар', array(), 'messages'), '@callback', array('query_string' => 'sort=offer_id&sort_type=desc' . $q)) ?>
<?php endif; ?>
</th>
<?php end_slot();
}?>
<?php include_slot('sf_admin.current_header') ?><?php $q = ($sf_request->hasParameter('q') && $sf_request->getParameter('q') != '' ? '&q=' . $sf_request->getParameter('q') : ''); ?>
<?php slot('sf_admin.current_header') ?>
<th class="sf_admin_date sf_admin_list_th_created_at">
<?php if ('created_at' == $sort[0]): ?>
<?php echo link_to(__('Дата', array(), 'messages'), '@callback', array('query_string' => 'sort=created_at&sort_type='.($sort[1] == 'asc' ? 'desc' : 'asc') . $q)) ?>
<?php echo ($sort[1] == 'asc' ? '▼' : '▲');?>
<?php else: ?>
<?php echo link_to(__('Дата', array(), 'messages'), '@callback', array('query_string' => 'sort=created_at&sort_type=desc' . $q)) ?>
<?php endif; ?>
</th>
<?php end_slot(); ?>
<?php include_slot('sf_admin.current_header') ?>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: yakov
* Date: 27.03.18
* Time: 16:09
*/
if ($callback->getOfferId() != null) {
$q = Doctrine_Query::create()
->select('p.*, o.*, ot.*')
->from('Product p')
->leftJoin('p.Offer o WITH o.product_id = p.id')
->where('o.id = ?', $callback->getOfferId())
->leftJoin('o.Translation ot WITH ot.lang = \'ru\'')
->fetchArray();
echo '<a class="blank_product" href="/ru/product/' . $q[0]['alias'] . '/">' . $q[0]['Offer'][0]['Translation']['ru']['title'] . '</a>';
}
<?php use_helper('I18N', 'Date') ?>
<?php if (!$sf_request->isXmlHttpRequest()): ?>
<?php include_partial('callback/assets') ?>
<span class="lui__h1"><?php echo __('Обратный звонок', array(), 'messages') ?></span><sup
class="lui__list_count">&nbsp;<?php echo ($sf_request->getParameter('q') ? 'найдено:&nbsp;' : '');?><?php echo isset($pager) ? $pager->getNbResults() : ''; ?>&nbsp;</sup>
<?php include_partial('callback/flashes') ?>
<div class="sf_admin_tabs">
<?php
foreach($tabs as $tab_key => $tab_val)
{
echo '<a href="' . (isset($tab_val['url_for']) ? url_for($tab_val['url_for']) : '?tab=' . $tab_key) . '" class="sf_admin_tab' . ($tab_key == $current_tab ? ' sf_admin_tab__active' : '') . '">' . $tab_val['label'] . '</a>';
}
?>
</div>
<span class="br15"></span>
<div class="batch_form__class">
<?php endif; ?>
<?php if (isset($pager)): ?>
<div class="lui__list_actions__wrapper" data-count="<?php echo $pager->getNbResults();?>">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<?php include_partial('callback/list_actions', array('helper' => $helper)) ?>
<?php include_partial('callback/list_batch_actions', array('helper' => $helper)) ?>
<td style="padding-right: 10px"><input style="background-color:#fff;width:360px;" type="text" autocomplete="off" value="<?php echo $sf_request->getParameter('q'); ?>"
class="type_search input_with_erase" id="callback_live_search" placeholder="Найти"/>
</td>
<?php if ($pager->haveToPaginate()): ?>
<td align="right" width="100%">
<div class="lui_pager">
<?php include_partial('callback/pagination', array('pager' => $pager)) ?>&nbsp;
<b style="position:relative;top:2px"><?php echo __('%%page%%/%%nb_pages%%', array('%%page%%' => $pager->getPage(), '%%nb_pages%%' => $pager->getLastPage()), 'sf_admin') ?></b>
</div>
</td>
<?php endif; ?>
</tr>
</table>
</div>
<form id="batch_form" action="<?php echo url_for('callback_collection', array('action' => 'batch')) ?>" method="post">
<div id="lui_scroller" class="lui_scroller">
<div class="lui__scroller_wrapper"><?php include_partial('callback/list', array('pager' => $pager, 'sort' => $sort, 'helper' => $helper, 'tab' => $tab)) ?></div>
</div>
<input type="hidden" name="batch_action" id="batch_action_id"/>
<?php $form = new BaseForm(); if ($form->isCSRFProtected()): ?>
<input type="hidden" name="<?php echo $form->getCSRFFieldName() ?>" value="<?php echo $form->getCSRFToken() ?>"/>
<?php endif; ?>
</form>
<?php endif; ?>
<?php if (!$sf_request->isXmlHttpRequest()): ?>
</div>
<?php if (isset($pager)): ?>
<script type="text/javascript">
var jqxhr = false;
var jqxhr_o = false;
var jqxhr_old = $('#callback_live_search').val().trim();
var jqxhr_last_result = $('#callback_live_search').val().trim();
var is_not_good_style_of_code = function (url) {
var state = {
title: $('title').html(),
url: window.location.pathname + url
}
history.pushState(state, state.title, state.url);
jqxhr_o = sOverlay($('.lui_scroller'));
jqxhr = $.ajax(url).done(function (html) {
var new_html = $(html);
$('.lui_pager').html(new_html.find('.lui_pager').length > 0 ? new_html.find('.lui_pager').html() : '');
$('.lui__scroller_wrapper').html(new_html.find('.lui__scroller_wrapper').html());
create_custom_table_head();
$('.lui__list_count').html('&nbsp;' + (jqxhr_old == '' ? '' : 'найдено:&nbsp;') + new_html.data('count'));
$('.lui__list_table__sourse').removeHighlight().highlight(jqxhr_old);
$('.export_excel').prop('href', url + '&export');
if (new_html.data('count') == '0') {
$('.export_excel').hide();
} else {
$('.export_excel').show();
}
jqxhr_last_result = $('#callback_live_search').val().trim();
jqxhr_o.remove();
});
}
$(document).ready(function () {
$('#callback_live_search').keyup(function (event) {
if (jqxhr_last_result == $(this).val().trim()) {
return;
}
var checked = [];
$('.sf_admin_batch_checkbox:checked').each(function (k, v) {
checked.push($(v).val());
});
jqxhr_old = $(this).val().trim();
try {
jqxhr.abort();
jqxhr_o.remove();
} catch (e) {
}
if ($(this).val().trim() != '' && event.which == 13) {
is_not_good_style_of_code('?q=' + jqxhr_old + (checked.length > 0 ? '&checked=' + checked.join(':') : ''));
} else if ($(this).val().trim() == '') {
is_not_good_style_of_code(checked.length > 0 ? '?checked=' + checked.join(':') : '');
}
});
if (jqxhr_old != '') {
cl(jqxhr_old);
$('.lui__list_table__sourse').removeHighlight().highlight(jqxhr_old);
}
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php if (isset($replace_content) && $replace_content !== false): ?>
<?php echo htmlspecialchars_decode($replace_content); ?>
<?php endif; ?>
\ No newline at end of file
<?php
require_once dirname(__FILE__).'/../lib/catGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/catGeneratorHelper.class.php';
/**
* cat actions.
*
* @package sf
* @subpackage cat
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class catActions extends autoCatActions
{
static public $parentId = null;
public function executeDelete(sfWebRequest $request)
{
$this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject())));
$cat = $this->getRoute()->getObject();
$children_count = Doctrine_Query::create()
->from("Cat")
->where("parent_id = ?", $cat->getId())
->count();
$product_count = Doctrine_Query::create()
->from("Product p")
->innerJoin("p.Cats c")
->where("c.id = ?", $cat->getId())
->count();
if($children_count == 0 && $product_count == 0){
$cat->delete();
echo 'ok';
}else{
echo 'no';
}
return sfView::NONE;
}
protected function buildQuery()
{
$query = parent::buildQuery();
$query->leftJoin("r.Translation t");
$query->andWhere("r.parent_id IS NULL");
return $query;
}
public function executeUpdate(sfWebRequest $request)
{
parent::executeUpdate($request);
return sfView::NONE;
}
public function executeCreate(sfWebRequest $request)
{
parent::executeCreate($request);
return sfView::NONE;
}
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
try
{
$cat = $form->save();
echo $this->getPartial('cat/struct_form', array('form' => new CatForm($cat), 'parent_id' => Cat::$parentId, 'link' => '/arm/cat' . ($cat ? '/' . $cat->getId() : '')));
return sfView::NONE;
}
catch (Doctrine_Validator_Exception $e)
{
$errorStack = $form->getObject()->getErrorStack();
return sfView::NONE;
}
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $cat)));
}
echo $this->getPartial('cat/struct_form', array('form' => $form, 'parent_id' => Cat::$parentId, 'link' => '/arm/cat' . ($this->cat && $this->cat->getId() ? '/' . $this->cat->getId() : '')));
}
public function executeStruct(sfWebRequest $request)
{
if(strpos($request->getPathInfo(), 'Blank') !== false){
$type = false;
foreach (array('cat', 'product', 'offer') as $t){
if(strpos($request->getParameter('Id'), $t) !== false){
$type = $t;
break;
}
}
if(!$type){
$type = 'cat';
if($request->getParameter('object_Group') == 1){
$type = 'product';
}elseif($request->getParameter('object_Group') == 3){
$type = 'offer';
}
}
if($type){
$id = str_replace(array('cat', 'product', 'offer', '_'), '', $request->getParameter('Id'));
if($type == 'cat'){
$cat = ($id ? Doctrine::getTable("Cat")->find($id) : null);
$form = new CatForm($cat, array('struct' => true));
}elseif($type == 'product'){
$product = ($id ? Doctrine::getTable("Product")->find($id) : null);
$form = new ProductForm($product, array('struct' => true));
}elseif($type == 'offer'){
$offer = ($id ? Doctrine::getTable("Offer")->find($id) : null);
$form = new OfferForm($offer);
}
Cat::$parentId = $request->getParameter('parentId');
echo $this->getPartial('struct_form', array('link' => '/arm/' . $type . ($id ? '/' . $id : ''), 'parent_id' => Cat::$parentId, 'form' => $form));
}
}elseif(strpos($request->getPathInfo(), 'List') !== false){
$id = str_replace(array('cat', 'product', 'offer', '_'), '', $request->getParameter('parentId'));
if($id && is_numeric($id)){
if(strpos($request->getParameter('parentId'), 'cat') !== false){
$cats = Doctrine_Query::create()
->select("c.id, c.parent_id, t.*")
->from("Cat c")
->innerJoin("c.Translation t")
->where("c.parent_id = ?", $id)
->orderBy("c.sort ASC")
->fetchArray();
$products = Doctrine_Query::create()
->select("p.id, p.is_delete, t.title, t.lang")
->from("Product p")
->innerJoin("p.Translation t")
->innerJoin("p.CatProduct c")
->where("c.cat_id = ?", $id)
->andWhere("p.is_delete = 0")
->orderBy("p.sort ASC")
->fetchArray();
echo $this->getPartial('struct', array('results' => array('cat' => $cats, 'product' => $products)));
}elseif(strpos($request->getParameter('parentId'), 'product') !== false){
$product = Doctrine::getTable("Product")->find($id);
$offers = Doctrine_Query::create()
->select("o.id, o.product_id, o.is_delete, t.lang, t.title, ")
->from("Offer o")
->innerJoin("o.Translation t")
->where("o.product_id = ?", $id)
->andWhere("o.is_delete = 0")
->orderBy("o.sort ASC")
->fetchArray();
echo $this->getPartial('struct', array('results' => array('offer' => $offers), 'is_detail' => ($product && $product->getIsDetail())));
}
}else{
$cats = Doctrine_Query::create()
->select("c.id, c.parent_id, t.*")
->from("Cat c")
->innerJoin("c.Translation t")
->where("c.parent_id IS NULL")
->orderBy("c.sort ASC")
->fetchArray();
echo $this->getPartial('struct', array('results' => array('cat' => $cats)));
}
}
return sfView::NONE;
}
public function executeSort(sfWebRequest $request)
{
$array = explode(',', $request->getParameter('SetSort'));
$ids = array();
foreach ($array as $key => $item)
{
$table = preg_replace("/[^a-z]/", '', $item);
$ids[$key] = preg_replace("/[^0-9]/", '', $item);
if ($table == 'offer')
{
Doctrine_Query::create()
->update($table)
->set("sort", intval($key))
->where("id = ?", intval($ids[$key]))
->execute();
}else
{
Doctrine::getTable($table)->findOneById(intval($ids[$key]))->setSort(intval($key))->save();
}
}
return sfView::NONE;
}
public function executeIndex(sfWebRequest $request)
{
// sorting
if ($request->getParameter('sort') && $this->isValidSortColumn($request->getParameter('sort')))
{
print_r($request->getParameter('sort'));
die();
$this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
}
// pager
if ($request->getParameter('page'))
{
$this->setPage($request->getParameter('page'));
}
else
{
$this->setPage(1);
}
//search
if ($request->getParameter('q'))
{
$this->setSearch($request->getParameter('q'), ($request->hasParameter('checked') ? $request->getParameter('checked') : false));
}
else
{
$this->setSearch(false);
}
//checked
if ($request->getParameter('checked'))
{
$this->setChecked($request->getParameter('checked'));
}
else
{
$this->setChecked(false);
}
$this->pager = $this->getPager($request);
$this->sort = $this->setSort(array(
0 => 'sort',
1 => 'ASC'
));
if($request->hasParameter('export'))
{
require_once sfConfig::get('sf_lib_dir') . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->setActiveSheetIndex(0);
$sheet->setCellValue('A1', 'Название');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('A1')->applyFromArray($styleArray);
$sheet->setCellValue('B1', 'Алиас');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('B1')->applyFromArray($styleArray);
$sheet->setCellValue('C1', 'Родительская категория');
$styleArray = array(
'font' => array(
'bold' => true,
)
);
$sheet->getStyle('C1')->applyFromArray($styleArray);
foreach ($this->pager->getResults() as $i => $cat)
{
$value = '';
ob_start();
ob_implicit_flush(0);
try
{
require(sfConfig::get('sf_app_module_dir') . '/cat/templates/_title.php');
}
catch (Exception $e)
{
ob_end_clean();
throw $e;
}
$value = ob_get_clean();
$sheet->setCellValue('A' . ($i + 2), $value);
$sheet->getColumnDimension('A')->setAutoSize(true);
$value = '';
$method = 'getAlias';
if(is_callable(array($cat, 'getAlias')))
{
$method = $cat->$method();
if(is_object($method) && count($method) > 0)
{
$value = $method->__toString();
}
else
{
$value = $method;
}
}
$sheet->setCellValue('B' . ($i + 2), $value);
$sheet->getColumnDimension('B')->setAutoSize(true);
$value = '';
ob_start();
ob_implicit_flush(0);
try
{
require(sfConfig::get('sf_app_module_dir') . '/cat/templates/_parent_id.php');
}
catch (Exception $e)
{
ob_end_clean();
throw $e;
}
$value = ob_get_clean();
$sheet->setCellValue('C' . ($i + 2), $value);
$sheet->getColumnDimension('C')->setAutoSize(true);
}
$sheet->setAutoFilter('A1:C' . $i);
$sheet->setTitle('Каталог');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$uuid = Page::generateUuid();
$objWriter->save('php://output');
$this->getResponse()->setHttpHeader('Content-type', 'application/octet-stream');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="Каталог.xlsx"');
return sfView::NONE;
}
}
}
generator:
class: sfDoctrineGenerator
param:
model_class: Cat
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: cat
with_doctrine_route: true
actions_base_class: sfActions
order: 10
config:
actions: ~
fields:
title: {label: 'Название'}
title_ru: {label: 'Название RU'}
title_en: {label: 'Название EN'}
alias: {label: 'Алиас'}
parent_id: {label: 'Родительская категория'}
photo: {label: 'Изображение'}
list:
layout: ~
title: 'Каталог'
display: [_title, alias, _parent_id]
max_per_page: 100
object_actions:
_delete: ~
_edit: ~
search:
fields: false
export: false
filter:
class: false
form: ~
edit:
title: Редактирование
new:
title: Добавление
\ No newline at end of file
<?php
/**
* cat module configuration.
*
* @package sf
* @subpackage cat
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class catGeneratorConfiguration extends BaseCatGeneratorConfiguration
{
}
<?php
/**
* cat module helper.
*
* @package sf
* @subpackage cat
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class catGeneratorHelper extends BaseCatGeneratorHelper
{
}
<?php if ($field->isPartial()): ?>
<?php include_partial('cat/'.$name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php elseif ($field->isComponent()): ?>
<?php include_component('cat', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php else: ?>
<div class="<?php echo $class ?><?php $form[$name]->hasError() and print ' errors' ?>">
<div>
<?php $opts = $form[$name]->getWidget()->getOptions(); ?>
<?php if (key_exists('type', $opts) && $opts['type'] == 'checkbox'): ?>
<div class="content"><label><?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes); ?><?php echo $label; ?></label></div>
<?php else: ?>
<span class="inline-label"><?php echo $form[$name]->renderLabel($label) ?></span>
<div class="content">
<?php echo $name == 'alias' ? 'catalog/' : ''; ?>
<?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?>
<?php echo $name == 'alias' ? '/' : ''; ?>
<?php echo $form[$name]->renderError() ?>
<?php if ($help): ?><span class="help"><?php echo __($help, array(), 'messages') ?></span><?php elseif ($help = $form[$name]->renderHelp()): ?><span class="help"><?php echo strip_tags($help, '<a><i>') ?></span><?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
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