Example #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;
}
Example #2
0
function tzs_front_end_edit_truck_handler($atts)
{
    ob_start();
    $user_id = get_current_user_id();
    $tr_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if (!is_user_logged_in()) {
        print_error("Вход в систему обязателен");
    } else {
        if ($tr_id <= 0) {
            print_error('Груз не найден');
        } else {
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['action']) && $_POST['action'] == 'edittruck' && $_POST['formName'] == 'truck') {
                $id = isset($_POST['id']) && is_numeric($_POST['id']) ? intval($_POST['id']) : 0;
                tzs_edit_truck($id);
            } else {
                global $wpdb;
                $sql = "SELECT * FROM " . TZS_TRUCK_TABLE . " WHERE id={$tr_id} AND user_id={$user_id};";
                $row = $wpdb->get_row($sql);
                if (count($row) == 0 && $wpdb->last_error != null) {
                    print_error('Не удалось отобразить информацию о транспорте. Свяжитесь, пожалуйста, с администрацией сайта');
                } else {
                    if ($row == null) {
                        print_error('Груз не найден');
                    } else {
                        $cost = json_decode($row->cost);
                        foreach ($cost as $key => $val) {
                            $_POST[$key] = '' . $val;
                        }
                        $_POST['tr_date_from'] = date("d.m.Y", strtotime($row->tr_date_from));
                        $_POST['tr_date_to'] = date("d.m.Y", strtotime($row->tr_date_to));
                        $_POST['tr_city_from'] = $row->tr_city_from;
                        $_POST['tr_city_to'] = $row->tr_city_to;
                        $_POST['comment'] = $row->comment;
                        if ($row->tr_weight > 0) {
                            $_POST['tr_weight'] = '' . remove_decimal_part($row->tr_weight);
                        }
                        if ($row->tr_volume > 0) {
                            $_POST['tr_volume'] = '' . remove_decimal_part($row->tr_volume);
                        }
                        $_POST['trans_type'] = '' . $row->trans_type;
                        $_POST['tr_type'] = '' . $row->tr_type;
                        $_POST['trans_count'] = '' . $row->trans_count;
                        if ($row->tr_length > 0 || $row->tr_height > 0 || $row->tr_width > 0) {
                            $_POST['set_dim'] = '';
                            $_POST['tr_width'] = '' . remove_decimal_part($row->tr_width);
                            $_POST['tr_height'] = '' . remove_decimal_part($row->tr_height);
                            $_POST['tr_length'] = '' . remove_decimal_part($row->tr_length);
                        }
                        $_POST['sh_descr'] = $row->sh_descr;
                        $_POST['tr_active'] = $row->active;
                        $_POST['id'] = '' . $row->id;
                        tzs_print_truck_form(null, true);
                    }
                }
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #3
0
function tzs_front_end_truck_get_record($tr_id, $is_duplicate = false)
{
    global $wpdb;
    $user_id = get_current_user_id();
    $sql = "SELECT * FROM " . TZS_TRUCK_TABLE . " WHERE id={$tr_id} AND user_id={$user_id};";
    $row = $wpdb->get_row($sql);
    if (count($row) == 0 && $wpdb->last_error != null) {
        print_error('Не удалось отобразить информацию о транспорте. Свяжитесь, пожалуйста, с администрацией сайта');
    } else {
        if ($row == null) {
            print_error('Груз не найден');
        } else {
            $sql_flag1 = "SELECT * FROM " . TZS_COUNTRIES_TABLE . " WHERE country_id=" . $row->from_cid;
            $row1 = $wpdb->get_row($sql_flag1);
            $sql_flag2 = "SELECT * FROM " . TZS_COUNTRIES_TABLE . " WHERE country_id=" . $row->to_cid;
            $row2 = $wpdb->get_row($sql_flag2);
            $_POST['from_code'] = "/wp-content/plugins/tzs/assets/images/flags/" . strtolower($row1->code) . '.png';
            $_POST['to_code'] = "/wp-content/plugins/tzs/assets/images/flags/" . strtolower($row2->code) . '.png';
            if ($is_duplicate) {
                $_POST['tr_date_from'] = date("d.m.Y");
                $_POST['tr_date_to'] = date("d.m.Y");
            } else {
                $_POST['tr_date_from'] = date("d.m.Y", strtotime($row->tr_date_from));
                $_POST['tr_date_to'] = date("d.m.Y", strtotime($row->tr_date_to));
            }
            $_POST['tr_city_from'] = $row->tr_city_from;
            $_POST['tr_city_to'] = $row->tr_city_to;
            $_POST['comment'] = $row->comment;
            if ($row->tr_weight > 0) {
                $_POST['tr_weight'] = '' . remove_decimal_part($row->tr_weight);
            }
            if ($row->tr_volume > 0) {
                $_POST['tr_volume'] = '' . remove_decimal_part($row->tr_volume);
            }
            $_POST['trans_type'] = '' . $row->trans_type;
            $_POST['tr_type'] = '' . $row->tr_type;
            $_POST['trans_count'] = '' . $row->trans_count;
            if ($row->tr_length > 0 || $row->tr_height > 0 || $row->tr_width > 0) {
                $_POST['set_dim'] = '';
                if ($row->tr_width > 0) {
                    $_POST['tr_width'] = '' . remove_decimal_part($row->tr_width);
                }
                if ($row->tr_height > 0) {
                    $_POST['tr_height'] = '' . remove_decimal_part($row->tr_height);
                }
                if ($row->tr_length > 0) {
                    $_POST['tr_length'] = '' . remove_decimal_part($row->tr_length);
                }
            }
            if ($row->cost > 0) {
                $_POST['cost'] = '' . remove_decimal_part($row->cost);
            }
            if ($row->price > 0) {
                $_POST['price'] = '' . remove_decimal_part($row->price);
            }
            if ($row->price_val > 0) {
                $_POST['cost_curr'] = '' . remove_decimal_part($row->price_val);
            }
            if ($row->prepayment > 0) {
                $_POST['prepayment'] = '' . remove_decimal_part($row->prepayment);
            }
            if ($row->cash > 0) {
                $_POST['cash'] = 'on';
            }
            if ($row->nocash > 0) {
                $_POST['nocash'] = 'on';
            }
            if ($row->way_ship > 0) {
                $_POST['way_ship'] = 'on';
            }
            if ($row->way_debark > 0) {
                $_POST['way_debark'] = 'on';
            }
            if ($row->soft > 0) {
                $_POST['soft'] = 'on';
            }
            if ($row->way_prepay > 0) {
                $_POST['way_prepay'] = 'on';
            }
            if ($row->price_query > 0) {
                $_POST['price_query'] = 'on';
            }
            if ($row->top_loading > 0) {
                $_POST['top_loading'] = 'on';
            }
            if ($row->side_loading > 0) {
                $_POST['side_loading'] = 'on';
            }
            if ($row->back_loading > 0) {
                $_POST['back_loading'] = 'on';
            }
            if ($row->full_movale > 0) {
                $_POST['full_movable'] = 'on';
            }
            if ($row->remove_cross > 0) {
                $_POST['remove_cross'] = 'on';
            }
            if ($row->remove_racks > 0) {
                $_POST['remove_racks'] = 'on';
            }
            if ($row->without_gate > 0) {
                $_POST['without_gate'] = 'on';
            }
            $_POST['sh_distance'] = $row->distance;
            $_POST['sh_descr'] = $row->sh_descr;
            $_POST['tr_active'] = $row->active;
            $_POST['input_city'] = explode(";", $row->path_segment_cities);
            $_POST['path_segment_distances'] = $row->path_segment_distances;
            if (!$is_duplicate) {
                $_POST['id'] = '' . $row->id;
            }
        }
    }
}
Example #4
0
function tzs_front_end_edit_product_handler($atts)
{
    ob_start();
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if (!is_user_logged_in()) {
        print_error("Вход в систему обязателен");
    } else {
        if ($sh_id <= 0) {
            print_error('Товар/услуга не найден');
        } else {
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['action']) && $_POST['action'] == 'editproduct' && $_POST['formName'] == 'product') {
                $id = isset($_POST['id']) && is_numeric($_POST['id']) ? intval($_POST['id']) : 0;
                tzs_edit_product($id);
            } else {
                global $wpdb;
                $sql = "SELECT * FROM " . TZS_PRODUCTS_TABLE . " WHERE id={$sh_id} AND user_id={$user_id};";
                $row = $wpdb->get_row($sql);
                if (count($row) == 0 && $wpdb->last_error != null) {
                    print_error('Не удалось отобразить информацию о товаре/услуге. Свяжитесь, пожалуйста, с администрацией сайта');
                } else {
                    if ($row == null) {
                        print_error('Товар/услуга не найден');
                    } else {
                        //" (type_id, title, description, copies, currency, price, payment, city_from, comment, expiration)".
                        $_POST['pr_type_id'] = '' . $row->type_id;
                        $_POST['pr_title'] = $row->title;
                        $_POST['pr_description'] = $row->description;
                        $_POST['pr_copies'] = '' . $row->copies;
                        $_POST['pr_currency'] = '' . $row->currency;
                        if ($row->price > 0) {
                            $_POST['pr_price'] = '' . remove_decimal_part($row->price);
                        }
                        $_POST['pr_payment'] = '' . $row->payment;
                        $_POST['pr_city_from'] = $row->city_from;
                        $_POST['pr_comment'] = $row->comment;
                        if ($row->expiration !== null) {
                            $_POST['pr_expiration'] = date("d.m.Y", strtotime($row->expiration));
                        }
                        $_POST['id'] = '' . $row->id;
                        tzs_print_product_form(null, true);
                    }
                }
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #5
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;
}
Example #6
0
function tzs_front_end_edit_shipment_handler($atts)
{
    ob_start();
    $user_id = get_current_user_id();
    $sh_id = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : 0;
    if (!is_user_logged_in()) {
        print_error("Вход в систему обязателен");
    } else {
        if ($sh_id <= 0) {
            print_error('Груз не найден');
        } else {
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['action']) && $_POST['action'] == 'editshipment' && $_POST['formName'] == 'shipment') {
                $id = isset($_POST['id']) && is_numeric($_POST['id']) ? intval($_POST['id']) : 0;
                tzs_edit_shipment($id);
            } else {
                global $wpdb;
                $sql = "SELECT * FROM " . TZS_SHIPMENT_TABLE . " WHERE id={$sh_id} AND user_id={$user_id};";
                $row = $wpdb->get_row($sql);
                if (count($row) == 0 && $wpdb->last_error != null) {
                    print_error('Не удалось отобразить информацию о грузе. Свяжитесь, пожалуйста, с администрацией сайта');
                } else {
                    if ($row == null) {
                        print_error('Груз не найден');
                    } else {
                        $sql_flag1 = "SELECT * FROM " . TZS_COUNTRIES_TABLE . " WHERE country_id=" . $row->from_cid;
                        $row1 = $wpdb->get_row($sql_flag1);
                        $sql_flag2 = "SELECT * FROM " . TZS_COUNTRIES_TABLE . " WHERE country_id=" . $row->to_cid;
                        $row2 = $wpdb->get_row($sql_flag2);
                        $_POST['from_code'] = "/wp-content/plugins/tzs/assets/images/flags/" . strtolower($row1->code) . '.png';
                        $_POST['to_code'] = "/wp-content/plugins/tzs/assets/images/flags/" . strtolower($row2->code) . '.png';
                        $_POST['sh_date_from'] = date("d.m.Y", strtotime($row->sh_date_from));
                        $_POST['sh_date_to'] = date("d.m.Y", strtotime($row->sh_date_to));
                        $_POST['sh_city_from'] = $row->sh_city_from;
                        $_POST['sh_city_to'] = $row->sh_city_to;
                        $_POST['sh_descr'] = $row->sh_descr;
                        $_POST['comment'] = $row->comment;
                        if ($row->sh_weight > 0) {
                            $_POST['sh_weight'] = '' . remove_decimal_part($row->sh_weight);
                        }
                        if ($row->sh_volume > 0) {
                            $_POST['sh_volume'] = '' . remove_decimal_part($row->sh_volume);
                        }
                        $_POST['sh_type'] = '' . $row->sh_type;
                        $_POST['trans_type'] = '' . $row->trans_type;
                        $_POST['trans_count'] = '' . $row->trans_count;
                        if ($row->sh_length > 0 || $row->sh_height > 0 || $row->sh_width > 0) {
                            $_POST['set_dim'] = '';
                            if ($row->sh_width > 0) {
                                $_POST['sh_width'] = '' . remove_decimal_part($row->sh_width);
                            }
                            if ($row->sh_height > 0) {
                                $_POST['sh_height'] = '' . remove_decimal_part($row->sh_height);
                            }
                            if ($row->sh_length > 0) {
                                $_POST['sh_length'] = '' . remove_decimal_part($row->sh_length);
                            }
                        }
                        if ($row->cost > 0) {
                            $_POST['cost'] = '' . remove_decimal_part($row->cost);
                        }
                        if ($row->price > 0) {
                            $_POST['price'] = '' . remove_decimal_part($row->price);
                        }
                        if ($row->price_val > 0) {
                            $_POST['cost_curr'] = '' . remove_decimal_part($row->price_val);
                        }
                        if ($row->prepayment > 0) {
                            $_POST['prepayment'] = '' . remove_decimal_part($row->prepayment);
                        }
                        if ($row->cash > 0) {
                            $_POST['cash'] = 'on';
                        }
                        if ($row->nocash > 0) {
                            $_POST['nocash'] = 'on';
                        }
                        if ($row->way_ship > 0) {
                            $_POST['way_ship'] = 'on';
                        }
                        if ($row->way_debark > 0) {
                            $_POST['way_debark'] = 'on';
                        }
                        if ($row->soft > 0) {
                            $_POST['soft'] = 'on';
                        }
                        if ($row->way_prepay > 0) {
                            $_POST['way_prepay'] = 'on';
                        }
                        if ($row->price_query > 0) {
                            $_POST['price_query'] = 'on';
                        }
                        $_POST['sh_distance'] = $row->distance;
                        $_POST['id'] = '' . $row->id;
                        $_POST['sh_active'] = $row->active;
                        tzs_print_shipment_form(null, true);
                    }
                }
            }
        }
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #7
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;
}
Example #8
0
function tzs_tr_sh_table_record_out($row, $form_type, $profile_td_text = null)
{
    //    $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);
    $path_segment_cities = explode(";", $row->path_segment_cities);
    //$cost = tzs_cost_to_str($row->cost, true);
    $cost = tzs_price_query_to_str($row);
    $dt_created = convert_time($row->time, "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 = '';
    }
    // Определение статуса записи
    $output_tbody = '<tr rid="' . $row->id . '"';
    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>';
    }
    /*
               <div class="record_number">
                   <span class="middle" title="Номер заявки">
                          № '.$row->id.'
                   </span>
               </div><br>
    */
    $output_tbody .= '
            <td>
                <div class="date_label" title="Дата публикации заявки">
                    ' . $dt_created[0] . '
                </div>
                <div class="time_label" title="Время публикации заявки">
                    ' . str_replace(':', ' : ', $dt_created[1]) . '
                </div><br>';
    if ($dt_pickup != '') {
        $output_tbody .= '<div class="date_label" title="Дата бесплатного поднятия заявки в ТОП">
                    ' . $dt_pickup[0] . '
                </div>
                <div class="time_label" title="Время бесплатного поднятия заявки в ТОП">
                    ' . str_replace(':', ' : ', $dt_pickup[1]) . '
                </div>';
    }
    $output_tbody .= '</td>
            <td style="min-width: 260px; width: 260px;">
                <div class="tbl_trucks_path_td">
                    <div class="city_label">' . htmlspecialchars(tzs_get_city($row->from_sid)) . (count($path_segment_cities) > 2 ? '...' : '') . '</div>
                    <div class="country_flag"><img id ="first_city_flag" src="/wp-content/plugins/tzs/assets/images/flags/' . $row->from_code . '.png"  width=18 height=12 alt=""></div>
                </div>
                <div class="tbl_trucks_dtc_td">
                    <div class="date_from_label" title="Дата погрузки">
                        ' . convert_date_year2($prefix === 'tr' ? $row->tr_date_from : $row->sh_date_from) . '<br/>
                    </div>
                </div>
                <div class="tbl_trucks_path_td">
                    <div class="region_label">' . ($row->from_rid != NULL && $row->from_rid > 0 && $row->from_rid != 20070188 ? str_replace('область', 'обл.', htmlspecialchars(tzs_get_region($row->from_rid))) : '&nbsp;&nbsp;') . '</div>
                </div>
                <div class="tbl_distance_td2">
                    <div class="distance_label">
            ';
    if ($row->distance > 0 && $prefix === 'tr') {
        //$output_tbody .= '&nbsp;расстояние '.tzs_make_distance_link($row->distance, false, array($row->tr_city_from, $row->tr_city_to));
        $output_tbody .= '&nbsp;расстояние ' . tzs_make_distance_link($row->distance, false, explode(";", $row->path_segment_cities));
    } else {
        if ($row->distance > 0 && $prefix === 'sh') {
            //$output_tbody .= '&nbsp;расстояние '.tzs_make_distance_link($row->distance, false, array($row->sh_city_from, $row->sh_city_to));
            $output_tbody .= '&nbsp;расстояние ' . tzs_make_distance_link($row->distance, false, explode(";", $row->path_segment_cities));
        }
    }
    $output_tbody .= ' (см. карту)</div>';
    $output_tbody .= '            </div>
                <div class="tbl_trucks_path_td">
                    <div class="city_label">' . (count($path_segment_cities) > 2 ? '...' : '') . htmlspecialchars(tzs_get_city($row->to_sid)) . '</div>
                    <div class="country_flag"><img id ="second_city_flag" src="/wp-content/plugins/tzs/assets/images/flags/' . $row->to_code . '.png"  width=18 height=12 alt=""></div>
                </div>
                <div class="tbl_trucks_dtc_td">
                    <div class="date_to_label" title="Дата выгрузки">
                        ' . convert_date_year2($prefix === 'tr' ? $row->tr_date_to : $row->sh_date_to) . '
                    </div>
                </div>
                <div class="tbl_trucks_path_td">
                    <div class="region_label">' . ($row->to_rid != NULL && $row->to_rid > 0 && $row->to_rid != 20070188 ? str_replace('область', 'обл.', htmlspecialchars(tzs_get_region($row->to_rid))) : '&nbsp;&nbsp;') . '</div>';
    if ($row->cash + $row->nocash + $row->way_ship + $row->way_debark + $row->soft + $row->way_prepay > 5) {
        $output_tbody .= '<div>&nbsp;<div>';
    }
    $output_tbody .= '            </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><br>
                <div class="tr_type_label" title="Тип транспортного средства">' . $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 class="tr_type_label" 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>';
    //if ($row->price > 0) {
    //                round($row->price / $row->distance, 2).' '.$GLOBALS['tzs_curr'][$row->price_val].
    //        number_format($row->cost, 0, '.', ' ').' '.$GLOBALS['tzs_curr'][$row->price_val].'<div><br>
    //                $row->price.' '.$GLOBALS['tzs_curr'][$row->price_val].
    //                '/км)</div>';
    $output_tbody .= '<div class="price_label" title="Стоимость перевозки груза">' . $cost[0] . '<div><br>';
    if (strlen($cost[1]) > 0) {
        $output_tbody .= '<div class="cost_label" title="Цена за 1 км перевозки груза">(' . $cost[1] . ')</div>';
    }
    //} else {
    //    $output_tbody .= '<div  class="price_label" title="Стоимость перевозки груза">'.$cost[0].'</div>';
    //}
    //                <div  class="payment_label" title="Форма оплаты услуг по перевозке груза">'.$cost[1].'</div>
    $output_tbody .= '
            </td>
            <td>
                <div  class="payment_label" title="Форма оплаты услуг по перевозке груза">' . str_replace(', ', ',<br>', $cost[2]) . '</div>
            </td>';
    //<div  class="payment_label" title="Форма оплаты услуг по перевозке груза">'.str_replace(', ', ',<br>', $cost[1]).'</div>
    if ($prefix === 'tr') {
        //$output_tbody .= '<td><div title="Комментарии">'.$row->comment.'</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;
}