<?php
$is_modal = !empty($is_modal);
$quotation_show_quantity_as = '';
if (!empty($quotations_info) && isset($quotations_info->show_quantity_as)) {
    $quotation_show_quantity_as = (string) $quotations_info->show_quantity_as;
}
$quotation_discount_type = !empty($quotations_info) && isset($quotations_info->discount_type)
    ? (string) $quotations_info->discount_type
    : '';

$reference_no = '';
if (empty(config_item('estimate_number_format'))) {
    $reference_no .= config_item('estimate_prefix');
}
if (config_item('increment_estimate_number') == 'FALSE') {
    $this->load->helper('string');
    $reference_no .= random_string('nozero', 6);
} else {
    $reference_no .= $this->quotations_model->generate_estimate_number();
}

$estimate_date = !empty($quotations_info->proposal_date) ? $quotations_info->proposal_date : date('Y-m-d');
$due_date = !empty($quotations_info->due_date) ? $quotations_info->due_date : date('Y-m-d');

$client_id = '';
if (!empty($project_info) && !empty($project_info->client_id)) {
    $client_id = $project_info->client_id;
} elseif (!empty($quotations_info) && !empty($quotations_info->client_id)) {
    $client_id = $quotations_info->client_id;
}

$project_id = '';
if (!empty($project_info) && !empty($project_info->project_id)) {
    $project_id = $project_info->project_id;
} elseif (!empty($quotations_info) && !empty($quotations_info->project_id)) {
    $project_id = $quotations_info->project_id;
}

$client_options = array('-' => lang('select') . ' ' . lang('client'));
if (!empty($all_client)) {
    foreach ($all_client as $v_client) {
        $client_options[$v_client->client_id] = $v_client->name;
    }
}

$project_options = array('' => lang('none'));
if (!empty($client_id) && $client_id !== '-') {
    $all_project = $this->db->where('client_id', $client_id)->get('tbl_project')->result();
    if (!empty($all_project)) {
        foreach ($all_project as $v_project) {
            $project_options[$v_project->project_id] = $v_project->project_name;
        }
    }
}

$all_user = $this->db->where('role_id != ', 2)->order_by('sort_user', 'ASC')->get('tbl_users')->result();
$agent_options = array('' => lang('select') . ' ' . lang('sales') . ' ' . lang('agent'));
if (!empty($all_user)) {
    foreach ($all_user as $v_user) {
        $profile_info = $this->db->where('user_id', $v_user->user_id)->get('tbl_account_details')->row();
        if (!empty($profile_info)) {
            $agent_options[$v_user->user_id] = $profile_info->fullname;
        }
    }
}
$selected_agent = !empty($quotations_info->reviewer_id) ? $quotations_info->reviewer_id : $this->session->userdata('user_id');

$notes_value = !empty($quotations_info->notes) ? $quotations_info->notes : $this->config->item('default_terms');

$discount_options = array(
    '' => lang('no') . ' ' . lang('discount'),
    'before_tax' => lang('before_tax'),
    'after_tax' => lang('after_tax'),
);

$status_options = array(
    'draft' => lang('draft'),
    'sent' => lang('sent'),
    'expired' => lang('expired'),
    'declined' => lang('declined'),
    'accepted' => lang('accepted'),
    'pending' => lang('pending'),
    'cancelled' => lang('cancelled'),
);
$status_selected = 'draft';

