Example #1
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 
}
Example #2
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 
}
Example #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;
}
Example #4
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 
}