
<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 panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">إضافة ورشة</h3>
            </div>
            <div class="panel-body">
                <form class="form-horizontal" action="workshop.php?do=add" method="post" id="worshopForm"><!--checkName(event, 'costcenter', 'name');-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">الورش</label>
                        <div class="col-lg-4">
                            <input type="text" name="name" id="name" class="form-control"/>
                        </div>
                    </div>

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


                    <div class="form-group">
                        <label class="col-lg-2 control-label">تفاصيل أخرى</label>
                        <div class="col-lg-4">
                            <textarea name="description"  id="description" class=" form-control" cols="45" rows="5"></textarea>
                        </div>
                    </div>

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


                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="reset" class="btn btn-danger pull-left">إلغاء</button>

                            <button type="button" class="btn btn-primary pull-left" id="add">إضافة</button>

                        </div>
                    </div>
                    <div class="clearfix"></div>
                </form>
            </div><!--panel-body-->
        </div><!--panel-->
    </div><!--container-->
</div><!--row-->
{literal}
<script type="text/javascript">
    $("#add").live('click', function () {
        var name = $('#name').val();
        var tableName = "workshop";
        if (name == "")
        {
            $('#name').css('background-color', 'yellow');
        }
        else
        {
            $('#name').css('background-color', 'white');
            $.ajax({
                url: 'checkRedundantNames.php?name=' + name + '&tablename=' + tableName,
                success: function (data) {
                    //alert(data);
                    if (data == '0')
                    {
                        $("#worshopForm").submit();
                    }
                    else if (data == '1')
                    {
                        $('#name').val("");
                        $('#name').focus();

                        alert('عفوا هذا الاسم مستخدم من قبل');
                        return false;
                    }
                }

            });
        }

    });
</script>
{/literal}
