/** fleetTruckLinkImporter::__construct()
  * Class constructor
  */
 public function __construct()
 {
     $realPath = realpath(dirname(__FILE__));
     $maxine = substr($realPath, 0, strrpos($realPath, DIRECTORY_SEPARATOR));
     $rootaccess = substr($maxine, 0, strrpos($maxine, DIRECTORY_SEPARATOR) + 1);
     define("BASE", $rootaccess);
     include_once BASE . "basefunctions/baseapis/TableManager.php";
     include_once BASE . "basefunctions/baseapis/FileParser/FileParser.php";
     $manager = new TableManager("fleet_truck_count");
     $apiurl = "https://t24.max.bwtsgroup.com/api_request/Report/export?report=73&responseFormat=csv";
     // Live
     // $apiurl	= "http://max.mobilize.biz/m4/2/api_request/Report/export?report=141&responseFormat=csv"; // Test
     $required_fleets = (array) array(27, 13, 20, 26, 24);
     $rows = (array) array();
     foreach ($required_fleets as $fleetId) {
         $url = $apiurl . "&Fleet=" . $fleetId;
         $fileParser = new FileParser($url);
         $fileParser->setCurlFile("fleet_truck_count_" . $fleetId . ".csv");
         $data = $fileParser->parseFile();
         $cnt = count($data);
         $rows[] = array("fleet_id" => $fleetId, "count" => $cnt, "t24" => 1);
         unset($s);
         unset($cnt);
     }
     //: Delete rows where t24=1
     $sql = (string) "DELETE FROM `fleet_truck_count` WHERE `t24`=1";
     $manager->runSql($sql);
     $manager->insert($rows);
 }
Exemplo n.º 2
0
 public function setManager(TableManager $manager = NULL)
 {
     if ($manager === NULL) {
         $test = new TableManager();
         ## Test to see if the sessions table exists and if not create it
         $sql = (string) "SHOW TABLES LIKE 's%'";
         if (($tables = $test->runSql($sql)) === FALSE) {
             return FALSE;
         }
         if ($tables) {
             $exists = (bool) FALSE;
             foreach ($tables as $tbl) {
                 $keys = array_keys($tbl);
                 if ($tbl[$keys[0]] == "sessions") {
                     $exists = TRUE;
                     break;
                 }
             }
             if ($exists === FALSE) {
                 $sql = (string) "CREATE TABLE IF NOT EXISTS `sessions` (";
                 $sql .= "`id` INT(32) NOT NULL AUTO_INCREMENT PRIMARY KEY,";
                 $sql .= "`session_id` VARCHAR(150) NOT NULL DEFAULT '' UNIQUE,";
                 $sql .= "`access` INT(32) NOT NULL DEFAULT 0,";
                 $sql .= "`data` LONGTEXT,";
                 $sql .= "`ip_address` VARCHAR(15) NOT NULL DEFAULT '000.000.000.000',";
                 $sql .= "INDEX (`access`),";
                 $sql .= "INDEX (`ip_address`)";
                 $sql .= ") ENGINE=INNODB DEFAULT CHARSET=UTF8;";
                 if ($test->runSql($sql) === FALSE) {
                     print "<pre>";
                     print_r($test->getErrors());
                     print "</pre>";
                     return FALSE;
                 }
             }
         }
         $test->__destruct();
         unset($test);
         $manager = new TableManager("sessions");
     }
     $this->_manager = $manager;
 }
