{literal}
<style>
     .newoption {
        background-color: #CCCCCC !important;
        font-weight: bold !important;
    }
</style>
{/literal}
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">استيراد السيارات</a></li>
            <li><a href="importContractController.php?do=show">عقود الاستيراد</a></li>
            <li class="active">تعديل </li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                {if $contractdata->del lt 2}
                <h3 class="panel-title">تعديل </h3>
                {else}
                <h3 class="panel-title">تفاصيل </h3>
                {/if}
            </div>
            <div class="panel-body">

                <form class="form-horizontal" action="importContractController.php" id="carformajax" method="post"
                    enctype="multipart/form-data" data-dosave="?do=savedata">
                    <input type="hidden" id="clientsearchvalue" value="{$Programsettingdata->clientsearchvalue}" />
                    <input type="hidden" name="supplierWithAddOption" id="supplierWithAddOption" value="{$Usergroupdata->addClientInBill}" />
                    <input type="hidden" name="withNakdi" id="withNakdi" value="{$Usergroupdata->showClientAndSupplierOne}" />
                    <input type="hidden" name="supplieridBeforeChange" id="supplieridBeforeChange" value="" />
                    <input type="hidden" name="suppliernameBeforeChange" id="suppliernameBeforeChange" value="" />

                    <div class="form-group">
                        <label class="col-lg-2 control-label">العميل </label>
                        <div class="col-lg-4"> 
                            <div id="clientDiv">
                                <input type="hidden" name="clientid" id="supplier" class="select2Supp" value="{$contractdata->clientid}" />
                                <input type="hidden" id="oldsupplierid" value="{$myclientdata.clientid}" />
                                <input type="hidden" id="oldsuppliername" value="{$myclientdata.clientname}" />
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="brand" class="col-lg-2 control-label">الماركة</label>
                        <div class="col-lg-4">
                            <input required="required" type="text" name="brand" class="form-control" value="{$contractdata->brand}" placeholder="الماركة"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="carcolor" class="col-lg-2 control-label">اللون</label>
                        <div class="col-lg-4">
                            <input required="required" type="text" name="carcolor" class="form-control" value="{$contractdata->carcolor}" placeholder="اللون"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="carmodel" class="col-lg-2 control-label">الموديل</label>
                        <div class="col-lg-4">
                            <input required="required" type="text" name="carmodel" class="form-control" value="{$contractdata->carmodel}" placeholder="الموديل"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="chasisno" class="col-lg-2 control-label">رقم الشاسيه</label>
                        <div class="col-lg-4">
                            <select name="chasisno" id="chasiNo" required="required"  data-placeholder="اختر " class="select2">
                                <option>اختر الشاسيه</option>
                                {foreach $allChasis as $single}
                                <option value="{$single}" {if {$contractdata->chasisno} eq $single} selected {/if}>{$single}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="cartype" class="col-lg-2 control-label">نوع السيارة</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input type="radio" name="cartype" value="0" {if $contractdata->cartype eq 0}checked{/if}/>
                                        جديدة 
                                </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input type="radio" name="cartype" value="1" {if $contractdata->cartype eq 1}checked{/if}/>
                                        مستعملة 
                                </label>
                            </div>                             
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="contractvalue" class="col-lg-2 control-label">قيمة التعاقد</label>
                        <div class="col-lg-4">
                            <input required="required" type="text" name="contractvalue" class="form-control floats" value="{$contractdata->contractvalue}" placeholder="قيمة التعاقد"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="carnumber" class="col-lg-2 control-label">رقم السيارة</label>
                        <div class="col-lg-4">
                            <input type="text" name="carnumber" class="form-control" value="{$contractdata->carnumber}" placeholder="رقم السيارة"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="carmotor" class="col-lg-2 control-label">موتور السيارة</label>
                        <div class="col-lg-4">
                            <input type="text" name="carmotor" class="form-control" value="{$contractdata->carmotor}" placeholder="موتور السيارة"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="contractimage" class="col-lg-2 control-label">صوره العقد</label>
                        <div class="col-lg-2">
                            {if $contractdata->contractimage !="." && $contractdata->contractimage}
                            <!-- <img src="../views/default/images/importcontract/{$contractdata->contractimage}"
                                style="width: 140px;height: 100px;border: 3px solid;border-radius: 6px;"> -->
                                <a href="../views/default/images/importcontract/{$contractdata->contractimage}" target="_blank" class="btn btn-success">عرض</a>
                            {else}
                            <img src="../views/default/assets/img/blank.png"
                                style="width: 140px;height: 100px;border: 3px solid;border-radius: 6px;" alt=""
                                class="card-img">
                            {/if}
                            <input type="hidden" name="oldcontractimage" id="oldcontractimage"
                                value="{$contractdata->contractimage}" />
                            {if $contractdata->del lt 2}
                            <input type="file" name="contractimage" id="contractimage" />
                            {/if}
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="notes" class="col-lg-2 control-label">ملاحظات</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" rows="3" name="notes" id="notes">{$contractdata->notes}</textarea>
                        </div>
                    </div>

                    <input type="hidden" name="contractid" id="contractId" value="{$contractdata->id}" />
                    {if $contractdata->del neq 5}
                    <input type="hidden" class="deldata" value="{$contractdata->del}" />
                    {/if}



                    {if $contractdata->del lt 2}
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left carformajax">تعديل </button>
                        </div>
                    </div>
                    {/if}
                </form>
            </div>
        </div>
    </div>
