コード例 #1
0
 protected function drawWorkPeriod()
 {
     imagefilledrectangle($this->im, $this->shiftXleft + 1, $this->shiftY, $this->sizeX + $this->shiftXleft - 2, $this->sizeY + $this->shiftY, $this->getColor($this->graphtheme['graphcolor'], 0));
     if ($this->m_showWorkPeriod != 1) {
         return;
     }
     if ($this->period > 3 * 2678400) {
         return;
     }
     // > 31*24*3600 (3*month)
     $db_work_period = DBselect('SELECT work_period FROM config');
     $work_period = DBfetch($db_work_period);
     if (!$work_period) {
         return;
     }
     $periods = parse_period($work_period['work_period']);
     if (!$periods) {
         return;
     }
     imagefilledrectangle($this->im, $this->shiftXleft + 1, $this->shiftY, $this->sizeX + $this->shiftXleft - 2, $this->sizeY + $this->shiftY, $this->getColor($this->graphtheme['noneworktimecolor'], 0));
     $now = time();
     if (isset($this->stime)) {
         $this->from_time = $this->stime;
         $this->to_time = $this->stime + $this->period;
     } else {
         $this->to_time = $now - 3600 * $this->from;
         $this->from_time = $this->to_time - $this->period;
     }
     $from = $this->from_time;
     $max_time = $this->to_time;
     $start = find_period_start($periods, $from);
     $end = -1;
     while ($start < $max_time && $start > 0) {
         $end = find_period_end($periods, $start, $max_time);
         $x1 = round(($start - $from) * $this->sizeX / $this->period) + $this->shiftXleft;
         $x2 = ceil(($end - $from) * $this->sizeX / $this->period) + $this->shiftXleft;
         //draw rectangle
         imagefilledrectangle($this->im, $x1, $this->shiftY, $x2 - 2, $this->sizeY + $this->shiftY, $this->getColor($this->graphtheme['graphcolor'], 0));
         $start = find_period_start($periods, $end);
     }
 }
コード例 #2
0
 function parse_period($days, $field = '')
 {
     list($c, $u) = parse_period($days);
     if ($u == 'error') {
         fatal_error(sprintf(_PLUG_PAY_WORLDPAY_FERROR4, $field, $days));
     }
     if ($u == 'fixed') {
         fatal_error(sprintf(_PLUG_PAY_WORLDPAY_FERROR4, $field, $days));
     }
     $tr = array('d' => 1, 'm' => 3, 'y' => 4);
     return array($c, $tr[$u]);
 }
コード例 #3
0
 function getPeriod($product)
 {
     list($count, $unit) = parse_period($product['expire_days']);
     switch ($unit) {
         case "d":
             return "Day";
             break;
         case "m":
             return "Month";
             break;
         case "y":
             return "Year";
             break;
     }
 }
コード例 #4
0
 function _getTextPeriod($days, $skip_one_c)
 {
     list($c, $u) = parse_period($days);
     switch ($u) {
         case 'd':
             $uu = $c == 1 ? 'day' : 'days';
             break;
         case 'm':
             $uu = $c == 1 ? 'month' : 'months';
             break;
         case 'y':
             $uu = $c == 1 ? 'year' : 'years';
             break;
     }
     $cc = $c;
     if ($c == 1) {
         $cc = $skip_one_c ? '' : 'one';
     }
     return "{$cc} {$uu}";
 }
コード例 #5
0
function unconvert_period_fields(&$p)
{
    global $product_additional_fields;
    foreach ($product_additional_fields as $f) {
        if ($f['type'] == 'period') {
            $v = $p[$f['name']];
            list($c, $u) = parse_period($p[$f['name']]);
            unset($p[$f['name']]);
            if ($u == 'fixed' && $c == MAX_SQL_DATE) {
                $p[$f['name']]['count'] = '';
                $p[$f['name']]['unit'] = 'lifetime';
            } else {
                $p[$f['name']]['count'] = $c;
                $p[$f['name']]['unit'] = $u;
            }
        }
    }
}