Esempio n. 1
0
    function display()
    {
        if ($this->displayLabel) {
            $this->showLabel();
        }
        $value = formatFromSQLTime($this->value);
        ?>
<input name="<?php 
        echo $this->name;
        ?>
" id="<?php 
        echo $this->id;
        ?>
" type="text" value="<?php 
        echo $value;
        ?>
" <?php 
        $this->displayAttributes();
        ?>
/><button id="<?php 
        echo $this->id;
        ?>
Button" type="button" class="graphicButtons buttonTime" onclick="showTP('<?php 
        echo APP_PATH;
        ?>
','<?php 
        echo $this->id;
        ?>
');"><span>pick time</span></button><?php 
    }
Esempio n. 2
0
    function displayWeek($userid, $dayInWeek = null)
    {
        // Creates a week view calendar for the widget
        if (!$dayInWeek) {
            $dayInWeek = mktime(0, 0, 0);
        }
        $firstDay = $dayInWeek;
        $dayArray = localtime($firstDay, true);
        while ($dayArray["tm_wday"] != 0) {
            $firstDay = strtotime("yesterday", $firstDay);
            $dayArray = localtime($firstDay, true);
        }
        //endwhile
        //build the initial array
        $events = array();
        $lastDay = strtotime("6 days", $firstDay);
        $tempDay = $firstDay;
        for ($i = 0; $i < 7; $i++) {
            $events["d" . $tempDay] = array();
            $tempDay = strtotime("tomorrow", $tempDay);
        }
        //endfor
        //first lets get the regular events in the timeframe;
        $querystatement = "\n            SELECT\n                notes.id,\n                notes.startdate,\n                notes.starttime,\n                notes.enddate,\n                notes.endtime,\n                notes.subject\n            FROM\n                notes\n            WHERE\n                (\n                    notes.private = 0\n                    OR notes.createdby=" . $userid . "\n                )\n                AND notes.type='EV'\n                AND notes.repeating = 0\n                AND notes.startdate >= '" . dateToString($firstDay, "SQL") . "'\n                AND notes.startdate <= '" . dateToString($lastDay, "SQL") . "'";
        $queryresult = $this->db->query($querystatement);
        while ($therecord = $this->db->fetchArray($queryresult)) {
            $events["d" . stringToDate($therecord["startdate"], "SQL")]["t" . stringToTime($therecord["starttime"], "24 Hour")][] = $therecord;
        }
        //next we do recurring events
        $querystatement = "\n            SELECT\n                notes.id,\n                notes.startdate,\n                notes.starttime,\n                notes.enddate,\n                notes.endtime,\n                notes.subject,\n                notes.repeattype,\n                notes.repeatevery,\n                notes.firstrepeat,\n                notes.lastrepeat,\n                notes.timesrepeated,\n                notes.repeatontheday,\n                notes.repeatontheweek,\n                notes.repeateachlist,\n                notes.repeatuntil,\n                notes.repeattimes\n            FROM\n                notes\n            WHERE\n                repeating =1\n                AND (\n                    notes.private = 0\n                    OR notes.createdby=" . $userid . "\n                ) AND notes.type='EV'\n                AND (\n                    notes.repeatuntil IS NULL\n                    OR notes.repeatuntil >= '" . dateToString($firstDay, "SQL") . "'\n                    )\n                AND (\n                    notes.repeattimes IS NULL\n                    OR notes.repeattimes > notes.timesrepeated\n                    )";
        $queryresult = $this->db->query($querystatement);
        $thetable = new notes($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1");
        while ($therecord = $this->db->fetchArray($queryresult)) {
            $dateArray = $thetable->getValidInRange(stringToDate($therecord["startdate"], "SQL"), $lastDay, $therecord);
            foreach ($dateArray as $date) {
                if ($date >= $firstDay && $date <= $lastDay) {
                    if ($therecord["enddate"]) {
                        $therecord["enddate"] = dateToString($date + (stringToDate($therecord["enddate"], "SQL") - stringToDate($therecord["startdate"], "SQL")), "SQL");
                    }
                    $therecord["startdate"] = dateToString($date, "SQL");
                    $events["d" . $date]["t" . stringToTime($therecord["starttime"], "24 Hour")][] = $therecord;
                }
                //endif
            }
            //endforeach
        }
        //endwhile
        $querystatement = "\n            SELECT\n                DECODE(password,'" . ENCRYPTION_SEED . "') AS decpass\n            FROM\n                users\n            WHERE\n                id=" . $_SESSION["userinfo"]["id"];
        $queryresult = $this->db->query($querystatement);
        $passrec = $this->db->fetchArray($queryresult);
        $icallink = "?u=" . $_SESSION["userinfo"]["id"] . "&amp;h=" . md5("phpBMS" . $_SESSION["userinfo"]["firstname"] . $_SESSION["userinfo"]["lastname"] . $_SESSION["userinfo"]["id"] . $passrec["decpass"]);
        ?>
        <input type="hidden" id="eventDateLast" value="<?php 
        echo strtotime("-7 days", $firstDay);
        ?>
" />
        <input type="hidden" id="eventDateToday" value="<?php 
        echo mktime(0, 0, 0);
        ?>
" />
        <input type="hidden" id="eventDateNext" value="<?php 
        echo strtotime("tomorrow", $lastDay);
        ?>
" />

        <ul id="eventButtons">
            <li id="icalLi"><a href="ical.php<?php 
        echo $icallink;
        ?>
" title="ical subscription link" id="icalA"><span>ical</span></a>&nbsp;</li>
            <li><button id="eventLastWeek" type="button" title="previous week" class="smallButtons"><span>&lt;&lt;</span></button></li>
            <li><button id="eventToday" type="button" title="today" class="smallButtons"><span>today</span></button></li>
            <li><button id="eventNextWeek" type="button" title="next week" class="smallButtons"><span>&gt;&gt;</span></button></li>
        </ul>
        <table border="0" cellspacing="0" cellpadding="0" width="100%" id="eventsList"><?php 
        foreach ($events as $date => $times) {
            ?>
<tr class="eventDayName" <?php 
            if (mktime(0, 0, 0) === (int) str_replace("d", "", $date)) {
                echo 'id="today"';
            }
            ?>
>
                        <td nowrap="nowrap"><?php 
            echo @strftime("%A", (int) str_replace("d", "", $date));
            ?>
</td>
                        <td width="100%" align="right"><?php 
            echo @strftime("%b %e %Y", (int) str_replace("d", "", $date));
            ?>
</td>
                </tr><?php 
            if (count($times)) {
                ksort($times);
                foreach ($times as $time => $timeevents) {
                    foreach ($timeevents as $event) {
                        ?>
                                <tr>
                                        <td nowrap="nowrap" valign="top" align="right"><?php 
                        echo formatFromSQLTime($event["starttime"]);
                        ?>
</td>
                                        <td valign="top" ><a href="<?php 
                        echo getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1") . "?id=" . $event["id"];
                        ?>
&amp;backurl=snapshot.php"><?php 
                        echo htmlQuotes($event["subject"]);
                        ?>
</a></td>
                                </tr><?php 
                    }
                    //endforeach events
                }
                //endforeach time
            } else {
                ?>
                        <tr>
                                <td class="disabledtext" align="right">no events</td>
                                <td>&nbsp;</td>
                        </tr><?php 
            }
            // endif
        }
        //endforeach day
        ?>
</table><?php 
    }
Esempio n. 3
0
function formatVariable($value, $format = NULL)
{
    switch ($format) {
        case "real":
            $value = number_format($value, 2);
            break;
        case "currency":
            $value = htmlQuotes(numberToCurrency($value));
            break;
        case "boolean":
            $value = booleanFormat($value);
            break;
        case "date":
            $value = formatFromSQLDate($value);
            break;
        case "time":
            $value = formatFromSQLTime($value);
            break;
        case "datetime":
            $value = formatFromSQLDatetime($value);
            break;
        case "filelink":
            $value = "<button class=\"graphicButtons buttonDownload\" type=\"button\" onclick=\"document.location='" . APP_PATH . "servefile.php?i=" . $value . "'\"><span>download</span></button>";
            //$value="<a href=\"".APP_PATH."servefile.php?i=".$value."\" style=\"display:block;\"><img src=\"".APP_PATH."common/stylesheet/".STYLESHEET."/image/button-download.png\" align=\"middle\" alt=\"view\" width=\"16\" height=\"16\" border=\"0\" /></a>";
            break;
        case "invoice":
            if ($value > 0 and $value != 9999999) {
                $value = "<a href=\"" . APP_PATH . "modules/bms/invoices_addedit.php?id={$value}\">{$value}</a>";
            }
            break;
        case "client":
            $value = "<a href=\"" . APP_PATH . "modules/bms/clients_addedit.php?id={$value}\">{$value}</a>";
            break;
        case "noencoding":
            $value = $value;
            break;
        case "bbcode":
            $value = htmlQuotes($value);
            // This list needs to be expanded
            $bbcodelist["[b]"] = "<strong>";
            $bbcodelist["[/b]"] = "</strong>";
            $bbcodelist["[br]"] = "<br />";
            $bbcodelist["[space]"] = "&nbsp;";
            foreach ($bbcodelist as $bbcode => $translation) {
                $value = str_replace($bbcode, $translation, $value);
            }
            break;
        default:
            $value = htmlQuotes($value);
    }
    return $value;
}