<?php if ($products) { ?>
                            <?php foreach ($products as $product) { ?>


                            <tr class="Order" data-orderid="<?= $product ['order_id']; ?>"
                                data-totalcustomerorders="<?= $product ['total_customer_orders']; ?>"
                                data-status="<?= $product ['status']; ?>">
                                <td class="text-center"><input type="checkbox" name="selected_order_ids[]"
                                                               value="<?php echo $product['order_id']; ?>"/> </td>
                                <td class="text-left">
                                    <? if ($product ['order_status'] == "İptal Edildi" OR $product ['order_status'] == "İade Edildi"): ?>
                                    <span class="label label-danger"
                                          style="font-size: 18px;"><?= $product ['order_status']; ?></span>
                                    <? else: ?>
                                    <?= $product ['order_status']; ?>
                                    <? endif; ?>
                                </td>
                                <td>
                                    <select class="room_no<?= $product['order_product_id']; ?>" onchange="changeRoomNumber(<?= $product['order_product_id']; ?>);">
                                        <option value="0" <?= $product['room_no'] == 0? 'selected': ''; ?>> Seçiniz </option>
                                        <?php for($i = 1; $i <= 60; $i++){ ?>
                                        <?php if($i == $product['room_no']){ ?>
                                        <option value="<?=$i;?>" selected> <?=$i;?></option>
                                        <?php }else{ ?>
                                        <option value="<?=$i;?>"> <?=$i;?> </option>
                                        <?php } ?>
                                        <?php } ?>
                                    </select>
                                </td>
                                <td class="text-center">
                                    <?php if ($product['customcase_image'] != '') { ?>
                                    <img width="50" height="80" data-src="<?php echo $product['case_image']; ?>"
                                         src="<?=HTTP_CATALOG?>catalog/view/theme/deercase/image/placeholder250.png"
                                         alt="Frame" style="position:absolute;">
                                    <img width="49" height="80" data-src="<?php echo $product['customcase_image']; ?>"
                                         src="<?=HTTP_CATALOG?>catalog/view/theme/deercase/image/placeholder250.png"
                                         alt="">
                                    <?php }elseif ($product['case_order_image'] != '') { ?>
                                    <img data-src="<?php echo $product['case_order_image']; ?>" width="70"
                                         src="<?=HTTP_CATALOG?>catalog/view/theme/deercase/image/placeholder250.png"/></a>
                                    <?php } else { ?>
                                    -
                                    <?php  } ?>

                                </td>
                                <td class="text-left <?php if($product['reprint_download_count'] > 0) { ?>red-frame <?php } ?>">
                                    <?php echo $product['product_model']; ?> <br>
                                    <?php if ($product['customer_pattern_data'] == '') { ?>
                                    <?php if ($product['customcase_image'] != '') {
                                    
                                     $pathinfo = pathinfo(str_replace('cropped','',$product['customcase_image']));
                                        if(isset($product['model2']) && $product['model2']!=''){
                                        
                                       
                                        $file_name=$product['model2'].'-'.$product['order_id'].'.'.$pathinfo['extension'];
                                        
                                        }else{
                                        
                                        $file_name=$pathinfo['filename'].'-'.$product['order_id'].'.'.$pathinfo['extension'];
                                        
                                        }
                                    
                                    ?>
                                    <a download="<?=$file_name?>"
                                       href="<?php echo str_replace('cropped','',$product['customcase_image']) ?>"
                                       style="cursor:pointer;<?php if($product['reprint_download_count'] > 0) { ?> color:red; <?php } ?>""
                                       onclick="IncreaseReprintDownloadCount(<?= $product['order_product_id']; ?>)"><i class="fa fa-cloud-download" aria-hidden="true"></i>
                                        Customcase Download</a>
                                    <?php } else { ?>
                                    -
                                    <?php   } ?>
                                    <?php }else if($product['product_type']==14){  ?>
                                    <a download href="<?php echo $product['case_order_image'] ?>"
                                       style="cursor:pointer;<?php if($product['reprint_download_count'] > 0) { ?> color:red; <?php } ?>"
                                       onclick="IncreaseReprintDownloadCount(<?= $product['order_product_id']; ?>)">
                                       <i class="fa fa-cloud-download" aria-hidden="true"></i> 4
                                        Download</a>
                                    <?php } else { if ($product['admin_pattern_image'] == '') { ?>
                                    <a id="btn_generate_<?php echo $product['order_product_id'] ?>"
                                       class="generate_button" style="cursor:pointer;<?php if($product['reprint_download_count'] > 0) { ?> color:red; <?php } ?>"
                                       onclick="GenerateImage('<?php echo $product['model'] ?>',<?php echo $product['order_product_id'] ?>, <?php echo $product['order_id'] ?>,<?=$product['product_type'];?>, <?=$product['product_id'];?> )">Generate</a>
                                    <?php } ?>

                                    <input type="hidden"
                                           id="customer_pattern_data_<?php echo $product['order_product_id'] ?>"
                                           value="<?php echo @htmlspecialchars($product['customer_pattern_data']) ?>">
                                    <a download href="<?php echo $product['admin_pattern_image'] ?>"
                                       style="cursor:pointer;<?php if($product['reprint_download_count'] > 0) { ?> color:red; <?php } ?>display:<?php echo ($product['admin_pattern_image'] == '' ? 'none' : '') ?>"
                                       id="img_download_<?php echo $product['order_product_id'] ?>"
                                       onclick="IncreaseReprintDownloadCount(<?= $product['order_product_id']; ?>)"><i
                                                class="fa fa-cloud-download" aria-hidden="true"></i> Download</a>

                                    <?php if($product['admin_gradient_pattern_image']){ ?>
                                    <a download href="<?php echo $product['admin_gradient_pattern_image'] ?>"
                                       style=" margin-top: 5px; cursor:pointer;display:<?php echo ($product['admin_gradient_pattern_image'] == '' ? 'none' : '') ?>"
                                       id="gradient_img_download_<?php echo $product['order_product_id'] ?>">Gradient
                                        Download</a>
                                    <?php } ?>
                                    <?php if ($product['customer_pattern_data'] != '') { ?>
                                    <a onclick="deleteGenerateImage(<?= $product['order_product_id']; ?>)">Delete</a>
                                    <?php } ?>
                                    <?php if($product['reprint_download_count'] > 0) { ?><b style="color:red;display:block;">(Daha önce indirildi)</b><?php } ?>
                                    <i id="loading_icon_<?php echo $product['order_product_id'] ?>" style="display:none"
                                       class="fa fa-spinner" aria-hidden="true"> Loading</i>

                                    <?php  }  ?>
                                </td>
                                <td class="text-left"><?= $product['case_text']; ?></td>
                                <td class="text-left">
                                    <?= $product['name']; ?> <br>
                                    <?php if($product ['options']){ ?>
                                    <?php foreach($product ['options'] as $option){ ?>
                                    <b style="color: red;">(<?=$option['value'];?>)</b>
                                    <?php } ?>
                                    <?php } ?>
                                    <br>
                                    <?php if($product['product_type']==3){ ?>
                                    <b style="color: red; font-size: 20px">Tutacaklı</b>
                                    <?php } ?>
                                </td>
                                <td class="text-left">
                                    <?php if($product['return_status'] == 1){ ?>
                                    <b style="color: red">İade</b>
                                    <?php }else if($product['return_status'] == 2){ ?>
                                    <b style="color: red">İptal</b>
                                    <?php }else if($product['return_status'] == 3){ ?>
                                    <b style="color: red">Değişim</b>
                                    <?php } ?>
                                </td>


                                <td class="text-center">

                                    <?php
                                    $idle_stock_text = '';
                                    $decButtonStatus = ' disabled="true" ';

                                    if (isset($product_idle_stock[$product['product_id']]) && $product_idle_stock[$product['product_id']] > 0
                                        && $product['case_text']=='' && $product['customcase_image']=='') {

                                        $product_idle_stock[$product['product_id']]--;
                                        $idle_stock_text = 'Atıl Stok Mevcut';
                                        $decButtonStatus = ' disabled="false"  ';
                                    }
                                    
                                    if ($product['idle_stock'] > 0) {
                                        $idle_stock_text = 'Atıl Stok Mevcut';
                                        $decButtonStatus = ' disabled="false"  ';
                                    }
                                    ?>

                                    <span id="decrease_product_idle_stock_button_container_<?=$product['product_id']?>_<?=$product['order_id']?>">
                                        <a href="javascript:" class="btn btn-danger btn-sm"
                                        id="dec-idle-stock-button-<?=$product['product_id']?>_<?=$product['order_id']?>" 
                                           onclick="decreaseIdleStock(<?=$product['product_id']?>,<?=$product['order_id']?>)">
                                            Atıl Stok Eksilt
                                        </a><br>
                                        <b style="color:red" id="idle-stock-text-<?=$product['product_id']?>"><?=$idle_stock_text?></b>
                                    </span>
                                    <div>
                                        <a class="btn btn-primary btn-sm" id="idle-stock-button-<?=$product['product_id']?>_<?=$product['order_id']?>" onclick="increaseIdleStock(<?=$product['product_id']?>,<?=$product['order_id']?>)" style="margin-top:1rem;">Atıl Stok Ekle</a>
                                    </div>
                                </td>

                                <td class="text-left"><?= $product ['comment']; ?></td>
                                <td class="text-left"><?php echo $product['customer']; ?> - <a href="<?=$product['order_href'];?>"
                                                          target="_blank"><?php echo $product['order_id']; ?></a> - <?php echo $product['date_added']; ?></td>
                                
                                <td class="text-center"><?php if ($product ['status']) { ?>
                                    <input type="checkbox" name="selected[]"
                                           value="<?php echo $product['order_product_id']; ?>"
                                           data-order-id="<?= $product['order_id']; ?>" checked="checked"/>
                                    <?php } else { ?>
                                    <input type="checkbox" name="selected[]"
                                           value="<?php echo $product['order_product_id']; ?>"
                                           data-order-id="<?= $product['order_id']; ?>"/>
                                    <?php } ?>
                                    <input type="hidden" name="shipping_code[]"
                                           value="<?php echo $product['shipping_code']; ?>"/></td>

                                
                                <td>
                                    <?php if ($product['order_status'] != "İptal Edildi" && $product['order_status'] != "İade Edildi") { ?>
                                    <?php if(!$product['scottycargo_info']){ ?>
                                    <a style="max-width: 100px;  <?php if($product['disable_scotty']!==1) { ?> margin-top:1.5rem; <?php } ?>"  class="button-shipping-scottycargo btn btn-danger" data-toggle="tooltip" data-scottycargo-value="<?=$product['order_id'];?>" title="Scotty Kargoya Gönder" <?php if($product['disable_scotty']==1) { ?> disabled <?php } ?>>
                                        <i class="fa fa-truck"></i> Scotty
                                    </a>
                                    <?php 
                                    if($product['disable_scotty']!==1) { ?> <br/> 
                                        <?php if($product['payment_code'] == 'iyzico_checkout_form') { ?> <span style="font-size:10px;">(Kredi Kartı)</span>  <?php } ?>  
                                    <? } ?>
                                    <?php } else{ ?>

                                        <a href="javascript:;"
                                           onclick="window.open ('<?=$product['scottycargo_barcode'];?>', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');"
                                           class="btn" data-toggle="tooltip" title="Kargo Barkodu Bastır"> <i
                                                    style="font-size:40px;" class="fa fa-print"></i></a> <br>
                                        <a title="Kargo Barkodu Bastır" href="<?=$product['scottycargo_barcode'];?>" target="_blank"> Scotty Barcode</a>
                                        <br>
                                        <?php if($product['scottycargo_info']['barcode_print_count']){ ?>
                                        <b><?=$product['scottycargo_info']['barcode_print_count']; ?></b> kere yazdırılmıştır.
                                        <?php } ?>
                                    <?php }
                                     }
                                    ?>
                                </td>

                                <!-- MNG Kargo -->
                               <td>
                                    <?php if ($product['order_status'] != "İptal Edildi" && $product['order_status'] != "İade Edildi") { ?>
                                        <?php if(!$product['mngcargo_info']){ ?>
                                        <a style="max-width: 100px;"  class="button-shipping-mngcargo btn btn-danger" data-toggle="tooltip" data-mngcargo-value="<?=$product['order_id'];?>" title="Mng Kargoya Gönder">
                                            <i class="fa fa-truck"></i> Mng
                                        </a>
                                   
                                        <?php }else{ ?>
                                   

                                            <a href="javascript:;"
                                            onclick="window.open ('<?=$product['mngcargo_barcode'];?>', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');"
                                            class="btn" data-toggle="tooltip" title="Kargo Barkodu Bastır"> <i
                                                        style="font-size:40px;" class="fa fa-print"></i></a> <br>
                                            <a title="Kargo Barkodu Bastır" href="<?=$product['mngcargo_barcode'];?>" target="_blank"> Mng Barcode</a>
                                            <br>
                                            <?php if($product['mngcargo_info']['barcode_print_count']){ ?>
                                            <b><?=$product['mngcargo_info']['barcode_print_count']; ?></b> kere yazdırılmıştır.
                                            <?php } ?>
                                    <?php } } ?>
                                </td>

                                <!-- MNG Kargo -->
                                  
                                
                                <!-- Surat Kargo -->
                                <!--<td>
                                    <?php if ($product['order_status'] != "İptal Edildi" && $product['order_status'] != "İade Edildi") { ?>

                                        <?php if(!$product['suratkargo_barcode']){ ?>
                                        <a style="max-width: 100px;" class="button-shipping-suratkargo btn btn-info" data-toggle="tooltip" data-suratkargo-value="<?=$product['order_id'];?>" title="Kargoya Gönder"> <i class="fa fa-truck"></i> Sürat K </a>
                                        <?php }else{ ?>
                                        
                                            <a href="javascript:;" onclick="window.open ('<?=$product['surat_kargo_barcode_default'];?>', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');" class="btn" data-toggle="tooltip" title="Kargo Barkodu Bastır"> <i style="font-size:40px;" class="fa fa-print"></i></a> <br>
                                        
                                            <?php if($product['suratkargo_barcode']['barcode_print_count']){ ?>
                                                <b><?=$product['suratkargo_barcode']['barcode_print_count']; ?></b> kere yazdırılmıştır.
                                            <?php } ?>
                                        <?php } ?>
                                        <br>
                                        

                                    <?php } ?>

                                </td>-->
                                <!-- Surat Kargo -->

                              <!--   <td>

                                    <?php if ($product['order_status'] != "İptal Edildi" && $product['order_status'] != "İade Edildi") { ?>

                                    <?php if(!$product['araskargo_barcode']){ ?>
                                    <a style="max-width: 100px;" class="button-shipping-araskargo btn btn-warning" data-toggle="tooltip" data-araskargo-value="<?=$product['order_id'];?>" title="Aras Kargoya Gönder"> <i class="fa fa-truck"></i> Aras Kargo </a> 
                                    
                                
                                    <?php }else{ ?>

                                        <a href="javascript:;"
                                           onclick="window.open ('<?=$product['aras_kargo_barcode_default'];?>', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');"
                                           class="btn" data-toggle="tooltip" title="Kargo Barkodu Bastır"> <i
                                                    style="font-size:40px;" class="fa fa-print"></i></a> <br>
                                        <a title="Kargo Barkodu Bastır" href="<?=$product['aras_kargo_barcode_default'];?>" target="_blank"> Hızlı Barcode</a>

                                        <br>
                                    
                                            <a title="Kargo Barkodu Bastır" class="button-shipping-araskargo btn btn-success" href="<?=$product['aras_kargo_last_barcode'];?>" target="_blank"> Son Barcode</a> <br>
                                         

                                        <?php if($product['araskargo_barcode']['barcode_print_count']){ ?>
                                        <b><?=$product['araskargo_barcode']['barcode_print_count']; ?></b> kere yazdırılmıştır.
                                        <?php } ?>
                                    <?php } } ?>


                                </td> -->

                                <!--
                                <td>
                                    <?php if ($product['order_status'] != "İptal Edildi" && $product['order_status'] != "İade Edildi") { ?>

                                    <?php if(!$product['kargo_talepno']){ ?>
                                    <a style="max-width: 100px;" class="button-shipping btn btn-info" data-toggle="tooltip"
                                       data-value="<?=$product['order_id'];?>" title="Kargoya Gönder"> <i
                                                class="fa fa-truck"></i> Yurtiçi </a>
                                    <?php }else{ ?>
                                    <a href="javascript:;"
                                       onclick="window.open ('<?=$product['kargo_barcode'];?>', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');"
                                       class="btn" data-toggle="tooltip" title="Kargo Barkodu Bastır"> <i
                                                style="font-size:40px;" class="fa fa-print"></i></a> <br>
                                    <a title="Kargo Barkodu Bastır" href="<?=$product['kargo_barcode'];?>" target="_blank"> Hızlı Barcode</a>
                                    <br>
                                    <?php if($product['kargo_talepno']['barcode_print_count']){ ?>
                                    <b><?=$product['kargo_talepno']['barcode_print_count']; ?></b> kere yazdırılmıştır.
                                    <?php } ?>
                                    <?php } ?>

                                    <?php } ?>

                                </td>
                                -->
                                

                                

                                

                                <td class="text-center">
                                    <div style="<?= $product['reprint_reason_id']? '': 'display: none'; ?>">
                                        <?php if ($product ['reprint']) { ?>
                                        <input type="checkbox" name="reprinted[]" value="<?php echo $product['reprint']; ?>" data-order-product-id="<?= $product['order_product_id']; ?>" checked="checked" />
                                        <?php } else { ?>
                                        <input type="checkbox" name="reprinted[]" value="<?php echo $product['reprint']; ?>" data-order-product-id="<?= $product['order_product_id']; ?>" />
                                        <?php } ?>
                                        <b style="color: red; margin-top: 5px; float: left; <?= ($product ['reprint']) ? '' : 'display: none;'; ?>">TEKRAR BASILACAK!</b>
                                        <br>
                                    </div>
                                    <select style="max-width: 85px;" class="reprint_reason<?= $product['order_product_id']; ?>" onchange="changeReprintReason(<?= $product['order_product_id']; ?>)">
                                        <option value="0"> Seçiniz </option>
                                        <?php foreach($reprint_reasons as $reason){ ?>
                                        <?php if($reason['reprint_reason_id'] == $product['reprint_reason_id']){ ?>
                                        <option value="<?=$reason['reprint_reason_id'];?>" selected> <?=$reason['name'];?> </option>
                                        <?php }else{ ?>
                                        <option value="<?=$reason['reprint_reason_id'];?>"> <?=$reason['name'];?> </option>
                                        <?php } ?>
                                        <?php } ?>
                                    </select>
                                </td>


                                <style>.mukerrer{padding: 8px 28px; background: red; color: #fff; border-radius: 10px;}</style>

                            </tr>
                            <?php } ?>
                            <?php } else { ?>
                            <tr>
                                <td class="text-center" colspan="8"> Bitti</td>
                            </tr>
                            <?php } ?>