protected function parseTimeAsRatio($time) { if (substr($time, -1) === '%') { return substr($time, 0, strlen($time) - 1) / 100; } return Max(Min((double) $time, 1), 0); }
public function Max() { list($xmax) = $this->plots[0]->Max(); $nmax = 0; $n = count($this->plots); for ($i = 0; $i < $n; ++$i) { $nc = count($this->plots[$i]->coords[0]); $nmax = max($nmax, $nc); list($x) = $this->plots[$i]->Max(); $xmax = Max($xmax, $x); } for ($i = 0; $i < $nmax; $i++) { // Get y-value for line $i by adding the // individual bars from all the plots added. // It would be wrong to just add the // individual plots max y-value since that // would in most cases give to large y-value. $y = $this->plots[0]->coords[0][$i]; for ($j = 1; $j < $this->nbrplots; $j++) { $y += $this->plots[$j]->coords[0][$i]; } $ymax[$i] = $y; } $ymax = max($ymax); return array($xmax, $ymax); }
public function execute(SpecificationInterface $spec, MediaInterface $source, $dest) { if (!$spec instanceof Animation) { throw new SpecNotSupportedException('Imagine Adapter only supports Image specs'); } if ($source->getType() !== MediaInterface::TYPE_VIDEO) { throw new SpecNotSupportedException('Imagine Adapter only supports Images'); } try { $movie = $this->container['ffmpeg.ffmpeg']->open($source->getFile()->getPathname()); $duration = $source->getDuration(); $time = $pas = Max(1, $duration / 11); $files = array(); while (ceil($time) < floor($duration)) { $files[] = $tmpFile = $this->tmpFileManager->createTemporaryFile(self::TMP_FILE_SCOPE, 'ffmpeg', 'jpg'); $frame = $movie->frame(TimeCode::fromSeconds($time)); $frame->filters()->fixDisplayRatio(); $frame->save($tmpFile); $time += $pas; } foreach ($files as $file) { $image = $this->container['imagine']->open($file); if ($spec->getWidth() && $spec->getHeight()) { $box = $this->boxFromSize($spec, $image->getSize()->getWidth(), $image->getSize()->getHeight()); if ($spec->getResizeMode() == Animation::RESIZE_MODE_OUTBOUND) { /* @var $image \Imagine\Gmagick\Image */ $image = $image->thumbnail($box, ImageInterface::THUMBNAIL_OUTBOUND); } else { $image = $image->resize($box); } } $image->save($file, array('quality' => $spec->getQuality(), 'resolution-units' => $spec->getResolutionUnit(), 'resolution-x' => $spec->getResolutionX(), 'resolution-y' => $spec->getResolutionY())); unset($image); } $image = $this->container['imagine']->open(array_shift($files)); foreach ($files as $file) { $image->layers()->add($this->container['imagine']->open($file)); } $image->save($dest, array('animated' => true, 'animated.delay' => 800, 'animated.loops' => 0)); $this->tmpFileManager->clean(self::TMP_FILE_SCOPE); } catch (FFMpegException $e) { $this->tmpFileManager->clean(self::TMP_FILE_SCOPE); throw new RuntimeException('Unable to transmute video to animation due to FFMpeg', null, $e); } catch (ImagineException $e) { $this->tmpFileManager->clean(self::TMP_FILE_SCOPE); throw new RuntimeException('Unable to transmute video to animation due to Imagine', null, $e); } catch (RuntimeException $e) { $this->tmpFileManager->clean(self::TMP_FILE_SCOPE); throw $e; } return $this; }
} #------------------------------------------------------------------------------- #-------------------------TRANSACTION------------------------------------------- if (Is_Error(DB_Transaction($TransactionID = UniqID('DomainTransfer')))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OrderID = DB_Insert('Orders', array('ContractID' => $Contract['ID'], 'ServiceID' => 20000, 'IsPayed' => TRUE, 'ServerID' => $DomainScheme['ServerID'])); if (Is_Error($OrderID)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $IDomainOrder = array('OrderID' => $OrderID, 'DomainName' => Mb_StrToLower($DomainName, 'UTF-8'), 'SchemeID' => $DomainScheme['ID'], 'PersonID' => $PersonID, 'WhoIs' => $WhoIs['Info'], 'AuthInfo' => $AuthInfo ? $AuthInfo : NULL, 'UpdateDate' => Time()); #------------------------------------------------------------------------------- $IDomainOrder['ExpirationDate'] = Max($WhoIs['ExpirationDate'], Time()); #------------------------------------------------------------------------------- $Domain = SPrintF('%s.%s', $DomainName, $DomainScheme['Name']); #------------------------------------------------------------------------------- for ($i = 1; $i < 5; $i++) { #------------------------------------------------------------------------------- $NsName = isset($WhoIs[SPrintF('Ns%uName', $i)]) ? $WhoIs[SPrintF('Ns%uName', $i)] : ''; #------------------------------------------------------------------------------- $IDomainOrder[SPrintF('Ns%uName', $i)] = $NsName; #------------------------------------------------------------------------------- $NsIP = isset($WhoIs[SPrintF('Ns%uIP', $i)]) ? $WhoIs[SPrintF('Ns%uIP', $i)] : ''; #------------------------------------------------------------------------------- $IDomainOrder[SPrintF('Ns%uIP', $i)] = $NsIP; #------------------------------------------------------------------------------- } #-------------------------------------------------------------------------------
function GetXMinMax() { list($min, $ymin) = $this->plots[0]->Min(); list($max, $ymax) = $this->plots[0]->Max(); $i = 0; // Some plots, e.g. PlotLine should not affect the scale // and will return (null,null). We should ignore those // values. while (($min === null || $max === null) && $i < count($this->plots) - 1) { ++$i; list($min, $ymin) = $this->plots[$i]->Min(); list($max, $ymax) = $this->plots[$i]->Max(); } foreach ($this->plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); if ($xmin !== null && $xmax !== null) { $min = Min($xmin, $min); $max = Max($xmax, $max); } } if ($this->y2axis != null) { foreach ($this->y2plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { if ($this->ynaxis[$i] != null) { foreach ($this->ynplots[$i] as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } } return array($min, $max); }
function Max() { return Max($this->data); }
#--------------------------------------------------------------------- $Comp = Comp_Load('Invoices/Build', $InvoiceID); if (Is_Error($Comp)) { return ERROR | @Trigger_Error(500); } } #----------------------------------------------------------------------- if (isset($Contract['HostingOrders'])) { #--------------------------------------------------------------------- $HostingOrders = $Contract['HostingOrders']; #--------------------------------------------------------------------- $HostingOrders = Is_Array($HostingOrders) ? $HostingOrders : array(); #--------------------------------------------------------------------- foreach ($HostingOrders as $HostingOrder) { #------------------------------------------------------------------- $DaysRemainded = Max(0, (int) $HostingOrder['DaysRemainded']); #------------------------------------------------------------------- $IHostingOrder = array('Login' => $HostingOrder['Login'], 'Password' => $HostingOrder['Password'], 'Domain' => $HostingOrder['Domain'], 'StatusID' => $DaysRemainded ? 'Active' : 'Suspended', 'StatusDate' => GetTime($HostingOrder['OrderDate'])); #------------------------------------------------------------------- $HostingScheme = $HostingOrder['HostingScheme']; #------------------------------------------------------------------- $HostingScheme = Is_Array($HostingScheme) ? $HostingScheme : array(); #------------------------------------------------------------------- $dHostingScheme = DB_Select('HostingSchemes', array('ID', 'ServersGroupID', 'CostDay'), array('Where' => SPrintF("`Name` = '%s'", $HostingScheme['Name']))); #------------------------------------------------------------------- switch (ValueOf($dHostingScheme)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': #--------------------------------------------------------------- $CostDay = $HostingScheme['CostDay'];
function print_inventory_planning() { global $path_to_root; $category = $_POST['PARAM_0']; $location = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($location == ALL_TEXT) { $location = 'all'; } if ($location == 'all') { $loc = _('All'); } else { $loc = get_location_name($location); } $cols = array(0, 50, 150, 180, 210, 240, 270, 300, 330, 390, 435, 480, 525); $per0 = strftime('%b', mktime(0, 0, 0, date('m'), 1, date('Y'))); $per1 = strftime('%b', mktime(0, 0, 0, date('m') - 1, 1, date('Y'))); $per2 = strftime('%b', mktime(0, 0, 0, date('m') - 2, 1, date('Y'))); $per3 = strftime('%b', mktime(0, 0, 0, date('m') - 3, 1, date('Y'))); $per4 = strftime('%b', mktime(0, 0, 0, date('m') - 4, 1, date('Y'))); $headers = array(_('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', _('QOH'), _('Cust Ord'), _('Supp Ord'), _('Sugg Ord')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => _('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(_('Inventory Planning Report'), "InventoryPlanning", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($category, $location); $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } if ($location == 'all') { $loc_code = ""; } else { $loc_code = $location; } $custqty = get_demand_qty($trans['stock_id'], $loc_code); $custqty += get_demand_asm_qty($trans['stock_id'], $loc_code); $suppqty = get_on_porder_qty($trans['stock_id'], $loc_code); $suppqty += get_on_worder_qty($trans['stock_id'], $loc_code); $period = getPeriods($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $dec = get_qty_dec($trans['stock_id']); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1); $rep->AmountCol(2, 3, $period['prd0'], $dec); $rep->AmountCol(3, 4, $period['prd1'], $dec); $rep->AmountCol(4, 5, $period['prd2'], $dec); $rep->AmountCol(5, 6, $period['prd3'], $dec); $rep->AmountCol(6, 7, $period['prd4'], $dec); $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']); $IdealStockHolding = $MaxMthSales * 3; $rep->AmountCol(7, 8, $IdealStockHolding, $dec); $rep->AmountCol(8, 9, $trans['qty_on_hand'], $dec); $rep->AmountCol(9, 10, $custqty, $dec); $rep->AmountCol(10, 11, $suppqty, $dec); $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty; if ($SuggestedTopUpOrder < 0.0) { $SuggestedTopUpOrder = 0.0; } $rep->AmountCol(11, 12, $SuggestedTopUpOrder, $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Tr->AddChild(new Tag('TD', array('align' => 'right'), $Div)); #------------------------------------------------------------------------------- $Table[] = new Tag('TABLE', array('width' => '100%'), $Tr); #------------------------------------------------------------------------------- $Comp = Comp_Load('Tables/Standard', $Table); if (Is_Error($Comp)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $Iframe = new Tag('IFRAME', array('id' => 'TicketReadMessages', 'src' => SPrintF('/TicketMessages?TicketID=%u', $Ticket['ID']), 'width' => '100%', 'style' => SPrintF('height:%u;', Max(@$_COOKIE['hScreen'] / 2.5, 240))), 'Загрузка...'); #------------------------------------------------------------------------------- $Form->AddChild(new Tag('TABLE', new Tag('TR', new Tag('TD', $Iframe)), new Tag('TR', new Tag('TD', $Comp)))); #------------------------------------------------------------------------------- $DOM->AddChild('Into', $Form); #------------------------------------------------------------------------------- if (Is_Error($DOM->Build(FALSE))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- return array('Status' => 'Ok', 'DOM' => $DOM->Object); #------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
<?php if (!(list($Countries, $Rank, $CountryUsers, $CountryMax, $CountryMin, $LogIncrements) = $Cache->get_value('geodistribution'))) { include_once SERVER_ROOT . '/classes/charts.class.php'; $DB->query(' SELECT Code, Users FROM users_geodistribution'); $Data = $DB->to_array(); $Count = $DB->record_count() - 1; if ($Count < 30) { $CountryMinThreshold = $Count; } else { $CountryMinThreshold = 30; } $CountryMax = ceil(log(Max(1, $Data[0][1])) / log(2)) + 1; $CountryMin = floor(log(Max(1, $Data[$CountryMinThreshold][1])) / log(2)); $CountryRegions = array('RS' => array('RS-KM')); // Count Kosovo as Serbia as it doesn't have a TLD foreach ($Data as $Key => $Item) { list($Country, $UserCount) = $Item; $Countries[] = $Country; $CountryUsers[] = number_format((log($UserCount) / log(2) - $CountryMin) / ($CountryMax - $CountryMin) * 100, 2); $Rank[] = round((1 - $Key / $Count) * 100); if (isset($CountryRegions[$Country])) { foreach ($CountryRegions[$Country] as $Region) { $Countries[] = $Region; $Rank[] = end($Rank); } } } reset($Rank);
function Stroke($aStrokeFileName = "") { // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // We need to know if we have stroked the plot in the // GetCSIMareas. Otherwise the CSIM hasn't been generated // and in the case of GetCSIM called before stroke to generate // CSIM without storing an image to disk GetCSIM must call Stroke. $this->iHasStroked = true; // Do any pre-stroke adjustment that is needed by the different plot types // (i.e bar plots want's to add an offset to the x-labels etc) for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->PreStrokeAdjust($this); $this->plots[$i]->Legend($this); } // Any plots on the second Y scale? if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->PreStrokeAdjust($this); $this->y2plots[$i]->Legend($this); } } // Bail out if any of the Y-axis not been specified and // has no plots. (This means it is impossible to do autoscaling and // no other scale was given so we can't possible draw anything). If you use manual // scaling you also have to supply the tick steps as well. if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) { $e = "Can't draw unspecified Y-scale.<br>\nYou have either:<br>\n"; $e .= "1. Specified an Y axis for autoscaling but have not supplied any plots<br>\n"; $e .= "2. Specified a scale manually but have forgot to specify the tick steps"; JpGraphError::Raise($e); } // Bail out if no plots and no specified X-scale if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) { JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>"); } //Check if we should autoscale y-axis if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->plots); $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->yscale->IsSpecified() && $this->yscale->auto_ticks) { // If the user has specified a min/max value for the scale we still use the // autoscaling to get a suitable tick distance. This might adjust the specified // min max values so they end up on a tick mark. $min = $this->yscale->scale[0]; $max = $this->yscale->scale[1]; $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } if ($this->y2scale != null) { if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->y2plots); $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->y2scale->IsSpecified() && $this->y2scale->auto_ticks) { // If the user has specified a min/max value for the scale we still use the // autoscaling to get a suitable tick distance. This might adjust the specified // min max values so they end up on a tick mark. $min = $this->y2scale->scale[0]; $max = $this->y2scale->scale[1]; $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } } //Check if we should autoscale x-axis if (!$this->xscale->IsSpecified()) { if (substr($this->axtype, 0, 4) == "text") { $max = 0; foreach ($this->plots as $p) { $max = max($max, $p->numpoints - 1); } $min = 0; if ($this->y2axis != null) { foreach ($this->y2plots as $p) { $max = max($max, $p->numpoints - 1); } } $this->xscale->Update($this->img, $min, $max); $this->xscale->ticks->Set($this->xaxis->tick_step, 1); $this->xscale->ticks->SupressMinorTickMarks(); } else { list($min, $ymin) = $this->plots[0]->Min(); list($max, $ymax) = $this->plots[0]->Max(); foreach ($this->plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } if ($this->y2axis != null) { foreach ($this->y2plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor); } //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale if (!is_numeric($this->yaxis->pos) && !is_string($this->yaxis->pos)) { $this->yaxis->SetPos($this->xscale->GetMinVal()); } if ($this->y2axis != null) { if (!is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos)) { $this->y2axis->SetPos($this->xscale->GetMaxVal()); } $this->y2axis->SetTitleSide(SIDE_RIGHT); } } // If we have a negative values and x-axis position is at 0 // we need to supress the first and possible the last tick since // they will be drawn on top of the y-axis (and possible y2 axis) // The test below might seem strange the reasone being that if // the user hasn't specified a value for position this will not // be set until we do the stroke for the axis so as of now it // is undefined. // For X-text scale we ignore all this since the tick are usually // much further in and not close to the Y-axis. Hence the test // for 'text' if (($this->yaxis->pos == $this->xscale->GetMinVal() || is_string($this->yaxis->pos) && $this->yaxis->pos == 'min') && !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && substr($this->axtype, 0, 4) != 'text' && $this->xaxis->pos != "min") { //$this->yscale->ticks->SupressZeroLabel(false); $this->xscale->ticks->SupressFirst(); if ($this->y2axis != null) { $this->xscale->ticks->SupressLast(); } } elseif (!is_numeric($this->yaxis->pos) && $this->yaxis->pos == 'max') { $this->xscale->ticks->SupressLast(); } if (!$_csim) { $this->StrokePlotArea(); $this->StrokeAxis(); } // Stroke bands if ($this->bands != null && !$_csim) { for ($i = 0; $i < count($this->bands); ++$i) { // Stroke all bands that asks to be in the background if ($this->bands[$i]->depth == DEPTH_BACK) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } if ($this->grid_depth == DEPTH_BACK && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke Y2-axis if ($this->y2axis != null && !$_csim) { $this->y2axis->Stroke($this->xscale); $this->y2grid->Stroke(); } $oldoff = $this->xscale->off; if (substr($this->axtype, 0, 4) == "text") { $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step); } // Stroke all plots for Y1 axis for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } // Stroke all plots for Y2 axis if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } $this->xscale->off = $oldoff; if ($this->grid_depth == DEPTH_FRONT && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke bands if ($this->bands != null) { for ($i = 0; $i < count($this->bands); ++$i) { // Stroke all bands that asks to be in the foreground if ($this->bands[$i]->depth == DEPTH_FRONT) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } // Stroke any lines added if ($this->lines != null) { for ($i = 0; $i < count($this->lines); ++$i) { $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } // Finally draw the axis again since some plots may have nagged // the axis in the edges. if (!$_csim) { $this->StrokeAxis(); } if ($this->y2scale != null && !$_csim) { $this->y2axis->Stroke($this->xscale); } if (!$_csim) { $this->StrokePlotBox(); $this->footer->Stroke($this->img); } if (!$_csim) { // The titles and legends never gets rotated so make sure // that the angle is 0 before stroking them $aa = $this->img->SetAngle(0); $this->StrokeTitles(); } $this->legend->Stroke($this->img); if (!$_csim) { $this->StrokeTexts(); $this->img->SetAngle($aa); // Draw an outline around the image map if (JPG_DEBUG) { $this->DisplayClientSideaImageMapAreas(); } // Adjust the appearance of the image $this->AdjustSaturationBrightnessContrast(); // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
$Count = DB_Count($TableID, array('Where' => $Where, 'GroupBy' => $Query['GroupBy'])); if (Is_Error($Count)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $Source['Count'] = $Count; //print_r($Count); //die(); #------------------------------------------------------------------------------- $Request = array('Where' => $Where, 'SortOn' => $Query['SortOn'], 'IsDesc' => $Query['IsDesc'], 'GroupBy' => $Query['GroupBy']); #------------------------------------------------------------------------------- $InPage = $Template['Query']['InPage']; #------------------------------------------------------------------------------- $Index =& $Query['Index']; #------------------------------------------------------------------------------- $Index = Min(Max(0, $Index), (int) (($Count > $InPage ? $Count : 0) / $InPage)); #------------------------------------------------------------------------------- $Request['Limits'] = array('Start' => $Index * $InPage, 'Length' => $InPage); #------------------------------------------------------------------------------- $ColumnsIDs = $Source['ColumnsIDs']; #------------------------------------------------------------------------------- $Columns = $Template['Columns']; #------------------------------------------------------------------------------- foreach ($Template['Sequence'] as $ColumnID) { #----------------------------------------------------------------------------- $Column = $Columns[$ColumnID]; #----------------------------------------------------------------------------- if (isset($Column['Alias'])) { $ColumnsIDs[] = SPrintF('%s as `%s`', $Column['Alias'], $ColumnID); } }
/** * List of papers with their reviews */ private function papersReviews($view, $templateName, $html = true, $anonymized = false) { $db = Zend_Db_Table::getDefaultAdapter(); $paperTbl = new Paper(); $paperStatusTbl = new PaperStatus(); $criteriaTbl = new Criteria(); $reviewTbl = new Review(); $reviewMarkTbl = new ReviewMark(); $registry = Zend_registry::getInstance(); $config = $registry->get("Config"); $config->putInView($view); // Set the mail types $view->someUser = Mail::SOME_USER; // Extract the block for each paper $view->setBlock($templateName, "PAPER_DETAIL", "PAPERS"); $view->setBlock($templateName, "REVIEW_CRITERIA", "REVIEW_CRITERIAS"); $view->setBlock("PAPER_DETAIL", "PAPER_INFO", "PAPER_DATA"); $view->setBlock("PAPER_DETAIL", "REVIEW_MARK", "REVIEW_MARKS"); $view->setBlock("PAPER_DETAIL", "REVIEWER", "REVIEWER_INFO"); // Header of the table, taken from table Criteria $criterias = $criteriaTbl->fetchAll(); $listCriterias = array(); foreach ($criterias as $criteria) { $criteria->putInView($view); $listCriterias[] = $criteria; $view->append("REVIEW_CRITERIAS", "REVIEW_CRITERIA"); } // Sort the papers on the average 'overall' field $query = "SELECT p.*, round(AVG(overall),4) AS overall " . "FROM Paper p LEFT JOIN Review r ON p.id=r.idPaper " . " WHERE inCurrentSelection='Y' GROUP BY p.id"; $result = $db->query($query); $arrPaper = $rankPaper = array(); while ($paper = $result->fetch(Zend_Db::FETCH_OBJ)) { $arrPaper[$paper->id] = $paper; $rankPaper[$paper->id] = $paper->overall; } // Get the status list $statusList = $db->fetchPairs("SELECT * FROM PaperStatus WHERE final_status='Y'"); // Sort in descending order arsort($rankPaper); reset($rankPaper); // List the papers in order $iPaper = 0; foreach ($rankPaper as $idPaper => $overall) { $paper = $arrPaper[$idPaper]; // Choose the CSS class $view->css_class = Config::CssCLass($iPaper++); $view->paper_id = $paper->id; $view->paper_title = $paper->title; if (!$anonymized) { $view->paper_authors = PaperRow::getPaperAuthors($db, $paper); } else { $view->paper_authors = "[anonymized]"; } $view->paper_email_contact = $paper->emailContact; $view->paper_rank = $iPaper; $view->paper_overall = $overall; $view->form_status = Zmax_View_Phplib::checkboxField("radio", "status[{$paper->id}]", $statusList, $paper->status, array("length" => 2)); // Now, loop on reviews $qRev = "SELECT * FROM Review r, User u " . " WHERE idPaper='{$paper->id}' AND u.id=r.id_user"; $resRev = $db->query($qRev); $countReviews = 0; $mail_reviewers = $comma = ""; while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) { $countReviews++; $mail_reviewers .= $comma . $review->email; $comma = ", "; } $view->paper_nb_reviewers = Max(1, $countReviews); //echo "Mail reviewers = $mail_reviewers<br/>"; $view->paper_email_reviewers = $mail_reviewers; $view->append("PAPER_DATA", "PAPER_INFO"); $resRev = $db->query($qRev); $iReview = 0; while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) { $iReview++; $view->reviewer_id = $review->id; if ($anonymized == false) { $view->reviewer_fname = $review->first_name; $view->reviewer_lname = $review->last_name; $view->external_reviewer_fname = $review->fname_ext_reviewer; $view->external_reviewer_lname = $review->lname_ext_reviewer; $view->review_comments = $review->comments; } else { $view->reviewer_fname = $iReview; $view->reviewer_lname = ""; $view->external_reviewer_fname = ""; $view->external_reviewer_lname = ""; $view->review_comments = ""; } $view->reviewer_email = $review->email; $view->review_overall = $review->overall; $view->review_summary = $review->summary; $view->review_details = $review->details; if ($review->reviewerExpertise >= 1 and $review->reviewerExpertise <= 3) { $view->reviewer_expertise = Config::$Expertise[$review->reviewerExpertise]; } // Avoid to introduce Latex commands in Latex files .... if (!$html) { $view->review_summary = str_replace("\\", "", $view->review_summary); $view->review_details = str_replace("\\", "", $view->review_details); $view->review_comments = str_replace("\\", "", $view->review_comments); } $view->assign("REVIEWER_INFO", "REVIEWER"); reset($listCriterias); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $criteria) { $reviewMark = $reviewMarkTbl->find($review->idPaper, $review->id_user, $criteria->id)->current(); if (!is_object($reviewMark)) { $reviewMark = $reviewMarkTbl->createRow(); // for default values } $reviewMark->putInView($view); $view->criteria_label = $criteria->label; $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->append("PAPERS", "PAPER_DETAIL"); // The paper data is shown only once for all the reviews $view->set_var("PAPER_DATA", " "); } // Show the paper even without reviewer if ($countReviews == 0) { $review = $reviewTbl->createRow(); $review->putInView($view); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $id => $label) { $reviewMark = $reviewMarkTbl->createRow(); $reviewMark->putInView($view); $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->set_var("REVIEWER_INFO", ""); $view->append("PAPERS", "PAPER_DETAIL"); $view->set_var("PAPER_DATA", ""); } // Summary for the paper if ($html) { $statPaper = Paper::getStats($paper->id, $listCriterias); $markFieldName = "ReviewMark" . "->mark"; $overallFieldName = "review_overall"; $view->set_var("NB_REVIEWERS", 1); if ($html) { $view->set_var("PAPER_DATA", "<td> </td><th>Summary</th>"); } $view->set_var("REVIEWER_INFO", " "); $view->set_var($overallFieldName, $paper->overall); reset($listCriterias); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $c) { $view->setVar($markFieldName, $statPaper[$c->id]); $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->append("PAPERS", "PAPER_DETAIL"); $view->set_var("PAPER_DATA", ""); } } }
public function editListAction(Request $request, $list_id) { $repository = $this->getUserListRepository(); $list = $repository->findUserListByUserAndId($this->getAuthenticatedUser(), $list_id); $query = $this->createUserQuery(); $query->on_bases_where_i_am($this->getAclForUser($this->getAuthenticatedUser()), ['canpush']); if ($request->get('query')) { $query->like($request->get('like_field'), $request->get('query'))->like_match(\User_Query::LIKE_MATCH_OR); } if (is_array($request->get('Activity'))) { $query->haveActivities($request->get('Activity')); } if (is_array($request->get('Template'))) { $query->haveTemplate($request->get('Template')); } if (is_array($request->get('Company'))) { $query->inCompanies($request->get('Company')); } if (is_array($request->get('Country'))) { $query->inCountries($request->get('Country')); } if (is_array($request->get('Position'))) { $query->havePositions($request->get('Position')); } $sort = $request->get('srt', 'usr_creationdate'); $ord = $request->get('ord', 'desc'); $perPage = 10; $offset_start = Max(((int) $request->get('page') - 1) * $perPage, 0); $query->sort_by($sort, $ord); $results = $query->include_phantoms()->limit($offset_start, $perPage)->execute()->get_results(); $params = ['query' => $query, 'results' => $results, 'list' => $list, 'sort' => $sort, 'ord' => $ord]; if ($request->get('type') === 'fragment') { return new Response($this->render('prod/actions/Feedback/ResultTable.html.twig', $params)); } return new Response($this->render('prod/actions/Feedback/list.html.twig', $params)); }
} // Either they aren't using NewGroupsOnly $SQL .= "AND ((NewGroupsOnly = '0' "; // Or this is the first torrent in the group to match the formatbitrate filter $SQL .= ") OR ( NewGroupsOnly = '1' "; // Test the filter doesn't match any previous formatbitrate in the group foreach ($UsedFormatBitrates as $UsedFormatBitrate) { $FormatReq = "(Formats LIKE '%|" . db_string($UsedFormatBitrate['format']) . "|%' OR Formats = '') "; $BitrateReq = "(Encodings LIKE '%|" . db_string($UsedFormatBitrate['bitrate']) . "|%' OR Encodings = '') "; $SQL .= "AND (NOT({$FormatReq} AND {$BitrateReq})) "; } $SQL .= '))'; if ($Properties['Year'] && $Properties['RemasterYear']) { $SQL .= " AND (('" . db_string(trim($Properties['Year'])) . "' BETWEEN FromYear AND ToYear)\n\t\t\tOR ('" . db_string(trim($Properties['RemasterYear'])) . "' BETWEEN FromYear AND ToYear)\n\t\t\tOR (FromYear = 0 AND ToYear = 0)) "; } elseif ($Properties['Year'] || $Properties['RemasterYear']) { $SQL .= " AND (('" . db_string(trim(Max($Properties['Year'], $Properties['RemasterYear']))) . "' BETWEEN FromYear AND ToYear)\n\t\t\tOR (FromYear = 0 AND ToYear = 0)) "; } else { $SQL .= " AND (FromYear = 0 AND ToYear = 0) "; } $SQL .= " AND UserID != '" . $LoggedUser['ID'] . "' "; $DB->query("\n\tSELECT Paranoia\n\tFROM users_main\n\tWHERE ID = {$LoggedUser['ID']}"); list($Paranoia) = $DB->next_record(); $Paranoia = unserialize($Paranoia); if (!is_array($Paranoia)) { $Paranoia = array(); } if (!in_array('notifications', $Paranoia)) { $SQL .= " AND (Users LIKE '%|" . $LoggedUser['ID'] . "|%' OR Users = '') "; } $SQL .= " AND UserID != '" . $LoggedUser['ID'] . "' "; $DB->query($SQL);
$Title = _('Inventory Planning') . ' - ' . _('Problem Report') . '....'; include 'includes/header.inc'; prnMsg(_('The purchase order quantities could not be retrieved by the SQL because') . ' - ' . DB_error_msg($db), 'error'); echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug == 1) { echo '<br />' . $SQL; } include 'includes/footer.inc'; exit; } $OnOrdRow = DB_fetch_array($OnOrdResult); $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 60, $FontSize, $InventoryPlan['stockid'], 'left'); $LeftOvers = $pdf->addTextWrap(100, $YPos, 150, 6, $InventoryPlan['description'], 'left'); $AverageOfLast4Months = $SalesRow['4mthtotal'] / 4; $LeftOvers = $pdf->addTextWrap(251, $YPos, 50, $FontSize, locale_number_format($AverageOfLast4Months, 1), 'right'); $MaxMthSales = Max($SalesRow['prd1'], $SalesRow['prd2'], $SalesRow['prd3'], $SalesRow['prd4']); $LeftOvers = $pdf->addTextWrap(309, $YPos, 50, $FontSize, locale_number_format($MaxMthSales, 0), 'right'); $Quantities = array($SalesRow['prd1'], $SalesRow['prd2'], $SalesRow['prd3'], $SalesRow['prd4']); $StandardDeviation = standard_deviation($Quantities); $LeftOvers = $pdf->addTextWrap(359, $YPos, 50, $FontSize, locale_number_format($StandardDeviation, 2), 'right'); $LeftOvers = $pdf->addTextWrap(409, $YPos, 50, $FontSize, locale_number_format($InventoryPlan['monthsleadtime'], 1), 'right'); $RequiredStockInSupplyChain = $AverageOfLast4Months * ($_POST['NumberMonthsHolding'] + $InventoryPlan['monthsleadtime']); $LeftOvers = $pdf->addTextWrap(456, $YPos, 50, $FontSize, locale_number_format($RequiredStockInSupplyChain, 0), 'right'); $LeftOvers = $pdf->addTextWrap(597, $YPos, 40, $FontSize, locale_number_format($InventoryPlan['qoh'], 0), 'right'); $LeftOvers = $pdf->addTextWrap(638, $YPos, 40, $FontSize, locale_number_format($TotalDemand, 0), 'right'); $LeftOvers = $pdf->addTextWrap(679, $YPos, 40, $FontSize, locale_number_format($OnOrdRow['qtyonorder'], 0), 'right'); $SuggestedTopUpOrder = $RequiredStockInSupplyChain - $InventoryPlan['qoh'] + $TotalDemand - $OnOrdRow['qtyonorder']; if ($SuggestedTopUpOrder <= 0) { $LeftOvers = $pdf->addTextWrap(730, $YPos, 40, $FontSize, _('Nil'), 'center'); } else { $LeftOvers = $pdf->addTextWrap(720, $YPos, 40, $FontSize, locale_number_format($SuggestedTopUpOrder, 0), 'right');
function print_inventory_planning() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $location = $_REQUEST['PARAM_1']; $comments = $_REQUEST['PARAM_2']; $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($location == reserved_words::get_all()) { $location = 'all'; } if ($location == 'all') { $loc = tr('All'); } else { $loc = $location; } $cols = array(0, 50, 150, 180, 210, 240, 270, 300, 330, 390, 435, 480, 525); $per0 = strftime('%b', mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $per1 = strftime('%b', mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'))); $per2 = strftime('%b', mktime(0, 0, 0, date('m') - 2, date('d'), date('Y'))); $per3 = strftime('%b', mktime(0, 0, 0, date('m') - 3, date('d'), date('Y'))); $per4 = strftime('%b', mktime(0, 0, 0, date('m') - 4, date('d'), date('Y'))); $headers = array(tr('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', tr('QOH'), tr('Cust Ord'), tr('Supp Ord'), tr('Sugg Ord')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(tr('Inventory Planning Report'), "InventoryPlanning.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($category, $location); $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $custqty = getCustQty($trans['stock_id'], $trans['loc_code']); $custqty += getCustAsmQty($trans['stock_id'], $trans['loc_code']); $suppqty = getSuppQty($trans['stock_id'], $trans['loc_code']); $period = getPeriods($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, number_format2($period['prd0'], $dec)); $rep->TextCol(3, 4, number_format2($period['prd1'], $dec)); $rep->TextCol(4, 5, number_format2($period['prd2'], $dec)); $rep->TextCol(5, 6, number_format2($period['prd3'], $dec)); $rep->TextCol(6, 7, number_format2($period['prd4'], $dec)); $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']); $IdealStockHolding = $MaxMthSales * 3; $rep->TextCol(7, 8, number_format2($IdealStockHolding, $dec)); $rep->TextCol(8, 9, number_format2($trans['qty_on_hand'], $dec)); $rep->TextCol(9, 10, number_format2($custqty, $dec)); $rep->TextCol(10, 11, number_format2($suppqty, $dec)); $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty; if ($SuggestedTopUpOrder < 0.0) { $SuggestedTopUpOrder = 0.0; } $rep->TextCol(11, 12, number_format2($SuggestedTopUpOrder, $dec)); } $rep->Line($rep->row - 4); $rep->End(); }
if (Is_Error($Image)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------- } elseif ($Height) { #------------------------------------------------------------------------- $Width = $Height / $Index; #------------------------------------------------------------------------- $Image = Image_Resize($Image, (int) $Width, (int) $Height); if (Is_Error($Image)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------- } elseif ($Scale != 100) { #------------------------------------------------------------------------- $Scale = Min(Max(50, $Scale), 200); #------------------------------------------------------------------------- $Width = $Size['Width'] * ($Scale / 100); $Height = $Width * $Index; #------------------------------------------------------------------------- $Image = Image_Resize($Image, (int) $Width, (int) $Height); if (Is_Error($Image)) { return ERROR | @Trigger_Error(500); } } #--------------------------------------------------------------------------- Header('Content-Type: image'); Header('Cache-Control: private, max-age=86400'); #--------------------------------------------------------------------------- return $Image; default:
function PN_BlogStatisticsProcess($target) { global $blogid, $pluginURL, $defaultURL, $blog; if (doesHaveOwnership()) { include_once 'lib/open-flash-chart.php'; $grpStyle = $_GET['grpStyle']; $grpData = explode("|", $_GET['grpData']); $grpTotal = $_GET['grpTotal']; $grpYear = $_GET['grpYear']; $grpTypeName = $_GET['grpTypeName']; $grpLinkType = $_GET['grpLinkType']; $grpXLabelType = isset($_GET['grpXLabelType']) ? $_GET['grpXLabelType'] : 0; $grpLabel = explode("|", $_GET['grpLabel']); $grpSubTitle = array(); $grpLabelTemp = array(); if (!empty($_GET['grpData'])) { if ($grpTypeName == "category") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = rawurlencode($grpLabel[$i] == 0 ? _t('분류없음') : htmlspecialchars(UTF8::lessenAsEm(getCategoryNameById($blogid, $grpLabel[$i]), 15))); } } else { if ($grpTypeName == "hits" || $grpTypeName == "cmmax" || $grpTypeName == "tbmax" || $grpTypeName == "tagmax") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = rawurlencode(htmlspecialchars(UTF8::lessenAsEm(str_replace(",", "-", getEntryTitleById($blogid, $grpLabel[$i])), 25))); } } else { if ($grpTypeName == "commenter" || $grpTypeName == "tag") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 15)); $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 6, '')); } $grpLabel = $grpLabelTemp; } else { if ($grpTypeName == "time") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = rawurlencode($grpLabel[$i] . "시"); } } else { if ($grpTypeName == "refer") { for ($i = 0; $i < count($grpLabel); $i++) { $tmpHost = explode('.', $grpLabel[$i]); $tmpHostCnt = count($tmpHost) - 1; $tmpDomain = (strlen($tmpHost[$tmpHostCnt]) < 3 ? $tmpHost[$tmpHostCnt - 2] . '.' : '') . $tmpHost[$tmpHostCnt - 1] . '.' . $tmpHost[$tmpHostCnt]; $cutDomain = explode('.', $tmpDomain); $grpSubTitle[] = htmlspecialchars($grpLabel[$i]); $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($cutDomain[0], 6, '')); } $grpLabel = $grpLabelTemp; } else { if ($grpTypeName == "referkey") { for ($i = 0; $i < count($grpLabel); $i++) { $tmpLabel = explode('(', $grpLabel[$i]); $grpSubTitle[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 15)); $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($tmpLabel[0], 6, '')); } $grpLabel = $grpLabelTemp; } } } } } } $g = new graph(); $g->bg_colour = '#FFFFFF'; if ($grpStyle == "pie") { $grpClickLink = ""; $grpPercent = array(); $grpLink = array(); for ($i = 0; $i < count($grpData); $i++) { $grpPercent[] = round($grpData[$i] / $grpTotal * 100, 0); } if ($grpLinkType == "archiveYear") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . "/archive/" . substr($grpLabel[$i], 0, 4); $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "archiveMonth" && $grpYear != "9999") { for ($i = 0; $i < count($grpLabel); $i++) { $cutMonth = str_replace("월", "", $grpLabel[$i]); $tmpMonth = strlen($cutMonth) == 1 ? "0" . $cutMonth : $cutMonth; $permalink = $defaultURL . "/archive/" . $grpYear . $tmpMonth; $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "category") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . "/category/" . getCategoryLabelById($blogid, $grpLabel[$i]); $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "entry") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . ($blog['useSlogan'] ? "/entry/" . getEntrySloganById($blogid, $grpLabel[$i]) : "/" . $grpLabel[$i]); $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "tag") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . "/tag/" . $grpLabel[$i]; $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } } } } } $g->pie(75, '#ffffff', '#000000', false, 1); $g->pie_values($grpData, $grpLabel, $grpLink, $grpSubTitle); $g->pie_slice_colours(array('#B9D2E6', '#E2B11C', '#A3CF22', '#EC7122', '#4FC0C0', '#D45E5E', '#A275A2', '#52A7D2', '#9F373B', '#B4ADA5', '#5FC97E', '#CFB85D', '#9DC64E', '#FFAB29', '#E23838', '#43CEA9', '#4CA9D9', '#BA4ECA', '#6C79DA', '#CCCCCC', '#AB5C06', '#C06868', '#5FC97E', 'CFB85D')); $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#(#percent#%25)' . $grpClickLink); } else { if ($grpStyle == "bar") { $g->title(' ', '{font-size:12px; color:#000000;margin-top:0px;padding:3px;}'); $g->set_data($grpData); $g->set_bar_titles($grpSubTitle); $g->bar_glass(70, '#68B1D9', '#62A0C1', '', 12); $g->bar_colours(array('#B9D2E6', '#E2B11C', '#A3CF22', '#EC7122', '#4FC0C0', '#D45E5E', '#A275A2', '#52A7D2', '#9F373B', '#B4ADA5', '#5FC97E', '#CFB85D', '#9DC64E', '#FFAB29', '#E23838', '#43CEA9', '#4CA9D9', '#BA4ECA', '#6C79DA', '#CCCCCC', '#AB5C06', '#C06868', '#5FC97E', 'CFB85D')); $g->x_axis_colour('#909090', '#D2D2FB'); $g->y_axis_colour('#909090', '#D2D2FB'); $g->set_x_labels($grpLabel); $g->set_x_label_style(10, '#000000', $grpXLabelType, -1); $g->set_y_label_style(9, '#888888'); $tmp_data_max = floor(Max($grpData) * 1.2); if ($tmp_y_max = $tmp_data_max % 10) { $tmp_data_max = $tmp_data_max + (10 - $tmp_y_max); } $g->set_y_max($tmp_data_max); $g->set_y_legend('', 11, '#736AFF'); $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#'); } else { if ($grpStyle == "line") { $g->title('', '{font-size:1px; color:#000000;}'); $g->set_data($grpData); $g->line_dot(2, 4, '#6FBBC6', _t('최근 7일간 방문자 수'), 11); // <-- 3px thick + dots $g->set_x_labels($grpLabel); $g->set_x_label_style(8, '#333333', $grpXLabelType, -1); $g->x_axis_colour('#909090', '#e7e7e7'); $g->y_axis_colour('#909090', '#e7e7e7'); $tmp_data_max = floor(Max($grpData) * 1.2); if ($tmp_y_max = $tmp_data_max % 10) { $tmp_data_max = $tmp_data_max + (10 - $tmp_y_max); } $g->set_y_max($tmp_data_max); $g->set_y_legend('', 1, '#736AFF'); $g->y_label_steps(4); $g->set_y_label_style(8, '#333333', $grpXLabelType, -1); $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#'); } } } echo $g->render(); flush(); } } }
/** * SetVolume */ public function SetVolume($value) { $desiredVolume = Max(0, Min(100, $value)); $instanceId = 0; $channel = 'Master'; $response = $this->Device()->sendRequestToDevice('SetVolume', array('InstanceID' => $instanceId, 'Channel' => $channel, 'DesiredVolume' => $desiredVolume)); return true; }
function GetBarMinMax() { $max = $this->scale->NormalizeDate($this->iObj[0]->GetMaxDate()); $min = $this->scale->NormalizeDate($this->iObj[0]->GetMinDate()); for ($i = 1; $i < count($this->iObj); ++$i) { $max = Max($max, $this->scale->NormalizeDate($this->iObj[$i]->GetMaxDate())); $min = Min($min, $this->scale->NormalizeDate($this->iObj[$i]->GetMinDate())); } $minDate = date("Y-m-d", $min); $min = strtotime($minDate); $maxDate = date("Y-m-d 23:59", $max); $max = strtotime($maxDate); return array($min, $max); }
function imageCircle() { $total = 0; $item_array = Split($this->ARRAYSPLIT, $this->ITEMARRAY); $num = Count($item_array); $item_max = 0; for ($i = 0; $i < $num; $i++) { $item_max = Max($item_max, $item_array[$i]); $total += $item_array[$i]; } $yy = $this->Y - $this->BORDER * 2; //画饼状图的阴影部分 $e = 0; for ($i = 0; $i < $num; $i++) { srand((double) microtime() * 1000000); if ($this->R != 255 && $this->G != 255 && $this->B != 255) { $R = Rand($this->R, 200); $G = Rand($this->G, 200); $B = Rand($this->B, 200); } else { $R = Rand(50, 200); $G = Rand(50, 200); $B = Rand(50, 200); } $s = $e; $leight = $item_array[$i] / $total * 360; $e = $s + $leight; $color = ImageColorAllocate($this->IMAGE, $R, $G, $B); $colorarray[$i] = $color; //画圆 for ($j = 90; $j > 70; $j–) { imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $e, $color, IMG_ARC_PIE); } //imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE); //ImageFilledRectangle($this->IMAGE,$this->BORDER,$yy-$this->BORDER,$leight,$yy,$color); //ImageString($this->IMAGE,$this->FONTSIZE,$leight+2,$yy-$this->BORDER,$item_array[$i],$this->FONTCOLOR); //用于间隔 $yy = $yy - $this->BORDER * 2; } //画饼状图的表面部分 $e = 0; for ($i = 0; $i < $num; $i++) { srand((double) microtime() * 1000000); if ($this->R != 255 && $this->G != 255 && $this->B != 255) { $R = Rand($this->R, 200); $G = Rand($this->G, 200); $B = Rand($this->B, 200); } else { $R = Rand(50, 200); $G = Rand(50, 200); $B = Rand(50, 200); } $s = $e; $leight = $item_array[$i] / $total * 360; $e = $s + $leight; //$color=$colorarray[$i]; $color = ImageColorAllocate($this->IMAGE, $R, $G, $B); //画圆 //for ($j = 90; $j > 70; $j–) imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $e, $color, IMG_ARC_PIE); imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE); } }
function ScaleImage($sourceImageWidth, $sourceImageHeight, $arSize, $resizeType, &$bNeedCreatePicture, &$arSourceSize, &$arDestinationSize) { if (!is_array($arSize)) { $arSize = array(); } if (!array_key_exists("width", $arSize) || intval($arSize["width"]) <= 0) { $arSize["width"] = 0; } if (!array_key_exists("height", $arSize) || intval($arSize["height"]) <= 0) { $arSize["height"] = 0; } $arSize["width"] = intval($arSize["width"]); $arSize["height"] = intval($arSize["height"]); $bNeedCreatePicture = false; $arSourceSize = array("x" => 0, "y" => 0, "width" => 0, "height" => 0); $arDestinationSize = array("x" => 0, "y" => 0, "width" => 0, "height" => 0); if ($sourceImageWidth > 0 && $sourceImageHeight > 0) { if ($arSize["width"] > 0 && $arSize["height"] > 0) { switch ($resizeType) { case BX_RESIZE_IMAGE_EXACT: $bNeedCreatePicture = true; $ratio = $sourceImageWidth / $sourceImageHeight < $arSize["width"] / $arSize["height"] ? $arSize["width"] / $sourceImageWidth : $arSize["height"] / $sourceImageHeight; $x = max(0, round($sourceImageWidth / 2 - $arSize["width"] / 2 / $ratio)); $y = max(0, round($sourceImageHeight / 2 - $arSize["height"] / 2 / $ratio)); $arDestinationSize["width"] = $arSize["width"]; $arDestinationSize["height"] = $arSize["height"]; $arSourceSize["x"] = $x; $arSourceSize["y"] = $y; $arSourceSize["width"] = round($arSize["width"] / $ratio, 0); $arSourceSize["height"] = round($arSize["height"] / $ratio, 0); break; default: if ($resizeType == BX_RESIZE_IMAGE_PROPORTIONAL_ALT) { $width = Max($sourceImageWidth, $sourceImageHeight); $height = Min($sourceImageWidth, $sourceImageHeight); } else { $width = $sourceImageWidth; $height = $sourceImageHeight; } $ResizeCoeff["width"] = $arSize["width"] / $width; $ResizeCoeff["height"] = $arSize["height"] / $height; $iResizeCoeff = Min($ResizeCoeff["width"], $ResizeCoeff["height"]); $iResizeCoeff = 0 < $iResizeCoeff && $iResizeCoeff < 1 ? $iResizeCoeff : 1; $bNeedCreatePicture = $iResizeCoeff != 1 ? true : false; $arDestinationSize["width"] = max(1, intval($iResizeCoeff * $sourceImageWidth)); $arDestinationSize["height"] = max(1, intval($iResizeCoeff * $sourceImageHeight)); $arSourceSize["x"] = 0; $arSourceSize["y"] = 0; $arSourceSize["width"] = $sourceImageWidth; $arSourceSize["height"] = $sourceImageHeight; break; } } else { $arSourceSize = array("x" => 0, "y" => 0, "width" => $sourceImageWidth, "height" => $sourceImageHeight); $arDestinationSize = array("x" => 0, "y" => 0, "width" => $sourceImageWidth, "height" => $sourceImageHeight); } } }
function Resample(&$img, $owdt, $ohgt, $maxwdt, $maxhgt, $quality=1) { if(!$maxwdt) $divwdt=0; else $divwdt=Max(1,$owdt/$maxwdt); if(!$maxhgt) $divhgt=0; else $divhgt=Max(1,$ohgt/$maxhgt); if($divwdt>=$divhgt) { $newwdt=$maxwdt; $newhgt=round($ohgt/$divwdt); } else { $newhgt=$maxhgt; $newwdt=round($owdt/$divhgt); } $tn=imagecreatetruecolor($newwdt,$newhgt); if($quality) imagecopyresampled($tn,$img,0,0,0,0,$newwdt,$newhgt,$owdt,$ohgt); else imagecopyresized($tn,$img,0,0,0,0,$newwdt,$newhgt,$owdt,$ohgt); imagedestroy($img); $img = $tn; return array($newwdt, $newhgt); }
function GetBarMinMax() { $start = 0; $n = count($this->iObj); while ($start < $n && $this->iObj[$start]->GetMaxDate() === false) { ++$start; } if ($start >= $n) { JpgraphError::RaiseL(6006); //('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]'); } $max = $this->scale->NormalizeDate($this->iObj[$start]->GetMaxDate()); $min = $this->scale->NormalizeDate($this->iObj[$start]->GetMinDate()); for ($i = $start + 1; $i < $n; ++$i) { $rmax = $this->scale->NormalizeDate($this->iObj[$i]->GetMaxDate()); if ($rmax != false) { $max = Max($max, $rmax); } $rmin = $this->scale->NormalizeDate($this->iObj[$i]->GetMinDate()); if ($rmin != false) { $min = Min($min, $rmin); } } $minDate = date("Y-m-d", $min); $min = strtotime($minDate); $maxDate = date("Y-m-d 23:59", $max); $max = strtotime($maxDate); return array($min, $max); }
function Stroke($aStrokeFileName = "") { // Do any pre-stroke adjustment that is needed by the different plot types // (i.e bar plots want's to add an offset to the x-labels etc) for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->PreStrokeAdjust($this); $this->plots[$i]->Legend($this); } // Any plots on the second Y scale? if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->PreStrokeAdjust($this); $this->y2plots[$i]->Legend($this); } } // Bail out if any of the Y-axis not been specified and // has no plots. (This means it is impossible to do autoscaling and // no other scale was given so we can't possible draw anything). If you use manual // scaling you also have to supply the tick steps as well. if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) { JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified Y-scale.</strong><br>\n\t\t\t\tYou have either:\n\t\t\t\t<br>* Specified an Y axis for autoscaling but have not supplied any plots\n\t\t\t\t<br>* Specified a scale manually but have forgot to specify the tick steps"); } // Bail out if no plots and no specified X-scale if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) { JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>"); } //Check if we should autoscale y-axis if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->plots); $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } if ($this->y2scale != null) { if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->y2plots); $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } } //Check if we should autoscale x-axis if (!$this->xscale->IsSpecified()) { if (substr($this->axtype, 0, 4) == "text") { $max = 0; foreach ($this->plots as $p) { $max = max($max, $p->numpoints - 1); } $min = 0; if ($this->y2axis != null) { foreach ($this->y2plots as $p) { $max = max($max, $p->numpoints - 1); } } $this->xscale->Update($this->img, $min, $max); $this->xscale->ticks->Set($this->xaxis->tick_step, 1); $this->xscale->ticks->SupressMinorTickMarks(); } else { list($min, $ymin) = $this->plots[0]->Min(); list($max, $ymax) = $this->plots[0]->Max(); foreach ($this->plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } if ($this->y2axis != null) { foreach ($this->y2plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor); } //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale $this->yaxis->SetPos($this->xscale->GetMinVal()); if ($this->y2axis != null) { $this->y2axis->SetPos($this->xscale->GetMaxVal()); $this->y2axis->SetTitleSide(SIDE_RIGHT); } } // If we have a negative values and x-axis position is at 0 // we need to supress the first and possible the last tick since // they will be drawn on top of the y-axis (and possible y2 axis) // The test below might seem strange the reasone being that if // the user hasn't specified a value for position this will not // be set until we do the stroke for the axis so as of now it // is undefined. if (!$this->xaxis->pos && $this->yscale->GetMinVal() < 0) { $this->yscale->ticks->SupressZeroLabel(false); $this->xscale->ticks->SupressFirst(); if ($this->y2axis != null) { $this->xscale->ticks->SupressLast(); } } $this->StrokePlotArea(); // Stroke axis $this->xaxis->Stroke($this->yscale); $this->yaxis->Stroke($this->xscale); // Stroke bands if ($this->bands != null) { for ($i = 0; $i < count($this->bands); ++$i) { // Stroke all bands that asks to be in the background if ($this->bands[$i]->depth == DEPTH_BACK) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } if ($this->grid_depth == DEPTH_BACK) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke Y2-axis if ($this->y2axis != null) { $this->y2axis->Stroke($this->xscale); $this->y2grid->Stroke(); } $oldoff = $this->xscale->off; if (substr($this->axtype, 0, 4) == "text") { $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step); } // Stroke all plots for Y1 axis for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } // Stroke all plots for Y2 axis if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } $this->xscale->off = $oldoff; if ($this->grid_depth == DEPTH_FRONT) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke bands if ($this->bands != null) { for ($i = 0; $i < count($this->bands); ++$i) { // Stroke all bands that asks to be in the foreground if ($this->bands[$i]->depth == DEPTH_FRONT) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } // Stroke any lines added if ($this->lines != null) { for ($i = 0; $i < count($this->lines); ++$i) { $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } // Finally draw the axis again since some plots may have nagged // the axis in the edges. $this->yaxis->Stroke($this->xscale); $this->xaxis->Stroke($this->yscale); if ($this->y2scale != null) { $this->y2axis->Stroke($this->xscale); } $this->StrokePlotBox(); // The titles and legends never gets rotated so make sure // that the angle is 0 before stroking them $aa = $this->img->SetAngle(0); $this->StrokeTitles(); $this->legend->Stroke($this->img); $this->StrokeTexts(); $this->img->SetAngle($aa); // Draw an outline around the image map if (JPG_DEBUG) { $this->DisplayClientSideaImageMapAreas(); } // Adjust the appearance of the image $this->AdjustSaturationBrightnessContrast(); // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); }
function GetXMinMax() { list($min, $ymin) = $this->plots[0]->Min(); list($max, $ymax) = $this->plots[0]->Max(); foreach ($this->plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } if ($this->y2axis != null) { foreach ($this->y2plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { if ($this->ynaxis[$i] != null) { foreach ($this->ynplots[$i] as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } } return array($min, $max); }
function Max() { list($xmax) = $this->plots[0]->Max(); $nmax = 0; $n = count($this->plots); for ($i = 0; $i < $n; ++$i) { $nc = count($this->plots[$i]->coords[0]); $nmax = max($nmax, $nc); list($x) = $this->plots[$i]->Max(); $xmax = Max($xmax, $x); } for ($i = 0; $i < $nmax; $i++) { $y = $this->plots[0]->coords[0][$i]; for ($j = 1; $j < $this->nbrplots; $j++) { $y += $this->plots[$j]->coords[0][$i]; } $ymax[$i] = $y; } $ymax = max($ymax); return array($xmax, $ymax); }
function GetXMinMax() { list($min, $ymin) = $this->plots[0]->Min(); list($max, $ymax) = $this->plots[0]->Max(); foreach ($this->plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } if ($this->y2axis != null) { foreach ($this->y2plots as $p) { list($xmin, $ymin) = $p->Min(); list($xmax, $ymax) = $p->Max(); $min = Min($xmin, $min); $max = Max($xmax, $max); } } return array($min, $max); }
function show_table($data, $full_texts = false, $vertical = true) { if (count($data) == 0) { return ""; } $limit = Max(round(220 / count($data[0])), 20); if ($vertical) { $limit = 150; } $content = "<table border='0' cellpadding='0' cellspacing='0'>"; if (!$vertical) { $content .= "<tr>"; foreach (array_keys($data[0]) as $value) { if ($full_texts and strlen($value) > $limit) { $value = substr($value, 0, $limit) . "..."; } $content .= "<td nowrap><b>" . q($value) . "</b></td>"; } $content .= "</tr>"; } foreach ($data as $dataset) { if ($vertical) { foreach ($dataset as $key => $value) { if ($value == "") { continue; } $content .= "<tr onmouseover='this.style.backgroundColor=\"#EFEFEF\";' onmouseout='this.style.backgroundColor=\"\";'>"; $content .= "<td style='width:25%;' valign='top'><b>" . q($key) . "</b></td>"; $hint = $value; if (is_numeric($value) and strlen($value) == 10) { $value .= " / " . sys_date("Y-m-d H:i:s a", $value); } if (!$full_texts and strlen($value) > $limit) { $value = substr($value, 0, $limit) . "..."; } $content .= "<td title='" . q($hint) . "'>" . nl2br(q($value)) . "</td></tr>"; } $content .= "<tr><td colspan='2'><hr></td></tr>"; } else { $content .= "<tr onmouseover='this.style.backgroundColor=\"#EFEFEF\";' onmouseout='this.style.backgroundColor=\"\";'>"; foreach ($dataset as $key => $value) { if ($vertical) { if ($full_texts and strlen($key) > $limit) { $key = substr($key, 0, $limit) . "..."; } $content .= "<td nowrap><b>" . q($key) . "</b></td>"; } $hint = $value; if (is_numeric($value) and strlen($value) == 10) { $hint = sys_date("Y-m-d H:i:s a", $value); } if (!$full_texts and strlen($value) > $limit) { $value = substr($value, 0, $limit) . "..."; } $content .= "<td nowrap title='" . q($hint) . "'>" . q($value) . "</td>"; } $content .= "</tr>"; } } return $content . "</table>"; }