Ejemplo n.º 1
0
function tzs_front_end_my_shipments_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $url = current_page_url();
    $page = current_page_number();
    $pp = TZS_RECORDS_PER_PAGE;
    $active = isset($_GET['active']) ? trim($_GET['active']) : '1';
    if ($user_id == 0) {
        ?>
        <div>Для просмотра необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
        <?php 
    } else {
        $sql = "SELECT COUNT(*) as cnt FROM " . TZS_SHIPMENT_TABLE . " WHERE user_id={$user_id} AND active={$active};";
        $res = $wpdb->get_row($sql);
        if (count($res) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить список грузов. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            $records = $res->cnt;
            $pages = ceil($records / $pp);
            if ($pages == 0) {
                $pages = 1;
            }
            if ($page > $pages) {
                $page = $pages;
            }
            $from = ($page - 1) * $pp;
            // Добавим отбор счетов и сортировку по ним для активных записей
            if ($active == 0) {
                $sql = "SELECT * FROM " . TZS_SHIPMENT_TABLE . "  WHERE user_id={$user_id} AND active={$active} ORDER BY time DESC LIMIT {$from},{$pp};";
            } else {
                $sql = "SELECT a.*,";
                $sql .= " b.id AS order_id,";
                $sql .= " b.number AS order_number,";
                $sql .= " b.status AS order_status,";
                $sql .= " b.dt_pay AS order_dt_pay,";
                $sql .= " b.dt_expired AS order_dt_expired,";
                $sql .= " IFNULL(b.dt_pay, a.time) AS dt_sort";
                $sql .= " FROM " . TZS_SHIPMENT_TABLE . " a";
                $sql .= " LEFT OUTER JOIN wp_tzs_orders b ON (b.tbl_type = 'SH' AND a.id = b.tbl_id AND ((b.status=1 AND b.dt_expired > NOW()) OR b.status=0) )";
                $sql .= " WHERE a.user_id={$user_id} AND a.active={$active}";
                $sql .= " ORDER BY order_status DESC, dt_sort DESC";
                $sql .= " LIMIT {$from},{$pp};";
            }
            $res = $wpdb->get_results($sql);
            if (count($res) == 0 && $wpdb->last_error != null) {
                print_error('Не удалось отобразить список транспорта. Свяжитесь, пожалуйста, с администрацией сайта');
            } else {
                ?>
                <script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
                <div id="my_products_wrapper">
                    <div id="my_products_table">
                        <table id="tbl_products">
                        <thead>
                            <tr id="tbl_thead_records_per_page">
                                <th colspan="4">
                                    <div class="div_td_left">
                                        <h3>Список <?php 
                echo $active === '1' ? 'публикуемых' : 'архивных';
                ?>
 грузов</h3>
                                    </div>
                                </th>
                                
                                <th colspan="6">
                                    <div id="my_products_button">
                                        <?php 
                if ($active === '1') {
                    ?>
                                            <button id="view_del" onClick="javascript: window.open('/account/my-shipments/?active=0', '_self');">Показать архивные</button>
                                        <?php 
                } else {
                    ?>
                                            <button id="view_edit" onClick="javascript: window.open('/account/my-shipments/?active=1', '_self');">Показать публикуемые</button>
                                        <?php 
                }
                ?>
                                        <button id="view_add" onClick="javascript: window.open('/account/add-shipment/', '_self');">Добавить груз</button>
                                    </div>
                                </th>
                            </tr>
                            <tr>
                                <th id="tbl_trucks_id">№, дата и время заявки</th>
                                <th id="tbl_trucks_path" nonclickable="true">Пункты погрузки /<br>выгрузки</th>
                                <th id="tbl_trucks_dtc">Дата погрузки /<br>выгрузки</th>
                                <th id="tbl_trucks_ttr">Тип груза</th>
                                <th id="tbl_trucks_wv">Вес,<br>объем</th>
                                <th id="tbl_trucks_comm">Описание груза</th>
                                <th id="tbl_trucks_cost">Стоимость,<br/>цена 1 км</th>
                                <th id="tbl_trucks_payment">Форма оплаты</th>
                                <th id="comm">Комментарии</th>
                                <th id="actions" nonclickable="true">Действия</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                foreach ($res as $row) {
                    $type = trans_types_to_str($row->trans_type, $row->tr_type);
                    $cost = tzs_cost_to_str($row->cost, true);
                    ?>
                                <tr rid="<?php 
                    echo $row->id;
                    ?>
" <?php 
                    echo $row->order_status == 1 ? ' class="top_record"' : ($row->order_status !== null && $row->order_status == 0 ? ' class="pre_top_record"' : '');
                    ?>
 >
                                <td>
                                    <?php 
                    echo $row->id;
                    ?>
<br>
                                    <?php 
                    echo convert_time($row->time);
                    ?>
                                </td>
                                <td>
                                        <?php 
                    echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->sh_city_from);
                    ?>
<br/><?php 
                    echo tzs_city_to_str($row->to_cid, $row->to_rid, $row->to_sid, $row->sh_city_to);
                    ?>
                                        <?php 
                    if ($row->distance > 0) {
                        ?>
                                                <br/>
                                                <?php 
                        echo tzs_make_distance_link($row->distance, false, array($row->sh_city_from, $row->sh_city_to));
                        ?>
                                        <?php 
                    }
                    ?>
                                </td>
                                <td><?php 
                    echo convert_date($row->sh_date_from);
                    ?>
<br/><?php 
                    echo convert_date($row->sh_date_to);
                    ?>
</td>

                                <td><?php 
                    echo $GLOBALS['tzs_sh_types'][$row->sh_type];
                    ?>
</td>
                                
                                <td>
                                <?php 
                    if ($row->sh_weight > 0) {
                        echo remove_decimal_part($row->sh_weight) . ' т<br>';
                    }
                    if ($row->sh_volume > 0) {
                        echo remove_decimal_part($row->sh_volume) . ' м³';
                    }
                    ?>
                                </td>

                                <td><?php 
                    echo htmlspecialchars($row->sh_descr);
                    ?>
</td>
                                <td>
                                    <?php 
                    if ($row->price > 0) {
                        echo $row->price . ' ' . $GLOBALS['tzs_curr'][$row->price_val] . '<br><br>';
                        echo round($row->price / $row->distance, 2) . ' ' . $GLOBALS['tzs_curr'][$row->price_val] . '/км';
                    }
                    ?>
                                </td>
                                <td><?php 
                    echo $cost[1];
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
                                <td>
                                        <a href="javascript:doDisplay(<?php 
                    echo $row->id;
                    ?>
);" at="<?php 
                    echo $row->id;
                    ?>
" id="icon_set">Действия</a>
                                        <div id="menu_set" id2="menu" for="<?php 
                    echo $row->id;
                    ?>
" style="display:none;">
                                                <ul>
                                                        <a href="/account/view-shipment/?id=<?php 
                    echo $row->id;
                    ?>
&link=my-shipments&active=<?php 
                    echo $active;
                    ?>
">Смотреть</a>
                                                        <a href="/account/edit-shipment/?id=<?php 
                    echo $row->id;
                    ?>
">Изменить</a>
                                                    <?php 
                    if ($row->active && $row->order_status === null) {
                        ?>
                                                        <a href="javascript:promptPickUp(<?php 
                        echo $row->id;
                        ?>
, 'SH');">В ТОП</a>
                                                    <?php 
                    }
                    ?>
                                                        
                                                    <?php 
                    if ($row->active && $row->order_status !== null && $row->order_status == 0) {
                        ?>
                                                        <a href="/account/view-order/?id=<?php 
                        echo $row->order_id;
                        ?>
">Счет ТОП</a>
                                                    <?php 
                    }
                    ?>
                                                        <a href="javascript: promptDelete(<?php 
                    echo $row->id . ', ' . $row->active;
                    ?>
);" id="red">Удалить</a>
                                                </ul>
                                        </div>
                                </td>
                                </tr>
                            <?php 
                }
                ?>
                        </tbody>
                        </table>
                    </div>
                </div>
                    
                <?php 
                include_once WP_PLUGIN_DIR . '/tzs/front-end/tzs.my.new_order.php';
                ?>
                

    <script src="/wp-content/plugins/tzs/assets/js/jquery.stickytableheaders.min.js"></script>
                    <script>
                    jQuery(document).ready(function(){
                            jQuery('table').on('click', 'td', function(e) {  
                                    var nonclickable = 'true' == e.delegateTarget.rows[1].cells[this.cellIndex].getAttribute('nonclickable');
                                    var id = this.parentNode.getAttribute("rid");
                                    if (!nonclickable)
                                            document.location = "/account/view-shipment/?id="+id+"&link=my-shipments&active=<?php 
                echo $active;
                ?>
";
                            });
                        
                            jQuery("#tbl_products").stickyTableHeaders();
                    });

                    function doDisplay(id) {
                            var el = jQuery('div[for='+id+']');
                            if (el.attr('style') == null) {
                                    el.attr('style', 'display:none;');
                                    jQuery('a[at='+id+']').attr('id', 'icon_set');
                            } else {
                                    el.removeAttr('style');
                                    jQuery('a[at='+id+']').attr('id', 'icon_set_cur');
                            }
                            jQuery("div[id2=menu]").each(function(i) {
                                    var id2 = this.getAttribute('for');
                                    if (id2 != ''+id) {
                                            this.setAttribute('style', 'display:none;');
                                            jQuery('a[at='+id2+']').attr('id', 'icon_set');
                                    }
                            });
                    }

                    function promptDelete(id, active) {
                    if (active === 1) {
                        var s_text = '<div><h2>Удалить запись '+id+' или перенести в архив ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p></div>';
                        buttons1 = new Object({
                                                'В архив': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 0);
                                                },
                                                'Удалить': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 1);
                                                },
                                                'Отменить': function () {
                                                        jQuery(this).dialog("close");
                                                }
                                            });
                    } else {
                        var s_text = '<div><h2>Удалить запись '+id+' из архива ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p></div>';
                        buttons1 = new Object({
                                                'Удалить': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 1);
                                                },
                                                'Отменить': function () {
                                                        jQuery(this).dialog("close");
                                                }
                                            });
                    }
                            jQuery('<div></div>').appendTo('body')
                                    .html(s_text)
                                    .dialog({
                                            modal: true,
                                            title: 'Удаление',
                                            zIndex: 10000,
                                            autoOpen: true,
                                            width: 'auto',
                                            resizable: false,
                                            buttons: buttons1,
                                            close: function (event, ui) {
                                                    jQuery(this).remove();
                                            }
                                    });
                    }

                    function doDelete(id, is_delete) {
                            var data = {
                                    'action': 'tzs_delete_shipment',
                                    'id': id,
                                'is_delete': is_delete
                            };

                            jQuery.post(ajax_url, data, function(response) {
                                    if (response == '1') {
                                            location.reload();
                                    } else {
                                            alert('Не удалось удалить: '+response);
                                    }
                            });
                    }
                    </script>
                    <?php 
                build_pages_footer($page, $pages);
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 2
0
function tzs_front_end_following_handler($atts)
{
    ob_start();
    $sp = tzs_validate_search_parameters();
    $s_sql = tzs_search_parameters_to_sql($sp, 'sh');
    $s_title = tzs_search_parameters_to_str($sp);
    $errors = $sp['errors'];
    $show_table = true;
    if (strlen($s_title) == 0 && count($errors) == 0) {
        $show_table = false;
        //$errors = array("Укажите параметры поиска");
    }
    if (count($errors) > 0) {
        print_errors($errors);
    }
    ?>
	<a href="javascript:showSearchDialog();" id="edit_search">Изменить параметры поиска</a>
	<?php 
    if (count($errors) == 0 && $show_table) {
        if (strlen($s_title) > 0) {
            ?>
			<div id="search_info">Попутные грузы <?php 
            echo $s_title;
            ?>
</div>
		<?php 
        } else {
            ?>
			<div id="search_info">Параметры поиска не заданы</div>
		<?php 
        }
        $page = current_page_number();
        ?>
	<a tag="page" id="realod_btn" href="<?php 
        echo build_page_url($page);
        ?>
">Обновить</a>
	<?php 
        global $wpdb;
        $url = current_page_url();
        $pp = TZS_RECORDS_PER_PAGE;
        $sql = "SELECT COUNT(*) as cnt FROM " . TZS_SHIPMENT_TABLE . " WHERE active=1 {$s_sql};";
        $res = $wpdb->get_row($sql);
        if (count($res) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить список грузов. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            $records = $res->cnt;
            $pages = ceil($records / $pp);
            if ($pages == 0) {
                $pages = 1;
            }
            if ($page > $pages) {
                $page = $pages;
            }
            $from = ($page - 1) * $pp;
            $sql = "SELECT * FROM " . TZS_SHIPMENT_TABLE . " WHERE active=1 {$s_sql} ORDER BY time DESC LIMIT {$from},{$pp};";
            $res = $wpdb->get_results($sql);
            if (count($res) == 0 && $wpdb->last_error != null) {
                print_error('Не удалось отобразить список грузов. Свяжитесь, пожалуйста, с администрацией сайта');
            } else {
                if (count($res) == 0) {
                    ?>
					<div id="info">По Вашему запросу ничего не найдено.</div>
				<?php 
                } else {
                    ?>
			<script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
			<table id="tbl_shipments">
			<tr>
				<th id="numb">Номер заявки</th>
				<th id="adds">Дата размещения</th>
				<th id="date-load">Дата погрузки<br>Дата выгрузки</th>
				<th id="numb-unload" nonclickable="true">Пункт погрузки<br>Пункт выгрузки</th>
				<th id="desc">Описание груза</th>
				<th id="wight">Вес</th>
				<th id="vol">Объем</th>
				<th id="type">Тип транспорта</th>
				<th id="cost">Цена</th>
				<th id="comm">Комментарии</th>
			</tr>
			<?php 
                    foreach ($res as $row) {
                        $type = isset($GLOBALS['tzs_tr_types'][$row->trans_type]) ? $GLOBALS['tzs_tr_types'][$row->trans_type] : "";
                        ?>
				<tr rid="<?php 
                        echo $row->id;
                        ?>
">
				<td><?php 
                        echo $row->id;
                        ?>
</td>
				<td><b><?php 
                        echo convert_date_no_year($row->time);
                        ?>
</b><br/><?php 
                        echo convert_time_only($row->time);
                        ?>
</td>
				<td><?php 
                        echo convert_date_no_year($row->sh_date_from);
                        ?>
<br/><?php 
                        echo convert_date_no_year($row->sh_date_to);
                        ?>
</td>
				<td>
					<?php 
                        echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->sh_city_from);
                        ?>
<br/><?php 
                        echo tzs_city_to_str($row->to_cid, $row->to_rid, $row->to_sid, $row->sh_city_to);
                        ?>
					<?php 
                        if ($row->distance > 0) {
                            ?>
						<br/>
						<?php 
                            echo tzs_make_distance_link($row->distance, false, array($row->sh_city_from, $row->sh_city_to));
                            ?>
					<?php 
                        }
                        ?>
				</td>
				
				<td><?php 
                        echo htmlspecialchars($row->sh_descr);
                        ?>
</td>
				
				<?php 
                        if ($row->sh_weight > 0) {
                            ?>
					<td><?php 
                            echo remove_decimal_part($row->sh_weight);
                            ?>
 т</td>
				<?php 
                        } else {
                            ?>
					<td>&nbsp;</td>
				<?php 
                        }
                        ?>
				
				<?php 
                        if ($row->sh_volume > 0) {
                            ?>
					<td><?php 
                            echo remove_decimal_part($row->sh_volume);
                            ?>
 м³</td>
				<?php 
                        } else {
                            ?>
					<td>&nbsp;</td>
				<?php 
                        }
                        ?>
				
				<td><?php 
                        echo $type;
                        ?>
</td>
				<td><?php 
                        echo tzs_cost_to_str($row->cost);
                        ?>
</td>
				<td><?php 
                        echo htmlspecialchars($row->comment);
                        ?>
</td>
				</tr>
				<?php 
                    }
                    ?>
			</table>
			
			<?php 
                }
                build_pages_footer($page, $pages);
            }
        }
    }
    ?>
		<script src="/wp-content/plugins/tzs/assets/js/search.js"></script>
		<script>
			var post = [];
			<?php 
    echo "// POST dump here\n";
    foreach ($_POST as $key => $value) {
        echo "post[" . tzs_encode2($key) . "] = " . tzs_encode2($value) . ";\n";
    }
    ?>
			
			function showSearchDialog() {
				doSearchDialog('cargo', post, null, true);
			}
			
			jQuery(document).ready(function(){
				jQuery('#tbl_shipments').on('click', 'td', function(e) {  
					var nonclickable = 'true' == e.delegateTarget.rows[0].cells[this.cellIndex].getAttribute('nonclickable');
					var id = this.parentNode.getAttribute("rid");
					if (!nonclickable)
						document.location = "/account/view-shipment/?id="+id;
				});
				hijackLinks(post);
				<?php 
    if (strlen($s_title) == 0) {
        ?>
showSearchDialog();<?php 
    }
    ?>
			});
		</script>
	<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 3
