<style>
    @media print {
        .table-black {
            border: 1px solid black;
        }

        td,
        th {
            border: 1px solid #000 !important;
        }
    }
</style>

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

        <ol class="breadcrumb">
            <li><a href="#">المخازن</a></li>
            <li><a href="storemovementController.php?do=show">التحويل بين المخازن</a></li>
            <li class="active">عرض تحويل</li>
        </ol>




        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading" style="padding:5px 15px 15px">
                <h3 class="panel-title" style="display: inline-block;"> عرض التحويل بين اكثر من مخزن</h3>
                <a href="{$youtubes[105]->url}" target="_blank" class="hidden-print"><img
                        src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube"
                        style="width: 2%;"></a>
                <a href="storemovementController.php" class="hidden-print"><input type="button"
                        style="margin-left: 12px" id="submit" class="btn btn-primary pull-left "
                        value="إضافة جديد" /></a>
            </div>
            <div class="panel-body">


                <div id="outputString" class="alert alert-block alert-success fade in" style="display:none">
                    <button type="button" class="close pull-left" data-dismiss="alert"
                        aria-hidden="true">&times;</button>

                    <p id="outputStringValue">{$outputString}</p>

                    <div class="clearfix"></div>
                </div>




                <form class="form-inline hidden-print" action="storemovementController.php?do=show" method="post">

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

                    {if $Programsettingdata->storeserial eq 1}
                    <div class="form-group ">
                        <label class="sr-only">رقم الايصال</label>

                        <div><span id="spryselect1">
                                <div id="operationnumDiv">
                                    <input type="hidden" name="operationnum" id="operationnum" class="select2Num wdt300" />
                                    <input type="hidden" id="oldoperationnum" />
                                </div>
                                <span class="selectInvalidMsg">*</span>
                            </span>

                        </div>

                        <!-- <select class="select2 wdt100" name="operationnum" id="operationnum">
                            <option value="-1">اختر رقم الايصال</option>


                            {foreach $alloperationnum as $myalloperationnum}


                            <option value="{$myalloperationnum->operationnum}">{$myalloperationnum->operationnum}
                            </option>


                            {/foreach}


                        </select> -->
                    </div>
                    {/if}
                    <br />

                    {if $searchinonestore neq 0}
                    <div class="form-group">
                        <label class="sr-only">المخزن</label>
                        <input type="hidden" name="storeId" id="storeId" value="{$manyParcodesstoreidfrom}">
                        {$store->storeName}

                    </div>
                    {else}
                    <div class="form-group">
                        <label class="sr-only">المخزن</label>
                        <select class="select2 wdt300" name="storeId" id="storeId">
                            <option value="-1">اختر مخزن</option>
                            {foreach $storeData as $store}
                            <option value="{$store->storeId}">{$store->storeName}</option>
                            {/foreach}
                        </select>
                    </div>
                    {/if}


                    <br>

                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>

                        <input type="text" class="form-control awdatepicker" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="from">

                    </div>


                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>

                        <input type="text" class="form-control awdatepicker" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="to">

                    </div>




                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>



            </div>
            <hr />

            <!-- Table -->
            {literal}
            <form method="post" action="storemovementController.php?do=executeOperation" onsubmit="if (Spry.Widget.Form.validate(this)) {
                        return countChoosenProducts('storemovementController');
                    } else {
                        return false;
                    }">

                {/literal}

                <div class="panel panel-default">
                    <!-- Default panel contents -->
                    <div class="panel-heading">{$message}</div>
                    <div class="panel-body">

                        <table class="table table-black dataTableClass" border="1" style="border : 1px solid black">
                            <thead>
                                <tr>
                                    <th class="hidden-print"><input type="checkbox" name="checkAll" id="checkAll" />
                                    </th>
                                    {if $Programsettingdata->storeserial eq 1}<th>رقم الايصال</th>{/if}
                                    <th>من مخزن</th>
                                    <th>الى مخزن</th>
                                    <th>التاريخ</th>
                                    <th>المستخدم</th>
                                    <th class="hidden-print">تفاصيل</th>
                                    <th class="hidden-print">تعديل</th>
                                    <th class="hidden-print">تفاصيل الأوردر</th>
                                    {if $usergroupdata->hideBillPrices != 1}<th class="hidden-print">طباعة الباركود</th>
                                    {/if}
                                    {if $usergroupdata->allowStoreMoveUpdateDel != 1}<th class="hidden-print">ايقاف</th>
                                    {/if}
                                    <th class="hidden-print">تحضير</th>
                                    <th class="hidden-print">قيد اليومية</th>

                                </tr>
                            </thead>
                            <tbody>




                                {foreach $storemovementData as $storemovement}
                                <tr {if {$storemovement->conditions} neq 0} class="danger" {/if}>
                                    <td class="hidden-print">
                                        <input type="checkbox" name="choosedItem[]" id="checked{$i}" class="choosenItem"
                                            value="{$storemovement->transferproductid}" />
                                    </td>
                                    {if $Programsettingdata->storeserial eq 1}
                                    <td nowrap="nowrap">
                                        {$storemovement->operationnum}
                                    </td>
                                    {/if}
                                    <td nowrap="nowrap">
                                        {$storemovement->storefromName}
                                    </td>
                                    <td nowrap="nowrap">
                                        {$storemovement->storetoName}
                                    </td>
                                    <td nowrap="nowrap">{$storemovement->driverdate}</td>
                                    <!-- <td nowrap="nowrap">{$storemovement->transferproductdate}</td> -->
                                    <td nowrap="nowrap">{$storemovement->employeename}</td>
                                    <td class="hidden-print" nowrap="nowrap">
                                        {if {$storemovement->conditions} eq 0}
                                        <a style="color:blue;"
                                            href="storemovementController.php?do=editshowstyle2&operationnum={$storemovement->operationnum}"
                                            target="_new">عرض </a>
                                        {/if}
                                    </td>
                                    <td class="hidden-print">
                                        {if {$storemovement->conditions} eq 0}
                                        <a href="storemovementController.php?do=edit&id={$storemovement->operationnum}"
                                            type="button" class="btn btn-default btn-lg editicon"></a>
                                        {/if}
                                    </td>
                                    <td class="hidden-print">
                                        {if {$storemovement->conditions} eq 0}
                                        <a href="storemovementController.php?do=editorder&on={$storemovement->operationnum}"
                                            type="button" class="btn btn-default btn-lg editicon"></a>
                                        {/if}
                                    </td>
                                    {if $usergroupdata->hideBillPrices != 1}
                                    <td class="hidden-print">
                                        <a href="productController.php?do=showbarcodestoremovement&operationnum={$storemovement->operationnum}"
                                            type="button" class="btn btn-default btn-lg editicon printparcode"></a>
                                    </td>
                                    {/if}
                                    {if $usergroupdata->allowStoreMoveUpdateDel != 1}
                                    <td class="hidden-print">
                                        {if $storemovement->recieveType == 1 && $storemovement->recieveUserid != 0}
                                        تم التسليم
                                        {else}


                                        {if {$storemovement->conditions} eq 0}
                                        <a href="storemovementController.php?do=tempdelete2&operationnum={$storemovement->operationnum}"
                                            type="button" class="btn btn-default btn-lg removeicon"></a>

                                        {elseif {$storemovement->conditions} eq 1 && $storemovement->userid != -2}
                                        <a href="storemovementController.php?do=returndelete2&operationnum={$storemovement->operationnum}"
                                            type="button" class="btn btn-default btn-lg correcticon"></a>

                                        {/if}



                                        {/if}
                                    </td>
                                    {/if}
                                    <td class="hidden-print">
                                        {if {$storemovement->isPrepared} eq 0}
                                        <a href="storemovementController.php?do=prepare&operationnum={$storemovement->operationnum}"
                                            type="button" class="btn btn-default btn-lg correcticon"></a>

                                        {elseif {$storemovement->isPrepared} eq 1}
                                        تم التحضير
                                        ({$storemovement->userPrepared})

                                        {/if}
                                    </td>
                                    <td class="hidden-print"><a href="dailyentry.php?id={$storemovement->dailyentryid}"
                                            target="_blank" type="button" class="btn btn-default btn-lg editicon"> </a>
                                    </td>

                                </tr>
                                <!--                                {if {$storemovement->userid} <> -2}

                                                                {if {$storemovement->conditions} eq 1  && {$storemovement->userid} <> -1}

                                                                <tr class="danger">
                                                                    {elseif {$storemovement->userid} eq -1}

                                                                <tr class="success">

                                                                    {elseif {$storemovement->conditions} eq 0  && {$storemovement->userid} <> -1}
                                                                <tr>
                                                                    {/if}

                                                                    <td class="hidden-print">
                                                                        <input type="checkbox" name="choosedItem[]" id="checked{$i}" class="choosenItem" value="{$storemovement->transferproductid}" />
                                                                    </td>
                                                                    {if $Programsettingdata->storeserial eq 1}<td>{$storemovement->transferproductid}</td>{/if}







                                                                    <td nowrap="nowrap">
                                                                        {if {$storemovement->operationnum}  > 0}
                                                                        {$storemovement->operationnum}
                                                                        {else}
                                                                        تحويل عام
                                                                        {/if}
                                                                    </td>
                                                                    <td class="hidden-print" nowrap="nowrap">
                                                                        {if {$storemovement->operationnum}  > 0}
                                                                        <a  href="storemovementController.php?do=editshowstyle2&operationnum={$storemovement->operationnum}"  target="_new">عرض </a>
                                                                        {else}
                                                                        تحويل عام
                                                                        {/if}
                                                                    </td>                       <td>{$storemovement->transferproductamount}</td>
                                                                    <td nowrap="nowrap">{$storemovement->transferproductdate}</td>

                                                                    {if $Programsettingdata->workerbetweenstores == 0}
                                                                    <td nowrap="nowrap">{$storemovement->driverName}</td>
                                                                    <td nowrap="nowrap">{$storemovement->lateHours}</td>
                                                                    <td class="hidden-print">
                                                                        {if $storemovement->driverid > 0}
                                                                        {if $storemovement->delivererid > 0}
                                                                        استلم<br/><strong>{$storemovement->deliverername}</strong>
                                                                        {else}
                                                                        <a href="storemovementController.php?do=recieve&transferproductid={$storemovement->transferproductid}" type="button" class="btn btn-default btn-lg bookicon"></a>
                                                                        {/if}
                                                                        {/if}
                                                                    </td>

                                                                    {/if}
                                                                    <td class="hidden-print">
                                                                        <a href="storemovementController.php?do=edit&transferproductid={$storemovement->transferproductid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                                                    </td>
                                                                    <td class="hidden-print">
                                                                        <a href="storemovementController.php?do=editorder&on={$storemovement->operationnum}" type="button" class="btn btn-default btn-lg editicon"></a>
                                                                    </td>





                                                                    <td class="hidden-print">
                                                                        {if {$storemovement->conditions} eq 0}
                                                                        <a href="storemovementController.php?do=tempdelete&transferproductid={$storemovement->transferproductid}" type="button" class="btn btn-default btn-lg removeicon"></a>

                                                                        {elseif {$storemovement->conditions} eq 1}
                                                                        <a href="storemovementController.php?do=returndelete&transferproductid={$storemovement->transferproductid}" type="button" class="btn btn-default btn-lg correcticon"></a>

                                                                        {/if}
                                                                    </td>







                                                                </tr>
                                                                {/if}-->
                                {/foreach}


                            </tbody>
                        </table>





                        <div class="clearfix"></div>


                        <hr />

                        <div class="hidden-print">
                            <div class="col-lg-12">
                                <div class="well well-sm">

                                    <div class="form-group">
                                        <div class="col-lg-4">
                                            <label for="operation"></label>
                                            <span id="spryselect1">
                                                <select name="operation" id="operation" data-placeholder="اختر العملية"
                                                    class="select2 wdt100">
                                                    <option value="-1">اختر عملية</option>
                                                    <option value="1">ايقاف</option>
                                                    <option value="2">تشغيل </option>
                                                </select>
                                                <span class="selectInvalidMsg">*</span></span>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-lg-4">
                                            <input name="" class="hidden-print btn btn-primary" type="submit"
                                                value="تنفيذ" />
                                        </div>
                                    </div>


                                    <div class="clearfix"></div>

                                    <div id="noElementsError" class="alert alert-danger fade in" style="display:none;">
                                        <button type="button" class="close pull-left" data-dismiss="alert"
                                            aria-hidden="true">×</button>
                                        <p>يجب اختيار العناصر أولاً</p>
                                        <div class="clearfix"></div>
                                    </div>

                                    <div class="clearfix">

                                        <div class="form-group">
                                            <div class="col-lg-4">
                                                <button type="button" onclick="print_Custom('mycustomheader');"
                                                    class="btn btn-success pull-right">طباعة</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </div>


            </form>

        </div>










    </div>