Exemplo n.º 3
0
function maxineTop($title = "")
{
    // Prep {
    ## User Data
    $mycapsSegments = new TableManager("users");
    $mycapsSegments->setWhere($mycapsSegments->quoteString("`users`.`personid`=?", (int) $_SESSION["userid"]));
    $user = $mycapsSegments->selectSingle();
    //$user				= sqlPull(array("table"=>"users", "where"=>"personid=".$_SESSION["userid"], "select"=>"firstname, lastname, user_profiles_id", "onerow"=>1));
    $smsaccess = testRights($_SESSION["userid"], "sms001");
    ## myCAPS segment check
    if (isset($_SESSION["userid"]) && $_SESSION["userid"]) {
        $mycapsSegments = new TableManager("mycaps_segments");
        $mycapsSegments->setWhere($mycapsSegments->quoteString("`mycaps_segments`.`userid`=?", (int) $_SESSION["userid"]) . $mycapsSegments->quoteString(" AND `mycaps_segments`.`finalized`=?", 0));
        $segment = $mycapsSegments->selectSingle();
    }
    ## Profile Data
    if ($user) {
        $user_profiles = new TableManager("user_profiles");
        ## Test for fortune column
        $cols = $user_profiles->getColumns();
        if (in_array("fortune", $cols) === FALSE) {
            $sql = (string) "ALTER TABLE `user_profiles` ADD COLUMN `fortune` TINYINT(1) NOT NULL DEFAULT 0, ADD INDEX (`fortune`);";
            if ($user_profiles->runSql($sql) === FALSE) {
                $errors = $user_profiles->getErrors();
                echo "<div class=\"error\">mySQL statement encountered an error. Last error was:<br />" . $errors[count($errors) - 1] . "</div>";
                return FALSE;
            }
        }
        $user_profiles->setWhere($user_profiles->quoteString("`user_profiles`.`id`=?", $user["user_profiles_id"]));
        $profile = $user_profiles->selectSingle();
    }
    ## Alerts
    $manager = new TableManager("alerts");
    $manager->setWhere($manager->quoteString("`alerts`.`deleted`=?", (int) 0) . $manager->quoteString(" AND `alerts`.`time_start`<=?", strtotime(date("Y-m-d") . " 00:00")) . $manager->quoteString(" AND `alerts`.`time_end`>=?", strtotime(date("Y-m-d") . " 23:59")));
    $manager->setCustomIndex("id");
    $alerts = $manager->selectMultiple();
    ## Theme
    $themes = new TableManager("themes");
    $themes->setQueryColumns(array("themes" => array("*")));
    $themes->setQueryFrom(array("left join" => array(0 => array("table" => array("abbr" => "user_profiles", "table" => "user_profiles"), "on" => "`themes`.`id`=`user_profiles`.`theme_id`"), 1 => array("table" => array("abbr" => "users", "table" => "users"), "on" => "`user_profiles`.`id`=`users`.`user_profiles_id`"))));
    $where = (string) "(ISNULL(`themes`.`deleted`)";
    $where .= $themes->quoteString(" OR `themes`.`deleted`=?)", 0);
    if ($_SESSION["userid"]) {
        $where .= $themes->quoteString(" AND `users`.`personid`=?", (int) $_SESSION["userid"]);
    } else {
        $where .= $themes->quoteString(" AND `themes`.`id`=?", (int) 1);
    }
    $themes->setWhere($where);
    $theme = $themes->selectSingle();
    $backgroundImage = (string) BASE . "images/new/themes/" . $theme["background-image"];
    $_SESSION["backgroundRepeat"] = (string) BASE . "images/new/themes/" . $theme["background-repeater"];
    $size = getimagesize($backgroundImage);
    $_SESSION["bgImageSize"] = $size;
    // }
    print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>";
    print "<html>";
    // Header Info {
    print "<head>";
    print "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />" . PHP_EOL;
    print "<link href='" . BASE . "/images/favicon.ico' rel='SHORTCUT ICON' />" . PHP_EOL;
    //print("<link href='".BASE."/basefunctions/scripts/manlinecss.php' rel='stylesheet' type='text/css' />");
    print "<link href='" . BASE . "/basefunctions/scripts/manline.css' media='all' rel='stylesheet' type='text/css' />" . PHP_EOL;
    print "<script type='text/javascript' language='javascript' src='" . BASE . "/basefunctions/scripts/manline.js'></script>";
    $headTitle = (string) "Maxweb";
    if ($title) {
        $headTitle .= " - " . $title;
    }
    print "<title>" . $headTitle . "</title>" . PHP_EOL;
    print "</head>";
    // }
    print "<body id=\"windowBody\" style='background-image:url(\"" . $backgroundImage . "\");'>";
    //print("<form action='#' method='post'>");
    // Header 1 {
    print "<h1>";
    print "<img alt=\"Maxweb Logo\" id=\"maxwebLogo\" src='" . BASE . "/images/new/logo.png' style=\"height:58px;margin-top:2px;width:299px;\">";
    print "<span style='float:right; text-align:right;'>";
    $links = (array) array("Home" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=home", "id" => "home"), "Documents" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=viewdocuments", "id" => "Documents"), "Gallery" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=viewgallery", "id" => "Gallery"), "InOut" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=inoutboard", "id" => "InOut"), "Max" => array("class" => "headerA", "href" => "http://login.max.manline.co.za", "id" => "Max", "target" => "_blank"), "Zimbra" => array("class" => "headerA", "href" => "http://mail.manline.co.za", "id" => "Zimbra", "target" => "_blank"));
    foreach ($links as $text => $data) {
        echo "<a class=\"" . $data["class"] . "\" href=\"" . $data["href"] . "\" id=\"" . $data["id"] . "\" " . (isset($data["target"]) ? "target=\"" . $data["target"] . "\" " : "") . "title=\"" . $text . "\"></a>" . PHP_EOL;
    }
    print "</span>";
    print "</h1>";
    // }
    // Header 2 {
    $messages = (array) array();
    if (isset($profile) && $profile) {
        if (!$profile["staffno"] || !$profile["department_id"] || !$profile["jobtitle"] || !$profile["location"]) {
            $messages[] = "Your profile information is incomplete.";
        }
    }
    if (isset($segment)) {
        if (date("U") > (int) $segment["enddate"] + 86400) {
            $messages[] = "Your CAPS is overdue";
        }
    }
    if (isset($alerts) && $alerts) {
        foreach ($alerts as $val) {
            $messages[] = $val["message"];
        }
    }
    ## Profile Data
    if ($messages) {
        informationBar($messages);
    }
    print "<h2>";
    print "<span style='width:10px; height:51px; background-image:url(\"" . BASE . "/images/new/menubarleft.png\"); float:left;'></span>";
    print "<span style='width:850px; height:36px; background-image:url(\"" . BASE . "/images/new/menubarmid.png\"); float:left; padding-top:15px;'>";
    // Left Span - Quick Navigation {
    print "<span style='float:left; margin-top:-5px;'>";
    ## Menu
    // $items[] = array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/", "text"=>"", "title"=>"");
    $items = (array) array();
    if ($user) {
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=mycapslist2", "text" => "myCAPS", "title" => "click to go to your CAPs");
    }
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=showm3", "text" => "Public M3", "title" => "View public M3 Graphs");
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=dockeeperfront", "text" => "Customer Documents", "title" => "View Documents required by Customers");
    if ($user) {
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=m3sys", "text" => "M3", "title" => "View M3 Graphs");
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=displaymydash", "text" => "Personal Dashboard", "title" => "Click to view your personal dashboard");
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=greenmileinput", "text" => "Green Mile Controls", "title" => "Click to update Green Mile Details");
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=ratescalc2", "text" => "Rates Calculator", "title" => "Click to view the rates calculator");
        if ($user["isit"] || $user["ismanager"]) {
            $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=nineblockinput", "text" => "9 Blocker", "title" => "Click to view your 9 Blocker");
            $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=listalerts", "text" => "Alerts", "title" => "Click to list all alerts");
            $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=edituserpool", "text" => "User Pools", "title" => "Click to view and edit User Pools");
        }
        $items[] = array("text" => "Faults System", "children" => array(array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=equipfaults", "text" => "Equipment Faults", "title" => "Click to view equipment faults"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=uflist", "text" => "Unit Faults", "title" => "Click to view unit faults"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=faultsys", "text" => "Fault Logging", "title" => "Log a new fault")));
        $items[] = array("text" => "Personnel Tools", "children" => array(array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=learnerlist", "text" => "Learner", "title" => "Click to view a list of learners"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=candmenu", "text" => "Candidates", "title" => "Click to view list of candidates"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=driverslist", "text" => "Drivers", "title" => "Click to view list of drivers"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=listusers", "text" => "Users", "title" => "Click to view user list")));
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=updateprofile", "text" => "Edit Your Profile", "title" => "Click to edit your profile");
    }
    /** Cameras link affects
    				  4 = > Jonathan Spencer
    				  5 = > Bradley Roberts
    				  141 = > Jerome Govender
    				  168 = > Lwazi Ally
    				  186 = > Ndumiso Langa
    				*/
    if (in_array($_SESSION["userid"], array(4, 5, 141, 168, 186))) {
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/cameras/", "text" => "Manline CCTV", "title" => "Click to view the cameras");
    }
    if ($_SESSION["isadmin"] || $smsaccess > 0) {
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=smssystem", "text" => "Send an SMS", "title" => "Click to use the SMS system");
    }
    if ($_SESSION["isit"] == 1) {
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=rightscontrol", "text" => "Access Rights", "title" => "Click to set user access rights");
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=loggingreport", "text" => "Logging Report", "title" => "Click to view the logging report");
        if ($_SESSION["isadmin"]) {
            $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=smssystem", "text" => "Send an SMS", "title" => "Click to use the SMS system");
        }
        $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=sandbox", "text" => "Sandbox", "title" => "Click to go to the coding sandbox");
        //$items[] = array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/index.php?mode=maxine/index&action=encoder", "text"=>"Text Encoder", "title"=>"Click to view the text encoder");
        //$items[] = array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/index.php?mode=maxine/index&action=truckfinder", "text"=>"Truck Finder", "title"=>"Click to view the truck finder");
        $items[] = array("text" => "Scaffolding", "children" => array(array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=documents", "text" => "Documents", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=gallery", "text" => "Gallery", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=galleryItems", "text" => "Gallery Items", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=newspaper_articles", "text" => "Newspaper Articles", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=pages", "text" => "Pages", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=themes", "text" => "Themes", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=type", "text" => "Type", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=user_profiles", "text" => "User Profiles", "title" => "Click to list all items")));
    }
    /* $items[] = array("text"=>"Corporate Clothing", "children"=>array(
    				array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/documents/Ladies Clothing Catalogue.pdf", "text"=>"Ladies", "title"=>"Click to download ladies clothing catalogue"),
    				array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/documents/Mens Clothing Catalogue.pdf", "text"=>"Mens", "title"=>"Click to download mens clothing catalogue")
    			)); */
    $items[] = array("href" => "/Maxine/documents/ManlinePriceList.pdf", "text" => "Corporate Clothing", "title" => "Click to download");
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/documents/Map to Head Office.pdf", "text" => "Map to Head office", "title" => "Click to download map to head office");
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=maxexpress", "text" => "Max Express", "title" => "Click to view Max Express editions");
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=viewnews", "text" => "News", "title" => "Click to view newspaper articles");
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=monthlyvideos", "text" => "Monthly Videos", "title" => "Click to view Neil's monthly video updates");
    $sql = (string) "SELECT * FROM `m3_departments`";
    $departs = $themes->runSql($sql);
    $depts = (array) array();
    foreach ($departs as $dept) {
        $depts[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=listdepartment&department=" . urlencode($dept["name"]), "text" => $dept["name"], "title" => "Click to view department members");
    }
    $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=listdepartment", "text" => "Staff Profiles", "title" => "Click to view all staff members", "children" => $depts);
    echo menu($items);
    print "</span>";
    // }
    // Right Span - Login Details {
    print "<span style='height:34px; float:right; margin-top:-5px; vertical-align:bottom;'>";
    if ($_SESSION["userid"] > 0) {
        print "<p class='standard' style='float:left; margin-right:10px; margin-top:8px;'>Logged in as " . $profile["firstname"] . " " . $profile["lastname"] . "</p>";
        echo "<a href=\"/Maxine/?logout\" id=\"logoutbutton\"></a>" . PHP_EOL;
    } else {
        $name = "";
        if ($_COOKIE["loggedname"]) {
            $name = $_COOKIE["loggedname"];
        }
        print "<form id=\"loginform\" name='loginform' action='index.php?mode=maxine/index&action=loginaction' method='post'>";
        print "<span style='width:16px; height:19px; background-image:url(\"" . BASE . "/images/new/loginicon.png\"); float:left; margin-top:5px;'></span>";
        print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginleft.png\"); float:left; margin-left:10px; margin-top:4px; '></span>";
        print "<input id=\"username\" name='conf[username]' value='" . $name . "' class='loginmid' onKeyPress='submitenter(this,event);' />";
        print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginright.png\"); float:left; margin-top:4px; '></span>";
        print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginleft.png\"); float:left; margin-left:10px; margin-top:4px;'></span>";
        print "<input type='password' id='passbox' name='conf[password]' class='loginmid' onKeyPress='submitenter(this,event);' />";
        print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginright.png\"); float:left; margin-top:4px; '></span>";
        echo "<a href=\"#\" id=\"loginbutton\" onclick=\"document.getElementById('loginform').submit();\"></a>" . PHP_EOL;
        print "</form>";
    }
    print "</span>";
    // }
    print $title;
    print "</span>";
    print "<span style='width:10px; height:51px; background-image:url(\"" . BASE . "/images/new/menubarright.png\"); float:left;'></span>";
    print "</h2>";
    if (isset($_SESSION["userid"]) && in_array($_SESSION["userid"], array(4, 23, 175)) || isset($profile["fortune"]) && $profile["fortune"]) {
        $fortune = shell_exec("fortune -s -n 100");
        echo "<div style=\"height:24px;margin:-14px auto 15px;position:relative;width:850px;\">";
        echo "<img alt=\"left corner\" src=\"" . BASE . "images/new/cookiebar_left.png\" style=\"height:24px;left:0px;position:absolute;top:0px;width:10px;\" />";
        echo "<div style=\"background-image:url(" . BASE . "images/new/cookiebar_mid.png);font-size:0.8em;height:24px;margin:-3px auto 0px;vertical-align:top;width:830px;\">" . $fortune . "</div>";
        echo "<img alt=\"right corner\" src=\"" . BASE . "images/new/cookiebar_right.png\" style=\"height:24px;position:absolute;right:0px;top:0px;width:10px;\" />";
        echo "</div>";
    }
    // }
}
 /** fleetTruckLinkImporter::__construct()
  * Class constructor
  */
 public function __construct()
 {
     $realPath = realpath(dirname(__FILE__));
     $maxine = substr($realPath, 0, strrpos($realPath, DIRECTORY_SEPARATOR));
     $rootaccess = substr($maxine, 0, strrpos($maxine, DIRECTORY_SEPARATOR) + 1);
     defined("BASE") || define("BASE", $rootaccess);
     include_once BASE . "basefunctions/baseapis/TableManager.php";
     include_once BASE . "basefunctions/baseapis/FileParser/FileParser.php";
     $manager = new TableManager("fleet_truck_count");
     //: Do a test to see if table includes subbie_trucks field
     $fields = $manager->describeTable();
     if (in_array('subbie_count', array_keys($fields)) === FALSE) {
         $sql = (string) "ALTER TABLE `fleet_truck_count` ADD COLUMN `subbie_count` INT NOT NULL DEFAULT 0;";
         if ($manager->runSql($sql) === FALSE) {
             print "Altering table failed" . PHP_EOL;
             return FALSE;
         }
     }
     //: End
     $subbietrucksurl = "https://login.max.bwtsgroup.com/api_request/Report/export?report=153&responseFormat=csv";
     // Max
     $apiurl = "https://login.max.bwtsgroup.com/api_request/Report/export?report=145&responseFormat=csv";
     // Max
     $t24apiurl = "https://t24.max.bwtsgroup.com/api_request/Report/export?report=73&responseFormat=csv";
     // T24
     // $apiurl	= "http://max.mobilize.biz/m4/2/api_request/Report/export?report=141&responseFormat=csv"; // Test
     //: Get the list of subbie trucks
     $fileParser = new FileParser($subbietrucksurl);
     $fileParser->setCurlFile("subbie_trucks.csv");
     $data = $fileParser->parseFile();
     $subbieTrucks = (array) array();
     foreach ($data as $val) {
         if (array_key_exists("Trucks", $val) === FALSE) {
             continue;
         }
         $trucks = preg_split("/\\,/", $val["Trucks"]);
         if (is_array($trucks) === FALSE) {
             continue;
         }
         foreach ($trucks as $trucklist) {
             $subbieTrucks[] = $trucklist;
         }
     }
     //print_r($subbieTrucks);
     unset($data);
     //return FALSE;
     //: End
     $fleetDayHandler = new fleetDayHandler();
     $required_fleets = $fleetDayHandler->getIncomeFleets();
     $rows = (array) array();
     foreach ($required_fleets as $val) {
         if (array_key_exists('fleets', $val)) {
             $count = (int) 0;
             $subbie_count = (int) 0;
             foreach ($val['fleets'] as $subfleets) {
                 $manager->setWhere($manager->quoteString('`fleet_id`=?', $subfleets[0]));
                 $record = $manager->selectSingle();
                 $count += (int) $record['count'];
                 $subbie_count += (int) $record['subbie_count'];
             }
             $rows[] = (array) array('fleet_id' => $val['id'], 'count' => isset($count) && $count ? $count : 0, 'subbie_count' => isset($subbie_count) && $subbie_count ? $subbie_count : 0);
         } else {
             $url = $apiurl . "&Fleet=" . $val["maxid"] . "&Start%20Date=" . date("Y-m-d") . "&Stop%20Date=" . date('Y-m-d', strtotime('+1 day'));
             if (array_key_exists('t24', $val)) {
                 $url = $t24apiurl . "&Fleet=" . $val["maxid"] . "&Start%20Date=" . date("Y-m-d") . "&Stop%20Date=" . date('Y-m-d', strtotime('+1 day'));
             }
             print_r('url: ' . $url . PHP_EOL);
             $fileParser = new FileParser($url);
             $fileParser->setCurlFile("fleet_truck_count_" . $val["id"] . ".csv");
             $data = $fileParser->parseFile();
             // print_r($data);
             /*if ($fleetId == 75) { //: confirm a fleet is correct
             		print("<pre>");
             		print_r($data);
             		print("</pre>");
             		}*/
             $sub_cnt = (int) 0;
             foreach ($data as $row) {
                 if (in_array($row['Truck'], $subbieTrucks)) {
                     $sub_cnt++;
                 }
             }
             //print($sub_cnt.PHP_EOL);
             $record = (array) array('fleet_id' => $val['id'], 'count' => count($data), 'subbie_count' => $sub_cnt);
             if (array_key_exists('t24', $val)) {
                 $record['t24'] = (int) 1;
             }
             $rows[] = $record;
         }
     }
     //: Loop through and update/insert records
     foreach ($rows as $row) {
         $where = (string) $manager->quoteString('`fleet_id`=?', $row['fleet_id']);
         if (array_key_exists('t24', $row) && $row['t24'] === 1) {
             $where .= $manager->quoteString(' AND `t24`=?', $row['t24']);
         }
         $manager->setWhere($where);
         $record = $manager->selectSingle();
         if ($record) {
             print_r($record);
             print_r($row);
             $nDifference = (double) $row['count'] == 0 ? 100 : ($record['count'] - $row['count']) / $row['count'] * 100;
             print_r('diff:  ' . $nDifference . PHP_EOL);
             if ($nDifference > 50 || $nDifference < -50) {
                 continue;
             }
             $manager->setWhere($manager->quoteString('`id`=?', $record['id']));
             $manager->update($row);
         } else {
             $manager->insert($row);
         }
     }
 }
