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

first

parents
<?php
/**
* user module helper.
*
* @package sf
* @subpackage user
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class userGeneratorHelper extends BaseUserGeneratorHelper
{
}
<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<?php echo form_tag_for($form, '@user') ?>
<div id="lui_scroller" class="lui__scroller_class">
<div class="lui__scroller_wrapper" style="position:relative;z-index:102;padding-left:10px;">
<?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?>
<?php include_partial('user/form_fieldset', array('user' => $user, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?>
<?php endforeach; ?>
<?php
$user = $form->getObject();
if (!$user->isNew())
{
if (!empty($user['current_discount']))
{
$discount = round($user['current_discount']) . '%';
echo 'Текущая скидка: <b>' . $discount . '</b>.<br />';
}
$salesPr = $user->getProductDiscount();
if (($salesPr[0]->getProductCode()) !== null)
{
//echo 'Дополнительные скидки по продуктам';
echo ' <table class="lui__list_table lui__list_table_donor lui__list_table__sourse" cellspacing="0">
<th class = "" style="border_bottom: 1px solid black; vertical-align:middle; width:400px;">
Товар
</th>
<th>
Код
</th>
<th>
Скидка
</th>
';
foreach ($salesPr as $product)
{
echo '<tr style="vertical-align:middle;">';
echo '<td>' . $product->getTitle() . '</td>';
echo '<td>' . $product->getProductCode() . '</td>';
echo '<td style="text-align:right;">' . (round($product->getDiscountValue()) . ' %') . '</td>';
echo '</tr>';
}
echo '</table>';
}
$supplier = $user->getClientDiscount();
if (($supplier[0]->getDiscountValue()) !== null)
{
//echo 'Дополнительные скидки по продуктам';
echo ' <table class="lui__list_table lui__list_table_donor lui__list_table__sourse" cellspacing="0">
<th class = "" style="border_bottom: 1px solid black; vertical-align:middle; width:400px;">
ИНН поставщика
</th>
<th>
Скидка
</th>
';
foreach ($supplier as $discount)
{
echo '<tr style="vertical-align:middle;">';
echo '<td>' . $discount->getInnSupplier() . '</td>';
echo '<td style="text-align:right;">' . (round($discount->getDiscountValue()) . ' %') . '</td>';
echo '</tr>';
}
echo '</table>';
}
echo '<p>Долг: <b>' .( ($user->getCurrentDebt() == '')? 0 : $user->getCurrentDebt()) . '</b> руб.</p><br/>';
$debt = $user->getDebt();
$month = array(
'01' => 'января',
'02' => 'февраля',
'03' => 'марта',
'04' => 'апреля',
'05' => 'мая',
'06' => 'июня',
'07' => 'июля',
'08' => 'августа',
'09' => 'сентября',
'10' => 'октября',
'11' => 'ноября',
'12' => 'декабря'
);
if ($debt[0]->getDebtSum() !== null)
{
echo ' <table class="lui__list_table lui__list_table_donor lui__list_table__sourse" cellspacing="0">
<th style="text-align:center; width:100px;">
Сумма
</th>
<th style="text-align:center; width:150px;">
Крайний срок
</th>
';
foreach ($debt as $detail)
{
$deadline = $detail->getDeadline();
$deadline = array_reverse(explode('-', $deadline));
$deadline[1] = $month[$deadline[1]];
$deadline[2] = $deadline[2] . ' г.';
$deadline = implode(' ', $deadline);
echo '<tr style="vertical-align:middle;">';
echo '<td style="text-align:right;">' . $detail->getDebtSum() . '</td>';
echo '<td style="text-align:right;">' . $deadline . '</td>';
echo '</tr>';
}
echo '</table>';
}
if (!empty($user['limit_by_sum']))
{
$sum_limit = $user['limit_by_sum'];
if ($sum_limit == 'Неограниченно')
{
echo '<p>Лимит по сумме: <b>' . $sum_limit . '</b>.</p><br />';
}
else
{
echo '<p>Лимит по сумме: <b>' . $sum_limit . '</b> руб.</p><br />';
}
}
}
?>
<span class="br10"></span>
<div class="lui__list_actions__wrapper">
<?php include_partial('user/form_actions', array('user' => $user, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
</div>
<span class="br30"></span>
</div>
</div>
</form>
<?php
$discount = $user->getCurrentDiscount();
//->getAccount()->getCurrentDiscount()
if ($discount != '')
{
/* print_r($q);
die();*/
echo ($discount) . '%';
}
else
{
echo '0%';
}
?>
\ No newline at end of file
<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<?php echo form_tag_for($form, '@user') ?>
<div id="lui_scroller" class="lui__scroller_class">
<div class="lui__scroller_wrapper" style="position:relative;z-index:102;padding-left:10px;">
<?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?>
<?php include_partial('user/form_fieldset', array('user' => $user, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset, 'history' => $history)) ?>
<?php endforeach; ?>
<span class="br30"></span>
</div>
</div>
<?php
$return = url_for('user/index');
if($sf_request->hasParameter('return'))
{
$return = $sf_request->getParameter('return');
}
elseif($sf_request->getReferer() != '' && strpos($sf_request->getReferer(), $sf_request->getUri()) === false)
{
$return = $sf_request->getReferer();
}
?>
<input type="hidden" name="return" value="<?php echo $return;?>" />
</form>
<ul class="sf_admin_actions sf_admin_actions__pseudo">
<?php
if($sf_user->hasCredential('user_create'))
{
?>
<?php if ($form->isNew()): ?>
<?php echo $helper->linkToDelete($form->getObject(), array( 'params' => array( ), 'confirm' => 'Are you sure?', 'class_suffix' => 'delete', 'label' => 'Delete',)) ?>
<?php echo $helper->linkToList(array( 'params' => array( ), 'class_suffix' => 'list', 'label' => 'Back to list',)) ?>
<?php echo $helper->linkToSave($form->getObject(), array( 'params' => array( ), 'class_suffix' => 'save', 'label' => 'Save',)) ?>
<?php echo $helper->linkToSaveAndAdd($form->getObject(), array( 'params' => array( ), 'class_suffix' => 'save_and_add', 'label' => 'Save and add',)) ?>
<?php echo $helper->linkToSaveAndList($form->getObject(), array( 'params' => array( ), 'class_suffix' => 'save_and_list', 'label' => 'Save and list',)) ?>
<?php else: ?>
<?php echo $helper->linkToDelete($form->getObject(), array( 'params' => array( ), 'confirm' => 'Are you sure?', 'class_suffix' => 'delete', 'label' => 'Delete',)) ?>
<?php echo $helper->linkToList(array( 'params' => array( ), 'class_suffix' => 'list', 'label' => 'Back to list',)) ?>
<?php echo $helper->linkToSave($form->getObject(), array( 'params' => array( ), 'class_suffix' => 'save', 'label' => 'Save',)) ?>
<?php echo $helper->linkToSaveAndAdd($form->getObject(), array( 'params' => array( ), 'class_suffix' => 'save_and_add', 'label' => 'Save and add',)) ?>
<?php echo $helper->linkToSaveAndList($form->getObject(), array( 'params' => array( ), 'class_suffix' => 'save_and_list', 'label' => 'Save and list',)) ?>
<li class="sf_admin_action_save" id="_send_password_id"><input value="Отправить пароль" type="submit" name="_send_password"></li>
<?php endif; ?>
<?php
}
?>
</ul>
<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('user/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,
)) ?>
<?php endforeach; ?>
<?php include_partial('user/form_fieldset_footer', array('form' => $form, 'history' => $history)) ?>
</fieldset>
<?php
if(count($history) > 0)
{
echo "<p><b>История заказов:</b></p>";
foreach ($history as $order)
{
echo "<a href='" . url_for('@client_order_edit?id=' . $order->getId()) . "'>Заказ №" . $order->getId() . " от " . $order->getCreatedAt() . "</a>";
echo "<i class='br5'></i>";
}
}
\ No newline at end of file
<script type="text/javascript">
<?php
?>
if($('#user_password').val() != ''){
$('#user_password').val('<?php echo $user->getOpenPassword();?>');
//$('#user_password').prop('placeholder', 'Скрыт');
}
var check_email = function(){
$('#_send_password_id').css('visibility', ($('#user_email').val().indexOf('@') != -1 ? 'visible' : 'hidden'));
}
check_email();
$('#_send_password_id input').click(function(){
$('.lui_form_layer form').append('<input type="hidden" name="_send_password" value="1" />');
});
$('#user_email').keyup(function(){
check_email();
});
var gen_pass_btn = $('<button style="position:relative;left:5px;top:-1px;">Сгенерировать</button>');
$('#user_password').after(gen_pass_btn);
gen_pass_btn.click(function(){
$('#user_password').val(PassGenJS.getPassword({letters: 0, lettersUpper: 0, numbers: 6}));
return false;
});
</script>
\ No newline at end of file
<?php
echo 'Ваш логин: ' . $user->getUsername();
echo "\n";
echo 'Пароль: ' . $user->getOpenPassword();
echo "\n";
echo '--------------------------------';
echo "\n";
echo $host;
?>
\ No newline at end of file
<?php
$id = $user->getId();
$q = Doctrine_Query::create()
->select('d.debt_sum')
->from('Debt d')
->where('d.user_id=?', $id)
->andWhere('d.deadline < NOW()')
->execute();
$overdue_sum = 0;
foreach ($q as $row)
{
$overdue_sum += $row['debt_sum'];
}
echo $overdue_sum;
?>
\ No newline at end of file
<?php
$id = $user->getId();
$q = Doctrine_Query::create()
->select('d.debt_sum')
->from('Debt d')
->where('d.user_id=?', $id)
->execute();
//print_r($user);
$total_sum = 0;
foreach ($q as $row)
{
$total_sum += $row['debt_sum'];
/*print_r($row['debt_sum']);*/
}
echo $total_sum;
//echo $q->getDiscountValue() . ' %';
?>
\ No newline at end of file
<?php
$inn = $user->getUsername();
if (empty($inn))
{
$inn = '';
}
echo $inn;
?>
\ No newline at end of file
<?php use_helper('I18N', 'Date') ?>
<?php include_partial('user/assets') ?>
<?php if (!$sf_request->isXmlHttpRequest()): ?>
<?php
$return = url_for('user/index');
if($sf_request->hasParameter('return'))
{
$return = $sf_request->getParameter('return');
}
elseif($sf_request->getReferer() != '' && strpos($sf_request->getReferer(), $sf_request->getUri()) === false)
{
$return = $sf_request->getReferer();
}
?>
<div class="lui_form_layer"><a href="<?php echo $return;?>" class="lui_form_layer__close anb"></a>
<?php endif; ?>
<span class="lui__h1"><?php echo __('Редактирование', array(), 'messages') ?></span>
<i class="br15 hidden_element"></i>
<div class="lui__list_actions__wrapper">
<?php include_partial('user/form_actions', array('user' => $user, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
</div>
<?php include_partial('user/flashes') ?>
<?php if ($form->hasGlobalErrors()): ?>
<?php echo $form->renderGlobalErrors() ?>
<?php endif; ?>
<?php include_partial('user/form', array('user' => $user, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper, 'history' => $history)) ?>
<?php include_partial('user/form_footer', array('user' => $user, 'form' => $form, 'configuration' => $configuration)) ?>
<?php if (!$sf_request->isXmlHttpRequest()): ?>
</div>
<?php endif; ?>
\ No newline at end of file
<?php
require_once dirname(__FILE__).'/../lib/videoGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/videoGeneratorHelper.class.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 autoVideoActions
{
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
try
{
$video = $form->save();
$video_custom = $request->getParameter('video_custom');
if(count($video_custom['tags']) > 0)
{
foreach($video_custom['tags'] as $tag_id)
{
$newProductTags = new VideoTags();
$newProductTags->setVideoId($video->getId());
$newProductTags->setTagId($tag_id);
$newProductTags->save();
}
}
}
catch (Doctrine_Validator_Exception $e)
{
$errorStack = $form->getObject()->getErrorStack();
$message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
foreach ($errorStack as $field => $errors)
{
$message .= "$field (" . implode(", ", $errors) . "), ";
}
$message = trim($message, ', ');
$this->getUser()->setFlash('error', $message);
return sfView::SUCCESS;
}
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $video)));
if ($request->hasParameter('_save_and_add'))
{
$this->getUser()->setFlash('notice', $notice.' You can add another one below.');
$this->redirect('@video_new');
}
elseif ($request->hasParameter('_save_and_list'))
{
$this->redirect('@video');
}
else
{
if(!$request->isXmlHttpRequest())
{
$this->getUser()->setFlash('notice', $notice);
$this->redirect($request->hasParameter('return') ? $request->getParameter('return') : array('sf_route' => 'video_edit', 'sf_subject' => $video));
}
}
}
else
{
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
$this->getResponse()->addHttpMeta('Sf-Form-Error', '1', true);
}
}
public function executeGdata(sfWebRequest $request)
{
if($request->getParameter('type') == 'youtube')
{
$ch = curl_init('https://www.googleapis.com/youtube/v3/videos?id=' . $request->getParameter("id") . '&key=AIzaSyACY3IFamw5LkQFiIVww38beV7O7_oHNhM&part=snippet');
curl_setopt($ch, CURLOPT_USERAGENT, 'IE20');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1');
$text = curl_exec($ch);
$json = json_decode($text, true);
if(is_array($json))
{
$ch = curl_init($json['items'][0]['snippet']['thumbnails']['high']['url']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$content = curl_exec($ch);
curl_close($ch);
if (file_exists('../upload/' . $request->getParameter('id') . '.jpg')) {
unlink('../upload/' . $request->getParameter('id') . '.jpg');
}
$fp = fopen('../upload/' . $request->getParameter('id') . '.jpg','x');
fwrite($fp, $content);
fclose($fp);
$request->setParameter('key', 'video_yt');
$request->setParameter('file', $request->getParameter('id') . '.jpg');
$resize = Page::resize($request, true);
echo json_encode(array('title' => $json['items'][0]['snippet']['title'], 'image' => $resize));
}
}
elseif($request->getParameter('type') == 'vk')
{
$ch = curl_init('https://vk.com/video_ext.php?' . str_replace(array(':', ';'), array('=', '&'), $request->getParameter('id')));
curl_setopt($ch, CURLOPT_USERAGENT, 'IE20');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1');
$page = curl_exec($ch);
preg_match('/<video id="video_player" poster="(.*)" preload="none"/', $page, $matches);
$ch = curl_init($matches[1]);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$content = curl_exec($ch);
curl_close($ch);
if (file_exists('../upload/' . $request->getParameter('id') . '.jpg')) {
unlink('../upload/' . $request->getParameter('id') . '.jpg');
}
$fp = fopen('../upload/' . $request->getParameter('id') . '.jpg','x');
fwrite($fp, $content);
fclose($fp);
$request->setParameter('key', 'video_yt');
$request->setParameter('file', $request->getParameter('id') . '.jpg');
$resize = Page::resize($request, true);
//preg_match('/var video_title = \'(.*)\';/', $page, $matches);
echo json_encode(array('image' => $resize));
}
return sfView::NONE;
}
protected function buildQuery()
{
$query = parent::buildQuery();
$query->leftJoin("r.Translation t");
return $query;
}
}
generator:
class: sfDoctrineGenerator
param:
model_class: Video
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: video
with_doctrine_route: true
actions_base_class: sfActions
order: 60
config:
actions: ~
fields:
id: {label: ''}
title: {label: 'Название'}
title_ru: {label: 'Название RU'}
title_en: {label: 'Название EN'}
vid: {label: 'Ссылка на YouTube'}
cover: {label: 'Обложка'}
created_at: {label: 'Дата создания'}
tags_list: {label: 'Теги'}
list:
layout: ~
title: 'Видео'
display: [_title, _cover]
max_per_page: 100
object_actions:
_delete: ~
_edit: ~
search:
fields: [title]
export: false
filter:
class: false
form: ~
edit:
title: Редактирование видео
new:
title: Добавление видео
\ No newline at end of file
<?php
/**
* video module configuration.
*
* @package sf
* @subpackage video
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class videoGeneratorConfiguration extends BaseVideoGeneratorConfiguration
{
}
<?php
/**
* video module helper.
*
* @package sf
* @subpackage video
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class videoGeneratorHelper extends BaseVideoGeneratorHelper
{
}
<?php
include_partial('main/image', array('image' => $video->getCover(), 'type' => 'fotorama', 'id' => $video->getId()));
?>
<script type="text/javascript">
var videoInp = $('#video_vid');
videoInp.on("change", function(){
console.log('change');
if (videoInp.data("value") != videoInp.val() || videoInp.val().indexOf("https://") != -1) {
var id = videoInp.val().replace("https://www.youtube.com/watch?v=", "").replace("https://youtu.be/", "").split("?");
if (id[0].length == 0) {
return;
}
var p = sOverlay($("#lui_scroller"));
$.getJSON('https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&id=' + id[0] + '&key=AIzaSyBNZlUiTOGWeTzZL58mgL7MWFReluzbQM0', function(data){
videoInp.data("value", videoInp.val());
if (data.items != undefined && data.items.length) {
$.each(data.items, function(k, item) {
var snippet = item.snippet;
$('.lui_tab_links__item__ru input[type="checkbox"]').click();
$("#video_ru_title").val(snippet.title);
$.getJSON(sf_prefix + "/uploader?key=video&url=" + snippet.thumbnails.standard.url, function(response) {
var div = '<div class="uploader_preview__item test_item" data-val="' + response.filename + '"><span title="Удалить файл" class="uploader_preview__item_close" onclick="$(this).parent().remove();liteUploader_updateVal_news_events_image_(event);">×</span>' + response.preview.replace('<img', '<img onclick="ftm.init(\'item\', this);" height="100"') + '</div>';
$('#video_cover___uploader_preview').html(div).show();
$('#video_cover_').val(response.filename);
});
});
}
});
}
});
</script>
\ 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