<?php require_once(APPPATH.'/views/header.php'); ?>
<body>
<div id="wrapper">
<?php require_once(APPPATH.'/views/menu_user.php'); ?>
        <div id="page-wrapper">
            <div class="container-fluid">
                <fieldset class="admin-border">
                <fieldset class="scheduler-border"><legend class="scheduler-border"><?php echo "Setari email";?></legend>
                <?php
                        if(isset($info))
                        {
                            if(isset($info['info']))
                            echo <<< INF
                                    <div class="row">
                                        <div class="col-md-6">
                                              <div class="alert alert-info" role="alert">{$info['info']}</div>
                                        </div>
                                    </div>
INF;
                        else
                            if(isset($info['eroare']))
                                echo <<< ERR
                                    <div class="panel panel-red">
                                        <div class="panel-heading">
                                            <h3 class="panel-title">$ERROR_TITLE</h3>
                                        </div>
                                    <div class="panel-body">
                                        {$info['eroare']}
                                    </div>
                            </div>
ERR;
                        }
                        ?>

                <div class="row">
                <form id="my_set" action="<?php echo base_url();?>adm/setari/save" method="POST" enctype="multipart/form-data">
                    <div class="col-lg-3 col-md-6 col-sm-8 col-xs-12">
                        <label>Host (*)</label><br />
                        <input class="form-control" type="text" id="host"  name="host" value="<?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->host : '';?>" placeholder="Host">
                    </div>
                    <div class="col-lg-3 col-md-6 col-sm-8 col-xs-12">
                        <label>Port (*)</label><br />
                        <input class="form-control" type="text" id="port"  name="port" value="<?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->port : '';?>" placeholder="Port">
                    </div>
                    <div class="clearfix"></div><br/>

                    <div class="col-lg-3 col-md-6 col-sm-8 col-xs-12">
                        <label>Utilizator email (*)</label><br />
                        <input class="form-control" type="text" id="username"  name="username" value="<?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->username : '';?>" placeholder="Utilizator email">
                    </div>
                    <div class="col-lg-3 col-md-6 col-sm-8 col-xs-12">
                        <label>Parola email (*)</label><br />
                        <input class="form-control" type="password" id="password"  name="password" value="<?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->password : '';?>" placeholder="Parola email">
                    </div>

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

                    <div class="col-lg-6 col-md-6 col-sm-8 col-xs-12">
                        <label>Nume utilizator (*)</label><br />
                        <input class="form-control" type="text" id="from_name"  name="from_name" value="<?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->from_name : '';?>" placeholder="Nume utilizator">
                    </div>

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

                    <div class="col-lg-6 col-md-6 col-sm-8 col-xs-12">
                        <label>Subiect email (*)</label><br />
                        <input class="form-control" type="text" id="subject_email"  name="subject_email" value="<?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->subject_email : '';?>" placeholder="Subiect email">
                    </div>

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

                    <div class="col-lg-6 col-md-6 col-sm-8 col-xs-12">
                        <label>Continut email (*) </label><br />
                        <textarea style="height:200px;" class="form-control" id="body_email"  name="body_email" placeholder="Continut email"><?=(isset($infoGenerale) && $infoGenerale)? $infoGenerale->body_email : '';?></textarea>
                    </div>

                    <div class="clearfix"></div><br/>
                    <div class="col-lg-3 col-md-6 col-sm-8 col-xs-12">
                      <button id="save_btn" type="submit" class="btn btn-primary">Salveaza</button>
                    </div><br />
                    </form>
                </div>
            </fieldset>
            </fieldset>
            </div>
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
     <div id="gif" class="modal fade loading-gif">
                 <div class="modal-dialog">
                       <div>
                           <img src="<?=base_url()?>img/loading.gif">
                       </div>
                 </div>
    </div>
<?php require_once(APPPATH.'/views/footer.php'); ?> 
<script>
            
        $(document).ready(function(){

            $("#my_set").validate({
                    // validation rules
                    rules: {
                        host: "required",
                        port: "required",
                        username: "required",
                        password: "required",
                        from_name: "required",
                        subject_email: "required",
                        body_email: "required"
                    },
                    // Specify validation error messages
                    messages: {
                        host: "Completeaza adresa de host.",
                        port: "Completeaza portul.",
                        username: "Completeaza email utilizator.",
                        password: "Completeaza parola utilizator.",
                        from_name: "Completeaza nume utilizator.",
                        subject_email: "Completeaza subiect email.",
                        body_email: "Completeaza continut email."
                    },
                    submitHandler: function(form) {
                      form.submit();
                    }
            });
        });

</script>      
</body>
</html>