
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="#">الأصول</a></li>
            <li class="active">إضافة أصل قديم</li>
        </ol>
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">إضافة أصل قديم</h3>
            </div>
            <div class="panel-body"> {literal}
                <form id="spform"  class="nameToBeChecked form-horizontal" action="assetController.php?do=add" method="post">
                    <!--validate the form before checking name-->
                    {/literal}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">إسم الأصل</label>
                        <div class="col-lg-4"> <span id="sprytextfield2">
                                <input type="text" name="assetname" id="assetname" class="form-control"  />
                                <span class="textfieldRequiredMsg">يجب ادخال الاسم</span></span>
                            <input name="savebefor" id="savebefor" type="hidden" value="{$savebefor}" />

                            <!----------- start nameError alert -------------->
                            <div id="nameError"  style="display:none">

                            </div>
                            <!----------- end nameError alert ------------->

                        </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 value="1"  class="radioR" name="manufacture"   type="radio" />

                                    نعم </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="0"  class="noradioR" name="manufacture" checked="checked"    type="radio" />
                                    لا </label>
                            </div>

                        </div>
                    </div>
                    <!--===== check old add page =========================-->

                    <input type="hidden" name="Add" value="0"/>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">نوع الأصل</label>
                        <div class="col-lg-4"> <span id="spryselect2">
                                <select id="assetscatid"  name="assetscatid" data-placeholder="اختر"  class="select2 wdt100">
                                    <option value="-1"></option>


                                    {foreach $allctadata as $mycat}


                                    <option value="{$mycat->assetscatid}">{$mycat->cattitel}</option>


                                    {/foreach}



                                </select>
                                <span class="selectRequiredMsg">اختر نوع.</span><span class="selectInvalidMsg">اختر نوع الاصل.</span></span> </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">سعر الأصل</label>
                        <div class="col-lg-4">
                            <div class="input-group"> <span id="sprytextfield1">
                                    <input type="text" id="assetprice" name="assetprice" class="positivefloat form-control" />
                                    <span class="textfieldRequiredMsg">ادخل السعر</span><span class="textfieldInvalidFormatMsg">ادخل القيمة صحيحة</span></span> <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">نسبة الإهلاك</label>
                        <div class="col-lg-4">
                            <div class="input-group"><span id="sprytextfield3">
                                    <input type="text" name="assetsDepreciation" class="positivefloat form-control"/>
                                    <span class="textfieldRequiredMsg">***.</span><span class="textfieldInvalidFormatMsg">ادخل رقم مناسب.</span><span class="textfieldMaxValueMsg"> ادخل رقم من 0 الى 100</span><span class="textfieldMinValueMsg"> ادخل رقم من 0 الى 100</span></span> <span class="input-group-addon">%</span> </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">مجمع الإهلاك</label>
                        <div class="col-lg-4">
                            <div class="input-group"><span id="sprytextfield4">
                                    <input type="text" name="depreciation" class="positivefloat form-control" />
                                    <span class="textfieldRequiredMsg">ادخل القيمه.</span><span class="textfieldInvalidFormatMsg">من فضلك ادخل قيمه صحيحه.</span></span> <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label"> سعر الساعة </label>
                        <div class="col-lg-4">
                            <div class="input-group"> <span id="sprytextfield6">
                                    <input type="text" name="Hourlyrate" class="positivefloat form-control" />
                                    <span class="textfieldRequiredMsg">ادخل القيمه.</span><span class="textfieldInvalidFormatMsg">من فضلك ادخل قيمه صحيحه.</span></span> <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">وصف الأصل</label>
                        <div class="col-lg-4">
                            <textarea name="assetdescription"  class=" form-control" cols="45" rows="5"></textarea>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <input name="type" type="hidden" value="{$type}" />
                            <button type="reset" class="btn btn-danger pull-left">إلغاء</button>
                            <button type="button" id="savebtn2" class="btn btn-primary pull-left">إضافة</button>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </form>
            </div>
            <!--panel-body-->
        </div>
        <!--panel-->
    </div>
    <!--container-->
</div>
<!--row-->
{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "real");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "integer", {isRequired: false, invalidValue: "-1", minValue: "0", maxValue: "100"});
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer");
    var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "real");

    var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue: "-1"});

    $('#savebtn2').live('click', function (e) {
        //ckeck name
        var tableName = 'assets';
        var inputName = 'assetname';
        var name = $("#" + inputName).val();
        $.ajax({
            url: 'checkRedundantNames.php?name=' + name + '&tablename=' + tableName,
            success: function (data) {
                //alert(data);
                if (data == '0') {
                    $("#nameError").css("display", "none");
                    var myForm = document.getElementById("spform");
                    var SS = Spry.Widget.Form.validate(myForm);
                    if (SS == true) {
                        if (!$('#spbutton').hasClass("processing")) {
                            $('#spbutton').addClass("processing");
                            myForm.submit();
                            //$('#spbutton').unbind('click');
                        }
                    }

                } else if (data == '1') {
                    $("#" + inputName).val("");
                    $("#" + inputName).focus();
                    $("#nameError").css("display", "block");
                    return false;
                }
            }
        });

    });
</script>
{/literal}