<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">استيراد السيارات</a></li>
            <li><a href="carTrackingController.php?do=show">تتبع مسار السيارات </a></li>
            <li class="active">تعديل</li>
        </ol>


        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">تعديل</h3>
            </div>
            <div class="panel-body">


                {literal}
                <form class="form-horizontal" action="carTrackingController.php?do=savedata" method="post"
                    enctype="multipart/form-data">
                    {/literal}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">الشاسيه </label>
                        <div class="col-lg-4">
                            <select name="chasis" id="chasis" data-placeholder="اختر " class="select2">
                                <option>اختر الشاسيه</option>
                                {foreach $allChasis as $single}
                                <option value="{$single.chasisno}" {if $trackingData.chasis eq $single.chasisno}selected{/if}>{$single.chasisno}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <hr />
                    <table class="table table-bordered table-black">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>الحالة</th>
                                <th>التاريخ</th>
                                <th>تعليق</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>1</td>
                                <td>Dealer showroom</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.buydate}" name="buydate"
                                            readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="buycomment">{$trackingData.buycomment}</textarea>
                                </td>
                            </tr>
                            <tr>
                                <td>2</td>
                                <td>warehouse</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.warehousedate}" name="warehousedate"
                                            readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="warehousecomment">{$trackingData.warehousecomment}</textarea></td>
                            </tr>
                            <tr>
                                <td>3</td>
                                <td>Ocean flight</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.e2date}" name="e2date" readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="e2comment">{$trackingData.e2comment}</textarea></td>
                            </tr>
                            <tr>
                                <td>4</td>
                                <td>Port of Egypt</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.portdate}" name="portdate" readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="portcomment">{$trackingData.portcomment}</textarea></td>
                            </tr>
                            <tr>
                                <td>5</td>
                                <td>Viking warehouse</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.arrivaldate}" name="arrivaldate" readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="arrivalcomment">{$trackingData.arrivalcomment}</textarea></td>
                            </tr>
                            <tr>
                                <td>6</td>
                                <td>vroom showroom</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.showroomdate}" name="showroomdate" readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="showroomcomment">{$trackingData.showroomcomment}</textarea></td>
                            </tr>
                            <tr>
                                <td>7</td>
                                <td>Delivered to the customer</td>
                                <td>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                        data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="{$trackingData.deliverdate}" name="deliverdate" readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                </td>
                                <td><textarea class="form-control" name="delivercomment">{$trackingData.delivercomment}</textarea></td>
                            </tr>
                        </tbody>
                    </table>
                    <input type="hidden" name="id" id="id" value="{$trackingData.id}">
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="submit" class="btn btn-primary pull-left">حفظ الامر</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{literal}
<script>
    $(document).ready(function () {
        $('#chasis').on('change', function () {
            var chasis = $(this).val();
            var id = $('#id').val();
            if (chasis) {
                $.ajax({
                    url: 'carTrackingController.php?do=checkExist',
                    type: 'POST',
                    data: { chasis: chasis,id:id },
                    success: function (data) {
                        if(data > 0){
                            window.location.href = "carTrackingController.php?do=edit&id=" + data;
                        }
                    }
                });
            }
        });
    });
</script>
{/literal}