Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use \Functions\Functions;
- $incomes = new CasesIncomes();
- $incomes = $incomes->data;
- ?>
- <h2>Предметы на складе (Цены: 100% от площадки Steam)</h2>
- <div class="row" id="stock">
- <?php
- $paid_for_skins_total = 0;
- foreach ($model->cases as $key => $case):
- if (count($case['items']) == 0) continue;
- $income = $incomes[$case['id']];
- ?>
- <form method="POST" action="">
- <div class="row case">
- <input type="hidden" name="case_id" value="<?=$case['id']?>">
- <div class="col-lg-22">
- <h2 id="<?=$case['static_name']?>"><button class="items-toggler"> - </button> <?=$case['name_en']?> - $<?=$case['price_usd']?> USD
- <span class="case-info">[Предметов в кейсе: <div class="case-items-count inline-div"><?=$case['current_count']?></div>, маржа: <div class="case-percentage inline-div"><?=Functions::format_number($income['percentage'])?></div>%]</span>
- </h2>
- <div class="items">
- <?php foreach ($case['items'] as $key => $item): ?>
- <?php
- $paid_for_skins_total += $item['price']/* * 0.8*/;
- //$item_data = $case['case']->get_item_data($item['market_hash_name']);
- $item_data = array();
- ?>
- <div class="row item" style="font-size: 150%">
- <div class="col-lg-2 text-right item-count-div"><?=$item['count']?></div>
- <div class="col-lg-2 text-center">
- <div class="row">
- <img src="http://steamcommunity-a.akamaihd.net/economy/image/<?php echo $item['img']; ?>/64fx64f" title="<?php echo $item['firstname']; ?> | <?php echo $item['secondname']; ?>" alt="<?php echo $item['market_hash_name']; ?>" class="<?php echo $item['rarity']; ?>">
- </div>
- <div class="row price">
- $<?=Functions::format_number($item['price']/* * 0.8*/)?> USD
- </div>
- </div>
- <div class="col-lg-9 col-lg-push-1 text-left">
- <div class="row market_hash_name"><?php echo $item['market_hash_name']; ?></div>
- <!--
- <div class="row">В кейсе: <?=$item_data['cnt']?> шт. Шанс: <?=$item_data['percentage']?>%</div>
- -->
- </div>
- <div class="col-lg-6">
- <input type="number" min="0" max="<?=$item['count']?>" value=0 name="skins[<?=$item['market_hash_name']?>]"> <span class="select-all-label">Все</span>
- </div>
- </div>
- <?php endforeach; ?>
- <a href="#<?=$case['static_name']?>" class="a-top">В начало <?=$case['name_en']?></a>
- </div>
- </div>
- <div class="col-lg-8 to-case-box">
- <div class="row text-center">
- <button class="btn btn-primary btn-lg btn-to-case">Отправить в кейс</button>
- </div>
- <div class="row text-center">
- <span class="case-name" name="<?=$case['static_name']?>"><?=$case['name_en']?></span>
- </div>
- <?php if ($member_id->user_id == 1 || $member_id->user_id == 2): ?>
- <div class="row text-center">
- <a onclick="select_all(this); return false;" href="#">ALL</a>
- </div>
- <?php endif; ?>
- </div>
- </div>
- </form>
- <?php endforeach; ?>
- </div>
- <div class="paid_total_amount" style="margin: 30px 0">
- <div class="row">
- <div class="col-lg-30 text-center">
- <span style="font-size: 160%">Цена всех предметов на складе: $<?=Functions::format_number($paid_for_skins_total/* * 0.7*/)?> USD
- </span>
- </div>
- </div>
- </div>
- <div class="cases-bottom-list case">
- <div class="items">
- <?php foreach ($model->cases as $key => $case):?>
- <?php if (count($case['items']) == 0) continue; ?>
- <a href="#<?=$case['static_name']?>"><?=$case['name_en']?></a>
- <?php endforeach; ?>
- </div>
- <div style="padding:10px;">
- <button class="to_top btn btn-primary btn-lg" style="width:100%; margin-bottom:3px">Наверх</button>
- <button class="to_bot btn btn-primary btn-lg" style="width:100%">Вниз</button>
- <!--<button class="items-toggler btn btn-primary btn-lg">-</button>!-->
- </div>
- </div>
- <script>
- $( document ).ready(function() {
- function select_all(el) {
- var inputs = $(el).parent().parent().prev().find('input[type=number]');
- $(inputs).each(function(index, item) {
- $(item).val($(item).attr('max'));
- });
- }
- $('.select-all-label').on('click', function() {
- $(this).prev().val($(this).prev().attr('max'));
- });
- $('.btn-to-case').on('click', function() {
- var MAX_COUNT_TO_SEND = 10;
- var send_count = 1;
- $('#loading_bg').addClass('active');
- var form = $(this).closest('form');
- var prev_form = form.prev();
- var skins = [];
- var items = form.find('.items > .item');
- items.each(function(item) {
- if ($(this).find('input[type="number"]').val() > 0) {
- skins.push({'market_hash_name' : $(this).find('.market_hash_name').text(),
- 'count' : $(this).find('input[type="number"]').val()});
- }
- });
- var case_id = parseInt(form.find('input[name="case_id"]').val());
- var partsArr = [];
- var parts_count = Math.ceil(skins.length / MAX_COUNT_TO_SEND);
- //console.log('parts_count : ' + parts_count);
- //console.log('parts_count : ' + parts_count);
- partsArr = array_chunk(skins, MAX_COUNT_TO_SEND); // разбиваем массив на 10 частей
- partsArr.forEach(function(item, i, partsArr) {
- sendItems(item, case_id, parts_count);
- });
- return false;
- function sendItems(skins, case_id, _count, small_count) {
- $.ajax({
- url: '<?=$this->router->generate('stock_test')?>?drop_to_inventory',
- type: 'POST',
- dataType: 'json',
- data: {
- 'skins': skins,
- 'case_id': case_id,
- },
- success: function(data) {
- /*
- console.log('skins : ' + skins);
- console.log('i : ' + send_count);
- console.log('count : ' + _count);
- */
- $('#loading_bg p').text('Отправлено: ' + send_count + ' из ' + _count);
- form.find('.case-items-count').text(data.current_count);
- var items = form.find('.items > .item');
- form.find('.case-percentage').text(data.percentage);
- items.each(function() {
- var input = $(this).find('input[type="number"]');
- var count = input.val();
- var new_count = input.attr('max') - count;
- input.attr('max', new_count);
- $(this).find('.col-lg-2.text-right').text(new_count);
- input.val(0);
- var our_items = $('input[name="'+input.attr('name')+'"]');
- our_items.each(function(){
- $(this).attr('max', new_count);
- $(this).val(0);
- $(this).closest('.item').find('.item-count-div').text(new_count);
- if (new_count == 0)
- $(this).closest('.item').remove();
- var _form = $(this).closest('form');
- if (_form.find('.items > .item').length < 1) {
- _form.remove();
- $('.cases-bottom-list a[href="#'+_form.find('h2').attr('id')+'"]').remove();
- }
- });
- if (new_count == 0)
- $(this).remove();
- });
- if (form.find('.items > .item').length < 1) {
- form.remove();
- $('.cases-bottom-list a[href="#'+form.find('h2').attr('id')+'"]').remove();
- $("html, body").scrollTop(prev_form.find('h2').offset().top-60);
- }
- $("html, body").scrollTop(form.find('h2').offset().top-60);
- if (send_count == _count) {
- setTimeout(function() {
- $('#loading_bg').removeClass('active');
- $('#loading_bg p').text('');
- getNotification('send-item');
- }, 5000);
- }
- send_count++;
- },
- error: function(name, xhr) {
- alert('Unexpected error. Please check your console.');
- console.log(name, xhr);
- if (send_count == _count) {
- $('#loading_bg').removeClass('active');
- $('#loading_bg p').text('');
- }
- }
- });
- }
- });
- function array_chunk(input, size) {
- for(var x, i = 0, c = -1, l = input.length, n = []; i < l; i++) {
- (x = i % size) ? n[c][x] = input[i] : n[++c] = [input[i]];
- }
- return n;
- }
- });
- </script>
- <div class="notification_box success" id="notification-send-item-box">
- <div class="head">
- <i class="icon icon-success-white"></i>
- <h3>Готово!</h3>
- </div>
- <p>Предметы успешно отправлены в кейс</p>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement