<?php
/* $Id: index.php 6941 2014-10-26 23:18:08Z daintree $*/
error_reporting(E_ALL & ~E_NOTICE);
$PageSecurity=0;
ob_start();
include('includes/session.inc');
$Title=_('ERP Home');
include('includes/newheader.php');

include('includes/SQL_CommonFunctions.inc');
include('includes/GetPaymentMethods.php');
include('includes/GetPrice.inc');
?>

		
  					
	<script src="angular/angular.min.js"></script>  
        
 
     
     
		

   
  
 									
									<?php
//this is where you paste. Below paste it:
// optionally hide all errors from displaying (but still log them)
ini_set('display_errors', '1');


$userid = $_SESSION['UserID'];
if($userid==='admin' || $userid==='jprasad' || $userid==='sharukh' ){
/**
 * Insert a leave record into the specified table.
 */
function insertLeaveRecord($table, $periodId, $employeeId, $type, $opening, $accruals, $adjustments, $remarks, $balance, $logs) {
    $type    = addslashes($type);
    $remarks = addslashes($remarks);
    $logs    = addslashes($logs);
    $sql = "
      INSERT INTO {$table}
        (periodid,payid,employeeid,type,
         opening_balance,accruals,adjustments,
         remarks,balance,logs)
      VALUES
        ('{$periodId}',NULL,'{$employeeId}','{$type}',
         '{$opening}','{$accruals}','{$adjustments}',
         '{$remarks}','{$balance}','{$logs}')
    ";
    DB_query($sql, _('Could not insert leave record'));
}


/**
 * Monthly accruals for Annual Leave → leave_register_annual_leave
 *  – 0.8333 days/mo (0.9167 if union_member) for each monthly anniversary
 *    after 3 months of service,
 *  – only for anniversaries > both 2025-04-27 and the last processed period end,
 *  – only those anniversaries falling within the current period window,
 *  – only for employees matching the calendar_management.management flag.
 */
function processAccruals($periodId) {
    // 1) Load this period’s dates + management flag
    $pr = DB_fetch_array(DB_query(
      "SELECT start_date,end_date,management
         FROM calendar_management
        WHERE id = '$periodId'",
      _('Could not fetch period')
    ));
    $periodStart    = new DateTime($pr['start_date']);
    $periodEnd      = new DateTime($pr['end_date']);
    $managementOnly = (int)$pr['management'];

    // 2) Pre-cutoff
    $globalCut = new DateTime('2025-04-27');
    if ($periodEnd <= $globalCut) return;

    // 3) Loop matching employees
    $emps = DB_query("
      SELECT employeeid, start_date, union_member
        FROM employeemaster
       WHERE status     = 'Active'
         AND management = '{$managementOnly}'
    ");
    while ($e = DB_fetch_array($emps)) {
        $eid      = $e['employeeid'];
        $hireDate = new DateTime($e['start_date']);

        // 4) Service cutoff
        $cut3m = clone $hireDate;
        $cut3m->add(new DateInterval('P3M'));
        if ($periodEnd <= $cut3m) continue;

        // 5) Get previous balance
        $lastQ = DB_query("
          SELECT balance
            FROM leave_register_annual_leave
           WHERE employeeid = '$eid'
             AND type       = 'Annual Leave'
           ORDER BY leaveid DESC
           LIMIT 1
        ");
        if (DB_num_rows($lastQ) > 0) {
            $lastRow        = DB_fetch_array($lastQ);
            $openingBalance = (float)$lastRow['balance'];
        } else {
            $openingBalance = 0.0;
        }

        // 6) Determine last processed date
        $lastProcQ = DB_query("
          SELECT cm.end_date
            FROM leave_register_annual_leave lr
            JOIN calendar_management cm ON lr.periodid = cm.id
           WHERE lr.employeeid = '$eid'
             AND lr.type       = 'Annual Leave'
           ORDER BY lr.leaveid DESC
           LIMIT 1
        ");
        if (DB_num_rows($lastProcQ) > 0) {
            $lpRow         = DB_fetch_array($lastProcQ);
            $lastProcessed = new DateTime($lpRow['end_date']);
        } else {
            $lastProcessed = $globalCut;
        }

        // anchor after both cut3m & globalCut
        if ($cut3m > $lastProcessed)    $lastProcessed = clone $cut3m;
        if ($globalCut > $lastProcessed) $lastProcessed = clone $globalCut;

        // 7) Count anniversaries
        $firstAnn = clone $hireDate;
        $firstAnn->add(new DateInterval('P3M'));
        $count    = 0;
        $ann      = $firstAnn;
        while ($ann <= $periodEnd) {
            if ($ann > $lastProcessed && $ann >= $periodStart) {
                $count++;
            }
            $ann->add(new DateInterval('P1M'));
        }
        if ($count <= 0) continue;

        // 8) Compute accrual & new balance
        $rate      = $e['union_member'] ? (11/12) : (10/12);
        $accruals  = round($count * $rate, 4);
        $newBalance= $openingBalance + $accruals;

        // 9) Insert
        $remarks = "Accrued {$accruals} days ({$count} mo) "
                 . "{$periodStart->format('d-m-Y')}→{$periodEnd->format('d-m-Y')}";
        $logs    = "Added {$accruals} days";

        insertLeaveRecord(
          'leave_register_annual_leave',
          $periodId,
          $eid,
          'Annual Leave',
          $openingBalance,
          $accruals,
          0,
          $remarks,
          $newBalance,
          $logs
        );
    }
}


/**
 * Yearly accruals for Sick Leave.
 */
function processYearlyAccruals($periodId) {
    $pr = DB_fetch_array(DB_query(
      "SELECT start_date,end_date,management
         FROM calendar_management
        WHERE id = '$periodId'",
      _('Could not fetch period')
    ));
    $winStart       = new DateTime($pr['start_date']);
    $winEnd         = new DateTime($pr['end_date']);
    $managementOnly = (int)$pr['management'];

    $types = [
      'Sick Leave'=> ['days'=>10,'cut'=>new DateTime('2025-04-27'),'roll'=>true]
    ];

    $emps = DB_query("
      SELECT employeeid,start_date
        FROM employeemaster
       WHERE status='Active'
         AND management = '{$managementOnly}'
    ");
    while ($e = DB_fetch_array($emps)) {
        $eid      = $e['employeeid'];
        $hireDate = new DateTime($e['start_date']);
        $cut3m    = clone $hireDate;
        $cut3m->add(new DateInterval('P3M'));

        $candidates = [];
        $yEnd = (int)$winEnd->format('Y');
        $a1   = DateTime::createFromFormat('Y-m-d',"{$yEnd}-{$hireDate->format('m-d')}");
        if ($a1 && $a1 >= $winStart && $a1 <= $winEnd && $a1 > $cut3m) {
            $candidates[] = $a1;
        }
        if ($winStart->format('Y-m') !== $winEnd->format('Y-m')) {
            $yStart = (int)$winStart->format('Y');
            $a2 = DateTime::createFromFormat('Y-m-d',"{$yStart}-{$hireDate->format('m-d')}");
            if ($a2 && $a2 >= $winStart && $a2 <= $winEnd && $a2 > $cut3m) {
                $candidates[] = $a2;
            }
        }

        foreach ($candidates as $ann) {
            foreach ($types as $typ => $cfg) {
                if ($cfg['cut'] && $ann < $cfg['cut']) continue;
                $days = $cfg['days'];
                $opening = 0.0;
                if ($cfg['roll']) {
                    $lr = DB_query(
                      "SELECT balance AS bal
                         FROM leave_register_sick_leave
                        WHERE employeeid='$eid' AND type='$typ'
                        ORDER BY periodid DESC LIMIT 1"
                    );
                    $last = DB_fetch_array($lr);
                    $opening = $last ? (float)$last['bal'] : 0.0;
                }
                $newBal = $opening + $days;
                $remarks = "$typ accrual on ".$ann->format('d-m-Y');
                $logs    = "Accrued {$days} days";

                DB_query("
                  INSERT INTO leave_register_sick_leave
                    (periodid,payid,employeeid,type,
                     opening_balance,accruals,adjustments,
                     remarks,balance,logs)
                  VALUES
                    ('$periodId',NULL,'$eid','$typ',
                     '$opening','$days',0,
                     '".addslashes($remarks)."',
                     '$newBal','".addslashes($logs)."')
                ", _('Could not insert yearly '.$typ));
            }
        }
    }
}

/**
 * Bereavement Leave accruals.
 */
function processBereavementAccruals($periodId) {
    $pr = DB_fetch_array(DB_query(
      "SELECT start_date,end_date,management
         FROM calendar_management
        WHERE id = '$periodId'",
      _('Could not fetch period')
    ));
    $periodStart    = new DateTime($pr['start_date']);
    $periodEnd      = new DateTime($pr['end_date']);
    $managementOnly = (int)$pr['management'];
    $cutDate        = new DateTime('2025-02-01');

    $emps = DB_query("
      SELECT employeeid,start_date
        FROM employeemaster
       WHERE status='Active'
         AND management = '{$managementOnly}'
    ");
    while ($e = DB_fetch_array($emps)) {
        $eid      = $e['employeeid'];
        $hireDate = new DateTime($e['start_date']);

        $cut3m = clone $hireDate;
        $cut3m->add(new DateInterval('P3M'));
        if ($periodEnd <= $cut3m) continue;

        // pre-2025 hire one-time
        if ($hireDate < $cutDate) {
            $chk = DB_query("
              SELECT 1 FROM leave_register_bereavement_leave
               WHERE employeeid='$eid' LIMIT 1
            ");
            if (DB_num_rows($chk) === 0) {
                DB_query("
                  INSERT INTO leave_register_bereavement_leave
                    (periodid,payid,employeeid,type,
                     opening_balance,accruals,adjustments,
                     remarks,balance,logs)
                  VALUES
                    ('$periodId',NULL,'$eid','Bereavement Leave',
                     0,3,0,
                     'One-time grant pre-Feb2025',3,'Granted 3 days')
                ", _('Could not insert bereavement accrual'));
            }
        }
        // post-2025 hire anniversaries
        else {
            $years = [(int)$periodStart->format('Y')];
            if ($periodEnd->format('Y') !== $periodStart->format('Y')) {
                $years[] = (int)$periodEnd->format('Y');
            }
            foreach ($years as $yr) {
                $ann = DateTime::createFromFormat('Y-m-d',"{$yr}-{$hireDate->format('m-d')}");
                if ($ann && $ann >= $periodStart && $ann <= $periodEnd) {
                    $chk = DB_query("
                      SELECT 1
                        FROM leave_register_bereavement_leave lr
                        JOIN calendar_management cm ON lr.periodid=cm.id
                       WHERE lr.employeeid='$eid'
                         AND YEAR(cm.end_date)='$yr'
                       LIMIT 1
                    ");
                    if (DB_num_rows($chk)===0) {
                        DB_query("
                          INSERT INTO leave_register_bereavement_leave
                            (periodid,payid,employeeid,type,
                             opening_balance,accruals,adjustments,
                             remarks,balance,logs)
                          VALUES
                            ('$periodId',NULL,'$eid','Bereavement Leave',
                             0,3,0,
                             'Anniversary grant {$ann->format('d-m-Y')}',3,'Granted 3 days')
                        ", _('Could not insert bereavement accrual'));
                    }
                    break;
                }
            }
        }
    }
}

/**
 * Delete a period and all its leave records.
 */
function deletePeriodAndLeaves($periodId) {
    DB_query("DELETE FROM leave_register_annual_leave      WHERE periodid='$periodId'");
    DB_query("DELETE FROM leave_register_sick_leave        WHERE periodid='$periodId'");
    DB_query("DELETE FROM leave_register_bereavement_leave WHERE periodid='$periodId'");
    DB_query("DELETE FROM calendar_management              WHERE id='$periodId'");
}

// ── HANDLE POSTS ─────────────────────────────────────────────
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (!isset($_POST['FormID'])||$_POST['FormID']!==$_SESSION['FormID']) {
        prnMsg(_('Bad Form'), 'error'); exit;
    }
    if (isset($_POST['action']) && $_POST['action']==='delete') {
        if ($userid==='admin') {
            deletePeriodAndLeaves((int)$_POST['id']);
            prnMsg(_('Deleted'), 'success');
        } else prnMsg(_('Only admin'), 'error');
    }
    elseif(isset($_POST['action']) && in_array($_POST['action'],['add','save'])) {
        $sd     = $_POST['start_date'];
        $ed     = $_POST['end_date'];
        $mgmt   = isset($_POST['management']) ? '1':'0';
        $period = 'Weekending-'.date('d-m-Y',strtotime($ed));
        $status = $_POST['status'];
        if ($_POST['action']==='save') {
			 $now = date('Y-m-d H:i:s');
            DB_query("
              UPDATE calendar_management
                 SET start_date='{$sd}',end_date='{$ed}',
                     period='{$period}',status='{$status}',created_by='{$userid}',date_created='{$now}',
                     management='{$mgmt}'
               WHERE id='{$_POST['id']}'"
            );
            $pid = $_POST['id'];
        } else {
            $now = date('Y-m-d H:i:s');
            DB_query("
              INSERT INTO calendar_management
                (period,start_date,end_date,status,created_by,date_created,management)
              VALUES
                ('{$period}','{$sd}','{$ed}','{$status}','{$userid}','{$now}','{$mgmt}')"
            );
            $pid = DB_Last_Insert_ID();
        }
        if ($status==='processing') {
            processAccruals($pid);
            processYearlyAccruals($pid);
            processBereavementAccruals($pid);
            prnMsg(_('Processed'), 'success');
        }
    }
}

// ── PREPARE FORM DEFAULTS ────────────────────────────────────
$editMode       = false;
$form_id        = '';
$form_start     = date('Y-m-d');
$form_end       = date('Y-m-d');
$form_status    = 'processing';
$form_management=0;
$form_action    ='add';
if (isset($_GET['edit'])) {
    $r=DB_fetch_array(DB_query("SELECT * FROM calendar_management WHERE id=".(int)$_GET['edit']));
    if ($r) {
        $editMode        = true;
        $form_id         = $r['id'];
        $form_start      = $r['start_date'];
        $form_end        = $r['end_date'];
        $form_status     = $r['status'];
        $form_management = (int)$r['management'];
        $form_action     = 'save';
    }
}

// ── PAGINATION ──────────────────────────────────────────────
$perPage    = 10;
$page       = (isset($_GET['page'])&&ctype_digit($_GET['page']))?(int)$_GET['page']:1;
$offset     = ($page-1)*$perPage;
$count      = DB_fetch_array(DB_query("SELECT COUNT(*) AS cnt FROM calendar_management"))['cnt'];
$totalPages = ceil($count/$perPage);
$listSql = "
  SELECT id,period,start_date,end_date,status,created_by,date_created,management
    FROM calendar_management
   ORDER BY id DESC
   LIMIT {$perPage} OFFSET {$offset}";
$paginatedList = DB_query($listSql);
?>
<!DOCTYPE html>
<html><head>
  <meta charset="utf-8">
  <title>Calendar Management</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head><body>
<div class="container my-4">
  <div class="d-flex justify-content-between mb-3">
    <h2>Pay-cycle Periods</h2>
    <button class="btn btn-success" data-bs-toggle="collapse" data-bs-target="#periodForm">
      <?= $editMode?'Edit':'+ Add New' ?> Period
    </button>
  </div>
  <div class="collapse <?= $editMode?'show':'' ?>" id="periodForm">
    <div class="card card-body mb-4">
      <form method="post" class="row g-3">
        <input type="hidden" name="FormID" value="<?= $_SESSION['FormID'] ?>">
        <input type="hidden" name="action" value="<?= $form_action ?>">
        <?php if($editMode):?>
        <input type="hidden" name="id" value="<?= $form_id ?>">
        <?php endif;?>
        <div class="col-md-3">
          <label class="form-label">Start Date</label>
          <input type="date" name="start_date" class="form-control" value="<?= $form_start?>" required>
        </div>
        <div class="col-md-3">
          <label class="form-label">End Date</label>
          <input type="date" name="end_date" class="form-control" value="<?= $form_end?>" required>
        </div>
        <div class="col-md-2">
          <label class="form-label">Status</label>
          <select name="status" class="form-select">
            <?php foreach(['processing'] as $st):?>
            <option value="<?= $st?>" <?= $form_status===$st?'selected':''?>>
              <?= ucfirst($st)?>
            </option>
            <?php endforeach;?>
          </select>
        </div>
        <div class="col-md-2">
          <div class="form-check mt-4">
            <input class="form-check-input" type="checkbox" name="management" id="management"
                   value="1" <?= $form_management?'checked':''?>>
            <label class="form-check-label" for="management">Management only</label>
          </div>
        </div>
        <div class="col-md-2 d-flex align-items-end">
          <button class="btn btn-primary w-100"><?= $editMode?'Save':'Create'?> Period</button>
        </div>
      </form>
    </div>
  </div>

  <div class="table-responsive">
    <table class="table table-hover align-middle">
      <thead class="table-light"><tr>
        <th>#</th><th>Period</th><th>Start</th><th>End</th>
        <th>Status</th><th>Mgmt?</th><th>By</th><th>Created</th><th></th>
      </tr></thead>
      <tbody>
      <?php while($row=DB_fetch_array($paginatedList)): ?>
      <tr>
        <td><?= $row['id']?></td>
        <td><?= htmlspecialchars($row['period'])?></td>
        <td><?= date('d-m-Y',strtotime($row['start_date']))?></td>
        <td><?= date('d-m-Y',strtotime($row['end_date']))?></td>
        <td><?= htmlspecialchars($row['status'])?></td>
        <td><?= $row['management']?'Yes':'No'?></td>
        <td><?= htmlspecialchars($row['created_by'])?></td>
        <td><?= date('d-m-Y H:i',strtotime($row['date_created']))?></td>
        <td class="text-end">
         
          <?php if($userid==='admin'): ?>
			 <a href="?edit=<?= $row['id']?>" class="btn btn-sm btn-primary">Edit</a>
          <form method="post" class="d-inline" onsubmit="return confirm('Delete #<?= $row['id']?>?')">
            <input type="hidden" name="FormID" value="<?= $_SESSION['FormID']?>">
            <input type="hidden" name="action" value="delete">
            <input type="hidden" name="id" value="<?= $row['id']?>">
            <button class="btn btn-sm btn-danger">Delete</button>
          </form>
          <?php endif;?>
        </td>
      </tr>
      <?php endwhile;?>
      </tbody>
    </table>
  </div>

  <nav><ul class="pagination justify-content-center">
    <li class="page-item <?= $page>1?'':'disabled'?>">
      <a class="page-link" href="?page=<?= $page-1?>">&laquo; Prev</a>
    </li>
    <?php for($p=1;$p<=$totalPages;$p++):?>
    <li class="page-item <?= $p==$page?'active':''?>">
      <a class="page-link" href="?page=<?=$p?>"><?=$p?></a>
    </li>
    <?php endfor;?>
    <li class="page-item <?= $page<$totalPages?'':'disabled'?>">
      <a class="page-link" href="?page=<?= $page+1?>">Next &raquo;</a>
    </li>
  </ul></nav>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php 

}else{
	
	echo "you are not authorized to access this contents";
	
}

?>
			  
 	</div >

						

		
					</div>
				</div>
			</div>
					
					

						<!--end:: Widgets/Stats-->

						<!--Begin::Section-->
						

		<!-- end::Quick Sidebar -->

		<!-- begin::Scroll Top -->
		<div id="m_scroll_top" class="m-scroll-top">
			<i class="la la-arrow-up"></i>
		</div>

		<!-- end::Scroll Top -->

		<!-- begin::Quick Nav -->
		

		<!-- begin::Quick Nav -->
<script src="includes/vendors/owl.carousel/dist/owl.carousel.js" type="text/javascript"></script>

		<!--end::Page Scripts -->
	</body>

	<!-- end::Body -->
</html>
 
      
<?php



/*The module link codes are hard coded in a switch statement below to determine the options to show for each tab */
include('includes/MainMenuLinksArray.php');

if (isset($SupplierLogin) AND $SupplierLogin==1){
	echo '<table class="table_index">
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=1">' . _('View or Amend outstanding offers') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=2">' . _('Create a new offer') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=3">' . _('View any open tenders without an offer') . '</a></p>
			</td>
			</tr>
		</table>';
	include('includes/footer.inc');
	exit;
} elseif (isset($CustomerLogin) AND $CustomerLogin==1){
	echo '<table class="table_index">
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/CustomerInquiry.php?CustomerID=' . $_SESSION['CustomerID'] . '">' . _('Account Status') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SelectOrderItems.php?NewOrder=Yes">' . _('Place An Order') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SelectCompletedOrder.php?SelectedCustomer=' . $_SESSION['CustomerID'] . '">' . _('Order Status') . '</a></p>
			</td>
			</tr>
		</table>';

	include('includes/footer.inc');
	exit;
}

if (isset($_GET['Application'])){ /*This is sent by this page (to itself) when the user clicks on a tab */
	$_SESSION['Module'] = $_GET['Application'];
}








//include('includes/footer.inc');

function GetRptLinks($GroupID) {
/*
This function retrieves the reports given a certain group id as defined in /reports/admin/defaults.php
in the acssociative array $ReportGroups[]. It will fetch the reports belonging solely to the group
specified to create a list of links for insertion into a table to choose a report. Two table sections will
be generated, one for standard reports and the other for custom reports.
*/
	global $db, $RootPath, $ReportList;
	require_once('reportwriter/languages/en_US/reports.php');
	require_once('reportwriter/admin/defaults.php');
	$GroupID=$ReportList[$GroupID];
	$Title= array(_('Custom Reports'), _('Standard Reports and Forms'));

	$sql= "SELECT id,
				reporttype,
				defaultreport,
				groupname,
				reportname
			FROM reports
			ORDER BY groupname,
					reportname";
	$Result=DB_query($sql,'','',false,true);
	$ReportList = '';
	while ($Temp = DB_fetch_array($Result)) $ReportList[] = $Temp;

	$RptLinks = '';
	for ($Def=1; $Def>=0; $Def--) {
        $RptLinks .= '<li class="menu_group_headers">';
        $RptLinks .= '<b>' .  $Title[$Def] . '</b>';
        $RptLinks .= '</li>';
		$NoEntries = true;
		if ($ReportList) { // then there are reports to show, show by grouping
			foreach ($ReportList as $Report) {
				if ($Report['groupname']==$GroupID AND $Report['defaultreport']==$Def) {
                    $RptLinks .= '<li class="menu_group_item">';
					$RptLinks .= '<p>&bull; <a href="' . $RootPath . '/reportwriter/ReportMaker.php?action=go&amp;reportid=' . $Report['id'] . '">' . _($Report['reportname']) . '</a></p>';
					$RptLinks .= '</li>';
					$NoEntries = false;
				}
			}
			// now fetch the form groups that are a part of this group (List after reports)
			$NoForms = true;
			foreach ($ReportList as $Report) {
				$Group=explode(':',$Report['groupname']); // break into main group and form group array
				if ($NoForms AND $Group[0]==$GroupID AND $Report['reporttype']=='frm' AND $Report['defaultreport']==$Def) {
                    $RptLinks .= '<li class="menu_group_item">';
					$RptLinks .= '<img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/folders.gif" width="16" height="13" alt="" />&nbsp;';
					$RptLinks .= '<p>&bull; <a href="' . $RootPath . '/reportwriter/FormMaker.php?id=' . $Report['groupname'] . '"></p>';
					$RptLinks .= $FormGroups[$Report['groupname']] . '</a>';
					$RptLinks .= '</li>';
					$NoForms = false;
					$NoEntries = false;
				}
			}
		}
		if ($NoEntries) $RptLinks .= '<li class="menu_group_item">' . _('There are no reports to show!') . '</li>';
	}
	return $RptLinks;
}
	
?>
<!-- Modal HTML embedded directly into document -->
<div id="ex1" class="modal">
  <p>Thanks for clicking. That felt good.</p>
  <a href="#" rel="modal:close">Close</a>
</div>


<!-- Modal -->
 <div class="modal fade" id="getCodeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog modal-lg">
      <div class="modal-content">
       <div class="modal-header">
         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
         <h4 class="modal-title" id="myModalLabel"> API CODE </h4>
       </div>
       <div class="modal-body" id="getCode" style="overflow-x: scroll;">
       
          
          
       </div>
    </div>
   </div>
 </div>



<script type="text/javascript">
jQuery(document).on("ready xcrudafterrequest",function(){
    
});
</script>