示例#1
0
function tzs_print_truck_form($errors, $edit = false)
{
    $d = date("d.m.Y");
    print_errors($errors);
    ?>

    <script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
    <script src="/wp-content/plugins/tzs/assets/js/autocomplete.js"></script>
    
    <div style="clear: both;"></div>
    
    <form name="theForm" enctype="multipart/form-data" method="post" id="bpost" class="pr_edit_form post-form" action="">

        <div id="cost_div" style="display:none;">
        <table>
                <tr>
                        <td>
                                <input type="radio" name="set_price" value="1" <?php 
    if (isset($_POST['set_price']) && $_POST['set_price'] == '1') {
        echo 'checked="checked"';
    }
    ?>
><b>Указать стоимость перевозки и форму оплаты</b><br/>
                                <input type="text" for="price" name="price" value="<?php 
    echo_val('price');
    ?>
" size="10">
                                <select for="price" name="cost_curr">
                                <?php 
    foreach ($GLOBALS['tzs_curr'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if ($val == '') {
            $val = '-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-';
        }
        if (isset($_POST['cost_curr']) && $_POST['cost_curr'] == $key && $key != 0) {
            echo 'selected="selected"';
        }
        if ($key == 0) {
            echo 'disabled="disabled"';
        }
        echo '>' . htmlspecialchars($val) . '</option>\\n';
    }
    ?>
                                </select><br/>
                                <input type="radio" for="price" name="payment" value="nocash" <?php 
    tzs_cost_print_option('payment', 'nocash');
    ?>
/> <span id="opt_nocash">без нал.</span>
                                <input type="radio" for="price" name="payment" value="cash" <?php 
    tzs_cost_print_option('payment', 'cash');
    ?>
/> <span id="opt_cash">нал.</span>
                                <input type="radio" for="price" name="payment" value="mix_cash" <?php 
    tzs_cost_print_option('payment', 'mix_cash');
    ?>
/> <span id="opt_mix_cash">комбинир.</span><br/>
                                <input type="radio" for="price" name="payment" value="soft" <?php 
    tzs_cost_print_option('payment', 'soft');
    ?>
/> <span id="opt_soft">софт</span>
                                <input type="radio" for="price" name="payment" value="conv" <?php 
    tzs_cost_print_option('payment', 'conv');
    ?>
/> <span id="opt_conv">удобная</span>
                                <input type="radio" for="price" name="payment" value="on_card" <?php 
    tzs_cost_print_option('payment', 'on_card');
    ?>
/> <span id="opt_on_card">на карту</span>
                        </td>

                        <td>
                                <input type="checkbox" for="price" opt="true" name="payment_way_nds" value="nds" <?php 
    tzs_cost_print_option_def('payment_way_nds');
    ?>
> <span id="opt_nds">НДС</span><br/>
                                <input type="checkbox" for="price" opt="true" name="payment_way_ship" value="ship" <?php 
    tzs_cost_print_option_def('payment_way_ship');
    ?>
> <span id="opt_ship">При погрузке</span><br/>
                                <input type="checkbox" for="price" opt="true" name="payment_way_debark" value="debark" <?php 
    tzs_cost_print_option_def('payment_way_debark');
    ?>
> <span id="opt_debark">При выгрузке</span><br/>
                                <input type="checkbox" for="price" name="payment_way_prepay" value="prepay" <?php 
    tzs_cost_print_option_def('payment_way_prepay');
    ?>
> <span id="opt_prepay">Предоплата</span>
                                <input type="text" for="price" name="prepayment" value="<?php 
    echo_val('prepayment');
    ?>
" size="5"> <span id="opt_prepayment">%</span><br/>
                                <input type="checkbox" for="price" opt="true" name="payment_way_barg" value="barg" <?php 
    tzs_cost_print_option_def('payment_way_barg');
    ?>
> <span id="opt_barg">Торг</span><br/>
                        </td>

                        <td>
                                <input type="radio" name="set_price" value="0" <?php 
    if (isset($_POST['set_price']) && $_POST['set_price'] == '0' || !isset($_POST['set_price'])) {
        echo 'checked="checked"';
    }
    ?>
><b>Не указывать стоимость перевозки</b><br/>(цена договорная)
                                <input type="checkbox" for="noprice" name="price_query" value="" <?php 
    tzs_cost_print_option_def('price_query');
    ?>
> <span id="opt_price_query">Запрос цены</span><br/>
                        </td>
                </tr>
        </table>
        </div>

    <!-- Новый вид формы, навеяно http://xiper.net/collect/html-and-css-tricks/verstka-form/blochnaya-verstka-form -->
        <div>
            <!--h4>Размещение информации о свободном транспорте</h4-->
            <h5>Обязательные к заполнению поля помечены <span class="form_field_required">*</span></h5>
            <h5>Заявка будет автоматически перенесена в архив на следующий день, после даты выгрузки !</h5>
            <!--p>Укажите, пожалуйста, категорию, наименование, описание, количество, стоимость, форму оплаты, месторасположение, дату окончания публикации товара и комментарии</p-->
            <hr/>
        </div>
    
        <!-- Left column form -->
        <div class="left_form_wrapper">
            <div class="pr_edit_form_line">
                <label for="tr_id">Номер заявки</label>
                <input type="text" id="" name="tr_id" size="15" value="<?php 
    echo_val('id');
    ?>
" disabled="disabled">
            </div>

            <div class="pr_edit_form_line">
                <label for="tr_date_from">Дата погрузки<span class="form_field_required">*</span></label>
                <input type="text" id="datepicker1" name="tr_date_from" size="" value="<?php 
    echo_val_def('tr_date_from', $d);
    ?>
">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_city_from">Населенный пункт погрузки<span class="form_field_required">*</span></label>
                <input autocomplete="city" id="first_city" type="text" size="35" name="tr_city_from" value="<?php 
    echo_val('tr_city_from');
    ?>
" autocomplete="on">
				<img id ="first_city_flag" style=" visibility:hidden;" width=18 height=12 alt="Флаг страны">
		   </div>
		   

			            
            <div class="pr_edit_form_line">
                <label for="show_dist_link"></label>
                <a id="show_dist_link" href="javascript:showDistanceDialog();">Расстояние между пунктами</a>
            </div>
            
            <div class="pr_edit_form_line">
                <label for="set_dim">Указать</label>
                <input type="checkbox" name="set_dim" id="set_dim" <?php 
    if (isset($_POST['set_dim'])) {
        echo 'checked="checked"';
    }
    ?>
>&nbsp;<span>габариты транспортного средства, в метрах</span>
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_length">Длина</label>
                <input type="text" size="3" name="tr_length" id="tr_length" value="<?php 
    echo_val('tr_length');
    ?>
" maxlength = "5">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_width">Ширина</label>
                <input type="text" size="3" name="tr_width" id="tr_width" value="<?php 
    echo_val('tr_width');
    ?>
" maxlength = "5">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_height">Высота</label>
                <input type="text" size="3" name="tr_height" id="tr_height" value="<?php 
    echo_val('tr_height');
    ?>
" maxlength = "5">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="">Стоимость перевозки<br><a href="javascript: showCostForm();">Указать</a></label>
                <span id="cost_str"></span>
            </div>
        </div>
    
        <!-- Right column form -->
        <div class="right_form_wrapper">
            <div class="pr_edit_form_line">
                <label for="tr_active">Статус<span class="form_field_required">*</span></label>
                <select name="tr_active">
                    <option value="1" <?php 
    if (isset($_POST["tr_active"]) && $_POST["tr_active"] === 1) {
        echo 'selected="selected"';
    }
    ?>
 >Публикуемый</option>
                    <option value="0" <?php 
    if (isset($_POST["tr_active"]) && $_POST["tr_active"] === 0) {
        echo 'selected="selected"';
    }
    ?>
 >Архивный</option>
                </select>
            </div>

            <div class="pr_edit_form_line">
                <label for="tr_date_to">Дата выгрузки<span class="form_field_required">*</span></label>
                <input type="text" id="datepicker2" name="tr_date_to" size="" value="<?php 
    echo_val_def('tr_date_to', $d);
    ?>
">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_city_to">Населенный пункт выгрузки<span class="form_field_required">*</span></label>
                <input autocomplete="city" id="second_city" type="text" size="35" name="tr_city_to" value="<?php 
    echo_val('tr_city_to');
    ?>
" autocomplete="on">
				<img id ="second_city_flag" style=" visibility:hidden;" width=18 height=12 alt="Флаг страны">
			</div>
            
            <div class="pr_edit_form_line">
                <label for="trans_type">Тип транспортного средства<span class="form_field_required">*</span></label>
                <select name="trans_type">
                <?php 
    foreach ($GLOBALS['tzs_tr_types'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if (isset($_POST['trans_type']) && $_POST['trans_type'] == $key || !isset($_POST['trans_type']) && $key == 0) {
            echo 'selected="selected"';
        }
        echo '>' . $val . '</option>';
    }
    ?>
                </select>
                &nbsp;&nbsp;<span><img id="trans_type_img" src="" alt=""></img></span>
            </div>
            
            <div class="pr_edit_form_line">
                <label for="trans_count">Количество машин</label>
		<input type="text" size="5" name="trans_count" value="<?php 
    echo_val('trans_count');
    ?>
" maxlength = "2" placeholder = "1">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_weight">Грузоподъемность (т)</label>
		<input type="text" size="5" name="tr_weight" value="<?php 
    echo_val('tr_weight');
    ?>
" maxlength = "5">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="tr_volume">Полезный объем (м³)</label>
		<input type="text" size="5" name="tr_volume" value="<?php 
    echo_val('tr_volume');
    ?>
" maxlength = "7">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="sh_descr">Желаемый груз</label>
                <input type="text" name="sh_descr" size="" value="<?php 
    echo_val('sh_descr');
    ?>
" maxlength = "255">
            </div>
            
            <div class="pr_edit_form_line">
                <label for="comment">Комментарии</label>
		<input type="text" size="15" name="comment" value="<?php 
    echo_val('comment');
    ?>
" maxlength = "255">
            </div>
        </div>
        
        <div style="clear: both;"></div>
        
        <div>
            <input name="addpost" type="button" onclick="calculate_distance()" id="addpostsub" class="submit_button" value="<?php 
    echo $edit ? "Сохранить изменения" : "Разместить";
    ?>
"/>
			<input type="hidden" name="length" id="route-length">
		</div>
        
	<?php 
    if ($edit) {
        ?>
		<input type="hidden" name="action" value="edittruck"/>
		<input type="hidden" name="id" value="<?php 
        echo_val('id');
        ?>
"/>
	<?php 
    } else {
        ?>
		<input type="hidden" name="action" value="addtruck"/>
	<?php 
    }
    ?>
	<input type="hidden" name="formName" value="truck" />
    </form>
	
	<script>
            tzs_tr2_types = [];
            <?php 
    foreach ($GLOBALS['tzs_tr2_types'] as $key => $val) {
        echo "tzs_tr2_types[{$key}] = '{$val['1']}';\n";
    }
    ?>
        
		
		jQuery("input").on('input', function () {
			var temp =  document.getElementById(this.id).value;
			if(temp.length == 0)
				document.getElementById(this.id+'_flag').style.visibility = 'hidden';
				
		});
		
/* 		jQuery("#second_city").on('input', function () {
			var temp =  document.getElementById('second_city').value;
			if(temp == "")
				document.getElementById('second_city_flag').src = "";	
		});	 */
		
		function calculate_distance() {	
			var routeFrom = document.getElementById('first_city').value;
			var routeTo = document.getElementById('second_city').value;
			document.getElementById('route-length').value = 'Изначально';
			// Создание маршрута
			ymaps.route([routeFrom, routeTo]).then(
				function(route) {
					//alert('Длина маршрута = ' + route.getHumanLength());
					var length = route.getHumanLength().replace(/&#160;/,' ').replace(/ км/,'');
					document.getElementById('route-length').value = length;
					var x = document.getElementsByName('theForm');
					x[0].submit(); // Form submission
				},
				function(error) {
				 alert('Невозможно построить маршрут. Возможно один из городов введен неверно.');
					document.getElementById('route-length').value = 'Ошибка';
				}
			); 
		}
		 
		function setEnabledByInstance(cl, el, enabled) {
			if (enabled) {
				el.removeAttr('disabled');
				jQuery(cl).find('span[id=opt_'+el.attr('value')+']').attr('style', 'color: #000;');
			} else {
				el.attr('disabled', 'disabled');
				jQuery(cl).find('span[id=opt_'+el.attr('value')+']').attr('style', 'color: #d3d3d3;');
			}
		}
		
		function setEnabled(cl, name, enabled) {
			if (enabled) {
				var el = jQuery(cl).find('[name='+name+']');
				el.removeAttr('disabled');
				jQuery(cl).find('span[id=opt_'+el.attr('value')+']').attr('style', 'color: #000;');
			} else {
				var el = jQuery(cl).find('[name='+name+']');
				el.attr('disabled', 'disabled');
				jQuery(cl).find('span[id=opt_'+el.attr('value')+']').attr('style', 'color: #d3d3d3;');
			}
		}
	
		function showHide(cl) {
			var price = jQuery(cl).find('input:radio[name=set_price]:checked').val() == '1';
			jQuery(cl).find('[for=price]').each(function() {
				setEnabledByInstance(cl, jQuery(this), price);
			});
			jQuery(cl).find('[for=noprice]').each(function() {
				setEnabledByInstance(cl, jQuery(this), !price);
			});
			var prepay = jQuery(cl).find('input[name=payment_way_prepay]').is(':checked');
			setEnabled(cl, 'prepayment', price && prepay);
			
			if (price && prepay) {
				jQuery(cl).find('span[id=opt_prepayment]').attr('style', 'color: #000;');
			} else {
				jQuery(cl).find('span[id=opt_prepayment]').attr('style', 'color: #d3d3d3;');
			}
		}
	
		function showCostForm() {
			var el = jQuery('#cost_div');
			var sel = jQuery(el).find('select[name=cost_curr] option:selected');
			
			var cl = jQuery(el).clone();
			if (sel != null) {
				jQuery(cl).find("select[name=cost_curr] option[value='"+sel.val()+"']").attr('selected', 'selected');
			}
			
			jQuery(cl).find('input[name=set_price]').click(function () {
				showHide(cl);
			});
			jQuery(cl).find('input[name=payment_way_prepay]').click(function () {
				showHide(cl);
			});
			showHide(cl);
			
			jQuery(cl).appendTo('body')
				.dialog({
					modal: true,
					title: 'Стоимость перевозки',
					zIndex: 10000,
					autoOpen: true,
					width: 'auto',
					resizable: false,
					buttons: {
						'Сохранить': function () {
							jQuery(this).dialog("close");
							var newEl = jQuery(this);
							newEl.attr('style', 'display:none;');
							newEl.attr('id', 'cost_div');
							var cl1 = newEl.clone();
							var sel = jQuery(newEl).find('select[name=cost_curr] option:selected');
							if (sel != null) {
								jQuery(cl1).find("select[name=cost_curr] option[value='"+sel.val()+"']").attr('selected', 'selected');
							}
							el.replaceWith(cl1);
							updateCostValue();
						},
						'Отмена': function () {
							jQuery(this).dialog("close");
						}
					},
					close: function (event, ui) {
						jQuery(this).remove();
					}
				});
		}
		
		function updateCostValue() {
			var str = '';
			if (jQuery('input:radio[name=set_price]:checked').val() == '1') {
				str += jQuery('input[name=price]').val();
				str += ' ';
				str += jQuery('select[name=cost_curr] option:selected').text();
				
				var opt = jQuery('input:radio[name=payment]:checked');
				if (opt.val() != null) {
					str += ', ';
					str += jQuery('#opt_'+opt.val()).html();
				}
				
				jQuery("input[opt='true']").each(function() {
					if (jQuery(this).is(':checked')) {
						str += ', ';
						str += jQuery('#opt_'+jQuery(this).val()).html();
					}
				});
				
				if (jQuery('input[name=payment_way_prepay]').is(':checked')) {
					str += ', предоплата: ';
					str += jQuery('input[name=prepayment]').val();
					str += '%';
				}
			} else {
				if (jQuery('input:radio[name=price_query]').is(':checked')) {
					str += 'запрос цены';
				}
			}
			jQuery('#cost_str').html(str);
		}
	
		function onSetDim(ch) {
			if (ch) {
				jQuery("#tr_length").removeAttr("disabled");
				jQuery("#tr_width").removeAttr("disabled");
				jQuery("#tr_height").removeAttr("disabled");
			} else {
				jQuery("#tr_length").attr("disabled", "disabled");
				jQuery("#tr_width").attr("disabled", "disabled");
				jQuery("#tr_height").attr("disabled", "disabled");
			}
		}
		
		function showDistanceDialog() {
			displayDistance([jQuery('input[name=tr_city_from]').val(), jQuery('input[name=tr_city_to]').val()], null);
		}

		function onTransTypeChange() {
			jQuery('#trans_type_img').attr('src', tzs_tr2_types[jQuery('[name=trans_type]').val()]);
		}

		jQuery(document).ready(function(){
                        jQuery('#set_dim').click(function() {
                                onSetDim(this.checked);
                        });
		
			jQuery('#bpost').submit(function() {
				jQuery('#addpostsub').attr('disabled','disabled');
				return true;
			});
		
			jQuery.datepicker.setDefaults(jQuery.datepicker.regional['ru']);
			jQuery( "#datepicker1" ).datepicker({ dateFormat: "dd.mm.yy" });
			jQuery( "#datepicker2" ).datepicker({ dateFormat: "dd.mm.yy" });
			onSetDim(jQuery('#set_dim').prop('checked'));
                        jQuery("[name=trans_type]").change(function() { onTransTypeChange(); });
                        jQuery("[name=trans_type]").keyup(function() { onTransTypeChange(); });
			
			updateCostValue();
                        onTransTypeChange();
		});
	</script>
<?php 
}
示例#2
0
function tzs_print_truck_form($errors, $edit = false)
{
    $d = date("d.m.Y");
    //print_errors($errors);
    ?>

    <script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
    <script src="/wp-content/plugins/tzs/assets/js/autocomplete.js"></script>
    <script src="/wp-content/plugins/tzs/assets/js/ksk_city_form.js" type="text/javascript"></script>
    
    <div style="clear: both;"></div>
    
    <!-- test new form -->
<div class="form_wrapper">
    <form enctype="multipart/form-data" method="post" id="form_truck" class="" action="">

        <div class="row-fluid"  style="width: 100%; ">
            <div class="span5">
                <div class="city_input_div">
                    <table id="citiesTable">
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="span7">
                 <div class="span7">
                     <div class="span6 margin-null"><input type="text" id="datepicker1" name="tr_date_from" size="" value="<?php 
    echo_val_def('tr_date_from', '');
    ?>
" placeholder="Дата погрузки" readonly="true" style="width: 100px;"></div>
                     <div class="span6 margin-null"><input type="text" id="datepicker2" name="tr_date_to" size="" value="<?php 
    echo_val_def('tr_date_to', '');
    ?>
" placeholder="Дата выгрузки" readonly="true" style="width: 100px;"></div>
                     <div class="span12 margin-null">
                        <select id="trans_type" name="trans_type" style="width: 98%">
                        <?php 
    tzs_print_array_options($GLOBALS['tzs_tr_types'], '', 'trans_type', 'Тип транспортного средства');
    ?>
                        </select>
                    </div>
                <div style="clear: both"></div> 
                    
                    <div style="clear: both"></div>
                    <div class="span12 margin-null"><input type="text" id="sh_descr" name="sh_descr" size="" value="<?php 
    echo_val('sh_descr');
    ?>
" maxlength = "255" placeholder="Желаемый груз" style="width: 95%"></div>
                    <div class="span12 margin-null"><input type="text" size="15" name="comment" value="<?php 
    echo_val('comment');
    ?>
" maxlength = "255" placeholder="Комментарий" style="width: 95%;"></div>
                    <div style="clear: both"></div>
                    <div>
                    </div>
                    <div class="span12 margin-null">
                        <input type="hidden" name="cost_curr" id="cost_curr" value="1">
                        <label for="cost">Стоимость перевозки:</label>&nbsp;
                        <input type="text" id="cost" name="cost" value="<?php 
    echo_val('cost');
    ?>
" size="10" style="width: 100px;">
                        <div class="post-input">грн</div>
                    </div>
                 </div>
                <div class="span5" style="margin-top: -5px;">
                    <div class="chekbox span12"><!-- style="text-align: right;"-->
                        <input type="checkbox" name="set_dim" id="set_dim" <?php 
    if (isset($_POST['set_dim'])) {
        echo 'checked="checked"';
    }
    ?>
><label for="set_dim">Указать габариты ТС (м):</label>
                        <!--div class="post-input gabarite"></div-->
                    </div>
                    <div class="span12">
                        <input type="text" name="tr_length" id="tr_length" value="<?php 
    echo_val('tr_length');
    ?>
" maxlength = "5" title="Формат: 99.99" placeholder="Длина" style="width: 50px; margin-right: 5px;">&nbsp;&nbsp;
                        <input type="text" name="tr_width" id="tr_width" value="<?php 
    echo_val('tr_width');
    ?>
" maxlength = "5" title="Формат: 99.99" placeholder="Ширина" style="width: 50px; margin-left: 5px;">&nbsp;&nbsp;
                        <input type="text" name="tr_height" id="tr_height" value="<?php 
    echo_val('tr_height');
    ?>
" maxlength = "5" title="Формат: 99.99" placeholder="Высота" style="width: 50px; margin-left: 5px;">
                    </div>
                    <div style="clear: both"></div>
                    <div class="span12"><!-- style="text-align: right; float: right;"-->
                        <label for="tr_volume">Объем груза&nbsp;=</label>&nbsp;
                        <input type="text" id="tr_volume" name="tr_volume" value="<?php 
    echo_val('tr_volume');
    ?>
" readonly="true" style="width: 80px;">
                        <div class="post-input">м<sup>3</sup></div>
                    </div>
                    <div style="clear: both"></div>
                    <div class="span12">
                        <label for="tr_weight">Вес груза:</label>&nbsp;
                        <input type="text" id="tr_weight" name="tr_weight" value="<?php 
    echo_val('tr_weight');
    ?>
" maxlength = "5" style="width: 50%;"><div class="post-input">т</div>
                    </div>
                    <div style="clear: both"></div>
                    <div class="span12">
                        <label for="trans_count">Кол-во машин:</label>&nbsp;
                        <input type="text" size="5" id="trans_count" name="trans_count" value="<?php 
    echo_val('trans_count');
    ?>
" maxlength = "2" placeholder = "0" style="width: 37%;">
                    </div>
               
                    <div style="clear: both"></div>
                    <div class="span12">
                        <label for="price">Цена&nbsp;=</label>&nbsp;
                        <input type="text" id="price" name="price" value="<?php 
    echo_val('price');
    ?>
" size="10" readonly="true" style="width: 100px;">
                        <div class="post-input">грн/км</div>
                    </div>
                    <div style="clear: both"></div>
                </div>
                <div style="clear: both"></div>
                
                
                
                <div class="span2">
                    <label for="">Загрузка:</label>
                </div>
                <!--div style="clear: both"></div-->
                <div class="chekbox span2 margin-checkbox">
                    <input type="checkbox" id="top_loading" name="top_loading" <?php 
    echo isset($_POST['top_loading']) ? 'checked="checked"' : '';
    ?>
><label for="top_loading">верхняя</label>
                </div>
                <div class="chekbox span2 margin-checkbox">
                    <input type="checkbox" id="side_loading" name="side_loading" <?php 
    echo isset($_POST['side_loading']) ? 'checked="checked"' : '';
    ?>
><label for="side_loading">боковая</label>
                </div>
                <div class="chekbox span2 margin-checkbox">
                    <input type="checkbox" id="back_loading" name="back_loading" <?php 
    echo isset($_POST['back_loading']) ? 'checked="checked"' : '';
    ?>
><label for="back_loading">задняя</label>
                </div>
                <div class="chekbox span4 margin-checkbox">
                    <input type="checkbox" id="without_gate" name="without_gate" style="width: 16%;" <?php 
    echo isset($_POST['without_gate']) ? 'checked="checked"' : '';
    ?>
 ><label for="without_gate">без ворот</label>
                </div>
                <div style="clear: both"></div>
                <div class="chekbox span4 margin-checkbox">
                    <input type="checkbox" id="full_movable" name="full_movable" <?php 
    echo isset($_POST['full_movable']) ? 'checked="checked"' : '';
    ?>
><label for="full_movable">с полной растентовкой</label>
                </div>
                
                <div class="chekbox span4 margin-checkbox">
                    <input type="checkbox" id="remove_cross" name="remove_cross" <?php 
    echo isset($_POST['remove_cross']) ? 'checked="checked"' : '';
    ?>
><label for="remove_cross">со снятием поперечин</label>
                </div>
                <div class="chekbox span4 margin-checkbox">
                    <input type="checkbox" id="remove_racks" name="remove_racks" <?php 
    echo isset($_POST['remove_racks']) ? 'checked="checked"' : '';
    ?>
 ><label for="remove_racks">со снятием стоек</label>
                </div>
            </div>
            
            <div class="span5"></div>
            <div class="span7">
                <div id="payments-method-label">
                    <label for="">Форма расчета (можно указать несколько способов одновременно):</label>
                </div>
                <div style="clear: both"></div>
                <div class="chekbox form-group">
                    <div class="chekbox span2 margin-checkbox">
                        <input type="checkbox" id="cash" name="cash" <?php 
    echo isset($_POST['cash']) ? 'checked="checked"' : '';
    ?>
><label for="cash">Наличная</label>
                    </div>
                    <div class="chekbox span3 margin-checkbox">    
                        <input type="checkbox" id="nocash" name="nocash" <?php 
    echo isset($_POST['nocash']) ? 'checked="checked"' : '';
    ?>
><label for="nocash">Безналичная</label>
                    </div>
                    <div class="chekbox span3 margin-checkbox">
                        <input type="checkbox" id="way_ship" name="way_ship" <?php 
    echo isset($_POST['way_ship']) ? 'checked="checked"' : '';
    ?>
><label for="way_ship">При погрузке</label>
                    </div>
                    <div class="chekbox span3 margin-checkbox">
                        <input type="checkbox" id="way_debark" name="way_debark" <?php 
    echo isset($_POST['way_debark']) ? 'checked="checked"' : '';
    ?>
><label for="way_debark">При выгрузке</label>
                    </div>
                    <div class="chekbox span2 margin-checkbox">
                        <input type="checkbox" id="soft" name="soft" <?php 
    echo isset($_POST['soft']) ? 'checked="checked"' : '';
    ?>
><label for="soft">Софт</label>
                    </div>
                    <div class="chekbox span4 margin-checkbox">
                        <input type="checkbox" id="way_prepay" name="way_prepay"  <?php 
    echo isset($_POST['way_prepay']) ? 'checked="checked"' : '';
    ?>
 ><label for="way_prepay">Предоплата</label>
                        <input type="text" id="prepayment" name="prepayment" class="margin-prepay" value="<?php 
    echo_val('prepayment');
    ?>
" size="5" placeholder = "0" style="width: 20px;"><div class="post-input margin-prepay">%</div>
                    </div>
                    <div class="chekbox span7 margin-checkbox">
                        <input type="checkbox" id="price_query" name="price_query" <?php 
    echo isset($_POST['price_query']) ? 'checked="checked"' : '';
    ?>
><label for="price_query">Не указывать стоимость (цена договорная)</label>
                    </div>
                </div>
                
            </div>
        </div>
        
   
    
   <!-- <div class="row-fluid"  style="width: 100%; ">
        <div class="span3">
        </div>
        <div id="div_second_city" class="span3 form-group">
        </div>
        <div class="span1">
            <img id ="second_city_flag" src="<?php 
    echo $edit ? echo_val('to_code') : "";
    ?>
" style="visibility:<?php 
    echo $edit ? 'visible' : 'hidden';
    ?>
" width=18 height=12 alt="">
        </div>
        <div class="span2">
        </div>
        <div class="span3">
        </div>
    </div> -->
    
    <!--div class="row-fluid"  style="width: 100%; ">
        <div class="span3">
        </div>
        <div id="div_second_city" class="span3 form-group">
        </div>
        <div class="span1">
            <img id ="second_city_flag" src="<?php 
    //echo $edit ? echo_val('to_code') : ""
    ?>
" style="visibility:<?php 
    echo $edit ? 'visible' : 'hidden';
    ?>
" width=18 height=12 alt="">
        </div>
        <div class="span2">
        </div>
        <div class="span3">
        </div>
    </div-->
                    

    <div class="row-fluid"  style="width: 100%; ">
            <input type="hidden" name="tr_active" id="tr_active" value="1">
        <div class="span1">
            <!--span><img id="trans_type_img" src="" alt=""></img></span>&nbsp;&nbsp;-->
        </div>
        <div class="span8">
            <!--div class="span12 chekbox" style="margin-bottom: 20px;">
            </div-->
            <div class="span4">
                <button id="form_button1"><?php 
    echo $edit ? "ИЗМЕНИТЬ ЗАЯВКУ" : "РАЗМЕСТИТЬ ЗАЯВКУ";
    ?>
</button>
            </div>
            <div class="span4">
                <?php 
    if (!$edit) {
        ?>
                <button id="form_button2">ОЧИСТИТЬ ВСЕ ПОЛЯ</button>
                <?php 
    }
    ?>
            </div>
            <div class="span4">
                <button id="form_button3">ВЫХОД</button>
            </div>
        </div>
        <div class="span4" style="padding: 2px;"><!-- float: right; -->
            <div class="" id="form_error_message" style="color: #F00;border: 1px #F00 dashed; border-radius: 4px; padding: 3px 5px; display: none;">
            </div>
        </div>
    </div>

    <div class="row-fluid"  style="width: 100%; margin-top: 10px;">
        <div class="span12">
            <div style="font-size: 92%; font-style: italic;">
                После нажатия кнопки "РАЗМЕСТИТЬ ЗАЯВКУ" заявка будет опубликована в базе транспорта, после нажатия кнопки "ВЫХОД" заявка не сохраняется.
            </div>
        </div>
    </div>

    <div class="row-fluid"  style="width: 100%; ">
        <div class="span12">
            <div style="font-size: 92%; font-style: italic;">
                <span style="color: #F00;">Напоминаем:</span> заявка будет удалена из базы активных заявок и перенесена в архив на следующий день после указанного Вами дня выгрузки
            </div>
        </div>
    </div>
    
	<?php 
    if ($edit) {
        ?>
		<input type="hidden" name="action" value="edittruck"/>
		<input type="hidden" name="id" value="<?php 
        echo_val('id');
        ?>
"/>
	<?php 
    } else {
        ?>
		<input type="hidden" name="action" value="addtruck"/>
	<?php 
    }
    ?>
        <input type="hidden" name="path_segment_distance" id="path_segment_distance" value="">
        <input type="hidden" name="route-length" id="route-length" value="">
	<input type="hidden" name="formName" value="truck" />
    </form>
</div>
    <div class="clearfix">&nbsp;</div>
    <div id="map_canvas"></div><!-- style="display: none;"-->
    
    <!-- Modal -->
    <div id="ViewMapModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width: 98%; margin-left: -49%;  top: 3%;">
        <div class="modal-header">
            <button id="ViewMapModalCloseButton" type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 id="myModalLabel">Просмотр карты маршрута</h4>
        </div>
        <div id="ViewMapModalBody" class="modal-body">
            <!--div id="map_canvas"></div-->
        </div>
        <div class="modal-footer">
            <button class="btn btn-default" data-dismiss="modal">Закрыть</button>
        </div>
    </div>
    
    <!-- test new form END -->
    <script>
     jQuery('#trans_type').on('change', function() {
            jQuery('#div_trans_type').addClass("change");    
     });
    </script>
	
    <script>
        tzs_tr2_types = [];
        <?php 
    foreach ($GLOBALS['tzs_tr2_types'] as $key => $val) {
        echo "tzs_tr2_types[{$key}] = '{$val['1']}';\n";
    }
    echo "CITY_NAMES = [];\n";
    echo "CITY_IDS = [];\n";
    if (isset($_POST['input_city'])) {
        foreach ($_POST['input_city'] as $key => $val) {
            echo "CITY_NAMES[{$key}] = '{$val}';\n";
        }
    }
    ?>
        
        
        // Расчет расстояния между пунктами
	function calculate_distance() {
                /*var length = 0;		
		var routeFrom = document.getElementById('first_city').value;
		var routeTo = document.getElementById('second_city').value;
		// Создание маршрута
		ymaps.route([routeFrom, routeTo]).then(
			function(route) {
				//alert('Длина маршрута = ' + route.getHumanLength());
				length = route.getHumanLength().replace(/&#160;/,' ').replace(/ км/,'');
				jQuery('#sh_distance').attr('value', length);
				document.getElementById('route-length').value = length;			
				//var x = document.getElementsByName('theForm');
				//x[0].submit(); // Form submission
			},
			function(error) {
			 alert('Невозможно построить маршрут. Возможно один из городов введен неверно.');
				document.getElementById('route-length').value = 'Ошибка';
			}
		);*/ 
	}

	/*var delay = (function(){
	  var timer = 0;
	  return function(callback, ms){
		clearTimeout (timer);
		timer = setTimeout(callback, ms);
	  };
	})();*/
	
        // Изменение полей "Населенный пункт погрузки" и "Населенный пункт выгрузки"
	function onCityChange() {
            /*if ((jQuery('#first_city').val().length > 0) && (jQuery('#second_city').val().length > 0)) {
                calculate_distance();
                jQuery('#show_dist_link').show();
            } else {
                if (jQuery('#first_city').val().length < 1) {
                    //jQuery('#first_city_flag').hide();
                    jQuery('#first_city_flag').attr('src', '');
                }
                
                if (jQuery('#second_city').val().length < 1) {
                    //jQuery('#second_city_flag').hide();
                    jQuery('#second_city_flag').attr('src', '');
                }
                
                jQuery('#sh_distance').attr('value', '');
                jQuery('#show_dist_link').hide();
            }
            
            if (typeof onCostChange === 'function') {
                onCostChange();
            }*/
	}
		
		
        // Изменение флага "Указать габариты груза (м):"
        function onSetDim(ch) {
            if (ch) {
                jQuery("#tr_length, #tr_width, #tr_height, #tr_volume").removeAttr("disabled");
                //jQuery("#tr_length, #tr_width, #tr_height").attr('required', 'required');
            } else {
                //jQuery("#tr_length, #tr_width, #tr_height").removeAttr('required');
                jQuery("#tr_length, #tr_width, #tr_height, #tr_volume").attr("disabled", "disabled");
                jQuery("#tr_length, #tr_width, #tr_height, #tr_volume").attr('value', '');
            }
        }

        // Вывод карты
        function showDistanceDialog() {
            /*if ((jQuery('#first_city').val().length > 0) && (jQuery('#second_city').val().length > 0)) {
                //displayDistance([jQuery('input[name=tr_city_from]').val(), jQuery('input[name=tr_city_to]').val()], null);
                displayDistance([jQuery('#first_city').val(), jQuery('#second_city').val()], null);
            } else {

            }*/
        }

        // Изменение поля "Тип транспорта"
        function onTransTypeChange() {
            //jQuery('#trans_type').addClass("change");
            //jQuery('#trans_type_img').attr('src', tzs_tr2_types[jQuery('[name=trans_type]').val()]);
        }

        // Изменение поля "Дата загрузки"
        function onDatePicker1Change(dateText, inst) {
            jQuery("#datepicker2").datepicker("option", "minDate", new Date(dateText.replace(/(\d+).(\d+).(\d+)/, '$3/$2/$1')));
            jQuery("#datepicker2").datepicker("setDate", dateText);
            //jQuery("#datepicker2").removeAttr("disabled");
        }

        // Изменение поля "Стоимость перевозки"
        function onCostChange() {
            if ((jQuery('#cost').val().length > 0) && (jQuery('#sh_distance').val().length > 0)) {
                var vol = (jQuery('#cost').val() / jQuery('#sh_distance').val()).toFixed(2);
                jQuery('#price').attr('value', vol);
            } else {
                jQuery('#price').attr('value', '');
            }
        }

        // Изменение флага "Не указывать стоимость (цена договорная)"
        function onPriceQueryChange() {
            if (jQuery("#price_query").is(':checked')) {
                jQuery("[name=cost]").attr('value', '');
                jQuery("[name=price]").attr('value', '');
                jQuery("[name=prepayment]").attr('value', '');

                jQuery("[name=cash]").prop('checked', false);
                jQuery("[name=nocash]").prop('checked', false);
                jQuery("[name=way_ship]").prop('checked', false);
                jQuery("[name=way_debark]").prop('checked', false);
                jQuery("[name=soft]").prop('checked', false);
                jQuery("[name=way_prepay]").prop('checked', false);

                jQuery("[name=cost]").attr("disabled", "disabled");
                jQuery("[name=price]").attr("disabled", "disabled");
                jQuery("[name=prepayment]").attr("disabled", "disabled");
                jQuery("[name=cash]").attr("disabled", "disabled");
                jQuery("[name=nocash]").attr("disabled", "disabled");
                jQuery("[name=way_ship]").attr("disabled", "disabled");
                jQuery("[name=way_debark]").attr("disabled", "disabled");
                jQuery("[name=soft]").attr("disabled", "disabled");
                jQuery("#way_prepay").attr("disabled", "disabled");
                jQuery("#prepayment").attr("disabled", "disabled");
            } else {
                jQuery("[name=cost]").removeAttr("disabled");
                jQuery("[name=price]").removeAttr("disabled");
                jQuery("[name=prepayment]").removeAttr("disabled");
                jQuery("[name=cash]").removeAttr("disabled");
                jQuery("[name=nocash]").removeAttr("disabled");
                jQuery("[name=way_ship]").removeAttr("disabled");
                jQuery("[name=way_debark]").removeAttr("disabled");
                jQuery("[name=soft]").removeAttr("disabled");
                jQuery("#way_prepay").removeAttr("disabled");

                jQuery("#prepayment").attr("disabled", "disabled");
            }
        }

        // Изменение флага "Предоплата"
        function onWayPrepayChange() {
            if (jQuery("#way_prepay").is(':checked')) {
                jQuery("#prepayment").attr('value', '');
                jQuery("#prepayment").removeAttr("disabled");
            } else {
                jQuery("#prepayment").attr('value', '');
                jQuery("#prepayment").attr("disabled", "disabled");
            }
        }

        // Рассчет объема груза
        function onVolumeCalculate() {
            if ((jQuery('#tr_length').val().length > 0) && (jQuery('#tr_width').val().length > 0) && (jQuery('#tr_height').val().length > 0)) {
                var vol = jQuery('#tr_length').val() * jQuery('#tr_width').val() * jQuery('#tr_height').val();
                jQuery('#tr_volume').attr('value', vol);
            } else {
                jQuery('#tr_volume').attr('value', '');
            }
        }

        // Очистка формы
        function resetForm(selector) {
            jQuery(':text, :password, :file, textarea', selector)
                    .val('')
                    .css({'border': '1px solid #007FFF'});
            jQuery(':input, select option', selector)
                    .removeAttr('checked')
                    .removeAttr('selected')
                    .css({'border': '1px solid #007FFF'});
            jQuery('select option:first', selector).attr('selected', true);
            
            // Очистим флаги и скроем кнопку "см. карту"
            jQuery('img', selector).attr('src', '')
            jQuery('#show_dist_link').hide();

            jQuery('#div_cash, #div_nocash, #div_way_ship, #div_way_debark, #div_soft, #div_way_prepay').css({'border': 'none'});
            jQuery("#payments-method-label").css({'border': 'none'});
            
            // Очистим список ошибок
            jQuery("#form_error_message").html('');
            jQuery("#form_error_message").hide();
        }

        // Функция проверки правильности заполнения полей формы до отправки
        function onFormValidate() {
            //var ErrorMsg1 = 'Список ошибок:<ul>';
            var ErrorMsg1 = '<p>';
            var ErrorMsg2 = '';
            var ErrorMsg3 = '</p>';

            // Проверка заполненности списка городов
            var index = 0;
            jQuery('#citiesTable').find('input[type=text]').each(function () {
                if (jQuery(this).attr('name') !== 'sh_distance') {
                    index += 1;
                    if (jQuery(this).val().length < 1) {
                        ErrorMsg2 = ErrorMsg2 + 'Не указан пункт маршрута № ' + index + '.<br>\n';
                        jQuery(this).css({'border': '2px solid #F00'});
                    } else {
                        jQuery(this).css({'border': '1px solid #007FFF'});
                    }
                } else {
                    if (jQuery(this).val().length < 1) {
                        ErrorMsg2 = ErrorMsg2 + 'Не выполнен расчет длины маршрута.<br>\n';
                        jQuery(this).css({'border': '2px solid #F00'});
                    } else {
                        jQuery(this).css({'border': '1px solid #007FFF'});
                    }
                }
            });

            if (jQuery('#datepicker1').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана дата погрузки.<br>\n';
                jQuery('#datepicker1').css({'border': '1px solid #F00'});
            } else {
                jQuery('#datepicker1').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#datepicker2').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана дата выгрузки.<br>\n';
                jQuery('#datepicker2').css({'border': '1px solid #F00'});
            } else {
                jQuery('#datepicker2').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#tr_type').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указан тип груза.<br>\n';
                jQuery('#tr_type').css({'border': '1px solid #F00'});
            } else {
                jQuery('#tr_type').css({'border': '1px solid #007FFF'});
            }
            
            /*if (jQuery('#sh_descr').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указано описание груза.<br>\n';
                jQuery('#sh_descr').css({'border': '1px solid #F00'});
            } else {
                jQuery('#sh_descr').css({'border': '1px solid #007FFF'});
            }*/

            if (jQuery('#trans_type').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указан тип транспортного средства.<br>\n';
                jQuery('#trans_type').css({'border': '1px solid #F00'});
            } else {
                jQuery('#trans_type').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#trans_count').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указано количество машин.<br>\n';
                jQuery('#trans_count').css({'border': '1px solid #F00'});
            } else {
                jQuery('#trans_count').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#set_dim').prop('checked')) {
                if (jQuery('#tr_length').val().length == 0) {
                    ErrorMsg2 = ErrorMsg2 + 'Не указана длина груза.<br>\n';
                    jQuery('#tr_length').css({'border': '1px solid #F00'});
                } else {
                    jQuery('#tr_length').css({'border': '1px solid #007FFF'});
                }

                if (jQuery('#tr_width').val().length == 0) {
                    ErrorMsg2 = ErrorMsg2 + 'Не указана ширина груза.<br>\n';
                    jQuery('#tr_width').css({'border': '1px solid #F00'});
                } else {
                    jQuery('#tr_width').css({'border': '1px solid #007FFF'});
                }

                if (jQuery('#tr_height').val().length == 0) {
                    ErrorMsg2 = ErrorMsg2 + 'Не указана высота груза.<br>\n';
                    jQuery('#tr_height').css({'border': '1px solid #F00'});
                } else {
                    jQuery('#tr_height').css({'border': '1px solid #007FFF'});
                }
            } else {
                jQuery('#tr_length, #tr_width, #tr_height').css({'border': '1px solid #007FFF'});
            }

            if (jQuery("#price_query").is(':checked')) {
                jQuery('#cost, #prepayment').css({'border': '1px solid #007FFF'});
                jQuery('#div_cash, #div_nocash, #div_way_ship, #div_way_debark, #div_soft, #div_way_prepay').css({'border': 'none'});
                jQuery("#payments-method-label").css({'border': 'none'});
            } else {
                if (jQuery('#cost').val().length < 1) {
                    ErrorMsg2 = ErrorMsg2 + 'Не указана стоимость перевозки.<br>\n';
                    jQuery('#cost').css({'border': '1px solid #F00'});
                } else {
                    jQuery('#cost').css({'border': '1px solid #007FFF'});
                }

                if (jQuery("#way_prepay").is(':checked')) {
                    if (jQuery('#prepayment').val().length < 1) {
                        ErrorMsg2 = ErrorMsg2 + 'Не указан % предоплаты.<br>\n';
                        jQuery('#prepayment').css({'border': '1px solid #F00'});
                    } else {
                        jQuery('#prepayment').css({'border': '1px solid #007FFF'});
                    }
                } else {
                    jQuery('#prepayment').css({'border': '1px solid #007FFF'});
                }
                
                // Проверка правильности указания переключателей
                if ((jQuery("#cash").is(':checked') || jQuery("#nocash").is(':checked') || jQuery("#way_ship").is(':checked') || jQuery("#way_debark").is(':checked') || jQuery("#soft").is(':checked') || jQuery("#way_prepay").is(':checked'))) {
                    jQuery('#div_cash, #div_nocash, #div_way_ship, #div_way_debark, #div_soft, #div_way_prepay').css({'border': 'none'});
                    jQuery("#payments-method-label").css({'border': 'none'});
                } else {
                    ErrorMsg2 = ErrorMsg2 + 'Не выбрана форма расчета.<br>\n';
                    jQuery('#div_cash, #div_nocash, #div_way_ship, #div_way_debark, #div_soft, #div_way_prepay').css({'border': '1px solid #F00'});
                    jQuery("#payments-method-label").css({'border': '1px solid #F00'});
                }
            }

            if (ErrorMsg2.length > 0) {
                jQuery("#form_error_message").html(ErrorMsg1 + ErrorMsg2 + ErrorMsg3);
                jQuery("#form_error_message").show();
                return false;
            } else {
                return true;
            }
        }

        /*
         * Функция, вызываемая после загрузки страницы
         */
        jQuery(document).ready(function(){
            initCitiesTable();
            
            jQuery('#totalDistance').append('<input type="text" id="sh_distance" name="sh_distance" size="" value="<?php 
    echo_val('sh_distance');
    ?>
" maxlength = "255" readonly="true" style="width: 50px;"><div class="post-input">км</div>&nbsp;&nbsp;');
            //jQuery('#show_dist_link').hide();

            jQuery('#set_dim').click(function() {
                    onSetDim(this.checked);
            });
            
            jQuery.datepicker.setDefaults(jQuery.datepicker.regional['ru']);
            jQuery( "#datepicker1" ).datepicker({ 
                dateFormat: "dd.mm.yy",
                minDate: new Date(),
                selectOtherMonths: true,
                showOtherMonths: true,
                onSelect: function(dateText, inst) { onDatePicker1Change(dateText, inst); }
            });
            jQuery( "#datepicker2" ).datepicker({ 
                dateFormat: "dd.mm.yy",
                selectOtherMonths: true,
                showOtherMonths: true
            });
            //jQuery("#datepicker2").attr("disabled", "disabled");
            jQuery('#datepicker1, #datepicker2').css({'cursor': 'pointer'});

            onSetDim(jQuery('#set_dim').prop('checked'));
            jQuery("[name=trans_type]").change(function() { onTransTypeChange(); });
            jQuery("[name=trans_type]").keyup(function() { onTransTypeChange(); });
            jQuery("#cost").change(function() { onCostChange(); });
            jQuery("#cost").keyup(function() { onCostChange(); });
            
            <?php 
    if ($errors != null && count($errors) > 0) {
        $err_str = '';
        foreach ($errors as $error) {
            $err_str .= $error . '</br>';
        }
        ?>
                jQuery("#form_error_message").html("<?php 
        echo $err_str;
        ?>
");
                jQuery("#form_error_message").show();
            <?php 
    }
    ?>

            //updateCostValue();
            onTransTypeChange();
            //onWayPrepayChange();
           // onCityChange();
            onCostChange();

            /*jQuery('#first_city, #second_city').on('input',function() { 		
                                        delay(function(){
                                                onCityChange();
                                          //alert('Time elapsed!');
                                        }, 1000 );///onCityChange(); 
                                        });*/

            jQuery("#tr_length, #tr_width, #tr_height, #cost, #tr_weight, #trans_count").bind("change keyup input click", function() {
                if (this.value.match(/[^0-9.]/g)) {
                    this.value = this.value.replace(/[^0-9.]/g, '');
                }
            });
            jQuery("#tr_length, #tr_width, #tr_height").change(function() { onVolumeCalculate(); });
            jQuery("#price_query").change(function() { onPriceQueryChange(); });
            jQuery("#way_prepay").change(function() { onWayPrepayChange(); });

            jQuery("#form_button1").click(function(event) { 
                event.preventDefault();
                var flag = onFormValidate();
                if (flag) {
                    jQuery("form[id='form_truck']").submit();
                }
            });

            jQuery("#form_button2").click(function(event) { 
                event.preventDefault();
                resetForm("form[id='form_truck']");
                onSetDim(jQuery('#set_dim').prop('checked'));
            });

            jQuery("#form_button3").click(function(event) { 
                event.preventDefault();
                location.href = "/account/my-trucks/";
            });
        });
		
    </script>
<?php 
}
示例#3
0
function tzs_front_end_products_handler($atts)
{
    // Определяем атрибуты
    // [tzs-view-products rootcategory="1"] - указываем на странице раздела
    // [tzs-view-products] - указываем на страницах подразделов
    extract(shortcode_atts(array('rootcategory' => '0'), $atts, 'tzs-view-products'));
    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);
    }
    ?>
<!------------------------------------------------------------------------->                        
    <div>
        <table  id="tbl_products">
            <thead>
    <form class="search_pr_form" id="search_pr_form2" name="search_pr_form1" method="POST">
                <tr id="tbl_thead_records_per_page">
                    <!--th colspan="4" id="thead_h1"></th-->
                    <th colspan="10">
                        <div id="thead_h1" class="div_td_left"><h1 class="entry-title"><strong>ПОИСК ТОВАРА</strong></h1></div>
                        <div id="show-search-form" class="search_button">поиск по<br>критериям</div>
                        <!--div class="thead_button">выбор критериев поиска</div-->
                    <?php 
    if (get_current_user_id() == 0) {
        ?>
                        <button id="" class="search_button add" data-toggle="modal" data-target="#myModal">Добавить <br>товар</button>
                        
                        <!-- Modal -->
                        <div id="myModal" class="modal fade" role="dialog">
                          <div class="modal-dialog">

                            <!-- Modal content-->
                            <div class="modal-content">
                              <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal">&times;</button>
                                <h4 class="modal-title">Добавить товар</h4>
                              </div>
                              <div class="modal-body">
                                <div class="">Для добавления товара, пожалуйста, <a href="/account/login">войдите</a> или <a href="/account/registration/">зарегистрируйтесь</a></div>
                              </div>
                              <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
                              </div>
                            </div>

                          </div>
                        </div>
                    <?php 
    }
    ?>
                        <div id="tbl_thead_records_per_page_th"></div>
                    </th>
                </tr>
                <tr>
                    <th id="tbl_products_id">Дата и время заявки</th>
                    <th id="tbl_products_sale">Покупка<br/>Продажа</th>
                    <th id="tbl_products_dtc">Период публи-<br/>кации</th>
                    <th id="tbl_products_type">Тип товара</th>
                    <th id="tbl_products_img">Фото товара</th>
                    <th id="tbl_products_title">Название, описание и местонахождение товара</th>
                    <th id="tbl_products_price">Цена<br/>Кол-во</th>
                    <th id="tbl_products_payment">Форма оплаты</th>
                    <th id="tbl_products_cost">Купить / Предложить цену</th>
                    <th id="tbl_products_comm" nonclickable="true">Контактные данные</th>
                </tr>
                <tr>
                    <th>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_2" class="tbl_thead_search_button" title="Фильтр по типу заявок">
                            <!--img chk="1" src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/checkbox_<?php 
    echo isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] > 0 ? 'checked' : 'unchecked';
    ?>
.png" width="16px" height="16px"-->
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_2', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_2" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_2" class="tbl_thead_search_div">
                            Тип заявки:<br>
                            <select name="sale_or_purchase">
                                <option value="0" <?php 
    if (isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Все</option>
                                <option value="1" <?php 
    if (isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Продажа</option>
                                <option value="2" <?php 
    if (isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Покупка</option>
                            </select><br>
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_3" class="tbl_thead_search_button" title="Фильтр по участнику тендера">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_3', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_3" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_3" class="tbl_thead_search_div">
                            Период публикации: от:<br>
                            <input type="text" name="data_from" value="<?php 
    echo_val('data_from');
    ?>
" size="10"><br>
                            Период публикации: до:<br>
                            <input type="text" name="data_to" value="<?php 
    echo_val('data_to');
    ?>
" size="10">
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_4" class="tbl_thead_search_button" title="Фильтр по периоду публикации">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_4', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_4" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_4" class="tbl_thead_search_div">
                            Тип товара:<br>
                            <select name="type_id" <?php 
    echo $p_id == $pa_root_id ? '' : ' disabled="disabled"';
    ?>
 >
                                <option value="0">все категории</option>
                                <option disabled>- - - - - - - -</option>
                                <?php 
    tzs_build_product_types('type_id', TZS_PR_ROOT_CATEGORY_PAGE_ID);
    ?>
                            </select>
                        </div>
                    </th>
                    <th>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_5" class="tbl_thead_search_button" title="Фильтр по описанию товара">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_5', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_5" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_5" class="tbl_thead_search_div">
                            Описание:<br>
                            <input type="text" name="pr_title" value="<?php 
    echo_val('pr_title');
    ?>
" size="30"><br>
                            Местонахождение: страна:<br>
                            <select name="country_from">
                                <?php 
    tzs_build_countries('country_from');
    ?>
                            </select><br>
                            Местонахождение: регион:<br>
                            <select name="region_from">
                                        <option>все области</option>
                            </select><br>
                            Местонахождение: город:<br>
                            <input type="text" name="cityname_from" value="<?php 
    echo_val('cityname_from');
    ?>
" size="10"><br>
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_6" class="tbl_thead_search_button" title="Фильтр по стоимости товара">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_6', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_6" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_6" class="tbl_thead_search_div">
                            Стоимость: от:<br>
                            <input type="text" name="price_from" value="<?php 
    echo_val('price_from');
    ?>
" size="10"><br>
                            Стоимость: до:<br>
                            <input type="text" name="price_to" value="<?php 
    echo_val('price_to');
    ?>
" size="10"><br>
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_7" class="tbl_thead_search_button" title="Фильтр по местонахождению товара">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_7', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_7" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_7" class="tbl_thead_search_div">
                            Форма оплаты:<br>
                            <select name="payment">
                                <option value="0" <?php 
    if (isset($_POST['payment']) && $_POST['payment'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Любая</option>
                                <option value="1" <?php 
    if (isset($_POST['payment']) && $_POST['payment'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Наличная</option>
                                <option value="2" <?php 
    if (isset($_POST['payment']) && $_POST['payment'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Безналичная</option>
                            </select><br>
                            НДС:<br>
                            <select name="nds">
                                <option value="0" <?php 
    if (isset($_POST['nds']) && $_POST['nds'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Все</option>
                                <option value="1" <?php 
    if (isset($_POST['nds']) && $_POST['nds'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Без НДС</option>
                                <option value="2" <?php 
    if (isset($_POST['nds']) && $_POST['nds'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Включая НДС</option>
                            </select>
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_8" class="tbl_thead_search_button" title="Фильтр по местонахождению товара">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_8', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_8" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_8" class="tbl_thead_search_div">
                            Участник тендера:<br>
                            <select name="fixed_or_tender">
                                <option value="0" <?php 
    if (isset($_POST['fixed_or_tender']) && $_POST['fixed_or_tender'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Все предложения</option>
                                <option value="1" <?php 
    if (isset($_POST['fixed_or_tender']) && $_POST['fixed_or_tender'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Цена зафиксирована</option>
                                <option value="2" <?php 
    if (isset($_POST['fixed_or_tender']) && $_POST['fixed_or_tender'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Тендерное предложение</option>
                            </select>
                        </div>
                    </th>
                    <th>
                        <div class="tbl_thead_search_button_1">
                            <a href="JavaScript:onTblTheadButtonSnowClick();" title="Полная форма изменения условий поиска"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/search-1.png" width="24px" height="24px"></a>&nbsp;
                            <a href="javascript:onTblTheadButtonClearClick();" title="Очистить все условия фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/eraser.png" width="24px" height="24px"></a>&nbsp;
                            <a href="javascript:onTblTheadButtonSearchClick();" title="Выполнить поиск по текущим условиям фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/find-1.png" width="24px" height="24px"></a>
                        </div>
                    </th>
                </tr>
    </form>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
<!------------------------------------------------------------------------->                        
    <div id="preloader">
        <img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/ajax-loader-3.gif" alt="Loading..."/>
    </div>
<!------------------------------------------------------------------------->                        
    <div id="pages_container">

    </div>
<!------------------------------------------------------------------------->                        
    <!--div id="slideout">
        <img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/search-1.png" width="32px" height="32px" alt="Форма поиска"></a>
        <div id="slideout_inner"-->
    <div class="slide_panel">
            <?php 
    tzs_front_end_search_pr_form();
    ?>
        <!--/div-->
    </div>
<!------------------------------------------------------------------------->                        
    <script src="/wp-content/plugins/tzs/assets/js/table_reload.js"></script>
    <script src="/wp-content/plugins/tzs/assets/js/jquery.stickytableheaders.min.js"></script>
    
    <script>
        var SearchFormVisible = false;
        

        function onCountryFromSelected() {
            var rid = <?php 
    echo isset($_POST["region_from"]) ? $_POST["region_from"] : 0;
    ?>
;
            doAjax(jQuery('[name=country_from]').val(), rid, jQuery('[name=region_from]'));
        }
        
        function onCountryToSelected() {
            var rid = <?php 
    echo isset($_POST["region_to"]) ? $_POST["region_to"] : 0;
    ?>
;
            doAjax(jQuery('[name=country_to]').val(), rid, jQuery('[name=region_to]'));
        }
        //
        function onForm1Change() {
            // chk_2
            jQuery('#chk_2').prop('checked', (jQuery('[name=sale_or_purchase]').val() > 0));
            if (jQuery('#chk_2').is(':checked')) {
                jQuery('#chk_2').removeAttr('disabled');
            } else {
                jQuery('#chk_2').attr('disabled', 'disabled');
            }
            
            // chk_3
            jQuery('#chk_3').prop('checked', ((jQuery('[name=data_from]').val().length > 7) || (jQuery('[name=data_to]').val().length > 7)));
            if (jQuery('#chk_3').is(':checked')) {
                jQuery('#chk_3').removeAttr('disabled');
            } else {
                jQuery('#chk_3').attr('disabled', 'disabled');
            }
            
            // chk_4
            jQuery('#chk_4').prop('checked', (jQuery('[name=type_id]').val() > 0));
            if (jQuery('#chk_4').is(':checked')) {
                jQuery('#chk_4').removeAttr('disabled');
            } else {
                jQuery('#chk_4').attr('disabled', 'disabled');
            }
            
            // chk_5
            jQuery('#chk_5').prop('checked', ((jQuery('[name=pr_title]').val().length > 0) || (jQuery('[name=country_from]').val() > 0) || (jQuery('[name=region_from]').val() > 0) || (jQuery('[name=cityname_from]').val().length > 0)));
            if (jQuery('#chk_5').is(':checked')) {
                jQuery('#chk_5').removeAttr('disabled');
            } else {
                jQuery('#chk_5').attr('disabled', 'disabled');
            }
            
            // chk_6
            jQuery('#chk_6').prop('checked', ((jQuery('[name=price_from]').val().length > 0) || (jQuery('[name=price_to]').val().length > 0)));
            if (jQuery('#chk_6').is(':checked')) {
                jQuery('#chk_6').removeAttr('disabled');
            } else {
                jQuery('#chk_6').attr('disabled', 'disabled');
            }
            
            // chk_7
            jQuery('#chk_7').prop('checked', ((jQuery('[name=payment]').val() > 0) || (jQuery('[name=nds]').val() > 0)));
            if (jQuery('#chk_7').is(':checked')) {
                jQuery('#chk_7').removeAttr('disabled');
            } else {
                jQuery('#chk_7').attr('disabled', 'disabled');
            }
            
            // chk_8
            jQuery('#chk_8').prop('checked', (jQuery('[name=fixed_or_tender]').val() > 0));
            if (jQuery('#chk_8').is(':checked')) {
                jQuery('#chk_8').removeAttr('disabled');
            } else {
                jQuery('#chk_8').attr('disabled', 'disabled');
            }
        }
        
        
        function onClearFilterSelected(eventObject) {
            var fid = eventObject.target.id;
            var fname = eventObject.target.name;
            var fchk = eventObject.target.checked;
            
            if (!fchk) {
                switch (fid) {
                    case 'chk_2': {
                        jQuery('[name=sale_or_purchase]').attr('value', 0);
                        jQuery('#chk_2').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_3': {
                        jQuery('[name=data_from]').attr('value', '');
                        jQuery('[name=data_to]').attr('value', '');
                        jQuery('#chk_3').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_4': {
                        jQuery('[name=type_id]').attr('value', 0);
                        jQuery('#chk_4').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_5': {
                        jQuery('[name=pr_title]').attr('value', '');
                        jQuery('[name=country_from]').attr('value', 0);
                        jQuery('[name=region_from]').attr('value', 0);
                        jQuery('[name=cityname_from]').attr('value', '');
                        jQuery('#chk_5').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_6': {
                        jQuery('[name=price_from]').attr('value', '');
                        jQuery('[name=price_to]').attr('value', '');
                        jQuery('#chk_6').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_7': {
                        jQuery('[name=payment]').attr('value', 0);
                        jQuery('[name=nds]').attr('value', 0);
                        jQuery('#chk_7').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_8': {
                        jQuery('[name=fixed_or_tender]').attr('value', 0);
                        jQuery('#chk_8').attr('disabled', 'disabled');
                        break;
                    }
                }
            }
        }
        
        function onTblTheadButtonSnowClick() {
            tblTHeadShowForm('', '.tbl_thead_search_div');
            tblTHeadShowSearchForm();
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function onTblTheadButtonSearchClick() {
            tblTHeadShowForm('', '.tbl_thead_search_div');
            if (SearchFormVisible) { tblTHeadShowSearchForm(); }
            //FormToFormCopy("search_pr_form1", "search_pr_form");
            TblTbodyReload(<?php 
    echo isset($_POST['page']) ? $_POST['page'] : '1';
    ?>
);
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function onTblTheadButtonClearClick() {
            FormClear("search_pr_form");
            FormClear("search_pr_form1");
            onForm1Change();
            tblTHeadShowForm('', '.tbl_thead_search_div');
            if (SearchFormVisible) { tblTHeadShowSearchForm(); }
            TblTbodyReload(<?php 
    echo isset($_POST['page']) ? $_POST['page'] : '1';
    ?>
);
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function onTblSearchButtonClick() {
            tblTHeadShowForm('', '.tbl_thead_search_div');
            //FormToFormCopy("search_pr_form", "search_pr_form1");
            TblTbodyReload(<?php 
    echo isset($_POST['page']) ? $_POST['page'] : '1';
    ?>
);
            // Скроем форму
            tblTHeadShowSearchForm();
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function tblTHeadShowSearchForm() {
            if (!SearchFormVisible) { 
                jQuery('.slide_panel').animate({'left':'0'},600); 
                //jQuery('#slideout').stop().animate({left: 385}, 1000);
                //jQuery('#slideout_inner').stop().animate({left: 0}, 1000);
            }
            else { 
                jQuery('.slide_panel').animate({'left':'-420'},500); 
                //jQuery('#slideout').stop().animate({left: 0}, 'slow');
                //jQuery('#slideout_inner').stop().animate({left: -385}, 'slow');
            }
            SearchFormVisible = ~ SearchFormVisible;
        }

  
        function thRecordsPerPagePrint(records_per_page) {
            var vTZS_RECORDS_PER_PAGE = <?php 
    echo TZS_RECORDS_PER_PAGE;
    ?>
;
            var vRecordsArray = [<?php 
    echo TZS_RECORDS_PER_PAGE_ARRAY;
    ?>
];
            var vRecordsStr = 'Количество записей на странице:<br>';
            
            if (!records_per_page || (records_per_page < 1)) { records_per_page = vTZS_RECORDS_PER_PAGE; }
            
            for(i=0;i<vRecordsArray.length;i++) {
                if (vRecordsArray[i] != records_per_page) {
                    vRecordsStr += '<a href="javascript:onRecordsPerPageSelected(' + vRecordsArray[i] + ')">' + vRecordsArray[i] + '</a>&nbsp;&nbsp;';
                }
            }
            
            jQuery("#tbl_thead_records_per_page_th").html(vRecordsStr);
        }
  
        function onRecordsPerPageSelected(records_per_page) {
            addHidden("#search_pr_form1", 'records_per_page', records_per_page);
            TblTbodyReload(1);
            thRecordsPerPagePrint(records_per_page);
        }
        
        // Функция, отрабатывающая после готовности HTML-документа
        jQuery(document).ready(function(){
                <?php 
    if (get_current_user_id() == 0) {
        ?>
                    jQuery('#menu-profile').hide();
                <?php 
    }
    ?>
                    
                // Установим обработчик "клика" в строках таблицы
                jQuery('#tbl_products').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;
                });
                
                jQuery("#show-search-form").click(function () { onTblTheadButtonSnowClick(); });

                // Создадми скрытые поля для формы
                var theForm = "#search_pr_form1";
                addHidden(theForm, 'form_type', 'products');
              //addHidden(theForm, 'type_id', '<?php 
    echo $p_id;
    ?>
');
                addHidden(theForm, 'rootcategory', '<?php 
    echo $rootcategory;
    ?>
');
                addHidden(theForm, 'cur_type_id', '<?php 
    echo $p_id;
    ?>
');
                addHidden(theForm, 'cur_post_name', '<?php 
    echo $p_name;
    ?>
');
                addHidden(theForm, 'p_title', '<?php 
    echo $p_title;
    ?>
');
                addHidden(theForm, 'records_per_page', '<?php 
    echo isset($_POST['records_per_page']) ? $_POST['records_per_page'] : TZS_RECORDS_PER_PAGE;
    ?>
');
                
                // Установим размеры для выезжающей панели с формой
                jQuery(".slide_panel").css({
                    'width': '360px',
                    'left': '-420px'
                });

                //jQuery('#thead_h1').html('<div class="div_td_left"><h1 class="entry-title">'+jQuery('h1.entry-title').html()+'</h1></div>');
                jQuery('header.entry-header').hide();
                jQuery("#tbl_products").stickyTableHeaders();
                
                // Устанавливаем обработчики событий 
                setFormFielsdChangeHandler('search_pr_form');
                jQuery('#chk_2, #chk_3, #chk_4, #chk_5, #chk_6, #chk_7, #chk_8').change(function(eventObject) { onClearFilterSelected(eventObject); });
                
                /*jQuery('#slideout').hover(
                    function() {
                        //jQuery('#slideout').stop().animate({left: 385}, 1000);
                        //jQuery('#slideout_inner').stop().animate({left: 0}, 1000);
                        if (!SearchFormVisible) { tblTHeadShowSearchForm(); }
                    }, 
                    function() {
                        //jQuery('#slideout').stop().animate({left: 0}, 'slow');
                        //jQuery('#slideout_inner').stop().animate({left: -385}, 'slow');
                    }
                );*/
    
                onForm1Change();
                //
                jQuery.datepicker.setDefaults(jQuery.datepicker.regional['ru']);
                jQuery("[name=data_from]").datepicker({ dateFormat: "dd.mm.yy" });
                jQuery("[name=data_to]").datepicker({ dateFormat: "dd.mm.yy" });


                // Скроем форму
                if (SearchFormVisible) { tblTHeadShowSearchForm(); }
                
                // Обновим тело таблицы
                TblTbodyReload(1);
                thRecordsPerPagePrint(<?php 
    echo isset($_POST['records_per_page']) ? $_POST['records_per_page'] : TZS_RECORDS_PER_PAGE;
    ?>
);

                //hijackLinks(post);

                ///
        });
    </script>
    <?php 
    ////
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
示例#4
0
function tzs_print_product_form($errors, $edit = false)
{
    //$d = date("d.m.Y");
    // Добавим 7 дней к текущей дате
    $dt = new DateTime();
    date_add($dt, date_interval_create_from_date_string(TZS_PR_PUBLICATION_MIN_DAYS + 1 . ' days'));
    $d = date_format($dt, "d.m.Y");
    if (isset($_GET['spis'])) {
        echo "<a id='edit_search' href='/account/my-products/'>Назад к списку</a> <div style='clear: both'></div>";
    } else {
        echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
    }
    echo '<div style="clear: both;"></div>';
    print_errors($errors);
    ?>
    <script src="/wp-content/plugins/tzs/assets/js/autocomplete.js"></script>
    <div style="clear: both;"></div>
    
    
    <form enctype="multipart/form-data" method="post" id="bpost" class="pr_edit_form post-form" action="">

<!-- Новый вид формы, навеяно http://xiper.net/collect/html-and-css-tricks/verstka-form/blochnaya-verstka-form -->
        <div>
            <hr/>
            <!--h3>Добавление товара или услуги</h3-->
            <!--p>Укажите, пожалуйста, категорию, наименование, описание, количество, стоимость, форму оплаты, месторасположение, дату окончания публикации товара и комментарии</p-->
            <p>Минимальный период публикации товара - <strong><?php 
    echo TZS_PR_PUBLICATION_MIN_DAYS;
    ?>
</strong> дней.<br/>При наступлении даты окончания публикации товар будет автоматически перенесен в архив.</p>
            <hr/>
        </div>
	<?php 
    if ($edit) {
        ?>
        <div class="pr_edit_form_line">
            <label for="pr_id">Номер</label>
            <input type="text" id="" name="pr_id" size="15" value="<?php 
        echo_val('id');
        ?>
" disabled="disabled">
        </div>
	<?php 
    }
    ?>
        <div class="pr_edit_form_line">
            <label for="pr_type_id">Статус</label>
            <select name="pr_active">
                <option value="1" <?php 
    if (isset($_POST["pr_active"]) && $_POST["pr_active"] === 1) {
        echo 'selected="selected"';
    }
    ?>
 >Публикуемый</option>
                <option value="0" <?php 
    if (isset($_POST["pr_active"]) && $_POST["pr_active"] === 0) {
        echo 'selected="selected"';
    }
    ?>
 >Архивный</option>
            </select>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_type_id">Категория</label>
            <select name="pr_type_id">
                <?php 
    tzs_build_product_types('pr_type_id', TZS_PR_ROOT_CATEGORY_PAGE_ID);
    ?>
            </select>
            <?php 
    wp_nonce_field('pr_type_id', 'pr_type_id_nonce');
    ?>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_sale_or_purchase">Тип заявки</label>
            <select name="pr_sale_or_purchase">
                <option value="1" <?php 
    if (isset($_POST['pr_sale_or_purchase']) && $_POST['pr_sale_or_purchase'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Продажа</option>
                <option value="2" <?php 
    if (isset($_POST['pr_sale_or_purchase']) && $_POST['pr_sale_or_purchase'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Покупка</option>
            </select>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_fixed_or_tender">Участник тендера</label>
            <select name="pr_fixed_or_tender">
                <option value="1" <?php 
    if (isset($_POST['pr_fixed_or_tender']) && $_POST['pr_fixed_or_tender'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Цена зафиксирована</option>
                <option value="2" <?php 
    if (isset($_POST['pr_fixed_or_tender']) && $_POST['pr_fixed_or_tender'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Тендерное предложение</option>
            </select>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_title">Наименование</label>
            <input type="text" id="pr_edit_text_big" name="pr_title" size="135" maxlength="255" value="<?php 
    echo_val('pr_title');
    ?>
">
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_description">Описание</label>
            <?php 
    $args = array('wpautop' => 1, 'media_buttons' => 0, 'textarea_name' => 'pr_description', 'textarea_rows' => 10, 'tabindex' => null, 'editor_css' => '', 'editor_class' => '', 'teeny' => 1, 'dfw' => 0, 'tinymce' => 1, 'quicktags' => array('id' => 'editpost', 'buttons' => 'strong,em,ul,ol,li,close'), 'drag_drop_upload' => false);
    wp_editor($_POST['pr_description'], 'editpost', $args);
    ?>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_copies">Количество</label>
            <input type="number" id="" name="pr_copies" size="2" value="<?php 
    echo_val('pr_copies');
    ?>
" min="0">
            <select for="pr_copies" name="pr_unit">
            <?php 
    foreach ($GLOBALS['tzs_pr_unit'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if ($val == '') {
            $val = '-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-';
        }
        if (isset($_POST['pr_unit']) && $_POST['pr_unit'] == $key && $key != 0) {
            echo 'selected="selected"';
        }
        if ($key == 0) {
            echo 'disabled="disabled"';
        }
        //echo '>'.htmlspecialchars($val).'</option>\n';
        echo '>' . $val . '</option>\\n';
    }
    ?>
            </select>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_price">Стоимость</label>
            <input type="text" id="" name="pr_price" size="10" value="<?php 
    echo_val('pr_price');
    ?>
">
            <select for="price" name="pr_currency">
            <?php 
    foreach ($GLOBALS['tzs_pr_curr'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if ($val == '') {
            $val = '-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-';
        }
        if (isset($_POST['pr_currency']) && $_POST['pr_currency'] == $key && $key != 0) {
            echo 'selected="selected"';
        }
        if ($key == 0) {
            echo 'disabled="disabled"';
        }
        //echo '>'.htmlspecialchars($val).'</option>\n';
        echo '>' . $val . '</option>\\n';
    }
    ?>
            </select>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_payment">Форма оплаты</label>
            <select name="pr_payment">
            <?php 
    foreach ($GLOBALS['tzs_pr_payment'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if ($val == '') {
            $val = '-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-';
        }
        if (isset($_POST['pr_payment']) && $_POST['pr_payment'] == $key) {
            // && $key != 0
            echo 'selected="selected"';
        }
        if ($key == 0) {
            //echo 'disabled="disabled"';
        }
        //echo '>'.htmlspecialchars($val).'</option>\n';
        echo '>' . $val . '</option>\\n';
    }
    ?>
            </select>
            <select name="pr_nds">
                <option value="0" <?php 
    if (isset($_POST['pr_nds']) && $_POST['pr_nds'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 disabled="disabled">---------------</option>
                <option value="1" <?php 
    if (isset($_POST['pr_nds']) && $_POST['pr_nds'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Без НДС</option>
                <option value="2" <?php 
    if (isset($_POST['pr_nds']) && $_POST['pr_nds'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Включая НДС</option>
            </select>
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_city_from">Местонахождение</label>
            <input autocomplete="city" id="pr_edit_text_big" type="text" size="135" name="pr_city_from" value="<?php 
    echo_val('pr_city_from');
    ?>
" autocomplete="off">
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_expiration">Окончание публикации</label>
            <input type="text" id="datepicker1" name="pr_expiration" size="" value="<?php 
    echo_val_def('pr_expiration', $d);
    ?>
">
        </div>
        <div class="pr_edit_form_line">
            <label for="pr_comment">Комментарии</label>
            <input type="text" id="pr_edit_text_big" name="pr_comment" size="135" value="<?php 
    echo_val('pr_comment');
    ?>
">
        </div>

	<?php 
    if ($edit) {
        ?>
		<input type="hidden" name="action" value="editproduct"/>
		<input type="hidden" name="id" value="<?php 
        echo_val('id');
        ?>
"/>
	<?php 
    } else {
        ?>
		<input type="hidden" name="action" value="addproduct"/>
	<?php 
    }
    ?>
	<input type="hidden" name="formName" value="product" />
        <table>
            <tr>
                <td width="130px">&nbsp;</td>
                <td>
                    <input name="addpost" type="submit" id="addpostsub" class="submit_button" value="<?php 
    echo $edit ? "Изменить" : "Разместить";
    ?>
"/>
                </td>
                <td width="15px">&nbsp;</td>
                <td>
                    <?php 
    if ($edit) {
        ?>
                        <a href="/edit-images-pr/?id=<?php 
        echo_val('id');
        ?>
&form_type=product" id="edit_images">Загрузить/обновить изображения</a>
                        <!--button id="edit_images" onClick="javascript: window.open('/edit-images-pr/?id=<?php 
        echo_val('id');
        ?>
&form_type=product', '_self');">Изменить изображения</button-->
                    <?php 
    }
    ?>
                </td>
            </tr>
        </table>
    </form>
	
    <script>
        jQuery(document).ready(function(){
            jQuery('#bpost').submit(function() {
                    jQuery('#addpostsub').attr('disabled','disabled');
                    return true;
            });
            jQuery.datepicker.setDefaults(jQuery.datepicker.regional['ru']);
            jQuery( "#datepicker1" ).datepicker({ dateFormat: "dd.mm.yy" });
            
            jQuery("[name=pr_sale_or_purchase]").change(function (eventObject) {
                if (eventObject.target.value == 2) {
                    jQuery("[name=pr_fixed_or_tender]").attr('value', 2);
                    jQuery('[name=pr_fixed_or_tender]').attr('disabled', 'disabled');
                } else {
                    jQuery('[name=pr_fixed_or_tender]').removeAttr('disabled');
                }
            });
        });
    </script>
<?php 
}
示例#5
0
function tzs_print_product_form($errors, $edit = false)
{
    //$d = date("d.m.Y");
    // Добавим 7 дней к текущей дате
    $dt = new DateTime();
    date_add($dt, date_interval_create_from_date_string(TZS_PR_PUBLICATION_MIN_DAYS + 1 . ' days'));
    $d = date_format($dt, "d.m.Y");
    $img_info = array();
    $img_names = array();
    //if(isset($_GET['spis'])) echo "<a id='edit_search' href='/account/my-products/'>Назад к списку</a> <div style='clear: both'></div>";
    //else echo "<button id='edit_search'  onclick='history.back()'>Назад к списку</button> <div style='clear: both'></div>";
    if (isset($_POST["pr_image_id_lists"]) && strlen($_POST["pr_image_id_lists"]) > 0) {
        $img_names = explode(';', $_POST["pr_image_id_lists"]);
        for ($i = 0; $i < count($img_names); $i++) {
            if ($img_names[$i] !== null && $img_names[$i] !== '') {
                $img_info[$i] = wp_get_attachment_image_src($img_names[$i], 'thumbnail');
            }
        }
    }
    //echo '<div style="clear: both;"></div>';
    //print_errors($errors);
    ?>
    <script src="/wp-content/plugins/tzs/assets/js/autocomplete.js"></script>
    
    <div style="clear: both;"></div>
    
    <!-- test new form -->
<div class="form_wrapper">
    <form enctype="multipart/form-data" method="post" id="form_product" class="" action="">
        
    <?php 
    if ($edit && isset($_POST["pr_active"]) && $_POST["pr_active"] == 0) {
        ?>
    <div class="row-fluid"  style="width: 100%; ">
        <div id="div_pr_active" class="span12">
            <div class="" style="background-color: #E5AEAE; text-align: center; padding: 2px;">Архивная заявка</div>
        </div>
    </div>
    <?php 
    }
    ?>
    
    <div class="row-fluid"  style="width: 100%; ">
        <div id="" class="span3">
            <select id="pr_type_id" name="pr_type_id">
                <option value="0" <?php 
    if (isset($_POST['pr_type_id']) && $_POST['pr_type_id'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Категория</option>
                <?php 
    tzs_build_product_types('pr_type_id', TZS_PR_ROOT_CATEGORY_PAGE_ID);
    ?>
            </select>
            <?php 
    wp_nonce_field('pr_type_id', 'pr_type_id_nonce');
    ?>
            <input type="hidden" name="pr_active" id="pr_active" value="1">
	</div>
        <div id="" class="span2">
            <!--label for="pr_sale_or_purchase">Тип заявки</label-->
            <select id="pr_sale_or_purchase" name="pr_sale_or_purchase" style="width: 100px;">
                <option value="0" <?php 
    if (isset($_POST['pr_sale_or_purchase']) && $_POST['pr_sale_or_purchase'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Тип заявки</option>
                <option value="1" <?php 
    if (isset($_POST['pr_sale_or_purchase']) && $_POST['pr_sale_or_purchase'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Продажа</option>
                <option value="2" <?php 
    if (isset($_POST['pr_sale_or_purchase']) && $_POST['pr_sale_or_purchase'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Покупка</option>
            </select>
        </div>
        <div id="" class="span3">
            <!--label for="pr_fixed_or_tender">Участник тендера</label-->
            <select id="pr_fixed_or_tender" name="pr_fixed_or_tender">
                <option value="0" <?php 
    if (isset($_POST['pr_fixed_or_tender']) && $_POST['pr_fixed_or_tender'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Участник тендера</option>
                <option value="1" <?php 
    if (isset($_POST['pr_fixed_or_tender']) && $_POST['pr_fixed_or_tender'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Цена зафиксирована</option>
                <option value="2" <?php 
    if (isset($_POST['pr_fixed_or_tender']) && $_POST['pr_fixed_or_tender'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Тендерное предложение</option>
            </select>
        </div>
        <div class="span4">
            <input autocomplete="city" id="first_city" type="text" size="35" name="pr_city_from" value="<?php 
    echo_val('pr_city_from');
    ?>
" autocomplete="on" placeholder="Местонахождение товара" style="width: 280px;">
        </div>
    </div>
    
    <div class="row-fluid"  style="width: 100%; ">
        <div class="span9">
            <input type="text" id="pr_title" name="pr_title" size="" maxlength="255" value="<?php 
    echo_val('pr_title');
    ?>
" placeholder="Наименование товара" style="width: 90%;">
        </div>
        <div class="span3">
        </div>
    </div>
                    
    <div class="row-fluid"  style="width: 100%; margin-bottom: 20px;">
        <div class="span8">
            <?php 
    /*$args = array(  'wpautop' => 1,
                      'media_buttons' => 0,
                      'textarea_name' => 'pr_description', //нужно указывать!
                      'textarea_rows' => 4,
                      'tabindex'      => null,
                      'editor_css'    => '',
                      'editor_class'  => '',
                      'teeny'         => 0,
                      'dfw'           => 0,
                      'tinymce'       => array(
                          'theme' => 'advanced',
                          //'theme_​advanced_​buttons1' => 'save,newdocument, | ,bold, italic, underline, strikethrough, |, justifyleft, justifycenter, justifyright, justifyfull, styleselect, formatselect, fontselect, fontsizeselect',
                          //'theme_​advanced_​buttons2' => 'cut, copy, paste, pastetext, pasteword, |, search, replace, |, bullist, numlist, |, outdent, indent, blockquote, |, undo, redo, |, link, unlink, anchor, image, cleanup, help, code, |, insertdate, inserttime, preview, |, forecolor, backcolor',
                          //'theme_​advanced_​buttons3' => 'tablecontrols, |, hr, removeformat, visualaid, |, sub, sup, |, charmap, emotions, iespell, media, advhr, |, print, |, ltr, rtl, |, fullscreen',
                          'theme_advanced_buttons1' => 'bold, italic, ul, min_size, max_size',
                          'theme_advanced_buttons2' => '',
                          'theme_advanced_buttons3' => '',
                          'theme_advanced_buttons4' => '',
                      ),
                      'quicktags'     => array(
                          'id' => 'editpost',
                          //'buttons' => 'formatselect,|bold,italic,underline,bullist,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,,spellchecker,wp_fullscreen,wp_adv'
                      ),
                      'drag_drop_upload' => false
                  );
      wp_editor($_POST['pr_description'], 'editpost', $args);
      */
    ?>
            
                <textarea name="pr_description" id="pr_description" cols="45" rows="3"><?php 
    echo $_POST['pr_description'];
    ?>
</textarea>
                <script type="text/javascript">
                    //CKEDITOR.replace( 'editor1');
                    CKEDITOR.config.toolbar = 'WB';
                    CKEDITOR.config.toolbar_WB = [
                        ['Bold','Italic','Underline','StrikeThrough','-','NumberedList','BulletedList','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','Undo','Redo','-','Image','Table','-','Link','Flash','Smiley','TextColor','BGColor','Source']
                        
                    ] ;
                    /*CKEDITOR.config.toolbar_WB = [
                        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat' ] },
                        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight'] },
                        { name: 'links', items: [ 'Link', 'Unlink' ] },
                        { name: 'insert', items: [ 'Image', 'SpecialChar' ] }
                        ];*/
                    CKEDITOR.replace( 'pr_description',
                        {
                            toolbar : 'WB'
                        });
                </script>
        </div>
        <div class="span4">
            <div class="span12" style="margin-bottom: 10px;">
                <label>Добавить изображения (до 1Мб):</label>
            </div>
            <div class="span12">
                <div class="pr_image_wrapper">
                    <div id="div_image1_off" class="pr_image_off">
                        <input type="file" id="image1_load" name="image1_load" class="inputfile inputfile-3" accept="image/jpeg,image/png,image/gif">
                        <label for="image1_load"><span>выбрать и загрузить</span></label>
                    </div>
                    <div id="div_image1_on" class="pr_image_on">
                        <span id="image1_delete" class="pr_image_delete"></span>
                        <img id="image1" src="<?php 
    echo isset($img_info[0][0]) ? $img_info[0][0] : '';
    ?>
">
                        <?php 
    if ($edit && isset($img_names[0])) {
        ?>
                            <input type="hidden" name="image_id_1" value="<?php 
        echo $img_names[0];
        ?>
"/>
                        <?php 
    }
    ?>
                    </div>
                </div>
                
                <div class="pr_image_wrapper">
                    <div id="div_image2_off" class="pr_image_off">
                        <input type="file" id="image2_load" name="image2_load" class="inputfile inputfile-3" accept="image/jpeg,image/png,image/gif">
                        <label for="image2_load"><span>выбрать и загрузить</span></label>
                    </div>
                    <div id="div_image2_on" class="pr_image_on">
                        <span id="image2_delete" class="pr_image_delete"></span>
                        <img id="image2" src="<?php 
    echo isset($img_info[1][0]) ? $img_info[1][0] : '';
    ?>
">
                        <?php 
    if ($edit && isset($img_names[1])) {
        ?>
                            <input type="hidden" name="image_id_2" value="<?php 
        echo $img_names[1];
        ?>
"/>
                        <?php 
    }
    ?>
                    </div>
                </div>
                
                <div class="pr_image_wrapper">
                    <div id="div_image3_off" class="pr_image_off">
                        <input type="file" id="image3_load" name="image3_load" class="inputfile inputfile-3" accept="image/jpeg,image/png,image/gif">
                        <label for="image3_load"><span>выбрать и загрузить</span></label>
                    </div>
                    <div id="div_image3_on" class="pr_image_on">
                        <span id="image3_delete" class="pr_image_delete"></span>
                        <img id="image3" src="<?php 
    echo isset($img_info[2][0]) ? $img_info[2][0] : '';
    ?>
">
                        <?php 
    if ($edit && isset($img_names[2])) {
        ?>
                            <input type="hidden" name="image_id_3" value="<?php 
        echo $img_names[2];
        ?>
"/>
                        <?php 
    }
    ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row-fluid"  style="width: 100%; ">
        <div id="div_pr_copies" class="span4">
            <label for="pr_copies">Количество</label>
            <input type="text" id="pr_copies" name="pr_copies" size="" value="<?php 
    echo_val('pr_copies');
    ?>
" min="0" placeholder="Количество" style="width: 80px;">
            &nbsp;&nbsp;
            <select for="pr_copies" id="pr_unit" name="pr_unit" style="width: 80px;">
            <?php 
    tzs_print_array_options($GLOBALS['tzs_pr_unit'], '', 'pr_unit', 'Ед.измерения');
    ?>
            </select>
        </div>
        <div id="div_pr_price" class="span4">
            <label for="pr_price">Стоимость</label>
            <input type="text" id="pr_price" name="pr_price" size="10" value="<?php 
    echo_val('pr_price');
    ?>
" placeholder="Стоимость" style="width: 80px;">
            &nbsp;&nbsp;
            <select for="pr_price" id="pr_currency" name="pr_currency" style="width: 80px;">
            <?php 
    tzs_print_array_options($GLOBALS['tzs_pr_curr'], '', 'pr_currency', 'Валюта');
    ?>
            </select>
        </div>
        <div class="span4">
            <label for="pr_expiration">Окончание публикации</label>
            <input type="text" id="datepicker1" name="pr_expiration" size="" value="<?php 
    echo_val_def('pr_expiration', $d);
    ?>
" placeholder="Дата выгрузки" readonly="true" style="width: 80px;">
        </div>
    </div>

    <div class="row-fluid"  style="width: 100%;">
        <div class="span8">
            <div class="span12">
                <label for="" id="payment_label">Форма расчета (можно указать несколько способов одновременно):</label>
            </div>
            
            <div class="span3 chekbox">
                <input type="checkbox" id="cash" name="cash" <?php 
    echo isset($_POST['cash']) ? 'checked="checked"' : '';
    ?>
><label for="cash">Наличная</label>
            </div>
            <div class="span3 chekbox">
                <input type="checkbox" id="nocash" name="nocash" <?php 
    echo isset($_POST['nocash']) ? 'checked="checked"' : '';
    ?>
><label for="nocash">Безналичная</label>
            </div>
            <div class="span3 chekbox">
                <input type="checkbox" id="nds" name="nds" <?php 
    echo isset($_POST['nds']) ? 'checked="checked"' : '';
    ?>
><label for="nds">включая НДС</label>
            </div>
            <div class="span3 chekbox">
                <input type="checkbox" id="nonds" name="nonds" <?php 
    echo isset($_POST['nonds']) ? 'checked="checked"' : '';
    ?>
><label for="nonds">без НДС</label>
            </div>
            
            <div class="span12">
            </div>
            
            <div class="span4">
                <button id="form_button1"><?php 
    echo $edit ? "ИЗМЕНИТЬ ЗАЯВКУ" : "РАЗМЕСТИТЬ ЗАЯВКУ";
    ?>
</button>
            </div>
            <div class="span4">
                <?php 
    if (!$edit) {
        ?>
                <button id="form_button2">ОЧИСТИТЬ ВСЕ ПОЛЯ</button>
                <?php 
    }
    ?>
            </div>
            <div class="span4">
                <button id="form_button3">ВЫХОД</button>
            </div>
        </div>
        
        <div class="span4" style="padding: 2px;"><!-- float: right; -->
            <div class="" id="form_error_message" style="color: #F00;border: 1px #F00 dashed; border-radius: 4px; padding: 3px 5px; display: none;">
            </div>
        </div>
    </div>

    <div class="row-fluid"  style="width: 100%; margin-top: 15px;">
        <div class="span12">
            <div style="font-size: 92%; font-style: italic;">
                После нажатия кнопки "РАЗМЕСТИТЬ ЗАЯВКУ" заявка будет опубликована в базе товаров, после нажатия кнопки "ВЫХОД" заявка не сохраняется.
            </div>
        </div>
    </div>

    <div class="row-fluid"  style="width: 100%; ">
        <div class="span12">
            <div style="font-size: 92%; font-style: italic;">
                <span style="color: #F00;">Напоминаем:</span> При наступлении даты окончания публикации товар будет автоматически перенесен в архив. Минимальный срок публикации - <?php 
    echo TZS_PR_PUBLICATION_MIN_DAYS;
    ?>
 дней
            </div>
        </div>
    </div>
    
	<?php 
    if ($edit) {
        ?>
		<input type="hidden" name="action" value="editproduct"/>
		<input type="hidden" name="id" value="<?php 
        echo_val('id');
        ?>
"/>
	<?php 
    } else {
        ?>
		<input type="hidden" name="action" value="addproduct"/>
                <input type="hidden" name="pr_active" value="1"/>
	<?php 
    }
    ?>
	<input type="hidden" name="formName" value="product" />
    </form>
</div>
    <div class="clearfix">&nbsp;</div>
    
    <!-- test new form END -->
    <script>
     jQuery('#pr_type_id').on('change', function() {
            jQuery('#div_pr_type_id').addClass("change");    
     });
     
     jQuery('#pr_sale_or_purchase').on('change', function() {
            jQuery('#div_pr_sale_or_purchase').addClass("change");    
     });
     
     jQuery('#pr_fixed_or_tender').on('change', function() {
            jQuery('#div_pr_fixed_or_tender').addClass("change");    
     });
    </script>
	
    <script>
        // Изменение поля "Единица измерения"
        function onPrUnitChange() {
            jQuery('#pr_currency').attr('value', jQuery('#pr_unit').val());
        }

        // Изменение поля "Валюта"
        function onPrCurrencyChange() {
            jQuery('#pr_unit').attr('value', jQuery('#pr_currency').val());
        }

        // Функция проверки правильности заполнения полей формы до отправки
        function onFormValidate() {
            //var ErrorMsg1 = 'Список ошибок:<ul>';
            var ErrorMsg1 = '<p>';
            var ErrorMsg2 = '';
            var ErrorMsg3 = '</p>';

            if (jQuery('#pr_type_id').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана категория товара.<br>\n';
                jQuery('#pr_type_id').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_type_id').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#pr_sale_or_purchase').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указан тип заявки.<br>\n';
                jQuery('#pr_sale_or_purchase').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_sale_or_purchase').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#pr_fixed_or_tender').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указан признак тендера.<br>\n';
                jQuery('#pr_fixed_or_tender').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_fixed_or_tender').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#first_city').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указан пункт местонахождения товара.<br>\n';
                jQuery('#first_city').css({'border': '2px solid #F00'});
            } else {
                jQuery('#first_city').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#pr_title').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указано наименование товара.<br>\n';
                jQuery('#pr_title').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_title').css({'border': '1px solid #007FFF'});
            }

            /*if (jQuery('#editpost').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не заполнено описание товара.<br>\n';
                jQuery('#editpost').css({'border': '2px solid #F00'});
            } else {
                jQuery('#editpost').css({'border': '1px solid #007FFF'});
            }*/

            if (jQuery('#pr_copies').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указано количество товара.<br>\n';
                jQuery('#pr_copies').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_copies').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#pr_unit').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана единица измерения количества товара.<br>\n';
                jQuery('#pr_unit').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_unit').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#pr_price').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана стоимость товара.<br>\n';
                jQuery('#pr_price').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_price').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#pr_currency').val() < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана валюта стоимости товара.<br>\n';
                jQuery('#pr_currency').css({'border': '2px solid #F00'});
            } else {
                jQuery('#pr_currency').css({'border': '1px solid #007FFF'});
            }

            if (jQuery('#datepicker1').val().length < 1) {
                ErrorMsg2 = ErrorMsg2 + 'Не указана дата окончания публикации.<br>\n';
                jQuery('#datepicker1').css({'border': '2px solid #F00'});
            } else {
                jQuery('#datepicker1').css({'border': '1px solid #007FFF'});
            }
                
            // Проверка правильности указания переключателей
            if (!(jQuery("#cash").is(':checked') || jQuery("#nocash").is(':checked') || jQuery("#nds").is(':checked') || jQuery("#nonds").is(':checked'))) {
                ErrorMsg2 = ErrorMsg2 + 'Необходимо выбрать хотя бы один способ в блоке "Форма расчета".<br>\n';
                jQuery('#payment_label').css({'border': '2px solid #F00'});
            } else {
                jQuery('#payment_label').css({'border': 'none'});
            }

            if (ErrorMsg2.length > 0) {
                jQuery("#form_error_message").html(ErrorMsg1 + ErrorMsg2 + ErrorMsg3);
                jQuery("#form_error_message").show();
                return false;
            } else {
                return true;
            }
        }

        // Очистка формы
        function resetForm(selector) {
            jQuery(':text, :password, :file, textarea', selector)
                    .val('')
                    .css({'border': '1px solid #007FFF'});
            jQuery(':input, select option', selector)
                    .removeAttr('checked')
                    .removeAttr('selected')
                    .css({'border': '1px solid #007FFF'});
            jQuery('select option:first', selector).attr('selected', true);

            // Очистим список ошибок
            jQuery("#form_error_message").html('');
            jQuery("#form_error_message").hide();
            
            jQuery("#image1_delete, #image2_delete, #image3_delete").click();
        }

        /*
         * Функция, вызываемая после загрузки страницы
         */
        jQuery(document).ready(function(){
            if (jQuery('#image1').attr('src') != '') {
                jQuery('#div_image1_off').hide();
                jQuery('#div_image1_on').show();
            }
            
            if (jQuery('#image2').attr('src') != '') {
                jQuery('#div_image2_off').hide();
                jQuery('#div_image2_on').show();
            }
            
            if (jQuery('#image3').attr('src') != '') {
                jQuery('#div_image3_off').hide();
                jQuery('#div_image3_on').show();
            }
            
            jQuery("#image1_load").change(function() {
                var fileObj = this.files[0];
                if (fileObj.size > 1024000) {
                    alert('Размер файла не должен превышать 1 Мб !');
                } else {
                    var url = URL.createObjectURL(fileObj);
                    jQuery('#image1').attr('src', url);
                    jQuery('#div_image1_off').hide();
                    jQuery('#div_image1_on').show();
                }
            });
            
            jQuery("#image2_load").change(function() {
                var fileObj = this.files[0];
                if (fileObj.size > 1024000) {
                    alert('Размер файла не должен превышать 1 Мб !');
                } else {
                    var url = URL.createObjectURL(fileObj);
                    jQuery('#image2').attr('src', url);
                    jQuery('#div_image2_off').hide();
                    jQuery('#div_image2_on').show();
                }
            });
            
            jQuery("#image3_load").change(function() {
                var fileObj = this.files[0];
                if (fileObj.size > 1024000) {
                    alert('Размер файла не должен превышать 1 Мб !');
                } else {
                    var url = URL.createObjectURL(fileObj);
                    jQuery('#image3').attr('src', url);
                    jQuery('#div_image3_off').hide();
                    jQuery('#div_image3_on').show();
                }
            });
            
            jQuery("#image1_delete").click(function(event) {
                jQuery('#image1').removeAttr('src');
                jQuery('#div_image1_off').show();
                jQuery('#div_image1_on').hide();
            });
            
            jQuery("#image2_delete").click(function(event) {
                jQuery('#image2').removeAttr('src');
                jQuery('#div_image2_off').show();
                jQuery('#div_image2_on').hide();
            });
            
            jQuery("#image3_delete").click(function(event) {
                jQuery('#image3').removeAttr('src');
                jQuery('#div_image3_off').show();
                jQuery('#div_image3_on').hide();
            });
            
            jQuery("#form_button1").click(function(event) { 
                event.preventDefault();
                var flag = onFormValidate();
                if (flag) {
                    jQuery("form[id='form_product']").submit();
                }
            });

            jQuery("#form_button2").click(function(event) { 
                event.preventDefault();
                resetForm("form[id='form_product']");
            });

            jQuery("#form_button3").click(function(event) { 
                event.preventDefault();
                location.href = "/account/profile/";
            });

            jQuery("#pr_sale_or_purchase").change(function (eventObject) {
                if (eventObject.target.value == 2) {
                    jQuery("#pr_fixed_or_tender").attr('value', 2);
                    jQuery('#pr_fixed_or_tender').attr('disabled', 'disabled');
                } else {
                    jQuery('#pr_fixed_or_tender').removeAttr('disabled');
                }
            });

            jQuery.datepicker.setDefaults(jQuery.datepicker.regional['ru']);
            jQuery( "#datepicker1" ).datepicker({ 
                dateFormat: "dd.mm.yy",
                minDate: "<?php 
    echo $d;
    ?>
",
                selectOtherMonths: true,
                showOtherMonths: true,
            });
            jQuery('#datepicker1').css({'cursor': 'pointer'});
    
            jQuery("#pr_copies, #pr_price").bind("change keyup input click", function() {
                if (this.value.match(/[^0-9.]/g)) {
                    this.value = this.value.replace(/[^0-9.]/g, '');
                }
            });
            
            jQuery("#pr_unit").change(function() { onPrUnitChange(); });
            jQuery("#pr_unit").keyup(function() { onPrUnitChange(); });
            jQuery("#pr_currency").change(function() { onPrCurrencyChange(); });
            jQuery("#pr_currency").keyup(function() { onPrCurrencyChange(); });
            if (jQuery('#pr_unit').val() < 1) {
                jQuery("#pr_unit").attr('value', 1);
                jQuery("#pr_currency").attr('value', 1);
            }
    
            
            <?php 
    if ($errors != null && count($errors) > 0) {
        $err_str = '';
        foreach ($errors as $error) {
            $err_str .= $error . '</br>';
        }
        ?>
                jQuery("#form_error_message").html("<?php 
        echo $err_str;
        ?>
");
                jQuery("#form_error_message").show();
            <?php 
    }
    ?>

        });
    </script>
<?php 
}
示例#6
0
function tzs_front_end_shipments_handler($atts)
{
    ob_start();
    ?>
    
<!------------------------------------------------------------------------->                        
    <div id="table_product">
        <table  id="tbl_products">
            <thead>
    <form class="search_pr_form" id="search_pr_form2" name="search_pr_form1" method="POST">
                <tr id="tbl_thead_records_per_page">
                    <!--th colspan="3" id="thead_h1"></th-->
                    <th colspan="9">
                        <div id="thead_h1" class="div_td_left"><h1 class="entry-title"><strong>ПОИСК ГРУЗА</strong></h1></div>
                        <div id="show-search-form" class="search_button">поиск по<br>критериям</div>
                    <?php 
    if (get_current_user_id() == 0) {
        ?>
                        <div class="thead_info">Для добавления грузов, пожалуйста, <a href="/account/login">войдите</a> или <a href="/account/registration/">зарегистрируйтесь</a></div>
                    <?php 
    }
    ?>
                        <div id="tbl_thead_records_per_page_th"></div>
                    </th>
                </tr>
                <tr>
                    <th id="tbl_trucks_id">Номер, дата и время заявки</th>
                    <th nonclickable="true" style="min-width: 260px; padding: 0; margin: 0;">
                        <div class="tbl_trucks_path">Пункты погрузки /<br/>выгрузки<br/>&nbsp;</div>
                        <div class="tbl_trucks_dtc">Даты погрузки /<br>выгрузки</div>
                    </th>
                    <th id="tbl_trucks_tc">Тип груза /<br>Желаемый тип ТС</th>
                    <th id="tbl_trucks_wv">Вес,<br>объём</th>
                    <th id="tbl_trucks_comm">Описание груза</th>
                    <th id="tbl_trucks_cost">Cтоимость,<br/>цена 1 км</th>
                    <th id="tbl_trucks_payment" nonclickable="true">Форма оплаты</th>
                    <th id="tbl_trucks_cont" nonclickable="true">Контактные данные</th>
                </tr>
                <tr>
                    <th>
                    </th>
                    <th style="min-width: 260px; width: 260px; padding: 0; margin: 0;">
                        <div class="tbl_trucks_path">
                        <div id="tbl_thead_search_button_2" class="tbl_thead_search_button" title="Фильтр по типу заявок">
                            <!--img chk="1" src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/checkbox_<?php 
    echo isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] > 0 ? 'checked' : 'unchecked';
    ?>
.png" width="16px" height="16px"-->
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_2', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_2" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_2" class="tbl_thead_search_div">
                            <span style="float: left;padding: 5px 5px;">
                                Пункт погрузки: страна:<br>
                                <select name="country_from">
                                    <?php 
    tzs_build_countries('country_from');
    ?>
                                </select><br>
                                Пункт погрузки: регион:<br>
                                <select name="region_from">
                                            <option>все области</option>
                                </select><br>
                                Пункт погрузки:&nbsp;<input type="checkbox" name="cargo_city_from" value="" <?php 
    if (isset($_POST['cargo_city_from'])) {
        echo 'checked="checked"';
    }
    ?>
/>город<br>
                                <input type="text" name="cargo_cityname_from" value="<?php 
    echo_val('cargo_cityname_from');
    ?>
" size="10"><br>
                                Пункт загрузки в радиусе<sup>*</sup>:&nbsp;<input type="checkbox" name="cargo_city_from_radius_check" value="" <?php 
    if (isset($_POST['cargo_city_from_radius_check'])) {
        echo 'checked="checked"';
    }
    ?>
/><br>
                                <select name="cargo_city_from_radius_value">
                                    <?php 
    foreach ($GLOBALS['tzs_city_from_radius_value'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if (isset($_POST['cargo_city_from_radius_value']) && $_POST['cargo_city_from_radius_value'] == $key || !isset($_POST['cargo_city_from_radius_value']) && $key == 0) {
            echo 'selected="selected"';
        }
        echo '>' . htmlspecialchars($val) . '</option>';
    }
    ?>
                                </select><br>
                            </span>
                            <span style="float: right;padding: 5px 5px;">
                                Пункт выгрузки: страна:<br>
                                <select name="country_to">
                                    <?php 
    tzs_build_countries('country_to');
    ?>
                                </select><br>
                                Пункт выгрузки: регион:<br>
                                <select name="region_to">
                                            <option>все области</option>
                                </select><br>
                                Пункт выгрузки:&nbsp;<input type="checkbox" name="cargo_city_to" value="" <?php 
    if (isset($_POST['cargo_city_to'])) {
        echo 'checked="checked"';
    }
    ?>
/>город<br>
                                <input type="text" name="cargo_cityname_to" value="<?php 
    echo_val('cargo_cityname_to');
    ?>
" size="10"><br><br>
                                <i><sup>*</sup>Для выбора радиуса укажите<br>страну и город пункта загрузки.</i>
                            </span>
                        </div>
                    <!--/th>
                    <th-->
                        </div>
                        <div class="tbl_trucks_dtc">
                        <div id="tbl_thead_search_button_3" class="tbl_thead_search_button" title="Фильтр по участнику тендера">
                            <!--img chk="1" src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/checkbox_<?php 
    echo isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] > 0 ? 'checked' : 'unchecked';
    ?>
.png" width="16px" height="16px"-->
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_3', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_3" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_3" class="tbl_thead_search_div">
                            Дата погрузки:<br>
                            <input type="text" name="data_from" value="<?php 
    echo_val('data_from');
    ?>
" size="10"><br>
                            Дата выгрузки:<br>
                            <input type="text" name="data_to" value="<?php 
    echo_val('data_to');
    ?>
" size="10">
                        </div>
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_4" class="tbl_thead_search_button" title="Фильтр по типу груза">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_4', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_4" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_4" class="tbl_thead_search_div">
                            Тип груза:<br>
                            <select name="sh_type">
                                <?php 
    foreach ($GLOBALS['tzs_sh_types_search'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if (isset($_POST['sh_type']) && $_POST['sh_type'] == $key || !isset($_POST['sh_type']) && $key == 0) {
            echo 'selected="selected"';
        }
        echo '>' . htmlspecialchars($val) . '</option>';
    }
    ?>
                            </select><br>
                            Тип транспорта:<br>
                            <select name="trans_type">
                                <?php 
    foreach ($GLOBALS['tzs_tr_types_search'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if (isset($_POST['trans_type']) && $_POST['trans_type'] == $key || !isset($_POST['trans_type']) && $key == 0) {
            echo 'selected="selected"';
        }
        echo '>' . htmlspecialchars($val) . '</option>';
    }
    ?>
                            </select>
                        </div>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_5" class="tbl_thead_search_button" title="Фильтр по описанию товара">
                            <!--img chk="1" src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/checkbox_<?php 
    echo isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] > 0 ? 'checked' : 'unchecked';
    ?>
.png" width="16px" height="16px"-->
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_5', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_5" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_5" class="tbl_thead_search_div">
                            Масса: от:<br>
                            <select name="weight_from">
                                    <?php 
    tzs_print_weight('weight_from');
    ?>
                            </select><br>
                            Масса: до:<br>
                            <select name="weight_to">
                                    <?php 
    tzs_print_weight('weight_to');
    ?>
                            </select><br>
                            Объем: от:<br>
                            <select name="volume_from">
                                    <?php 
    tzs_print_volume('volume_from');
    ?>
                            </select><br>
                            Объем: до:<br>
                            <select name="volume_to">
                                    <?php 
    tzs_print_volume('volume_to');
    ?>
                            </select>
                        </div>
                    </th>
                    <th>
                    </th>
                    <th>
                        <div id="tbl_thead_search_button_7" class="tbl_thead_search_button" title="Фильтр по цене/стоимости">
                            <a href="JavaScript:tblTHeadShowForm('#tbl_thead_search_div_7', '.tbl_thead_search_div');"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/navigate-down.png"></a>
                            <label class="switch"><input id="chk_7" type="checkbox" value="1" name="k" disabled="disabled"><span class="switch"></span></label>
                        </div>
                        <div id="tbl_thead_search_div_7" class="tbl_thead_search_div">
                            Cтоимость: от:<br>
                            <input type="text" name="price_from" value="<?php 
    echo_val('price_from');
    ?>
" size="10"><br>
                            Cтоимость: до:<br>
                            <input type="text" name="price_to" value="<?php 
    echo_val('price_to');
    ?>
" size="10"><br>
                            Цена 1 км: от:<br>
                            <input type="text" name="price_km_from" value="<?php 
    echo_val('price_from');
    ?>
" size="10"><br>
                            Цена 1 км: до:<br>
                            <input type="text" name="price_km_to" value="<?php 
    echo_val('price_to');
    ?>
" size="10"><br>
                        </div>
                    </th>
                    <th>
                    </th>
                    <th>
                        <div class="tbl_thead_search_button_1">
                            <a href="JavaScript:onTblTheadButtonSnowClick();" title="Полная форма изменения условий поиска"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/search-1.png" width="24px" height="24px"></a>&nbsp;
                            <a href="javascript:onTblTheadButtonClearClick();" title="Очистить все условия фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/eraser.png" width="24px" height="24px"></a>&nbsp;
                            <a href="javascript:onTblTheadButtonSearchClick();" title="Выполнить поиск по текущим условиям фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/find-1.png" width="24px" height="24px"></a>
                        </div>
                    </th>
                </tr>
    </form>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
<!------------------------------------------------------------------------->                        
    <div id="preloader">
        <img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/ajax-loader-3.gif" alt="Loading..."/>
    </div>
<!------------------------------------------------------------------------->                        
    <div id="pages_container">

    </div>
<!------------------------------------------------------------------------->                        
    <!--div id="slideout">
        <img src="<?php 
    //echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/search-1.png" width="32px" height="32px" alt="Форма поиска"></a>
        <div id="slideout_inner"-->
    <div class="slide_panel">
        <?php 
    tzs_front_end_search_tr_form('shipments');
    ?>
        <!--/div-->
    </div>
<!------------------------------------------------------------------------->                        
    <script src="/wp-content/plugins/tzs/assets/js/distance.js"></script>
    <script src="/wp-content/plugins/tzs/assets/js/table_reload.js"></script>
    <script src="/wp-content/plugins/tzs/assets/js/jquery.stickytableheaders.min.js"></script>
    
    <script>
        var SearchFormVisible = false;
        

        function onCountryFromSelected() {
            var rid = <?php 
    echo isset($_POST["region_from"]) ? $_POST["region_from"] : 0;
    ?>
;
            doAjax(jQuery('[name=country_from]').val(), rid, jQuery('[name=region_from]'));
                        
            if (jQuery('[name=cargo_cityname_from]').val().length > 2 && jQuery('[name=country_from]').val() > 0) {
                jQuery('[name=cargo_city_from_radius_check]').removeAttr('disabled');

                if (jQuery('[name=cargo_city_from_radius_check]').is(':checked')) {
                    jQuery('[name=cargo_city_from_radius_value]').removeAttr('disabled');
                } else {
                    jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
                }
            } else {
                jQuery('[name=cargo_city_from_radius_check]').prop('checked', false);
                jQuery('[name=cargo_city_from_radius_check]').attr('disabled', 'disabled');
                jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
            }
        }
        
        function onCountryToSelected() {
            var rid = <?php 
    echo isset($_POST["region_to"]) ? $_POST["region_to"] : 0;
    ?>
;
            doAjax(jQuery('[name=country_to]').val(), rid, jQuery('[name=region_to]'));
        }
		
        function onCityFromSelected() {
            if (jQuery('[name=cargo_city_from]').is(':checked')) {
                    jQuery('[name=cargo_cityname_from]').removeAttr('disabled');

                if (jQuery('[name=cargo_cityname_from]').val().length > 2 && jQuery('[name=country_from]').val() > 0) {
                    jQuery('[name=cargo_city_from_radius_check]').removeAttr('disabled');

                    if (jQuery('[name=cargo_city_from_radius_check]').is(':checked')) {
                        jQuery('[name=cargo_city_from_radius_value]').removeAttr('disabled');
                    } else {
                        jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
                    }
                } else {
                    jQuery('[name=cargo_city_from_radius_check]').prop('checked', false);
                    jQuery('[name=cargo_city_from_radius_check]').attr('disabled', 'disabled');
                    jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
                }
            } else {
                    jQuery('[name=cargo_cityname_from]').attr('disabled', 'disabled');

                    jQuery('[name=cargo_city_from_radius_check]').prop('checked', false);
                    jQuery('[name=cargo_city_from_radius_check]').attr('disabled', 'disabled');
                    jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
            }
        }
        
        function onCityToSelected() {
                if (jQuery('[name=cargo_city_to]').is(':checked')) {
                        jQuery('[name=cargo_cityname_to]').removeAttr('disabled');
                } else {
                        jQuery('[name=cargo_cityname_to]').attr('disabled', 'disabled');
                }
        }

        function onCityNameFromChanged() {
                if (jQuery('[name=cargo_cityname_from]').val().length > 2 && jQuery('[name=country_from]').val() > 0) {
                        jQuery('[name=cargo_city_from_radius_check]').removeAttr('disabled');
                } else {
                        jQuery('[name=cargo_city_from_radius_check]').prop('checked', false);
                        jQuery('[name=cargo_city_from_radius_check]').attr('disabled', 'disabled');
                        jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
                }
        }

        function onCityFromRadiusSelected() {
                if (jQuery('[name=cargo_city_from_radius_check]').is(':checked')) {
                        jQuery('[name=cargo_city_from_radius_value]').removeAttr('disabled');
                } else {
                        jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
                }
        }
        //
        function onForm1Change() {
            // chk_2
            jQuery('#chk_2').prop('checked', ((jQuery('[name=country_from]').val() > 0) || (jQuery('[name=country_to]').val() > 0) || (jQuery('[name=region_from]').val() > 0) || (jQuery('[name=region_to]').val() > 0) ||
                    (jQuery('[name=cargo_city_from]').is(':checked') && (jQuery('[name=cargo_cityname_from]').val().length > 0)) ||
                    (jQuery('[name=cargo_city_to]').is(':checked') && (jQuery('[name=cargo_cityname_to]').val().length > 0)) ||
                    (jQuery('[name=cargo_city_from_radius_check]').is(':checked') && (jQuery('[name=cargo_city_from_radius_value]').val().length > 0))));
            if (jQuery('#chk_2').is(':checked')) {
                jQuery('#chk_2').removeAttr('disabled');
            } else {
                jQuery('#chk_2').attr('disabled', 'disabled');
            }
            
            // chk_3
            jQuery('#chk_3').prop('checked', ((jQuery('[name=data_from]').val().length > 7) || (jQuery('[name=data_to]').val().length > 7)));
            if (jQuery('#chk_3').is(':checked')) {
                jQuery('#chk_3').removeAttr('disabled');
            } else {
                jQuery('#chk_3').attr('disabled', 'disabled');
            }
            
            // chk_4
            jQuery('#chk_4').prop('checked', ((jQuery('[name=sh_type]').val() > 0) || (jQuery('[name=trans_type]').val() > 0)));
            if (jQuery('#chk_4').is(':checked')) {
                jQuery('#chk_4').removeAttr('disabled');
            } else {
                jQuery('#chk_4').attr('disabled', 'disabled');
            }
            
            // chk_5
            jQuery('#chk_5').prop('checked', ((jQuery('[name=weight_from]').val() > 0) || (jQuery('[name=weight_to]').val() > 0) || (jQuery('[name=volume_from]').val() > 0) || (jQuery('[name=volume_to]').val() > 0)));
            if (jQuery('#chk_5').is(':checked')) {
                jQuery('#chk_5').removeAttr('disabled');
            } else {
                jQuery('#chk_5').attr('disabled', 'disabled');
            }
            
            // chk_7
            jQuery('#chk_7').prop('checked', ((jQuery('[name=price_from]').val().length > 0) || (jQuery('[name=price_to]').val().length > 0) || (jQuery('[name=price_km_from]').val().length > 0) || (jQuery('[name=price_km_to]').val().length > 0)));
            if (jQuery('#chk_7').is(':checked')) {
                jQuery('#chk_7').removeAttr('disabled');
            } else {
                jQuery('#chk_7').attr('disabled', 'disabled');
            }
        }
        
        function onClearFilterSelected(eventObject) {
            var fid = eventObject.target.id;
            var fname = eventObject.target.name;
            var fchk = eventObject.target.checked;
            
            if (!fchk) {
                switch (fid) {
                    case 'chk_2': {
                        jQuery('[name=country_from]').attr('value', 0);
                        jQuery('[name=country_to]').attr('value', 0);
                        jQuery('[name=region_from]').attr('value', 0);
                        jQuery('[name=region_to]').attr('value', 0);
                        jQuery('[name=cargo_city_from_radius_value]').attr('value', 0);
                        jQuery('[name=cargo_cityname_from]').attr('value', '');
                        jQuery('[name=cargo_cityname_to]').attr('value', '');
                        jQuery('[name=cargo_city_from]').prop('checked', false);
                        jQuery('[name=cargo_city_to]').prop('checked', false);
                        jQuery('[name=cargo_city_from_radius_check]').prop('checked', false);
                        jQuery('[name=cargo_cityname_from]').attr('disabled', 'disabled');
                        jQuery('[name=cargo_cityname_to]').attr('disabled', 'disabled');
                        jQuery('[name=cargo_city_from_radius_value]').attr('disabled', 'disabled');
                        jQuery('#chk_2').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_3': {
                        jQuery('[name=data_from]').attr('value', '');
                        jQuery('[name=data_to]').attr('value', '');
                        jQuery('#chk_3').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_4': {
                        jQuery('[name=sh_type]').attr('value', 0);
                        jQuery('[name=trans_type]').attr('value', 0);
                        jQuery('#chk_4').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_5': {
                        jQuery('[name=weight_from]').attr('value', 0);
                        jQuery('[name=weight_to]').attr('value', 0);
                        jQuery('[name=volume_from]').attr('value', 0);
                        jQuery('[name=volume_to]').attr('value', 0);
                        jQuery('#chk_5').attr('disabled', 'disabled');
                        break;
                    }
                    case 'chk_7': {
                        jQuery('[name=price_from]').attr('value', '');
                        jQuery('[name=price_to]').attr('value', '');
                        jQuery('[name=price_km_from]').attr('value', '');
                        jQuery('[name=price_km_to]').attr('value', '');
                        jQuery('#chk_7').attr('disabled', 'disabled');
                        break;
                    }
                }
            }
        }
        
        function onTblTheadButtonSnowClick() {
            tblTHeadShowForm('', '.tbl_thead_search_div');
            tblTHeadShowSearchForm();
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function onTblTheadButtonSearchClick() {
            tblTHeadShowForm('', '.tbl_thead_search_div');
            if (SearchFormVisible) { tblTHeadShowSearchForm(); }
            //FormToFormCopy("search_pr_form1", "search_pr_form");
            TblTbodyReload(<?php 
    echo isset($_POST['page']) ? $_POST['page'] : '1';
    ?>
);
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function onTblTheadButtonClearClick() {
            FormClear("search_pr_form");
            FormClear("search_pr_form1");
            onForm1Change();
            tblTHeadShowForm('', '.tbl_thead_search_div');
            if (SearchFormVisible) { tblTHeadShowSearchForm(); }
            TblTbodyReload(<?php 
    echo isset($_POST['page']) ? $_POST['page'] : '1';
    ?>
);
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function onTblSearchButtonClick() {
            tblTHeadShowForm('', '.tbl_thead_search_div');
            //FormToFormCopy("search_pr_form", "search_pr_form1");
            TblTbodyReload(<?php 
    echo isset($_POST['page']) ? $_POST['page'] : '1';
    ?>
);
            // Скроем форму
            tblTHeadShowSearchForm();
            // Для исключения повторного обновления страницы - return false
            //return false;
        }
        
        function tblTHeadShowSearchForm() {
            if (!SearchFormVisible) { 
                jQuery('.slide_panel').animate({'left':'0'},600); 
                //jQuery('#slideout').stop().animate({left: 385}, 1000);
                //jQuery('#slideout_inner').stop().animate({left: 0}, 1000);
            }
            else { 
                jQuery('.slide_panel').animate({'left':'-740'},500); 
                //jQuery('#slideout').stop().animate({left: 0}, 'slow');
                //jQuery('#slideout_inner').stop().animate({left: -385}, 'slow');
            }
            SearchFormVisible = ~ SearchFormVisible;
        }

    
        function thRecordsPerPagePrint(records_per_page) {
            var vTZS_RECORDS_PER_PAGE = <?php 
    echo TZS_RECORDS_PER_PAGE;
    ?>
;
            var vRecordsArray = [<?php 
    echo TZS_RECORDS_PER_PAGE_ARRAY;
    ?>
];
            var vRecordsStr = 'Количество записей на странице:<br>';
            
            if (!records_per_page || (records_per_page < 1)) { records_per_page = vTZS_RECORDS_PER_PAGE; }
            
            for(i=0;i<vRecordsArray.length;i++) {
                if (vRecordsArray[i] != records_per_page) {
                    vRecordsStr += '<a href="javascript:onRecordsPerPageSelected(' + vRecordsArray[i] + ')">' + vRecordsArray[i] + '</a>&nbsp;&nbsp;';
                }
            }
            
            jQuery("#tbl_thead_records_per_page_th").html(vRecordsStr);
        }
  
        function onRecordsPerPageSelected(records_per_page) {
            addHidden("#search_pr_form1", 'records_per_page', records_per_page);
            TblTbodyReload(1);
            thRecordsPerPagePrint(records_per_page);
        }
      
        // Функция, отрабатывающая после готовности HTML-документа
        jQuery(document).ready(function(){
                <?php 
    if (get_current_user_id() == 0) {
        ?>
                    jQuery('#menu-profile').hide();
                <?php 
    }
    ?>
                    
                // Установим обработчик "клика" в строках таблицы
                jQuery('#tbl_products').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 && (id != null)) {
                                document.location = "/account/view-shipment/?id="+id;
                        }
                });

                jQuery("#show-search-form").click(function () { onTblTheadButtonSnowClick(); });

                // Создадми скрытые поля для формы
                var theForm = "#search_pr_form1";
                addHidden(theForm, 'form_type', 'shipments');
                addHidden(theForm, 'records_per_page', '<?php 
    echo isset($_POST['records_per_page']) ? $_POST['records_per_page'] : TZS_RECORDS_PER_PAGE;
    ?>
');
                
                // Установим размеры для выезжающей панели с формой
                jQuery(".slide_panel").css({
                    'bottom': '0px',
                    'width': '700px',
                    'left': '-740px'
                });
                
                //jQuery('#thead_h1').html('<div class="div_td_left"><h1 class="entry-title">'+jQuery('h1.entry-title').html()+'</h1></div>');
                jQuery('header.entry-header').hide();
                jQuery("#tbl_products").stickyTableHeaders();
                
                /*jQuery("#slideout, #slideout_inner").css({
                    'top': '110px'
                });*/

                // Устанавливаем обработчики событий 
                setFormFielsdChangeHandler('search_pr_form');
                jQuery('#chk_2, #chk_3, #chk_4, #chk_5, #chk_6, #chk_7').change(function(eventObject) { onClearFilterSelected(eventObject); });
                
                /*jQuery('#slideout').hover(
                    function() {
                        //jQuery('#slideout').stop().animate({left: 385}, 1000);
                        //jQuery('#slideout_inner').stop().animate({left: 0}, 1000);
                        if (!SearchFormVisible) { tblTHeadShowSearchForm(); }
                    }, 
                    function() {
                        //jQuery('#slideout').stop().animate({left: 0}, 'slow');
                        //jQuery('#slideout_inner').stop().animate({left: -385}, 'slow');
                    }
                );*/
                
                /*jQuery('[name=records_per_page]').change(function(eventObject) {
                    addHidden(theForm, 'records_per_page', eventObject.target.value);
                    TblTbodyReload(1); 
                });*/
                onForm1Change();
                onCountryFromSelected();
		onCountryToSelected();
                //onCityFromSelected();
                //onCityNameFromChanged();
                //onCityToSelected();
                //onCityFromRadiusSelected();
                //
                jQuery.datepicker.setDefaults(jQuery.datepicker.regional['ru']);
                jQuery("[name=data_from]").datepicker({ dateFormat: "dd.mm.yy" });
                jQuery("[name=data_to]").datepicker({ dateFormat: "dd.mm.yy" });


                // Скроем форму
                if (SearchFormVisible) { tblTHeadShowSearchForm(); }
                
                // Обновим тело таблицы
                TblTbodyReload(1);
                thRecordsPerPagePrint(<?php 
    echo isset($_POST['records_per_page']) ? $_POST['records_per_page'] : TZS_RECORDS_PER_PAGE;
    ?>
);
        });
    </script>
    
	
	<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
示例#7
0
function tzs_front_end_search_pr_form()
{
    tzs_copy_get_to_post();
    $product_auction = get_param_def('product_auction', 'products');
    $pa_root_id = $product_auction === 'auctions' ? '' . TZS_AU_ROOT_CATEGORY_PAGE_ID : '' . TZS_PR_ROOT_CATEGORY_PAGE_ID;
    $p_id = get_the_ID();
    ?>
    <form class="search_pr_form" id="search_pr_form1" name="search_pr_form" method="POST">
        <table name="search_param" border="0">
            <tr>
                <th colspan="2">Укажите критерии поиска товаров и услуг</th>
            </tr>
            <tr>
                <td>Категория:<br>
                    <!--select name="type_id" <?php 
    //echo (isset($_POST['cur_type_id']) && ($_POST['cur_type_id'] === $pa_root_id)) ? '' : ' disabled="disabled"';
    ?>
 -->
                    <!--select name="type_id" <?php 
    //echo (isset($_POST['rootcategory']) && ($_POST['rootcategory'] === '1')) ? '' : ' disabled="disabled"';
    ?>
 -->
                    <select name="type_id" <?php 
    echo $p_id == $pa_root_id ? '' : ' disabled="disabled"';
    ?>
 >
                        <option value="0">все категории</option>
			<option disabled>- - - - - - - -</option>
                        <?php 
    tzs_build_product_types('type_id', $pa_root_id);
    ?>
                    </select>
                    <?php 
    wp_nonce_field('type_id', 'type_id_nonce');
    ?>
                </td>
                <td>Местонахождение: страна:<br>
                    <select name="country_from">
                        <?php 
    tzs_build_countries('country_from');
    ?>
                    </select>
                </td>
            <tr>
                <td>Тип заявки:<br>
                    <select name="sale_or_purchase">
                        <option value="0" <?php 
    if (isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Все</option>
                        <option value="1" <?php 
    if (isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Продажа</option>
                        <option value="2" <?php 
    if (isset($_POST['sale_or_purchase']) && $_POST['sale_or_purchase'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Покупка</option>
                    </select>
                </td>
                <td>Местонахождение: регион:<br>
                    <select name="region_from">
                        <option value="0">все области</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Участник тендера:<br>
                    <select name="fixed_or_tender">
                        <option value="0" <?php 
    if (isset($_POST['fixed_or_tender']) && $_POST['fixed_or_tender'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Все предложения</option>
                        <option value="1" <?php 
    if (isset($_POST['fixed_or_tender']) && $_POST['fixed_or_tender'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Цена зафиксирована</option>
                        <option value="2" <?php 
    if (isset($_POST['fixed_or_tender']) && $_POST['fixed_or_tender'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Тендерное предложение</option>
                    </select>
                </td>
                <td>Местонахождение: город:<br>
                    <input type="text" name="cityname_from" value="<?php 
    echo_val('cityname_from');
    ?>
" size="30">
                </td>
            </tr>
            <tr>
                <td>Форма оплаты:<br>
                    <select name="payment">
                        <option value="0" <?php 
    if (isset($_POST['payment']) && $_POST['payment'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Любая</option>
                        <option value="1" <?php 
    if (isset($_POST['payment']) && $_POST['payment'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Наличная</option>
                        <option value="2" <?php 
    if (isset($_POST['payment']) && $_POST['payment'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Безналичная</option>
                    </select>
                </td>
                <td>НДС:<br>
                    <select name="nds">
                        <option value="0" <?php 
    if (isset($_POST['nds']) && $_POST['nds'] == 0) {
        echo 'selected="selected"';
    }
    ?>
 >Все</option>
                        <option value="1" <?php 
    if (isset($_POST['nds']) && $_POST['nds'] == 1) {
        echo 'selected="selected"';
    }
    ?>
 >Без НДС</option>
                        <option value="2" <?php 
    if (isset($_POST['nds']) && $_POST['nds'] == 2) {
        echo 'selected="selected"';
    }
    ?>
 >Включая НДС</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Стоимость: от:<br>
                    <input type="text" name="price_from" value="<?php 
    echo_val('price_from');
    ?>
" size="10">
                </td>
                <td>Стоимость: до:<br>
                    <input type="text" name="price_to" value="<?php 
    echo_val('price_to');
    ?>
" size="10">
                </td>
            </tr>
            <tr>
                <td>Дата размещения: от:<br>
                    <input type="text" name="data_from" value="<?php 
    echo_val('data_from');
    ?>
" size="10">
                </td>
                <td>Дата размещения: до:<br>
                    <input type="text" name="data_to" value="<?php 
    echo_val('data_to');
    ?>
" size="10">
                </td>
            </tr>
            <tr>
                <td>Описание:<br>
                    <input type="text" name="pr_title" value="<?php 
    echo_val('pr_title');
    ?>
" size="30">
                </td>
                <td>
                    <div style="text-align:right; vertical-aligment: middle;">
                        <a href="JavaScript:tblTHeadShowSearchForm();" title="Скрыть форму изменения условий поиска"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/form_hide.png" width="110px" height="24px"></a>&nbsp;&nbsp;
                        <a href="javascript:onTblTheadButtonClearClick();" title="Очистить все условия фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/eraser.png" width="24px" height="24px"></a>&nbsp;&nbsp;
                        <a href="javascript:onTblSearchButtonClick();" title="Выполнить поиск по текущим условиям фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/find-1.png" width="24px" height="24px"></a>
                    </div>
                </td>
            </tr>
        </table>
    </form>
    <?php 
}
示例#8
0
function tzs_front_end_search_tr_form($form_type)
{
    tzs_copy_get_to_post();
    ?>
    <form class="search_pr_form" id="search_pr_form1" name="search_pr_form" method="POST">
        <table name="search_param" border="0">
            <tr>
                <th colspan="4">Укажите критерии поиска <?php 
    echo $form_type === 'transport' ? 'транспорта' : 'грузов';
    ?>
</th>
            </tr>
            <tr>
                <th class="td_border_right_dotted">
                    <div style="color: #F5C034; font-weight: bold;">
                        ПОГРУЗКА
                    </div>
                </th>
                <th class="td_border_right_dotted">
                    <div style="color: #F5C034; font-weight: bold;">
                        ВЫГРУЗКА
                    </div>
                </th>
                <th>&nbsp;</th>
                <th>&nbsp;</th>
            </tr>
            <tr>
                <td class="td_border_right_dotted">Страна:<br>
                    <select name="country_from">
                        <?php 
    tzs_build_countries('country_from');
    ?>
                    </select>
                    <?php 
    wp_nonce_field('country_from">', 'type_country_from">');
    ?>
                </td>
                <td class="td_border_right_dotted">Страна:<br>
                    <select name="country_to">
                        <?php 
    tzs_build_countries('country_to');
    ?>
                    </select>
                </td>
                
                <td>Масса: от:<br>
                    <!--select name="weight_from">
                            <?php 
    //tzs_print_weight('weight_from');
    ?>
                    </select-->
                    <input type="text" name="weight_from" value="<?php 
    echo_val('weight_from');
    ?>
" size="10">
                </td>
                <td>Масса: до:<br>
                    <!--select name="weight_to">
                            <?php 
    //tzs_print_weight('weight_to');
    ?>
                    </select-->
                    <input type="text" name="weight_to" value="<?php 
    echo_val('weight_to');
    ?>
" size="10">
                </td>
            <tr>
                <td class="td_border_right_dotted">Регион:<br>
                    <select name="region_from">
                                <option>все области</option>
                    </select>
                </td>
                <td class="td_border_right_dotted">Регион:<br>
                    <select name="region_to">
                                <option>все области</option>
                    </select>
                </td>
                
                <td>Объем: от:<br>
                    <!--select name="volume_from">
                            <?php 
    //tzs_print_volume('volume_from');
    ?>
                    </select-->
                    <input type="text" name="volume_from" value="<?php 
    echo_val('volume_from');
    ?>
" size="10">
                </td>
                <td>Объем: до:<br>
                    <!--select name="volume_to">
                            <?php 
    //tzs_print_volume('volume_to');
    ?>
                    </select-->
                    <input type="text" name="volume_to" value="<?php 
    echo_val('volume_to');
    ?>
" size="10">
                </td>
            </tr>
            <tr>
                <td class="td_border_right_dotted">Населенный пункт:&nbsp;<input type="checkbox" name="cargo_city_from" value="" <?php 
    if (isset($_POST['cargo_city_from'])) {
        echo 'checked="checked"';
    }
    ?>
/><br>
                    <input type="text" name="cargo_cityname_from" value="<?php 
    echo_val('cityname_from');
    ?>
" size="10">
                </td>
                <td class="td_border_right_dotted">Населенный пункт:&nbsp;<input type="checkbox" name="cargo_city_to" value="" <?php 
    if (isset($_POST['cargo_city_to'])) {
        echo 'checked="checked"';
    }
    ?>
/><br>
                    <input type="text" name="cargo_cityname_to" value="<?php 
    echo_val('cargo_cityname_to');
    ?>
" size="10">
                </td>
                <td>Cтоимость: от:<br>
                    <input type="text" name="price_from" value="<?php 
    echo_val('price_from');
    ?>
" size="10"><br>
                </td>
                <td>Cтоимость: до:<br>
                    <input type="text" name="price_to" value="<?php 
    echo_val('price_to');
    ?>
" size="10"><br>
                </td>
            </tr>
            <tr>
                <td class="td_border_right_dotted">Пункт загрузки в радиусе<sup>*</sup>:&nbsp;<input type="checkbox" name="cargo_city_from_radius_check" value="" <?php 
    if (isset($_POST['cargo_city_from_radius_check'])) {
        echo 'checked="checked"';
    }
    ?>
/><br>
                    <select name="cargo_city_from_radius_value">
                        <?php 
    foreach ($GLOBALS['tzs_city_from_radius_value'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if (isset($_POST['cargo_city_from_radius_value']) && $_POST['cargo_city_from_radius_value'] == $key || !isset($_POST['cargo_city_from_radius_value']) && $key == 0) {
            echo 'selected="selected"';
        }
        echo '>' . htmlspecialchars($val) . '</option>';
    }
    ?>
                    </select>
                </td>
                <td class="td_border_right_dotted">&nbsp;</td>
                
                <td>Цена 1 км: от:<br>
                    <input type="text" name="price_km_from" value="<?php 
    echo_val('price_from');
    ?>
" size="10"><br>
                </td>
                <td>Цена 1 км: до:<br>
                    <input type="text" name="price_km_to" value="<?php 
    echo_val('price_to');
    ?>
" size="10"><br>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="td_border_right_dotted td_border_top_dotted">
                    <div style="color: #F5C034; font-style: italic; font-weight: bold;">
                        <sup>*</sup>Для выбора радиуса укажите страну и город пункта погрузки.
                    </div>
                </td>
                
                <td>Тип транспорта:<br>
                    <select name="trans_type">
                        <?php 
    foreach ($GLOBALS['tzs_tr_types_search'] as $key => $val) {
        echo '<option value="' . $key . '" ';
        if (isset($_POST['trans_type']) && $_POST['trans_type'] == $key || !isset($_POST['trans_type']) && $key == 0) {
            echo 'selected="selected"';
        }
        echo '>' . htmlspecialchars($val) . '</option>';
    }
    ?>
                    </select>
                </td>
                <td>
                    <?php 
    if ($form_type === 'shipments') {
        ?>
                    Тип груза:<br>
                    <select name="sh_type">
                        <?php 
        foreach ($GLOBALS['tzs_sh_types_search'] as $key => $val) {
            echo '<option value="' . $key . '" ';
            if (isset($_POST['sh_type']) && $_POST['sh_type'] == $key || !isset($_POST['sh_type']) && $key == 0) {
                echo 'selected="selected"';
            }
            echo '>' . htmlspecialchars($val) . '</option>';
        }
        ?>
                    </select>
                    <?php 
    } else {
        ?>
                    Желаемый груз:<br>
                    <input type="text" name="sh_descr" value="<?php 
        echo_val('sh_descr');
        ?>
" size="30">
                    <?php 
    }
    ?>
                </td>
            </tr>
            <tr>
                <td class="td_border_right_dotted td_border_top_dotted">Дата:<br>
                    <input type="text" name="data_from" value="<?php 
    echo_val('data_from');
    ?>
" size="10">
                </td>
                <td class="td_border_right_dotted td_border_top_dotted">Дата:<br>
                    <input type="text" name="data_to" value="<?php 
    echo_val('data_to');
    ?>
" size="10">
                </td>
                
                <td colspan="2" class="td_border_top_dotted">
                    <div style="text-align:right; vertical-aligment: middle;">
                        <a href="JavaScript:tblTHeadShowSearchForm();" title="Скрыть форму изменения условий поиска"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/form_hide.png" width="150px" height="26px"></a>&nbsp;&nbsp;
                        <a href="javascript:onTblTheadButtonClearClick();" title="Очистить все условия фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/eraser.png" width="24px" height="24px"></a>&nbsp;&nbsp;
						<a href="javascript:onTblSearchButtonClick();" title="Выполнить поиск по текущим условиям фильтра"><img src="<?php 
    echo get_site_url();
    ?>
/wp-content/plugins/tzs/assets/images/find-1.png" width="24px" height="24px"></a>
                    </div>
                </td>
            </tr>
        </table>
    </form>
    <?php 
}
示例#9
0
function tzs_print_edit_image_form($errors)
{
    $php_max_file_uploads = (int) ini_get('max_file_uploads');
    if ($php_max_file_uploads > TZS_PR_MAX_IMAGES) {
        $php_max_file_uploads = TZS_PR_MAX_IMAGES;
    }
    if (isset($_POST['image_id_lists']) && $_POST['image_id_lists'] !== '') {
        $img_names = explode(';', $_POST['image_id_lists']);
    } else {
        $img_names = array();
    }
    $form_type = get_param('form_type');
    $form_type_info = array('product' => array('product', TZS_PRODUCTS_TABLE, 'Товар/услуга', 'товаре/услуге', 'товар/услугу', 'товара/услуги'), 'auction' => array('auction', TZS_AUCTIONS_TABLE, 'Тендер', 'тендере', 'тендер', 'тендера'));
    echo '<div style="clear: both;"></div>';
    print_errors($errors);
    ?>
    <div style="clear: both;"></div>
    <div id="images_edit" style="width: 100%;">
    
    <form enctype="multipart/form-data" method="post" id="fpost" class="pr_edit_form post-form" action="">
        <div id="">
            <!--h3>Изменение прикрепленных изображений</h3>
            <hr/-->
            <p>Наименование <?php 
    echo $_POST['form_type'] == 'product' ? 'товара/услуги' : 'тендера';
    ?>
: <strong>"<?php 
    echo $_POST['title'];
    ?>
"</strong> (Id=<?php 
    echo $_POST['id'];
    ?>
)</p>
            <p>Допустимое кол-во изображений: <strong><?php 
    echo $php_max_file_uploads;
    ?>
</strong></p>
            <p>Допустимый размер одного изображения: <strong>2 Мб</strong></p>
        </div>
        <div id="">
            <table id="tbl_products" border='0'>
                <tr>
                    <th id="wight">Номер изображения</th>
                    <th>Прикрепленное изображение</th>
                    <th id="wight">Удалить изображение</th>
                    <th>Новое изображение</th>
                    <th>Главное изображение</th>
                </tr>
                <?php 
    for ($i = 0; $i < $php_max_file_uploads; $i++) {
        ?>
                    <tr>
                        <td><?php 
        echo $i + 1;
        ?>
</td>
                    <?php 
        if (count($img_names) > 0 && $img_names[$i] !== null && $img_names[$i] !== '') {
            $main_image_disabled = '';
            $img_info = wp_get_attachment_image_src($img_names[$i], 'thumbnail');
            ?>
                        <td><img src="<?php 
            echo $img_info[0];
            ?>
" name="image_<?php 
            echo $i;
            ?>
" alt="Изображение №<?php 
            echo $i + 1;
            ?>
"></td>
                        <td><input type="checkbox" id="" name="del_image_<?php 
            echo $i;
            ?>
" <?php 
            if (isset($_POST["del_image_{$i}"])) {
                echo 'checked="checked"';
            }
            ?>
></td>
                        <td><input type="file" id="chg_image" name="chg_image_<?php 
            echo $i;
            ?>
" multiple="false" accept="image/*"></td>
                    <?php 
        } else {
            $main_image_disabled = 'disabled="disabled"';
            ?>
                        <td><input type="file" id="add_image" name="add_image_<?php 
            echo $i;
            ?>
" multiple="false" accept="image/*"></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    <?php 
        }
        ?>
                        <td>
                            <input type="radio" <?php 
        echo $main_image_disabled;
        ?>
 tag="main_image_'.$i.'" id="main_image" name="main_image" value="<?php 
        echo $i;
        ?>
" <?php 
        if (isset($_POST['main_image']) && $_POST['main_image'] == "{$i}") {
            echo 'checked="checked"';
        }
        ?>
>
                            <?php 
        if ($i === 0) {
            wp_nonce_field('image_0', 'image_0_nonce');
        }
        ?>
                        </td>
                    </tr>
                <?php 
    }
    ?>
            </table>
        </div>
            <input type="hidden" name="action" value="editimages"/>
            <input type="hidden" name="id" value="<?php 
    echo_val('id');
    ?>
"/>
            <input type="hidden" name="image_id_lists" value="<?php 
    echo_val('image_id_lists');
    ?>
"/>
            <?php 
    if (isset($_POST['main_image'])) {
        ?>
                <input type="hidden" name="old_main_image" value="<?php 
        echo_val('main_image');
        ?>
"/>
            <?php 
    }
    ?>
            <input type="hidden" name="formName" value="<?php 
    echo_val('form_type');
    ?>
images" />
        <table>
            <tr>
                <td width="130px">&nbsp;</td>
                <td>
                    <input name="addpost" type="submit" id="addpostsub" class="submit_button" value="Загрузить/обновить изображения"/>
                </td>
                <td width="15px">&nbsp;</td>
                <td>
                    <a href="/view-<?php 
    echo $form_type_info[$form_type][0];
    ?>
/?id=<?php 
    echo_val('id');
    ?>
&spis=new" id="edit_images">Просмотреть <?php 
    echo $form_type_info[$form_type][4];
    ?>
</a>
                </td>
            </tr>
        </table>
    </form>
    </div>
    
	
    <script>
        function onMainImageRadioStatus(e) {
            fname = e.target.name;
            fname_ar = fname.split('_');
            i = fname_ar[2];
            s3 = 'input:radio[name=main_image]:nth(' + i + ')';
            if (e.target.files.length > 0) {
                jQuery(s3).removeAttr('disabled');
            } else {
                jQuery(s3).attr('disabled', 'disabled');
            }
        }

        jQuery(document).ready(function(){
            jQuery('input[type=file]').change(function(e) {
                onMainImageRadioStatus(e);
            });
            
            jQuery('#fpost').submit(function() {
                jQuery('#addpostsub').attr('disabled','disabled');
                jQuery('#images_edit').after('<div id="fpost_status"><h4>Идет загрузка файлов, подождите...</h4></div>');
                return true;
            });
        });
    </script>
    <?php 
}