Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'fop_enqueue_conditional_scripts' not found or invalid function name in /home/u7097946/public_html/manciticomsec.com/wp-includes/class-wp-hook.php on line 303

main-calendar







Home


To Do List


KALENDER

day

[insert_php]
$host = “localhost:3306”; //database location
$user = “mancitic_calenda”; //database username
$pass = “manciti88”; //database password
$db_name = “mancitic_calendar”; //database name

//Database Connection
$connection = mysql_connect($host, $username, $password);
mysql_select_db($dbname);

function kalender($month, $year, $numOfDays)
{

// Create array containing abbreviations of days of week.
$daysOfWeek = array(‘S’, ‘M’, ‘T’, ‘W’, ‘T’, ‘F’, ‘S’);

$curDay = 1;//intval(date(‘d’));
// What is the first day of the month in question?
$hariPertama /*:unix timestamp*/ = mktime(0, 0, 0, $month, 1, $year);

// How many days does this month contain?
$numberDaysOfMonth = intval(date(‘t’, $hariPertama));
$rem = $numberDaysOfMonth – $curDay;
// Retrieve some information about the first day of the
// month in question.
$dateComponents = getdate($hariPertama);

// What is the name of the month in question?
$monthName = $dateComponents[‘month’];

// What is the index value (0-6) of the first day of the
// month in question.
$dayOfWeek = $dateComponents[‘wday’];

// Create the table tag opener and day headers

$calendar = “

“;
$calendar .= “

“;
$calendar .= “

“;

// Create the calendar headers

foreach ($daysOfWeek as $day) {
$calendar .= “

“;
}

// Create the rest of the calendar

// Initiate the day counter, starting with the 1st.

$currentDay = $curDay;

$calendar .= “

“;

// The variable $dayOfWeek is used to
// ensure that the calendar
// display consists of exactly 7 columns.

if ($dayOfWeek > 0) {
$calendar .= “

“;
}

$month = str_pad($month, 2, “0”, STR_PAD_LEFT);
$conn = get_connection();
if (!$conn) die(500);
$query = $conn->query(“SELECT * FROM kalender”);
$kalender = [];
while ($row = $query->fetch_assoc()) {

$d = intval(date(‘d’, $row[“tanggal”]));
$kalender[$d][“action”] = $row[“action”];
$kalender[$d][“status”] = $row[“status”];
}
while ($currentDay <= $numberDaysOfMonth) { // Seventh column (Saturday) reached. Start a new row. if ($dayOfWeek == 7) { $dayOfWeek = 0; $calendar .= "

“;

}

$currentDayRel = str_pad($currentDay, 2, “0”, STR_PAD_LEFT);

$date = “$year-$month-$currentDayRel”;
$color = “”;
if (array_key_exists($currentDay, $kalender)) {
if ($kalender[$currentDay][“status”] == 1) $color = “background: green”;
elseif ($kalender[$currentDay][“status”] == 2) $color = “background: red”;
}
$shortjump = $nosmoke = “”;
if (array_key_exists($currentDay, $kalender))
switch ($kalender[$currentDay][“action”]) {
case 1: //shortjump
$nosmoke = “disabled”;
break;
case 2: //nosmoke
$shortjump = “disabled”;
break;
}
$tanggal = mktime(null, null, null, $month, $currentDay, $year);
$confirmVisible = “”;

if (intval(date(‘d’, $tanggal)) != intval(date(‘d’))
|| !array_key_exists($currentDay, $kalender)
|| $kalender[$currentDay][“action”] == 0) {
$confirmVisible = ” style=’visibility: hidden'”;
}

$calendar .= “

“;

// Increment counters

$currentDay++;
$dayOfWeek++;

}

// Complete the row of the last week in month, if necessary

if ($dayOfWeek != 7) {

$remainingDays = 7 – $dayOfWeek;
$calendar .= “

“;

}

$calendar .= “

“;

$calendar .= “

$monthName $year
$day
 
$currentDay


 

“;

return $calendar;

}

$curMonth = date(‘n’);
$curYear = date(‘Y’);
echo kalender($curMonth, $curYear, 60);
[/insert_php]