<style type="text/css">
    .chosen-container a.chosen-single{line-height: 24px !important;}
</style>

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2><?= print_lang($app_lang,'edit_lot_sale'); ?></h2>
        <ol class="breadcrumb">
            <li>
                <a class="url-elem" href="<?php echo url('/dashboard'); ?>"><?= print_lang($app_lang,'home'); ?></a>
            </li>
            <li>
                <a class="url-elem" href="<?php echo url('/lot-purchase/sold'); ?>"><?= print_lang($app_lang,'lot_sales'); ?></a>
            </li>
            <li class="active">
                <strong><?= print_lang($app_lang,'edit_lot_sale'); ?></strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">
    </div>
</div>


<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox-title">
        <h5><?= print_lang($app_lang,'fields_with'); ?> <strong class="text-danger">*</strong> <?= print_lang($app_lang,'are_mandatory'); ?></h5>
    </div>
    <div class="ibox-content">
        <!-- spinner -->
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
        <!-- spinner -->
        <div class="row">
            <div class="col-sm-12 b-r">
                <form role="form" id="lot-sale-form" action="<?php echo url('/lot-purchase/sold/update').'/'.$editing_data['uid']; ?>">

                    <div class="row extra-mar-botm">
                        <div class="col-md-4">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'currency'); ?> <strong class="text-danger">*</strong></label>
                                <input type="hidden" name="parent_uid" value="<?= $editing_data['parent']; ?>">
                                <input type="hidden" name="child_uid" value="<?= $editing_data['child']; ?>">

                                <input type="hidden" name="lot_currency" value="<?= $lot_data['currency']; ?>">
                                <input type="hidden" name="lot_currency_usd_equalance" value="<?= $lot_data['currency_usd_equalance']; ?>">

                                <input type="hidden" name="lot_real_cost" value="<?= $editing_data['real_cost']; ?>">
                                <input type="hidden" name="_sold_discount_amount" value="<?= $editing_data['discount_amount']; ?>">
                                <select class="form-control chosen-select" name="_sold_currency">
                                    <option disabled="" selected="">-- <?= print_lang($app_lang,'currency'); ?> --</option>
                                    <?php foreach($currencies as $row){ ?>
                                        <option <?php if($editing_data['currency'] == $row['uid']){ echo 'selected="selected"'; } ?> value="<?= $row['uid']; ?>" data-usd-equalance="<?= $row['usd_equalance']; ?>"><?= $row['name']; ?> (<?= $row['symbol']; ?>)</option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'client'); ?> <strong class="text-danger">*</strong></label>
                                <select class="form-control chosen-select" name="_sold_client">
                                    <option disabled="" selected="">-- <?= print_lang($app_lang,'client'); ?> --</option>
                                    <?php foreach($clients as $row){ ?>
                                        <option <?php if($editing_data['client'] == $row['uid']){ echo 'selected="selected"'; } ?> value="<?= $row['uid']; ?>"><?= $row['name']; ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'invoice'); ?></label>
                                <select class="form-control chosen-select" name="_sold_invoice">
                                    <option disabled="" selected="">-- <?= print_lang($app_lang,'invoice'); ?> --</option>
                                    <?php foreach($sold_invoices as $row){ ?>
                                        <?php
                                        $inv_selected = NULL;
                                        $inv_display = 'class="display-none"';
                                        if($editing_data['client'] == $row['client'] AND $editing_data['currency'] == $row['currency'])
                                        {
                                            $inv_display =  NULL;
                                            if($editing_data['invoice'] == $row['invoice']){ $inv_selected = 'selected="selected"'; }
                                        }
                                        ?>
                                        <option <?= $inv_display; ?> <?= $inv_selected; ?> data-client="<?= $row['client']; ?>" data-currency="<?= $row['currency']; ?>" value="<?= $row['invoice']; ?>"><?= $row['invoice']; ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="row extra-mar-botm">
                        <div class="col-md-2">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'weight'); ?></label>
                                <input type="text" class="form-control pointer-none" name="_sold_weight" value="<?= $editing_data['weight']; ?>" placeholder="<?= print_lang($app_lang,'weight'); ?>">
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="row">
                                <div class="col-md-7">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'difference'); ?></label>
                                        <select class="form-control chosen-select" name="_sold_difference_type">
                                            <option value="plus" <?php if($editing_data['difference_type'] == 'plus'){ echo 'selected="selected"'; } ?>><?= print_lang($app_lang,'plus'); ?></option>
                                            <option value="minus" <?php if($editing_data['difference_type'] == 'minus'){ echo 'selected="selected"'; } ?>><?= print_lang($app_lang,'minus'); ?></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-5">
                                    <div class="form-group">
                                        <label style="opacity: 0; color: transparent;">-</label>
                                        <input type="text" class="form-control" name="_sold_difference" value="<?= $editing_data['difference']; ?>" placeholder="<?= print_lang($app_lang,'amount'); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'gross_weight'); ?></label>
                                <input type="text" class="form-control pointer-none" name="_sold_gross_weight" value="<?= $editing_data['gross_weight']; ?>" placeholder="<?= print_lang($app_lang,'gross_weight'); ?>">
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'mod_lot_sale_popup_input_saqlat'); ?> </label>
                                <input type="text" class="form-control" name="_saqlat" value="<?= $editing_data['saqlat']; ?>" placeholder="<?= print_lang($app_lang,'mod_lot_sale_popup_input_saqlat'); ?>">
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'mod_lot_sale_popup_input_liters_qty'); ?> </label>
                                <input type="text" class="form-control" name="_litres_qty" value="<?= $editing_data['litres_qty']; ?>" placeholder="<?= print_lang($app_lang,'mod_lot_sale_popup_input_liters_qty'); ?>" readonly>
                            </div>
                        </div>

                    </div>

                    <div class="row extra-mar-botm">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'sale_price'); ?> <strong class="text-danger">*</strong></label>
                                <input type="text" class="form-control" name="_sold_sale_price" value="<?= $editing_data['sale_price']; ?>" placeholder="<?= print_lang($app_lang,'sale_price'); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'profit'); ?></label>
                                <input type="text" class="form-control pointer-none" name="_sold_profit" value="<?= $editing_data['profit']; ?>" placeholder="<?= print_lang($app_lang,'profit'); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'total_profit'); ?></label>
                                <input type="text" class="form-control pointer-none" name="_sold_total_profit" value="<?= $editing_data['total_profit']; ?>" placeholder="<?= print_lang($app_lang,'total_profit'); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'total'); ?></label>
                                <input type="text" class="form-control pointer-none" name="_sold_total" value="<?= $editing_data['total']; ?>" placeholder="<?= print_lang($app_lang,'total'); ?>">
                            </div>
                        </div>
                    </div>

                    <div class="row extra-mar-botm">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'discount'); ?></label>
                                <input type="text" class="form-control" name="_sold_discount" value="<?= $editing_data['discount']; ?>" placeholder="<?= print_lang($app_lang,'discount'); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'gross_amount'); ?></label>
                                <input type="text" class="form-control pointer-none" name="_sold_gross_amount" value="<?= $editing_data['gross_amount']; ?>" placeholder="<?= print_lang($app_lang,'gross_amount'); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'cash'); ?></label>
                                <input type="text" class="form-control" name="_sold_cash" value="<?= $editing_data['cash']; ?>" placeholder="<?= print_lang($app_lang,'cash'); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?= print_lang($app_lang,'cash_account'); ?></label>
                                <select class="form-control chosen-select" name="_sold_cash_account">
                                    <option disabled="" selected="">-- <?= print_lang($app_lang,'account'); ?> --</option>
                                    <?php foreach($accounts as $row){ ?>
                                    <?php if($row['type'] == 'bank' OR $row['type'] == 'cashbook'){?>
                                        <option <?php if($editing_data['cash_account'] == $row['uid']){ echo 'selected="selected"'; } ?> value="<?= $row['uid']; ?>"><?= $row['name']; ?></option>
                                    <?php }} ?>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="row extra-mar-botm">
                        <div class="col-md-12 text-right">
                            <a class="btn btn-w-m btn-outline btn-danger url-elem" href="<?php echo url('/lot-purchase/sold'); ?>"><?= print_lang($app_lang,'cancel'); ?></a>
                            <button class="btn btn-w-m btn-primary" type="submit"><?= print_lang($app_lang,'update'); ?></button>
                        </div>
                    </div>

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

</div>