View
<input type="hidden" name="cbox[<?php echo $arraksimenus['d_MenuName_ID']; ?>]" value="<?php echo $arraksimenus['d_MenuName_ID']; ?>"/>
<input type="checkbox" name="cbox[<?php echo $arraksimenus['d_MenuName_ID']; ?>]" value="1"
<?
if($ceklagiallowsz['isAllow']==1)
{ echo 'checked';
}
?>/>
Model
function edituserakses($dataedit)
{
//print_r($dataedit);
foreach( $dataedit[cbox] as $data2 => $checkbox )
{
$pecah=substr($checkbox,0,1);
if($pecah==1)
{
$pecahlagi=1;
}
else
{
$pecahlagi=0;
}
/*
echo "UPDATE tb_d_usrlgn set isAllow='$pecahlagi'
where d_MenuName_ID='".$data2 ."' and m_UsrLgn_ID='".$_POST['userloginid']."'
"."</br>";
*/
$querya=$this->db->query("select count(d_MenuName_ID) as jumlahnya
from tb_d_usrlgn
where d_MenuName_ID='".$data2."' and m_UsrLgn_ID='".$_POST['userloginid']."' ");
foreach($querya->result_array() as $row)
{
if($row['jumlahnya']==1)
{
$sql2 = "UPDATE tb_d_usrlgn set isAllow='$pecahlagi'
where d_MenuName_ID='".$data2 ."' and m_UsrLgn_ID='".$_POST['userloginid']."'
";
$this->db->query($sql2);
}//tutup if jumlahnya
if($row['jumlahnya']!=1 && $pecahlagi==1)
{
$sql2 = "
declare @No varchar(18)
exec sprGetUCode 'tb_d_UsrLgn', @No output
select @No
insert into tb_d_UsrLgn values (@No,'".$_POST['userloginid']."' , '".$data2 ."', 'TRUE')
";
$this->db->query($sql2);
}//tutup else
}//tutup foreach count
}
}
Tidak ada komentar:
Posting Komentar