Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <section class="content-header">
- <h1>
- <?php echo $title;?>
- </h1>
- <ol class="breadcrumb">
- <li><a href="#"><i class="fa fa-list"></i><?php echo $menu_title;?></a></li>
- <li class="active"><a href="#"><?php echo $sub_menu_title;?></a></li>
- </ol>
- </section>
- <section class="content">
- <div class="row">
- <div class="col-md-12">
- <div class="box box-primary">
- <div class='box-header with-border'>
- <h3 class='box-title'><a onclick="add_user()" class="btn btn-primary btn-small">
- <i class="glyphicon glyphicon-plus"></i> <?php echo lang('index_create_user_link');?></a></h3>
- <label calss='control-label' ></label>
- </div>
- <div class="box-body table-responsive">
- <table id="mytable" class="table table-bordered table-striped" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th>No.</th>
- <th>NAMA SALES</th>
- <th>NO HP</th>
- <th>TDC</th>
- <th>WILAYAH</th>
- <th>LEVEL</th>
- <th>KD SUPER</th>
- <th>Edit</th>
- <th>Delete</th>
- </tr>
- </thead>
- <?php
- $no=1;
- foreach ($salesmans as $row){
- echo"
- <tr>
- <td>$no</td>
- <td>".$row->USERID."</td>
- <td>".$row->NOHP."</td>
- <td>".$row->CABANG."</td>
- <td>".$row->WILAYAH."</td>
- <td>".$row->LEVEL."</td>
- <td>".$row->KDSUPER."</td>
- ";?>
- <td><a onclick="edit_user(<?php echo $row->submission_id;?>)"><i class="btn btn-info btn-sm glyphicon glyphicon-edit" data-toggle="tooltip" title="Edit"></i></a></td>
- <?php echo"
- <td>" . anchor('auth/delete/' . $row->submission_id, '<i class="btn-sm btn-info glyphicon glyphicon-trash" data-toggle="tooltip" title="Delete"></i>', array('onclick' => "return confirm('Data Akan di Hapus?')")) . "</td>
- </tr>";
- $no++;
- }
- ?>
- </Table>
- </div><!-- /.box-body -->
- </div><!-- /.box -->
- </div>
- </div>
- </section><!-- /.content -->
- <script src="<?php echo base_url();?>assets/js/jquery-1.12.0.min.js"></script>
- <script src="<?php echo base_url();?>assets/js/plugins/datatables/jquery.dataTables.min.js"></script>
- <script src="<?php echo base_url();?>assets/js/plugins/select2/select2.min.js"></script>
- <script type="text/javascript">
- var table;
- var save_method; //for save method string
- table = $("#mytable").dataTable();
- $('.itemName').select2({
- placeholder: 'Select for tag',
- ajax: {
- url: "<?php echo site_url('Master/getClusters');?>",
- dataType: 'json',
- delay: 250,
- processResults: function (data) {
- return {
- results: data
- };
- },
- cache: true
- },
- dropdownParent: $('#myModal')
- });
- function add_user()
- {
- save_method = 'add';
- $('#form')[0].reset(); // reset form on modals
- $('.form-group').removeClass('has-error'); // clear error class
- $('.help-block').empty(); // clear error string
- $('[id="email"]').show();
- get_csrf();
- $('#myModal').modal('show'); // show bootstrap modal
- $('.modal-title').text('MENAMBAHKAN USER'); // Set Title to Bootstrap modal title
- }
- function simpan(id) {
- var url;
- if (save_method == 'add') {
- url = "<?php echo site_url('auth/create_user');?>";
- } else {
- url = "<?php echo site_url('auth/edit_user/')?>" + id;
- }
- // ajax adding data to database
- $.ajax({
- url: url,
- type: "POST",
- data: $('#form').serialize(),
- dataType: "JSON",
- success: function(data) {
- if (data.status) {
- $('#myModal').modal('hide');
- alert('Success Adding/Update data');
- } else {
- alert(data.pesan);
- }
- location.reload()
- },
- error: function(jqXHR, textStatus, errorThrown) {
- alert("Gagal menambahkan/Edit user, mungkin user sudah ada/kesalahan data !!!");
- location.reload();
- }
- });
- }
- function edit_user(id)
- {
- save_method = 'update';
- $('#form')[0].reset(); // reset form on modals
- // $('.form-group').removeClass('has-error'); // clear error class
- // $('.help-block').empty(); // clear error string
- //Ajax Load data from ajax
- $.ajax({
- url : "<?php echo site_url('auth/edit_user')?>/"+id,
- type: "GET",
- dataType: "JSON",
- success: function(data)
- {
- $('#myModal').modal('show'); // show bootstrap modal when complete loaded
- $('.modal-title').text('Edit User'); // Set title to Bootstrap modal title
- },
- error: function (jqXHR, textStatus, errorThrown)
- {
- alert('Error get data from ajax');
- }
- });
- }
- </script>
- <!-- Bootstrap modal -->
- <div class="modal fade" id="myModal" role="dialog">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- <h3 class="modal-title">Person Form</h3>
- </div>
- <div class="modal-body form">
- <div class="text-red"></div>
- <div class="box-body">
- <form id="form" class="form-horizontal" style="overflow:hidden;">
- <div class="form-group">
- <label for="example">Nama Depan</label>
- <input type="text" name="first_name" id="first_name" class="form-control" required oninvalid="setCustomValidity('Nama Depan !')"
- oninput="setCustomValidity('')" placeholder="Masukan Nama Depan" >
- </div>
- <div class="form-group">
- <label for="">Nama Belakang</label>
- <input type="text" class="form-control" name="last_name" id="last_name" required oninvalid="setCustomValidity('Nama Belakang !')"
- oninput="setCustomValidity('')" placeholder="Masukan Nama Belakang">
- </div>
- <div class="form-group">
- <label for="">Nama Pengguna</label>
- <input type="text" class="form-control" name="username" id="username" required oninvalid="setCustomValidity('Nama Pengguna !')"
- oninput="setCustomValidity('')" placeholder="Nama Pengguna">
- <?php echo form_error('username', '<div class="text-red">', '</div>'); ?>
- </div>
- <div class="form-group">
- <label for="email" id="email">Alamat Email</label>
- <input type="email" class="form-control" name="email" id="email" required oninvalid="setCustomValidity('Email Kosong/ Format Tidak Sesuai !')"
- oninput="setCustomValidity('')" placeholder="example@example.com">
- </div>
- <div class="form-group">
- <label for="">Nama Perusahaan</label>
- <input type="text" class="form-control" name="company" id="company" required oninvalid="setCustomValidity('Nama Perusahaan Kosong !')"
- oninput="setCustomValidity('')" placeholder="Masukan Nama Perusahaan">
- </div>
- <div class="form-group">
- <label for="">Nomor Handphone</label>
- <input type="number" class="form-control" name="phone" id="phone" required oninvalid="setCustomValidity('Nama Perusahaan Kosong !')"
- oninput="setCustomValidity('')" placeholder="Masukan No Handphone">
- </div>
- <div class="form-group">
- <label for="">Password</label>
- <input type="password" class="form-control" name="password" id="password" required oninvalid="setCustomValidity('Password Kosong !')"
- oninput="setCustomValidity('')" placeholder="Masukan Password (min 8 max 20)">
- </div>
- <div class="form-group">
- <label for="">CLUSTERS :</label>
- <select class="itemName form-control" style="width:500px" name="itemName"></select>
- </div>
- </form>
- </div><!-- /.box-body -->
- </div>
- <div class="modal-footer">
- <button type="button" id="btnSave" onclick="simpan(<?php echo $user->id;?>)" class="btn btn-primary">Save</button>
- <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
- </div>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement