1. Create MYKAD field & Javascript function in views. Example : views/carian/tambah_rekod.php
<div class="">
<div class="span10 offset1">
<div class="widget-box" >
<div class="widget-title">
<span class="icon">
<i class="icon-th-large"></i>
</span>
<h5>Daftar Pengguna</h5>
</div>
<div class="widget-content" >
<?php echo tbs_horizontal_form_open('carian/tambah_rekod', array('id'=>'tambah_rekod'));?>
<div class="alert alert-fail">
<span id="msgbox"></span>
</div>
<div style="margin-left: 10px; ">
<?php echo tbs_horizontal_input(array( //validation using jquery -> assets/validation/register.js
'name'=>'mykad',
'id'=>'mykad',
'value'=>set_value('mykad', $mykad),
'class'=>'input-large',
'maxlength'=>'12',
// 'readonly' => 'readonly',
), array(
'label'=>'No. MyKad',
), true);
?>
<?php echo tbs_horizontal_input(array(
'name'=>'nama',
'id'=>'nama',
'value'=> set_value('nama', $nama),
'class'=>'input-xxlarge',
//'readonly' => 'readonly',
), array(
'label'=>'Nama',
), true); ?>
<?php echo tbs_horizontal_dropdown('jantina',$jantina_u,
$jantina, array(
'id'=>'jantina',
//'value'=> set_value('jantina', $jantina),
'class'=>'input-medium',
//'disabled' => 'disabled',
), array(
'label'=>'Jantina',
), true); ?>
<?php echo tbs_horizontal_password(array(
'name'=>'katalaluan',
'id'=>'katalaluan',
'value'=>set_value('katalaluan', $katalaluan),
'class'=>'input-medium',
//'readonly' => 'readonly',
), array(
'label'=>'Kata Laluan',
), true); ?>
<?php echo tbs_horizontal_password(array(
'name'=>'re_katalaluan',
'id'=>'re_katalaluan',
'value'=>set_value('re_katalaluan', $re_katalaluan),
'class'=>'input-medium',
//'readonly' => 'readonly',
), array(
'label'=>'Pengesahan Kata Laluan',
), true); ?>
<?php echo tbs_horizontal_input(array(
'name'=>'emel',
'id'=>'emel',
'value'=> set_value('emel', $emel),
'class'=>'input-xlarge',
//'readonly' => 'readonly',
), array(
'label'=>'Emel',
), true); ?>
<?php echo tbs_horizontal_dropdown('skim', $skim_u,
$skim, array(
'id'=>'skim',
'class'=>'input-xlarge',
//'disabled' => 'disabled',
), array(
'label'=>'Jawatan',
), true)?>
<?php echo tbs_horizontal_input(array(
'name'=>'gred',
'id'=>'gred',
'value'=> set_value('gred', $gred),
'class'=>'input-small',
'maxlength'=>'10',
//'readonly' => 'readonly',
), array(
'label'=>'Gred',
), true); ?>
<font style=" color: #CC0000"> (Contoh: 17 / 41 / JUSA A / TURUS 3) </font>
<br>
<?php echo tbs_horizontal_dropdown('jenisFasiliti', $jenisFasiliti_u,
$jenisFasiliti, array(
'id'=>'jenisFasiliti',
'class'=>'input-xlarge',
//'disabled' => 'disabled',
), array(
'label'=>'Jenis Fasiliti',
), true)?>
<div id="ajaxjenisFasiliti">
<?php echo tbs_horizontal_dropdown('lokasiBertugas', $lokasiBertugas_u,
$lokasiBertugas, array(
'id'=>'lokasiBertugas',
'class'=>'input-xlarge',
//'disabled' => 'disabled',
), array(
'label'=>'Lokasi Bertugas',
), true)?>
</div>
<div id="ajaxpenempatan">
<?php echo tbs_horizontal_dropdown('penempatan', $penempatan_u,
$penempatan, array(
'id'=>'penempatan',
'class'=>'input-xlarge',
//'disabled' => 'disabled',
), array(
'label'=>'Penempatan',
), true)?>
</div>
<!-- Dropdown Untuk STATUS AKTIF -->
<?php echo tbs_horizontal_dropdown('status',$status_u,$status,
array('id'=>'status','class'=>'',),
array('label'=>'Status Aktif','class'=>''),
true);
?>
<!-- Dropdown Untuk Peranan -->
<?php echo tbs_horizontal_dropdown('levelAdmin',$levelAdmin_u,$levelAdmin,
array('id'=>'levelAdmin','class'=>'',),
array('label'=>'Peranan','class'=>''),
true);
?>
</div>
<br>
<div class="form-actions">
<button type="submit" class="btn btn-orange" id="daftar"><i class="icon icon-plus icon-white"></i> Daftar</button>
<button type="reset" id="semula" class="btn btn-orange"><i class="icon icon-repeat icon-white"></i> Reset</button>
<a class="btn btn-orange" href="<?php echo base_url('index.php/carian/pengguna')?>"><i class="icon icon-chevron-left icon-white"></i> Kembali</a>
</div>
<?php echo form_close();?>
</div>
</div>
<script src='<?php echo base_url('assets/validation/pengguna.js')?>'></script>
<script>
// window.listUser = function(){
// AjaxCall(base_url+'index.php/pentadbiran/listJson', '', 'listUser', 'id', '', '');
// };
$(document).ready(function(){
$('#simpan').live('click', function() {
var check_validate = $('#tambah_rekod').valid();
if(check_validate == true){
return true;
}
});
$('#jenisFasiliti').live('change', function(e){
e.preventDefault();
$.post(base_url+'index.php/carian/getFasiliti', 'id='+$(this).val(), function(data) {
if(data == '') {
$("#ajaxjenisFasiliti").slideUp('fast').html(data);;
} else {
$("#ajaxjenisFasiliti").html(data).slideDown('fast');
}
});
});
$('#lokasiBertugas').live('change', function(e){
e.preventDefault();
$.post(base_url+'index.php/carian/getPenempatan', 'id='+$(this).val(), function(data) {
if(data == '') {
$("#ajaxpenempatan").slideUp('fast').html(data);;
} else {
$("#ajaxpenempatan").html(data).slideDown('fast');
}
});
});
$("#mykad").blur(function() { //091
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('semak...').fadeIn("slow");
//check the username exists or not from ajax
var val = $("#mykad").val();
$.post(base_url+'index.php/carian/semakMyKad',{ myKad:val } ,
function(data) { //092
if(data=='yes') { //093
$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
$("#mykad").val("");
$(this).html('No. MyKad Telah Wujud').addClass('messageboxerror').fadeTo(900,1);
});
} else {
$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
$("#msgbox").text("");
});
} //093
}); //092
});
$("#katalaluan").blur(function() { //091
var password = $("#katalaluan").val();
var repassword = $("#re_katalaluan").val();
if(password != '' && repassword != '') {
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('semak...').fadeIn("slow");
//check the username exists or not from ajax
$.post(base_url+'index.php/carian/semakPassword',{ password:password, repassword:repassword } ,
function(data) { //092
if(data=='yes') { //093
$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
$("#katalaluan").val("");
$("#re_katalaluan").val("");
$(this).html('Kata Laluan Dan Pengesahan Kata Laluan Tidak Sepadan').addClass('messageboxerror').fadeTo(900,1);
});
} else {
$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
$("#msgbox").text("");
});
} //093
});
}
});
$("#re_katalaluan").blur(function() { //091
var password = $("#katalaluan").val();
var repassword = $("#re_katalaluan").val();
if(password != '' && repassword != '') {
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('semak...').fadeIn("slow");
//check the username exists or not from ajax
$.post(base_url+'index.php/carian/semakPassword',{ password:password, repassword:repassword } ,
function(data) { //092
if(data=='yes') { //093
$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
$("#katalaluan").val("");
$("#re_katalaluan").val("");
$(this).html('Kata Laluan Dan Pengesahan Kata Laluan Tidak Sepadan').addClass('messageboxerror').fadeTo(900,1);
});
} else {
$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
$("#msgbox").text("");
});
} //093
});
}
});
});
</script>
2. Put the function below in controllers. Example : controllers/carian.php
<?php
class Carian extends MY_Controller {
public function __construct() {
parent::__construct();
$this->_ci =& get_instance();
$this->authentication->check();
$this->load->model('applicant_model');
$this->load->model("Eminda_model");
$this->load->model('Tbl_pengguna_model');
$this->load->model('Tbl_profil_model');
$this->load->model('Tbl_perkhidmatan_model');
$this->load->helper('html');
}
function semakMyKad() {
$myKad = $this->input->post('myKad');
if($myKad != '') {
$data = $this->Eminda_model->semakMyKad($myKad);
echo $data;
}
}
}
3. Put the function below in models. Example : models/eminda_model.php
<?php
class Eminda_model extends CI_Model {
function __construct() {
parent::__construct();
}
function semakMyKad($myKad) {
$this->db->select('mykad');
$this->db->where(array('mykad'=>$myKad));
$query = $this->db->get('pengguna');
return ($query->num_rows() == 0) ? "no":"yes";
}
}
Di sediakan oleh MOHD AIDIL BIN MOHD NAYAN
Friday, 23 October 2015
CHECK EXISTING MYKAD IN DATABASE
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment