<?php /* Smarty version Smarty-3.1.11, created on 2016-11-29 09:59:27
         compiled from "../views/default/userview/edit.html" */ ?>
<?php /*%%SmartyHeaderCode:290155615583d517fe264e1-94427150%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '1b0361040fa830ef85b139d5254b60f8276cb801' => 
    array (
      0 => '../views/default/userview/edit.html',
      1 => 1480411474,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '290155615583d517fe264e1-94427150',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'loadData' => 0,
    'UserGroupData' => 0,
    'UserGroup' => 0,
    'allbranchdata' => 0,
    'myallbranchdata' => 0,
    'saveData' => 0,
    'save' => 0,
    'storData' => 0,
    'mystorData' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_583d518020bf48_13380844',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_583d518020bf48_13380844')) {function content_583d518020bf48_13380844($_smarty_tpl) {?>

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

        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="userController.php?do=show">المستخدمين</a></li>
            <li class="active">تعديل مستخدم</li>
        </ol>


        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">تعديل مستخدم</h3>
            </div>
            <div class="panel-body">
                <form class="form-horizontal" role="form" action="userController.php?do=update" method="post" id="spform">




                    <div class="form-group">
                        <label for="username" class="col-lg-2 control-label">اسم المستخدم</label>
                        <div class="col-lg-4">

                            <span id="name">
                                <input type="text" class="form-control" placeholder="اسم المستخدم" name="username" id="username" value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->username;?>
">
                                <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>رسالة خطا</h4>
                                <p>هذا الاسم مستخدم من قبل</p>

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


                        </div>
                    </div>


                    <div class="form-group">
                        <label for="password" class="col-lg-2 control-label">كلمة المرور</label>
                        <div class="col-lg-4">

                            <span id="sprytextfield1">
                                <input type="password" name="password" class="form-control" placeholder="كلمة المرور" value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->password;?>
"/>
                                <span class="textfieldRequiredMsg">*</span></span>

                        </div>
                    </div>



                    <div class="form-group">
                        <label for="employeename" class="col-lg-2 control-label">اسم الموظف</label>
                        <div class="col-lg-4">

                            <span id="sprytextfield2">
                                <input type="text" class="form-control" placeholder="اسم الموظف" name="employeename"  value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->employeename;?>
">
                                <span class="textfieldRequiredMsg">*</span></span>

                        </div>
                    </div>

                    <div class="form-group">
                        <label for="userstoreid" class="col-lg-2 control-label">السؤال السرى<span style="color: red;display: block">فى حالة نسيت كلمة المرور</span></label>
                        <div class="col-lg-4">
                            <textarea class="form-control" name="question" rows="3" required><?php echo $_smarty_tpl->tpl_vars['loadData']->value->question;?>
</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userstoreid" class="col-lg-2 control-label">الاجابة السرية<span style="color: red;display: block">فى حالة نسيت كلمة المرور</span></label>
                        <div class="col-lg-4">
                            <textarea class="form-control" name="answer" rows="3" required><?php echo $_smarty_tpl->tpl_vars['loadData']->value->answer;?>
</textarea>
                        </div>
                    </div>




                    <div class="form-group">
                        <label for="usergroupid" class="col-lg-2 control-label">المجموعة</label>
                        <div class="col-lg-4">


                            <span id="spryselect2">
                                <select class="select2 wdt100" name="usergroupid" id="usergroupid">

                                    <?php  $_smarty_tpl->tpl_vars['UserGroup'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['UserGroup']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['UserGroupData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['UserGroup']->key => $_smarty_tpl->tpl_vars['UserGroup']->value){
$_smarty_tpl->tpl_vars['UserGroup']->_loop = true;
?>

                                    <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->usergroupid;?>
<?php $_tmp1=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['UserGroup']->value->usergroupid;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp1==$_tmp2){?> selected="selected" <?php }?>  value="<?php echo $_smarty_tpl->tpl_vars['UserGroup']->value->usergroupid;?>
"><?php echo $_smarty_tpl->tpl_vars['UserGroup']->value->usergroupname;?>
</option>

                                    <?php } ?>

                                </select>
                                <span class="selectInvalidMsg"> *</span></span>
                        </div>
                    </div>


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

                    <!--

                    <div class="form-group">
                        <label for="usergroupid" class="col-lg-2 control-label"> الفرع</label>
                        <div class="col-lg-4">

                            <select required  class="select2 wdt100" name="branchid" id="branchid">
                                <option value="-1">اختر الفرع</option>
                                <option value="0" <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->branchId;?>
<?php $_tmp3=ob_get_clean();?><?php if ($_tmp3==0){?> selected="selected" <?php }?>>  كل الفروع</option>

                                <?php  $_smarty_tpl->tpl_vars['myallbranchdata'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['myallbranchdata']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allbranchdata']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['myallbranchdata']->key => $_smarty_tpl->tpl_vars['myallbranchdata']->value){
$_smarty_tpl->tpl_vars['myallbranchdata']->_loop = true;
?>

                                <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->branchId;?>
<?php $_tmp4=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['myallbranchdata']->value->branchId;?>
<?php $_tmp5=ob_get_clean();?><?php if ($_tmp4==$_tmp5){?> selected="selected" <?php }?>     value="<?php echo $_smarty_tpl->tpl_vars['myallbranchdata']->value->branchId;?>
"><?php echo $_smarty_tpl->tpl_vars['myallbranchdata']->value->branchName;?>
</option>
                                <?php } ?>


                            </select>

                        </div>
                    </div>



                    <div class="form-group">
                        <label for="employeename" class="col-lg-2 control-label">نسبه البائع</label>
                        <div class="col-lg-4"><span id="sprytextfield3">
                                <input type="text"  class="form-control" placeholder="نسبه البائع" value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->awardrate;?>
" name="awardrate" />
                                <span class="textfieldRequiredMsg">***.</span><span class="textfieldInvalidFormatMsg">ادخل رقم مناسب.</span><span class="textfieldMaxValueMsg"> ادخل رقم من 0 الى 100</span><span class="textfieldMinValueMsg"> ادخل رقم من 0 الى 100</span></span></div>
                    </div>




                    <div class="form-group">
                        <label for="saveid" class="col-lg-2 control-label">الخزنة</label>
                        <div class="col-lg-4">

                            <span id="spryselect3">
                                <select class="select2 wdt100" name="saveid" id="saveid">


                                    <?php  $_smarty_tpl->tpl_vars['save'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['save']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['saveData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['save']->key => $_smarty_tpl->tpl_vars['save']->value){
$_smarty_tpl->tpl_vars['save']->_loop = true;
?>

                                    <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->saveid;?>
<?php $_tmp6=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['save']->value->saveid;?>
<?php $_tmp7=ob_get_clean();?><?php if ($_tmp6==$_tmp7){?> selected="selected" <?php }?> value="<?php echo $_smarty_tpl->tpl_vars['save']->value->saveid;?>
"><?php echo $_smarty_tpl->tpl_vars['save']->value->savename;?>
</option>

                                    <?php } ?>


                                </select>
                                <span class="selectInvalidMsg"> *</span></span>
                        </div>
                    </div>




                    <div class="form-group">
                        <label for="saveid" class="col-lg-2 control-label">البحث فى يوميه الخزنه</label>
                        <div class="col-lg-4">


                            <select class="select2 wdt100" name="searchinonesave" id="searchinonesave">
                                <option   <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->searchinonesave;?>
<?php $_tmp8=ob_get_clean();?><?php if ($_tmp8==0){?> selected="selected" <?php }?>  value="0">كل الخزن</option>
                                <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->searchinonesave;?>
<?php $_tmp9=ob_get_clean();?><?php if ($_tmp9==1){?> selected="selected" <?php }?> value="1">خزنه المستخدم فقط</option>
                            </select>

                        </div>
                    </div>




                    <div class="form-group">
                        <label for="userstoreid" class="col-lg-2 control-label">المخزن</label>
                        <div class="col-lg-4">

                            <span id="spryselect4">
                                <select class="select2 wdt100" name="userstoreid" id="userstoreid">
                                    <option value="-1">اختر المخزن</option>
                                    <option value="0" <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->userstoreid;?>
<?php $_tmp10=ob_get_clean();?><?php if ($_tmp10=='0'){?> selected="selected" <?php }?>>كل المخازن</option>
                                    <?php  $_smarty_tpl->tpl_vars['mystorData'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['mystorData']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['storData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['mystorData']->key => $_smarty_tpl->tpl_vars['mystorData']->value){
$_smarty_tpl->tpl_vars['mystorData']->_loop = true;
?>

                                    <option value="<?php echo $_smarty_tpl->tpl_vars['mystorData']->value->storeId;?>
" <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['loadData']->value->userstoreid;?>
<?php $_tmp11=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['mystorData']->value->storeId;?>
<?php $_tmp12=ob_get_clean();?><?php if ($_tmp11==$_tmp12){?> selected="selected" <?php }?>><?php echo $_smarty_tpl->tpl_vars['mystorData']->value->storeName;?>
</option>

                                    <?php } ?>


                                </select>
                                <span class="selectInvalidMsg"> *</span></span>
                        </div>
                    </div>

                    -->



                    <input type="hidden" name="userid" id="userid" value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->userid;?>
"/>
                    <input type="hidden" name="currentdate" value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->currentdate;?>
"/>
                    <input type="hidden" name="conditions" value="<?php echo $_smarty_tpl->tpl_vars['loadData']->value->conditions;?>
"/>





                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left" id="spbutton">حفظ الامر</button>
                        </div>
                    </div>




                </form>
            </div>
        </div>




    </div>
</div>




<script type="text/javascript">
    var name = new Spry.Widget.ValidationTextField("name");
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue: "-1", isRequired: false});
    //var spryselect3 = new Spry.Widget.ValidationSelect("spryselect3", {isRequired: false, invalidValue: "-1"});
    //var spryselect4 = new Spry.Widget.ValidationSelect("spryselect4", {isRequired: false, invalidValue: "-1"});
    //var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "integer", {isRequired: false, invalidValue: "-1", minValue: "0", maxValue: "100"});
</script>


<script type="text/javascript">
    $('#spbutton').live('click', function (e) {
        //ckeck name
        var tableName = 'user';
        var inputName = 'username';
        var name = $("#" + inputName).val();
        var id = $("#userid").val();
        $.ajax({
            url: 'checkRedundantNames.php?do=checkNameWithId&name=' + name + '&id=' + id + '&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>

<?php }} ?>