Example #1
0
 public function execute()
 {
     if (Tools::isConnectedUser()) {
         header("Content-type: image/png");
         $height = Tools::getSecureGETIntValue('height');
         $width = Tools::getSecureGETIntValue('width');
         $color = Tools::getSecureGETStringValue('color');
         $strike = isset($_GET['strike']) ? TRUE : FALSE;
         // barrer le texte
         $text = isset($_GET['text']) ? $_GET['text'] : NULL;
         // image color
         $img = self::createGradiantImage($width, $height, $color);
         if ($strike) {
             self::createStrikeImage($img, $width, $height);
         }
         if ($text) {
             self::createText($img, $width, $height, $text);
         }
         imagepng($img);
         imagedestroy($img);
     } else {
         Tools::sendUnauthorizedAccess();
     }
 }
        // TODO do not log exception if date = 01-01-1970
        $startTimestamp = Tools::date2timestamp(Tools::getSecureGETStringValue("loadPerUser_startdate"));
        $endTimestamp = Tools::date2timestamp(Tools::getSecureGETStringValue("loadPerUser_enddate"));
        $attributesJsonStr = Tools::getSecureGETStringValue('attributesJsonStr');
        $attributesArray = json_decode(stripslashes($attributesJsonStr), true);
        $showSidetasks = 'on' != $attributesArray[LoadPerUserIndicator::OPTION_SHOW_SIDETASKS] ? false : true;
        //$logger->error("showSidetasks = ".var_export($showSidetasks, true).' attr '.$attributesArray[LoadPerUserIndicator::OPTION_SHOW_SIDETASKS]);
        // update dataProvider
        $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp);
        $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp);
        $indicator = new LoadPerUserIndicator($pluginDataProvider);
        // override plugin settings with current attributes
        $indicator->setPluginSettings(array(LoadPerUserIndicator::OPTION_SHOW_SIDETASKS => $showSidetasks));
        $indicator->execute();
        $data = $indicator->getSmartyVariablesForAjax();
        // construct the html table
        foreach ($data as $smartyKey => $smartyVariable) {
            $smartyHelper->assign($smartyKey, $smartyVariable);
            #$logger->debug("key $smartyKey = ".var_export($smartyVariable, true));
        }
        $html = $smartyHelper->fetch(LoadPerUserIndicator::getSmartySubFilename());
        $data['loadPerUser_htmlContent'] = $html;
        // return html & chart data
        $jsonData = json_encode($data);
        echo $jsonData;
    } else {
        Tools::sendNotFoundAccess();
    }
} else {
    Tools::sendUnauthorizedAccess();
}