<style>
    .productbarcodeinput{

    }
    .productsizeinput{
        width: 75px;
    }
    .pkinput{
        width: 100px;
    }
    .refinput{
        width: 75px;
    }
    .madeininput{
        width: 150px;
    }
    .productnuminput{
        width: 50px;
    }
</style>

<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">المنتجات</a></li>
            <li><a href="productController.php?do=show">عرض المنتجات</a></li>
            <li class="active">طباعه باركود مفصل</li>
        </ol>


        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">طباعه باركود مفصل</h3>

                <a href="{$youtubes[81]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>

            </div>
            <div class="panel-body">

                <div id="productdiv" style="display:none">
                    {foreach $allproduct as $myallproduct}
                    <option value="{$myallproduct->productId}">{$myallproduct->productName}</option>
                    {/foreach}
                </div>
                {literal}
                <form class="nameToBeChecked form-horizontal" role="form" action="printparcodedetailed.php" method="post" id="printParcodeDetailedForm">

                    {/literal}

                    <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>

                    <input name="itr" id="itr" type="hidden" value="1">
                    <input name="storeid" id="storeid" type="hidden" value="{$storeid}">

                    <div class="table-responsive">
                        <table class="table table-black" id="producttabeldetailed" width="100%">
                            <tr>
                                <td colspan="1">   <!--button type="button"  class="btn" onClick="addproductdetailed();">اضافه منتج</button></td-->
                                <td colspan="5"> <p>
                                        <!--<input name="name" type="text" id="name" value="{$companyname}" />-->
                                        <input name="size" type="text" id="size" value="14" placeholder="حجم الخط"/>
                                        <input name="currency" type="text" id="currency" value="L.E" placeholder="العملة"/>
                                    </p>
                                    <p>
                                        <input name="productsize" type="text" id="productsize" value="" placeholder="product size" onchange="localStorage.setItem('detailedproductsize', $(this).val())"/>
                                        <input name="pk" type="text" id="pk" value="" placeholder="pk" onchange="localStorage.setItem('detailedparcodepk', $(this).val())"/>
                                        <input name="ref" type="text" id="ref" value="" placeholder="ref" onchange="localStorage.setItem('detailedparcoderef', $(this).val())"/>
                                        <input name="madein" type="text" id="madein" value="" placeholder="made in" onchange="localStorage.setItem('detailedparcodemadein', $(this).val())"/>
                                    </p>
                                    <p>
                                        <label class='color-black'>
                                            <input value="0" class="noradioR parcodeTypeToPrint" name="parcodeTypeToPrint" id="parcodeTypeToPrint0" type="radio" onchange="localStorage.setItem('parcodeTypeToPrint', $(this).val())"/>
                                            استخدام الباركود </label>
                                        <label class='color-black'>
                                            <input value="1" class="noradioR parcodeTypeToPrint" name="parcodeTypeToPrint" id="parcodeTypeToPrint1" type="radio" onchange="localStorage.setItem('parcodeTypeToPrint', $(this).val())"/>
                                            استخدام الباركود المتخصص </label>
                                    </p>
                                    <!--p>طباعه السعر التجزئة
                                      <input name="pricOption" type="checkbox" value="1" />
                                      <br>
                                      طباعه السعر الجمله <input name="pricOption1" type="checkbox" value="1" />
                                  </p--></td>
                            </tr>
                            <tr>
                                <th>المنتج</th>
                                <th>الباركود</th>
                                <th>size</th>
                                <th>pk</th>
                                <th>ref</th>
                                <th>Made in</th>
                                <th>مرات الطباعه</th>
                                <th>حذف</th>

                            </tr>
                            <tr>
                                <td style="width:150 px !important; ">
                                    <div class="form-group">
                                        <!--<label class="col-lg-2 control-label">اختر المنتج</label>-->
                                        <div class="col-lg-6"  ><!--style="width:300px"-->
                                            <!--select  class="select2 wdt100" style="width:300px"  name="productId1" onChange="getbarcode(this.value,1)">
                                            <option value="-1"></option>
                                             {foreach $allproduct as $myallproduct}
                                             <option value="{$myallproduct->productId}">{$myallproduct->productName}</option>
                                             {/foreach}

                                           </select-->
                                            <div id="myproductselect">
                                                <input type="hidden" class="select2product wdt300"   name="product1" id="product1" data-placeholder="اختر منتج"  />
                                            </div>
                                        </div>
                                    </div>


                                </td>
                            <div id="divname1" style="display:none">
                                <input name="productname1"id="productname1" type="text">
                                <input name="price1"  id="price1" type="text">
                                <input name="pricen1"  id="pricen1" type="text">
                                <input name="pricenen1"  id="pricenen1" type="text">
                                <input name="catname1"  id="catname1" type="text">
                            </div>
                            <td><input name="productbarcode1"  id="productbarcode1" type="text" class="productbarcodeinput" onkeypress="getproductbyParcode(event, this.value, 1);">
                                <div id="updatebarcod1">
                                </div>
                            </td>
                            <td><input name="productsize1"  value=""  type="text" class="productsizeinput"></td>
                            <td><input name="pk1"  value=""  type="text" class="pkinput"></td>
                            <td><input name="ref1"  value=""  type="text" class="refinput"></td>
                            <td><input name="madein1"  value=""  type="text" class="madeininput"></td>
                            <td><input name="productnum1"  value="1"  type="text" class="productnuminput"></td>

                            <td><a onClick="javascript:removebarcodProduct(1)" type="button" class="btn btn-default btn-lg removeicon"></a></td>

                            </tr>


                        </table>
                        <table width="100%" class="table-black">
                            <tr> <td colspan="4">   <button type="button"  class="btn" onClick="addproductdetailed();">اضافه منتج</button></td></tr>
                            <tr>
                                <td colspan="2" width="30%">&nbsp;  </td>
                                <td colspan="2">


                                    <p>
                                        <input name="cat" type="checkbox" id="cat" value="1" onchange="localStorage.setItem('cat', $(this).is(':checked'))"/>
                                        <label for="">طباعة التصنيف</label>
                                    </p>
                                    <p>
                                        <input name="pricOption" type="radio" id="pricOption0" value="0" onchange="localStorage.setItem('pricOption', this.value)"/>
                                        <label for="">طباعه بدون سعر</label>
                                        <br />
                                    <p>
                                        <input name="pricOption" type="radio" id="pricOption1" value="1" onchange="localStorage.setItem('pricOption', this.value)"/>
                                        <label for="speparcode"> طباعه السعر الجمله</label>
                                        <br />
                                    <p>
                                        <input name="pricOption" type="radio" id="pricOption2" value="2" onchange="localStorage.setItem('pricOption', this.value)"/>
                                        <label for="speparcode"> طباعه السعر نصف الجملة </label>
                                        <br />
                                    <p>
                                        <input name="pricOption" type="radio" id="pricOption3" value="3" onchange="localStorage.setItem('pricOption', this.value)"/>
                                        <label for="">طباعه السعر التجزئة</label>
                                    </p>
                                </td>
                            </tr>
                        </table>


                    </div>

                    <!-- =================================================   -->






                    <div class="modal fade" id="myModa_barcode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close pull-left" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <h4 class="modal-title">تعديل الباركود</h4>
                                </div>
                                <div class="modal-body">


                                    <div class="input-group">
                                        <input type="text" class="form-control" id="newbarcod">

                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">اغلاق</button>
                                    <button type="button" class="btn btn-primary savemodel_barcode">حفظ البيانات</button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                    </div>


                    <!-- =================================================   -->

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">

                            <button type="submit"  class="btn btn-primary pull-left">طباعه </button>

                        </div>
                    </div>


                </form>
            </div>
        </div>




    </div>