$permissionL = !empty($quotations_info->permission) ? $quotations_info->permission : null;
$back_url = !empty($quotations_info->quotations_id) ? base_url('admin/quotations/quotations_details/' . $quotations_info->quotations_id) : base_url('admin/quotations');
?>
<?php if (!$is_modal) { ?>
<div class="space-y-6">
    <div class="rounded-2xl border border-border bg-card p-6 shadow-sm">
        <div class="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
            <div>
                <p class="text-xs font-semibold uppercase tracking-wide text-muted-foreground"><?= lang('quotations') ?></p>
                <h1 class="text-2xl font-semibold text-foreground"><?= lang('convert_to_estimate') ?></h1>
                <p class="text-sm text-muted-foreground"><?= !empty($quotations_info->quotations_form_title) ? html_escape($quotations_info->quotations_form_title) : lang('estimate') ?></p>
            </div>
            <a href="<?= $back_url ?>" class="inline-flex items-center gap-2 rounded-lg border border-border bg-card px-3 py-2 text-sm font-medium text-foreground hover:bg-muted">
                <i data-lucide="arrow-left" class="h-4 w-4"></i>
                <?= lang('quotation_details') ?>
            </a>
        </div>
    </div>
    <div class="rounded-2xl border border-border bg-card p-6 shadow-sm">
<?php } ?>
<?php if ($is_modal) { ?>
<div class="panel panel-custom">
    <div class="modal-body wrap-modal wrap">
<?php } ?>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.js"></script>

        <script type="text/javascript">
            $(document).ready(function() {
                init_items_sortable();
            });
        </script>
        <form role="form" data-parsley-validate="" novalidate="" action="<?php echo base_url(); ?>admin/quotations/converted_to_estimate/<?= $quotations_info->quotations_id ?>" method="post" class="invoice-convert-modern form-horizontal form-groups-bordered">
            <div class="grid gap-8">
                <div class="bg-slate-50 p-4 rounded-xl border border-slate-200 dark:bg-slate-800 dark:border-slate-700">
                    <div class="row mb-lg invoice-accounting-template">
                        <div class="col-xs-8 br pv">
                            <section class="rounded-xl border border-border bg-card p-4 space-y-5">
                                <div class="flex flex-wrap items-center justify-between gap-3 border-b border-border pb-3">
                                    <div class="flex items-center gap-2 text-sm font-semibold text-foreground">
                                        <i data-lucide="file-text" class="h-5 w-5"></i>
                                        <h2 class="text-base font-semibold text-foreground"><?= lang('estimate') . ' ' . lang('details') ?></h2>
                                    </div>
                                </div>

                                <div class="grid grid-cols-1 gap-5 md:grid-cols-2">
                                    <?= form_input_group('reference_no', lang('reference_no'), $reference_no, 'text', true, array('placeholder' => lang('reference_no'))); ?>
                                    <?= form_datepicker('estimate_date', lang('estimate_date'), $estimate_date, true, array('id' => 'estimate_date', 'data-max' => '#due_date', 'data-auto-close' => 'true')); ?>
                                    <?= form_datepicker('due_date', lang('due_date'), $due_date, true, array('id' => 'due_date', 'data-min' => '#estimate_date', 'data-auto-close' => 'true')); ?>
                                    <?= form_select_group('discount_type', lang('discount_type'), $discount_options, $quotation_discount_type, false, array('data-discount-type' => '1')); ?>
                                    <?= form_select_group('client_id', lang('client'), $client_options, $client_id, true, array('class' => 'select_box', 'id' => 'client_id', 'onchange' => 'get_project_by_id(this.value)', 'data-width' => '100%')); ?>
                                    <?= form_select_group('project_id', lang('project'), $project_options, $project_id, false, array('class' => 'select_box', 'id' => 'client_project', 'data-width' => '100%')); ?>
                                </div>
                            </section>
                        </div>

                        <div class="col-xs-4 br pv">
                            <section class="rounded-xl border border-border bg-card p-4 space-y-5">
                                <div class="flex items-center gap-2 text-sm font-semibold text-foreground border-b border-border pb-2">
                                    <i data-lucide="settings" class="h-5 w-5"></i>
                                    <h2 class="text-base font-semibold text-foreground"><?= lang('settings') ?></h2>
                                </div>

                                <div class="grid grid-cols-1 gap-4">
                                    <?= form_select_group('status', lang('status'), $status_options, $status_selected, false, array('class' => 'select_box', 'data-width' => '100%')); ?>
                                    <?= form_select_group('user_id', lang('sales') . ' ' . lang('agent'), $agent_options, $selected_agent, true, array('class' => 'select_box', 'data-width' => '100%')); ?>
                                </div>

                                <?= form_permission_modern($permission_user, $permissionL); ?>
                            </section>
                        </div>

                        <div class="col-sm-12 mt-4">
                            <section class="rounded-xl border border-border bg-card p-4">
                                <?= form_editor('notes', lang('notes'), $notes_value, false); ?>
                            </section>
                        </div>
                    </div>
                </div>
            <?php
            if (!empty($quotations_info->client_id)) {
                $client_info = $this->quotations_model->check_by(array('client_id' => $quotations_info->client_id), 'tbl_client');
                if (!empty($client_info)) {
                    $currency = $this->quotations_model->client_currency_symbol($quotations_info->client_id);
                    $client_lang = $client_info->language;
                } else {
                    $client_lang = 'english';
                    $currency = $this->quotations_model->check_by(array('code' => config_item('default_currency')), 'tbl_currencies');
                }
            } else {
                $client_lang = 'english';
                $currency = $this->quotations_model->check_by(array('code' => config_item('default_currency')), 'tbl_currencies');
            }
            unset($this->lang->is_loaded[5]);
            $language_info = $this->lang->load('sales_lang', $client_lang, TRUE, FALSE, '', TRUE);
            ?>
            <style type="text/css">
                .invoice-convert-modern .invoice-accounting-template {
                    margin: 0;
                    display: grid;
                    grid-template-columns: minmax(0, 1fr);
                    gap: 1rem;
                }

                .invoice-convert-modern .invoice-accounting-template > [class*="col-"] {
                    float: none;
                    width: 100%;
                    border-right: 0 !important;
                    padding-left: 0;
                    padding-right: 0;
                }

                .invoice-convert-modern .invoice-accounting-template .row {
                    margin-left: 0;
                    margin-right: 0;
                }

                .invoice-convert-modern .invoice-accounting-template .form-group {
                    margin-bottom: 14px;
                }

                .invoice-convert-modern .invoice-accounting-template .form-group > [class*="col-"] {
                    float: none;
                    width: 100%;
                    padding-left: 0;
                    padding-right: 0;
                }

                .invoice-convert-modern .invoice-accounting-template .control-label {
                    display: block;
                    width: 100%;
                    text-align: left;
                    padding-top: 0;
                    margin-bottom: 6px;
                    font-size: 13px;
                    font-weight: 600;
                    color: hsl(var(--foreground));
                }

                .invoice-convert-modern .invoice-accounting-template .form-control,
                .invoice-convert-modern .invoice-accounting-template .select2-selection,
                .invoice-convert-modern .invoice-accounting-template .bootstrap-select .dropdown-toggle {
                    width: 100% !important;
                    border-color: hsl(var(--border));
                    border-radius: 10px;
                    min-height: 38px;
                    background: hsl(var(--input));
                    box-shadow: none;
                }

                .invoice-convert-modern .invoice-accounting-template .input-group {
                    display: flex;
                    width: 100%;
                }

                .invoice-convert-modern .invoice-accounting-template .input-group .form-control {
                    border-top-right-radius: 0;
                    border-bottom-right-radius: 0;
                }

                .invoice-convert-modern .invoice-accounting-template .input-group-addon {
                    border-color: hsl(var(--border));
                    border-radius: 0 10px 10px 0;
                    background: hsl(var(--muted));
                    color: hsl(var(--muted-foreground));
                    min-width: 40px;
                }

                .invoice-convert-modern .invoice-accounting-template .col-sm-12 > div > [class*="col-"] {
                    float: none;
                    width: 100%;
                    padding-left: 0;
                    padding-right: 0;
                }

                .dropdown-menu>li>a {
                    white-space: normal;
                }

                .dragger {
                    background: url(../../../../assets/img/dragger.png) 10px 32px no-repeat;
                    cursor: pointer;
                }

                <?php if (!empty($quotations_info)) { ?>.dragger {
                    background: url(../../../../assets/img/dragger.png) 10px 32px no-repeat;
                    cursor: pointer;
                }

                <?php } ?>.input-transparent {
                    box-shadow: none;
                    outline: 0;
                    border: 0 !important;
                    background: 0 0;
                    padding: 3px;
                }

                @media (min-width: 1024px) {
                    .invoice-convert-modern .invoice-accounting-template {
                        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
                    }

                    .invoice-convert-modern .invoice-accounting-template > .col-sm-12 {
                        grid-column: 1 / -1;
                    }
                }
            </style>
            <?php
            $saved_items = $this->quotations_model->get_all_items();
            ?>
            <div class="row">
                <div class="col-md-4">
                    <div class="form-group">
                        <select name="item_select" class="selectpicker m0" data-width="100%" id="item_select" data-none-selected-text="<?php echo lang('add_items'); ?>" data-live-search="true">
                            <option value=""></option>
                            <?php
                            if (!empty($saved_items)) {
                                $saved_items = array_reverse($saved_items);
                                foreach ($saved_items as $group_id => $v_saved_items) {
                                    if ($group_id != 0) {
                                        $group = $this->db->where('customer_group_id', $group_id)->get('tbl_customer_group')->row()->customer_group;
                                    } else {
                                        $group = '';
                                    }
                            ?>
                                    <optgroup data-group-id="<?php echo $group_id; ?>" label="<?php echo $group; ?>">
                                        <?php
                                        if (!empty($v_saved_items)) {
                                            foreach ($v_saved_items as $v_item) { ?>
                                                <option value="<?php echo $v_item->saved_items_id; ?>" data-subtext="<?php echo strip_html_tags(mb_substr($v_item->item_desc, 0, 200)) . '...'; ?>">
                                                    (<?= display_money($v_item->unit_cost, $currency->symbol); ?>
                                                    ) <?php echo $v_item->item_name; ?></option>
                                        <?php }
                                        }
                                        ?>
                                    </optgroup>

                                <?php } ?>

                            <?php
                                $item_created = can_action('39', 'created');
                                if (!empty($item_created)) { ?>
                                    <option data-divider="true"></option>
                                    <option value="newitem" data-content="<span class='text-info'><?php echo lang('new_item'); ?></span>"></option>
                                <?php } ?>
                            <?php
                            }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="col-md-5 pull-right">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><?php echo lang('show_quantity_as'); ?></label>
                        <div class="col-sm-8">
                            <label class="radio-inline c-radio">
                                <input type="radio" value="qty" id="<?php echo lang('qty'); ?>" name="show_quantity_as" <?php if ($quotation_show_quantity_as === 'qty') {
                                                                                                                            echo 'checked';
                                                                                                                        } else if (!isset($hours_quantity) && !isset($qty_hrs_quantity)) {
                                                                                                                            echo 'checked';
                                                                                                                        } ?>>
                                <span data-lucide="circle"></span><?php echo lang('qty'); ?>
                            </label>
                            <label class="radio-inline c-radio">
                                <input type="radio" value="hours" id="<?php echo lang('hours'); ?>" name="show_quantity_as" <?php if ($quotation_show_quantity_as === 'hours' || isset($hours_quantity)) {
                                                                                                                                echo 'checked';
                                                                                                                            } ?>>
                                <span data-lucide="circle"></span><?php echo lang('hours'); ?>
                            </label>
                            <label class="radio-inline c-radio">
                                <input type="radio" value="qty_hours" id="<?php echo lang('qty') . '/' . lang('hours'); ?>" name="show_quantity_as" <?php if ($quotation_show_quantity_as === 'qty_hours' || isset($qty_hrs_quantity)) {
                                                                                                                                                        echo 'checked';
                                                                                                                                                    } ?>>
                                <span data-lucide="circle"></span><?php echo lang('qty') . '/' . lang('hours'); ?>
                            </label>
                        </div>
                    </div>
                </div>

                <div class="table-responsive s_table">
                    <table class="table invoice-items-table items">
                        <thead style="background: #e8e8e8">
                            <tr>
                                <th></th>
                                <th><?= $language_info['item_name'] ?></th>
                                <th><?= $language_info['description'] ?></th>
                                <?php
                                $invoice_view = config_item('invoice_view');
                                if (!empty($invoice_view) && $invoice_view == '2') {
                                ?>
                                    <th class="col-sm-2"><?= $language_info['hsn_code'] ?></th>
                                <?php } ?>
                                <?php
                                $qty_heading = $language_info['qty'];
                                if ($quotation_show_quantity_as === 'hours' || isset($hours_quantity)) {
                                    $qty_heading = lang('hours');
                                } else if ($quotation_show_quantity_as === 'qty_hours') {
                                    $qty_heading = lang('qty') . '/' . lang('hours');
                                }
                                ?>
                                <th class="qty col-sm-1"><?php echo $qty_heading; ?></th>
                                <th class="col-sm-2"><?= $language_info['price'] ?></th>
                                <th class="col-sm-2"><?= $language_info['tax_rate'] ?> </th>
                                <th class="col-sm-1"><?= $language_info['total'] ?></th>
                                <th class="col-sm-1 hidden-print"><?= $language_info['action'] ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (isset($quotations_info)) {
                                echo form_hidden('merge_current_invoice', $quotations_info->quotations_id);
                                echo form_hidden('isedit', $quotations_info->quotations_id);
                            }
                            ?>
                            <tr class="main">
                                <td></td>
                                <td>
                                    <textarea name="item_name" class="form-control" placeholder="<?php echo lang('item_name'); ?>"></textarea>
                                </td>
                                <td>
                                    <textarea name="item_desc" class="form-control" placeholder="<?php echo lang('description'); ?>"></textarea>
                                </td>
                                <?php
                                $invoice_view = config_item('invoice_view');
                                if (!empty($invoice_view) && $invoice_view == '2') {
                                ?>
                                    <td><input type="text" name="hsn_code" class="form-control"></td>
                                <?php } ?>
                                <td>
                                    <input type="text" data-parsley-type="number" name="quantity" min="0" value="1" class="form-control" placeholder="<?php echo lang('qty'); ?>">
                                    <input type="text" placeholder="<?php echo lang('unit') . ' ' . lang('type'); ?>" name="unit" class="form-control input-transparent">
                                </td>
                                <td>
                                    <input type="hidden" name="new_itmes_id" class="form-control">
                                    <input type="hidden" name="saved_items_id" class="form-control">
                                    <input type="text" data-parsley-type="number" min="0" value="1" name="unit_cost" class="form-control" placeholder="<?php echo lang('price'); ?>">
                                </td>
                                <td>
                                    <?php
                                    $taxes = $this->db->order_by('tax_rate_percent', 'ASC')->get('tbl_tax_rates')->result();
                                    $default_tax = config_item('default_tax');
                                    if (!is_numeric($default_tax)) {
                                        $default_tax = unserialize($default_tax);
                                    }
                                    $select = '<select class="selectpicker tax main-tax" data-width="100%" name="taxname" multiple data-none-selected-text="' . lang('no_tax') . '">';
                                    foreach ($taxes as $tax) {
                                        $selected = '';
                                        if (!empty($default_tax) && is_array($default_tax)) {
                                            if (in_array($tax->tax_rates_id, $default_tax)) {
                                                $selected = ' selected ';
                                            }
                                        }
                                        $select .= '<option value="' . $tax->tax_rate_name . '|' . $tax->tax_rate_percent . '"' . $selected . 'data-taxrate="' . $tax->tax_rate_percent . '" data-taxname="' . $tax->tax_rate_name . '" data-subtext="' . $tax->tax_rate_name . '">' . $tax->tax_rate_percent . '%</option>';
                                    }
                                    $select .= '</select>';
                                    echo $select;
                                    ?>
                                </td>
                                <td></td>
                                <td>
                                    <?php
                                    $new_item = 'undefined';
                                    if (isset($quotations_info)) {
                                        $new_item = true;
                                    }
                                    ?>
                                    <button type="button" onclick="add_item_to_table('undefined','undefined',<?php echo $new_item; ?>); return false;" class="btn-xs btn btn-info"><i data-lucide="check"></i>
                                    </button>
                                </td>
                            </tr>
                            <?php if (isset($quotations_info) || isset($add_items)) {
                                $i = 1;
                                $items_indicator = 'items';
                                if (isset($quotations_info)) {
                                    $add_items = [
                                        [
                                            'proposals_items_id' => 0,
                                            'item_name' => $quotations_info->quotations_form_title,
                                            'unit_cost' => $quotations_info->quotations_amount,
                                            'item_desc' => '[quotations]' . ' ' . $quotations_info->quotations_form_title,
                                            'hsn_code' => '',
                                            'unit' => '',
                                            'quantity' => 1,
                                        ]
                                    ];
                                    $items_indicator = 'items';
                                }
                                foreach ($add_items as $item) {
                                    $item = (object) $item;
                                    $manual = false;
                                    $table_row = '<tr class="sortable item">';
                                    $table_row .= '<td class="dragger">';
                                    if (!is_numeric($item->quantity)) {
                                        $item->quantity = 1;
                                    }
                                    $invoice_item_taxes = $this->quotations_model->get_invoice_item_taxes($item->proposals_items_id, 'proposal');
                                    if (!is_array($invoice_item_taxes)) {
                                        $invoice_item_taxes = array();
                                    }

                                    // passed like string
                                    if ($item->proposals_items_id == 0) {
                                        $invoice_item_taxes = isset($invoice_item_taxes[0]) ? $invoice_item_taxes[0] : array();
                                        $manual = true;
                                    }
                                    $table_row .= form_hidden('' . $items_indicator . '[' . $i . '][estimate_items_id]', $item->proposals_items_id);
                                    $amount = $item->unit_cost * $item->quantity;
                                    $amount = ($amount);
                                    // order input
                                    $table_row .= '<input type="hidden" class="order" name="' . $items_indicator . '[' . $i . '][order]"><input type="hidden" name="estimate_items_id[]" value="' . $item->proposals_items_id . '">';
                                    $table_row .= '</td>';
                                    $table_row .= '<td class="bold item_name"><textarea name="' . $items_indicator . '[' . $i . '][item_name]" class="form-control">' . $item->item_name . '</textarea></td>';
                                    $table_row .= '<td><textarea name="' . $items_indicator . '[' . $i . '][item_desc]" class="form-control" >' . $item->item_desc . '</textarea></td>';
                                    $invoice_view = config_item('invoice_view');
                                    if (!empty($invoice_view) && $invoice_view == '2') {
                                        $table_row .= '<td><input type="text" name="' . $items_indicator . '[' . $i . '][hsn_code]" class="form-control" value="' . $item->hsn_code . '"></td>';
                                    }
                                    $table_row .= '<td><input type="text" data-parsley-type="number" min="0" onblur="calculate_total();" onchange="calculate_total();" data-quantity name="' . $items_indicator . '[' . $i . '][quantity]" value="' . $item->quantity . '" class="form-control">';
                                    $unit_placeholder = '';
                                    if (!$item->unit) {
                                        $unit_placeholder = lang('unit');
                                        $item->unit = '';
                                    }
                                    $table_row .= '<input type="text" placeholder="' . $unit_placeholder . '" name="' . $items_indicator . '[' . $i . '][unit]" class="form-control input-transparent text-right" value="' . $item->unit . '">';
                                    $table_row .= '</td>';
                                    $table_row .= '<td class="rate"><input type="text" data-parsley-type="number"  onblur="calculate_total();" onchange="calculate_total();" name="' . $items_indicator . '[' . $i . '][unit_cost]" value="' . $item->unit_cost . '" class="form-control"></td>';
                                    $table_row .= '<td class="taxrate">' . $this->admin_model->get_taxes_dropdown('' . $items_indicator . '[' . $i . '][taxname][]', $invoice_item_taxes, 'invoice', $item->proposals_items_id, true, $manual) . '</td>';
                                    $table_row .= '<td class="amount">' . $amount . '</td>';
                                    $table_row .= '<td><a href="#" class="btn-xs btn btn-danger pull-left" onclick="delete_item(this,' . $item->proposals_items_id . '); return false;"><i data-lucide="trash-2"></i></a></td>';
                                    $table_row .= '</tr>';
                                    echo $table_row;
                                    $i++;
                                }
                            }
                            ?>

                        </tbody>
                    </table>
                </div>

                <div class="row">
                    <div class="col-xs-8 pull-right">
                        <table class="table text-right">
                            <tbody>
                                <tr id="subtotal">
                                    <td><span class="bold"><?php echo lang('sub_total'); ?> :</span>
                                    </td>
                                    <td class="subtotal">
                                    </td>
                                </tr>
                                <tr id="discount_percent">
                                    <td>
                                        <div class="row">
                                            <div class="col-md-7">
                                                <span class="bold"><?php echo lang('discount'); ?>
                                                    (%)</span>
                                            </div>
                                            <div class="col-md-5">
                                                <?php
                                                $discount_percent = 0;
                                                if (!empty($quotations_info) && isset($quotations_info->discount_percent) && $quotations_info->discount_percent != 0) {
                                                    $discount_percent = $quotations_info->discount_percent;
                                                }
                                                ?>
                                                <input type="text" data-parsley-type="number" value="<?php echo $discount_percent; ?>" class="form-control pull-left" min="0" max="100" name="discount_percent">
                                            </div>
                                        </div>
                                    </td>
                                    <td class="discount_percent"></td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="row">
                                            <div class="col-md-7">
                                                <span class="bold"><?php echo lang('adjustment'); ?></span>
                                            </div>
                                            <div class="col-md-5">
                                                <input type="text" data-parsley-type="number" value="<?php if (isset($quotations_info->adjustment)) {
                                                                                                            echo $quotations_info->adjustment;
                                                                                                        } else {
                                                                                                            echo 0;
                                                                                                        } ?>" class="form-control pull-left" name="adjustment">
                                            </div>
                                        </div>
                                    </td>
                                    <td class="adjustment"></td>
                                </tr>
                                <tr>
                                    <td><span class="bold"><?php echo lang('total'); ?> :</span>
                                    </td>
                                    <td class="total">
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div id="removed-items"></div>
                <div class="modal-footer flex items-center justify-end gap-3 mt-6 border-t border-border/60 pt-4">
                    <?php if ($is_modal) { ?>
                        <button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><?= lang('close') ?></button>
                    <?php } else { ?>
                        <a href="<?= $back_url ?>" class="btn btn-default btn-sm"><?= lang('close') ?></a>
                    <?php } ?>
                    <input type="submit" value="<?= lang('save') ?>" name="update" class="btn btn-success btn-sm">
                </div>
                </div>
            </div>
        </form>
<?php if (!$is_modal) { ?>
    </div>
</div>
<?php } else { ?>
    </div>
</div>
<?php } ?>