Exemplo n.º 5
0
/** displayFleetKmsTable($fleet_id, array $conf)
 * display a fleet kms table correctly
 * @param int $fleet_id 
 * @param array $conf 
 * @return string $html
 */
function displayFleetKmsTable($fleet_id, array $conf)
{
    /* print '<pre style="color:#FFF">';
    			print_r($conf);
    			print '</pre>'; */
    $mtddays = getFleetBudgetDays((int) $fleet_id, NULL, NULL);
    $monthenddays = getFleetBudgetDays((int) $fleet_id, NULL, mktime(0, 0, 0, date("m"), date("t"), date("Y")));
    $manager = new TableManager("fleet_scores");
    $sql = (string) "SELECT * FROM `fleet_scores` WHERE ";
    $sql .= $manager->quoteString("`fleetid`=?", (int) $fleet_id);
    $sql .= $manager->quoteString(" AND `date`>=?", mktime(0, 0, 0, date("m"), 1, date("Y")));
    $sql .= $manager->quoteString(" AND `date`<=?", mktime(0, 0, 0, date("m"), date("t"), date("Y")));
    if (($results = $manager->runSql($sql)) === FALSE) {
        return FALSE;
    }
    $monthendbudget = (int) 0;
    foreach ($results as $val) {
        if (isset($val["budget"]) && $val["budget"] > 0) {
            $monthendbudget += $val["budkms"];
        }
    }
    unset($results);
    $data = array("cd_actual" => array_key_exists("kms", $conf) ? $conf["kms"] : 0, "cd_budget" => array_key_exists("budkms", $conf) ? $conf["budkms"] : 0);
    $data["cd_variance"] = array_key_exists("cd_actual", $data) && array_key_exists("cd_budget", $data) ? (string) round($data["cd_actual"] - $data["cd_budget"], 0) : "-";
    $data["cd_percent"] = array_key_exists("cd_actual", $data) && array_key_exists("cd_budget", $data) && $data["cd_budget"] > 0 ? (string) round($data["cd_actual"] / $data["cd_budget"] * 100, 0) : "-";
    $data["mtd_actual"] = array_key_exists("totkms", $conf) && $conf["truck_count"] && $mtddays > 0 ? (string) round($conf["totkms"] / $mtddays / $conf["truck_count"], 0) : "-";
    $data["mtd_budget"] = array_key_exists("totbudkms", $conf) && $conf["truck_count"] && $mtddays > 0 ? (string) round($conf["totbudkms"] / $mtddays / $conf["truck_count"], 0) : "-";
    $data["mtd_variance"] = array_key_exists("mtd_actual", $data) && array_key_exists("mtd_budget", $data) ? (string) round($data["mtd_actual"] - $data["mtd_budget"], 0) : "-";
    $data["mtd_percent"] = array_key_exists("mtd_actual", $data) && array_key_exists("mtd_budget", $data) && $data["mtd_budget"] > 0 ? (string) round($data["mtd_actual"] / $data["mtd_budget"] * 100, 0) : "-";
    $data["mef_actual"] = array_key_exists("mtd_actual", $data) && $mtddays > 0 && $monthenddays > 0 ? (string) round($data["mtd_actual"] * $monthenddays, 0) : "-";
    if (isset($monthendbudget) && $monthendbudget > 0) {
        $data["mef_budget"] = array_key_exists("truck_count", $conf) && $conf["truck_count"] > 0 ? (string) round($monthendbudget / $conf["truck_count"], 0) : "-";
    } else {
        $data["mef_budget"] = array_key_exists("mtd_budget", $data) && $mtddays > 0 && $monthenddays > 0 ? (string) round($data["mtd_budget"] * $monthenddays, 0) : "-";
    }
    $data["mef_variance"] = array_key_exists("mef_actual", $data) && array_key_exists("mef_budget", $data) ? (string) round($data["mef_actual"] - $data["mef_budget"], 0) : "-";
    $data["mef_percent"] = array_key_exists("mef_actual", $data) && array_key_exists("mef_budget", $data) && $data["mef_budget"] > 0 ? (string) round($data["mef_actual"] / $data["mef_budget"] * 100, 0) : "-";
    /* print '<pre style="color:#FFF">';
    			print_r($data);
    			print '</pre>'; */
    $vars = (string) "";
    foreach ($data as $key => $val) {
        $vars .= $key . "=" . $val . "&";
    }
    $vars = substr($vars, 0, -1);
    $object = embedObject("/images/kms_table.swf", array("FlashVars" => $vars, "height" => round(164 * $conf["factor"], 0), "name" => "kms_table", "width" => round(850 * $conf["factor"], 0)), TRUE);
    //return $object;
    return $data;
}
Exemplo n.º 6
0
 public function __construct()
 {
     $manager = new TableManager("user_profiles");
     echo "<link href=\"http://" . $_SERVER["SERVER_NAME"] . "/basefunctions/scripts/manline.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />" . PHP_EOL;
     echo "<p class=\"standard\">" . PHP_EOL;
     echo "Update current records to be integer based instead of string based<br />" . PHP_EOL;
     $list = $manager->selectMultiple();
     foreach ($list as $key => $val) {
         if (!$val["birthday"]) {
             continue;
         }
         $manager->setWhere($manager->quoteString("`user_profiles`.`id`=?", $val["id"]));
         $data = (array) array();
         $split = preg_split("/\\s/", $val["birthday"]);
         $data["birthday"] = mktime(0, 0, 0, date("m", strtotime("01-" . $split[1] . "-2011")), $split[0], 2011);
         if ($manager->update($data) === false) {
             echo "<span style=\"color:#F00;\" title=\"Update failed\">|</span>" . PHP_EOL;
             return false;
         }
         echo "<span style=\"color:#FFF;\" title=\"Update successful\">|</span>" . PHP_EOL;
         $manager->setWhere("");
         ## TOCTOU Race condition ##
     }
     echo "<br />Update table so that the birthday column is an integer column<br />" . PHP_EOL;
     $sql = (string) "alter table user_profiles modify column birthday int(50) not null default '0',add index (`birthday`);";
     if ($manager->runSql($sql) === false) {
         echo "<echo style=\"color:#FFF;\">" . PHP_EOL;
         print_r($manager->getErrors());
         echo "</pre>" . PHP_EOL;
         return false;
     }
     echo "<br />Get list of users<br />" . PHP_EOL;
     $sql = (string) "SELECT * FROM `users` WHERE `deleted`='0'";
     if (($list = $manager->runSql($sql)) === false) {
         echo "<echo style=\"color:#FFF;\">" . PHP_EOL;
         print_r($manager->getErrors());
         echo "</pre>" . PHP_EOL;
         return false;
     }
     echo "<br />Loop through and get the userdates entry for birthday and update the user_profiles table.<br />" . PHP_EOL;
     foreach ($list as $key => $val) {
         if (!$val["user_profiles_id"]) {
             continue;
         }
         $sql = (string) "SELECT * FROM `userdates` WHERE `userid`='" . $val["personid"] . "'  AND `datetype`='birthday' LIMIT 1";
         if (($row = $manager->runSql($sql)) === false) {
             echo "<echo style=\"color:#FFF;\">" . PHP_EOL;
             print_r($manager->getErrors());
             echo "</pre>" . PHP_EOL;
             return false;
         }
         $manager->setWhere($manager->quoteString("`user_profiles`.`id`=?", $val["user_profiles_id"]));
         $data = (array) array();
         $birthday = date("Y-m-d", $row[0]["date"]);
         $split = preg_split("/\\-/", $birthday);
         $data["birthday"] = strtotime("1971-" . $split[1] . "-" . $split[2]);
         if ($manager->update($data) === false) {
             echo "<span style=\"color:#F00;\" title=\"Update failed\">|</span>" . PHP_EOL;
             return false;
         }
         echo "<span style=\"color:#FFF;\" title=\"Update successful\">|</span>" . PHP_EOL;
         $manager->setWhere("");
         ## TOCTOU Race condition ##
     }
     echo "<br />Get any records form the user_profiles table where the birthday year isn't 1971<br />" . PHP_EOL;
     $manager->setWhere($manager->quoteString("DATE_FORMAT(FROM_UNIXTIME(`user_profiles`.`birthday`), '%Y')!=?", 1971));
     $list = $manager->selectMultiple();
     foreach ($list as $key => $val) {
         $manager->setWhere($manager->quoteString("`user_profiles`.`id`=?", $val["id"]));
         $date = date("Y-m-d", $val["birthday"]);
         $split = preg_split("/\\-/", $date);
         $data = (array) array("birthday" => strtotime("1971-" . $split[1] . "-" . $split[2]));
         if ($manager->update($data) === false) {
             echo "<span style=\"color:#F00;\" title=\"Update failed\">|</span>" . PHP_EOL;
             return false;
         }
         echo "<span style=\"color:#FFF;\" title=\"Update successful\">|</span>" . PHP_EOL;
         $manager->setWhere("");
         ## TOCTOU Race condition ##
     }
 }
