Exemplo n.º 1
0
 private static function _build_datebox_sql($today, $today_arr, $then, $then_arr, $mark)
 {
     $t =& $GLOBALS["t"];
     $fields = explode(",", $GLOBALS["current_view"]["ENABLE_CALENDAR"]);
     if (count($fields) == 1) {
         self::$today = $today;
         self::$then = $then;
         $sql = "(" . $fields[0] . " between " . $today . " and " . $then . ")";
     } else {
         if (count($fields) == 2) {
             $sql = "((" . $fields[1] . " between " . $today . " and " . $then . ") or (" . $fields[0] . " between " . $today . " and " . $then . "))";
         } else {
             // 0-start,1-end,2-recurrence,3-until,4-allday,5-repeatinterval,6-repeatexclusions,7-repeatstart,8-repeatend
             $start = $fields[0];
             $end = $fields[1];
             $rec = $fields[2];
             $until = $fields[3];
             $rstart = $fields[7];
             $rend = $fields[8];
             $wtoday = $today_arr["wday"];
             $wthen = $then_arr["wday"];
             $mtoday = $today_arr["mday"];
             $mthen = $then_arr["mday"];
             $ytoday = $today_arr["yday"];
             $ythen = $then_arr["yday"];
             $sql = "(({$end} between {$today} and {$then}) or ({$then} between {$start} and {$end})";
             $sql .= " or ({$start} < {$then} and ({$until}=0 or {$until} > {$today}) and ";
             $sql .= "({$rec}='days'";
             if ($mark == "day") {
                 $sql .= " or ({$rec}='weeks' and (({$rend} between {$wtoday} and {$wthen}) or ({$rend}>={$rstart} and {$wthen} between {$rstart} and {$rend}) or ({$rend}<{$rstart} and {$wthen} not between {$rend}+1 and {$rstart}-1)) )";
             } else {
                 $sql .= " or {$rec}='weeks'";
             }
             if ($mark == "day" or $mark == "week") {
                 $sql .= " or ({$rec}='months' and (({$rend} between {$mtoday} and {$mthen}) or ({$rend}>={$rstart} and {$mthen} between {$rstart} and {$rend}) or ({$rend}<{$rstart} and {$mthen} not between {$rend}+1 and {$rstart}-1)) )";
             } else {
                 $sql .= " or {$rec}='months'";
             }
             if ($mark == "day" or $mark == "week" or $mark == "month" or $mark == "gantt") {
                 $sql .= " or ({$rec}='years' and (({$rend} between {$ytoday} and {$ythen}) or ({$rend}>={$rstart} and {$ythen} between {$rstart} and {$rend}) or ({$rend}<{$rstart} and {$ythen} not between {$rend}+1 and {$rstart}-1)) )";
             } else {
                 $sql .= " or {$rec}='years'";
             }
             $sql .= ")))";
         }
     }
     $t["sqlwhere"][] = $sql;
     $t["sqlwhere_default"][] = $sql;
 }