<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,'add_new_car_purchase'); ?></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('/car-purchases'); ?>"><?= print_lang($app_lang,'car_purchases'); ?></a>
            </li>
            <li class="active">
                <strong><?= print_lang($app_lang,'add_car_purchase'); ?></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="temp-car-purchases-form">

                    <div class="row " style="margin-bottom: 5px;">
                        <div class="col-md-7">
                            <div class="row">
                                <div class="col-md-4 fixed-fields-input">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'currency'); ?> <strong class="text-danger">*</strong></label>
                                        <select class="form-control chosen-select" name="temp_currency" >
                                            <option disabled="" selected="">-- <?= print_lang($app_lang,'select_currency'); ?> --</option>
                                            <?php foreach($currencies as $row){ ?>
                                                <option value="<?= $row['uid']; ?>"><?= $row['name']; ?> (<?= $row['symbol']; ?>)</option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-4 fixed-fields-input">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'agent'); ?> <strong class="text-danger">*</strong></label>
                                        <select class="form-control chosen-select" name="temp_agent" >
                                            <option disabled="" selected="">-- <?= print_lang($app_lang,'select_agent'); ?> --</option>
                                            <?php foreach($suppliers as $row){ ?>
                                                <option value="<?= $row['uid']; ?>"><?= $row['name']; ?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-4 fixed-fields-input">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'invoice'); ?> <strong class="text-danger">*</strong></label>
                                        <input type="text" class="form-control" name="temp_invoice" value="<?= $invoice_num; ?>"  placeholder="<?= print_lang($app_lang,'invoice_#'); ?>" readonly>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-5">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'car_name'); ?> <strong class="text-danger">*</strong></label>
                                        <input type="text" class="form-control" name="temp_car_name" placeholder="<?= print_lang($app_lang,'car_name'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'car_model'); ?> <strong class="text-danger">*</strong></label>
                                        <input type="text" class="form-control" name="temp_car_model" placeholder="<?= print_lang($app_lang,'car_model'); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>                    

                    <div class="row" style="margin-bottom: 5px;">
                        <div class="col-md-7">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'shasi_num'); ?></label>
                                        <input type="text" class="form-control" name="temp_shasi_num" placeholder="<?= print_lang($app_lang,'shasi_num'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'car_color'); ?> <strong class="text-danger">*</strong></label>
                                        <input type="text" class="form-control" name="temp_car_color" placeholder="<?= print_lang($app_lang,'car_color'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'car_makes'); ?> <strong class="text-danger">*</strong></label>
                                        <input type="text" class="form-control" name="temp_car_make" placeholder="<?= print_lang($app_lang,'car_makes'); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-5">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'expense_details'); ?></label>
                                        <input type="text" class="form-control" name="temp_expense_details" placeholder="<?= print_lang($app_lang,'expense_details'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'car_image'); ?></label>
                                        <input type="file" class="form-control" name="temp_car_image">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row" style="margin-bottom: 5px;">
                        <div class="col-md-7">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'cost'); ?> <strong class="text-danger">*</strong></label>
                                        <input type="text" class="form-control in-calculation" name="temp_cost" placeholder="<?= print_lang($app_lang,'cost'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'transfer_exp'); ?></label>
                                        <input type="text" class="form-control in-calculation" name="temp_transfer_exp" placeholder="<?= print_lang($app_lang,'transfer_exp'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'agent_commission'); ?></label>
                                        <input type="text" class="form-control in-calculation" name="temp_agent_commission" placeholder="<?= print_lang($app_lang,'agent_commission'); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-5">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'other_expenses'); ?></label>
                                        <input type="text" class="form-control in-calculation" name="temp_other_expenses" placeholder="<?= print_lang($app_lang,'other_expenses'); ?>">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label><?= print_lang($app_lang,'total_amount'); ?></label>
                                        <input type="text" class="form-control" name="temp_total_amount" placeholder="<?= print_lang($app_lang,'total_amount'); ?>" readonly>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row extra-mar-botm">
                        <div class="col-md-12 text-right">
                            <button style="width: 100%;" class="btn btn-w-m btn-primary" type="submit"><?= print_lang($app_lang,'add_to_purchase'); ?></button>
                        </div>
                    </div>

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

        <form role="form" id="car-purchases-form" action="<?php echo url('/car-purchases/save'); ?>">
            <div class="row" style="margin-top: 10px;">
                <div class="col-md-12">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th class="text-center"><?= print_lang($app_lang,'car_name'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'car_model'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'shasi_num'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'color'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'make'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'cost'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'transfer_exp'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'agent_commission'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'other_expenses'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'total'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'action'); ?></th>
                                </tr>
                            </thead>
                            <tbody id="car-purchases-table-body">
                                
                            </tbody>
                        </table>    
                    </div>
                </div>

                <div class="col-md-12"><hr></div>
                <div class="col-md-12 car-purchases-totals-col">
                    <div class="row">
                        <div class="col-md-7">
                            <div class="row">
                                <div class="col-md-4 purchase-total-cel purchases-total-cost-row">
                                    <strong><?= print_lang($app_lang,'total_cost'); ?>: </strong>
                                    <span class="cals-span"></span>
                                    <input class="cals-input" type="hidden" name="total_cost">
                                </div>
                                <div class="col-md-4 purchase-total-cel purchases-transfer-exp-row">
                                    <strong><?= print_lang($app_lang,'total_transfer_exp'); ?>: </strong>
                                    <span class="cals-span"></span>
                                    <input class="cals-input" type="hidden" name="total_transfer_expenses">
                                </div>
                                <div class="col-md-4 purchase-total-cel purchases-total-agent-commission-row">
                                    <strong><?= print_lang($app_lang,'total_agent_commission'); ?>: </strong>
                                    <span class="cals-span"></span>
                                    <input class="cals-input" type="hidden" name="total_agent_commission">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-5">
                            <div class="row">
                                <div class="col-md-6 purchase-total-cel purchases-total-other-expenses-row">
                                    <strong><?= print_lang($app_lang,'total_other_expenses'); ?>: </strong>
                                    <span class="cals-span"></span>
                                    <input class="cals-input" type="hidden" name="total_other_expenses">
                                </div>
                                <div class="col-md-6 purchase-total-cel purchases-grand-total-amount-row">
                                    <strong><?= print_lang($app_lang,'grand_total'); ?>: </strong>
                                    <span class="cals-span"></span>
                                    <input class="cals-input" type="hidden" name="grand_total">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-12"><hr></div>

                <div class="col-md-12" style="margin-top: 20px;">
                    <input type="submit" style="width: 100%;" class="btn btn-primary" value="<?= print_lang($app_lang,'save_print'); ?>">
                </div>

            </div>
        </form>

    </div>

</div>