
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="#">الموردين</a></li>
            <li><a href="#">إدارة الموردين</a></li>
            <li class="active">تعديل مورد</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">تعديل مورد</h3>
            </div>
            <div class="panel-body"> {literal}
                <form id="suppform" class="nameToBeChecked form-horizontal" action="?do=update" method="post">
                    <!--validate the form before checking name-->
                    {/literal}
                    <input type="hidden" name="dailyentryid" value="{$loadData->dailyentryid}"/>
                    <input name="id" id="id" type="hidden" value="{$loadData->supplierid}" />
                    <div class="form-group">
                        <label class="col-lg-2 control-label">اسم المورد</label>
                        <div class="col-lg-4">
                            <input name="txtName" type="text" id="txtName" class="form-control" value="{$loadData->suppliername}"/>
                            <input name="oldname" type="hidden" id="oldname" class="form-control" value="{$loadData->suppliername}"/>

                            <div id="nameError"  style="display:none"></div>
                        </div>
                    </div>
                    {if $Programsettingdata->clientserial eq 1}
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">الرقم التسلسلي</label>
                        <div class="col-lg-4">

                            <input type="text" disabled class="form-control" value="{$loadData->supplierid}"/>

                            <div class="clearfix"></div>
                        </div>


                    </div>
                    <!-- =================================================   -->
                    {/if}
                     <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">كود المورد </label>
                        <div class="col-lg-4">
                            <input type="text" name="suppliercode" class="form-control" value="{$loadData->suppliercode}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    {if $Programsettingdata->maintenance neq 1}
                    <!-- =================================================   -->
                   
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">المحافظه    /  المدينة  </label>
                        <div class="col-lg-4">
                            <input id="" type="text" name="goverareaid"  id="goverareaid" class="getgoverarea"  data-placeholder=" المحافظه    /  المدينة    " />
                            <input type="hidden" id="goverareaidv"  value="{$loadData->goverareaid}"/>
                            <input type="hidden" id="governmentname"  value="{$governmentname}"/>
                            <input type="hidden" id="areaname"  value="{$areaname}"/>



                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">اسم المستفيد فى الشيك</label>
                        <div class="col-lg-4">
                            <input type="text" name="namepayeecheck" class="form-control" value="{$loadData->namepayeecheck}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">الرقم االرضي </label>
                        <div class="col-lg-4">
                            <input type="text" name="suppliermobile" class="form-control" value="{$loadData->suppliermobile}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">مسئول الضمانات</label>
                        <div class="col-lg-4">
                            <input type="text" name="warrantyOfficer" class="form-control" value="{$loadData->warrantyOfficer}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">موبايل الضمانات</label>
                        <div class="col-lg-4">
                            <input type="text" name="warrantymobile" class="form-control" value="{$loadData->warrantymobile}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">اسم البائع</label>
                        <div class="col-lg-4">
                            <input type="text" name="sellername" class="form-control" value="{$loadData->sellername}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">موبايل البائع</label>
                        <div class="col-lg-4">
                            <input type="text" name="sellermobile" class="form-control" value="{$loadData->sellermobile}"/>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    {/if}

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">العنوان</label>
                        <div class="col-lg-4">
                            <input name="txtAddress" type="text" id="txtAddress"  value="{$loadData->supplieraddress}" class="form-control"/>
                            <div id="addressError"  style="display:none"></div>
                        </div>
                    </div>
                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">رقم التليفون</label>
                        <div class="col-lg-4">
                            <input name="txtPhone" type="text" id="txtPhone"  class="positiveNo form-control"  value="{$loadData->supplierphone}"/>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">قيمة المديونية</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="txtDebt" id="txtDebt" disabled="disabled" value="{$loadData->suppliercurrentDebt}" class="form-control"/>
                                <input type="hidden" name="debt" id="debt" value="{$loadData->suppliercurrentDebt}" />
                                <span class="input-group-addon">{$currency}</span>
                                <div id="valueError"  style="display:none"></div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" {if $Programsettingdata->showCurrency != 1}style="display:none;"{/if}>
                        <label for="txtName" class="col-lg-2 control-label">عملة المورد</label>
                        <div class="col-lg-4">
                            <select class="select2" name="sullpierCurrencyidTxt" id="sullpierCurrencyidTxt" disabled>
                                {foreach $allCurrency as $data}
                                <option value="{$data->id}" data-cfactor="{$data->conversionFactor}" data-othercfactor="{$data->otherconversionFactor}"
                                        {if $loadData->sullpierCurrencyid == $data->id}selected{/if}>{$data->name}</option>
                                {/foreach}
                            </select>
                            <input type="hidden" name="sullpierCurrencyid" id="sullpierCurrencyid" value="{$loadData->sullpierCurrencyid}" />
                        </div>
                    </div>
                    <div class="form-group" {if $Programsettingdata->showCurrency != 1}style="display:none;"{/if}>
                        <label for="txtName" class="col-lg-2 control-label">قيمة المديونية بعملته</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="suppliercurrentDebtInCurrencyTxt" id="suppliercurrentDebtInCurrencyTxt" disabled="disabled" value="{$loadData->suppliercurrentDebtInCurrency}" class="form-control"/>
                                <input type="hidden" name="suppliercurrentDebtInCurrency" id="suppliercurrentDebtInCurrency" value="{$loadData->suppliercurrentDebtInCurrency}" />
                                <span class="input-group-addon">{$currency}</span>
                                <div id="valueError"  style="display:none"></div>
                            </div>
                        </div>
                    </div>
                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">تفاصيل أخرى</label>
                        <div class="col-lg-4">
                            <textarea name="textDetails" cols="" rows="" id="textDetails" class="form-control">{$loadData->supplierdetails}</textarea>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">إخفاء</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input name="conditions" type="radio" value="1" {if {$loadData->
                                    conditions} eq 1} checked="checked" {/if} />
                                    نعم </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input name="conditions" type="radio" {if {$loadData->
                                    conditions} eq 0} checked="checked" {/if} value="0" />
                                    لا </label>
                            </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="comments" class="col-lg-2 control-label">التصنيفات</label>
                        <div class="col-lg-4">

                            <select class="js-example-basic-multiple" id="check" name="category_id[]" multiple="multiple">
                                {foreach $allParents as $category}
                                <option value="{$category->productCatId}" {if $category->productCatId|in_array:$loadData->category_id}selected{/if}>{$category->productCatName}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="comments" class="col-lg-2 control-label">نوع المورد</label>
                        <div class="col-lg-4">

                            <select class="js-example-basic-multiple" name="typesupplier[]" multiple="multiple">
                                {foreach $alltypes as $type}
                                <option value="{$type->typeId}" {if $type->typeId|in_array:$loadData->typesupplier_id}selected{/if}>{$type->typeName}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <input type="hidden" id="suppIsClientTooSetting" value="{$Programsettingdata->suppIsClientToo}"/>
                    {if $Programsettingdata->suppIsClientToo == 1}
                    <!--==============================-->
                    <div class="form-group">
                        <label for="typs" class="col-lg-2 control-label">المورد عميل ايضا</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input name="suppIsClientToo" id="suppIsClientToo0" type="radio" class="suppIsClientToo" {if $loadData->linkedClientId < 1}checked="checked"{/if} value="0">لا
                                </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input name="suppIsClientToo" id="suppIsClientToo1" type="radio" class="suppIsClientToo" value="1">عميل جديد بنفس الاسم
                                </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input name="suppIsClientToo" id="suppIsClientToo2" type="radio" class="suppIsClientToo" {if $loadData->linkedClientId >= 1}checked="checked"{/if} value="2">عميل موجود
                                </label>
                            </div>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group" id="suppIsClientTooDiv">
                        <label for="typs" class="col-lg-2 control-label">المورد عميل ايضا</label>
                        <div class="col-lg-4">
                            <input type="hidden" name="client" id="client" value=""/>
                        </div>
                        <input type="hidden" name="oldClientId" id="oldClientId" value="{$loadData->linkedClientId}"/>
                        <input type="hidden" name="oldClientName" id="oldClientName" value="{$loadData->linkedClientName}"/>
                    </div>
                    <!--==============================-->
                    {else}
                    <input type="hidden" name="suppIsClientToo" id="suppIsClientToo" value="{$loadData->linkedClientId}"/>
                    <input type="hidden" name="oldClientId" id="oldClientId" value="{$loadData->linkedClientId}"/>
                    <input type="hidden" name="client" id="client" value="{$loadData->linkedClientId}"/>
                    {/if}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">الرقم الضريبى</label>
                        <div class="col-lg-4">
                            <input name="taxnumber" type="text" id="taxnumber"  value="{$loadData->taxnumber}" class="form-control"/>
                            <div id="taxnumberError"  style="display:none"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">نوع المورد فى شجرة الحسابات</label>
                        <div class="col-lg-9">
                            <div class="radio-inline">
                                <label>
                                    <input value="0" class="noradioR" name="supplierTypeForTree" type="radio" {if $loadData->supplierTypeForTree == 0}checked="checked"{/if}>
                                    مورد محلى </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="1" class="radioR" name="supplierTypeForTree" type="radio" {if $loadData->supplierTypeForTree == 1}checked="checked"{/if}s>
                                    مورد خدمات  </label>
                            </div>

                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">نسبة خصم المورد فى حاله شراء فاتوره مبيعات لمورد (فواتير شركات الشحن) </label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="shippingDiscountPer" id="shippingDiscountPer" class="positivefloat form-control" value="{$loadData->shippingDiscountPer}"/>

                                <span class="input-group-addon">%</span>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button name="saveIncBtn" type="button" id="saveIncBtn" class="btn btn-primary pull-left">حفظ</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "real");


    $(document).ready(function () {
        $('.js-example-basic-multiple').select2();
        $(".getgoverarea").select2({
            allowClear: true,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: 'maintenancesuppliers.php?do=getgoverarea',
                dataType: 'json',
                type: "POST",
                data: function (term) {

                    return {
                        searchTerms: term,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return  '<span>' + data.text + '</span >';

            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            },
        });
        $(".getgoverarea").select2("data", {id: $('#goverareaidv').val(), text: $('#governmentname').val() + '/' + $('#areaname').val()});


    });
</script>
{/literal}