Persyarat:
Sistem Operasi : Linux (dianjurkan Red Hat 9)
Web Server
: Apache
Database Server : MySQL
Program lain
: PHP
Instalasi:
a.
Instalasi Web Server
Langkah pertama yang harus dilakukan adalah instalasi web server. Biasanya
di sistem operasi Linux telah tersedia Web Server Apache, terkecuali Linux
yang dibuat oleh distro tertentu yang tidak menyertakan Apache di dalamnya.
b.
Instalasi PHP
PHP ini diperlukan karena aplikasi ini disusun dengan menggunakan bahasa
pemrograman PHP. PHP yang digunakan adalah PHP versi 4 ke atas. Pada
Linux yang menyediakan fasilitas Web Services umumnya telah menyediakan
PHP di dalamnya.
c.
Copy Program
Pada konfigurasi Apache standard di Linux, semua data website disimpan
dalam direktory /var/www/html. Maka direktori eoffice dikopikan ke direktori
website tersebut dengan melakukan perintah cp –r * /var/www/html, dari
dalam direktori eoffice.
d.
Instalasi Database Server
Database
server yang digunakan pada aplikasi ini adalah MySQL, dimana
umumnya Linux pun menyertakan program ini dalam sistem operasinya. Dan
untuk mengoperasikannya, kita bisa masuk dengan mengetikkan perintah
mysql di dalam console Linux.
e.
Create Database
Pada awalnya, MySQL tidak menyediakan database kecuali database milik
MySQL sendiri. Untuk itu kita harus membuat sebuah database dengan nama
“eoffice” untuk menjalankan E-Office ini. Gunakan console Linux dan
ketikkan perintah mysql dan tekan enter. Kita berada di dalam console
MySQL, dan di dalamnya kita masukkan perintah CREATE DATABASE
eoffice.
f.
Create User pada Database
Untuk mengaktifkan user agar bisa website E-Office bisa mengakses database
eoffice ini, di dalam console MySQL kita mengetikkan GRANT all privileges
on eoffice.* to eoffice@localhost identified by "AuraLL" with grant option;
g.
Memasukkan isi database
Untuk memasukkan isi inisial database ini, maka kita harus memasukkan
seluruh isi query awal ke dalam database mysql dengan menggunakan
perintah mysql eoffice < [eoffice dir]/query/eoffice.sql
Lampiran 2. Source code class date
<?PHP/*
COMPLETE DATE TIME FUNCTIONS FOR COMPLEX CALCULATION OF DATE AND TIME
USING SOME DIFFERENT STANDARD OF DATE AND TIME, FOR DECREASING CALCULATION
COMPLEXITY. THIS IS USED MOST BY CALENDAR AND TIMELINE CLASS */ define( 'D_SUNDAY', 0 ); define( 'D_MONDAY', 1 ); define( 'D_TUESDAY', 2 ); define( 'D_WENESDAY', 3 ); define( 'D_THURSDAY', 4 ); define( 'D_FRIDAY', 5 ); define( 'D_SATURDAY', 6 ); define( 'M_JANUARY', 1 ); define( 'M_FEBRUARY', 2 ); define( 'M_MARCH', 3 ); define( 'M_APRIL', 4 ); define( 'M_MAY', 5 ); define( 'M_JUNE', 6 ); define( 'M_JULY', 7 ); define( 'M_AUGUST', 8 ); define( 'M_SEPTEMBER', 9 ); define( 'M_OCTOBER', 10); define( 'M_NOVEMBER', 11); define( 'M_DECEMBER', 12); define( 'SEC_MINUTE', 60 ); define( 'SEC_HOUR', 3600 ); define( 'SEC_DAY', 86400 ); class eo_date {
// VARIABLE USED BY THIS CLASS
var $current_date = null;
var $current_day = null;
var $current_day_on_week = null;
var $current_month = null;
var $current_year = null;
var $current_day_string = null; var $current_day_short_string = null; var $current_month_string = null; var $current_month_short_string = null; var $current_week_on_month = null; var $current_day_on_year = null; var $current_week_on_year = null;
var $date_flag = null;
// FUNCTION USED BY THIS CLASS //CONSTRUCTOR
* @return eo_date * @param unknown $d * @param unknown $m * @param unknown $y
* @desc EOffice Date Object Constructor */
function eo_date($d=null, $m=null, $y=null) {
$this->init();
$this->set_now();
if ($d != null) $this->set_day($d); if ($m != null) $this->set_month($m); if ($y != null) $this->set_year($y); $this->apply_current(); } function init() { $this->current_day = 0; $this->current_day_on_week = 0; $this->current_month = 0; $this->current_year = 0; $this->current_day_string = ""; $this->current_day_short_string = ""; $this->current_month_string = ""; $this->current_month_short_string = ""; $this->current_week_on_month = 0; $this->current_day_on_year = 0; $this->current_week_on_year = 0; } function apply_from_date() { $this->current_day =
$this->current_date["mday"]; //TANGGAL DLM BULAN
$this->current_day_on_week =
$this->current_date["wday"]; //TANGGAL DLM MINGGU, HARI KE-
$this->current_month =
$this->current_date["mon"];
$this->current_year =
$this->current_date["year"];
$this->current_day_string =
$this->current_date["weekday"]; //HARI DALAM NAMA, SENIN, DKK $this->current_day_short_string =
$this->num_to_short_days($this->current_date["wday"]); //HARI DALAM NAMA, SENIN, DKK
$this->current_month_string = $this->current_date["month"]; //BULAN DLM NAMA, JANUARY, DKK >current_month_short_string =
$this->num_to_short_month($this->current_date["mon"]); //BULAN DLM NAMA, JANUARY, DKK
$this->current_day_on_year = $this->current_date["yday"]; //HARI DLM TAHUN, HARI KE-2XX
$this->current_week_on_month = floor($this->current_day / 7) + 1; //MINGGU DLM BULAN, MINGGU KE-
$this->current_week_on_year = floor($this->current_day_on_year / 7) + 1; //MINGGU DLM TAHUN, MINGGU KE 2X }
$stamp = mktime(0, 0, 0, $this->current_month, $this->current_day, $this->current_year); $this->current_date = getdate($stamp); $this->apply_from_date(); } function check_date() {
return (checkdate(>current_month, $this->current_day, $this->current_year));
}
function if_false_then_reset_date() {
if (!$this->check_date()) $this->set_now(); }
//BASIC FUNCTIONS SET
function set_now($timestamp=null) { if ($timestamp == null) { $d = date("d"); $m = date("m"); $y = date("Y");
$stamp = mktime(0, 0, 0, $m, $d, $y); $this->current_date = getdate($stamp); $this->set_date($d, $m, $y); } else { $this->current_date = getdate($timestamp); } $this->apply_from_date(); } function set_day($d) { $this->current_day = $d; } function set_month($m) { $this->current_month = $m; } function set_year($y) { $this->current_year = $y; }
function set_date($d, $m, $y) { $this->current_day = $d; $this->current_month = $m; $this->current_year = $y; } function set_mysql_date($mysd) { $tmp = explode("-", $mysd); $this->set_date($tmp[2], $tmp[1], $tmp[0]); $this->apply_current(); }
//BASIC FUNCTION GET
return ($this->current_day." ".$this->current_month_string." ".$this->current_year); } function get_day_string() { return ($this->current_day_string); } function get_day_number_week() { return ($this->current_day_on_week); } function get_day_number() { return ($this->current_day); } function get_day_on_year_number() { return ($this->current_day_on_year); } function get_days_in_month() {
return (cal_days_in_month($cal, $this->get_month(), $this->get_year())); } function get_date_number() { return ($this->current_day); } function get_month() { return ($this->current_month); } function get_month_string() { return ($this->current_month_string); } function get_year() { return ($this->current_year); } function get_week_on_month() { return ($this->current_week_on_month); } function get_days_before_new_year() { $total = $this->get_days_before_new_month();
for (($count = $this->current_month + 1); $count <= 12; $count++) {
$total += cal_days_in_month($cal, $count, $this->current_year);
}
return ($total);
}
function get_days_before_new_month() {
$days_month_total = cal_days_in_month($cal, $this->current_month, $this->current_year);
return ($days_month_total - $this->current_day); } function get_weeks_before_new_year() { return (floor($this->get_days_before_new_year() / 7)); } function get_months_before_new_year() { return (12 - $this->current_month); } //MOVEMENT FUNCTIONS function next_year($inc=null) { if ($inc == null) $inc = 1;
$this->current_year += $inc; $this->apply_current(); } function next_beginning_year($inc=null) { $this->current_month = 1; $this->current_day = 1; $this->next_year(); } function previous_year($inc=null) { if ($inc == null) $inc = 1;
$this->current_year -= $inc; $this->apply_current(); }
function next_month($inc=null) { if ($inc == null) $inc = 1; $this->current_month += $inc; $this->apply_current(); }
function next_beginning_month($inc=null) { if ($inc == null) $inc = 1;
$this->set_day(1);
$this->next_month($inc); }
function previous_month($inc=null) { if ($inc == null) $inc = 1; $this->current_month -= $inc; $this->apply_current(); }
function next_week($inc=null) { if ($inc == null) $inc = 1;
$this->current_day += (7 * $inc); $this->apply_current(); }
function previous_week($inc=null) { if ($inc == null) $inc = 1;
$this->current_day = $month_end_date - ($inc * 7); $this->apply_current();
}
function next_day($inc=null) { if ($inc == null) $inc = 1; $this->current_day += $inc; $this->apply_current(); }
function previous_day($inc=null) { if ($inc == null) $inc = 1; $this->current_day -= $inc; $this->apply_current(); }
//WRITING FUNCTIONS
function write_vars() {
echo "Day | ".$this->current_day_string."<BR>"; echo "Date | ".$this->current_day."<BR>"; echo "Month | ".$this->current_month."<BR>"; echo "Month Word |
".$this->current_month_string."<BR>";
echo "Year | ".$this->current_year."<BR>"; echo "Days of Year |
".$this->current_day_on_year."<BR>";
echo "Weeks of Month | ".$this->current_week_on_month."<BR>";
echo "Weeks of Year| ".$this->current_week_on_year."<BR>";
echo "Days before New Month | ".$this->get_days_before_new_month()."<BR>";
echo "Days before New Year | ".$this->get_days_before_new_year()."<BR>";
echo "Weeks before New Year | ".$this->get_weeks_before_new_year()."<BR>"; } function write_date($code) { } function write_date_simple() { $buffer = "\n".$this->current_day."-".$this->current_month."-".substr($this->current_year, 2, 2); echo $buffer; } function write_date_short() {
$buffer = $this->current_day_short_string.", ".$this->current_day." ".$this->current_month_short_string."
".substr($this->current_year, 2, 2);
echo $buffer;
function write_date_complete() {
$buffer = $this->current_day_string.", >current_day." >current_month_string." ".$this->current_year; echo $buffer; } function write_date_numbers() { $buffer = $this->current_year."-".$this->current_month."-".$this->current_day; echo $buffer; } //CONVERTING FUNCTIONS function timestamp_to_string($time){ $year = substr($time, 0, 4); $month = substr($time, 4, 2); $month_word = $this->num_to_month($month); $date = substr($time, 6, 2); $hour = substr($time, 8, 2); $minute = substr($time, 10, 2); $second = substr($time, 12, 2);
$stamp = mktime($hour, $minute, $second, $month, $date, $year);
$str_date = $date." ".$month_word." ".$year; $str_time = $hour.":".$minute.":".$second; return array ($year, $month_word, $date, $hour, $minute, $second, $stamp, $str_date, $str_time);
}
function num_to_days($num) {
$num %= 7;
if ($num == "01") $day_word = "Sunday"; if ($num == "02") $day_word = "Monday"; if ($num == "03") $day_word = "Tuesday"; if ($num == "04") $day_word = "Wednesday"; if ($num == "05") $day_word = "Thursday"; if ($num == "06") $day_word = "Friday"; if ($num == "07") $day_word = "Saturday";
return ($day_word);
}
function num_to_month($num) {
$num %= 13;
if ($num == "01") $month_word = "January"; if ($num == "02") $month_word = "February"; if ($num == "03") $month_word = "March"; if ($num == "04") $month_word = "April"; if ($num == "05") $month_word = "May"; if ($num == "06") $month_word = "June"; if ($num == "07") $month_word = "July";
if ($num == "08") $month_word = "August"; if ($num == "09") $month_word = "September"; if ($num == "10") $month_word = "October"; if ($num == "11") $month_word = "November"; if ($num == "12") $month_word = "December";
return ($month_word);
}
function num_to_short_days($num) {
$num %= 7;
if ($num == "01") $day_word = "Sun"; if ($num == "02") $day_word = "Mon"; if ($num == "03") $day_word = "Tue"; if ($num == "04") $day_word = "Wed"; if ($num == "05") $day_word = "Thu"; if ($num == "06") $day_word = "Fri"; if ($num == "07") $day_word = "Sat";
return ($day_word); } function num_to_bit_days($num) { $num %= 7; if ($num == "01") $day_word = "S"; if ($num == "02") $day_word = "M"; if ($num == "03") $day_word = "T"; if ($num == "04") $day_word = "W"; if ($num == "05") $day_word = "T"; if ($num == "06") $day_word = "F"; if ($num == "07") $day_word = "S"; return ($day_word); } function num_to_short_month($num) { $num %= 13; if ($num == 0) $num = 1;
if ($num == "01") $month_word = "Jan"; if ($num == "02") $month_word = "Feb"; if ($num == "03") $month_word = "Mar"; if ($num == "04") $month_word = "Apr"; if ($num == "05") $month_word = "May"; if ($num == "06") $month_word = "Jun"; if ($num == "07") $month_word = "Jul"; if ($num == "08") $month_word = "Aug"; if ($num == "09") $month_word = "Sep"; if ($num == "10") $month_word = "Oct"; if ($num == "11") $month_word = "Nov"; if ($num == "12") $month_word = "Dec";
return ($month_word);
} }
//================================================================ ===============================
//================================================================ ===============================
//================================================================ ===============================
/*
FUNCTIONS FOR DATE CALCULATING, USE EO_DATE ABOVE ============================================== */
function cal_days_of_year($y) { $total = 0;
for ($count = 1; $count < 12; $count++) {
$total += cal_days_in_month($cal, $count, $y); }
return ($total);
}
function cal_count_to_days($d, $m, $y=null) { if ($y == null) $cy = date("Y");
$days = $d;
for ($count = 1; $count <= $y; $count++) {
$days += cal_days_of_year($cy + $count - 1); }
for ($count_2 = 1; $count_2 <= $m; $count_2++) {
$days += cal_days_in_month($cal, $count_2, $cy + $count) + 1;
}
return ($days);
}
function cal_count_to_months($m=null, $y=null) { return ($m + ($y * 12));
}
function cal_count_2_days($d2, $m2=null, $y2=null, $d1=null, $m1=null, $y1=null) {
$total = 0;
$date_1 = new eo_date($d1, $m1, $y1); $date_2 = new eo_date($d2, $m2, $y2);
$year = abs($date_2->get_year() - $date_1->get_year());
switch ($year) {
case 0 : {
if ($date_1->current_month == $date_2->current_month) {
$total = $date_2->current_day - $date_1->current_day;
} else {
$total =
$date_1->get_days_before_new_month();
for (($count = $date_1->current_month + 1); $count < $date_2->current_month; $count++) {
$total += cal_days_in_month($cal, $count, $date_1->current_year); } $total += $date_2->current_day; } break; } default: { $total = $date_1->get_days_before_new_year();
for (($count = $date_1->current_year + 1); $count < $date_2->current_year; $count++) {
$total += cal_days_of_year($count); } $total += $date_2->current_day_on_year; break; } } return ($total); }
function cal_count_2_days_date($date_1, $date_2) { $total = 0;
$year = abs($date_2->get_year() - $date_1->get_year()); switch ($year) {
case 0 : {
if ($date_1->current_month == $date_2->current_month) {
$total = $date_2->current_day - $date_1->current_day;
} else {
$total =
$date_1->get_days_before_new_month();
for (($count = $date_1->current_month + 1); $count < $date_2->current_month; $count++) {
$total += cal_days_in_month($cal, $count, $date_1->current_year); } $total += $date_2->current_day; } break; } default: { $total = $date_1->get_days_before_new_year();
for (($count = $date_1->current_year + 1); $count < $date_2->current_year; $count++) {
} $total += $date_2->current_day_on_year; break; } } return ($total); }
function cal_count_2_weeks($d2, $m2, $y2, $d1=null, $m1=null, $y1=null) {
return ((cal_count_days($d2, $m2, $y2, $d1, $m1, $y1)) / 7); }
function cal_count_2_months($d2, $m2, $y2, $d1=null, $m1=null, $y1=null) {
$total = 0;
$date_1 = new eo_date($d1, $m1, $y1); $date_2 = new eo_date($d2, $m2, $y2);
$year = abs($date_2->get_year() - $date_1->get_year()); switch ($year) { case 0 : { if ($date_1->current_month != $date_2->current_month) { $total = ($date_2->current_month - $date_1->current_month) - 1; $sub_total = $date_1->get_days_before_new_month(); $sub_total += $date_2->current_day; $total += $sub_total / 30; } break; } default: { $total = $date_1->get_months_before_new_year(); $total += ($year - 1) * 12; $total += $date_2->current_month - 1; $sub_total = $date_1->get_days_before_new_month(); $sub_total += $date_2->current_day; $total += $sub_total / 30; break; } } return (printfloat($total, 2));
}
function cal_count_years($d2, $m2, $y2, $d1=null, $m1=null, $y1=null) {
return (printfloat((cal_count_days($d2, $m2, $y2, $d1, $m1, $y1) / 365), 2));
}
function printfloat($float, $dec) {
$tmp = substr($float, 0, strpos($float, ".") + $dec + 1); if (substr($tmp, strlen($tmp) - 1, 1) == ".") $tmp = substr($tmp, 0, strlen($tmp) - 1);
return ($tmp);
}
function cal_days_to_date_complete($days, $m = null) { if ($month == null) $m = 1;
$y = 1970;
$stamp = mktime(0, 0, 0, $m, $days, $y); $date_temp = getdate($stamp);
$td = $date_temp["mday"]; $tm = $date_temp["mon"] - 1; $ty = $date_temp["year"] - $y; return (array($td, $tm, $ty)); }
function copy_date($source, $dest) {
$dest->set_day($source->get_day_number()); $dest->set_month($source->get_month()); $dest->set_year($source->get_year()); $dest->apply_current();
}
function is_bigger($date_1, $date_2) {
if ($date_1->get_year() > $date_2->get_year()) { return(1);
} elseif ($date_1->get_year() < $date_2->get_year()) { return(0);
} else {
if ($date_1->get_month() > $date_2->get_month()) { return(1);
} elseif ($date_1->get_month() < $date_2->get_month()) { return(0); } else { if ($date_1->get_day_number() > $date_2->get_day_number()) { return(1);
} elseif ($date_1->get_day_number() < $date_2->get_day_number()) {
return(0);
} else {
return(0); }
} }
}
function is_same($date_1, $date_2) {
if (($date_1->get_year() == $date_2->get_year()) && ($date_1->get_month() == $date_2->get_month()) && ($date_1->get_day_number() == $date_2->get_day_number())) { return(1); } else { return(0); } }
function next_beginning_year_until($start, $end) { $tmp = new eo_date();
copy_date($start, &$tmp); $start->next_beginning_year();
$stop = is_bigger($start, $end); copy_date($tmp, &$start);
if ($stop == 1) { //IF STOP TO
END DATE
$interval = cal_count_2_days($end->get_day_number(), $end->get_month(), $end->get_year(), $start->get_day_number(), $start->get_month(), $start->get_year());
copy_date($end, &$start);
} else { //IF NOT
STOP TO END DATE, STILL FAR TO END DATE
$interval = $start->get_days_before_new_year() + 1; $start->next_beginning_year();
}
return(array ($stop, $interval)); }
function list_days_year($start, $end) { $check = 0; $count = 0; $list[] = null; $year[] = null; while ($check == 0) { $year[$count] = $start->get_year(); $tmp = next_beginning_year_until(&$start, $end); $check = $tmp[0]; $list[$count] = $tmp[1]; $count++; } return(array($list, $year)); }
function next_beginning_month_until($start, $end) { $tmp = new eo_date();
copy_date($start, &$tmp); $start->next_beginning_month();
$stop = is_bigger($start, $end); copy_date($tmp, &$start);
if ($stop == 1) { //IF STOP TO
END DATE
$interval = cal_count_2_days($end->get_day_number(), $end->get_month(), $end->get_year(), $start->get_day_number(), $start->get_month(), $start->get_year());
copy_date($end, &$start);
} else { //IF NOT
STOP TO END DATE, STILL FAR TO END DATE
$interval = $start->get_days_before_new_month() + 1; $start->next_beginning_month();
}
return(array ($stop, $interval)); }
function list_days_month($start, $end) { $check = 0; $count = 0; $list[] = null; $month[] = null; while ($check == 0) { $month[$count] = $start->get_month(); $tmp = next_beginning_month_until(&$start, $end); $check = $tmp[0]; $list[$count] = $tmp[1]; $count++; } return(array($list, $month)); }
Lampiran 3. Source code class Timeline
<?PHP/*
TIMELINE FUNCTION, IDENTICALLY SIMILLIAR WITH GANTT CHART BUT THIS TIMELINE IS MORE SIMPLE AND EASY TO UNDERSTAND. SURE, THAT THIS FUNCTION MADE FOR PROGRAMMING OPTIMATION. NEED EO_DATE CLASS : THE MOST COMPLETE DATE FUNCTIONS HAHAHA */
class eo_single_timeline { var $header = null;
var $start_date = null; var $end_date = null;
var $start_line_date = null; var $end_line_date = null; var $link = null;
var $depend = array(null); var $color = null;
var $report = null; var $current_id = null; var $current_type = null;
var $range = null; //COLUMN RANGE, NOT THE DATE RANGE! function eo_single_timeline($id, $type, $header, $date, $rg) {
$this->current_id = $id; $this->current_type = $type;
$this->header = $header;
$this->start_line_date = new eo_date(); $this->end_line_date = new eo_date();
copy_date($date, &$this->start_line_date); $this->start_date = new eo_date();
$this->end_date = new eo_date(); $this->set_range($rg); }
function set_data($id, $type) { $this->current_id = $id; $this->current_type = $type; } function set_range($rg) { $this->range = $rg; copy_date($this->start_line_date, &$this->end_line_date); $this->end_line_date->next_day($rg); }
function set_date_mysql($start, $end) {
$this->start_date->set_mysql_date($start); $this->end_date->set_mysql_date($end); }
function draw_row() {
global $_GET;
$start = new eo_date(); $end = new eo_date();
if (is_bigger(>start_date, $this->start_line_date) == 1) { copy_date($this->start_date, &$start); } else { copy_date($this->start_line_date, &$start); } if (is_bigger($this->end_date, $this->end_line_date) == 1) { copy_date($this->end_line_date, &$end); } else { copy_date($this->end_date, &$end); }
$show = !is_bigger($start, $end);
$length_1 = cal_count_2_days_date($this->start_line_date, $start);
$length_2 = cal_count_2_days_date($start, $end); if ($length_2 != 0) $length_2 += 1;
$length_3 = cal_count_2_days_date($end, $this->end_line_date) - 1;
/*
if ($length_1 + $length_2 + $length_3 > $this->range) { if ($length_3 == 0) { if ($length_2 == 0) { $length_1 -= 1; } else { $length_2 -= 1; } } */ echo "<TR bgcolor=\"#FFFFFF\">\n";
echo "<TD NOWRAP align=\"right\" height=\"30\" bgcolor=\"#EEEEEE\">";
switch ($_GET["menu"]) { case 0 : echo "<A
href=\"main.php?action=4&menu=1&project=".$this->current_id."\" class=\"tl_font_2_red\" >"; break;
case 1 : echo "<A
href=\"main.php?action=4&menu=2&project=".$_GET["project"]."&modul e=".$this->current_id."\" class=\"tl_font_2_red\" >"; break;
case 2 : echo "<A
e=".$_GET["module"]."&task=".$this->current_id."\" class=\"tl_font_2_red\" >"; break;
}
echo " : : ".$this->header." : : "; echo "</A></TD>\n"; if ($length_1 > 0) { echo "<TD colspan=\"".$length_1."\" align=\"center\" class=\"tl_td_outline_soft\">"; echo ">"; echo "</TD>\n"; } if ($show) { if ($length_2 > 0) { echo "<TD colspan=\"".$length_2."\" align=\"center\" class=\"tl_td_outline_hard\">"; echo $length_2; echo "</TD>\n"; } } if ($length_3 > 0) { echo "<TD colspan=\"".$length_3."\" align=\"center\" class=\"tl_td_outline_soft\">"; echo "<"; echo "</TD>\n"; }
// echo "<TD width=\"10\" bgcolor=\"EEEEEE\"></TD>"; echo "</TR>\n"; } } //================================================================ =================================== //================================================================ =================================== //============================================= TIMELINE CLASS //================================================================ =================================== //================================================================ =================================== class eo_timeline { var $start_date = null; var $end_date = null; var $temp = null; var $day_range = null; var $month_range = null; var $main_link = null;
var $time_rows = array(null); var $global_type = null; var $global_id = null; var $user_id = null;
var $range = null; /**
* @return eo_timeline * @param unknown $type
* @desc eoffice timeline (semi gantt chart) graphic shows projects, modules or task schedules. $type: 1 -> projects 2 -> modules 3 -> tasks */
function eo_timeline($type, $id=null, $user=null) {
global $_SERVER; global $_GET; global $_POST; global $_SESSION; $this->init(); $this->global_type = $type;
if ($id == null) >global_id = 0; else $this->global_id = $id;
if ($user != null) $this->user_id = $user; } //INITIALIZATION============================================ ============================ function process_submit() { $this->get_header_url(); $this->get_post_var(); if($_POST["post"] == 1) { $this->start_date->set_mysql_date($_POST["start"]); $this->end_date->set_mysql_date($_POST["end"]); if ($_POST["next"] == 1) { $this->start_date->next_day($this->range); $this->end_date->next_day($this->range); } if ($_POST["prev"] == 1) { $this->start_date->previous_day($this->range); $this->end_date->previous_day($this->range); } } else { $this->set_date_range($this->range); }
$this->fit_to_week(); }
function init() {
$this->start_date = new eo_date(); $this->end_date = new eo_date(); $this->range = 35; $this->process_submit(); } //SETTING PARAMETERS======================================================== ============== function get_header_url() { $tmp = $_SERVER['QUERY_STRING']; $head = $_SERVER['PHP_SELF'];
$header = substr($head, strrpos($head, "/") + 1, strlen($head));
$this->main_link = $header."?".$tmp; }
function set_date($d1, $m1, $y1, $d2, $m2, $y2) { $this->start_date->set_date($d1, $m1, $y1); $this->end_date->set_date($d2, $m2, $y2); $this->fit_to_week(); } function fit_to_week() { $first = $this->start_date->get_day_number_week(); $last = $this->end_date->get_day_number_week(); if ($first != 0) $this->start_date->previous_day($first);
if ($last != 0) $this->end_date->next_day(7 - $last); $this->range =
cal_count_2_days_date($this->start_date, $this->end_date); }
function set_date_range ($d=null, $m=null) {
if ($d == null) >day_range = 30; else $this->day_range = $d;
if ($d == null) >month_range = 0; else $this->month_range = $m; $this->range = cal_count_to_days($this->day_range, $this->month_range); if ($this->range % 7 != 0) $this->range = (floor($this->range / 7) + 1) * 7; copy_date($this->start_date, &$this->end_date);
if ($d > 0) $this->end_date->next_day($d); if ($m > 0) $this->end_date->next_month($m); $this->fit_to_week(); } //TIMELINE PROCCESSES======================================================== ========= function exec_query() { if (isset($_GET["project"])) { if (isset($_GET["module"])) { $this->global_type = 3; } else { $this->global_type = 2; } } else { $this->global_type = 1; } switch ($this->global_type) { case 1 : {
$query = "SELECT * FROM projects";
} break;
case 2 : {
$query = "SELECT * FROM project_modules WHERE module_project_id = ".$_GET["project"];
} break;
case 3 : {
$query = "SELECT * FROM tasks WHERE task_module_id = ".$_GET["module"]." AND task_project_id = ".$_GET["project"]; } break; default: { $query = ""; } } $result = mysql_query($query);
while ($row[] = mysql_fetch_array($result));
for ($count = 0; $count < mysql_num_rows($result); $count++) {
switch ($this->global_type) {
case 1 : {
$this->time_rows[$count] = new
eo_single_timeline($row[$count]["project_id"], $this->global_type, $row[$count]["project_name"], $this->start_date, $this->range); $this->time_rows[$count]->set_date_mysql($row[$count]["project_start_date"], $row[$count]["project_end_date"]); } break; case 2 : { $this->time_rows[$count] = new eo_single_timeline($row[$count]["module_id"], $this->global_type,
$row[$count]["module_name"], $this->start_date, $this->range); $this->time_rows[$count]->set_date_mysql($row[$count]["module_start_date"], $row[$count]["module_end_date"]); } break; case 3 : { $this->time_rows[$count] = new eo_single_timeline($row[$count]["task_id"], $this->global_type, $row[$count]["task_name"], $this->start_date, $this->range); $this->time_rows[$count]->set_date_mysql($row[$count]["task_start_date"], $row[$count]["task_end_date"]); } break; default: { } } } } function draw_navigator() {
echo "<LINK href=\"./css/timeline.css\" rel=\"stylesheet\" type=\"text/css\">";
if ($_POST["link"] == "") $_POST["link"] = $this->main_link;
?>
<SCRIPT language="JavaScript">
function next() {
var form = document.timeline;
form.next.value = "1";
set_post(); }
function prev() {
var form = document.timeline;
form.prev.value = "1";
set_post(); }
function set_post() {
var form = document.timeline;
form.start.value = form.start_date_year.value + "-" + form.start_date_month.value + "-" + form.start_date_day.value; form.end.value = form.end_date_year.value + "-" + form.end_date_month.value + "-" + form.end_date_day.value; form.post.value = "1"; form.submit(); } </SCRIPT>
<TABLE align="center" cellpadding="5" cellspacing="0" class="tl_table_2" width="100%" bgcolor="#DDDDDD">
<FORM name="timeline" action="<?PHP echo $_POST["link"]."&type=".$this->global_type."&id=".$this->global_id;?>" method="POST"> <TR bgcolor="#AAAAAA"> <TD colspan="3" align="left" class="tl_header_1_white"> <?PHP switch ($this->global_type) {
case 1 : echo "<I>
P r o j e c t s T i m e l i n e</I>"; break;
case 2 : echo "<I>
M o d u l e s T i m e l i n e</I>"; break;
case 3 : echo "<I>
T a s k s T i m e l i n e</I>"; break; } ?> </TD> </TR> <TR> <TD align="right" width="20" class="tl_font_1_white"> <A href="javascript:prev();"> <IMG
src="./images/prev.gif" width="16" height="16" alt="next" border="0"> </A> </TD> <TD align="center" width="450" class="tl_font_1_white"> <?PHP $this->draw_date_input("start_date",
>start_date->get_day_number(), >start_date->get_month(), $this->start_date->get_year());
echo "<A
class=\"tl_header_2_gray\"> until </A>";
$this->draw_date_input("end_date", $this->end_date->get_day_number(), $this->end_date->get_month(), $this->end_date->get_year());
echo "<INPUT
name=\"submit_timeline\" type=\"button\" value=\"Submit\" onClick=\"set_post();\" class=\"tl_button\">"; ?> </TD> <TD align="left" class="tl_font_1_white"> <A href="javascript:next()"> <IMG
src="./images/next.gif" width="16" height="16" alt="next" border="0">
</A> </TD> </TR>
<INPUT type="hidden" name="prev"> <INPUT type="hidden" name="next"> <INPUT type="hidden" name="start"> <INPUT type="hidden" name="end">
<INPUT type="hidden" name="post"> <INPUT type="hidden" name="link" value="<?PHP echo $_POST["link"]; ?>">
</FORM> </TABLE> <?PHP } function draw_timeline() { ?>
<TABLE align="center" cellpadding="5" cellspacing="0" class="tl_table_1" bgcolor="#EEEEEE">
<?PHP
//CREATING THE COLUMNS WIDTH FOR FIXING THE CELL'S SIZE echo "<TR>\n";
echo "<TD NOWRAP height=\"0\"></TD>"; for ($count_2 = 1; $count_2 < $this->range; $count_2++) {
echo "<TD height=\"0\" width=\"10\"></TD>";
}
echo "</TR>\n"; //CREATING DATE RANGE
//YEARS $list = list_days_year($this->start_date, $this->end_date); echo "<TR>\n"; echo "<TD height=\"20\">"; echo "</TD>";
for ($count = 0; $count < count($list[0]); $count++) { if ($list[0][$count] > 0) { echo "<TD colspan=\"".$list[0][$count]."\" align=\"center\" class=\"tl_td_year\"><B>". $list[1][$count]."</B></TD>"; } } //MONTHS $list = list_days_month($this->start_date, $this->end_date); echo "<TR>\n"; echo "<TD height=\"20\">"; echo "</TD>";
for ($count = 0; $count < count($list[0]); $count++) {
if ($list[0][$count] > 0) {
echo "<TD
colspan=\"".$list[0][$count]."\" align=\"center\" class=\"tl_td_line_left_now\"><B>".
num_to_short_month($list[1][$count])."</B></TD>"; } } echo "</TR>\n"; //WEEKS $tmp = new eo_date(); echo "<TR>\n"; echo "<TD height=\"10\"></TD>"; copy_date($this->start_date, &$tmp); $num = $tmp->get_day_number_week(); $count = 0;
while ($count < $this->range) { echo "<TD colspan=\"7\" align=\"left\" class=\"tl_td_blank\">".$tmp->get_day_number()."</TD>"; $count += 7; $tmp->next_week(); } /*
while ($count < $this->range) {
switch ($num) {
case 0 : { echo "<TD colspan=\"7\" align=\"left\" class=\"tl_td_blank\">".$tmp->get_day_number()."</TD>"; } break; } $num++; $count++; $tmp->next_day(); $num %= 7; } */ echo "</TR>\n"; //DAYS echo "<TR>\n"; echo "<TD height=\"10\"></TD>"; $tmp = new eo_date(); copy_date($this->start_date, &$tmp); $num = $tmp->get_day_number_week(); $count = 0;
$now = new eo_date();
while ($count < $this->range) {
if (is_same($now, $tmp)) {
echo "<TD align=\"center\"
} else { switch ($num) { case 0 : { echo "<TD align=\"center\" class=\"tl_td_line_left\">".num_to_bit_days($num + 1)."</TD>"; } break; case 6 : { echo "<TD align=\"center\" class=\"tl_td_line_left\">".num_to_bit_days($num + 1)."</TD>"; } break; default: { echo "<TD align=\"center\" class=\"tl_td_white\">".num_to_bit_days($num + 1)."</TD>"; } break; } } $tmp->next_day(); $num = $tmp->get_day_number_week(); $count++; } echo "</TR>\n";
//DRAWING THE ROWS OF TIMELINE FROM EACH DATA LIST
for ($count = 0; $count < count($this->time_rows); $count++) { $this->time_rows[$count]->draw_row(); } ?> <TR> <TD> </TD> </TR> </TABLE> <?PHP } function draw() { $this->exec_query(); $this->draw_navigator(); //echo "<BR>"; $this->draw_timeline(); } //OTHER FUNCTIONS========================================================= =============== function get_post_var() {
if ($_GET["id"] != null) $this->global_id = $_GET["id"]; else $this->global_id = 1;
if ($_GET["type"] != null) $this->global_type = $_GET["type"]; else $this->global_type = 1;
if ($_GET["user"] != null) $this->user_id = $_GET["user"]; else $this->user_id = null;
function draw_date_input($input_name, $current_date=null, $current_month=null, $current_year=null) {
if (is_null($current_date)) $current_date = date(d); if (is_null($current_month)) $current_month = date(m); if (is_null($current_year)) $current_year = date(Y); //HARI
echo "<SELECT name=\"".$input_name."_day\" id=\"".$input_name."_day\" class=\"tl_combo\">";
for ($i=01; $i<=31; $i++){
echo "<OPTION value=\"".$i."\""; if ($i == $current_date) echo " SELECTED"; echo ">".$i."</OPTION>";
}
echo "</SELECT>"; //BULAN
echo "<SELECT name=\"".$input_name."_month\" id=\"".$input_name."_month\" class=\"tl_combo_year\">";
for ($i=1; $i<=12; $i++){
echo "<OPTION value=\"".$i."\"";
if ($i == $current_month) echo " SELECTED"; echo ">".num_to_short_month($i)."</OPTION>"; }
echo "</SELECT>"; //TAHUN
echo "<SELECT name=\"".$input_name."_year\" id=\"".$input_name."_year\" class=\"tl_combo_year\">";
for ($i = $current_year - 40; $i <= ($current_year + 5); $i++){
echo "<OPTION value=\"".$i."\""; if ($i == $current_year) echo " SELECTED"; echo ">".$i."</OPTION>"; } echo "</SELECT>"; } } ?>