</div>

<!------------------------Client Model----------------------------->
<!-- Modal -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal"
                        aria-hidden="true">&times;</button>
                <h4 class="modal-title">{$smarty.const.CLIENT_ADD_CLIENT}</h4>
            </div>
            <div class="modal-body">
                <form id="clientInfo" action="#" method="post" class="form-horizontal">
                    <input type="hidden" name="returnToselect2Ajax" value="1" />
                    <div class="form-group">
                        <label for="newclientName"
                               class="col-lg-2 control-label">{$smarty.const.SELL_BILL_CLIENT_NAME}</label>
                        <div class="col-lg-4"> <span id="sprytextfield2">
                                <input class="form-control" placeholder="{$smarty.const.SELL_BILL_CLIENT_NAME}"
                                       id="newclientName" name="newclientName" type="text" required="required" />
                                <span class="textfieldRequiredMsg">*</span></span>
                            <div id="nameError" class="alert alert-block alert-danger fade in" style="display:none">
                                <button type="button" class="close pull-left" data-dismiss="alert"
                                        aria-hidden="true">&times;</button>
                                <h4>{$smarty.const.CLIENT_WRONG_MESSAGE}</h4>
                                <p>{$smarty.const.CLIENT_THAT_NAME_ALREADY_TAKEN}</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>




                    <div class="form-group" {if $Programsettingdata->simpleAddClientInBill neq
                        1}style="display:none"{/if}>
                        <label for="clientaddress"
                               class="col-lg-2 control-label">{$Programsettingdata->clientcodname}</label>
                        <div class="col-lg-4">
                            <input class="form-control" placeholder="{$Programsettingdata->clientcodname}"
                                   id="clientcode" name="clientcode" type="text" />
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="txtAddress"
                               class="col-lg-2 control-label">{$smarty.const.CLIENT_COMPANY_REGION}</label>
                        <div class="col-lg-4">
                            <span id="spryselect1">
                                <input {if $Programsettingdata->clientfieldrequired eq 1} required="required" {/if}
                                type="hidden" name="clientareaid" value="0" id="clientareaid"/>
                                <span
                                    class="selectInvalidMsg">{$smarty.const.CLIENT_SELECT_COMPANY_REGION}</span></span>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="taxnumber" class="col-lg-2 control-label">الرقم الضريبى</label>
                        <div class="col-lg-4">
                            <span id="spryselect1">
                                <input class="form-control" type="text" name="taxnumber" placeholder="الرقم الضريبى"
                                       id="taxnumber">
                                <span class="selectInvalidMsg"></span></span>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label for="newclientdebt"
                               class="col-lg-2 control-label">{$smarty.const.CLIENT_INDEBTEDNESS}</label>
                        <div class="col-lg-4">
                            <input class="form-control numberinput" placeholder="{$smarty.const.CLIENT_INDEBTEDNESS}"
                                   id="newclientdebt" name="newclientdebt" type="text" required="required" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="clientaddress" class="col-lg-2 control-label">{$smarty.const.CLIENT_ADDRESS}</label>
                        <div class="col-lg-4">
                            <input class="form-control" placeholder="{$smarty.const.CLIENT_ADDRESS}" id="clientaddress"
                                   name="clientaddress" type="text" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="clientphone"
                               class="col-lg-2 control-label">{$smarty.const.SELL_BILL_PHONE_NUMBER}</label>
                        <div class="col-lg-4">
                            <input class="form-control numberinput" placeholder="{$smarty.const.SELL_BILL_PHONE_NUMBER}"
                                   id="clientphone" name="clientphone" type="text" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="clientmobile"
                               class="col-lg-2 control-label">{$smarty.const.CLIENT_MOBILE_NUMBER}</label>
                        <div class="col-lg-4">
                            <input class="form-control numberinput" placeholder="{$smarty.const.CLIENT_MOBILE_NUMBER}"
                                   id="clientmobile" name="clientmobile" type="text" />
                        </div>
                    </div>
                    <div class="form-group ">
                        <label class="col-lg-2 control-label">المندوب </label>
                        <div class="col-lg-4">
                            <span>
                                <select name="delegateid" id="delegateid" data-placeholder="اختر "
                                        class="select2 wdt100">


                                    <option value="-1">اختر </option>
                                    {foreach $allDelegate as $delegate}
                                    <option value="{$delegate.userid}">{$delegate.employeename}</option>
                                    {/foreach}
                                </select>
                            </span>

                        </div>
                    </div>
                    <div class="form-group" {if $Programsettingdata->simpleAddClientInBill neq
                        1}style="display:none"{/if}>
                        <label for="debtLimit" class="col-lg-2 control-label">{$smarty.const.CLIENT_DEBT_LIMIT} </label>
                        <div class="col-lg-4">
                            <input type="text" name="debtLimit" class="form-control positivefloat" id="debtLimit"
                                   value="{$Programsettingdata->clientDefaultDebtLimit}">
                        </div>
                    </div>
                    <!-- =================================================   -->

                    <div class="form-group" {if $Programsettingdata->simpleAddClientInBill neq
                        1}style="display:none"{/if}>
                        <label class="col-lg-2 control-label">{$smarty.const.CLIENT_SPECIAL_DISCOUNT} </label>
                        <div class="col-lg-1">
                            <input type="checkbox" name="specialDiscount" id="specialDiscount" value="1" />
                        </div>
                        <div style="display: none" id="specialDiscountVal_div">
                            <label class="col-lg-1 control-label">{$smarty.const.CLIENT_RATIO} </label>
                            <div class="col-lg-2">
                                <input type="text" name="specialDiscountVal" id="specialDiscountVal"
                                       class="form-control positivefloat" placeholder="" value="" />
                            </div>
                        </div>
                    </div>

                    <!-- =================================================   -->

                    <div class="form-group" {if $Programsettingdata->simpleAddClientInBill neq
                        1}style="display:none"{/if}>
                        <label class="col-lg-2 control-label">{$smarty.const.CLIENT_CARD_IMAGE}</label>
                        <div class="col-lg-4">
                            <input type="file" name="file" id="file" />
                        </div>
                    </div>


                    <!-- =================================================   -->
                    <div class="form-group">
                        <label for="clientdetails" class="col-lg-2 control-label">{$smarty.const.CLIENT_COMMENT}</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" rows="3" name="clientdetails" id="clientdetails"></textarea>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label class="col-lg-2 control-label"> {$smarty.const.SELL_BILL_PRICE_TYPE}</label>
                        <div class="col-lg-4">
                            <span>
                                <select name="priceTypeId" id="priceTypeId"
                                        data-placeholder=" {$smarty.const.SELL_BILL_SELECT}" class="select2 wdt100">
                                    <option value="-1">{$smarty.const.CLIENT_CHOOSE_PRICE_TYPE}</option>
                                    {if $Programsettingdata->showpriceall eq 1}
                                    <option value="0">{$smarty.const.SELL_BILL_WHOLESALE}</option>
                                    {/if}
                                    {if $Programsettingdata->showpriceunit eq 1}
                                    <option value="1">{$smarty.const.SELL_BILL_RETAIL}</option>
                                    {/if}
                                    {if $Programsettingdata->showpricehalf eq 1}
                                    <option value="2">{$smarty.const.SELL_BILL_HALF_WHOLESALE}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice4 eq 1}
                                    <option value="4">{$smarty.const.SELL_BILL_PRICE4}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice5 eq 1}
                                    <option value="5">{$smarty.const.SELL_BILL_PRICE5}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice6 eq 1}
                                    <option value="6">{$smarty.const.SELL_BILL_PRICE6}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice7 eq 1}
                                    <option value="7">{$smarty.const.SELL_BILL_PRICE7}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice8 eq 1}
                                    <option value="8">{$smarty.const.SELL_BILL_PRICE8}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice9 eq 1}
                                    <option value="9">{$smarty.const.SELL_BILL_PRICE9}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice10 eq 1}
                                    <option value="10">{$smarty.const.SELL_BILL_PRICE10}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice11 eq 1}
                                    <option value="11">{$smarty.const.SELL_BILL_PRICE11}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice12 eq 1}
                                    <option value="12">{$smarty.const.SELL_BILL_PRICE12}</option>
                                    {/if}
                                    {if $Programsettingdata->showprice13 eq 1}
                                    <option value="13">{$smarty.const.SELL_BILL_PRICE13}</option>
                                    {/if}
                                </select>
                            </span>

                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group" {if $Programsettingdata->simpleAddClientInBill neq
                        1}style="display:none"{/if}>
                        <label for="textDetails" class="col-lg-2 control-label">{$smarty.const.SELL_BILL_STORE}</label>
                        <div class="col-lg-3">
                            <label>
                                <input type="checkbox" class="ckstore" name="store_all" id="store_all" checked="checked"
                                       value="1" />
                                {$smarty.const.CLIENT_ALL_STORES}
                            </label>
                        </div>
                        {foreach $storeData as $data}
                        <div class="col-lg-3">
                            <label>
                                <input type="checkbox" class="clientStore ckstore" name="store{$data->storeId}"
                                       id="store{$data->storeId}" checked="checked" disabled="disabled" value="1" />
                                {$data->storeName}
                            </label>
                        </div>
                        {/foreach}
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group" >
                        <label for="texttype"
                               class="col-lg-2 control-label">{$smarty.const.CLIENT_CUSTOMER_TYPE}</label>
                        <div class="col-lg-3">
                            <label>
                                <input type="checkbox" class="cktype" name="typeClient_all" id="typeClient_all"
                                        value="1" />
                                {$smarty.const.CLIENT_ALL_CUSTOMER_TYPE}
                            </label>
                        </div>
                        {foreach $typeClient as $data}
                        <div class="col-lg-3">
                            <label>
                                <input type="checkbox" class="typeClient cktype" name="type{$data->typeId}"
                                       id="type{$data->typeId}"  value="1" />
                                {$data->typeName}
                            </label>
                        </div>
                        {/foreach}
                    </div>
                    <!-- =================================================   -->
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default savemodel2"
                        data-dismiss="modal">{$smarty.const.CLIENT_NO}</button>
                <button type="button" class="btn btn-primary savemodel1">{$smarty.const.CLIENT_YES}</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->