Exemplo n.º 7
0
 /** Scaffold_Forms_User_profiles::setHtml($html = null)
  * @param string $html HTML form definition
  */
 public function setHtml($html = NULL)
 {
     ## Preparation
     $record = $this->getRecord();
     if (is_object("TableManager") === false) {
         include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php";
     }
     $tableManager = new TableManager("m3_departments");
     $departments = $tableManager->selectMultiple();
     $sql = (string) "SELECT * FROM `themes` WHERE (ISNULL(`deleted`) OR `deleted`=0)";
     $themes = $tableManager->runSql($sql);
     $users = new TableManager("users");
     $metaData = $users->getMetaData();
     if ($record) {
         $users->setChildRecords(true);
         $users->setChildTables(array(0 => array("rights_users" => "rights_users", "where" => "`rights_users`.`userid`=?")));
         $users->setWhere($users->quoteString("`users`.`user_profiles_id`=?", (int) $record["id"]));
         $user = $users->selectSingle();
     }
     $sql = (string) "SELECT * FROM `rights_groups` WHERE 1=1;";
     $rights_groups = $users->runSql($sql);
     $locations = (array) array(0 => array("name" => "Head Office"), 1 => array("name" => "Durban"), 2 => array("name" => "Empangeni"), 3 => array("name" => "East London"), 4 => array("name" => "Kokstad"), 5 => array("name" => "Pietermaritzburg"), 6 => array("name" => "Newcastle"), 7 => array("name" => "Vanderbijl Park"), 8 => array("name" => "Isando"), 9 => array("name" => "Germiston"), 10 => array("name" => "Cape Town"), 11 => array("name" => "Wilmar Depot"), 12 => array("name" => "Sasolburg"), 13 => array("name" => "Boksburg"), 14 => array("name" => "Port Elizabeth"), 15 => array("name" => "Delmas"), 16 => array("name" => "Slurry"), 17 => array("name" => "Hercules"), 18 => array("name" => "Heriotdale"));
     ## End
     if (is_string($html) === FALSE) {
         $html = NULL;
     }
     if ($html === NULL) {
         $html = (string) "<style type=\"text/css\">";
         $html .= "#buttons{padding:5px 30px;text-align:right;}";
         $html .= "#content{padding:10px 15px;text-align:left;}";
         $html .= "#tabs{background-color:#ebf0ea;}";
         $html .= "#tabImages{margin:0px auto;}";
         $html .= "#userProfile{background-color:#bccdba;font:13px/1.22 Arial,Helvetica,sans-serif;margin:0px;padding:0px;width:100%;}";
         $html .= ".lbl{color:#000;margin:2px 0px 19px;padding:0px;width:auto;}";
         $html .= ".lblcb{color:#000;margin-bottom:15px;margin-top:0px;padding:0px;width:auto;}";
         $html .= ".pc{display:inline-block;float:left;margin-right:15px;text-align:left;width:auto;}";
         $html .= ".tablImages{cursor:pointer;height:39px;padding:10px 15px;width:44px;}";
         $html .= ".tablImages:first-child{background-color:#FFF;}";
         $html .= "input,select,textarea{background-color:#FFF;border:1px solid #999;margin:0px 0px 15px;padding:0px;width:100%;}";
         $html .= "input[type=checkbox],input[type=radio]{width:auto;}";
         $html .= "textarea{height:54px;}";
         $html .= "</style>" . PHP_EOL;
         $html .= "<form enctype=\"multipart/form-data\" id=\"userProfile\" method=\"POST\">";
         if (isset($user) && isset($user["personid"])) {
             $html .= "<input name=\"personid\" type=\"hidden\" value=\"" . $user["personid"] . "\" />";
         }
         $html .= "<div id=\"tabs\"><span id=\"tabImages\">";
         ## Mouse Events
         $mouse_events = (string) "onclick=\"up.mouse(this, event);\" onmouseout=\"up.mouse(this, event);\" onmouseover=\"up.mouse(this, event);\"";
         $html .= "<img alt=\"profile\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-profile.png\" />";
         $html .= "<img alt=\"communication\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-communication.png\" />";
         $html .= "<img alt=\"login\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-login.png\" />";
         if (isset($_SESSION["isit"]) && $_SESSION["isit"]) {
             $html .= "<img alt=\"flags\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-flags.png\" />";
             $html .= "<img alt=\"accessgroups\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-accessgroups.png\" />";
         }
         $html .= "</span></div>";
         $html .= "<div id=\"content\">";
         ## Profile
         $html .= "<div id=\"profile\">";
         $html .= "<span class=\"pc\">";
         ## labels
         $html .= "<label class=\"lbl\" for=\"staffno\">Staff Number</label><br />";
         $html .= "<label class=\"lbl\" for=\"firstname\">First name</label><br />";
         $html .= "<label class=\"lbl\" for=\"lastname\">Last name</label><br />";
         $html .= "<label class=\"lbl\" for=\"jobtitle\">Job Title</label><br />";
         $html .= "<label class=\"lbl\" for=\"department_id\" style=\"margin-bottom:21px;\">Department</label><br />";
         $html .= "<label class=\"lbl\" for=\"location\">Location</label><br />";
         $html .= "<label class=\"lbl\" for=\"day\" style=\"margin-bottom:21px;\">Birthday</label><br />";
         if (isset($_SESSION["isit"]) && $_SESSION["isit"]) {
             $html .= "<label class=\"lbl\" for=\"image_file\">Image</label><br />" . PHP_EOL;
         }
         $html .= "<label class=\"lbl\" for=\"fortune\" title=\"Would you like a fortune cookie to be displayed on each page?\">Fortune</label><br />";
         $html .= "<label class=\"lbl\" for=\"theme_id\">Theme</label><br />";
         $html .= "</span>";
         $html .= "<span class=\"pc\" style=\"margin-right:30px;text-align:left;width:32%;\">";
         ## inputs
         $html .= "<input id=\"staffno\" name=\"staffno\" " . (isset($record) && isset($record["staffno"]) ? "readonly=\"readonly\" " : "") . " type=\"text\" value=\"" . (isset($record) && isset($record["staffno"]) ? $record["staffno"] : "") . "\">";
         $html .= "<input id=\"firstname\" name=\"firstname\" type=\"text\" value=\"" . (isset($record) && isset($record["firstname"]) ? $record["firstname"] : "") . "\">";
         $html .= "<input id=\"lastname\" name=\"lastname\" type=\"text\" value=\"" . (isset($record) && isset($record["lastname"]) ? $record["lastname"] : "") . "\">";
         $html .= "<input id=\"jobtitle\" name=\"jobtitle\" type=\"text\" value=\"" . (isset($record) && isset($record["jobtitle"]) ? $record["jobtitle"] : "") . "\" />";
         $html .= "<select id=\"department_id\" name=\"department_id\">";
         $html .= "<option value=\"0\">Please select...</options>";
         foreach ($departments as $dept) {
             $html .= "<option value=\"" . $dept["id"] . "\"" . (isset($record) && isset($record["department_id"]) && $record["department_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>";
         }
         $html .= "</select>";
         $html .= "<select id=\"location\" name=\"location\">";
         foreach ($locations as $location) {
             $html .= "<option " . (isset($record) && isset($record["location"]) && $record["location"] == $location["name"] ? "selected=\"selected\" " : "") . "value=\"" . $location["name"] . "\">" . $location["name"] . "</option>";
         }
         $html .= "</select>";
         $html .= "<select id=\"day\" name=\"day\" style=\"float:left;margin-bottom:15px;margin-right:15px;width:60px;\">";
         $html .= "<option value=\"0\">Day</option>";
         for ($i = 1; $i < 32; $i++) {
             $html .= "<option " . (isset($record) && isset($record["birthday"]) && date("d", $record["birthday"]) == $i ? "selected=\"selected\" " : "") . "value=\"" . (strlen($i) == 1 ? "0" . $i : $i) . "\">" . (strlen($i) == 1 ? "0" . $i : $i) . "</option>";
         }
         $html .= "</select>";
         $html .= "<select id=\"month\" name=\"month\" style=\"float:left;width:120px;\">";
         $html .= "<option value=\"0\">Month</option>";
         for ($i = 1; $i < 13; $i++) {
             $html .= "<option " . (isset($record) && isset($record["birthday"]) && date("F", $record["birthday"]) == date("F", mktime(0, 0, 0, $i, 1, 2000)) ? "selected=\"selected\" " : "") . "value=\"" . date("m", mktime(0, 0, 0, $i, 1, 2000)) . "\">" . date("F", mktime(0, 0, 0, $i, 1, 2000)) . "</option>";
         }
         $html .= "</select>";
         if (isset($_SESSION["isit"]) && $_SESSION["isit"]) {
             $html .= "<input type=\"file\" id=\"image_file\" name=\"image\" size=\"15\" />";
         }
         $html .= "<input" . (isset($record) && isset($record["fortune"]) && $record["fortune"] ? " checked=\"checked\"" : "") . " id=\"fortune\" name=\"fortune\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />";
         $html .= "<input id=\"theme_id\" name=\"theme_id\" type=\"hidden\" value=\"" . (isset($record) && isset($record["theme_id"]) ? $record["theme_id"] : "") . "\"  />";
         $i = (int) 0;
         $html .= "<div>";
         foreach (is_array($themes) ? $themes : array() as $theme) {
             $html .= "<img alt=\"theme\" onclick=\"up.resetBorders(this);document.getElementById('theme_id').value='" . $theme["id"] . "';\" src=\"" . BASE . "images/new/themes/" . $theme["background-image"] . "\" style=\"border:1px solid #" . (isset($record) && isset($record["theme_id"]) && $record["theme_id"] === $theme["id"] ? "F00" : "000") . ";cursor:pointer;height:30px;margin:5px;width:30px;\" />";
             $i++;
             if ($i === 3) {
                 $i = 0;
                 $html .= "<br class=\"clear\" />";
             }
         }
         $html .= "</div><br class=\"clear\" >";
         $html .= "</span>";
         $html .= "<span class=\"pc\">";
         ## labels
         $html .= "<label class=\"lbl\" for=\"family\" style=\"margin-bottom:56px;\">Family</label><br class=\"clear\" />";
         $html .= "<label class=\"lbl\" for=\"goals\" style=\"margin-bottom:56px;\">Goals</label><br class=\"clear\" />";
         $html .= "<label class=\"lbl\" for=\"interests\" style=\"margin-bottom:56px;\">Interests</label><br class=\"clear\" />";
         $html .= "<label class=\"lbl\" for=\"aspirations\" style=\"margin-bottom:56px;\">Aspirations</label><br class=\"clear\" />";
         $html .= "<label class=\"lbl\" for=\"quote\" style=\"margin-bottom:56px;\">Quote</label><br class=\"clear\" />";
         $html .= "</span>";
         $html .= "<span class=\"pc\" style=\"width:32%;\">";
         ## inputs
         $html .= "<textarea id=\"family\" name=\"family\">" . ($record ? $record["family"] : "") . "</textarea><br class=\"clear\" />";
         $html .= "<textarea id=\"goals\" name=\"goals\">" . ($record ? $record["goals"] : "") . "</textarea><br />";
         $html .= "<textarea id=\"interests\" name=\"interests\">" . ($record ? $record["interests"] : "") . "</textarea><br />";
         $html .= "<textarea id=\"aspirations\" name=\"aspirations\">" . ($record ? $record["aspirations"] : "") . "</textarea><br />";
         $html .= "<textarea id=\"quote\" name=\"quote\">" . ($record ? $record["quote"] : "") . "</textarea><br />";
         $html .= "</span>";
         $html .= "<br class=\"clear\" /></div>";
         ## Communication
         $html .= "<div id=\"communication\" style=\"display:none;\">";
         $html .= "<span class=\"pc\">";
         ## labels
         $html .= "<label class=\"lbl\" for=\"extension\">Office extension</label><br />";
         $html .= "<label class=\"lbl\" for=\"cell\">Cellphone</label>";
         $html .= "</span>";
         $html .= "<span class=\"pc\" style=\"margin-right:30px;width:30%;\">";
         ## inputs
         $html .= "<input id=\"extension\" name=\"extension\" type=\"text\" value=\"" . (isset($user) && isset($user["extension"]) ? $user["extension"] : "") . "\" /><br style=\"clear:both;\" />";
         $html .= "<input id=\"cell\" name=\"cell\" type=\"text\" value=\"" . (isset($user) && isset($user["cell"]) ? $user["cell"] : "") . "\" /><br />";
         $html .= "</span>";
         $html .= "<span class=\"pc\">";
         ## labels
         $html .= "<label class=\"lbl\" for=\"email\">Email</label>";
         $html .= "</span>";
         $html .= "<span class=\"pc\" style=\"width:37.4%;\">";
         ## inputs
         $html .= "<input id=\"email\" name=\"email\" type=\"email\" value=\"" . $user["email"] . "\" /><br />";
         $html .= "</span>";
         $html .= "<br class=\"clear\" /></div>";
         ## Login
         $html .= "<div id=\"login\" style=\"display:none;\">";
         $html .= "<span class=\"pc\">";
         ## labels
         $html .= "<label class=\"lbl\" for=\"username\">Username</label>";
         $html .= "</span>";
         $html .= "<span class=\"pc\" style=\"margin-right:30px;width:32%;\">";
         ## inputs
         $html .= "<input id=\"username\" name=\"username\" type=\"text\" value=\"" . (isset($user) && isset($user["username"]) ? $user["username"] : "") . "\" />";
         $html .= "</span>";
         $html .= "<span class=\"pc\">";
         ## labels
         $html .= "<label class=\"lbl\" for=\"password\">Password</label><br />";
         $html .= "<label class=\"lbl\" for=\"con_pass\">Confirm password</label>";
         $html .= "</span>";
         $html .= "<span class=\"pc\" style=\"width:29%;\">";
         ## inputs
         $html .= "<input id=\"password\" name=\"password\" type=\"password\" /><br />";
         $html .= "<input id=\"con_pass\" onblur=\"formManipulators.checkPasswordIdentical('password', 'con_pass');\" type=\"password\" />";
         $html .= "</span>";
         $html .= "<br class=\"clear\" /></div>";
         if (isset($_SESSION["isit"]) && $_SESSION["isit"]) {
             ## Flags
             $cols = (array) array();
             $i = (int) 0;
             foreach ($metaData as $col => $data) {
                 if ($col == "isadmin") {
                     continue;
                 }
                 if (in_array($data["Type"], array("int(1)", "tinyint(1)"))) {
                     $cols[$i][$col] = $data;
                     $i++;
                     if ($i === 3) {
                         $i = 0;
                     }
                 }
             }
             $html .= "<div id=\"flags\" style=\"display:none;\">";
             $html .= "<span class=\"pc\">";
             ## inputs
             foreach (is_array($cols[0]) ? $cols[0] : array() as $col => $data) {
                 $html .= "<input" . (isset($user) && isset($user[$col]) && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\" style=\"width:25%;\">";
             ## labels
             foreach (is_array($cols[0]) ? $cols[0] : array() as $col => $data) {
                 $html .= "<label class=\"lblcb\" for=\"" . $col . "\">" . $col . "</label><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\">";
             ## inputs
             foreach (is_array($cols[1]) ? $cols[1] : array() as $col => $data) {
                 $html .= "<input" . (isset($user) && isset($user[$col]) && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\" style=\"width:25%;\">";
             ## labels
             foreach (is_array($cols[1]) ? $cols[1] : array() as $col => $data) {
                 $html .= "<label class=\"lblcb\" for=\"" . $col . "\">" . $col . "</label><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\">";
             ## inputs
             foreach (is_array($cols[2]) ? $cols[2] : array() as $col => $data) {
                 $html .= "<input" . (isset($user) && isset($user[$col]) && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\" style=\"width:25%;\">";
             ## labels
             foreach (is_array($cols[2]) ? $cols[2] : array() as $col => $data) {
                 $html .= "<label class=\"lblcb\" for=\"" . $col . "\">" . $col . "</label><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<br class=\"clear\" /></div>";
             ## Access groups
             $cols = (array) array();
             $i = (int) 0;
             foreach ($rights_groups as $grp) {
                 $cols[$i][] = $grp;
                 $i++;
                 if ($i === 3) {
                     $i = 0;
                 }
             }
             $html .= "<div id=\"accessgroups\" style=\"display:none;\">";
             $html .= "<span class=\"pc\">";
             ## inputs
             foreach (is_array($cols[0]) ? $cols[0] : array() as $key => $data) {
                 $checked = (bool) false;
                 if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) {
                     foreach ($user["children"]["rights_users"] as $right) {
                         if ($right['groupid'] == $data["id"]) {
                             $checked = true;
                             break;
                         }
                     }
                 }
                 $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $data["id"] . "\" name=\"group[" . $data["id"] . "]\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"" . $data["id"] . "\" /><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\" style=\"width:25%;\">";
             ## labels
             foreach (is_array($cols[0]) ? $cols[0] : array() as $key => $data) {
                 $html .= "<label class=\"lblcb\" for=\"" . $data["id"] . "\" title=\"" . $data["description"] . "\">" . $data["name"] . "</label><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\">";
             ## inputs
             foreach (is_array($cols[1]) ? $cols[1] : array() as $key => $data) {
                 $checked = (bool) false;
                 if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) {
                     foreach ($user["children"]["rights_users"] as $right) {
                         if ($right['groupid'] == $data["id"]) {
                             $checked = true;
                             break;
                         }
                     }
                 }
                 $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $data["id"] . "\" name=\"group[" . $data["id"] . "]\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"" . $data["id"] . "\" /><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\" style=\"width:25%;\">";
             ## labels
             foreach (is_array($cols[1]) ? $cols[1] : array() as $key => $data) {
                 $html .= "<label class=\"lblcb\" for=\"" . $data["id"] . "\" title=\"" . $data["description"] . "\">" . $data["name"] . "</label><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\">";
             ## inputs
             foreach (is_array($cols[2]) ? $cols[2] : array() as $key => $data) {
                 $checked = (bool) false;
                 if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) {
                     foreach ($user["children"]["rights_users"] as $right) {
                         if ($right['groupid'] == $data["id"]) {
                             $checked = true;
                             break;
                         }
                     }
                 }
                 $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $data["id"] . "\" name=\"group[" . $data["id"] . "]\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"" . $data["id"] . "\" /><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<span class=\"pc\" style=\"width:25%;\">";
             ## labels
             foreach (is_array($cols[2]) ? $cols[2] : array() as $key => $data) {
                 $html .= "<label class=\"lblcb\" for=\"" . $data["id"] . "\" title=\"" . $data["description"] . "\">" . $data["name"] . "</label><br class=\"clear\" />";
             }
             $html .= "</span>";
             $html .= "<br class=\"clear\" /></div>";
         }
         $html .= "<br class=\"clear\" /></div>";
         $html .= "<div id=\"buttons\">";
         $html .= "<span class=\"button\" onclick=\"document.getElementById('userProfile').submit();\" style=\"height:26px;padding-top:8px;width:114px;\">Save</span>";
         $html .= "<span class=\"button\" onclick=\"document.location='/';\" style=\"height:26px;padding-top:8px;width:114px;\">Cancel</span>";
         $html .= "</div>";
         $html .= "</form>" . PHP_EOL;
         $html .= "<script type=\"text/javascript\">";
         $html .= "var up={};";
         $html .= "up.mouse = function(e, ev) {";
         $html .= "var i,p1=e.parentNode,p2=document.getElementById('content');";
         $html .= "if (!ev) {var ev = window.event;} if (!ev) {return false;}";
         $html .= "switch (ev.type) {";
         $html .= "case 'click': ";
         $html .= "for (i=0;i<p1.childNodes.length;i++){p1.childNodes[i].style.backgroundColor='inherit';if (p1.childNodes[i].getAttribute('alt') == e.getAttribute('alt')) {e.setAttribute('obg', '#FFF');e.style.backgroundColor='#FFF';}} ";
         $html .= "for (i=0;i<p2.childNodes.length;i++) {p2.childNodes[i].style.display='none';}";
         $html .= "document.getElementById(e.getAttribute('alt')).style.display='';";
         $html .= "break;";
         $html .= "case 'mouseout': e.style.backgroundColor=e.getAttribute('obg'); break;";
         $html .= "case 'mouseover': e.setAttribute('obg', e.style.backgroundColor);e.style.backgroundColor='#FFF'; break;";
         $html .= "}";
         $html .= "};";
         $html .= "up.resetBorders = function(e){";
         $html .= "var i,p=e.parentNode;";
         $html .= "for(i=0;i<p.childNodes.length;i++){p.childNodes[i].style.borderColor='#000';}";
         $html .= "e.style.borderColor='#F00';";
         $html .= "};";
         $html .= "</script>" . PHP_EOL;
         //$html .= "";
     }
     $this->_html = $html;
 }
 /** Scaffold_Forms_User_profiles::setHtml($html = null)
  * @param string $html HTML form definition
  */
 public function setHtml($html = null)
 {
     if ($html === null) {
         ## Preparation
         $record = self::getRecord();
         if (is_object("TableManager") === false) {
             include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php";
         }
         $tableManager = new TableManager("m3_departments");
         $departments = $tableManager->selectMultiple();
         $sql = (string) "SELECT * FROM `themes` WHERE (ISNULL(`deleted`) OR `deleted`=0)";
         $themes = $tableManager->runSql($sql);
         $users = new TableManager("users");
         $metaData = $users->getMetaData();
         if ($record) {
             $users->setChildRecords(true);
             $users->setChildTables(array(0 => array("rights_users" => "rights_users", "where" => "`rights_users`.`userid`=?")));
             $users->setWhere($users->quoteString("`users`.`user_profiles_id`=?", (int) $record["id"]));
             $user = $users->selectSingle();
         }
         $sql = (string) "SELECT * FROM `rights_groups` WHERE 1=1;";
         $rights_groups = $users->runSql($sql);
         ## End
         $html = (string) "<form enctype=\"multipart/form-data\" method=\"POST\">" . PHP_EOL;
         $html .= "<div style=\"width:800px;\">" . PHP_EOL;
         $html .= "<div style=\"text-align:center;\">" . PHP_EOL;
         $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL;
         $html .= "</div>" . PHP_EOL;
         ## Profile details
         $html .= "<fieldset style=\"width:730px;\">";
         $html .= "<legend>Profile details</legend>";
         $html .= "<div style=\"border:none;float:left;width:49%;\">";
         $html .= "<label for=\"staffno\" style=\"color:#000;width:150px;\">Staff Number</label>" . PHP_EOL;
         $html .= "<input id=\"staffno\" name=\"staffno\" " . ($record["staffno"] ? "readonly=\"readonly\" " : "") . "type=\"text\" value=\"" . ($record["staffno"] ? $record["staffno"] : "") . "\"><br style=\"clear:both;\" />" . PHP_EOL;
         $html .= "<label for=\"firstname\" style=\"color:#000;width:150px;\">First name</label>" . PHP_EOL;
         $html .= "<input id=\"firstname\" name=\"firstname\" type=\"text\" value=\"" . ($record["firstname"] ? $record["firstname"] : "") . "\"><br />" . PHP_EOL;
         $html .= "<label for=\"day\" style=\"color:#000;width:150px;\">Birthday</label>" . PHP_EOL;
         $html .= "<select id=\"day\" name=\"day\" style=\"float:left;margin-bottom:5px;width:50px;\">";
         $html .= "<option value=\"0\">Day</option>" . PHP_EOL;
         for ($i = 1; $i < 32; $i++) {
             $html .= "<option " . ($record["birthday"] && date("d", $record["birthday"]) == $i ? "selected=\"selected\" " : "") . "value=\"" . (strlen($i) == 1 ? "0" . $i : $i) . "\">" . (strlen($i) == 1 ? "0" . $i : $i) . "</option>";
         }
         $html .= "</select>";
         $html .= "<select id=\"month\" name=\"month\" style=\"float:left;width:120px;\">";
         $html .= "<option value=\"0\">Month</option>" . PHP_EOL;
         for ($i = 1; $i < 13; $i++) {
             $html .= "<option " . ($record["birthday"] && date("F", $record["birthday"]) == date("F", mktime(0, 0, 0, $i, 1, 2000)) ? "selected=\"selected\" " : "") . "value=\"" . date("m", mktime(0, 0, 0, $i, 1, 2000)) . "\">" . date("F", mktime(0, 0, 0, $i, 1, 2000)) . "</option>";
         }
         $html .= "</select><br style=\"clear:both;\" />";
         $html .= "<label for=\"department_id\" style=\"color:#000;width:150px\">Department</label>" . PHP_EOL;
         $html .= "<select id=\"department_id\" name=\"department_id\">" . PHP_EOL;
         $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL;
         foreach ($departments as $dept) {
             $html .= "<option value=\"" . $dept["id"] . "\"" . ($record && $record["department_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>" . PHP_EOL;
         }
         $html .= "</select><br class=\"clear\" />" . PHP_EOL;
         $locations = (array) array(0 => array("name" => "Head Office"), 1 => array("name" => "Durban"), 2 => array("name" => "Empangeni"), 3 => array("name" => "East London"), 4 => array("name" => "Kokstad"), 5 => array("name" => "Pietermaritzburg"), 6 => array("name" => "Newcastle"), 7 => array("name" => "Vanderbijl Park"), 8 => array("name" => "Isando"), 9 => array("name" => "Germiston"));
         $html .= "<label for=\"location\" style=\"color:#000;width:150px;\">Location</label>" . PHP_EOL;
         $html .= "<select id=\"location\" name=\"location\" style=\"float:left;width:165px;\">" . PHP_EOL;
         foreach ($locations as $location) {
             $html .= "<option " . ($record["location"] && $record["location"] == $location["name"] ? "selected=\"selected\" " : "") . "value=\"" . $location["name"] . "\">" . $location["name"] . "</option>" . PHP_EOL;
         }
         $html .= "</select><br class=\"clear\" />" . PHP_EOL;
         $html .= "<label for=\"interests\" style=\"color:#000;\">Interests</label>" . PHP_EOL;
         $html .= "<textarea id=\"interests\" name=\"interests\">" . ($record ? $record["interests"] : "") . "</textarea><br />" . PHP_EOL;
         $html .= "<label for=\"aspirations\" style=\"color:#000;\">Aspirations</label>" . PHP_EOL;
         $html .= "<textarea id=\"aspirations\" name=\"aspirations\">" . ($record ? $record["aspirations"] : "") . "</textarea><br />" . PHP_EOL;
         $html .= "<label for=\"quote\" style=\"color:#000;\">Quote</label>" . PHP_EOL;
         $html .= "<textarea id=\"quote\" name=\"quote\">" . ($record ? $record["quote"] : "") . "</textarea><br />" . PHP_EOL;
         $html .= "</div>";
         $html .= "<div style=\"border:none;float:left;width:49%;\">";
         $html .= "<label for=\"image_file\" style=\"color:#000;width:150px;\">Image</label>" . PHP_EOL;
         $html .= "<input type=\"file\" id=\"image_file\" name=\"image\" /><br />" . PHP_EOL;
         $html .= "<label for=\"lastname\" style=\"color:#000;width:150px;\">Last name</label>" . PHP_EOL;
         $html .= "<input id=\"lastname\" name=\"lastname\" type=\"text\" value=\"" . ($record["lastname"] ? $record["lastname"] : "") . "\"><br class=\"clear\" /><br /><br />" . PHP_EOL;
         $html .= "<label for=\"jobtitle\" style=\"color:#000;width:150px\">Job Title</label>" . PHP_EOL;
         $html .= "<input type=\"text\" id=\"jobtitle\" name=\"jobtitle\" value=\"" . ($record ? $record["jobtitle"] : "") . "\" /><br />" . PHP_EOL;
         $html .= "<label for=\"family\" style=\"color:#000;\">Family</label>" . PHP_EOL;
         $html .= "<textarea id=\"family\" name=\"family\">" . ($record ? $record["family"] : "") . "</textarea><br />" . PHP_EOL;
         $html .= "<label for=\"goals\" style=\"color:#000;\">Goals</label>" . PHP_EOL;
         $html .= "<textarea id=\"goals\" name=\"goals\">" . ($record ? $record["goals"] : "") . "</textarea><br />" . PHP_EOL;
         $html .= "</div>";
         $html .= "</fieldset>";
         ## User details
         $html .= "<fieldset style=\"width:730px;\">";
         $html .= "<legend>User details</legend>";
         $html .= "<div style=\"float:left;width:49%;\">";
         $html .= "<fieldset style=\"border:none;\">";
         $html .= "<legend>Communication</legend>";
         $html .= "<label for=\"extension\" style=\"color:#000;width:150px;\">Office extension</label>";
         $html .= "<input id=\"extension\" name=\"extension\" type=\"text\" value=\"" . $user["extension"] . "\" /><br />";
         $html .= "<label for=\"cell\" style=\"color:#000;width:150px;\">Cellphone</label>";
         $html .= "<input id=\"cell\" name=\"cell\" type=\"text\" value=\"" . $user["cell"] . "\" /><br />";
         $html .= "<label for=\"email\" style=\"color:#000;width:150px;\">Email</label>";
         $html .= "<input id=\"email\" name=\"email\" type=\"email\" value=\"" . $user["email"] . "\" /><br />";
         $html .= "</fieldset>";
         $html .= "<fieldset style=\"border:none;\">";
         $html .= "<legend>Login and Password</legend>";
         if ($user) {
             $html .= "<input id=\"personid\" name=\"personid\" type=\"hidden\" value=\"" . $user["personid"] . "\" />";
         }
         $html .= "<label for=\"username\" style=\"color:#000;width:150px;\">Username</label>";
         $html .= "<input id=\"username\" name=\"username\"" . (isset($user) ? "" : " onblur=\"check.checkUsernameAvailability(this);\"") . " type=\"text\" value=\"" . $user["username"] . "\" /><br />";
         $html .= "<label for=\"pass\" style=\"color:#000;width:150px;\">Password</label>";
         $html .= "<input id=\"pass\" name=\"password\" type=\"password\" /><br />";
         $html .= "<label for=\"conpass\" style=\"color:#000;width:150px;\">Confirm password</label>";
         $html .= "<input id=\"conpass\" name=\"conpass\" type=\"password\" onblur=\"formManipulators.checkPasswordIdentical('pass', 'conpass')\" /><br />";
         $html .= "</fieldset>";
         $html .= "</div>";
         $html .= "<div style=\"float:left;width:49%;\">";
         $html .= "<fieldset style=\"border:none;\">";
         $html .= "<legend>Flags</legend>";
         if ($_SESSION["isit"]) {
             foreach ($metaData as $col => $data) {
                 if ($col == "isadmin") {
                     continue;
                 }
                 if (in_array($data["Type"], array("int(1)", "tinyint(1)"))) {
                     $html .= "<input" . ($user && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" type=\"checkbox\" value=\"1\" />";
                     $html .= "<label for=\"" . $col . "\" style=\"color:#000;\">" . $col . "</label><br />";
                 }
             }
         } else {
             $html .= "Cannot set access flags. Please see IT dept. to change";
         }
         $html .= "</fieldset>";
         $html .= "<fieldset style=\"border:none;\">";
         $html .= "<legend>Access Groups</legend>";
         if ($_SESSION["isit"]) {
             foreach ($rights_groups as $grp) {
                 $checked = (bool) false;
                 if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) {
                     foreach ($user["children"]["rights_users"] as $right) {
                         if ($right['groupid'] == $grp["id"]) {
                             $checked = true;
                             break;
                         }
                     }
                 }
                 $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $grp["id"] . "\" name=\"group[" . $grp["id"] . "]\" type=\"checkbox\" value=\"" . $grp["id"] . "\" />";
                 $html .= "<label for=\"" . $grp["id"] . "\" style=\"color:#000;\">" . $grp["name"] . "</label><br />";
             }
         } else {
             $html .= "Cannot set access flags. Please see IT dept. to change";
         }
         $html .= "</fieldset>";
         $html .= "</div>";
         $html .= "</fieldset>";
         $html .= "<div style=\"text-align:center;\">" . PHP_EOL;
         $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL;
         $html .= "</div>" . PHP_EOL;
         $html .= "</div>" . PHP_EOL;
         $html .= "</form>" . PHP_EOL;
         //$html .= "<iframe id=\"targetFrame\" name=\"targetFrame\"></iframe>".PHP_EOL;
         $html .= "<iframe id=\"targetFrame\" name=\"targetFrame\" style=\"display:none;\"></iframe>" . PHP_EOL;
         $html .= "<script type=\"text/javascript\">" . PHP_EOL;
         $html .= "function selectTheme(elem) {\n\t\t  for (var i=0; i<document.getElementById('profileTheme').getElementsByTagName('IMG').length;i++) {\n\t\t  document.getElementById('profileTheme').getElementsByTagName('IMG')[i].style.border='none';\n\t\t  } \n\t\t  elem.style.border='1px solid #000';\n\t\t  }" . PHP_EOL;
         $html .= "</script>" . PHP_EOL;
     }
     $this->_html = $html;
 }
Exemplo n.º 9
0
/** getFleetBudgetDays($fleet, $startDate = NULL, $stopDate = NULL)
 * get the number of days that fleet $fleet has a budget for
 * @param INT $fleet Fleet ID
 * @param INT $startDate when do we start
 * @param INT $stopDate when do we stop
 * @return INT number of days on success FALSE otherwise
 */
function getFleetBudgetDays($fleet, $startDate = NULL, $stopDate = NULL)
{
    //: Tests
    if (is_int($fleet) === FALSE) {
        return FALSE;
    }
    if (is_int($startDate) === FALSE) {
        $startDate = mktime(0, 0, 0, date("m"), 1, date("Y"));
    }
    if (is_int($stopDate) === FALSE) {
        $stopDate = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
    }
    //: End
    //: Function Content
    $manager = new TableManager("fleet_scores");
    $sql = (string) "SELECT * FROM `fleet_scores` WHERE ";
    $sql .= $manager->quoteString("`fleetid`=?", (int) $fleet);
    $sql .= $manager->quoteString(" AND `date`>=?", $startDate);
    $sql .= $manager->quoteString(" AND `date`<=?", $stopDate);
    if (($results = $manager->runSql($sql)) === FALSE) {
        return FALSE;
    }
    $day = (int) 0;
    foreach ($results as $val) {
        if (isset($val["budget"]) && $val["budget"] > 0) {
            $day++;
        }
    }
    return $day;
    //: End
}