0
function tzs_front_end_view_product_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if ($sh_id <= 0) {
        print_error('Товар/услуга не найден');
    } else {
        $sql = "SELECT * FROM " . TZS_PRODUCTS_TABLE . " WHERE id={$sh_id};";
        $row = $wpdb->get_row($sql);
        if (count($row) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить информацию о товаре/услуге. Свяжитесь, пожалуйста, с администрацией сайта.');
        } else {
            if ($row == null) {
                print_error('Товар/услуга не найден');
            } else {
                if (isset($_GET['spis'])) {
                    echo "<a id='edit_search' href='/account/my-products/'>Назад к списку</a> <div style='clear: both'></div>";
                } elseif (isset($_GET['link'])) {
                    echo "<a id='edit_search' href='/" . $_GET['link'] . "/'>Назад к списку</a> <div style='clear: both'></div>";
                } else {
                    echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
                }
                ?>
                <div id="">
                    <table border="0" id="view_ship">
			<tr>
				<td>Номер товара/услуги</td>
				<td><?php 
                echo $row->id;
                ?>
</td>
			</tr>
			<tr>
				<td>Активно</td>
				<td><?php 
                echo $row->active == 1 ? 'Да' : 'Нет';
                ?>
</td>
			</tr>
			<tr>
				<td>Дата размещения</td>
				<td><?php 
                echo convert_date_no_year($row->created);
                ?>
 <?php 
                echo convert_time_only($row->time);
                ?>
</td>
			</tr>
			<?php 
                if ($row->last_edited != null) {
                    ?>
			<tr>
				<td>Дата последнего изменения</td>
				<td><?php 
                    echo convert_date_no_year($row->last_edited);
                    ?>
 <?php 
                    echo convert_time_only($row->last_edited);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->expiration != null) {
                    ?>
			<tr>
				<td>Дата окончания публикации</td>
				<td><?php 
                    echo convert_date_no_year($row->expiration);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->type_id > 0) {
                    ?>
			<tr>
				<td>Категория</td>
				<td><?php 
                    echo $row->type_id;
                    $res = tzs_get_children_pages(TZS_PR_ROOT_CATEGORY_PAGE_ID);
                    $key = array_search(intval($row->type_id), $res);
                    if ($key) {
                        echo $res[$key]['title'];
                    }
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<tr>
				<td>Краткое описание товара/услуги</td>
				<td><?php 
                echo htmlspecialchars($row->title);
                ?>
</td>
			</tr>
			<tr>
				<td>Полное описание товара/услуги</td>
				<td><?php 
                echo htmlspecialchars($row->description);
                ?>
</td>
			</tr>
			<?php 
                if ($row->copies > 0) {
                    ?>
			<tr>
				<td>Количество</td>
				<td><?php 
                    echo $row->copies;
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->price > 0) {
                    ?>
			<tr>
				<td>Стоимость товара</td>
				<td><?php 
                    echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->payment > 0) {
                    ?>
			<tr>
				<td>Форма оплаты</td>
				<td><?php 
                    echo $GLOBALS['tzs_pr_payment'][$row->payment];
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<tr>
				<td>Местонахождение</td>
				<td><?php 
                echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                ?>
</td>
			</tr>
			<?php 
                if (strlen($row->comment) > 0) {
                    ?>
			<tr>
				<td>Комментарии</td>
				<td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if (strlen($row->image_id_lists) > 0) {
                    ?>
			<tr>
				<td>Изображения</td>
				<td><?php 
                    //$img_names = explode(';', $row->pictures);
                    $img_names = explode(';', $row->image_id_lists);
                    $main_image_id = $row->main_image_id;
                    if (count($img_names) > 0) {
                        ?>
                                    <table>
                                        <?php 
                        // Вначале выведем главное изображение
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                        if ($attachment_info !== false) {
                            echo '<tr><td><img src="' . $attachment_info[0] . '" alt=""></td></tr>';
                        }
                        // Затем выведем все остальные изображения
                        for ($i = 0; $i < count($img_names); $i++) {
                            if ($img_names[$i] !== $main_image_id) {
                                $attachment_info = wp_get_attachment_image_src($img_names[$i], 'full');
                                //if (file_exists(ABSPATH . $img_names[$i])) {
                                if ($attachment_info !== false) {
                                    echo '<tr><td><img src="' . $attachment_info[0] . '" alt=""></td></tr>';
                                }
                            }
                        }
                        ?>
                                    </table>
                                        <?php 
                    }
                    ?>
</td>
			</tr>
			<?php 
                } else {
                    $img_names = array();
                }
                ?>
			</table>
                    </div>

			<?php 
                if ($user_id == 0 && $GLOBALS['tzs_au_contact_view_all'] == false) {
                    ?>
				<div>Для просмотра контактов необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
			<?php 
                } else {
                    if ($user_id != $row->user_id) {
                        ?>
			
			<br/>
			<h1 class="entry-title">Контактная информация</h1>
			
			<?php 
                        tzs_print_user_table($row->user_id);
                        ?>
			
			<script src="/wp-content/plugins/tzs/assets/js/feedback.js"></script>
			
			<button id="view_feedback" onClick="<?php 
                        echo tzs_feedback_build_url($row->user_id);
                        ?>
">Отзывы <span>|</span> Рейтинг пользователя</button>
			<?php 
                    } else {
                        ?>
				<button id="view_del" onClick="javascript: promptDelete(<?php 
                        echo $row->id;
                        ?>
);">Удалить</button>
				<button id="view_edit" onClick="javascript: window.open('/account/edit-product/?id=<?php 
                        echo $row->id;
                        ?>
', '_self');">Изменить</button>
			<?php 
                    }
                }
                ?>
			<script>
				function promptDelete(id) {
					jQuery('<div></div>').appendTo('body')
						.html('<div><h6>Удалить запись '+id+'?</h6></div>')
						.dialog({
							modal: true,
							title: 'Удаление',
							zIndex: 10000,
							autoOpen: true,
							width: 'auto',
							resizable: false,
							buttons: {
								'Да': function () {
									jQuery(this).dialog("close");
									doDelete(id);
								},
								'Нет': function () {
									jQuery(this).dialog("close");
								}
							},
							close: function (event, ui) {
								jQuery(this).remove();
							}
						});
				}
				function doDelete(id) {
					var data = {
						'action': 'tzs_delete_product',
						'id': id
					};
					
					jQuery.post(ajax_url, data, function(response) {
						if (response == '1') {
							window.open('/account/my-products/', '_self');
						} else {
							alert('Не удалось удалить: '+response);
						}
					});
				}
			</script>
			<?php 
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 4
0
function tzs_front_end_view_auctionsd_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if ($sh_id <= 0) {
        print_error('Тендер не найден');
    } else {
        $sql = "SELECT * FROM " . TZS_AUCTIONS_TABLE . " WHERE id={$sh_id};";
        $row = $wpdb->get_row($sql);
        if (count($row) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить информацию о тендер. Свяжитесь, пожалуйста, с администрацией сайта.');
        } else {
            if ($row == null) {
                print_error('Тендер не найден');
            } else {
                if (isset($_GET['spis'])) {
                    echo "<a id='edit_search' href='/account/my-auctions/'>Назад к списку</a> <div style='clear: both'></div>";
                } else {
                    echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
                }
                ?>
            <div style='clear: both'>
			
			
				
            <br />
            <div class="container-fluid">
    <div class="row-fluid" >
        <div class="span4" id="img_kart">
        <?php 
                if (strlen($row->image_id_lists) > 0) {
                    //$img_names = explode(';', $row->pictures);
                    $img_names = explode(';', $row->image_id_lists);
                    $main_image_id = $row->main_image_id;
                    if (count($img_names) > 0) {
                        ?>
        <?php 
                        // Вначале выведем главное изображение
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                        if ($attachment_info !== false) {
                            ?>
            <ul class="thumbnails"  style="max-height: 470px;">
                <li class="span12">
                    <a href="#" class="thumbnail" id="general-img">
                        <img id="general" src=<?php 
                            echo $attachment_info[0];
                            ?>
 alt="">
                    </a>
                </li>
            </ul>
            
                    
            <?php 
                        }
                        ?>
            <ul class="thumbnails">
                <li class="span3">
                    <a href="#" class="thumbnail" >
                        <img src=<?php 
                        echo $attachment_info[0];
                        ?>
 alt="" onclick="clickSmallImage(this);">
                    </a>
                </li>
            <?php 
                        // Затем выведем все остальные изображения
                        for ($i = 0; $i < count($img_names); $i++) {
                            if ($img_names[$i] !== $main_image_id) {
                                $attachment_info = wp_get_attachment_image_src($img_names[$i], 'full');
                                //if (file_exists(ABSPATH . $img_names[$i])) {
                                if ($attachment_info !== false) {
                                    ?>
                        <li class="span3">
                            <a href="#" class="thumbnail" >
                                <img src=<?php 
                                    echo $attachment_info[0];
                                    ?>
 alt="" onclick="clickSmallImage(this);">
                            </a>
                        </li>
                        
                    <?php 
                                }
                            }
                        }
                        ?>
            </ul>
            <?php 
                    }
                } else {
                    ?>
                    <ul class="thumbnails"  style="max-height: 470px;">
                        <li class="span12">
                            <a href="#" class="thumbnail" id="general-img">
                                <img id="general" src="/wp-content/themes/twentytwelve/image/360x270.png" alt="">
                            </a>
                        </li>
                    </ul>
                <?php 
                }
                ?>
            
        </div>
        <div class="span7">
            <div class="well well-large">
                <div id="bet">
                    <form name="bet_form" id="bet_form" >
                        <fieldset>
                            
                            <div id="bet_error" style="color: red;"><?php 
                echo $user_id === 0 ? '<p>Для участия в тендере необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></p>' : '';
                ?>
</div>
                            <?php 
                if ($user_id == $row->user_id) {
                    ?>
                            <div class="pull-left label-txt">
                                <label><strong>Актуальная цена:</strong></label>
                                <!-- <strong><div id="tek_price">515 <?php 
                    /*echo $GLOBALS['tzs_pr_curr'][$row->currency]; */
                    ?>
</div></strong> -->
                                <strong><div id="tek_price"></div></strong>
                            </div>
                            <div class="pull-left label-txt" style="min-width: 60px;">
                                <label><strong>Ставок:</strong></label>
                                <!-- <strong><div id="tek_price">515 <?php 
                    /*echo $GLOBALS['tzs_pr_curr'][$row->currency]; */
                    ?>
</div></strong> -->
                                <strong><div id="tek_stavki"></div></strong>
                            </div>
                            <?php 
                } else {
                    ?>
                            <div class="pull-left label-txt">
                                <label><strong>Актуальная цена:</strong></label>
                            </div>
                            <div class="pull-left label-txt" style="min-width: 60px;">
                                <label><strong>Ставок:</strong></label>
                            </div>
                            <?php 
                }
                ?>
                            <?php 
                if ($user_id != $row->user_id && $user_id != 0) {
                    ?>
                            <div class="pull-left" style="padding-left: 10px;">
                                <strong>Ваша ставка:</strong>
                            </div>
                            <div class="clearfix"></div>
                            <?php 
                }
                ?>
                            <?php 
                if ($user_id == $row->user_id) {
                    ?>
			                         <div class="pull-left">
				                        <button id="view_del" style="margin: 0 20px 0 0;" onClick="javascript: promptDelete(<?php 
                    echo $row->id . ', ' . $row->active;
                    ?>
);">Удалить</button>
				                        <a id="view_edit" style="margin: 0 20px 0 0;" onClick="javascript: window.location.href = '/account/edit-auction/?id=<?php 
                    echo $row->id;
                    ?>
';">Изменить</a>
                                        
                                    </div>
                            <?php 
                }
                ?>
                            <?php 
                if ($user_id != $row->user_id) {
                    ?>
                            <?php 
                    if (!$user_id) {
                        echo "<div class='clearfix'></div>";
                    }
                    ?>
                            <div class="pull-left label-txt">
                                    <!-- <center><strong><div id="tek_price">515 <?php 
                    /* echo $GLOBALS['tzs_pr_curr'][$row->currency]; */
                    ?>
</div></strong></center> -->
                                    <center><strong><div id="tek_price"></div></strong></center>
                                </div> 
                              <div class="pull-left label-txt" style="min-width: 60px;">
                                    <!-- <center><strong><div id="tek_price">515 <?php 
                    /* echo $GLOBALS['tzs_pr_curr'][$row->currency]; */
                    ?>
</div></strong></center> -->
                                    <center><strong><div id="tek_stavki"></div></strong></center>
                                </div>       
                            <?php 
                }
                ?>
                            
                            
                            <?php 
                if ($user_id != $row->user_id && $user_id != 0) {
                    ?>
                            
                            <div class="pull-left" style="width: 30%; padding-left: 10px;">
                                <input id="bet_user" type="number" style="width: 45%;" <?php 
                    echo $user_id === 0 ? 'disabled="disabled"' : '';
                    ?>
/>  
                            </div>
                            <div class="pull-left">
                                <button   id="bet_button" type="button" onclick="bet_click();" <?php 
                    echo $user_id === 0 ? 'disabled="disabled"' : '';
                    ?>
>Сделать ставку</button>
                            </div>
                            
                            <div class="clearfix"></div>
                            <strong>Комментарий к ставке</strong>
                            <textarea id="text_bet" class="bet-area" rows="1" cols="75" name="text-bet" placeholder="Текст ставки"></textarea>
                            <input id="user_id" style="display: none;" value=<?php 
                    echo $user_id;
                    ?>
 />
                            <input id="user_name" style="display: none;" value=<?php 
                    $meta = get_user_meta($row->user_id, 'fio');
                    echo $meta[0];
                    ?>
 />
                            <input id="auction_id" style="display: none;" value=<?php 
                    echo $sh_id;
                    ?>
 />
                            <input id="created" style="display: none;" value=<?php 
                    echo date("Y-m-d H:i:s");
                    ?>
 />
                            <?php 
                }
                ?>
                            <input id="currency" style="display: none;" value="<?php 
                echo $GLOBALS['tzs_pr_curr'][$row->currency];
                ?>
" />
                            <div class="clearfix"></div>
                        </fieldset>
                    </form>
                </div>
                <div id="labeltxt">
                    <div class="pull-left label-txt">
                        <label><strong>Активно:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->active == 1 ? 'Да' : 'Нет';
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Категория:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo get_the_title($row->type_id);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Дата размещения:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_date($row->created);
                ?>
 <?php 
                echo convert_time_only($row->time);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Дата окончания:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_date($row->expiration);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Краткое описание:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo htmlspecialchars($row->title);
                ?>
 
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Количество:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->copies;
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Начальная стоимость:</strong></label>
                    </div>
                    <div class="pull-left" id="bet_label">
                        <?php 
                echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Форма оплаты:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $GLOBALS['tzs_pr_payment'][$row->payment];
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Место нахождение:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    
                </div>
            </div>
        </div>
    </div>
   
    <div class="row-fluid">
        <div class="span11">
            <ul id="myTab" class="nav nav-tabs">
                <li class="active"><a href="#description" data-toggle="tab">Описание</a></li>
                <li><a href="#contact" data-toggle="tab">Контактная информация</a></li>
                <?php 
                if ($user_id == $row->user_id) {
                    ?>
                        <li><a href="#dopolnenie" data-toggle="tab">История ставок</a></li>
                <?php 
                }
                ?>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="description">
                    <?php 
                echo $row->description;
                //echo htmlspecialchars($row->description);
                ?>
                </div>
                <div class="tab-pane fade" id="contact">
                    <?php 
                if ($user_id == 0 && $GLOBALS['tzs_au_contact_view_all'] == false) {
                    ?>
				        <div>Для просмотра контактов необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
                    <?php 
                } else {
                    if ($user_id != $row->user_id) {
                        ?>
			
			<br/>
			
			
			 <!-- <div class="span6"> --!>
            
                <div id="labeltxt">
                    <?php 
                        echo tzs_print_user_table_ed($row->user_id);
                        ?>
   
                </div>
            
       
        <!-- </div> --!>
			 <script src="/wp-content/plugins/tzs/assets/js/feedback.js"></script>
			
			<button id="view_feedback" onClick="<?php 
                        echo tzs_feedback_build_url($row->user_id);
                        ?>
">Отзывы <span>|</span> Рейтинг пользователя</button>
			<?php 
                    }
                }
                ?>
  
			
                </div>
                <div class="tab-pane fade" id="dopolnenie">
                    <div class="well well-large">
                        <div id="wrapper_bet">
                        <?php 
                $active = " AND active=1";
                // Отбор ставок по тендеру - active=1 AND
                $sql = "SELECT MAX(rate) FROM " . TZS_AUCTION_RATES_TABLE . " WHERE auction_id={$sh_id} {$active}";
                /*$max = $wpdb->get_results($sql); */
                $max = $wpdb->get_var($sql);
                if (max > 0) {
                    echo "<input id='act_rate' style='display: none;' value=" . round($max, 2) . " />";
                } else {
                    echo "<input id='act_rate' style='display: none;' value=" . $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency] . " />";
                }
                $sql = "SELECT COUNT(*) FROM " . TZS_AUCTION_RATES_TABLE . " WHERE auction_id={$sh_id} {$active}";
                /*$max = $wpdb->get_results($sql); */
                $cnt_rate = $wpdb->get_var($sql);
                if ($cnt_rate > 0) {
                    echo "<input id='cnt_rate' style='display: none;' value=" . $cnt_rate . " />";
                } else {
                    echo "<input id='cnt_rate' style='display: none;' value='0' />";
                }
                $sql = "SELECT * FROM " . TZS_AUCTION_RATES_TABLE . " WHERE auction_id={$sh_id} ORDER BY active DESC,created DESC;";
                $res = $wpdb->get_results($sql);
                if (count($res) == 0 && $wpdb->last_error != null) {
                    print_error('Не удалось отобразить информацию о ставках. Свяжитесь, пожалуйста, с администрацией сайта.');
                } else {
                    if (count($res) == 0) {
                        print_error('Ставки не найдены');
                    } else {
                        ?>
                            <table border="0" id="tbl_products" style="float: none !important;">
                                <tr>
                                        <th>Статус</th>
                                        <th id="tbl_products_dtc">Размещена <br /> Отозвана</th>
                                        <!-- <th id="tbl_products_dtc">Дата и время отзыва</th> -->
                                        <th id="price">Предложенная стоимость</th>
                                        <th id="price">Комментарий</th>
                                        <!-- <th id="price">Автор</th> -->
                                        <?php 
                        if ($user_id !== 0 || $GLOBALS['tzs_au_contact_view_all'] !== false) {
                            ?>
                                        <th id="price">Автор <br /> Контактные данные</th>
                                        <?php 
                        }
                        ?>
                                </tr>
                                <?php 
                        $i = 0;
                        foreach ($res as $row) {
                            $user_info = get_userdata($row->user_id);
                            if ($row->reviewed == null) {
                                $reviewed = "&nbsp";
                            } else {
                                $reviewed = convert_time($row->reviewed);
                            }
                            ?>
                                    <tr id="<?php 
                            echo $row->active == 1 ? 'tbl_auction_rate_active' : 'tbl_auction_rate_reviewed';
                            ?>
">
                                        <td><?php 
                            echo $row->active == 1 ? 'Активна' : 'Отозвана';
                            ?>
</td>
                                        <td><?php 
                            echo ' ' . convert_time($row->created) . "<br />" . $reviewed;
                            ?>
</td>
                                        <!-- <td><?php 
                            /*echo $row->reviewed == null ? '&nbsp;' : convert_time($row->reviewed); */
                            ?>
</td> -->
                                        <td><?php 
                            echo $row->rate . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                            ?>
</td>
                                        <td><?php 
                            echo $row->description;
                            ?>
</td>
                                        <!-- <td><?php 
                            /* $meta = get_user_meta($row->user_id, 'fio'); echo $meta[0]; */
                            ?>
</td> -->
                                        <?php 
                            if ($user_id !== 0 || $GLOBALS['tzs_au_contact_view_all'] !== false) {
                                ?>
                                        <td>
                                            <?php 
                                $meta = get_user_meta($row->user_id, 'fio');
                                echo $meta[0] . '<br />';
                                ?>
                                            <?php 
                                $meta = get_user_meta($row->user_id, 'telephone');
                                echo $meta[0] == null ? '' : 'Номера телефонов: ' . htmlspecialchars($meta[0]) . '<br/>';
                                ?>
                                            <?php 
                                echo $user_info->user_email == null ? '' : 'E-mail: ' . htmlspecialchars($user_info->user_email) . '<br/>';
                                ?>
                                            <?php 
                                $meta = get_user_meta($row->user_id, 'skype');
                                echo $meta[0] == null ? '' : 'Skype: ' . htmlspecialchars($meta[0]) . '<br/>';
                                ?>
                                        </td>
                                        <?php 
                            }
                            ?>
                                    </tr>
                                
                                <?php 
                        }
                        ?>
                            </table>
                        <?php 
                    }
                }
                ?>
                        </div>
                
                    </div>  
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    jQuery('#myTab a').click(function (e) {
    e.preventDefault();
    jQuery(this).tab('show');
})
</script>
<script>
jQuery(document).ready(function() { 
    document.getElementById('tek_price').innerHTML=document.getElementById('act_rate').value+' '+document.getElementById('currency').value;
    document.getElementById('tek_stavki').innerHTML=document.getElementById('cnt_rate').value;
    
    now = new Date();
    month=now.getUTCMonth()+1;
    now_str=now.getFullYear()+'-'+month+'-'+now.getUTCDate()+' '+now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();
});

function clickSmallImage(element)
{
    document.getElementById("general").src=element.src;
}

function bet_click()
{
flag_subs=0;
document.getElementById('bet_error').innerHTML="";
paramstr=document.getElementById('text_bet').id+"=" + encodeURIComponent(document.getElementById('text_bet').value) + "&"+document.getElementById('user_id').id+"="+document.getElementById('user_id').value+"&"+document.getElementById('user_name').id+"="+document.getElementById('user_name').value+"&"+document.getElementById('auction_id').id+"="+document.getElementById('auction_id').value+"&"+document.getElementById('bet_user').id+"=" + document.getElementById('bet_user').value + "&"+document.getElementById('currency').id+"=" + document.getElementById('currency').value + "&"+document.getElementById('created').id+"=" + now_str + "&";

if  ((document.getElementById('bet_user').value != "") )
{
    flag_subs=flag_subs+1;
}
else
{

  document.getElementById('bet_error').innerHTML="Ставка не может быть пустой!";
  return false;  
}
if  (parseFloat(document.getElementById('bet_user').value, 10) > parseFloat(document.getElementById('tek_price').innerHTML, 10) )
{
    flag_subs=flag_subs+1;
}
else
{
  document.getElementById('bet_error').innerHTML="Ставка не может быть меньше актуальной цены!";
  return false;  
}
if(flag_subs>=1)
{
jQuery.ajax({
		url: "/wp-admin/admin-ajax.php?action=add_bet",
       // url: "/wp-content/plugins/tzs/functions/tzs.functions.php?action=add_bet",
		type: "POST",
		data: paramstr,
		success: function(data){
			//document.forms["bet_form"].submit();
            bet_rate=document.getElementById('bet_user').value;
            document.getElementById('tek_price').innerHTML=bet_rate+' '+document.getElementById('currency').value+'.';
            document.getElementById('bet_error').innerHTML="Ваша ставка принята!";
            document.getElementById('bet_user').value="";
            document.getElementById('text_bet').value="";
            //jQuery("#wrapper_bet").load("/wp-content/plugins/tzs/front-end/tzs.view.auctions#wrapper_bet");
            document.getElementById('wrapper_bet').innerHTML=data;
            //alert(data);

		},
        error: function(data){
			//document.forms["bet_form"].submit();
            
            alert(data);

		}			
	});		   
}
}

</script>


			<br/>
                        
			
                                
			<script>
				function promptDelete(id, active) {
                                    if (active === 1) {
                                        var s_text = '<div><h2>Удалить запись '+id+' или перенести в архив ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                                        buttons1 = new Object({
                                                                'В архив': function () {
                                                                        jQuery(this).dialog("close");
                                                                        doDelete(id, 0);
                                                                },
                                                                'Удалить': function () {
                                                                        jQuery(this).dialog("close");
                                                                        doDelete(id, 1);
                                                                },
                                                                'Отменить': function () {
                                                                        jQuery(this).dialog("close");
                                                                }
                                                            });
                                    } else {
                                        var s_text = '<div><h2>Удалить запись '+id+' из архива ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                                        buttons1 = new Object({
                                                                'Удалить': function () {
                                                                        jQuery(this).dialog("close");
                                                                        doDelete(id, 1);
                                                                },
                                                                'Отменить': function () {
                                                                        jQuery(this).dialog("close");
                                                                }
                                                            });
                                    }

					jQuery('<div></div>').appendTo('body')
						.html(s_text)
						.dialog({
							modal: true,
							title: 'Удаление',
							zIndex: 10000,
							autoOpen: true,
							width: 'auto',
							resizable: false,
							buttons: buttons1,
							close: function (event, ui) {
								jQuery(this).remove();
							}
						});
				}
				function doDelete(id, is_delete) {
                                    p_data = "id=" + id + "&is_delete=" + is_delete;
                                    jQuery.ajax({
                                        url: "/wp-admin/admin-ajax.php?action=tzs_delete_auction",
                                        type: "POST",
                                        data: p_data,
                                        success: function(response){
                                            //window.open('/account/my-auctions/', '_self');
                                            window.open('/account/my-auctions/', '');
                                        },
                                        error: function(response){
                                            alert('Не удалось удалить: '+response);
                                        }
                                    });		   
					/*var data = {
						'action': 'tzs_delete_auction',
						'id': id,
                                                'is_delete': is_delete
					};
					
					jQuery.post(ajax_url, data, function(response) {
						if (response == '1') {
							window.open('/account/my-auctions/', '_self');
						} else {
							alert('Не удалось удалить: '+response);
						}
					});*/
				}
			</script>
			<?php 
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 5
0
function tzs_front_end_view_shipment_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if ($sh_id <= 0) {
        print_error('Груз не найден');
    } else {
        $sql = "SELECT * FROM " . TZS_SHIPMENT_TABLE . " WHERE id={$sh_id};";
        $row = $wpdb->get_row($sql);
        if (count($row) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить информацию о грузе. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            if ($row == null) {
                print_error('Груз не найден');
            } else {
                $type = isset($GLOBALS['tzs_tr_types'][$row->trans_type]) ? $GLOBALS['tzs_tr_types'][$row->trans_type] : "";
                $sh_type = isset($GLOBALS['tzs_sh_types'][$row->sh_type]) ? $GLOBALS['tzs_sh_types'][$row->sh_type] : "";
                $path_segment_cities = explode(";", $row->path_segment_cities);
                $loading_types = tzs_loading_types_to_str($row);
                ?>
			<script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
                        <div id="contact-block-right" style="left: 82%;">
                            <div class="span2" style="width: 80%;">
                    <?php 
                echo "<img src='" . get_user_meta($row->user_id, 'company_logo', true) . "' width='145px'/>";
                $form_type = 'shipments';
                echo tzs_print_user_contacts($row, $form_type);
                ?>
                    <?php 
                if (isset($_GET['spis'])) {
                    echo "<a id='edit_search' href='/account/my-shipments/'>Назад к списку</a> <div style='clear: both'></div>";
                } elseif (isset($_GET['link'])) {
                    echo "<a id='edit_search' href='/" . $_GET['link'] . (isset($_GET['active']) ? "/?active=" . $_GET['active'] : "/") . "'>Назад к списку</a> <div style='clear: both'></div>";
                } else {
                    echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
                }
                ?>
            <?php 
                if ($user_id == $row->user_id) {
                    ?>
                <div style="margin-top: 15px;">
                    <a id="view_edit"  onClick="javascript: window.location.href = '/account/edit-shipment/?id=<?php 
                    echo $row->id;
                    ?>
';">Изменить</a>
                </div>
                    
            <?php 
                }
                ?>
                </div>
            </div>

<div class="container" id="product-container">
    <div class="row-fluid" >
        <div class="span4" id="img_kart">
            <div class="well well-large">
                    <div class="pull-left label-txt">
                        <label><strong>Номер груза:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->id;
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Активно:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->active == 1 ? 'Да' : 'Нет';
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Дата размещения:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_time($row->time);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                if ($row->last_edited != null) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Дата <!--последнего -->изменения:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    echo convert_time($row->last_edited);
                    ?>
                    </div>
                    <div class="clearfix"></div>
                
                   <?php 
                }
                ?>
        </div>
        </div>
        <div class="span6" id="descript">
              <div class="well well-large">
                    <div class="pull-left label-txt">
                        <label><strong>Дата погрузки:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_date($row->sh_date_from);
                ?>
 
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Дата выгрузки:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_date($row->sh_date_to);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Пункт погрузки:</strong></label>
                    </div>
                    <div class="pull-left" id="bet_label">
                        <?php 
                echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->sh_city_from);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                if (count($path_segment_cities) > 2) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Промежуточные<br>пункты:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    for ($i = 1; $i < count($path_segment_cities) - 1; $i++) {
                        echo $path_segment_cities[$i] . "<br>";
                    }
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                    <div class="pull-left label-txt">
                        <label><strong>Пункт выгрузки:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo tzs_city_to_str($row->to_cid, $row->to_rid, $row->to_sid, $row->sh_city_to);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                if ($row->distance > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Расстояние:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    echo tzs_make_distance_link($row->distance, false, $path_segment_cities);
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                    <?php 
                if (strlen($sh_type) > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Тип груза:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    echo $sh_type;
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                    <div class="pull-left label-txt">
                        <label><strong>Описание груза:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo htmlspecialchars($row->sh_descr);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                if ($row->sh_weight > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Вес:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    echo $row->sh_weight;
                    ?>
 т
                    </div>
                    <div class="clearfix"></div>
                   <?php 
                }
                ?>
 
                    <?php 
                if ($row->sh_volume > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Объем:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    echo $row->sh_volume;
                    ?>
 м³
                    </div>
                    <div class="clearfix"></div>
                   <?php 
                }
                ?>
 
                    <div class="pull-left label-txt">
                        <label><strong>Количество машин:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->trans_count;
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                if (strlen($type) > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Тип транспорта:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                    echo $type;
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                    <?php 
                if ($row->sh_length > 0 || $row->sh_height > 0 || $row->sh_width > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Габариты:</strong></label>
                    </div>
                    <div class="pull-left" style="width: 60%">
                        Длина = <?php 
                    echo $row->sh_length;
                    ?>
м<br>Ширина = <?php 
                    echo $row->sh_width;
                    ?>
м<br>Высота = <?php 
                    echo $row->sh_height;
                    ?>
м
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                    
                    <?php 
                if (strlen($loading_types) > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Загрузка:</strong></label>
                    </div>
                    <div class="pull-left" style="width: 60%">
                        <?php 
                    echo str_replace(', ', ',<br>', $loading_types);
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                    
                    <?php 
                //$cost = tzs_cost_to_str($row->cost);
                $cost = tzs_price_query_to_str($row);
                if (count($cost) > 0) {
                    ?>
                    <div class="pull-left label-txt">
                        <label><strong>Цена:</strong></label>
                    </div>
                    <div class="pull-left" style="width: 60%">
                        <?php 
                    echo $cost[0];
                    ?>
                        <?php 
                    echo $cost[1] ? ' (' . $cost[1] . ')' : '';
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    
                    <div class="pull-left label-txt">
                        <label><strong>Форма оплаты:</strong></label>
                    </div>
                    <div class="pull-left" style="width: 60%">
                        <?php 
                    echo str_replace(', ', ',<br>', $cost[2]);
                    ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                }
                ?>
                </div>
            </div>
        </div>
        
    </div>
			
			
			<script>
				function promptDelete(id) {
					jQuery('<div></div>').appendTo('body')
						.html('<div><h6>Удалить запись '+id+'?</h6></div>')
						.dialog({
							modal: true,
							title: 'Удаление',
							zIndex: 10000,
							autoOpen: true,
							width: 'auto',
							resizable: false,
							buttons: {
								'Да': function () {
									jQuery(this).dialog("close");
									doDelete(id);
								},
								'Нет': function () {
									jQuery(this).dialog("close");
								}
							},
							close: function (event, ui) {
								jQuery(this).remove();
							}
						});
				}
				function doDelete(id) {
					var data = {
						'action': 'tzs_delete_shipment',
						'id': id
					};
					
					jQuery.post(ajax_url, data, function(response) {
						if (response == '1') {
							window.open('/account/my-shipments/', '_self');
						} else {
							alert('Не удалось удалить: '+response);
						}
					});
				}
			</script>
			<?php 
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 6
0
function tzs_front_end_view_shipment_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if ($sh_id <= 0) {
        print_error('Груз не найден');
    } else {
        $sql = "SELECT * FROM " . TZS_SHIPMENT_TABLE . " WHERE id={$sh_id};";
        $row = $wpdb->get_row($sql);
        if (count($row) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить информацию о грузе. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            if ($row == null) {
                print_error('Груз не найден');
            } else {
                $type = isset($GLOBALS['tzs_tr_types'][$row->trans_type]) ? $GLOBALS['tzs_tr_types'][$row->trans_type] : "";
                ?>
			<script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
			<?php 
                if (isset($_GET['spis'])) {
                    echo "<a id='edit_search' href='/account/my-shipments/'>Назад к списку</a> <div style='clear: both'></div>";
                } elseif (isset($_GET['link'])) {
                    echo "<a id='edit_search' href='/" . $_GET['link'] . "/'>Назад к списку</a> <div style='clear: both'></div>";
                } else {
                    echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
                }
                ?>
            <table border="0" id="view_ship">
			<tr>
				<td>Номер груза</td>
				<td><?php 
                echo $row->id;
                ?>
</td>
			</tr>
			<tr>
				<td>Активно</td>
				<td><?php 
                echo $row->active == 1 ? 'Да' : 'Нет';
                ?>
</td>
			</tr>
			<tr>
				<td>Дата размещения</td>
				<td><?php 
                echo convert_date_no_year($row->time);
                ?>
 <?php 
                echo convert_time_only($row->time);
                ?>
</td>
			</tr>
			<?php 
                if ($row->last_edited != null) {
                    ?>
			<tr>
				<td>Дата последнего изменения</td>
				<td><?php 
                    echo convert_date_no_year($row->last_edited);
                    ?>
 <?php 
                    echo convert_time_only($row->last_edited);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<tr>
				<td>Дата погрузки</td>
				<td><?php 
                echo convert_date_no_year($row->sh_date_from);
                ?>
</td>
			</tr>
			<tr>
				<td>Дата выгрузки</td>
				<td><?php 
                echo convert_date_no_year($row->sh_date_to);
                ?>
</td>
			</tr>
			<tr>
				<td>Пункт погрузки</td>
				<td><?php 
                echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->sh_city_from);
                ?>
</td>
			</tr>
			<tr>
				<td>Пункт выгрузки</td>
				<td><?php 
                echo tzs_city_to_str($row->to_cid, $row->to_rid, $row->to_sid, $row->sh_city_to);
                ?>
</td>
			</tr>
			<tr>
				<td>Описание груза</td>
				<td><?php 
                echo htmlspecialchars($row->sh_descr);
                ?>
</td>
			</tr>
			<?php 
                if ($row->sh_weight > 0) {
                    ?>
			<tr>
				<td>Вес</td>
				<td><?php 
                    echo $row->sh_weight;
                    ?>
 т</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->sh_volume > 0) {
                    ?>
			<tr>
				<td>Объем</td>
				<td><?php 
                    echo $row->sh_volume;
                    ?>
 м³</td>
			</tr>
			<?php 
                }
                ?>
			<tr>
				<td>Количество машин</td>
				<td><?php 
                echo $row->trans_count;
                ?>
</td>
			</tr>
			<tr>
				<td>Тип транспорта</td>
				<td><?php 
                echo $type;
                ?>
</td>
			</tr>
			<?php 
                if ($row->sh_length > 0 || $row->sh_height > 0 || $row->sh_width > 0) {
                    ?>
			<tr>
				<td>Габариты</td>
				<td>Длинна=<?php 
                    echo $row->sh_length;
                    ?>
м Ширина=<?php 
                    echo $row->sh_width;
                    ?>
м Высота=<?php 
                    echo $row->sh_height;
                    ?>
м</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                $cost = tzs_cost_to_str($row->cost);
                if (strlen($cost) > 0) {
                    ?>
			<tr>
				<td>Цена</td>
				<td><?php 
                    echo $cost;
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			
			<?php 
                if ($row->distance > 0) {
                    ?>
			<tr>
				<td>Расстояние</td>
				<td><?php 
                    echo tzs_make_distance_link($row->distance, false, array($row->sh_city_from, $row->sh_city_to));
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			
			<?php 
                if (strlen($row->comment) > 0) {
                    ?>
			<tr>
				<td>Комментарии</td>
				<td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			</table>
			
			<?php 
                if ($user_id == 0) {
                    ?>
				<div>Для просмотра контактов необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
			<?php 
                } else {
                    if ($user_id != $row->user_id) {
                        ?>
			
			<br/>
			<h1 class="entry-title">Контактная информация</h1>
			
			<?php 
                        tzs_print_user_table($row->user_id);
                        ?>
			
			<script src="/wp-content/plugins/tzs/assets/js/feedback.js"></script>
			
			<button id="view_feedback" onClick="<?php 
                        echo tzs_feedback_build_url($row->user_id);
                        ?>
">Отзывы <span>|</span> Рейтинг пользователя</button>
			<?php 
                    } else {
                        ?>
				<button id="view_del" onClick="javascript: promptDelete(<?php 
                        echo $row->id;
                        ?>
);">Удалить</button>
				<button id="view_edit" onClick="javascript: window.open('/account/edit-shipment/?id=<?php 
                        echo $row->id;
                        ?>
', '_self');">Изменить</button>
			<?php 
                    }
                }
                ?>
			<script>
				function promptDelete(id) {
					jQuery('<div></div>').appendTo('body')
						.html('<div><h6>Удалить запись '+id+'?</h6></div>')
						.dialog({
							modal: true,
							title: 'Удаление',
							zIndex: 10000,
							autoOpen: true,
							width: 'auto',
							resizable: false,
							buttons: {
								'Да': function () {
									jQuery(this).dialog("close");
									doDelete(id);
								},
								'Нет': function () {
									jQuery(this).dialog("close");
								}
							},
							close: function (event, ui) {
								jQuery(this).remove();
							}
						});
				}
				function doDelete(id) {
					var data = {
						'action': 'tzs_delete_shipment',
						'id': id
					};
					
					jQuery.post(ajax_url, data, function(response) {
						if (response == '1') {
							window.open('/account/my-shipments/', '_self');
						} else {
							alert('Не удалось удалить: '+response);
						}
					});
				}
			</script>
			<?php 
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 7
0
function tzs_front_end_view_productsd_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if ($sh_id <= 0) {
        print_error('Товар/услуга не найден');
    } else {
        $sql = "SELECT * FROM " . TZS_PRODUCTS_TABLE . " WHERE id={$sh_id};";
        $row = $wpdb->get_row($sql);
        if (count($row) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить информацию о товаре/услуге. Свяжитесь, пожалуйста, с администрацией сайта.');
        } else {
            if ($row == null) {
                print_error('Товар/услуга не найден');
            } else {
                if (isset($_GET['spis'])) {
                    echo "<a id='edit_search' href='/account/my-products/'>Назад к списку</a>";
                } else {
                    echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button>";
                }
                ?>
                  
                    
                     <div style='clear: both'>
            <br />
            <div class="container-fluid">
    <div class="row-fluid" >
        <div class="span4" id="img_kart">
        <?php 
                if (strlen($row->image_id_lists) > 0) {
                    //$img_names = explode(';', $row->pictures);
                    $img_names = explode(';', $row->image_id_lists);
                    $main_image_id = $row->main_image_id;
                    if (count($img_names) > 0) {
                        ?>
        <?php 
                        // Вначале выведем главное изображение
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                        if ($attachment_info !== false) {
                            ?>
            <ul class="thumbnails"  style="max-height: 470px;">
                <li class="span12">
                    <a href="#" class="thumbnail" id="general-img">
                        <img id="general" src=<?php 
                            echo $attachment_info[0];
                            ?>
 alt="">
                    </a>
                </li>
            </ul>
            
                    
            <?php 
                        }
                        ?>
            <ul class="thumbnails">
                <li class="span3">
                    <a href="#" class="thumbnail" >
                        <img src=<?php 
                        echo $attachment_info[0];
                        ?>
 alt="" onclick="clickSmallImage(this);">
                    </a>
                </li>
            <?php 
                        // Затем выведем все остальные изображения
                        for ($i = 0; $i < count($img_names); $i++) {
                            if ($img_names[$i] !== $main_image_id) {
                                $attachment_info = wp_get_attachment_image_src($img_names[$i], 'full');
                                //if (file_exists(ABSPATH . $img_names[$i])) {
                                if ($attachment_info !== false) {
                                    ?>
                        <li class="span3">
                            <a href="#" class="thumbnail" >
                                <img src=<?php 
                                    echo $attachment_info[0];
                                    ?>
 alt="" onclick="clickSmallImage(this);">
                            </a>
                        </li>
                        
                    <?php 
                                }
                            }
                        }
                        ?>
            </ul>
            <?php 
                    }
                } else {
                    ?>
                    <ul class="thumbnails"  style="max-height: 470px;">
                        <li class="span12">
                            <a href="#" class="thumbnail" id="general-img">
                                <img id="general" src="/wp-content/themes/twentytwelve/image/360x270.png" alt="">
                            </a>
                        </li>
                    </ul>
                <?php 
                }
                ?>
            
        </div>
        <div class="span7">
            <div class="well well-large">
                <div id="labeltxt">
                    <div class="pull-left label-txt">
                        <label><strong>Активно:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->active == 1 ? 'Да' : 'Нет';
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Категория:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo get_the_title($row->type_id);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Дата размещения:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_date($row->created);
                ?>
 <?php 
                echo convert_time_only($row->time);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Дата окончания:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo convert_date($row->expiration);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Краткое описание:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo htmlspecialchars($row->title);
                ?>
 
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Количество:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->copies;
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Cтоимость:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Форма оплаты:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo $GLOBALS['tzs_pr_payment'][$row->payment];
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pull-left label-txt">
                        <label><strong>Место нахождение:</strong></label>
                    </div>
                    <div class="pull-left">
                        <?php 
                echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                ?>
                    </div>
                    <div class="clearfix"></div>
                    <?php 
                if ($user_id == $row->user_id) {
                    ?>
                        <center>
                            <button id="view_del" onClick="javascript: promptDelete(<?php 
                    echo $row->id . ', ' . $row->active;
                    ?>
);">Удалить</button>
			         	    <button id="view_edit" onClick="javascript: window.open('/account/edit-product/?id=<?php 
                    echo $row->id;
                    ?>
', '_self');">Изменить</button>
                        </center>
                    <?php 
                }
                ?>
    
                </div>
            </div>
        </div>
    </div>
   
    <div class="row-fluid">
        <div class="span11">
            <ul id="myTab" class="nav nav-tabs">
                <li class="active"><a href="#description" data-toggle="tab">Описание</a></li>
                <li><a href="#contact" data-toggle="tab">Контактная информация</a></li>
                <li><a href="#allgoods" data-toggle="tab">Все товары пользователя</a></li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="description">
                    <?php 
                echo $row->description;
                ?>
                </div>
                <div class="tab-pane fade" id="contact">
                    <?php 
                if ($user_id == 0 && $GLOBALS['tzs_au_contact_view_all'] == false) {
                    ?>
				        <div>Для просмотра контактов необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
                    <?php 
                } else {
                    if ($user_id != $row->user_id) {
                        ?>
			         <br/>
			         <div class="span6"> 
                        <div id="labeltxt">
                            <?php 
                        echo tzs_print_user_table_ed($row->user_id);
                        ?>
   
                        </div>
                    </div> 
			         <script src="/wp-content/plugins/tzs/assets/js/feedback.js"></script>
        			<button id="view_feedback" onClick="<?php 
                        echo tzs_feedback_build_url($row->user_id);
                        ?>
">Отзывы <span>|</span> Рейтинг пользователя</button>
			         <?php 
                    }
                }
                ?>
  
                </div>
                <div class="tab-pane fade" id="allgoods">
                    <?php 
                /*echo do_shortcode('[tzs-view-user-products user_id=1]');*/
                echo do_shortcode('[tzs-view-user-products user_id=' . $row->user_id . ']');
                ?>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    jQuery('#myTab a').click(function (e) {
    e.preventDefault();
    jQuery(this).tab('show');
})
</script>
<script>
function clickSmallImage(element)
{
    document.getElementById("general").src=element.src;
}
</script>
            
     
			
			
			<script>
				function promptDelete(id, active) {
                                    if (active === 1) {
                                        var s_text = '<div><h2>Удалить запись '+id+' или перенести в архив ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                                        buttons1 = new Object({
                                                                'В архив': function () {
                                                                        jQuery(this).dialog("close");
                                                                        doDelete(id, 0);
                                                                },
                                                                'Удалить': function () {
                                                                        jQuery(this).dialog("close");
                                                                        doDelete(id, 1);
                                                                },
                                                                'Отменить': function () {
                                                                        jQuery(this).dialog("close");
                                                                }
                                                            });
                                    } else {
                                        var s_text = '<div><h2>Удалить запись '+id+' из архива ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                                        buttons1 = new Object({
                                                                'Удалить': function () {
                                                                        jQuery(this).dialog("close");
                                                                        doDelete(id, 1);
                                                                },
                                                                'Отменить': function () {
                                                                        jQuery(this).dialog("close");
                                                                }
                                                            });
                                    }
					jQuery('<div></div>').appendTo('body')
						.html(s_text)
						.dialog({
							modal: true,
							title: 'Удаление',
							zIndex: 10000,
							autoOpen: true,
							width: 'auto',
							resizable: false,
							buttons: buttons1,
							close: function (event, ui) {
								jQuery(this).remove();
							}
						});
				}
				function doDelete(id, is_delete) {
					var data = {
						'action': 'tzs_delete_product',
						'id': id,
                                                'is_delete': is_delete
					};
					
					jQuery.post(ajax_url, data, function(response) {
						if (response == '1') {
							window.open('/account/my-products/', '_self');
						} else {
							alert('Не удалось удалить: '+response);
						}
					});
				}
			</script>
<?php 
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 8
0
function tzs_products_table_record_out($row, $form_type, $pr_type_array, $profile_td_text = null)
{
    //    $user_info = tzs_get_user_meta($row->user_id);
    $output_tbody = '<tr rid="' . $row->id . '" id=';
    if ($row->sale_or_purchase == 1) {
        $output_tbody .= '"tbl_auctions_tr_lot_1"';
    } else {
        $output_tbody .= '"tbl_auctions_tr_lot_0"';
    }
    if ($row->top_status == 2) {
        $output_tbody .= $row->order_status == 1 ? ' class="vip_top_record"' : ($profile_td_text && $row->order_status !== null && $row->order_status == 0 ? ' class="pre_vip_top_record"' : '');
    } else {
        if ($row->top_status == 1) {
            $output_tbody .= ' class="top_record"';
        } else {
        }
    }
    $output_tbody .= '>';
    if ($profile_td_text == 'no') {
        $output_tbody .= '<td><input type="radio" order-status="' . ($row->order_status == null ? '' : $row->order_status) . '" top-status="' . $row->top_status . '" order-id="' . $row->order_id . '" record-active="' . $row->active . '" id="r_table_record_id" name="r_table_record_id" value="' . $row->id . '"';
        if (isset($_POST['table_record_id']) && $_POST['table_record_id'] == "{$row->id}") {
            $output_tbody .= 'checked="checked"';
        }
        $output_tbody .= '></td>';
    }
    $dt_created = convert_time($row->created, "d.m.y (Hч:iмин)");
    $dt_created = explode(" ", $dt_created);
    if ($row->dt_pickup != '0000-00-00 00:00:00') {
        $dt_pickup = convert_time($row->dt_pickup, "d.m.y (Hч:iмин)");
        $dt_pickup = explode(" ", $dt_pickup);
    } else {
        $dt_pickup = '';
    }
    /*<div class="record_number">
          <span class="middle" title="Номер заявки">
                 № '.$row->id.'
          </span>
      </div>*/
    $output_tbody .= '
            <td>
                <div>
                    <div class="date_label" title="Дата публикации заявки">
                        ' . $dt_created[0] . '
                    </div>
                    <div class="time_label" title="Время публикации заявки">
                        ' . $dt_created[1] . '
                    </div><br>';
    if ($dt_pickup != '') {
        $output_tbody .= '<div class="date_label" title="Дата бесплатного поднятия заявки в ТОП">
                    ' . $dt_pickup[0] . '
                </div>
                <div class="time_label" title="Время бесплатного поднятия заявки в ТОП">
                    ' . $dt_pickup[1] . '
                </div>';
    }
    $output_tbody .= '
                </div>
            </td>
            <td>
                <div>
                    <span title="Тип заявки">
                        <strong>';
    if ($row->sale_or_purchase == 1) {
        $output_tbody .= 'Продажа';
    } else {
        $output_tbody .= 'Покупка';
    }
    $output_tbody .= '</strong>
                    </span>
                </div>
            </td>';
    $output_tbody .= '<td>
                <div>
                    ' . convert_date_year2($row->created) . '<br/>
                    <span class="expired_label" title="Дата окончания публикации">
                        ' . convert_date_year2($row->expiration) . '
                    </span>
                </div>
            </td>
            <td>' . $pr_type_array[$row->type_id]['title'] . '
            </td>
            <td>
                <div class="ienlarger">';
    if (strlen($row->image_id_lists) > 0) {
        $main_image_id = $row->main_image_id;
        // Вначале выведем главное изображение
        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
        if ($attachment_info !== false) {
            $output_tbody .= '<a href="#nogo">
                                <img src="' . $attachment_info[0] . '" alt="thumb" class="resize_thumb">
                                <span>
                                    ' . trim($row->title) . '<br/>
                                    <img src="' . $attachment_info[0] . '" alt="large"/>
                                </span>
                            </a>';
        }
    }
    $output_tbody .= '</div>
            </td>
            <td>
                <div class="title_text">
                    <span title="Краткое описание товара">
                        ' . trim($row->title) . '
                    </span>
                        <br><br>' . tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from, 'Местонахождение товара') . '
                </div>
            </td>

            <td>
                <div>
                    <span class="price_label" title="Цена товара">
                        <strong>' . $row->price . '</strong> ' . $GLOBALS['tzs_pr_curr'][$row->currency] . '
                    </span>
                    <br>
                    <br>
                    <span class="copies_label" title="Количество товара">
                        <strong>' . $row->copies . '</strong> ' . $GLOBALS['tzs_pr_unit'][$row->unit] . '
                    </span>
                </div>
            </td>
            <td>
                <div>
                    <span class="payment_label" title="Форма оплаты">
                        ' . $GLOBALS['tzs_pr_payment'][$row->payment] . '<br/>
                        ' . $GLOBALS['tzs_pr_nds'][$row->nds] . '
                    </span>
                </div>
            </td>';
    $output_tbody .= '<td><div>';
    if ($row->fixed_or_tender == 2) {
        //$output_tbody .= '<span class="btnGray" title="Купить товар по фиксированной цене">Купить</span>';
        $output_tbody .= '<a class="btnBlue" title="Купить товар по фиксированной цене">Купить</a>';
        $output_tbody .= '<a class="btnBlue" title="Предложить свою цену за товар">Предложить свою цену</a>';
    } else {
        $output_tbody .= '<a class="btnBlue" title="Купить товар по фиксированной цене">Купить</a>';
        $output_tbody .= '<span class="btnGray" title="Предложить свою цену за товар">Предложить свою цену</span>';
    }
    $output_tbody .= '</div></td>';
    if ($profile_td_text == 'no') {
        $output_tbody .= '';
    } else {
        if ($profile_td_text) {
            $output_tbody .= '<td>' . $profile_td_text . '</td>';
        } else {
            $output_tbody .= '<td>' . tzs_print_user_contacts($row, $form_type, 0) . '</td>';
        }
    }
    $output_tbody .= '</tr>';
    return $output_tbody;
}
Ejemplo n.º 9
0
function tzs_tr_sh_table_record_out_cont($row, $form_type)
{
    //    $user_info = tzs_get_user_meta($row->user_id);
    if ($form_type === 'shipments') {
        $prefix = 'sh';
    } else {
        $prefix = 'tr';
    }
    $type = trans_types_to_str($row->trans_type, $row->tr_type);
    $cost = tzs_cost_to_str($row->cost, true);
    $output_tbody = '<tr rid="' . $row->id . '">';
    $output_tbody .= '
            <td>
                <div class="record_number">
                    <span class="middle" title="Номер заявки">
                           № ' . $row->id . '
                    </span>
                </div>
                <div>
                    <span class="time_label" title="Дата и время публикации заявки">
                        ' . convert_date_year2($row->time) . '<br>
                        ' . convert_time_only($row->time) . '
                    </span>
                </div>
            </td>
            <td>
                <div>' . tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $prefix === 'tr' ? $row->tr_city_from : $row->sh_city_from, 'Пункт погрузки') . '<br/>' . tzs_city_to_str($row->to_cid, $row->to_rid, $row->to_sid, $prefix === 'tr' ? $row->tr_city_to : $row->sh_city_to, 'Пункт выгрузки');
    if ($row->distance > 0 && $prefix === 'tr') {
        $output_tbody .= '<br/>' . tzs_make_distance_link($row->distance, false, array($row->tr_city_from, $row->tr_city_to));
    } else {
        if ($row->distance > 0 && $prefix === 'sh') {
            $output_tbody .= '<br/>' . tzs_make_distance_link($row->distance, false, array($row->sh_city_from, $row->sh_city_to));
        }
    }
    $output_tbody .= '
                </div>
            </td>
            <td>
                <div><strong>
                    <span class="expired_label" title="Дата погрузки">
                    ' . convert_date_year2($prefix === 'tr' ? $row->tr_date_from : $row->sh_date_from) . '<br/>
                    </span><br>
                    <span class="expired_label" title="Дата выгрузки">
                        ' . convert_date_year2($prefix === 'tr' ? $row->tr_date_to : $row->sh_date_to) . '
                    </span></strong>
                </div>
            </td>';
    if ($prefix === 'sh') {
        $output_tbody .= '<td>
                <div title="Тип груза">' . (isset($GLOBALS['tzs_sh_types'][$row->sh_type]) ? $GLOBALS['tzs_sh_types'][$row->sh_type] : '') . '</div>
            </td>';
        $output_tbody .= '<td><div>';
        if ($row->tr_weight > 0 || $row->sh_weight > 0) {
            $output_tbody .= '<span title="Вес груза">' . remove_decimal_part($prefix === 'tr' ? $row->tr_weight : $row->sh_weight) . ' т</span><br>';
        }
        if ($row->tr_volume > 0 || $row->sh_volume > 0) {
            $output_tbody .= '<span title="Объем груза">' . remove_decimal_part($prefix === 'tr' ? $row->tr_volume : $row->sh_volume) . ' м³</span>';
        }
        $output_tbody .= '</div></td>
            <td><div title="Описание груза">' . $row->sh_descr . '</div></td>';
    } else {
        $output_tbody .= '<td>
                <div title="Тип транспортного средства">' . $type . '</div>
            </td>
            <td><div title="Описание транспортного средства">';
        $tr_ds1 = '';
        $tr_ds2 = '';
        if ($row->tr_length > 0) {
            $tr_ds1 .= 'Д';
            $tr_ds2 .= intval($row->tr_length);
        }
        if ($row->tr_width > 0) {
            if ($tr_ds1 !== '') {
                $tr_ds1 .= 'x';
            }
            if ($tr_ds2 !== '') {
                $tr_ds2 .= 'x';
            }
            $tr_ds1 .= 'Ш';
            $tr_ds2 .= intval($row->tr_width);
        }
        if ($row->tr_height > 0) {
            if ($tr_ds1 !== '') {
                $tr_ds1 .= 'x';
            }
            if ($tr_ds2 !== '') {
                $tr_ds2 .= 'x';
            }
            $tr_ds1 .= 'В';
            $tr_ds2 .= intval($row->tr_height);
        }
        if ($tr_ds1 !== '' && $tr_ds2 !== '') {
            $output_tbody .= $tr_ds1 . ': ' . $tr_ds2 . ' м<br>';
        }
        if ($row->tr_weight > 0) {
            $output_tbody .= remove_decimal_part($row->tr_weight) . ' т<br>';
        }
        if ($row->tr_volume > 0) {
            $output_tbody .= remove_decimal_part($row->tr_volume) . ' м³<br>';
        }
        if ($row->tr_descr && strlen($row->tr_descr) > 0) {
            $output_tbody .= $row->tr_descr . '<br>';
        }
        $output_tbody .= '</div></td>
            <td><div title="Желаемый груз">' . $row->sh_descr . '</div></td>';
    }
    $output_tbody .= '<td><div title="Стоимость перевозки груза">';
    if ($row->price > 0) {
        $output_tbody .= $row->price . ' ' . $GLOBALS['tzs_curr'][$row->price_val] . '<br><br>' . round($row->price / $row->distance, 2) . ' ' . $GLOBALS['tzs_curr'][$row->price_val] . '/км';
    } else {
        $output_tbody .= $cost[0];
    }
    $output_tbody .= '</div>
            </td>
            <td>
                <div title="Форма оплаты услуг по перевозке груза">' . $cost[1] . '</div>
            </td>';
    if ($prefix === 'tr') {
        //$output_tbody .= '<td><div title="Комментарии">'.$row->comment.'</div></td>';
    }
    $output_tbody .= '</tr>';
    return $output_tbody;
}
Ejemplo n.º 10
0
function tzs_front_end_view_auction_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if ($sh_id <= 0) {
        print_error('Тендер не найден');
    } else {
        $sql = "SELECT * FROM " . TZS_AUCTIONS_TABLE . " WHERE id={$sh_id};";
        $row = $wpdb->get_row($sql);
        if (count($row) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить информацию о тендер. Свяжитесь, пожалуйста, с администрацией сайта.');
        } else {
            if ($row == null) {
                print_error('Тендер не найден');
            } else {
                if (isset($_GET['spis'])) {
                    echo "<a id='edit_search' href='/account/my-auctions/'>Назад к списку</a> <div style='clear: both'></div>";
                } else {
                    echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
                }
                ?>
                    <table border="0" id="view_ship">
			<tr>
				<td>Номер тендера</td>
				<td><?php 
                echo $row->id;
                ?>
</td>
			</tr>
			<tr>
				<td>Активен</td>
				<td><?php 
                echo $row->active == 1 ? 'Да' : 'Нет';
                ?>
</td>
			</tr>
			<tr>
				<td>Дата размещения</td>
				<td><?php 
                echo convert_date_no_year($row->created);
                ?>
 <?php 
                echo convert_time_only($row->time);
                ?>
</td>
			</tr>
			<?php 
                if ($row->last_edited != null) {
                    ?>
			<tr>
				<td>Дата последнего изменения</td>
				<td><?php 
                    echo convert_date_no_year($row->last_edited);
                    ?>
 <?php 
                    echo convert_time_only($row->last_edited);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->expiration != null) {
                    ?>
			<tr>
				<td>Дата окончания публикации</td>
				<td><?php 
                    echo convert_date_no_year($row->expiration);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->type_id > 0) {
                    ?>
			<tr>
				<td>Категория</td>
				<td><?php 
                    echo $row->type_id;
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<tr>
				<td>Краткое описание товара/услуги</td>
				<td><?php 
                echo htmlspecialchars($row->title);
                ?>
</td>
			</tr>
			<tr>
				<td>Полное описание товара/услуги</td>
				<td><?php 
                echo htmlspecialchars($row->description);
                ?>
</td>
			</tr>
			<?php 
                if ($row->copies > 0) {
                    ?>
			<tr>
				<td>Количество</td>
				<td><?php 
                    echo $row->copies;
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->price > 0) {
                    ?>
			<tr>
				<td>Стартовая стоимость товара</td>
				<td><?php 
                    echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if ($row->payment > 0) {
                    ?>
			<tr>
				<td>Форма оплаты</td>
				<td><?php 
                    echo $GLOBALS['tzs_pr_payment'][$row->payment];
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<tr>
				<td>Местонахождение</td>
				<td><?php 
                echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                ?>
</td>
			</tr>
			<?php 
                if (strlen($row->comment) > 0) {
                    ?>
			<tr>
				<td>Комментарии</td>
				<td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			<?php 
                if (strlen($row->image_id_lists) > 0) {
                    ?>
			<tr>
				<td>Изображения</td>
				<td><?php 
                    //$img_names = explode(';', $row->pictures);
                    $img_names = explode(';', $row->image_id_lists);
                    $main_image_id = $row->main_image_id;
                    if (count($img_names) > 0) {
                        ?>
                                    <table>
                                        <?php 
                        // Вначале выведем главное изображение
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                        if ($attachment_info !== false) {
                            echo '<tr><td><img src="' . $attachment_info[0] . '" alt=""></td></tr>';
                        }
                        // Затем выведем все остальные изображения
                        for ($i = 0; $i < count($img_names); $i++) {
                            if ($img_names[$i] !== $main_image_id) {
                                $attachment_info = wp_get_attachment_image_src($img_names[$i], 'full');
                                //if (file_exists(ABSPATH . $img_names[$i])) {
                                if ($attachment_info !== false) {
                                    echo '<tr><td><img src="' . $attachment_info[0] . '" alt=""></td></tr>';
                                }
                            }
                        }
                        ?>
                                    </table>
                                        <?php 
                    }
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
			</table>

			<br/>
			<h1 class="entry-title">Контактная информация</h1>
			
			<?php 
                if ($user_id == 0 && $GLOBALS['tzs_au_contact_view_all'] == false) {
                    ?>
				<div>Для просмотра контактов необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
			<?php 
                } else {
                    if ($user_id != $row->user_id) {
                        ?>
			<?php 
                        tzs_print_user_table($row->user_id);
                        ?>
			
			<script src="/wp-content/plugins/tzs/assets/js/feedback.js"></script>
			
			<button id="view_feedback" onClick="<?php 
                        echo tzs_feedback_build_url($row->user_id);
                        ?>
">Отзывы <span>|</span> Рейтинг пользователя</button>
			<?php 
                    } else {
                        ?>
				<button id="view_del" onClick="javascript: promptDelete(<?php 
                        echo $row->id;
                        ?>
);">Удалить</button>
				<button id="view_edit" onClick="javascript: window.open('/account/edit-auction/?id=<?php 
                        echo $row->id;
                        ?>
', '_self');">Изменить</button>
			<?php 
                    }
                }
                ?>

			<br/>
                        <hr/>
			<h2 class="entry-title">Информация о ставках</h2>
                        <?php 
                // Отбор ставок по тендеру - active=1 AND
                $sql = "SELECT * FROM " . TZS_AUCTION_RATES_TABLE . " WHERE auction_id={$sh_id} ORDER BY active DESC,created DESC;";
                $res = $wpdb->get_results($sql);
                if (count($res) == 0 && $wpdb->last_error != null) {
                    print_error('Не удалось отобразить информацию о ставках. Свяжитесь, пожалуйста, с администрацией сайта.');
                } else {
                    if (count($res) == 0) {
                        print_error('Ставки не найдены');
                    } else {
                        ?>
                            <table border="0" id="tbl_products">
                                <tr>
                                        <th>Статус</th>
                                        <th id="tbl_products_dtc">Дата и время размещения</th>
                                        <th id="tbl_products_dtc">Дата и время отзыва</th>
                                        <th id="price">Предложенная стоимость</th>
                                        <th id="price">Автор</th>
                                        <?php 
                        if ($user_id !== 0 || $GLOBALS['tzs_au_contact_view_all'] !== false) {
                            ?>
                                        <th id="price">Контактные данные</th>
                                        <?php 
                        }
                        ?>
                                </tr>
                                <?php 
                        foreach ($res as $row) {
                            $user_info = get_userdata($row->user_id);
                            ?>
                                    <tr id="<?php 
                            echo $row->active == 1 ? 'tbl_auction_rate_active' : 'tbl_auction_rate_reviewed';
                            ?>
">
                                        <td><?php 
                            echo $row->active == 1 ? 'Активна' : 'Отозвана';
                            ?>
</td>
                                        <td><?php 
                            echo convert_time($row->created);
                            ?>
</td>
                                        <td><?php 
                            echo $row->reviewed == null ? '&nbsp;' : convert_time($row->reviewed);
                            ?>
</td>
                                        <td><?php 
                            echo $row->rate . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                            ?>
</td>
                                        <td><?php 
                            $meta = get_user_meta($row->user_id, 'fio');
                            echo $meta[0];
                            ?>
</td>
                                        <?php 
                            if ($user_id !== 0 || $GLOBALS['tzs_au_contact_view_all'] !== false) {
                                ?>
                                        <td>
                                            <?php 
                                $meta = get_user_meta($row->user_id, 'telephone');
                                echo $meta[0] == null ? '' : 'Номера телефонов: ' . htmlspecialchars($meta[0]) . '<br/>';
                                ?>
                                            <?php 
                                echo $user_info->user_email == null ? '' : 'E-mail: ' . htmlspecialchars($user_info->user_email) . '<br/>';
                                ?>
                                            <?php 
                                $meta = get_user_meta($row->user_id, 'skype');
                                echo $meta[0] == null ? '' : 'Skype: ' . htmlspecialchars($meta[0]) . '<br/>';
                                ?>
                                        </td>
                                        <?php 
                            }
                            ?>
                                    </tr>
                                <?php 
                        }
                        ?>
                            </table>
                        <?php 
                    }
                }
                ?>
                                
			<script>
				function promptDelete(id) {
					jQuery('<div></div>').appendTo('body')
						.html('<div><h6>Удалить запись '+id+'?</h6></div>')
						.dialog({
							modal: true,
							title: 'Удаление',
							zIndex: 10000,
							autoOpen: true,
							width: 'auto',
							resizable: false,
							buttons: {
								'Да': function () {
									jQuery(this).dialog("close");
									doDelete(id);
								},
								'Нет': function () {
									jQuery(this).dialog("close");
								}
							},
							close: function (event, ui) {
								jQuery(this).remove();
							}
						});
				}
				function doDelete(id) {
					var data = {
						'action': 'tzs_delete_auction',
						'id': id
					};
					
					jQuery.post(ajax_url, data, function(response) {
						if (response == '1') {
							window.open('/account/my-auctions/', '_self');
						} else {
							alert('Не удалось удалить: '+response);
						}
					});
				}
			</script>
			<?php 
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 11
0
function tzs_front_end_user_products_handler($atts)
{
    // Определяем атрибуты
    // [tzs-view-user-products user_id="1"] - указываем на странице раздела
    // [tzs-view-products] - указываем на страницах подразделов
    extract(shortcode_atts(array('user_id' => '0'), $atts, 'tzs-view-user-products'));
    ob_start();
    $sql1 = ' AND user_id=' . $user_id;
    global $wpdb;
    $page = current_page_number();
    $url = current_page_url();
    $pp = TZS_RECORDS_PER_PAGE;
    $sql = "SELECT COUNT(*) as cnt FROM " . TZS_PRODUCTS_TABLE . " WHERE active=1 {$sql1} ";
    $res = $wpdb->get_row($sql);
    if (count($res) == 0 && $wpdb->last_error != null) {
        print_error('Не удалось отобразить список товаров. Свяжитесь, пожалуйста, с администрацией сайта -count');
    } else {
        $records = $res->cnt;
        $pages = ceil($records / $pp);
        if ($pages == 0) {
            $pages = 1;
        }
        if ($page > $pages) {
            $page = $pages;
        }
        $from = ($page - 1) * $pp;
        $sql = "SELECT * FROM " . TZS_PRODUCTS_TABLE . " WHERE active=1 {$sql1} ORDER BY created DESC LIMIT {$from},{$pp}; ";
        $res = $wpdb->get_results($sql);
        if (count($res) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить список товаров. Свяжитесь, пожалуйста, с администрацией сайта - record');
        } else {
            if (count($res) == 0) {
                ?>
                    <div style="clear: both;"></div>
                    <div class="errors">
                        <div id="info error">По Вашему запросу ничего не найдено.</div>
                    </div>
                    <?php 
            } else {
                ?>
                    <div>
                        <table id="tbl_products">
                        <tr>
                            <th id="tbl_products_id">Номер</th>
                            <th id="tbl_products_img">Фото</th>
                            <th id="tbl_products_dtc">Дата размещения</th>
                            <th id="title">Описание товара</th>
                            <th id="price">Стоимость товара</th>
                            <th id="descr">Форма оплаты</th>
                            <th id="cities">Город</th>
                            <th id="comm">Комментарии</th>
                        </tr>
                        <?php 
                foreach ($res as $row) {
                    ?>
                            <tr rid="<?php 
                    echo $row->id;
                    ?>
">
                                <td><?php 
                    echo $row->id;
                    ?>
</td>
                                <td>
                                    <?php 
                    if (strlen($row->image_id_lists) > 0) {
                        //$img_names = explode(';', $row->pictures);
                        $main_image_id = $row->main_image_id;
                        // Вначале выведем главное изображение
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'thumbnail');
                        if ($attachment_info !== false) {
                            //if (file_exists(ABSPATH . $img_names[0])) {
                            //echo '<img src="'.get_site_url().'/'.$img_names[0].'" alt="">';
                            echo '<img src="' . $attachment_info[0] . '" alt="">';
                            // width="50px" height="50px"
                        } else {
                            echo '&nbsp;';
                        }
                    } else {
                        echo '&nbsp;';
                    }
                    ?>
                                </td>
                                <td><?php 
                    echo convert_time($row->created);
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->title);
                    ?>
</td>
                                <td><?php 
                    echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                    ?>
</td>
                                <td><?php 
                    echo $GLOBALS['tzs_pr_payment'][$row->payment];
                    ?>
</td>
                                <td><?php 
                    echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
                            </tr>
                            <?php 
                }
                ?>
                        </table>
                    </div>
                <?php 
            }
            build_pages_footer($page, $pages);
        }
    }
    ////
    ?>
        <script src="/wp-content/plugins/tzs/assets/js/search.js"></script>
        <script>
                var post = [];
                <?php 
    echo "// POST dump here\n";
    foreach ($_POST as $key => $value) {
        echo "post[" . tzs_encode2($key) . "] = " . tzs_encode2($value) . ";\n";
    }
    if (!isset($_POST['type_id'])) {
        echo "post[" . tzs_encode2("type_id") . "] = " . tzs_encode2($p_id) . ";\n";
    }
    if (!isset($_POST['cur_type_id'])) {
        echo "post[" . tzs_encode2("cur_type_id") . "] = " . tzs_encode2($p_id) . ";\n";
    }
    ?>

                function showSearchDialog() {
                        doSearchDialog('products', post, null);
                        //doSearchDialog('auctions', post, null);
                }

                jQuery(document).ready(function(){
                        jQuery('#tbl_products').on('click', 'td', function(e) {  
                                var nonclickable = 'true' == e.delegateTarget.rows[0].cells[this.cellIndex].getAttribute('nonclickable');
                                var id = this.parentNode.getAttribute("rid");
                                if (!nonclickable)
                                        document.location = "/account/view-product/?id="+id;
                        });
                        hijackLinks(post);
                });
        </script>
	<?php 
    ////
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 12
0
function tzs_front_end_my_auctions_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $url = current_page_url();
    $page = current_page_number();
    $pp = TZS_RECORDS_PER_PAGE;
    $active = isset($_GET['active']) ? trim($_GET['active']) : '1';
    if ($user_id == 0) {
        ?>
            <div>Для просмотра необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
            <?php 
    } else {
        $sql = "SELECT COUNT(*) as cnt FROM " . TZS_AUCTIONS_TABLE . " WHERE user_id={$user_id} AND active={$active};";
        $res = $wpdb->get_row($sql);
        if (count($res) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить список тендеров. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            $records = $res->cnt;
            $pages = ceil($records / $pp);
            if ($pages == 0) {
                $pages = 1;
            }
            if ($page > $pages) {
                $page = $pages;
            }
            $from = ($page - 1) * $pp;
            $sql = "SELECT a.*,(SELECT COUNT(*) FROM " . TZS_AUCTION_RATES_TABLE . " c WHERE c.auction_id = a.id) AS rate_count FROM " . TZS_AUCTIONS_TABLE . " a  WHERE a.user_id={$user_id} AND a.active={$active} ORDER BY a.created DESC LIMIT {$from},{$pp};";
            $res = $wpdb->get_results($sql);
            if (count($res) == 0 && $wpdb->last_error != null) {
                print_error('Не удалось отобразить список тендеров. Свяжитесь, пожалуйста, с администрацией сайта');
            } else {
                ?>
                <div id="my_auctions_wrapper">
                    <div id="my_products_button">
                        <?php 
                if ($active === '1') {
                    ?>
                            <button id="view_del" onClick="javascript: window.open('/account/my-auction/?active=0', '_self');">Показать архивные</button>
                        <?php 
                } else {
                    ?>
                            <button id="view_edit" onClick="javascript: window.open('/account/my-auction/?active=1', '_self');">Показать действующие</button>
                        <?php 
                }
                ?>
                        <button id="view_add" onClick="javascript: window.open('/account/add-auction/', '_self');">Добавить тендер</button>
                    </div>

                    <div id="my_auctions_table">
                        <h3>Список <?php 
                echo $active === '1' ? 'действующих' : 'архивных';
                ?>
 тендеров</h3>
                        <table id="tbl_products">
                        <tr>
                            <th id="tbl_products_id">Номер</th>
                            <th id="tbl_auctions_lot">Тип<br>Кол-во ставок</th>
                            <th id="tbl_products_img">Фото</th>
                            <th id="tbl_products_dtc">Дата размещения<br>Дата окончания</th>
                            <th id="title">Описание</th>
                            <th id="copies">Кол-во</th>
                            <th id="price">Цена за единицу</th>
                            <th id="descr">Форма оплаты</th>
                            <th id="cities">Город</th>
                            <th id="comm">Комментарии</th>
                            <th id="actions" nonclickable="true">Действия</th>
                        </tr>
                        <?php 
                foreach ($res as $row) {
                    ?>
                            <tr rid="<?php 
                    echo $row->id;
                    ?>
" id="<?php 
                    echo $row->is_lot == 1 ? 'tbl_auctions_tr_lot_1' : 'tbl_auctions_tr_lot_0';
                    ?>
">
                                <td><?php 
                    echo $row->id;
                    ?>
</td>
                                <td><?php 
                    echo $row->is_lot == 1 ? 'Продам' : 'Куплю';
                    ?>
<br><br><?php 
                    echo 'Ставок-' . $row->rate_count;
                    ?>
</td>
                                <td>
                                    <?php 
                    if (strlen($row->image_id_lists) > 0) {
                        $main_image_id = $row->main_image_id;
                        // Вначале выведем главное изображение
                        //$attachment_info = wp_get_attachment_image_src($main_image_id, 'thumbnail');
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                        if ($attachment_info !== false) {
                            ?>
                                            <div class="ienlarger">
                                                <a href="#nogo">
                                                    <img src="<?php 
                            echo $attachment_info[0];
                            ?>
" alt="thumb" class="resize_thumb">
                                                    <span>
                                                        <?php 
                            echo htmlspecialchars($row->title);
                            ?>
<br/>
                                                        <img src="<?php 
                            echo $attachment_info[0];
                            ?>
" alt="large"/>
                                                    </span>
                                                </a>
                                            </div>
                                        <?php 
                        } else {
                            echo '&nbsp;';
                        }
                    } else {
                        echo '&nbsp;';
                    }
                    ?>
                                </td>
                                <td><?php 
                    echo convert_date($row->created);
                    ?>
<br><?php 
                    echo convert_date($row->expiration);
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->title);
                    ?>
</td>
                                <td><?php 
                    echo $row->copies . " " . $GLOBALS['tzs_au_unit'][$row->unit];
                    ?>
</td>
                                <td><?php 
                    echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                    ?>
</td>
                                <td><?php 
                    echo $GLOBALS['tzs_pr_payment'][$row->payment];
                    ?>
</td>
                                <td><?php 
                    echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
                                <td>
                                        <a href="javascript:doDisplay(<?php 
                    echo $row->id;
                    ?>
);" at="<?php 
                    echo $row->id;
                    ?>
" id="icon_set">Действия</a>
                                        <div id="menu_set" id2="menu" for="<?php 
                    echo $row->id;
                    ?>
" style="display:none;">
                                                <ul>
                                                        <a href="/account/view-auction/?id=<?php 
                    echo $row->id;
                    ?>
">Смотреть</a>
                                                        <a href="/account/edit-auction/?id=<?php 
                    echo $row->id;
                    ?>
">Изменить</a>
                                                        <a href="javascript: promptDelete(<?php 
                    echo $row->id . ', ' . $row->active;
                    ?>
);" id="red">Удалить</a>
                                                </ul>
                                        </div>
                                </td>
                            </tr>
                        <?php 
                }
                ?>
                        </table>
                    </div>
                </div>

            <script>
                jQuery(document).ready(function(){
                        jQuery('table').on('click', 'td', function(e) {  
                                var nonclickable = 'true' === e.delegateTarget.rows[0].cells[this.cellIndex].getAttribute('nonclickable');
                                var id = this.parentNode.getAttribute("rid");
                                if (!nonclickable)
                                        document.location = "/account/view-auction/?id="+id;
                        });
                        
                          //align element in the middle of the screen
                        jQuery.fn.alignCenter = function() {
                           //get margin left
                           //var marginLeft = Math.max(40, parseInt(jQuery(window).width()/2 - jQuery(this).width()/2)) + 'px';
                           var marginLeft = - jQuery(this).width()/2 + 'px';
                           //get margin top
                           //var marginTop = Math.max(40, parseInt(jQuery(window).height()/2 - jQuery(this).height()/2)) + 'px';
                           var marginTop = - jQuery(this).height()/2 + 'px';
                           //return updated element
                           //return jQuery(this).css({'margin-left':marginLeft*(-1), 'margin-top':marginTop*(-1)});
                           return jQuery(this).css({'margin-left':'120px', 'margin-top':marginTop});
                        };
                });

                function doDisplay(id) {
                        var el = jQuery('div[for='+id+']');
                        if (el.attr('style') === null) {
                                el.attr('style', 'display:none;');
                                jQuery('a[at='+id+']').attr('id', 'icon_set');
                        } else {
                                el.removeAttr('style');
                                jQuery('a[at='+id+']').attr('id', 'icon_set_cur');
                        }
                        jQuery("div[id2=menu]").each(function(i) {
                                var id2 = this.getAttribute('for');
                                if (id2 != ''+id) {
                                        this.setAttribute('style', 'display:none;');
                                        jQuery('a[at='+id2+']').attr('id', 'icon_set');
                                }
                        });
                }

                function promptDelete(id, active) {
                    if (active === 1) {
                        var s_text = '<div><h2>Удалить запись '+id+' или перенести в архив ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                        buttons1 = new Object({
                                                'В архив': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 0);
                                                },
                                                'Удалить': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 1);
                                                },
                                                'Отменить': function () {
                                                        jQuery(this).dialog("close");
                                                }
                                            });
                    } else {
                        var s_text = '<div><h2>Удалить запись '+id+' из архива ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                        buttons1 = new Object({
                                                'Удалить': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 1);
                                                },
                                                'Отменить': function () {
                                                        jQuery(this).dialog("close");
                                                }
                                            });
                    }
                    
                    jQuery('<div></div>').appendTo('body')
                        .html(s_text)
                        .dialog({
                                modal: true,
                                title: 'Удаление',
                                zIndex: 10000,
                                autoOpen: true,
                                width: 'auto',
                                resizable: false,
                                buttons: buttons1,
                                close: function (event, ui) {
                                        jQuery(this).remove();
                                }
                        });
                }

                function doDelete(id, is_delete) {
                        var data = {
                                'action': 'tzs_delete_auction',
                                'id': id,
                                'is_delete': is_delete
                        };

                        jQuery.post(ajax_url, data, function(response) {
                                if (response == '1') {
                                        location.reload();
                                } else {
                                        alert('Не удалось удалить: '+response);
                                }
                        });
                }
                </script>
                <?php 
                build_pages_footer($page, $pages);
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 13
0
function tzs_front_end_my_products_handler($atts)
{
    ob_start();
    global $wpdb;
    $user_id = get_current_user_id();
    $url = current_page_url();
    $page = current_page_number();
    $pp = TZS_RECORDS_PER_PAGE;
    $active = isset($_GET['active']) ? trim($_GET['active']) : '1';
    if ($user_id == 0) {
        ?>
            <div>Для просмотра необходимо <a href="/account/login/">войти</a> или <a href="/account/registration/">зарегистрироваться</a></div>
            <?php 
    } else {
        $sql = "SELECT COUNT(*) as cnt FROM " . TZS_PRODUCTS_TABLE . " WHERE user_id={$user_id} AND active={$active};";
        $res = $wpdb->get_row($sql);
        if (count($res) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить список товаров/услуг. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            $records = $res->cnt;
            $pages = ceil($records / $pp);
            if ($pages == 0) {
                $pages = 1;
            }
            if ($page > $pages) {
                $page = $pages;
            }
            $from = ($page - 1) * $pp;
            // Добавим отбор счетов и сортировку по ним для активных записей
            if ($active == 0) {
                $sql = "SELECT * FROM " . TZS_PRODUCTS_TABLE . "  WHERE user_id={$user_id} AND active={$active} ORDER BY created DESC LIMIT {$from},{$pp};";
            } else {
                $sql = "SELECT a.*,";
                $sql .= " b.id AS order_id,";
                $sql .= " b.number AS order_number,";
                $sql .= " b.status AS order_status,";
                $sql .= " b.dt_pay AS order_dt_pay,";
                $sql .= " b.dt_expired AS order_dt_expired,";
                $sql .= " IFNULL(b.dt_pay, a.created) AS dt_sort";
                $sql .= " FROM " . TZS_PRODUCTS_TABLE . " a";
                $sql .= " LEFT OUTER JOIN wp_tzs_orders b ON (b.tbl_type = 'PR' AND a.id = b.tbl_id AND ((b.status=1 AND b.dt_expired > NOW()) OR b.status=0) )";
                $sql .= " WHERE a.user_id={$user_id} AND a.active={$active}";
                $sql .= " ORDER BY order_status DESC, dt_sort DESC";
                $sql .= " LIMIT {$from},{$pp};";
            }
            $res = $wpdb->get_results($sql);
            if (count($res) == 0 && $wpdb->last_error != null) {
                print_error('Не удалось отобразить список товаров/услуг. Свяжитесь, пожалуйста, с администрацией сайта');
            } else {
                ?>
                <div id="my_products_wrapper">
                    <div id="my_products_table">
                        <table id="tbl_products">
                        <thead>
                            <tr id="tbl_thead_records_per_page">
                                <!--th colspan="10" id="thead_h1"-->
                                <!--th colspan="4" id="thead_h1"-->
                                <th colspan="4">
                                    <div class="div_td_left">
                                        <h3>Список <?php 
                echo $active === '1' ? 'публикуемых' : 'архивных';
                ?>
 товаров</h3>
                                    </div>
                                </th>
                                
                                <th colspan="6">
                                    <div id="my_products_button">
                                        <?php 
                if ($active === '1') {
                    ?>
                                            <button id="view_del" onClick="javascript: window.open('/account/my-products/?active=0', '_self');">Показать архивные</button>
                                        <?php 
                } else {
                    ?>
                                            <button id="view_edit" onClick="javascript: window.open('/account/my-products/?active=1', '_self');">Показать публикуемые</button>
                                        <?php 
                }
                ?>
                                        <button id="view_add" onClick="javascript: window.open('/account/add-product/', '_self');">Добавить товар</button>
                                    </div>
                                </th>
                            </tr>
                            <tr>
                                <th id="tbl_products_id">№, дата и время заявки</th>
                                <th id="tbl_products_sale">Покупка<br/>Продажа</th>
                                <th id="tbl_products_img">Фото</th>
                                <th id="tbl_products_dtc">Период публикации</th>
                                <th id="title">Описание товара</th>
                                <th id="price">Стоимость товара</th>
                                <th id="descr">Форма оплаты</th>
                                <th id="cities">Город</th>
                                <th id="comm">Комментарии</th>
                                <th id="actions" nonclickable="true">Действия</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php 
                foreach ($res as $row) {
                    ?>
                            <tr rid="<?php 
                    echo $row->id;
                    ?>
" <?php 
                    echo $row->order_status == 1 ? ' class="top_record"' : ($row->order_status !== null && $row->order_status == 0 ? ' class="pre_top_record"' : '');
                    ?>
 >
                                <td>
                                    <?php 
                    echo $row->id;
                    ?>
<br>
                                    <?php 
                    echo convert_time($row->created);
                    ?>
                                </td>
                                <td>
                                    <?php 
                    echo $row->sale_or_purchase == 1 ? 'Продажа' : 'Покупка';
                    ?>
<br><br>
                                    <?php 
                    echo $row->fixed_or_tender == 1 ? 'Цена зафиксирована' : 'Тендерное предложение';
                    ?>
                                </td>
                                <td>
                                    <?php 
                    if (strlen($row->image_id_lists) > 0) {
                        $main_image_id = $row->main_image_id;
                        // Вначале выведем главное изображение
                        $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                        if ($attachment_info !== false) {
                            ?>
                                            <div class="ienlarger">
                                                <a href="#nogo">
                                                    <img src="<?php 
                            echo $attachment_info[0];
                            ?>
" alt="thumb" class="resize_thumb">
                                                    <span>
                                                        <?php 
                            echo htmlspecialchars($row->title);
                            ?>
<br/>
                                                        <img src="<?php 
                            echo $attachment_info[0];
                            ?>
" alt="large"/>
                                                    </span>
                                                </a>
                                            </div>
                                        <?php 
                        } else {
                            echo '&nbsp;';
                        }
                    } else {
                        echo '&nbsp;';
                    }
                    ?>
                                </td>
                                <td><?php 
                    echo convert_date($row->created) . '<br>' . convert_date($row->expiration);
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->title);
                    ?>
</td>
                                <td><?php 
                    echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                    ?>
</td>
                                <td><?php 
                    echo $GLOBALS['tzs_pr_payment'][$row->payment];
                    ?>
</td>
                                <td><?php 
                    echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                    ?>
</td>
                                <td><?php 
                    echo htmlspecialchars($row->comment);
                    ?>
</td>
                                <td>
                                        <a href="javascript:doDisplay(<?php 
                    echo $row->id;
                    ?>
);" at="<?php 
                    echo $row->id;
                    ?>
" id="icon_set">Действия</a>
                                        <div id="menu_set" id2="menu" for="<?php 
                    echo $row->id;
                    ?>
" style="display:none;">
                                                <ul>
                                                        <a href="/account/view-product/?id=<?php 
                    echo $row->id;
                    ?>
&link=my-products&active=<?php 
                    echo $active;
                    ?>
">Смотреть</a>
                                                        <a href="/account/edit-product/?id=<?php 
                    echo $row->id;
                    ?>
">Изменить</a>
                                                    <?php 
                    if ($row->active && $row->order_status === null) {
                        ?>
                                                        <a href="javascript:promptPickUp(<?php 
                        echo $row->id;
                        ?>
, 'PR');">В ТОП</a>
                                                    <?php 
                    }
                    ?>
                                                        
                                                    <?php 
                    if ($row->active && $row->order_status !== null && $row->order_status == 0) {
                        ?>
                                                        <a href="/account/view-order/?id=<?php 
                        echo $row->order_id;
                        ?>
">Счет ТОП</a>
                                                    <?php 
                    }
                    ?>
                                                        <a href="javascript:promptDelete(<?php 
                    echo $row->id . ', ' . $row->active;
                    ?>
);" id="red">Удалить</a>
                                                </ul>
                                        </div>
                                </td>
                            </tr>
                        <?php 
                }
                ?>
                        </tbody>
                        </table>
                    </div>
                </div>
            
                <!-- Modal -->
                <!--div id="RecordPickUpModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-header">
                        <button id="RecordPickUpModalCloseButton" type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">Поднятие объявления в ТОП</h3>
                    </div>
                    <div class="modal-body">
                        <h4>Создать счет на оплату услуг добавления заявки в ТОП ?</h4>
                        <form id="RecordPickUpForm" method="post" action="" class="pr_edit_form">
                            <div class="pr_edit_form_line">
                                <label for="order_tbl_type">Префикс таблицы</label>
                                <input type="text" id="order_tbl_type" name="order_tbl_type" value="" disabled="disabled">
                            </div>
                            <div class="pr_edit_form_line">
                                <label for="order_tbl_id">ID заявки</label>
                                <input type="text" id="order_tbl_id" name="order_tbl_id" value="" disabled="disabled">
                            </div>
                            <div class="pr_edit_form_line">
                                <label for="order_cost">Стоимость услуги, грн</label>
                                <input type="text" id="order_cost" name="order_cost" value="<?php 
                echo get_option('t3s_setting_record_pickup_cost');
                ?>
" disabled="disabled">
                            </div>
                        </form>
                        <div id="RecordPickUpInfo"></div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal">Закрыть</button>
                        <button id="RecordPickUpSubmit" class="btn btn-primary" onClick="doPickUp();">Создать счет</button>
                    </div>
                </div-->

                <?php 
                include_once WP_PLUGIN_DIR . '/tzs/front-end/tzs.my.new_order.php';
                ?>
                
    <script src="/wp-content/plugins/tzs/assets/js/jquery.stickytableheaders.min.js"></script>
            <script>
/*                function promptPickUp(id, table_prefix) {
                    jQuery("#order_tbl_type").attr('value', table_prefix);
                    jQuery("#order_tbl_id").attr('value', id);
                    jQuery("#RecordPickUpModal").modal('show');
                }
                
                function doPickUp() {
                    jQuery("#RecordPickUpSubmit").attr('disabled', 'disabled');
                    jQuery('#RecordPickUpInfo').html('Подождите, идет формирование счета на оплату...');
                    //fd = jQuery('#RecordPickUpModal form#RecordPickUpForm').serialize();
                    fd = 'order_tbl_type=' + jQuery("#order_tbl_type").val() + '&order_tbl_id=' + jQuery("#order_tbl_id").val();
                    jQuery.ajax({
                        url: "/wp-admin/admin-ajax.php?action=tzs_order_add",
                        type: "POST",
                        data: fd,
                        dataType: 'json',
                        success: function(data) {
                            if ((data.output_error !== 'undefined') && (data.output_error !== '')) {
                                jQuery('#RecordPickUpInfo').html(data.output_error);
                            }
                            if ((data.order_id !== 'undefined') && (data.order_id !== '')) {
                                location.href = "<?php 
                //echo get_site_url();
                ?>
/account/view-order/?id=" + data.order_id + "&spis=new";
                            }
                        },
                        error: function(data) {
                            if (data.responseText !== 'undefined') {
                                jQuery('#RecordPickUpInfo').html(data.responseText);
                            }
                        }			
                    });
                    
                }
*/                
                function doDisplay(id) {
                        var el = jQuery('div[for='+id+']');
                        if (el.attr('style') == null) {
                                el.attr('style', 'display:none;');
                                jQuery('a[at='+id+']').attr('id', 'icon_set');
                        } else {
                                el.removeAttr('style');
                                jQuery('a[at='+id+']').attr('id', 'icon_set_cur');
                        }
                        jQuery("div[id2=menu]").each(function(i) {
                                var id2 = this.getAttribute('for');
                                if (id2 != ''+id) {
                                        this.setAttribute('style', 'display:none;');
                                        jQuery('a[at='+id2+']').attr('id', 'icon_set');
                                }
                        });
                }

                function promptDelete(id, active) {
                    if (active === 1) {
                        var s_text = '<div><h2>Удалить запись '+id+' или перенести в архив ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                        buttons1 = new Object({
                                                'В архив': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 0);
                                                },
                                                'Удалить': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 1);
                                                },
                                                'Отменить': function () {
                                                        jQuery(this).dialog("close");
                                                }
                                            });
                    } else {
                        var s_text = '<div><h2>Удалить запись '+id+' из архива ?</h2><hr/><p>Запись из архива можно в любой момент снова опубликовать.</p><p>При удалении записи будут так же удалены все прикрепленные изображения.</p></div>';
                        buttons1 = new Object({
                                                'Удалить': function () {
                                                        jQuery(this).dialog("close");
                                                        doDelete(id, 1);
                                                },
                                                'Отменить': function () {
                                                        jQuery(this).dialog("close");
                                                }
                                            });
                    }
                        jQuery('<div></div>').appendTo('body')
                                .html(s_text)
                                .dialog({
                                        modal: true,
                                        title: 'Удаление',
                                        zIndex: 10000,
                                        autoOpen: true,
                                        width: 'auto',
                                        resizable: false,
                                        buttons: buttons1,
                                        close: function (event, ui) {
                                                jQuery(this).remove();
                                        }
                                });
                }

                function doDelete(id, is_delete) {
                        var data = {
                                'action': 'tzs_delete_product',
                                'id': id,
                                'is_delete': is_delete
                        };

                        jQuery.post(ajax_url, data, function(response) {
                                if (response == '1') {
                                        location.reload();
                                } else {
                                        alert('Не удалось удалить: '+response);
                                }
                        });
                }
                
                jQuery(document).ready(function(){
                        jQuery('table').on('click', 'td', function(e) {  
                                var nonclickable = 'true' == e.delegateTarget.rows[1].cells[this.cellIndex].getAttribute('nonclickable');
                                var id = this.parentNode.getAttribute("rid");
                                if (!nonclickable)
                                        document.location = "/account/view-product/?id="+id+"&link=my-products&active=<?php 
                echo $active;
                ?>
";
                        });
                        
                        jQuery("#tbl_products").stickyTableHeaders();
                });

            </script>
                <?php 
                build_pages_footer($page, $pages);
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Ejemplo n.º 14
0
function tzs_front_end_auctions_handler($atts)
{
    // Определяем атрибуты
    // [tzs-view-auctions rootcategory="1"] - указываем на странице раздела
    // [tzs-view-auctions] - указываем на страницах подразделов
    extract(shortcode_atts(array('rootcategory' => '0'), $atts, 'tzs-view-auctions'));
    ob_start();
    $p_id = get_the_ID();
    $p_title = the_title('', '', false);
    // Если указан параметр rootcategory, то выводим все товары раздела
    // Иначе - товары категории
    if ($rootcategory === '1') {
        $sql1 = ' AND type_id IN (' . tzs_build_product_types_id_str($p_id) . ')';
        $p_name = '';
    } else {
        $sql1 = ' AND type_id=' . $p_id;
        $p_name = get_post_field('post_name', $p_id);
    }
    $sp = tzs_validate_pr_search_parameters();
    $errors = $sp['errors'];
    if (count($errors) > 0) {
        print_errors($errors);
    }
    ?>
	<a href="javascript:showSearchDialog();" id="edit_search">Изменить параметры поиска</a>
    <?php 
    if (count($errors) == 0) {
        $s_sql = tzs_search_pr_parameters_to_sql($sp, '');
        $s_title = tzs_search_pr_parameters_to_str($sp);
        ?>
            <div id="search_info"><?php 
        echo $p_title;
        echo strlen($s_title) > 0 ? ' * ' . $s_title : '';
        ?>
</div>
	<?php 
        $page = current_page_number();
        ?>
	<a tag="page" id="realod_btn" href="<?php 
        echo build_page_url($page);
        ?>
">Обновить</a>
	<?php 
        global $wpdb;
        $url = current_page_url();
        $pp = TZS_RECORDS_PER_PAGE;
        $sql = "SELECT COUNT(*) as cnt FROM " . TZS_AUCTIONS_TABLE . " WHERE active=1 {$sql1} {$s_sql};";
        $res = $wpdb->get_row($sql);
        if (count($res) == 0 && $wpdb->last_error != null) {
            print_error('Не удалось отобразить список тендеров. Свяжитесь, пожалуйста, с администрацией сайта');
        } else {
            $records = $res->cnt;
            $pages = ceil($records / $pp);
            if ($pages == 0) {
                $pages = 1;
            }
            if ($page > $pages) {
                $page = $pages;
            }
            $from = ($page - 1) * $pp;
            $sql = "SELECT a.*,(SELECT COUNT(*) FROM " . TZS_AUCTION_RATES_TABLE . " c WHERE c.auction_id = a.id) AS rate_count FROM " . TZS_AUCTIONS_TABLE . " a  WHERE a.active=1 {$sql1} {$s_sql} ORDER BY a.created DESC LIMIT {$from},{$pp};";
            $res = $wpdb->get_results($sql);
            if (count($res) == 0 && $wpdb->last_error != null) {
                print_error('Не удалось отобразить список тендеров. Свяжитесь, пожалуйста, с администрацией сайта.');
            } else {
                if (count($res) == 0) {
                    ?>
                    <div style="clear: both;"></div>
                    <div class="errors">
                        <div id="info error">По Вашему запросу ничего не найдено.</div>
                    </div>
                    <?php 
                } else {
                    ?>
                    <div>
                        <table id="tbl_products">
                        <tr>
                            <th id="tbl_products_id">Номер</th>
                            <th id="tbl_auctions_lot">Тип<br>Кол-во ставок</th>
                            <th id="tbl_products_img">Фото</th>
                            <th id="tbl_products_dtc">Дата размещения<br>Дата окончания</th>
                            <th id="tbl_auctions_title">Описание</th>
                            <th id="tbl_auctions_copies">Кол-во</th>
                            <th id="tbl_products_price">Цена за единицу</th>
                            <th id="tbl_products_payment">Форма оплаты</th>
                            <th id="tbl_products_cities">Город</th>
                            <th id="tbl_products_comm">Комментарии</th>
                        </tr>
                        <?php 
                    foreach ($res as $row) {
                        ?>
                            <tr rid="<?php 
                        echo $row->id;
                        ?>
" id="<?php 
                        echo $row->is_lot == 1 ? 'tbl_auctions_tr_lot_1' : 'tbl_auctions_tr_lot_0';
                        ?>
">
                                <td><?php 
                        echo $row->id;
                        ?>
</td>
                                <td><?php 
                        echo $row->is_lot == 1 ? 'Продам' : 'Куплю';
                        ?>
<br><br><?php 
                        echo 'Ставок-' . $row->rate_count;
                        ?>
</td>
                                <td>
                                    <?php 
                        if (strlen($row->image_id_lists) > 0) {
                            $main_image_id = $row->main_image_id;
                            // Вначале выведем главное изображение
                            $attachment_info = wp_get_attachment_image_src($main_image_id, 'full');
                            if ($attachment_info !== false) {
                                ?>
                                            <div class="ienlarger">
                                                <a href="#nogo">
                                                    <img src="<?php 
                                echo $attachment_info[0];
                                ?>
" alt="thumb" class="resize_thumb">
                                                    <span>
                                                        <?php 
                                echo htmlspecialchars($row->title);
                                ?>
<br/>
                                                        <img src="<?php 
                                echo $attachment_info[0];
                                ?>
" alt="large"/>
                                                    </span>
                                                </a>
                                            </div>
                                        <?php 
                            } else {
                                echo '&nbsp;';
                            }
                        } else {
                            echo '&nbsp;';
                        }
                        ?>
                                </td>
                                <td><?php 
                        echo convert_date($row->created);
                        ?>
<br><?php 
                        echo convert_date($row->expiration);
                        ?>
</td>
                                <td><?php 
                        echo htmlspecialchars($row->title);
                        ?>
</td>
                                <td><?php 
                        echo $row->copies . " " . $GLOBALS['tzs_au_unit'][$row->unit];
                        ?>
</td>
                                <td><?php 
                        echo $row->price . " " . $GLOBALS['tzs_pr_curr'][$row->currency];
                        ?>
</td>
                                <td><?php 
                        echo $GLOBALS['tzs_pr_payment'][$row->payment];
                        ?>
</td>
                                <td><?php 
                        echo tzs_city_to_str($row->from_cid, $row->from_rid, $row->from_sid, $row->city_from);
                        ?>
</td>
                                <td><?php 
                        echo htmlspecialchars($row->comment);
                        ?>
</td>
                            </tr>
                            <?php 
                    }
                    ?>
                        </table>
                    </div>
                <?php 
                }
                build_pages_footer($page, $pages);
            }
        }
    }
    ////
    ?>
        <script src="/wp-content/plugins/tzs/assets/js/search.js"></script>
        <script>
                var post = [];
                <?php 
    echo "// POST dump here\n";
    foreach ($_POST as $key => $value) {
        echo "post[" . tzs_encode2($key) . "] = " . tzs_encode2($value) . ";\n";
    }
    if (!isset($_POST['type_id'])) {
        echo "post[" . tzs_encode2("type_id") . "] = " . tzs_encode2($p_id) . ";\n";
    }
    if (!isset($_POST['cur_type_id'])) {
        echo "post[" . tzs_encode2("cur_type_id") . "] = " . tzs_encode2($p_id) . ";\n";
    }
    if (!isset($_POST['cur_post_name']) && $p_name !== '') {
        echo "post[" . tzs_encode2("cur_post_name") . "] = " . tzs_encode2($p_name) . ";\n";
    }
    ?>

                function showSearchDialog() {
                        doSearchDialog('auctions', post, null);
                }

                jQuery(document).ready(function(){
                        jQuery('#tbl_products').on('click', 'td', function(e) {  
                                var nonclickable = 'true' == e.delegateTarget.rows[0].cells[this.cellIndex].getAttribute('nonclickable');
                                var id = this.parentNode.getAttribute("rid");
                                if (!nonclickable)
                                        document.location = "/account/view-auction/?id="+id;
                        });
                        hijackLinks(post);
                });
        </script>
	<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}