</div>



{literal}
<script type="text/javascript">

    jQuery(document).ready(function () {

        $(".select2Num").select2({
            placeholder: "رقم الايصال",
            inimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "storemovementAjaxController.php?do=select2OperationNumAjax",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 7, // page size
                    };
                },
                results: function (data) {
                    return { results: data };
                }
            },
            formatResult: function (data) {
                return '<span>' + data.text + '</span >';
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = { id: item[0], text: item[1], mobile: item[6] };
                callback(data);
            },
            //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
        }).on('select2-loaded', function (e) {// not "select2-open" nor "select2-opening" //http://mkurz.github.io/select2/index.html
            $('.newoption').parent().addClass('newoption');
        }).on("select2-selecting", function (e) {
            // the class to make diffrence of change from select2 itself "choose another option" ,it wont exist for triggering change
            $('#operationnum').addClass('selectingClass');
        })
        //this is needed for ajax =>to obtain id from it  and use in ajax
        $('#operationnum').select2('data', { id: $('#oldoperationnum').val(), text: $('#oldoperationnum').val() });
        setTimeout(function () {
            //this is needed as we need html to end drawing then put value => without it text will be undefined
            $('#operationnum').select2('data', { id: $('#oldoperationnum').val(), text: $('#oldoperationnum').val() });
        }, 0)
    });


    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", { isRequired: false, invalidValue: "-1" });
    $('.printparcode').mousedown(function (e) {
        e.preventDefault();
        var href = $(this).attr('href') + '&parcodeTypeToPrint=' + localStorage.getItem("parcodeTypeToPrint");
        window.open(href)
    });
</script>
{/literal}