</div>



{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");


    $('#productsize').val(localStorage.getItem("detailedproductsize"));
    $('#pk').val(localStorage.getItem("detailedparcodepk"));
    $('#ref').val(localStorage.getItem("detailedparcoderef"));
    $('#madein').val(localStorage.getItem("detailedparcodemadein"));

    $('[name=productsize1]').val(localStorage.getItem("detailedproductsize"));
    $('[name=pk1]').val(localStorage.getItem("detailedparcodepk"));
    $('[name=ref1]').val(localStorage.getItem("detailedparcoderef"));
    $('[name=madein1]').val(localStorage.getItem("detailedparcodemadein"));

    $('.parcodeTypeToPrint').removeAttr('checked');
    if (localStorage.getItem("parcodeTypeToPrint") == 1) {
        $('#parcodeTypeToPrint1').attr('checked', 'checked');
    } else {
        $('#parcodeTypeToPrint0').attr('checked', 'checked');
    }
    //
    if (localStorage.getItem("showComp") == "true") {
        $('#showComp').attr('checked', 'checked');
    } else {
        $('#showComp').removeAttr('checked', 'checked');
    }
    if (localStorage.getItem("cat") == "true") {
        $('#cat').attr('checked', 'checked');
    } else {
        $('#cat').removeAttr('checked', 'checked');
    }
    if (localStorage.getItem("speparcode") == "true") {
        $('#speparcode').attr('checked', 'checked');
    } else {
        $('#speparcode').removeAttr('checked', 'checked');
    }
    if (localStorage.getItem("double") == "true") {
        $('#double').attr('checked', 'checked');
    } else {
        $('#double').removeAttr('checked', 'checked');
    }

    //
    for (var i = 0; i < 4; i++) {
        if (localStorage.getItem("pricOption") == i.toString()) {
            $('#pricOption' + i).attr('checked', 'checked');
        } else {
            $('#pricOption' + i).removeAttr('checked', 'checked');
        }
    }


    $('#productsize').live('keyup', function () {
        $('.productsizeinput').val($(this).val());
    });
    $('#pk').live('keyup', function () {
        $('.pkinput').val($(this).val());
    });
    $('#ref').live('keyup', function () {
        $('.refinput').val($(this).val());
    });
    $('#madein').live('keyup', function () {
        $('.madeininput').val($(this).val());
    });

    $(function () {
        $("#product1").select2({
            placeholder: "إسم المنتج",
            minimumInputLength: document.getElementById("searchvalue").value,
            //minimumInputLength: 3,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "sellbillAjaxController.php?do=getProducts",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10, // page size
                        storeid: $("#storeid").val(),
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: formatResultFatma,
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });


        $("#product1").change(function () {


            var theselectedvalue = $(this).val();
            getbarcode(theselectedvalue, 1);

        });
    });
    function getproductbyParcode(e, value, itr)
    {
        //\s means "one space", and \s+ means "one or more spaces".
        value = value.replace(/\s+/g, '');//\s is the regex for "whitespace", and g is the "global" flag, meaning match ALL \s (whitespaces).
        var code = (e.keyCode ? e.keyCode : e.which);
        //to stop the submit of the form
        if (e.which == 13 && value != "")
        {
            e.preventDefault();
            e.stopPropagation();
            var billnameid = 3;
            value = value.replace("ه", "i");//this replacement is for parcode reader
            value = value.replace("÷", "i");//this replacement is for parcode reader
            value = value.replace("/", "i");//this replacement is for parcode reader
            value = value.replace("I", "i");//this replacement is for parcode reader
            //alert(value.charAt(0));
            $.ajax({
                url: 'sellbillAjaxController.php?do=getproductNamebyOnlyParcode&parcode=' + value + '&billnameid=' + billnameid + '',
                success: function (data) {
                    var response = $.parseJSON(data);
                    getbarcode(response.id, itr);
                    $("#product" + itr).select2('data', {id: response.id, text: response.text});
                }
            });
            // }
        }
    }
</script>
{/literal}
