Я пытаюсь сделать "kalendar" из меню в классе Module, чтобы выполнить действие как кнопку отправки из формы, которая называется "Semak Kekosongan" в классе Kalendar.Я не очень разбирался в платформе ATK.
Класс Kalendar
Этот класс является формой для перечисления утвержденной комнаты, а также новой / ожидающей
<?php
atkimport("modules.lesson_utils.dateutil");
class kalendar extends atkNode {
function kalendar ()
{
$this->atkNode("kalendar");
}
function kL ()
{
$this->atkNode("kL");
}
function getFilterRecord()
{
static $s_record = NULL;
global $g_sessionManager, $ATK_VARS;
$user=&atkGetUser();
$filter_previous = explode("/",$ATK_VARS['atkfilter']);
//print "filter=".$ATK_VARS['atkfilter'];
/*
$bulan_pilihan = $filter_previous[0];
$tahun_pilihan = $filter_previous[1];
$ptj_pilihan = $filter_previous[2];
$Bilik Mesyuarat_pilihan = $filter_previous[3];
*/
//print "pilihan bulan = $bulan_pilihan tahun = $tahun_pilihan ptj = $ptj_pilihan Bilik Mesyuarat = $Bilik Mesyuarat_pilihan";
if ($s_record==NULL) {
$s_record = array();
$s_record["tahun"] = $g_sessionManager->pageVar("tahun");
$s_record["bulan"] = $g_sessionManager->pageVar("bulan");
$s_record["bilik_mesyuarat"] = $g_sessionManager->pageVar("bilik_mesyuarat");
$s_record["id_ptj"] = $g_sessionManager->pageVar("id_ptj");
$s_record["pilihan"] = $g_sessionManager->pageVar("pilihan");
// convert attribute html values to internal values
$attrs = &$this->getFilterAttrs();
foreach (array_keys($attrs) as $attribname) {
$p_attrib = &$attrs[$attribname];
$s_record[$attribname] = &$p_attrib->fetchValue($s_record);
}
$go = $g_sessionManager->pageVar("go");
if ($go!=1) {
//lesson 2 - define initial value for input
$g_db=&atkGetDb();
if ($bulan_pilihan!="") {
//$s_record["bulan"] = $bulan_pilihan;
//$s_record["tahun"] = $tahun_pilihan;
//$s_record["id_ptj"] = $ptj_pilihan;
//$s_record["bilik_mesyuarat"] = $Bilik Mesyuarat_pilihan;
} else {
//set initial value
$query="SELECT MONTH(CURRENT_DATE()) as bulan, YEAR(CURRENT_DATE()) as tahun ";
$result=$g_db->getrows($query);
$s_record["bulan"] = $result[0][bulan];
$s_record["tahun"] = $result[0][tahun];
$s_record["id_ptj"] = $user['idptj'];
}
}
}
return $s_record;
}
function &getFilterAttrs()
{
$user=&atkGetUser();
//$attrs["tahun"] = &new atkListAttribute("tahun",array("2016","2017","2018","2019"),AF_OBLIGATORY|AF_LIST_NO_NULL_ITEM);
$attrs["tahun"] = &new atkListAttribute("tahun",array("2018","2019"),AF_OBLIGATORY|AF_LIST_NO_NULL_ITEM);
$attrs["bulan"] = &new atkListAttribute("bulan",array("Jan","Feb","Mac","Apr","Mei","Jun","Jul","Aug","Sep","Okt","Nov","Dis"),array("1","2","3","4","5","6","7","8","9","10","11","12"),AF_OBLIGATORY|AF_LIST_NO_NULL_ITEM);
$attrs["bilik_mesyuarat"] = &new atkManyToOneRelation("bilik_mesyuarat","tempahan.bilik_mesyuarat",AF_OBLIGATORY|AF_LIST_NO_NULL_ITEM); //
return $attrs;
}
function getFilterBar()
{
$record = $this->getFilterRecord();
$attrs = &$this->getFilterAttrs();
//lesson 3 - display input dlm bentuk html
$output = '<form action="'.getDispatchFile().'" method="get">';
$output.= session_form();
$output.= '<input type="hidden" name="go" value="1">'; //trigger to prevent loading the first time
//testing table column
// === START ===
//$output.= "<div>";
//$output.= "<div class = "column">";
// === END ===
$output.= "<table>";
$output.= "<tr><td colspan = '6'>".atktext("<font color='blue'>Kalendar Tempahan Bilik Mesyuarat hanya memaparkan tempahan Bilik Mesyuarat yang telah diluluskan sahaja<font><br>");
$output.= "<tr><td colspan = '6'>".atktext("<font color='black'>** Klik pada Tarikh untuk membuat tempahan<font><br>");
$output.= "<tr><td colspan = '6'>".atktext("<font color='black'>** Klik pada Bil Mesyuarat untuk menyemak maklumat tempahan<font><br><br>");
$output.= "<tr><td>".atktext(" Tahun : ").$attrs["tahun"]->edit($record)." </td>";
$output.= "<td>".atktext(" Bulan : ").$attrs["bulan"]->edit($record)." </td>";
$output.= "<td>".atktext(" Bilik Mesyuarat : ")." ".$attrs["bilik_mesyuarat"]->edit($record)." </td>";
$output.= "<td>".' <input type="submit" value="'.atktext(" Semak Kekosongan").'">'." </td>";
$output.= "</table><br>";
//Test table column
// === START ===
// === END ===
$output.= '</form>';
return $output;
}
/*
* The report call. This is a custom action for this node.
*/
function action_report()
{
$content = $this->getReportData1();
$page = &$this->getPage();
$page->addContent($this->renderActionPage("admin", $content));
$page->register_script(atkconfig("atkroot")."atk/javascript/newwindow.js");
/*
* Test second function new box output
* -----------------------------------
*/
//$content2 = $this->lK();
// ---------------END-----------------
}
/*
* The report output.
*/
//lesson 5 - design report
function getReportData1()
{
global $g_sessionManager;
$g_db=&atkGetDb();
$ui = &$this->getUi();
$this->addStyle("style.css");
$output = $this->getFilterBar();
$filterrecord = $this->getFilterRecord();
$bilik_mesyuarat = $filterrecord["bilik_mesyuarat"];
//first time generate
if ($bilik_mesyuarat=="") {
$bilik_mesyuarat['id'] = 1;
}
$user=&atkGetUser();
$go = $g_sessionManager->pageVar("go");
$parts = explode('-',$currdate);
$year = $parts[0];
$month = $parts[1];
$today_day=date("j"); //If today is September 29, $day_num=29
$today_month = date("m"); //If today is September 29, $month_num=9
$today_year = date("Y"); //4-digit year
$month_num = $filterrecord["bulan"]; //If today is September 29, $month_num=9
$year = $filterrecord["tahun"]; //4-digit year
$date_today = getdate(mktime(0,0,0,$month_num,1,$year)); //Returns array of date info for 1st day of this month
$month_name = $date_today["month"]; //Example: "September" - to label the Calendar
$first_week_day = $date_today["wday"]; //"wday" is 0-6, 0 being Sunday. This is for day 1 of this month
$cont = true;
$today = 27; //The last day of the month must be >27, so start here
while (($today <= 32) && ($cont)) //At 32, we have to be rolling over to the next month
{
//Iterate through, incrementing $today
//Get the date information for the (hypothetical) date $month_num/$today/$year
$date_today = getdate(mktime(0,0,0,$month_num,$today,$year));
//Once $date_today's month ($date_today["mon"]) rolls over to the next month, we've found the $lastday
if ($date_today["mon"] != $month_num)
{
$lastday = $today - 1; //If we just rolled over to the next month, need to subtract 1 to get our $lastday
$cont = false; //This kicks us out of the while loop
}
$today++;
}
$month_CAP = strtoupper ( $month_name );
$prev_month = $month_num - 1;
$next_month = $month_num + 1;
$next_year = $year;
$prev_year = $year;
$ptj_next = $id_ptj['id'];
if ($prev_month==0) {
$prev_month = 12;
$prev_year = $year - 1;
}
if ($next_month==13) {
$next_month = 1;
$next_year = $year + 1;
}
$output.= "<table cellspacing=2 cellpadding=5 frame='all' rules='all' style='border:solid #808080 1px ;' >";
$output.= "<caption><b><font color = 'dark blue' size = '5'> $url_prev_month $month_CAP $year $url_next_month </b></caption>";
$output.= "<tr align=center bgcolor=#0080ff>
<th style='border:solid #aed6f1'><font color='white'>Ahad</th>
<th style='border:solid #aed6f1'><font color='white'>Isnin</th>
<th style='border:solid #aed6f1'><font color='white'>Selasa</th>
<th style='border:solid #aed6f1'><font color='white'>Rabu</th>
<th style='border:solid #aed6f1'><font color='white'>Khamis</th>
<th style='border:solid #aed6f1'><font color='white'>Jumaat</th>
<th style='border:solid #aed6f1'><font color='white'>Sabtu</th></font></tr>";
$day = 1; //This variable will track the day of the month
$wday = $first_week_day; //This variable will track the day of the week (0-6, with Sunday being 0)
$firstweek = true; //Initialize $firstweek variable so we can deal with it first
//print "<br>after..ptj = $id_ptj[id] Bilik Mesyuarat =$bilik_mesyuarat[bilik_mesyuarat] <br> ";
while ( $day <= $lastday) //Iterate through all days of the month
{
if ($firstweek) {//Special case - first week (remember we initialized $first_week_day above)
$output.= "<tr align=left>";
for ($i=1; $i<=$first_week_day; $i++)
{
$output.= "<td height = '80' style='border:solid #aed6f1' bgcolor = '#808b96'> </td>"; //Put a blank cell for each day until you hit $first_week_day
}
$firstweek = false; //Great, we're done with the blank cells
}
if ($wday==0){ //Start a new row every Sunday
$output.= "<tr align=left>";
}
$output.= "<td height = '80' valign='top' style='width:120px; border:solid #aed6f1'";
$hari_ini = $year."-".$month_num."-".$day;
$url = $trip = "";
$url2 = $trip2 = ""; #boleh delete
$penuh = false;
$masa = 0;
$query1 = "SELECT time(tarikh_mula) as masa_mula, time(tarikh_tamat) as masa_tamat
FROM ttempahan
INNER JOIN tbilik_mesyuarat ON ttempahan.idbilik_mesyuarat = tbilik_mesyuarat.id
WHERE kelulusan = 'LULUS'
AND '$hari_ini' BETWEEN DATE(tarikh_mula) AND DATE(tarikh_tamat)
AND ttempahan.idbilik_mesyuarat LIKE '".$bilik_mesyuarat['id']."'
ORDER BY 1";
$result1=$g_db->getrows($query1);
foreach ($result1 as $row) {
$masa = $masa + ($row['masa_tamat'] - $row['masa_mula']);
}
if ($masa>6) { // dalam sehari kalau mesyuarat lebih 7 jam so dikira penuh
$penuh = true;
}
#print $hari_ini. " ".$masa."<br>";
$query2 = "SELECT
CASE sesi
WHEN '1' THEN 'Pagi'
WHEN '2' THEN 'Petang'
WHEN '3' THEN 'Full Day'
END AS sesi,
nama_bilik_mesyuarat, COUNT(*) jumlah_tempahan
FROM ttempahan
INNER JOIN tbilik_mesyuarat ON ttempahan.idbilik_mesyuarat = tbilik_mesyuarat.id
WHERE kelulusan = 'LULUS'
AND '$hari_ini' BETWEEN DATE(tarikh_mula) AND DATE(tarikh_tamat)
AND ttempahan.idbilik_mesyuarat LIKE '".$bilik_mesyuarat['id']."'
GROUP BY 1,2
ORDER BY 1";
// Testing query to show pending link
// === START ===
$query3 = "SELECT
CASE sesi
WHEN '1' THEN 'Pagi'
WHEN '2' THEN 'Petang'
WHEN '3' THEN 'Full Day'
END AS sesi,
nama_bilik_mesyuarat, COUNT(*) jumlah_tempahan
FROM ttempahan
INNER JOIN tbilik_mesyuarat ON ttempahan.idbilik_mesyuarat = tbilik_mesyuarat.id
WHERE NOT kelulusan = 'LULUS'
AND '$hari_ini' BETWEEN DATE(tarikh_mula) AND DATE(tarikh_tamat)
AND ttempahan.idbilik_mesyuarat LIKE '".$bilik_mesyuarat['id']."'
GROUP BY 1,2
ORDER BY 1";
// === END ===
//print $query;
//die();
$result2=$g_db->getrows($query2);
$i = 1;
foreach ($result2 as $row) {
if ($row['sesi']=='Full Day') {
$penuh = true;
}
$trip .= $row['sesi']." (".$row['jumlah_tempahan'].")<br>";
$idbilik = $bilik_mesyuarat[id];
$url = '<a href="javascript:NewWindow(\'dispatch.php?atknodetype=tempahan.view_tempahan&atkaction=report&atkfilter='.$hari_ini.'|'.$bilik_mesyuarat[id].'|'.$row[nama_bilik_mesyuarat].'\',\'popuplink\',800,500,\'yes\',\'yes\')">'.$trip.'</a><br/>';
//$output.= "<br><b>".$url;
}
//background-image: url(image/back.gif)
// === START to print test query 3 ====
$result3=$g_db->getrows($query3);
$i = 1;
foreach ($result3 as $row) {
if ($row['sesi']=='Full Day') {
$penuh = true;
}
$trip2 .= $row['sesi']." (".$row['jumlah_tempahan'].")<br>";
$idbilik = $bilik_mesyuarat[id];
$url2 = '<font color="orange"><a href="javascript:NewWindow(\'dispatch.php?atknodetype=tempahan.view_tempahan&atkaction=report&atkfilter='.$hari_ini.'|'.$bilik_mesyuarat[id].'|'.$row[nama_bilik_mesyuarat].'\',\'popuplink\',800,500,\'yes\',\'yes\')" style="color: inherit;">'.$trip2.'</a></font><br/>';
//$output.= "<br><b>".$url;
}
// === END ===
if ($penuh) {
//$output.= "background ='C:\wamp\www\tempahan_bilikmesyuarat\modules\tempahan\rrrrrdiagonal_stripe_ed_shop_preview.png' height='6px' no_repeat width='6px' align = 'left'"; //highlight TODAY in yellow
//$output.= "background ='http://zaidyhomestay.my/uploads/9/0/7/1/90716519/full_1.png' height='5px' no_repeat width='5px' align = 'left'"; //highlight TODAY in yellow
// $output.= "background: url(../images/menuBg.jpg) repeat-y left top";
}
else {
if($day==$today_day && $month_num==$today_month) {
$output.= " bgcolor=' #fef9e7'"; //highlight TODAY in yellow
} else if ($wday=='0'||$wday=='6'){ //aiza 19022019
$output.= " bgcolor='#e5e8e8'"; // jumaat dan sabtu
} else {
$output.= " bgcolor='white'"; // weekeday
}
}
$tarikhhariini = strtotime(date("Y-m-d"));
$selected_day_str = strtotime(date($hari_ini));
if ($selected_day_str >= $tarikhhariini){
$url_add=href(dispatch_url("tempahan.senarai_tempahan_user","add",array("atkfilter"=>$hari_ini,"idbilikmesy"=>$bilik_mesyuarat['id'])),"<font color='blue'>$day</font>","","","style='text-decoration:none;'");
} else {
$url_add = $day;
}
$output.="><b>$url_add</b><br>";
$output.= "<br><b>".$url;
//Test link for pending/new result
//=== START ===
$output.= "<br><b>".$url2;
//=== END ===
$output.= "</td>";
if ($wday==6)
$output.= "</tr>"; //If today is Saturday, close this row
$wday++; //Increment $wday
$wday = $wday % 7; //Make sure $wday stays between 0 and 6 (so when $wday++ == 7, this will take it back to 0)
$day++; //Increment $day
}
while($wday <=6 ) //Until we get through Saturday
{
$output.= "<td height = '80' style='border:solid #aed6f1' bgcolor = '#808b96'> </td>"; //Output an empty cell
$wday++;
}
$output.= "</tr></table>";
//$tr = &atknew("atk.utils.atktablerenderer");
//$output .= $tr->render($tableData, TBL_DATA, "recordlist")."<br/>";
//$output .= $tr->render($tableData, TBL_DATA, "recordlist");
//}
// Render a box around the generated output
$boxedoutput = $ui->renderBox(array("title"=>$this->actionTitle('report'), "content"=>$output));
// Return the generated boxed output
return $boxedoutput;
//return $box2();
}
//test wan
/*
* function box2()
* {
*
* $output2.="<table border='1' 'swing:right'>";
* $output2.="<tr><td>TEST</td></tr>";
* $output2.="</table>";
*
* $boxedoutput2 = $ui->renderBox(array("title"=>$this->actionTitle('report'), "content"=>$output2));
*
* return $boxedoutput2;
* }
*/
//end testwan
}
?>
Модуль класса для меню
<?php
class mod_tempahan extends atkModule
{
var $module = "tempahan";
//Am
//START AM ("Testing")
//END Am
function getMenuItems()
{
$user=&atkGetUser();
if ($user['profile_id']!=9 || $user=="") { //9 = guest , user null = administrator
//$this->menuitem("Kalendar", dispatch_url("tempahan.kalendar", "report"),"main");
//------Am Testing kalendar testing---------------------
//----------------------START---------------------------
$this->menuitem("Kalendar", dispatch_url("tempahan.kalendar", "record"),"main");
//-----------------------END----------------------------
if ($user['profile_id']==1) { //1 = pengguna
$this->menuitem("Senarai Tempahan", dispatch_url("tempahan.senarai_tempahan_user", "admin"),"main");
$this->menuitem("Penyelaras","","main");
$this->menuitem("Senarai Penyelaras", dispatch_url("tempahan.penyelaras", "admin"),"Penyelaras");
} else {
$this->menuitem("Senarai Tempahan", dispatch_url("tempahan.senarai_tempahan_user", "admin",Array("atkfilter" => "ttempahan.idpemohon = '".$user['id']."'")),"main");
}
if ($user['profile_id']==3 || $user['profile_id']==2 ) { //3 = penyelaras, 2 = admin
//AM
$this->menuitem("Kalendar", dispatch_url("tempahan.kalendar", "admin", "report"),"main");
//AM END
$this->menuitem("Penyelaras","","main");
$this->menuitem("Semua Tempahan", dispatch_url("tempahan.senarai_tempahan_penyelaras", "admin",Array("jenis"=>"PENYELARAS")),"Penyelaras");
$this->menuitem("Baru/Pending", dispatch_url("tempahan.senarai_tempahan_penyelaras", "admin",Array("atkfilter" => "ttempahan.kelulusan IN ('BARU','PENDING')","jenis"=>"PENYELARAS")),"Penyelaras");
$this->menuitem("Senarai Penyelaras", dispatch_url("tempahan.penyelaras", "admin"),"Penyelaras");
$this->menuitem("Senarai Tempahan Mesyuarat", dispatch_url("tempahan.semak_mesyuarat_detail", "report"),"Penyelaras");
}
$this->menuitem("Bilik_Mesyuarat","","main");
$this->menuitem("Senarai_Bilik_Mesyuarat", dispatch_url("tempahan.bilik_mesyuarat", "admin"),"Bilik_Mesyuarat");
}
}
function getNodes()
{
//registerNode("tempahan.kalendar", array("report"));
//AM
registerNode("tempahan.kalendar", getDispatchFile("go"));
//END AM
registerNode("tempahan.view_tempahan", array("report"));
registerNode("tempahan.senarai_tempahan_user", array("admin","add","edit","delete"));
registerNode("tempahan.senarai_tempahan_penyelaras", array("admin","add","edit","delete"));
registerNode("tempahan.bilik_mesyuarat", array("admin","add","edit","delete"));
registerNode("tempahan.penyelaras", array("admin","add","edit","delete"));
registerNode("tempahan.kemudahan", array("admin","add","edit","delete"));
registerNode("tempahan.bilik_kemudahan", array("admin","add","edit","delete"));
registerNode("tempahan.bilik_penyelaras", array("admin","add","edit","delete"));
registerNode("tempahan.view_sejarah_kemaskini", array("admin"));
registerNode("tempahan.semak_mesyuarat_detail", array("report"));
}
//END AM
}
?>