Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $serverName = "LAPTOP-SOI03H0J"; //serverName\instanceName
- $connectionInfo = array( "Database"=>"pustaxa", "UID"=>"", "PWD"=>"");
- $conn = sqlsrv_connect($serverName, $connectionInfo);
- if( $conn ) {
- // echo "Connection established.<br />";
- }else{
- echo "Connection could not be established.<br />";
- die( print_r( sqlsrv_errors(), true));
- }
- $output = array('data' => array());
- $sql = "SELECT * FROM dbo.Kalendar";
- $stmt = sqlsrv_query( $conn, $sql );
- if( $stmt === false) {
- die( print_r( sqlsrv_errors(), true) );
- }
- $x = 1;
- while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
- $active = '';
- $PDMSabah = '';
- $PDMSarawak = '';
- $PDMUtara = '';
- $PDMTimur = '';
- $PDMSelatan = '';
- if($row['PDMKL'] == 1) {
- $active = '<label class="label label-success">Bekerja</label>';
- } else {
- $active = '<label class="label label-danger">Cuti</label>';
- }
- if($row['PDMSabah'] == 1) {
- $PDMSabah = '<label class="label label-success">Bekerja</label>';
- } else {
- $PDMSabah = '<label class="label label-danger">Cuti</label>';
- }
- if($row['PDMSarawak'] == 1) {
- $PDMSarawak = '<label class="label label-success">Bekerja</label>';
- } else {
- $PDMSarawak = '<label class="label label-danger">Cuti</label>';
- }
- if($row['PDMTimur'] == 1) {
- $PDMTimur = '<label class="label label-success">Bekerja</label>';
- } else {
- $PDMTimur = '<label class="label label-danger">Cuti</label>';
- }
- if($row['PDMUtara'] == 1) {
- $PDMUtara = '<label class="label label-success">Bekerja</label>';
- } else {
- $PDMUtara = '<label class="label label-danger">Cuti</label>';
- }
- if($row['PDMSelatan'] == 1) {
- $PDMSelatan = '<label class="label label-success">Bekerja</label>';
- } else {
- $PDMSelatan = '<label class="label label-danger">Cuti</label>';
- }
- $actionButton = '
- <div class="btn-group">
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- Action <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <li><a type="button" data-toggle="modal" data-target="#editMemberModal" onclick="editMember('.$row['idKalendar'].')"> <span class="glyphicon glyphicon-edit"></span> Edit</a></li>
- <li><a type="button" data-toggle="modal" data-target="#removeMemberModal" onclick="removeMember('.$row['idKalendar'].')"> <span class="glyphicon glyphicon-trash"></span> Remove</a></li>
- </ul>
- </div>';
- $date = $row['Tarikh'];
- //$newDate = date_format($date,"Y/m/d H:i:s");
- $output['data'][] = array(
- $date,
- $active,
- $PDMSabah,
- $PDMSarawak,
- $PDMTimur,
- $PDMUtara,
- $PDMSelatan,
- $actionButton
- );
- $x++;
- }
- // database connection close
- echo json_encode($output);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement