Esempio n. 1
0
 static function getInstance()
 {
     if (self::$uniqueInstance == NULL) {
         self::$uniqueInstance = new self();
     }
     return self::$uniqueInstance;
 }
Esempio n. 2
0
 /**
  * Singleton Pattern
  *
  * Auto Create Object Instance.
  *
  */
 public static function getInstance()
 {
     if (null === self::$_objInstance) {
         self::$_objInstance = new Stat();
     }
     return self::$_objInstance;
 }
Esempio n. 3
0
function PageStat(&$skeleton)
{
    $itemlist = new ItemList($skeleton);
    $db = Stat::loadDb();
    $itemlist->setBorders(array('top' => '-', 'bottom' => '-', 'left' => '+', 'right' => '+'));
    $itemlist->setText("Number of page viewed: " . $db['total_pages']);
    $skeleton->addWidget($itemlist);
}
Esempio n. 4
0
 public function testFailedJobExceptionsAreCaught()
 {
     $payload = array('class' => 'Failing_Job', 'args' => null);
     $job = new Job('jobs', $payload);
     $job->worker = $this->worker;
     $this->worker->perform($job);
     $this->assertEquals(1, Stat::get('failed'));
     $this->assertEquals(1, Stat::get('failed:' . $this->worker));
 }
Esempio n. 5
0
 function test_run_maxHpIsThere()
 {
     Initial::addData();
     $character = Finalize::run();
     $id = $character->getStatId();
     $stat = Stat::find($id);
     $max_hp = $stat->getMaxHp();
     $result = 11;
     $this->assertEquals($max_hp, $result);
 }
Esempio n. 6
0
 function points_game($stat_type, $game, &$stats)
 {
     $this->_init_rosters($stats);
     $kp_id = $this->_stat_type_id('Kills');
     $km_id = $this->_stat_type_id('Killed');
     $cp_id = $this->_stat_type_id('Catches');
     $cm_id = $this->_stat_type_id('Caught');
     foreach ($this->rosters as $team_id => $roster) {
         foreach ($roster as $person_id => $position) {
             $value = $this->_value($kp_id, $person_id, $stats) - $this->_value($km_id, $person_id, $stats) + ($this->_value($cp_id, $person_id, $stats) - $this->_value($cm_id, $person_id, $stats)) * 2;
             if (Stat::applicable($stat_type, $position) || $value != 0) {
                 $stats['Stat'][] = array('game_id' => $game['Game']['id'], 'team_id' => $team_id, 'person_id' => $person_id, 'stat_type_id' => $stat_type['id'], 'value' => $value);
             }
         }
     }
 }
Esempio n. 7
0
 function points_game($stat_type, $game, &$stats)
 {
     $this->_init_rosters($stats);
     $t_id = $this->_stat_type_id('Tries');
     $c_id = $this->_stat_type_id('Conversions');
     $pk_id = $this->_stat_type_id('Penalty Kicks');
     $dg_id = $this->_stat_type_id('Drop Goals');
     foreach ($this->rosters as $team_id => $roster) {
         foreach ($roster as $person_id => $position) {
             $value = $this->_value($t_id, $person_id, $stats) * 5 + $this->_value($c_id, $person_id, $stats) * 2 + $this->_value($pk_id, $person_id, $stats) * 3 + $this->_value($dg_id, $person_id, $stats) * 3;
             if (Stat::applicable($stat_type, $position) || $value != 0) {
                 $stats['Stat'][] = array('game_id' => $game['Game']['id'], 'team_id' => $team_id, 'person_id' => $person_id, 'stat_type_id' => $stat_type['id'], 'value' => $value);
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Former::$rules);
     if ($validation->passes()) {
         $this->former->create($input);
         $data = 'lead in ';
         $url = 'http://eleads.lafilm.com:8088/Cmc.Integration.LeadImport.HttpPost/ImportLeadProcessor.aspx';
         if ($input['program'] == 'BSEB-O' || $input['program'] == 'BSDC-O') {
             $camp = 'MAIN2';
         } else {
             $camp = 'MAIN';
         }
         $post = '';
         $post .= 'Leadsource=' . $input['leadSource'];
         $post .= '&Format=' . $input['format'];
         $post .= '&FirstName=' . $input['FirstName'];
         $post .= '&LastName=' . $input['LastName'];
         $post .= '&Program=' . $input['program'];
         $post .= '&Email=' . $input['email'];
         $post .= '&PostalCodeorZip=' . $input['PostalCodeorZip'];
         $post .= '&Phone=' . $input['Phone'];
         $post .= '&Country=' . $input['Country'];
         $post .= '&PreviousEducation=' . $input['PreviousEducation'];
         $post .= '&leadtype=NEWLEAD&campus=' . $camp;
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $response = curl_exec($ch);
         $stat = Input::get('stat_id');
         $stats = Stat::find($stat);
         $stats->convert = 1;
         $stats->save();
         return json_encode(array('msg' => 'Lead Processed', 'res' => $response));
     }
     return 'not true';
 }
Esempio n. 9
0
/** Display an infocom report for items like consumables
 *
 * @param $itemtype  item type
 * @param $begin     begin date
 * @param $end       end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
    global $DB, $valeurtot, $valeurnettetot, $valeurnettegraphtot, $valeurgraphtot, $CFG_GLPI;
    $itemtable = getTableForItemType($itemtype);
    $query = "SELECT `glpi_infocoms`.*\n             FROM `glpi_infocoms`\n             INNER JOIN `{$itemtable}`\n                  ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`\n                      AND `glpi_infocoms`.`itemtype`='{$itemtype}') ";
    switch ($itemtype) {
        case 'Consumable':
            $query .= " INNER JOIN `glpi_consumableitems`\n                        ON (`glpi_consumables`.`consumableitems_id` = `glpi_consumableitems`.`id`) " . getEntitiesRestrictRequest("WHERE", "glpi_consumableitems");
            break;
        case 'Cartridge':
            $query .= " INNER JOIN `glpi_cartridgeitems`\n                        ON (`glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`) " . getEntitiesRestrictRequest("WHERE", "glpi_cartridgeitems");
            break;
        case 'SoftwareLicense':
            $query .= " INNER JOIN `glpi_softwares`\n                        ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`) " . getEntitiesRestrictRequest("WHERE", "glpi_softwarelicenses");
            break;
    }
    if (!empty($begin)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` >= '{$begin}'\n                       OR `glpi_infocoms`.`use_date` >= '{$begin}')";
    }
    if (!empty($end)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` <= '{$end}'\n                       OR `glpi_infocoms`.`use_date` <= '{$end}')";
    }
    if ($result = $DB->query($query)) {
        if ($DB->numrows($result) > 0 && ($item = getItemForItemtype($itemtype))) {
            echo "<h2>" . $item->getTypeName(1) . "</h2>";
            echo "<table class='tab_cadre'>";
            $valeursoustot = 0;
            $valeurnettesoustot = 0;
            $valeurnettegraph = array();
            $valeurgraph = array();
            while ($line = $DB->fetch_assoc($result)) {
                if ($itemtype == 'SoftwareLicense') {
                    $item->getFromDB($line["items_id"]);
                    if ($item->fields["serial"] == "global") {
                        if ($item->fields["number"] > 0) {
                            $line["value"] *= $item->fields["number"];
                        }
                    }
                }
                if ($line["value"] > 0) {
                    $valeursoustot += $line["value"];
                }
                $valeurnette = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "n");
                $tmp = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "all");
                if (is_array($tmp) && count($tmp) > 0) {
                    foreach ($tmp["annee"] as $key => $val) {
                        if ($tmp["vcnetfin"][$key] > 0) {
                            if (!isset($valeurnettegraph[$val])) {
                                $valeurnettegraph[$val] = 0;
                            }
                            $valeurnettegraph[$val] += $tmp["vcnetdeb"][$key];
                        }
                    }
                }
                if (!empty($line["buy_date"])) {
                    $year = substr($line["buy_date"], 0, 4);
                    if ($line["value"] > 0) {
                        if (!isset($valeurgraph[$year])) {
                            $valeurgraph[$year] = 0;
                        }
                        $valeurgraph[$year] += $line["value"];
                    }
                }
                $valeurnettesoustot += str_replace(" ", "", $valeurnette);
            }
            $valeurtot += $valeursoustot;
            $valeurnettetot += $valeurnettesoustot;
            if (count($valeurnettegraph) > 0) {
                echo "<tr><td colspan='5' class='center'>";
                ksort($valeurnettegraph);
                $valeurnettegraphdisplay = array_map('round', $valeurnettegraph);
                foreach ($valeurnettegraph as $key => $val) {
                    if (!isset($valeurnettegraphtot[$key])) {
                        $valeurnettegraphtot[$key] = 0;
                    }
                    $valeurnettegraphtot[$key] += $valeurnettegraph[$key];
                }
                Stat::showGraph(array(__('Account net value') => $valeurnettegraphdisplay), array('title' => __('Account net value'), 'width' => 400));
                echo "</td></tr>\n";
            }
            if (count($valeurgraph) > 0) {
                echo "<tr><td colspan='5' class='center'>";
                ksort($valeurgraph);
                $valeurgraphdisplay = array_map('round', $valeurgraph);
                foreach ($valeurgraph as $key => $val) {
                    if (!isset($valeurgraphtot[$key])) {
                        $valeurgraphtot[$key] = 0;
                    }
                    $valeurgraphtot[$key] += $valeurgraph[$key];
                }
                Stat::showGraph(array(_x('price', 'Value') => $valeurgraphdisplay), array('title' => _x('price', 'Value'), 'width' => 400));
                echo "</td></tr>";
            }
            echo "</table>\n";
            return true;
        }
    }
    return false;
}
Esempio n. 10
0
// Just in case someone has a older version of neon.
$sStatsTable = $database->CachedQuery("CREATE TABLE IF NOT EXISTS `stats` (`id` int(8) NOT NULL AUTO_INCREMENT, `result` varchar(8) NOT NULL, `type` varchar(65) NOT NULL, `timestamp` int(16) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;", array(), 1);
// Pull used/total memory for stats
$sFree = shell_exec('free');
$sFree = (string) trim($sFree);
$sFree_Array = explode("\n", $sFree);
$sMemory = explode(" ", $sFree_Array[1]);
$sMemory = array_filter($sMemory);
$sMemory = array_merge($sMemory);
$sUsedMemory = $sMemory[2];
$sTotalMemory = $sMemory[1];
// Pull server load for stats
$sLoad = sys_getloadavg();
$sLoad = $sLoad[0];
$sStat = new Stat(0);
$sStat->uType = "used_memory";
$sStat->uResult = $sUsedMemory;
$sStat->uTimestamp = time();
$sStat->InsertIntoDatabase();
$sStat = new Stat(0);
$sStat->uType = "total_memory";
$sStat->uResult = $sTotalMemory;
$sStat->uTimestamp = time();
$sStat->InsertIntoDatabase();
$sStat = new Stat(0);
$sStat->uType = "load";
$sStat->uResult = $sLoad;
$sStat->uTimestamp = time();
$sStat->InsertIntoDatabase();
$sOld = time() - 60 * 60 * 24;
$sStatsTable = $database->CachedQuery("DELETE FROM stats WHERE timestamp < '{$sOld}'", array(), 1);
Esempio n. 11
0
if (isset($_GET["date2"])) {
    $_POST["date2"] = $_GET["date2"];
}
if (empty($_POST["date1"]) && empty($_POST["date2"])) {
    $year = date("Y") - 1;
    $_POST["date1"] = date("Y-m-d", mktime(1, 0, 0, date("m"), date("d"), $year));
    $_POST["date2"] = date("Y-m-d");
}
if (!empty($_POST["date1"]) && !empty($_POST["date2"]) && strcmp($_POST["date2"], $_POST["date1"]) < 0) {
    $tmp = $_POST["date1"];
    $_POST["date1"] = $_POST["date2"];
    $_POST["date2"] = $tmp;
}
if (!isset($_GET["start"])) {
    $_GET["start"] = 0;
}
Stat::title();
echo "<div class='center'><form method='post' name='form' action='stat.item.php'>";
echo "<table class='tab_cadre'><tr class='tab_bg_2'>";
echo "<td class='right'>" . __('Start date') . "</td><td>";
Html::showDateField("date1", array('value' => $_POST["date1"]));
echo "</td><td rowspan='2' class='center'>";
echo "<input type='submit' class='submit' name='submit' value='" . __s('Display report') . "'></td></tr>";
echo "<tr class='tab_bg_2'><td class='right'>" . __('End date') . "</td><td>";
Html::showDateField("date2", array('value' => $_POST["date2"]));
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
Stat::showItems($_SERVER['PHP_SELF'], $_POST["date1"], $_POST["date2"], $_GET['start']);
Html::footer();
Esempio n. 12
0
 function test_getModifier()
 {
     $stat_total = 16;
     $mod = Stat::getModifier($stat_total);
     $result = 3;
     $this->assertEquals($mod, $result);
 }
Esempio n. 13
0
 function updateMaxHp()
 {
     $mod = $this->getModifier($_SESSION['con']);
     $proficiencies = Stat::getProficiency();
     $GLOBALS['DB']->exec("UPDATE stats SET max_hp = {$mod} WHERE id = {$this->getId()};");
     $this->setMaxHp($mod);
 }
Esempio n. 14
0
 function getSurvival()
 {
     $id = $this->getStatId();
     $stat = Stat::find($id);
     $stat_total = $stat->getSurvival();
     return $stat_total;
 }
Esempio n. 15
0
        }
        Stat::showGraph(array(__('Number opened') => $cleandata), array('title' => __('Number opened'), 'showtotal' => 1, 'unit' => __('Tickets'), 'type' => 'pie'));
    }
    if (isset($data['solved']) && is_array($data['solved'])) {
        foreach ($data['solved'] as $key => $val) {
            $cleandata[Html::clean($key)] = $val;
        }
        Stat::showGraph(array(__('Number solved') => $cleandata), array('title' => __('Number solved'), 'showtotal' => 1, 'unit' => __('Tickets'), 'type' => 'pie'));
    }
    if (isset($data['late']) && is_array($data['late'])) {
        foreach ($data['late'] as $key => $val) {
            $cleandata[Html::clean($key)] = $val;
        }
        Stat::showGraph(array(__('Number solved late') => $cleandata), array('title' => __('Number solved late'), 'showtotal' => 1, 'unit' => __('Tickets'), 'type' => 'pie'));
    }
    if (isset($data['closed']) && is_array($data['closed'])) {
        foreach ($data['closed'] as $key => $val) {
            $newkey = Toolbox::unclean_cross_side_scripting_deep(Html::clean($key));
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array(__('Number closed') => $cleandata), array('title' => __('Number closed'), 'showtotal' => 1, 'unit' => __('Tickets'), 'type' => 'pie'));
    }
    if (isset($data['opensatisfaction']) && is_array($data['opensatisfaction'])) {
        foreach ($data['opensatisfaction'] as $key => $val) {
            $newkey = Toolbox::unclean_cross_side_scripting_deep(Html::clean($key));
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array(__('Satisfaction survey') => $cleandata), array('title' => __('Satisfaction survey'), 'showtotal' => 1, 'unit' => __('Tickets'), 'type' => 'pie'));
    }
}
Html::footer();
Esempio n. 16
0
<?php

session_start();
// Everything has a beginning...
require_once 'src/Config.php';
$time = microtime();
require_once 'src/ModelEntities.php';
require_once 'src/Common.php';
require_once 'src/Holder.php';
require_once 'src/Dispatcher.php';
require_once 'src/Skeleton.php';
require_once 'src/Stat.php';
Holder::init();
Stat::log();
$app = new AsciiMasterWidget(80);
$skeleton = new Skeleton($app);
require_once Dispatcher::dispatch();
require_once 'src/Template.php';
 public function postLoad()
 {
     $job = Input::get('job');
     $level = Input::get('level');
     $craftable_only = Input::get('craftable_only');
     $rewardable_too = Input::get('rewardable_too');
     // All Jobs
     $job_list = ClassJob::get_name_abbr_list();
     // Jobs are capital
     $desired_job = strtoupper($job);
     $job = ClassJob::get_by_abbr($desired_job);
     // What stats do the class like?
     $stat_ids_to_focus = Stat::get_ids(Stat::focus($job->abbr->term));
     View::share('job_list', $job_list);
     View::share('job', $job);
     View::share('stat_ids_to_focus', $stat_ids_to_focus);
     View::share('level', $level);
     $equipment = Item::calculate($job->id, $level, 0, $craftable_only, $rewardable_too);
     exit(json_encode($this->getOutput($equipment)));
 }
Esempio n. 18
0
                switch ($params["type"]) {
                    case "comp_champ":
                        $val = Stat::getItems($_GET["itemtype"], $params["date1"], $params["date2"], $params["dropdown"]);
                        Stat::showTable($_GET["itemtype"], $params["type"], $params["date1"], $params["date2"], $params["start"], $val, $params["dropdown"]);
                        break;
                    case "device":
                        $val = Stat::getItems($_GET["itemtype"], $params["date1"], $params["date2"], $params["dropdown"]);
                        Stat::showTable($_GET["itemtype"], $params["type"], $params["date1"], $params["date2"], $params["start"], $val, $params["dropdown"]);
                        break;
                    default:
                        $val2 = isset($params['value2']) ? $params['value2'] : 0;
                        $val = Stat::getItems($_GET["itemtype"], $params["date1"], $params["date2"], $params["type"], $val2);
                        Stat::showTable($_GET["itemtype"], $params["type"], $params["date1"], $params["date2"], $params["start"], $val, $val2);
                }
            } else {
                if (isset($_GET["type"]) && $_GET["type"] == "hardwares") {
                    Stat::showItems("", $_GET["date1"], $_GET["date2"], $_GET['start']);
                }
            }
            break;
        default:
            // Plugin case
            if ($plug = isPluginItemType($_GET["item_type"])) {
                if (Plugin::doOneHook($plug['plugin'], 'dynamicReport', $_GET)) {
                    exit;
                }
            }
            $params = Search::manageParams($_GET["item_type"], $_GET);
            Search::showList($_GET["item_type"], $params);
    }
}
Esempio n. 19
0
    }
    if (isset($data['solved']) && is_array($data['solved'])) {
        foreach ($data['solved'] as $key => $val) {
            $newkey = html_clean($key);
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array($LANG['stats'][11] => $cleandata), array('title' => $LANG['stats'][11], 'showtotal' => 1, 'unit' => $LANG['stats'][35], 'type' => 'pie'));
    }
    if (isset($data['late']) && is_array($data['late'])) {
        foreach ($data['late'] as $key => $val) {
            $newkey = html_clean($key);
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array($LANG['stats'][19] => $cleandata), array('title' => $LANG['stats'][19], 'showtotal' => 1, 'unit' => $LANG['stats'][35], 'type' => 'pie'));
    }
    if (isset($data['closed']) && is_array($data['closed'])) {
        foreach ($data['closed'] as $key => $val) {
            $newkey = html_clean($key);
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array($LANG['stats'][11] => $cleandata), array('title' => $LANG['stats'][17], 'showtotal' => 1, 'unit' => $LANG['stats'][35], 'type' => 'pie'));
    }
    if (isset($data['opensatisfaction']) && is_array($data['opensatisfaction'])) {
        foreach ($data['opensatisfaction'] as $key => $val) {
            $newkey = html_clean($key);
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array($LANG['stats'][11] => $cleandata), array('title' => $LANG['satisfaction'][3], 'showtotal' => 1, 'unit' => $LANG['stats'][35], 'type' => 'pie'));
    }
}
commonFooter();
Esempio n. 20
0
/** Display an infocom report
 *
 * @param $itemtype  item type
 * @param $begin     begin date
 * @param $end       end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
    global $DB, $valeurtot, $valeurnettetot, $valeurnettegraphtot, $valeurgraphtot, $CFG_GLPI;
    $itemtable = getTableForItemType($itemtype);
    $query = "SELECT `glpi_infocoms`.*,\n                    `{$itemtable}`.`name` AS name,\n                    `{$itemtable}`.`ticket_tco`,\n                    `glpi_entities`.`completename` AS entname,\n                    `glpi_entities`.`id` AS entID\n             FROM `glpi_infocoms`\n             INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`\n                                         AND `glpi_infocoms`.`itemtype` = '{$itemtype}')\n             LEFT JOIN `glpi_entities` ON (`{$itemtable}`.`entities_id` = `glpi_entities`.`id`)\n             WHERE `{$itemtable}`.`is_template` = '0' " . getEntitiesRestrictRequest("AND", $itemtable);
    if (!empty($begin)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` >= '{$begin}'\n                       OR `glpi_infocoms`.`use_date` >= '{$begin}') ";
    }
    if (!empty($end)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` <= '{$end}'\n                       OR `glpi_infocoms`.`use_date` <= '{$end}') ";
    }
    $query .= " ORDER BY entname ASC, `buy_date`, `use_date`";
    $display_entity = Session::isMultiEntitiesMode();
    $result = $DB->query($query);
    if ($DB->numrows($result) > 0 && ($item = getItemForItemtype($itemtype))) {
        echo "<h2>" . $item->getTypeName(1) . "</h2>";
        echo "<table class='tab_cadre'><tr><th>" . __('Name') . "</th>";
        if ($display_entity) {
            echo "<th>" . __('Entity') . "</th>";
        }
        echo "<th>" . _x('price', 'Value') . "</th><th>" . __('ANV') . "</th>";
        echo "<th>" . __('TCO') . "</th><th>" . __('Date of purchase') . "</th>";
        echo "<th>" . __('Startup date') . "</th><th>" . __('Warranty expiration date') . "</th></tr>";
        $valeursoustot = 0;
        $valeurnettesoustot = 0;
        $valeurnettegraph = array();
        $valeurgraph = array();
        while ($line = $DB->fetch_assoc($result)) {
            if (isset($line["is_global"]) && $line["is_global"] && $item->getFromDB($line["items_id"])) {
                $line["value"] *= Computer_Item::countForItem($item);
            }
            if ($line["value"] > 0) {
                $valeursoustot += $line["value"];
            }
            $valeurnette = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "n");
            $tmp = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "all");
            if (is_array($tmp) && count($tmp) > 0) {
                foreach ($tmp["annee"] as $key => $val) {
                    if ($tmp["vcnetfin"][$key] > 0) {
                        if (!isset($valeurnettegraph[$val])) {
                            $valeurnettegraph[$val] = 0;
                        }
                        $valeurnettegraph[$val] += $tmp["vcnetdeb"][$key];
                    }
                }
            }
            if (!empty($line["buy_date"])) {
                $year = substr($line["buy_date"], 0, 4);
                if ($line["value"] > 0) {
                    if (!isset($valeurgraph[$year])) {
                        $valeurgraph[$year] = 0;
                    }
                    $valeurgraph[$year] += $line["value"];
                }
            }
            $valeurnettesoustot += str_replace(" ", "", $valeurnette);
            echo "<tr class='tab_bg_1'><td>" . $line["name"] . "</td>";
            if ($display_entity) {
                echo "<td>" . $line['entname'] . "</td>";
            }
            echo "<td class='right'>" . Html::formatNumber($line["value"]) . "</td>" . "<td class='right'>" . Html::formatNumber($valeurnette) . "</td>" . "<td class='right'>" . Infocom::showTco($line["ticket_tco"], $line["value"]) . "</td>" . "<td>" . Html::convDate($line["buy_date"]) . "</td>" . "<td>" . Html::convDate($line["use_date"]) . "</td>" . "<td>" . Infocom::getWarrantyExpir($line["buy_date"], $line["warranty_duration"]) . "</td></tr>";
        }
        $valeurtot += $valeursoustot;
        $valeurnettetot += $valeurnettesoustot;
        $tmpmsg = sprintf(__('Total: Value=%1$s - Account net value=%2$s'), Html::formatNumber($valeursoustot), Html::formatNumber($valeurnettesoustot));
        echo "<tr><td colspan='6' class='center'><h3>{$tmpmsg}</h3></td></tr>";
        if (count($valeurnettegraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurnettegraph);
            $valeurnettegraphdisplay = array_map('round', $valeurnettegraph);
            foreach ($valeurnettegraph as $key => $val) {
                if (!isset($valeurnettegraphtot[$key])) {
                    $valeurnettegraphtot[$key] = 0;
                }
                $valeurnettegraphtot[$key] += $valeurnettegraph[$key];
            }
            Stat::showGraph(array(__('Account net value') => $valeurnettegraphdisplay), array('title' => __('Account net value'), 'width' => 400));
            echo "</td></tr>";
        }
        if (count($valeurgraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurgraph);
            $valeurgraphdisplay = array_map('round', $valeurgraph);
            foreach ($valeurgraph as $key => $val) {
                if (!isset($valeurgraphtot[$key])) {
                    $valeurgraphtot[$key] = 0;
                }
                $valeurgraphtot[$key] += $valeurgraph[$key];
            }
            Stat::showGraph(array(_x('price', 'Value') => $valeurgraphdisplay), array('title' => _x('price', 'Value'), 'width' => 400));
            echo "</td></tr>";
        }
        echo "</table>";
        return true;
    }
    return false;
}
Esempio n. 21
0
<?php

ini_set('display_errors', "On");
error_reporting(E_ALL | E_STRICT);
//自动加载类
set_include_path(get_include_path() . PATH_SEPARATOR . 'class/');
//设置加载路径
spl_autoload_extensions('.php');
//设置加载后缀名
function myAutoload($className)
{
    require_once $className . '.php';
    //直接根据类名跟文件关系包含文件
}
spl_autoload_register("myAutoload");
//注册自动加载函数
//测试代码开始
echo Stat::getInstance()->sayHi();
echo '<br>';
echo Teacher::getInstance()->sayHi();
echo '<br>';
class People
{
    function sayHi()
    {
        return 'Hello i am a people?';
    }
}
echo Singleton::getInstance('People')->sayHi();
echo '<hr>';
echo file_get_contents('./read.txt');
	<?php 
if (Auth::check()) {
    // If it is a user do nothing
    $hid = 0;
} else {
    $hit = new Stat();
    $hit->hit = 1;
    $hit->vid = $id;
    $hit->lp_id = $lp_id;
    $hit->save();
    $hid = $hit->id;
}
$asmp = '';
$asf = '';
$bseb = '';
$asra = '';
$bsave = '';
$bsgpd = '';
$bsdf = '';
$bsebo = '';
if (!$slug) {
    $slug == '';
}
switch ($slug) {
    case 'mp':
    case 'mp-mobile':
        $asmp = 'selected';
        break;
    case 'film':
    case 'film-mobile':
        $asf = 'selected';
Esempio n. 23
0
    $errors = array();
    /*
    Contrôle des champs obligatoire
    
    if(empty($_POST['refchangement'])){
    	$errors['refchangement']="Vous devez remplir le champ reférencement changement!";
    }
    */
    if (empty($errors)) {
        $listeCheck = '';
        for ($i = 0; $i < count($STATGEOL); $i++) {
            if (isset($_POST['stat_zonegeo_' . $i])) {
                $listeCheck .= $i . ',';
            }
        }
        $stat = new Stat();
        $stat->SetParam(NULL, $idIncident, $_POST['refchangement'], $_POST['stat_publicationIR'], $_POST['stat_publicationPM'], $_POST['stat_typecause'], $_POST['stat_typecause_second'], $_POST['stat_typologiegts'], $_POST['stat_equipeResp'], $_POST['fournisseurResp'], $_POST['statPowerprod'], $_POST['statLegacy'], $_POST['stat_Composant'], $_POST['Composant_complement'], $listeCheck);
        $idStat = $stat->Creer();
        $_SESSION['flash']['success'] = "Le stat est Bien Ajouté !";
        header('Location:modifStat.php?idStat=' . $idStat . '&idIncident=' . $idIncident);
    }
}
$incident = new incidents();
$incident->_setUser($userConnected);
$incident->chargerIncident($idIncident);
$impacte = new Impact();
$impacte->chargerFirstIncident($idIncident);
$application = new Application();
$application->SelectAppliById($impacte->getApplicationId());
require_once '../inc/header.inc.php';
?>
Esempio n. 24
0
        foreach ($data['solved'] as $key => $val) {
            $newkey = Toolbox::unclean_cross_side_scripting_deep(Html::clean($key));
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array(__('Number solved') => $cleandata), array('title' => __('Number solved'), 'showtotal' => 1, 'unit' => $item->getTypeName(Session::getPluralNumber()), 'type' => 'pie'));
    }
    if (isset($data['late']) && is_array($data['late'])) {
        foreach ($data['late'] as $key => $val) {
            $newkey = Toolbox::unclean_cross_side_scripting_deep(Html::clean($key));
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array(__('Number solved late') => $cleandata), array('title' => __('Number solved late'), 'showtotal' => 1, 'unit' => $item->getTypeName(Session::getPluralNumber()), 'type' => 'pie'));
    }
    if (isset($data['closed']) && is_array($data['closed'])) {
        foreach ($data['closed'] as $key => $val) {
            $newkey = Toolbox::unclean_cross_side_scripting_deep(Html::clean($key));
            $cleandata[$newkey] = $val;
        }
        Stat::showGraph(array(__('Number closed') => $cleandata), array('title' => __('Number closed'), 'showtotal' => 1, 'unit' => $item->getTypeName(Session::getPluralNumber()), 'type' => 'pie'));
    }
    if ($_GET['itemtype'] == 'Ticket') {
        if (isset($data['opensatisfaction']) && is_array($data['opensatisfaction'])) {
            foreach ($data['opensatisfaction'] as $key => $val) {
                $newkey = Toolbox::unclean_cross_side_scripting_deep(Html::clean($key));
                $cleandata[$newkey] = $val;
            }
            Stat::showGraph(array(__('Satisfaction survey') => $cleandata), array('title' => __('Satisfaction survey'), 'showtotal' => 1, 'unit' => $item->getTypeName(Session::getPluralNumber()), 'type' => 'pie'));
        }
    }
}
Html::footer();
Esempio n. 25
0
 public function __destruct()
 {
     Stat::getInstance();
     new Error();
 }
