<?php
                        // HTTP/1.0
           if($_REQUEST['ajax']) {
            switch($_REQUEST['code']) {
                case "transno":
                
                  if(RetRstField("SELECT fnid FROM tluser WHERE ftusername='{$_REQUEST['fttrans_no']}'")) {
                      ?>

                      alert('User Name sudah dipakai... ');
                <?php
                  }
                  else {
                        ?>
                         submitbutton('Simpan','','','','');

                <?php
                  }
                break;
            }       
            die("");
        }
       function GetGridUser($n) {
       $x='';
       $ftusername='';
     
       $ssql="SELECT ftusername FROM tluser WHERE fnid='{$_REQUEST['id']}'";
       $rs=mysql_query($ssql) or die($ssql);
       $r=mysql_fetch_assoc($rs);
       $ftusername=$r['ftusername'];
       
       $ssql="SELECT A.fnsecurity_access,IFNULL(B.ftusername,'{$ftusername}') AS ftusername,a.ftmodule_code, A.ftsecurity_description,a.ftsecurity_subdescription,IFNULL(B.fnsecurity,0) AS fnsecurity
                FROM tssecurity_access A LEFT JOIN tluser_access B ON A.fnsecurity_access=B.fnsecurity_access AND (B.ftusername ='{$ftusername}' OR B.ftusername IS NULL)
                WHERE  
                    a.ftmodule_code='{$n}'";
               
                $rs=mysql_query("select distinct  ftsecurity_description from ($ssql) m ") or die($ssql) ;
                
                $x.= "<table class='ewTable' id='TransactionDetail{$n}' name='TransactionDetail{$n}' border='0' width='100%' cellspacing='0' celpadding='0'>
                    <tr class='is_edit_header_row' width=100%>
                    <td valign=top width=30 align=center>No</th>
                    <td valign=top  width=400   align=center>Keterangan</th>                   
                    </tr>";
        
                $i=0;
                $j=0;
		while($r = mysql_fetch_assoc($rs))
		 {
                    if ($i%2) {
                            $class1="ewTableRow";
                            $class2="ISGridTDeven";
                    } else {						
                            $class1="ISGridTRodd";
                            $class2="ISGridTDodd";
                    }
                     $j++;
			$x.= "<tr class='$class1'> 
                          	    <td class='$class2' valign=top>{$j}</td>
                           	   <td class='$class2'><b>{$r['ftsecurity_description']}</b> ";
                           	 
			   $rs1=mysql_query($ssql." and A.ftsecurity_description='".$r['ftsecurity_description']."'") or die("m");
               $x.="<table class='ewTable'  border='0'  cellspacing='0' celpadding='0'>";
			   while($r1 = mysql_fetch_assoc($rs1)) {
					
                     		if($r1['fnsecurity']==0){
                            		$c="";
                     		}
                     		else {
                       	   	 	$c=" checked ";
                     		}
                            $x.="<tr  class='$class1'>";
                            $x.="<td class='$class2'>";
                     		 $x.= " <input type=hidden name=fnS[] value='{$r1['fnsecurity_access']}'>{$r1['fnsecurity_access']}
                           	   <input type=checkbox name=c{$r1['fnsecurity_access']} value='1' $c ></td><td>
                                {$r1['ftsecurity_subdescription']}";
                                $x.="</td>";
                                $x.="</tr>";
			 	 }
                 $x.="</table>";
			     $x.="</td> </tr>";
                     $i++;
		 }
		$x.="</table>";
		
                return $x;
        
    }
    function GetUser() {

        
        $x.="
            <link rel='stylesheet' type='text/css' href='tab-view/tab-view.css' />
            <div class='TabView' id='TabView' style='width: 100%;'>
            <!-- ***** Tabs ************************************************************ -->

            <div class='Tabs' style='width: 100%;height=100%'>
              <a class='Current'>security</a>
		 <a>SaldoAwal</a>
              <a>inventory</a>
              <a>penjualan</a>    
              <a>preproduksi</a> 
              <a>keuangan</a>    
            </div>


            <!-- ***** Pages *********************************************************** -->

            <div class='Pages' style=' style='width: 100%;' >
              <div class='Page' style='display: block;'><div class='Pad'>";
              
               $x.=GetGridUser('1');
                 $x.="</div></div>
              <div class='Page' style='display:  none;'><div class='Pad'>";
               $x.=GetGridUser('1.5');

          $x.="</div></div>
              <div class='Page' style='display:  none;'><div class='Pad'>";
               $x.=GetGridUser('2');
        
        $x.="</div></div>
              <div class='Page' style='display:  none;'><div class='Pad'>";
               $x.=GetGridUser('3');
        $x.="</div></div>
              <div class='Page' style='display:  none;'><div class='Pad'>";
               $x.=GetGridUser('4');
          $x.=" </div></div>
              <div class='Page' style='display:  none;'><div class='Pad'>";
              $x.=GetGridUser('5');
          $x.="</div></div>
        </div>
        </div>
        <script type='text/javascript' src='tab-view/tab-view.js'></script>
        <script type='text/javascript'>
            tabview_initialize('TabView');
        </script>";
        return $x;

        
    }

    Getsecurity(7);
    $objAxpDB->ViewName("Daftar User");  
    $objAxpDB->ViewSQL('SELECT fnid,ftusername,ftfirst_name,ftuser_group_code FROM tluser ORDER BY ftusername,ftfirst_name,ftuser_group_code');
    $objAxpDB->ViewCaption('ID, User Name, Nama, Group User');

    $objAxpDB->FormName("User");
    $objAxpDB->FormSQL('SELECT ftusername,ftpassword,ftpassword as password_confirm,ftuser_group_code,ftfirst_name,
                        ftmiddle_name,ftlast_name,ftdepartment,
                        fnstatus FROM tluser
                        ');
    $objAxpDB->FormCaption(' User Name,Password, Confirm Password , Group User, Nama Depan, Nama Tengah, Nama Belakang,  Departemen,Status ');
    
    $objAxpDB->Lookup('ftuser_group_code', 'SELECT ftuser_group_code, ftuser_group_name FROM tluser_group', 'ftuser_group_code', 'ftuser_group_name', -1,true);
    $objAxpDB->Lookup('fnstatus', 'SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status where fntrans_group_code=9', 'fntrans_status_code', 'fttrans_status_name', 1,true);
    $objAxpDB->FormPosition('TL, TL, TL, TL,TL,TL,TR,TR,TR');
    $password="document.getElementById('ftpassword').type='password';
              document.getElementById('password_confirm').type='password';";
   
    $objAxpDB->FormJS("{$password}");
   
    $objAxpDB->GridSQL(0, "SELECT fnid FROM tluser");    
    $m=GetUser();
    #die($m);
    $objAxpDB->GridReplace(0, $m);
    
    $objAxpDB->SetStatus("id");                        
    if ($objAxpDB->GetStatus("id") == "") {
            $objAxpDB->ButtonShow("baru, tutup");

    }
    elseif ($objAxpDB->GetStatus("id") == 0) {
            $objAxpDB->ButtonShow("reset, simpan, tutup");

    }
    elseif ($objAxpDB->GetStatus("id") != 0) {
            $objAxpDB->ButtonShow("update, hapus, tutup"); 
            $objAxpDB->FormLocked("1, 0, 0");
    }
    $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();
    

?>
