<?php echo $header; ?><?php echo $column_left; ?>

<style>
table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  text-align: left;
  padding: 8px;
}

tr:nth-child(even) {background-color: #f2f2f2;}

.bg-warning {
    background-color: #f39c12!important;
}
.bg-success {
    background-color: #27ae60!important;
}
</style>


<div id="content">
    <div class="page-header">
        <div class="container-fluid">
            <div class="pull-right">

                <?php if ( !in_array($order_status_id, [7,11]) ) { ?>

                <?php if(!$scottycargo_shipping_info){ ?>
                    <a id="button-shipping-scottycargo" target="_blank" data-toggle="tooltip" data-scottycargo-value="<?=$order_id;?>" class="btn btn-default" <?php if($payment_code=='cod') { ?> disabled <?php } ?> ><i class="fa fa-print"></i> Scotty Kargo Oluştur</a>
                <?php }else{ ?>
                    <a href="<?=$scottycargo_shipping_info;?>" id="" target="_blank" data-toggle="tooltip" data-scottycargo-value="<?=$order_id;?>" class="btn btn-info"><i class="fa fa-print"></i> Scotty Kargo Barkodu Bastır</a>
                <?php } ?>

                <?php if(!$byexpress_shipping_info){ ?>
                    <a id="button-shipping-byexpress" target="_blank" data-toggle="tooltip" data-value="<?=$order_id;?>" class="btn btn-default"><i class="fa fa-print"></i> ByExpress K.B Oluştur</a>
                <?php }else{ ?>
                    <a href="<?=$byexpress_shipping_info;?>" id="" target="_blank" data-toggle="tooltip" data-value="<?=$order_id;?>" class="btn btn-info"><i class="fa fa-print"></i> Kargo Barkodu Bastır</a>
                <?php } ?>

                <?php if(!$shipping_info_second){ ?>
                    <a id="button-shipping_second" target="_blank" data-toggle="tooltip" data-kargovalue="<?=$order_id;?>" class="btn btn-warning"><i class="fa fa-print"></i> 2. Kargo Barkodu Oluştur</a>
                <?php }else{ ?>
                    <a href="<?=$shipping_info_second;?>" id="" target="_blank" data-toggle="tooltip" data-kargovalue="<?=$order_id;?>" class="btn btn-warning"><i class="fa fa-print"></i> 2. Kargo Barkodu Bastır</a>
                <?php } ?>


                <?php if(!$shipping_info){ ?>
                    <a id="button-shipping" target="_blank" data-toggle="tooltip" data-value="<?=$order_id;?>" class="btn btn-info"><i class="fa fa-print"></i> Kargo Barkodu Oluştur</a>
                <?php }else{ ?>
                    <a href="<?=$shipping_info;?>" id="" target="_blank" data-toggle="tooltip" data-value="<?=$order_id;?>" class="btn btn-info"><i class="fa fa-print"></i> Kargo Barkodu Bastır</a>
                <?php } ?>

                <?php } ?>

                <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a>
                <a href="<?php echo $delete; ?>" data-toggle="tooltip" title="Sil" class="btn btn-danger"><i class="fa fa-remove"></i></a>

            </div>
            <h1><?php echo $heading_title; ?></h1>
            <ul class="breadcrumb">
                <?php foreach ($breadcrumbs as $breadcrumb) { ?>
                    <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
                <?php } ?>
            </ul>
        </div>
    </div>
    <div class="container-fluid">

        <div class="col-sm-7">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-info-circle"></i> <?php echo $text_order; ?></h3>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <td style="width: 50%;" class="text-left"><?php echo $text_payment_address; ?></td>
                                <?php if ($shipping_method) { ?>
                                    <td style="width: 50%;" class="text-left"><?php echo $text_shipping_address; ?></td>
                                <?php } ?>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="text-left"><?php echo $payment_address; ?></td>
                                <?php if ($shipping_method) { ?>
                                    <td class="text-left"><?php echo $shipping_address; ?></td>
                                <?php } ?>
                            </tr>
                        </tbody>
                    </table>
                    
                    <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <td class="text-left"><?php
                                    if ($column_image == 'column_image')
                                        echo 'Resim';
                                    else
                                        echo $column_image;
                                    ?> </td>
                                <td class="text-left"><?php echo $column_pattern_image; ?></td>
                                <td class="text-left"><?php echo $column_download_image; ?></td>
                                <td class="text-left"><?php echo $column_product; ?></td>
                                <td>Atıl Stok</td>
                                <td>Yazı</td>
                                <td class="text-left"><?php echo $column_model; ?></td>
                                <!--<td class="text-right"><?php echo $column_quantity; ?></td> -->
                                <td class="text-right"><?php echo $column_price; ?></td>
                                <td class="text-right"><?php echo $column_total; ?></td>
                                <td class="text-right">KDV Dahil</td>
                                <td class="text-right">Iade/İptal</td>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($products as $product) { 
                                if($are_all_products_prepared==1) { ?>
                                <tr class="bg-success">  
                                <?php } else if($product['status']==1) { ?>
                                <tr class="bg-warning"> 
                                <?php } else { ?>
                                <tr>
                                <?php } ?>
                                    <td class="text-center">
                                        <!--<a target="_blank" href="<?php echo $product['image']; ?>"><img src="<?php echo $product['image']; ?>" width="70"/></a>-->
                                        <a target="_blank" href="<?php echo (int)$product['product_type']==11?$product['p_11_pattern_img']:$product['image']; ?>"><img src="<?php echo (int)$product['product_type']==11?$product['p_11_pattern_img']:$product['image']; ?>" width="<?php echo (int)$product['product_type']==11?30:70;?>"/></a>
                                    </td>
                                    <td class="text-center">
                                        <?php if ($product['customcase_image'] != '') { ?>
                                        <?php if((int)$product['product_type'] != 11){ ?>
                                            <img width="50" height="80" src="<?php echo $product['case_image']; ?>" alt="Frame" style="position:absolute;">
                                        <?php }?>
                                            <!--<img width="49" height="80" src="<?php echo $product['customcase_image']; ?>" alt="">-->
                                        <img width="<?php echo (int)$product['product_type']==11?52:49;?>" height="<?php echo (int)$product['product_type']==11?60:80;?>" src="<?php echo $product['customcase_image']; ?>" alt="">
                                            <?php
                                        }elseif ($product['case_order_image'] != '') {
                                            ?>
                                            <a  download href="<?php echo $product['case_order_image']; ?>"><img src="<?php echo $product['case_order_image']; ?>" width="70"/></a>
                                            <?php
                                        } else {
                                            echo '-';
                                        }
                                        ?>

                                    </td>
                                    <td  class="text-center">
                                        <?php 
                                        
                                        if ($product['customer_pattern_data'] == '') { 
                                        
                                        
                                        ?>
                                            <?php if ($product['customcase_image'] != '') {

                                                if($product['model'] == 'cst003'){
                                                    $file_tobe_download=str_replace('cropped','',$product['customcase_image']);
                                                }else{

                                                    $pathinfo = pathinfo(str_replace('cropped','',$product['customcase_image']));
                                                    
                                                    if( isset($product['model2'])){
                                                    
                                                            if( $product['model2']){
                                                            
                                                            $file_name=$product['model2'].'-'.$order_id.'.'.$pathinfo['extension'];
                                                            
                                                            }else{
                                                            
                                                            $file_name=$pathinfo['filename'].'-'.$order_id.'.'.$pathinfo['extension'];
                                                            
                                                            }


                                                    }else{
                                                    
                                                    $file_name=$pathinfo['filename'].'-'.$order_id.'.'.$pathinfo['extension'];
                                                    
                                                    }
                                                        $file_tobe_download="";
                                                        if($product['product_type']==11){
                                                            $file_name=$product['p_11_pattern_img'];
                                                            $file_tobe_download=$file_name;
                                                        }
                                                        else{
                                                          $file_tobe_download=str_replace('cropped','',$product['customcase_image']);
                                                        }
                                                }


                                            ?>
                                            <a class='download' download href="<?php echo $file_tobe_download ?>" style="cursor:pointer;"  ><i class="fa fa-cloud-download" aria-hidden="true"></i> Download</a>
                                            <!--<a download="<?=$file_name?>" href="<?php echo str_replace('cropped','',$product['customcase_image']) ?>" style="cursor:pointer;"  ><i class="fa fa-cloud-download" aria-hidden="true"></i> Download</a>-->
                                        <?php } else { ?>
                                                -
                                        <?php   } ?>
                                        <?php }else if($product['product_type']==14){  ?>
                                            <a download href="<?php echo $product['case_order_image'] ?>" style="cursor:pointer;"  ><i class="fa fa-cloud-download" aria-hidden="true"></i></a>
                                            <?php } else { if ($product['admin_pattern_image'] == '') { ?>
                                                <a id="btn_generate_<?php echo $product['order_product_id'] ?>" style="cursor:pointer;" onclick="GenerateImage('<?php echo $product['model'] ?>',<?php echo $product['order_product_id'] ?>, <?=$product['product_type'];?>, <?=$product['product_id'];?>, <?=$order_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']) ?>">
                                            
                                            <?php
                                            $file_name='';
                                            
                                            if($product['product_type']=='8'){
                                            $pathinfo = pathinfo($product['admin_pattern_image']);
                                           
                                            $temp_name=explode('-',$product['admin_pattern_image']);
                                            
                                            $file_name='10000'.'-'.$temp_name[1].'-'.$order_id.'-'.$product['order_product_id'].'.'.$pathinfo['extension'];
     if(strpos($product['admin_pattern_image'], '5000') !== false){   
     $file_name='5000'.'-'.$temp_name[1].'-'.$order_id.'-'.$product['order_product_id'].'.'.$pathinfo['extension'];
         
     }
                                            
                                            }
                                            ?>
                                            <a download="<?=$file_name?>" href="<?php echo $product['admin_pattern_image'] ?>" style="cursor:pointer;display:<?php echo ($product['admin_pattern_image'] == '' ? 'none' : '') ?>" id="img_download_<?php echo $product['order_product_id'] ?>" ><i class="fa fa-cloud-download" aria-hidden="true"></i></a>
                                       
                                            <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'] ?>" ><i class="fa fa-etsy" aria-hidden="true"></i></a>
                                            <i id="loading_icon_<?php echo $product['order_product_id'] ?>" style="display:none" class="fa fa-spinner" aria-hidden="true"> Loading</i>
                                            <a onclick="deleteGenerateImage(<?= $product['order_product_id']; ?>)"><i class="fa fa-trash" style="color:red;padding-left: 10px;cursor: pointer;"aria-hidden="true"></i></a>
                                        <?php  }  ?>

                                    </td>
                                    <td class="text-left">
                                    <?php if ($product['customcase_image'] != '') { ?>
                                            <a href="<?php echo HTTPS_CATALOG . '?route=' . $product['href']; ?>" style="color:#000"><?php echo $product['name']; ?></a>
                                            <?php } else { ?>
                                            <a target="_blank" href="<?php echo HTTPS_CATALOG . '?route=' . $product['href']; ?>"  style="color:#000"><?php echo $product['name']; ?></a>
                                    <?php }  ?>


                                        <?php foreach ($product['option'] as $option) { ?>
                                            <br />
                                        <?php if ($option['type'] != 'file') { ?>
                                                &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
                                            <?php } else { ?>
                                                &nbsp;<small> - <?php echo $option['name']; ?>: <a href="<?php echo $option['href']; ?>"  style="color:#000"><?php echo $option['value']; ?></a></small>
                                            <?php } ?>
                                        <?php } ?>

                                    </td>
                                    <td class="text-center">
                                        <!--
                                        <b style="font-size: 11px;white-space: nowrap;">Atıl Stok Ekle</b>

                                        <a href="<?=$editUrl.$product['product_id']?>" class="btn btn-primary" target="_blank">

                                            <i class="fa fa-pencil"></i>

                                        </a>-->

                                        <a class="btn btn-default" id="idle-stock-button-<?=$product['product_id']?>_<?=$order_id?>" onclick="increaseIdleStock(<?=$product['product_id']?>,<?=$order_id?>)">Atıl Stok Ekle</a>

                                    </td>
                                     <td class="text-left">
                                         
                                         <?php 
                                         
                                            if(isset($product['customer_pattern_data']) && $product['customer_pattern_data'] != null && $product['customer_pattern_data'] != ''){
                                            
                                            $customer_pattern_data = json_decode($product['customer_pattern_data'],true);
                                            
                                            echo $customer_pattern_data['pattern_text'];
                                            }
                                         
                                         ?>
                                         
                                         
                                         </td>
                                     
                                     
                                     
                                    <td class="text-left"><?php echo $product['model']; ?> x <?php echo $product['quantity']; ?></td>
                                    <!-- <td class="text-right"><?php echo $product['quantity']; ?></td> -->
                                    <td class="text-right"><?php echo $product['price']; ?></td>
                                    <td class="text-right"><?php echo $product['total']; ?></td>
                                    <td class="text-right"><?php echo $product['KDV']; ?></td>
                                    <td class="text-right">
                                        <select id="return_select_box" class="<?= $product["order_product_id"]; ?>_" onchange="returnStatusCahange('<?= $product["order_product_id"]; ?>', '<?= $product["product_id"]; ?>')">
                                            <option value="0">--</option>
                                            <?php if($product['return_status'] == 1){ ?>
                                                <option value="1" selected>İade</option>
                                            <?php }else{ ?>
                                                <option value="1" >İade</option>
                                            <?php } ?>

                                            <?php if($product['return_status'] == 2){ ?>
                                                <option value="2" selected>İptal</option>
                                            <?php }else { ?>
                                                <option value="2">İptal</option>
                                            <?php } ?>

                                            <?php if($product['return_status'] == 3){ ?>
                                                <option value="3" selected>Değişim</option>
                                            <?php }else{ ?>
                                                <option value="3">Değişim</option>
                                            <?php } ?>

                                        </select>
                                    </td>
                                </tr>
                                <?php } ?>
                                <?php foreach ($vouchers as $voucher) { ?>
                                <tr>
                                    <td class="text-left"><a href="<?php echo $voucher['href']; ?>"><?php echo $voucher['description']; ?></a></td>
                                    <td class="text-left"></td>
                                    <td class="text-right">1</td>
                                    <td class="text-right"><?php echo $voucher['amount']; ?></td>
                                    <td class="text-right"><?php echo $voucher['amount']; ?></td>
                                </tr>
                                <?php } ?>
                                <?php foreach ($totals as $total) { ?>
                                <tr>
                                    <td colspan="7" class="text-right"><?php echo $total['title']; ?></td>
                                    <td class="text-right"><?php echo $total['text']; ?></td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                    
                    </div>
                    
                    
                            <?php if ($comment) { ?>
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <td><?php echo $text_comment; ?></td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><?php echo $comment; ?></td>
                                </tr>
                            </tbody>
                        </table>
<?php } ?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title"><i class="fa fa-shopping-cart"></i> <?php echo $text_order_detail; ?></h3>
                        </div>
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td style="width: 1%;"><button data-toggle="tooltip" title="<?php echo $text_store; ?>" class="btn btn-info btn-xs"><i class="fa fa-shopping-cart fa-fw"></i></button></td>
                                    <td><a href="<?php echo $store_url; ?>" target="_blank"><?php echo $store_name; ?></a></td>
                                </tr>
                                <tr>
                                    <td><button data-toggle="tooltip" title="<?php echo $text_date_added; ?>" class="btn btn-info btn-xs"><i class="fa fa-calendar fa-fw"></i></button></td>
                                    <td><?php echo $date_added; ?></td>
                                </tr>
                                <tr>
                                    <td><button data-toggle="tooltip" title="<?php echo $text_payment_method; ?>" class="btn btn-info btn-xs"><i class="fa fa-credit-card fa-fw"></i></button></td>
                                    <td><?php echo $payment_method; ?></td>
                                </tr>
                                <?php if ($shipping_method) { ?>
                                    <tr>
                                        <td><button data-toggle="tooltip" title="<?php echo $text_shipping_method; ?>" class="btn btn-info btn-xs"><i class="fa fa-truck fa-fw"></i></button></td>
                                        <td><?php echo $shipping_method; ?></td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title"><i class="fa fa-user"></i> <?php echo $text_customer_detail; ?></h3>
                        </div>
                        <table class="table">
                            <tr>
                                <td style="width: 1%;"><button data-toggle="tooltip" title="<?php echo $text_customer; ?>" class="btn btn-info btn-xs"><i class="fa fa-user fa-fw"></i></button></td>
                                <td><?php if ($customer) { ?>
                                    <a href="<?php echo $customer; ?>" target="_blank"><?php echo $firstname; ?> <?php echo $lastname; ?></a>

                                    <a href="index.php?route=customer/customer/login&token=<?php echo $token; ?>&customer_id=<?=$customer_id;?>&store_id=0" target="_blank" data-toggle="tooltip" class="btn btn-info"><i class="fa fa-lock"></i> Bu kullanıcı ile giriş yap.</a>

                                    <?php } else { ?>
                                <?php echo $firstname; ?> <?php echo $lastname; ?>
                                   <!-- <a href="index.php?route=customer/customer/login&token=<?php echo $token; ?>&customer_id=<?=$customer_id;?>&order_id=<?=$order_id;?>&store_id=0" target="_blank" data-toggle="tooltip" class="btn btn-info"><i class="fa fa-lock"></i> Bu kullanıcı ile giriş yap.</a> -->
                            <?php } ?></td>
                            </tr>
                            <tr>
                                <td><button data-toggle="tooltip" title="<?php echo $text_customer_group; ?>" class="btn btn-info btn-xs"><i class="fa fa-group fa-fw"></i></button></td>
                                <td><?php echo $customer_group; ?></td>
                            </tr>
                            <tr>
                                <td><button data-toggle="tooltip" title="<?php echo $text_email; ?>" class="btn btn-info btn-xs"><i class="fa fa-envelope-o fa-fw"></i></button></td>
                                <td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></td>
                            </tr>
                            <tr>
                                <td><button data-toggle="tooltip" title="<?php echo $text_telephone; ?>" class="btn btn-info btn-xs"><i class="fa fa-phone fa-fw"></i></button></td>
                                <td><?php echo $telephone; ?></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title"><i class="fa fa-cog"></i> <?php echo $text_option; ?></h3>
                        </div>
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td><?php echo $text_invoice; ?></td>
                                    <td id="invoice" class="text-right"><?php echo $invoice_no; ?></td>
                                    <td style="width: 1%;" class="text-center"><?php if (!$invoice_no) { ?>
                                            <button id="button-invoice" data-loading-text="<?php echo $text_loading; ?>" data-toggle="tooltip" title="<?php echo $button_generate; ?>" class="btn btn-success btn-xs"><i class="fa fa-cog"></i></button>
                                <?php } else { ?>
                                            <button disabled="disabled" class="btn btn-success btn-xs"><i class="fa fa-refresh"></i></button>
                                <?php } ?></td>
                                </tr>
                                <tr>
                                    <td><?php echo $text_reward; ?></td>
                                    <td class="text-right"><?php echo $reward; ?></td>
                                    <td class="text-center"><?php if ($customer && $reward) { ?>
                                    <?php if (!$reward_total) { ?>
                                                <button id="button-reward-add" data-loading-text="<?php echo $text_loading; ?>" data-toggle="tooltip" title="<?php echo $button_reward_add; ?>" class="btn btn-success btn-xs"><i class="fa fa-plus-circle"></i></button>
                                        <?php } else { ?>
                                                <button id="button-reward-remove" data-loading-text="<?php echo $text_loading; ?>" data-toggle="tooltip" title="<?php echo $button_reward_remove; ?>" class="btn btn-danger btn-xs"><i class="fa fa-minus-circle"></i></button>
                                            <?php } ?>
                                        <?php } else { ?>
                                            <button disabled="disabled" class="btn btn-success btn-xs"><i class="fa fa-plus-circle"></i></button>
                                        <?php } ?></td>
                                </tr>
                                <tr>
                                    <td><?php echo $text_affiliate; ?>
                                        <?php if ($affiliate) { ?>
                                            (<a href="<?php echo $affiliate; ?>"><?php echo $affiliate_firstname; ?> <?php echo $affiliate_lastname; ?></a>)
                                    <?php } ?></td>
                                    <td class="text-right"><?php echo $commission; ?></td>
                                    <td class="text-center"><?php if ($affiliate) { ?>
                                            <?php if (!$commission_total) { ?>
                                                <button id="button-commission-add" data-loading-text="<?php echo $text_loading; ?>" data-toggle="tooltip" title="<?php echo $button_commission_add; ?>" class="btn btn-success btn-xs"><i class="fa fa-plus-circle"></i></button>
                                        <?php } else { ?>
                                                <button id="button-commission-remove" data-loading-text="<?php echo $text_loading; ?>" data-toggle="tooltip" title="<?php echo $button_commission_remove; ?>" class="btn btn-danger btn-xs"><i class="fa fa-minus-circle"></i></button>
                                            <?php } ?>
                                        <?php } else { ?>
                                            <button disabled="disabled" class="btn btn-success btn-xs"><i class="fa fa-plus-circle"></i></button>
                                        <?php } ?></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>




        <div class="col-sm-5">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-comment-o"></i> <?php echo $text_history; ?></h3>
                </div>
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab-history" data-toggle="tab"><?php echo $tab_history; ?></a></li>
                        <li><a href="#tab-additional" data-toggle="tab"><?php echo $tab_additional; ?></a></li>
                        <?php if($payment_code == 'iyzico_checkout_form'){ ?>
                            <li><a href="#tab-iyzico-refund" data-toggle="tab">Iyzico İade/İptal</a></li>
                        <?php } ?>
                        <li><a href="#tab-coupon-create" data-toggle="tab">Kupon Kodu Tanımla</a></li>
                        <?php foreach ($tabs as $tab) { ?>
                            <li><a href="#tab-<?php echo $tab['code']; ?>" data-toggle="tab"><?php echo $tab['title']; ?></a></li>
                        <?php } ?>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab-history">
                            <div id="history"></div>
                            <br />
                            <fieldset>
                                <legend><?php echo $text_history_add; ?></legend>
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" for="input-order-status"><?php echo $entry_order_status; ?></label>
                                        <div class="col-sm-10">
                                            <select name="order_status_id" id="input-order-status" class="form-control">
                                                <?php foreach ($order_statuses as $order_statuses) { ?>
                                                <?php if ($order_statuses['order_status_id'] == $order_status_id) { ?>
                                                        <option value="<?php echo $order_statuses['order_status_id']; ?>" selected="selected"><?php echo $order_statuses['name']; ?></option>
                                                    <?php } else { ?>
                                                        <option value="<?php echo $order_statuses['order_status_id']; ?>"><?php echo $order_statuses['name']; ?></option>
                                                    <?php } ?>
                                                <?php } ?>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" for="input-override"><span data-toggle="tooltip" title="<?php echo $help_override; ?>"><?php echo $entry_override; ?></span></label>
                                        <div class="col-sm-10">
                                            <input type="checkbox" name="override" value="1" id="input-override" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" for="input-notify"><?php echo $entry_notify; ?></label>
                                        <div class="col-sm-10">
                                            <input type="checkbox" name="notify" value="1" id="input-notify" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" for="input-comment"><?php echo $entry_comment; ?></label>
                                        <div class="col-sm-10">
                                            <textarea name="comment" rows="8" id="input-comment" class="form-control"></textarea>
                                        </div>
                                    </div>
                                </form>
                            </fieldset>
                            <div class="text-right">
                                <button id="button-history" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary"><i class="fa fa-plus-circle"></i> <?php echo $button_history_add; ?></button>
                            </div>
                        </div>
                        <div class="tab-pane" id="tab-additional">
                            <?php if ($account_custom_fields) { ?>
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <td colspan="2"><?php echo $text_account_custom_field; ?></td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                    <?php foreach ($account_custom_fields as $custom_field) { ?>
                                                <tr>
                                                    <td><?php echo $custom_field['name']; ?></td>
                                                    <td><?php echo $custom_field['value']; ?></td>
                                                </tr>
                                    <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            <?php } ?>
                                <?php if ($payment_custom_fields) { ?>
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <td colspan="2"><?php echo $text_payment_custom_field; ?></td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                    <?php foreach ($payment_custom_fields as $custom_field) { ?>
                                                <tr>
                                                    <td><?php echo $custom_field['name']; ?></td>
                                                    <td><?php echo $custom_field['value']; ?></td>
                                                </tr>
                                    <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                                        <?php } ?>
                                <?php if ($shipping_method && $shipping_custom_fields) { ?>
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <td colspan="2"><?php echo $text_shipping_custom_field; ?></td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php foreach ($shipping_custom_fields as $custom_field) { ?>
                                                <tr>
                                                    <td><?php echo $custom_field['name']; ?></td>
                                                    <td><?php echo $custom_field['value']; ?></td>
                                                </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            <?php } ?>
                            <div class="table-responsive">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <td colspan="2"><?php echo $text_browser; ?></td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td><?php echo $text_ip; ?></td>
                                            <td><?php echo $ip; ?></td>
                                        </tr>
                                    <?php if ($forwarded_ip) { ?>
                                            <tr>
                                                <td><?php echo $text_forwarded_ip; ?></td>
                                                <td><?php echo $forwarded_ip; ?></td>
                                            </tr>
                                    <?php } ?>
                                        <tr>
                                            <td><?php echo $text_user_agent; ?></td>
                                            <td><?php echo $user_agent; ?></td>
                                        </tr>
                                        <tr>
                                            <td><?php echo $text_accept_language; ?></td>
                                            <td><?php echo $accept_language; ?></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <div class="tab-pane" id="tab-iyzico-refund">

                        </div>

                        <div class="tab-pane" id="tab-coupon-create">

                        </div>

                        <?php foreach ($tabs as $tab) { ?>
                            <div class="tab-pane" id="tab-<?php echo $tab['code']; ?>"><?php echo $tab['content']; ?></div>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        // Return Check Box Chanhe #Bilal 10/11/2020
        function returnStatusCahange(order_product_id, product_id){

            var selected_value = $("." +order_product_id + "_ option:selected").val();


            $.ajax({
                url: 'index.php?route=sale/order_dev/changeOrderReturnStatus&order_product_id='+ order_product_id +'&order_id=<?=$order_id;?>' +'&token=<?=$token?>&selected_value=' + selected_value + '&product_id=' + product_id,
                dataType: 'json',
                type: 'POST',
                data: {},
                success: function(json){

                    $('.alert').remove();

                    if (json['error']) {
                        $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                    }

                    if (json['success']) {
                        $('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                    }


                },beforeSend: function () {
                    //$('[data-value="'+ order_id +'"]').html("<b>İşlem Yapılıyor..</b>");
                   // $("." +order_product_id + "_").after("İşlem Yapılıyor..");
                }
            });
        }
        // Return Check Box Chanhe #Bilal 10/11/2020

        $('#button-shipping_second').click(function(e){

            var conf = confirm("Bu kargo barkodu iade ve değişim işlemleri için eklenmiştir. Emin misiniz? ");

            if(conf){
                var order_id = $(this).attr('data-kargovalue');
                var firma = 'YURTICI';
                $.ajax({
                    url: 'index.php?route=sale/order_dev/kargola_second&firma='+ firma +'&order_id='+ order_id +'&token=<?=$token?>',
                    dataType: 'json',
                    type: 'POST',
                    data: {},
                    success: function(json){
                        if(json['status'] == 1){
                            location.reload();
                        }else{
                            $('body [data-kargovalue="'+ order_id +'"]').after("Başarısız");
                        }
                    },beforeSend: function () {
                        $('[data-kargovalue="'+ order_id +'"]').html("<b>İşlem Yapılıyor..</b>");
                    }
                });
            }


        });

        $('#button-shipping').click(function(e){
            var order_id = $(this).attr('data-value');
            var firma = 'YURTICI';
            $.ajax({
                url: 'index.php?route=sale/order_dev/kargola&firma='+ firma +'&order_id='+ order_id +'&token=<?=$token?>',
                dataType: 'json',
                type: 'POST',
                data: {},
                success: function(json){
                    if(json['status'] == 1){
                        location.reload();
                    }else{
                        $('body [data-value="'+ order_id +'"]').after("Başarısız");
                    }
                },beforeSend: function () {
                    $('[data-value="'+ order_id +'"]').html("<b>İşlem Yapılıyor..</b>");
                }
            });
        });


        // ByExpress Cargo Send

        $('#button-shipping-byexpress').click(function(e){

            var conf = confirm("Emin misiniz!");
            if(conf){
                var order_id = $(this).attr('data-value');
                $.ajax({
                    url: 'index.php?route=sale/order_dev/byexpress&order_id='+ order_id +'&token=<?=$token?>',
                    dataType: 'json',
                    type: 'POST',
                    data: {},
                    success: function(json){
                        if(json['status'] == 1){
                            location.reload();
                        }else{
                            $('body [data-value="'+ order_id +'"]').after("Başarısız");
                            alert(json['error']);
                        }
                    },beforeSend: function () {
                        $('[data-value="'+ order_id +'"]').html("<b>İşlem Yapılıyor..</b>");
                    }
                });
            }else{
                alert("Vazgeçtiniz!");
            }


        });

        // ByExpress Cargo Send


        // ByExpress Cargo Send

        $('#button-shipping-scottycargo').click(function(e){
            var conf = confirm("Emin misiniz!");
            if(conf){
                var order_id = $(this).attr('data-scottycargo-value');
                $.ajax({
                    url: 'index.php?route=sale/order_dev/scottycargo&order_id='+ order_id +'&token=<?=$token?>',
                    dataType: 'json',
                    type: 'POST',
                    data: {},
                    success: function(json){
                        if(json['status'] == 1){
                            addHistoryForScottyCargo(order_id);
                        }else{
                            $('body [data-scottycargo-value="'+ order_id +'"]').after("Başarısız");
                            alert(json['error']);
                        }
                    },beforeSend: function () {
                        $('[data-scottycargo-value="'+ order_id +'"]').html("<b>İşlem Yapılıyor..</b>");
                    }
                });
            }else{
                alert("Vazgeçtiniz!");
            }
        });
  
        function addHistoryForScottyCargo(order_id) {
            var token = '';
            // Login to the API
            $.ajax({
                url: '<?php echo $catalog; ?>index.php?route=api/login',
                type: 'post',
                dataType: 'json',
                data: 'key=<?php echo $api_key; ?>',
                crossDomain: true,
                success: function (json) {
                    if (json['token']) {
                        token = json['token'];
                        $.ajax({
                            url: '<?php echo $catalog; ?>index.php?route=api/order_dev/history&token=' + token + '&store_id=0&order_id=' + order_id,
                            type: 'post',
                            dataType: 'json',
                            data: 'order_status_id=' + '<?=$scottycargo_order_status_id;?>' + '&notify=1&override=1&append=1&comment=' + encodeURIComponent("Kargo Kaydı Açıldı"),
                            success: function (json) {
                                location.reload();
                            },
                            error: function (xhr, ajaxOptions, thrownError) {
                                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                            }
                        });

                    }
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                }
            });
        }

        // ByExpress Cargo Send

        function deleteGenerateImage(product_id) {

            if(confirm("Silmek istediğinizden Emin misiniz?")){
                $.ajax({
                    url: '<?php echo HTTPS_CATALOG ?>index.php?route=piyerSoft/cases/deleteGenerateImage',
                    type: 'post',
                    dataType: 'json',
                    data: {order_product_id: product_id},
                    success: function (json) {
                        if(json['success'])
                            location.reload();
                        else
                            alert(json['error']);
                    }
                });
            }


        }

        function GenerateImage(pattern_code, id, product_type, product_id, order_id) {
            //alert(product_type);
            var customer_pattern_data = $('#customer_pattern_data_' + id).val();

            if(product_type == 4){
                var url = '<?php echo HTTPS_CATALOG ?>index.php?route=piyerSoft/cases/GenerateDpiImageType4';
            }else{
                var url = '<?php echo HTTPS_CATALOG ?>index.php?route=piyerSoft/cases/GenerateDpiImage';
            }


            $("#btn_generate_" + id).hide();
            $("#loading_icon_" + id).show();
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: {order_product_id: id, pattern_code: pattern_code, customer_pattern_data: customer_pattern_data, product_id: product_id, order_id:order_id},

                success: function (res) {

                    if (res.responce == 'success') {
                        $("#loading_icon_" + id).hide();
                        $("#img_download_" + id).attr("href", '<?php echo HTTPS_CATALOG ?>image/' + res.pattern_img);
                        $("#img_download_" + id).show();
                        if(res.gradient_img!=''){
                        $("#gradient_img_download_" + id).attr("href", '<?php echo HTTPS_CATALOG ?>image/' + res.gradient_img);
                        $("#gradient_img_download_" + id).show();
                        }
                    } else {
                         alert(res.responce);
                        $("#btn_generate_" + id).show();
                        $("#loading_icon_" + id).hide();
                    }

                }
            });

        }
    </script>
        <script type="text/javascript"><!--

            $(document).delegate('#button-ip-add', 'click', function () {
                $.ajax({
                    url: 'index.php?route=user/api/addip&token=<?php echo $token; ?>&api_id=<?php echo $api_id; ?>',
                    type: 'post',
                    data: 'ip=<?php echo $api_ip; ?>',
                    dataType: 'json',
                    beforeSend: function () {
                        $('#button-ip-add').button('loading');
                    },
                    complete: function () {
                        $('#button-ip-add').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                        }

                        if (json['success']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });

            $(document).delegate('#button-invoice', 'click', function () {
                $.ajax({
                    url: 'index.php?route=sale/order_dev/createinvoiceno&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>',
                    dataType: 'json',
                    beforeSend: function () {
                        $('#button-invoice').button('loading');
                    },
                    complete: function () {
                        $('#button-invoice').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                        }

                        if (json['invoice_no']) {
                            $('#invoice').html(json['invoice_no']);

                            $('#button-invoice').replaceWith('<button disabled="disabled" class="btn btn-success btn-xs"><i class="fa fa-cog"></i></button>');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });

            $(document).delegate('#button-reward-add', 'click', function () {
                $.ajax({
                    url: 'index.php?route=sale/order_dev/addreward&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>',
                    type: 'post',
                    dataType: 'json',
                    beforeSend: function () {
                        $('#button-reward-add').button('loading');
                    },
                    complete: function () {
                        $('#button-reward-add').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                        }

                        if (json['success']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                            $('#button-reward-add').replaceWith('<button id="button-reward-remove" data-toggle="tooltip" title="<?php echo $button_reward_remove; ?>" class="btn btn-danger btn-xs"><i class="fa fa-minus-circle"></i></button>');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });

            $(document).delegate('#button-reward-remove', 'click', function () {
                $.ajax({
                    url: 'index.php?route=sale/order_dev/removereward&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>',
                    type: 'post',
                    dataType: 'json',
                    beforeSend: function () {
                        $('#button-reward-remove').button('loading');
                    },
                    complete: function () {
                        $('#button-reward-remove').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                        }

                        if (json['success']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                            $('#button-reward-remove').replaceWith('<button id="button-reward-add" data-toggle="tooltip" title="<?php echo $button_reward_add; ?>" class="btn btn-success btn-xs"><i class="fa fa-plus-circle"></i></button>');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });

            $(document).delegate('#button-commission-add', 'click', function () {
                $.ajax({
                    url: 'index.php?route=sale/order_dev/addcommission&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>',
                    type: 'post',
                    dataType: 'json',
                    beforeSend: function () {
                        $('#button-commission-add').button('loading');
                    },
                    complete: function () {
                        $('#button-commission-add').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                        }

                        if (json['success']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                            $('#button-commission-add').replaceWith('<button id="button-commission-remove" data-toggle="tooltip" title="<?php echo $button_commission_remove; ?>" class="btn btn-danger btn-xs"><i class="fa fa-minus-circle"></i></button>');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });

            $(document).delegate('#button-commission-remove', 'click', function () {
                $.ajax({
                    url: 'index.php?route=sale/order_dev/removecommission&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>',
                    type: 'post',
                    dataType: 'json',
                    beforeSend: function () {
                        $('#button-commission-remove').button('loading');
                    },
                    complete: function () {
                        $('#button-commission-remove').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                        }

                        if (json['success']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                            $('#button-commission-remove').replaceWith('<button id="button-commission-add" data-toggle="tooltip" title="<?php echo $button_commission_add; ?>" class="btn btn-success btn-xs"><i class="fa fa-plus-circle"></i></button>');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });


            $('#tab-iyzico-refund').load('index.php?route=extension/payment/iyzico_checkout_form_dev/order&token=<?= $token; ?>&order_id=<?= $order_id; ?>');

            $('#tab-coupon-create').load('index.php?route=sale/return/returnCoupon&token=<?= $token;?>&order_id=<?=$order_id;?>');


            var token = '';

            // Login to the API
            $.ajax({
                url: '<?php echo $catalog; ?>index.php?route=api/login',
                type: 'post',
                dataType: 'json',
                data: 'key=<?php echo $api_key; ?>',
                crossDomain: true,
                success: function (json) {
                    $('.alert').remove();

                    if (json['error']) {
                        if (json['error']['key']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error']['key'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                        }

                        if (json['error']['ip']) {
                            $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error']['ip'] + ' <button type="button" id="button-ip-add" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-danger btn-xs pull-right"><i class="fa fa-plus"></i> <?php echo $button_ip_add; ?></button></div>');
                        }
                    }

                    if (json['token']) {
                        token = json['token'];
                    }
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                }
            });

            $('#history').delegate('.pagination a', 'click', function (e) {
                e.preventDefault();

                $('#history').load(this.href);
            });



            $('#history').load('index.php?route=sale/order_dev/history&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>');

            $('#button-history').on('click', function () {

                $.ajax({
                    url: '<?php echo $catalog; ?>index.php?route=api/order_dev/history&token=' + token + '&store_id=<?php echo $store_id; ?>&order_id=<?php echo $order_id; ?>',
                    type: 'post',
                    dataType: 'json',
                    data: 'order_status_id=' + encodeURIComponent($('select[name=\'order_status_id\']').val()) + '&notify=' + ($('input[name=\'notify\']').prop('checked') ? 1 : 0) + '&override=' + ($('input[name=\'override\']').prop('checked') ? 1 : 0) + '&append=' + ($('input[name=\'append\']').prop('checked') ? 1 : 0) + '&comment=' + encodeURIComponent($('textarea[name=\'comment\']').val()),
                    beforeSend: function () {
                        $('#button-history').button('loading');
                    },
                    complete: function () {
                        $('#button-history').button('reset');
                    },
                    success: function (json) {
                        $('.alert').remove();

                        if (json['error']) {
                            $('#history').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                        }

                        if (json['success']) {
                            $('#history').load('index.php?route=sale/order_dev/history&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>');

                            $('#history').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                            $('textarea[name=\'comment\']').val('');
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            });

            /*function changeStatus() {
                var status_id = $('select[name="order_status_id"]').val();

                $('#openbay-info').remove();

                $.ajax({
                    url: 'index.php?route=extension/openbay/getorderinfo&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>&status_id=' + status_id,
                    dataType: 'html',
                    success: function (html) {
                        //$('#history').after(html);
                    }
                });
            }

            function addOrderInfo() {
                var status_id = $('select[name="order_status_id"]').val();

                $.ajax({
                    url: 'index.php?route=extension/openbay/addorderinfo&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>&status_id=' + status_id,
                    type: 'post',
                    dataType: 'html',
                    data: $(".openbay-data").serialize()
                });
            }*/

            $(document).ready(function () {
                changeStatus();
            });

            $('select[name="order_status_id"]').change(function () {
                changeStatus();
            });
//--></script>
    </div>

<script>
            function increaseIdleStock(productId, orderId) {
            if (productId) {
                $.ajax({
                    url: "index.php?route=sale/prepared_orders/increaseIdleStock&token=<?=$token?>&product_id=" + productId,
                    type: "GET",
                    beforeSend: function () {
                        $('#idle-stock-button-'+productId+'_'+orderId).html('Ekleniyor..');
                    },
                    success: function (result) {
                        alert(result['message'] + '\n' + 'Güncel atıl stok adeti: ' + result.data);
                        /* //bu sayfada swal ekli değil. eklemedim alert kullandım -Can 24.12.2021
                        Swal.fire({
                            icon: 'success',
                            title: result['message'],
                            text: 'Güncel atıl stok adeti: ' + result.data,
                            confirmButtonText: 'Tamam',
                        });*/
                        $('#idle-stock-text-'+productId).html('Atıl Stok Mevcut');
                    },
                    complete: function() {
                        $('#idle-stock-button-'+productId+'_'+orderId).html('Atıl Stok Ekle');
                    }
                });
            }
        }
</script>
    <?php echo $footer; ?>

    