Esempio n. 26
0
File: app.php Progetto: Camolot/dnd
    $_SESSION['class'] = $_POST['class_id'];
    return $app['twig']->render('background.html.twig', array('backgrounds' => Background::getAll()));
});
//background page
//carry race id, class id, background id to stats page
$app->post('/stats', function () use($app) {
    $_SESSION['background'] = $_POST['background_id'];
    $race_id = $_SESSION['race'];
    $race_find = Race::find($race_id);
    $race = getName($race_find);
    $class_id = $_SESSION['class'];
    $class_find = CharClass::find($class_id);
    $classname = getName($class_find);
    $stats = statRoll();
    $assigned_stats = assignRolls($six_rolls, $classname, $race);
    return $app['twig']->render('stats.html.twig', array('stat' => Stat::getAll()));
});
//stats page
//carry race id, class id, background id, stats id to skills page
$app->post('/bio', function () use($app) {
    $_SESSION['str'] = $_POST['str_id'];
    $_SESSION['dex'] = $_POST['dex_id'];
    $_SESSION['con'] = $_POST['con_id'];
    $_SESSION['int'] = $_POST['int_id'];
    $_SESSION['wis'] = $_POST['wis_id'];
    $_SESSION['cha'] = $_POST['cha_id'];
    return $app['twig']->render('bio.html.twig');
});
//bio page
//render bio page
$app->get('/bio', function () use($app) {
    $type = "comp_champ";
    $val = Stat::getItems($itemtype, $_REQUEST["date1"], $_REQUEST["date2"], $_REQUEST["dropdown"]);
    $params = array('type' => $type, 'dropdown' => $_REQUEST["dropdown"], 'date1' => $_REQUEST["date1"], 'date2' => $_REQUEST["date2"], 'start' => $_REQUEST["start"]);
} else {
    //   echo "Device";
    $type = "device";
    $field = $_REQUEST["dropdown"];
    $val = Stat::getItems($itemtype, $_REQUEST["date1"], $_REQUEST["date2"], $_REQUEST["dropdown"]);
    $params = array('type' => $type, 'dropdown' => $_REQUEST["dropdown"], 'date1' => $_REQUEST["date1"], 'date2' => $_REQUEST["date2"], 'start' => $_REQUEST["start"]);
}
/*printPager($_REQUEST['start'],count($val),$CFG_GLPI['root_doc'].'/front/stat.location.php',
  "date1=".$_REQUEST["date1"]."&amp;date2=".$_REQUEST["date2"]."&amp;dropdown=".$_REQUEST["dropdown"],
  'Stat',$params);*/
if (!$_REQUEST['showgraph']) {
    PluginMobileStat::show($type, $_REQUEST["date1"], $_REQUEST["date2"], $_REQUEST['start'], $val, $_REQUEST["dropdown"]);
} else {
    $data = Stat::getDatas($type, $_REQUEST["date1"], $_REQUEST["date2"], $_REQUEST['start'], $val, $_REQUEST["dropdown"]);
    if (isset($data['opened']) && is_array($data['opened'])) {
        foreach ($data['opened'] as $key => $val) {
            $cleandata[html_clean($key)] = $val;
        }
        PluginMobileStat::showGraph(array($LANG['stats'][5] => $cleandata), array('title' => $LANG['stats'][5], 'showtotal' => 1, 'unit' => $LANG['stats'][35], 'type' => 'pie'));
    }
    if (isset($data['solved']) && is_array($data['solved'])) {
        foreach ($data['solved'] as $key => $val) {
            $cleandata[html_clean($key)] = $val;
        }
        PluginMobileStat::showGraph(array($LANG['stats'][11] => $cleandata), array('title' => $LANG['stats'][11], 'showtotal' => 1, 'unit' => $LANG['stats'][35], 'type' => 'pie'));
    }
}
$common->displayFooter();
Esempio n. 28
0
/** Display an infocom report
 *
 * @param $itemtype item type
 * @param $begin begin date
 * @param $end end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
    global $DB, $valeurtot, $valeurnettetot, $valeurnettegraphtot, $valeurgraphtot, $LANG, $CFG_GLPI;
    $itemtable = getTableForItemType($itemtype);
    $query = "SELECT `glpi_infocoms`.*,\n                    `{$itemtable}`.`name` AS name,\n                    `{$itemtable}`.`ticket_tco`,\n                    `glpi_entities`.`completename` AS entname,\n                    `glpi_entities`.`id` AS entID\n             FROM `glpi_infocoms`\n             INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`\n                                         AND `glpi_infocoms`.`itemtype` = '{$itemtype}')\n             LEFT JOIN `glpi_entities` ON (`{$itemtable}`.`entities_id` = `glpi_entities`.`id`)\n             WHERE `{$itemtable}`.`is_template` = '0' " . getEntitiesRestrictRequest("AND", $itemtable);
    if (!empty($begin)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` >= '{$begin}'\n                       OR `glpi_infocoms`.`use_date` >= '{$begin}') ";
    }
    if (!empty($end)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` <= '{$end}'\n                       OR `glpi_infocoms`.`use_date` <= '{$end}') ";
    }
    $query .= " ORDER BY entname ASC, `buy_date`, `use_date`";
    $display_entity = isMultiEntitiesMode();
    $result = $DB->query($query);
    if ($DB->numrows($result) > 0) {
        $item = new $itemtype();
        echo "<h2>" . $item->getTypeName() . "</h2>";
        echo "<table class='tab_cadre'><tr><th>" . $LANG['common'][16] . "</th>";
        if ($display_entity) {
            echo "<th>" . $LANG['entity'][0] . "</th>";
        }
        echo "<th>" . $LANG['financial'][21] . "</th><th>" . $LANG['financial'][92] . "</th>";
        echo "<th>" . $LANG['financial'][91] . "</th><th>" . $LANG['financial'][14] . "</th>";
        echo "<th>" . $LANG['financial'][76] . "</th><th>" . $LANG['financial'][80] . "</th></tr>";
        $valeursoustot = 0;
        $valeurnettesoustot = 0;
        $valeurnettegraph = array();
        $valeurgraph = array();
        while ($line = $DB->fetch_array($result)) {
            if (isset($line["is_global"]) && $line["is_global"]) {
                $line["value"] *= Computer_Item::countForItem($itemtype, $line["items_id"]);
            }
            if ($line["value"] > 0) {
                $valeursoustot += $line["value"];
            }
            $valeurnette = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "n");
            $tmp = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "all");
            if (is_array($tmp) && count($tmp) > 0) {
                foreach ($tmp["annee"] as $key => $val) {
                    if ($tmp["vcnetfin"][$key] > 0) {
                        if (!isset($valeurnettegraph[$val])) {
                            $valeurnettegraph[$val] = 0;
                        }
                        $valeurnettegraph[$val] += $tmp["vcnetdeb"][$key];
                    }
                }
            }
            if (!empty($line["buy_date"])) {
                $year = substr($line["buy_date"], 0, 4);
                if ($line["value"] > 0) {
                    if (!isset($valeurgraph[$year])) {
                        $valeurgraph[$year] = 0;
                    }
                    $valeurgraph[$year] += $line["value"];
                }
            }
            $valeurnettesoustot += str_replace(" ", "", $valeurnette);
            echo "<tr class='tab_bg_1'><td>" . $line["name"] . "</td>";
            if ($display_entity) {
                if ($line['entID'] == 0) {
                    echo "<td>" . $LANG['entity'][2] . "</td>";
                } else {
                    echo "<td>" . $line['entname'] . "</td>";
                }
            }
            echo "<td class='right'>" . formatNumber($line["value"]) . "</td><td class='right'>" . formatNumber($valeurnette) . "</td><td class='right'>" . Infocom::showTco($line["ticket_tco"], $line["value"]) . "</td><td>" . convDate($line["buy_date"]) . "</td><td>" . convDate($line["use_date"]) . "</td><td>" . getWarrantyExpir($line["buy_date"], $line["warranty_duration"]) . "</td></tr>";
        }
        $valeurtot += $valeursoustot;
        $valeurnettetot += $valeurnettesoustot;
        echo "<tr><td colspan='6' class='center'><h3>" . $LANG['common'][33] . "&nbsp;: " . $LANG['financial'][21] . "=" . formatNumber($valeursoustot) . " - " . $LANG['financial'][81] . "=" . formatNumber($valeurnettesoustot) . "</h3></td></tr>";
        if (count($valeurnettegraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurnettegraph);
            $valeurnettegraphdisplay = array_map('round', $valeurnettegraph);
            foreach ($valeurnettegraph as $key => $val) {
                if (!isset($valeurnettegraphtot[$key])) {
                    $valeurnettegraphtot[$key] = 0;
                }
                $valeurnettegraphtot[$key] += $valeurnettegraph[$key];
            }
            Stat::showGraph(array($LANG['financial'][81] => $valeurnettegraphdisplay), array('title' => $LANG['financial'][81], 'width' => 400));
            echo "</td></tr>";
        }
        if (count($valeurgraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurgraph);
            $valeurgraphdisplay = array_map('round', $valeurgraph);
            foreach ($valeurgraph as $key => $val) {
                if (!isset($valeurgraphtot[$key])) {
                    $valeurgraphtot[$key] = 0;
                }
                $valeurgraphtot[$key] += $valeurgraph[$key];
            }
            Stat::showGraph(array($LANG['financial'][21] => $valeurgraphdisplay), array('title' => $LANG['financial'][21], 'width' => 400));
            echo "</td></tr>";
        }
        echo "</table>";
        return true;
    }
    return false;
}
Esempio n. 29
0
 /**
  * Retrieve the list of timer ids from timer statistics object.
  *
  * Timer ids will be ordered and filtered by thresholds and filter pattern.
  *
  * @param Stat $stat
  * @return string[]
  */
 protected function _getTimerIds(Stat $stat)
 {
     return $stat->getFilteredTimerIds($this->_thresholds, $this->_filterPattern);
 }
Esempio n. 30
0
    $available = array('opensatisfaction' => _nx('survey', 'Opened', 'Opened', 2), 'answersatisfaction' => _nx('survey', 'Answered', 'Answered', 2));
    echo "<div class='center'>";
    foreach ($available as $key => $name) {
        echo "<input type='checkbox' onchange='submit()' name='graph[{$key}]' " . ($show_all || isset($_GET['graph'][$key]) ? "checked" : "") . "> " . $name . "&nbsp;";
    }
    echo "</div>";
    $toprint = array();
    foreach ($available as $key => $name) {
        if ($show_all || isset($_GET['graph'][$key])) {
            $toprint[$name] = $values[$key];
        }
    }
    Stat::showGraph($toprint, array('title' => __('Satisfaction survey'), 'showtotal' => 1, 'unit' => __('Tickets')));
    $values['avgsatisfaction'] = Stat::constructEntryValues($_GET['itemtype'], "inter_avgsatisfaction", $_GET["date1"], $_GET["date2"]);
    $available = array('avgsatisfaction' => __('Satisfaction'));
    echo "<div class='center'>";
    foreach ($available as $key => $name) {
        echo "<input type='checkbox' onchange='submit()' name='graph[{$key}]' " . ($show_all || isset($_GET['graph'][$key]) ? "checked" : "") . "> " . $name . "&nbsp;";
    }
    echo "</div>";
    $toprint = array();
    foreach ($available as $key => $name) {
        if ($show_all || isset($_GET['graph'][$key])) {
            $toprint[$name] = $values[$key];
        }
    }
    Stat::showGraph($toprint, array('title' => __('Satisfaction')));
}
// form using GET method : CRSF not needed
echo "</form>";
Html::footer();