Ejemplo n.º 1
0
 public function toRegex(Range $range)
 {
     $min = $range->getMin();
     $max = $range->getMax();
     if ($min === $max) {
         return $min;
     }
     if ($min > $max) {
         return sprintf('%d|%d', $min, $max);
     }
     $positives = [];
     $negatives = [];
     if ($min < 0) {
         $newMin = 1;
         if ($max < 0) {
             $newMin = abs($max);
         }
         $newMax = abs($min);
         $negatives = $this->splitToPatterns($newMin, $newMax);
         $min = 0;
     }
     if ($max >= 0) {
         $positives = $this->splitToPatterns($min, $max);
     }
     return $this->siftPatterns($negatives, $positives);
 }
Ejemplo n.º 2
0
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     return $this->range->contains($this->current()->getKey());
 }
Ejemplo n.º 3
0
 public function intersect(Range $range)
 {
     $lowestNumber = max($range->getLowestNumber(), $this->lowestNumber);
     $highestNumber = min($range->getHighestNumber(), $this->highestNumber);
     if ($lowestNumber <= $highestNumber) {
         return $this->createRange($lowestNumber, $highestNumber);
     }
     return null;
 }
Ejemplo n.º 4
0
 public function testValidateType()
 {
     $field = new Range("range", "range", 10, 20);
     $result = $field->validateType("range", "NaN", $element);
     $this->assertFalse($result);
     $result = $field->validateType("range", 5, $element);
     $this->assertFalse($result);
     $result = $field->validateType("range", 15, $element);
     $this->assertTrue($result);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function build(SetInterface $identities, ServerRequestInterface $request, HttpResource $definition, SpecificationInterface $specification = null, Range $range = null) : MapInterface
 {
     $map = new Map('string', HeaderInterface::class);
     if (!$definition->isRangeable()) {
         return $map;
     }
     $map = $map->put('Accept-Ranges', new AcceptRanges(new AcceptRangesValue('resources')));
     if (!$range instanceof Range) {
         return $map;
     }
     $length = $range->lastPosition() - $range->firstPosition();
     return $map->put('Content-Range', new ContentRange(new ContentRangeValue('resources', $range->firstPosition(), $last = $range->firstPosition() + $identities->size(), $identities->size() < $length ? $last : $last + $length)));
 }
Ejemplo n.º 6
0
 /**
  * 
  * Enter description here ...
  * @param Range $r
  */
 public static function save(Range $r)
 {
     $dbh = $GLOBALS['dbh'];
     if ($r->get_id()) {
         // Update
         $data = $dbh->prepare("\n\t\t\t\tUPDATE \n\t\t\t\t\t`range`\n\t\t\t\tSET \n\t\t\t\t\tname=:name\n\t\t\t\tWHERE \n\t\t\t\t\tid=:id\n\t\t\t");
         $data->execute(array(':name' => $r->get_name(), ':id' => $r->get_id()));
     } else {
         // Insert
         $data = $dbh->prepare("\n\t\t\t\tINSERT \n\t\t\t\t\tINTO `range` (name)\n\t\t\t\tVALUES\n\t\t\t\t\t(:name)\n\t\t\t");
         $data->execute(array(':name' => $r->get_name()));
     }
 }
Ejemplo n.º 7
0
 /**
  * @param IP|Network|Range $find
  * @return bool
  * @throws \Exception
  */
 public function contains($find)
 {
     if ($find instanceof IP) {
         $within = strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0 && strcmp($find->inAddr(), $this->lastIP->inAddr()) <= 0;
     } elseif ($find instanceof Range || $find instanceof Network) {
         /**
          * @var Network|Range $find
          */
         $within = strcmp($find->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0 && strcmp($find->getLastIP()->inAddr(), $this->lastIP->inAddr()) <= 0;
     } else {
         throw new \Exception('Invalid type');
     }
     return $within;
 }
Ejemplo n.º 8
0
 public function __construct($lowestNumber = 0, $highestNumber = 0)
 {
     if (!is_int($lowestNumber) || !is_int($highestNumber)) {
         throw new \InvalidArgumentException('Only integer numbers are supported');
     }
     parent::__construct($lowestNumber, $highestNumber);
 }
Ejemplo n.º 9
0
 /**
  * Constructor
  *
  * @param \JAAulde\IP\V4\Address|string                               $a1 The base address with which the network and broadcast addresses of this block will be calculated. This can be an
  *                                                                        an instance of \JAAulde\IP\V4\Address, in which case the second parameter will be required, or a string in dot-notated format with optional CIDR
  *                                                                        slash prefix. If a string without CIDR slash prefix, second parameter is required. If there is a CIDR slash prefix, second parameter will be ignored.
  * @param \JAAulde\IP\V4\SubnetMask|int|string|\JAAulde\IP\V4\Address $a2 Optional depending on what was given as the first parameter. This is a subnet mask
  *                                                                        to determine the size of this block, or a CIDR prefix for calculating a subnet mask, or a second \JAAulde\IP\V4\Address instance to fit into the derived
  *                                                                        block.
  *
  * @throws Exception
  */
 public function __construct($a1, $a2 = null)
 {
     $subnetMask = null;
     if (is_string($a1)) {
         $a1parts = explode('/', $a1, 2);
         $a1sub1 = $a1parts[0];
         $a1sub2 = isset($a1parts[1]) ? $a1parts[1] : null;
         $a1 = new Address($a1sub1);
         if ($a1sub2 !== null) {
             $a2 = (int) $a1sub2;
         }
     }
     if ($a2 instanceof SubnetMask) {
         $subnetMask = $a2;
     } else {
         if ($a2 instanceof Address) {
             $a2 = SubnetMask::calculateCIDRToFit($a1, $a2);
         }
         if (is_string($a2) && count(explode('.', $a2)) === 4) {
             $subnetMask = new SubnetMask($a2);
         } elseif (is_int($a2) || is_string($a2)) {
             $subnetMask = SubnetMask::fromCIDRPrefix((int) preg_replace('/[^\\d]/', '', (string) $a2));
         }
     }
     if (!$subnetMask instanceof SubnetMask) {
         throw new \Exception(__METHOD__ . ' could not derive a subnet mask. See documentation for second param, $a2.');
     }
     $this->subnetMask = $subnetMask;
     parent::__construct(self::calculateNetworkAddress($a1, $subnetMask), self::calculateBroadcastAddress($a1, $subnetMask));
 }
 /**
  * @dataProvider rangeDataProvider
  **/
 public function testCreation($min, $max, $throwsException)
 {
     if ($throwsException) {
         $this->setExpectedException('WrongArgumentException');
     }
     $range = Range::create($min, $max);
 }
Ejemplo n.º 11
0
 /**
  * Create a new instance from a date object.
  *
  * @param DateTime $date A date within the season
  */
 public function __construct(DateTime $date)
 {
     $this->unix = $date->timestamp();
     $start = Date::mkdate($date->numeric("Y"), $date->numeric("n"), 1);
     $end = Date::mkdate($date->numeric("Y"), $date->numeric("n"), $date->numeric("t"));
     parent::__construct($start, $end);
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function all(string $name, SpecificationInterface $specification = null, Range $range = null) : SetInterface
 {
     $definition = $this->capabilities->get($name);
     if ($range !== null && !$definition->isRangeable()) {
         throw new ResourceNotRangeableException();
     }
     if ($specification !== null) {
         $query = '?' . $this->specificationTranslator->translate($specification);
     }
     $url = $this->resolver->resolve((string) $definition->url(), $query ?? (string) $definition->url());
     $url = Url::fromString($url);
     $headers = new Map('string', HeaderInterface::class);
     if ($range !== null) {
         $headers = $headers->put('Range', new RangeHeader(new RangeValue('resource', $range->firstPosition(), $range->lastPosition())));
     }
     $response = $this->transport->fulfill(new Request($url, new Method(Method::GET), new ProtocolVersion(1, 1), new Headers($headers), new NullStream()));
     return $this->serializer->denormalize($response, 'rest_identities', null, ['definition' => $definition]);
 }
 public function testMonthOffsetReturnsExpectedDates()
 {
     $this->object->setFirstDate(\DateTime::createFromFormat('Y-m-d', '2014-01-01'));
     $this->object->setLastDate(\DateTime::createFromFormat('Y-m-d', '2014-03-01'));
     $this->object->setOpt('interval', 'P1M');
     $range = $this->object->getRange();
     $this->assertEquals('2014-01-01', $range['2014-01-01']['formatted']);
     $this->assertEquals('2014-02-01', $range['2014-02-01']['formatted']);
     $this->assertEquals('2014-03-01', $range['2014-03-01']['formatted']);
 }
Ejemplo n.º 14
0
 /**
  * Set the columns to repeat at the left hand side of each printed page.
  *
  * @param integer $firstCol First column to repeat
  * @param integer $lastCol  Last column to repeat. Optional.
  *
  * @return PrintSetup
  */
 public function printRepeatColumns($firstCol, $lastCol = null)
 {
     if (!isset($lastCol)) {
         $lastCol = $firstCol;
     }
     $this->printRepeat->setColFrom($firstCol)->setColTo($lastCol);
     if (is_null($this->printRepeat->getRowFrom())) {
         $this->printRepeat->setRowFrom(0)->setRowTo(Biff8::MAX_ROW_IDX);
     }
     return $this;
 }
Ejemplo n.º 15
0
 public static function createFromXml($xml)
 {
     $z = new Zestimate();
     $z->amount = Xml::xstring($xml, 'amount');
     $z->lastUpdated = new Date(Xml::xstring($xml, 'last-updated'));
     $z->thirtyDayChange = Xml::xstring($xml, 'valueChange[@duration="30"]');
     $z->percentile = Xml::xstring($xml, 'percentile');
     $ranges = $xml->xpath('valuationRange');
     if (count($ranges == 1)) {
         $z->range = Range::createFromXml($ranges[0]);
     }
     return $z;
 }
 public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
 {
     //	Check each property is valid
     //
     if (!parent::isValid($properties_dictionary, $limit_to_keys, $error)) {
         return false;
     }
     if (ValidationC::should_test_property(EVENT_SPACE_TIME_OCCURRENCE_RELATIONSHIP_NAME_RANGE, $properties_dictionary, false, $limit_to_keys) && !Range::isValid($properties_dictionary[EVENT_SPACE_TIME_OCCURRENCE_RELATIONSHIP_NAME_RANGE], $limit_to_keys, $error)) {
         //	Attendees range was not valid
         //
         return false;
     }
     return true;
 }
Ejemplo n.º 17
0
 /**
  * create a new UnicodeBlock
  *
  * If $name is given and $r is Null, the block is looked up in the
  * database. If $r is set, the relevant items are taken from there.
  */
 public function __construct($name, $db, $r = NULL)
 {
     if ($r === NULL) {
         // performance: allow to specify range
         $query = $db->prepare("\n                SELECT name, first, last, abstract\n                FROM blocks\n                LEFT JOIN block_abstract\n                    ON blocks.name = block_abstract.block\n                WHERE replace(replace(lower(name), '_', ''), ' ', '') = ?\n                LIMIT 1");
         $query->execute([Toolkit::normalizeName($name)]);
         $r = $query->fetch(\PDO::FETCH_ASSOC);
         $query->closeCursor();
         if ($r === False) {
             throw new Exception('No block named ' . $name);
         }
     }
     $this->name = $r['name'];
     // use canonical name
     $this->limits = [$r['first'], $r['last']];
     parent::__construct(range($r['first'], $r['last']), $db);
 }
Ejemplo n.º 18
0
 /**
  * Searches a range
  * 
  * @param Range $range 
  * 
  * @return RangeIterator
  */
 public function searchRange(Range $range)
 {
     $iterator = $this->getIterator();
     // find start
     $start = null;
     $binarySearch = new BinarySearch($this);
     $startHint = $binarySearch->search($range->getMin());
     if ($startHint == null) {
         return new RangeIterator($iterator, Range::getEmptyRange());
     }
     $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY);
     if (!$range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) {
         // shift $startHint higher
         foreach ($iterator as $result) {
             if ($range->contains($result->getKey())) {
                 $start = $result;
                 break;
             }
         }
     } else {
         // shift $startHint lower
         if ($range->contains($startHint->getKey())) {
             $start = $startHint;
         }
         $iterator->setDirection(KeyReader::DIRECTION_BACKWARD);
         foreach ($iterator as $result) {
             // Skip everything which is too big
             if (!$range->contains($result->getKey() && $result->getKey() >= $range->getMax())) {
                 continue;
             }
             // shift the start left until no more key is included
             if ($range->contains($result->getKey())) {
                 $start = $result;
             } else {
                 break;
             }
         }
     }
     if (is_null($start)) {
         return new RangeIterator($iterator, Range::getEmptyRange());
     }
     $iterator = $this->getIterator();
     $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY);
     return new RangeIterator($iterator, $range);
 }
 public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
 {
     //	Check each property is valid
     //
     if (!parent::isValid($properties_dictionary, $limit_to_keys, $error)) {
         return false;
     }
     if (ValidationC::should_test_property(RANGE_POSITION, $properties_dictionary, true, $limit_to_keys) && !Range::propertyIsValid(RANGE_POSITION, $properties_dictionary[RANGE_POSITION], $error)) {
         //	Position was not valid
         //
         return false;
     }
     if (ValidationC::should_test_property(RANGE_LENGTH, $properties_dictionary, true, $limit_to_keys) && !Range::propertyIsValid(RANGE_LENGTH, $properties_dictionary[RANGE_LENGTH], $error)) {
         //	Range was not valid
         //
         return false;
     }
     return true;
 }
Ejemplo n.º 20
0
 /**
  * @param IP|Network $exclude
  * @return array
  * @throws \Exception
  */
 public function exclude($exclude)
 {
     $exclude = self::parse($exclude);
     if ($exclude->getFirstIP()->inAddr() > $this->getLastIP()->inAddr() || $exclude->getLastIP()->inAddr() < $this->getFirstIP()->inAddr()) {
         throw new \Exception('Exclude subnet not within target network');
     }
     $networks = array();
     $newPrefixLength = $this->getPrefixLength() + 1;
     $lower = clone $this;
     $lower->setPrefixLength($newPrefixLength);
     $upper = clone $lower;
     $upper->setIP($lower->getLastIP()->next());
     while ($newPrefixLength <= $exclude->getPrefixLength()) {
         $range = new Range($lower->getFirstIP(), $lower->getLastIP());
         if ($range->contains($exclude)) {
             $matched = $lower;
             $unmatched = $upper;
         } else {
             $matched = $upper;
             $unmatched = $lower;
         }
         $networks[] = clone $unmatched;
         if (++$newPrefixLength > $this->getNetwork()->getMaxPrefixLength()) {
             break;
         }
         $matched->setPrefixLength($newPrefixLength);
         $unmatched->setPrefixLength($newPrefixLength);
         $unmatched->setIP($matched->getLastIP()->next());
     }
     sort($networks);
     return $networks;
 }
Ejemplo n.º 21
0
    echo "selected";
}
?>
>воскресенье</option>
</select><br>
<input type="submit" name="submitted" value="submit"/>
</form>
<?php 
if ($_GET["calendar_from"]) {
    calendar('fields', 'from');
}
if ($_GET["calendar_to"]) {
    calendar('fields', 'to');
}
if ($_GET["submitted"]) {
    $range = new Range($_GET['from'], $_GET['to']);
    if (!$range->get_validation_logs()) {
        echo "\n\t\t<table class='table table-hover'><thead><td><div>Список дат:</div></td></thead>";
        $list = $range->create_list($_GET['week']);
        for ($i = 0; $i < count($list); $i++) {
            $list[$i] = explode("-", $list[$i]);
            $newlist[$i] = $list[$i][0] . "." . $list[$i][1] . "." . $list[$i][2] . ' ' . $list[$i][3];
            echo "<tr><td>{$newlist[$i]}</td></tr>";
        }
        echo "</table>";
    }
}
?>

</body>
Ejemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 protected function assertCorrectLimits(Range $range)
 {
     $this->assertCorrectLimitType($range->min());
     $this->assertCorrectLimitType($range->max());
     $this->assertSameCurrencies();
 }
Ejemplo n.º 23
0
<?php

include_once 'include/connect.php';
include_once 'class/range.class.php';
include_once 'class/device.class.php';
$results = Range::getAll();
$width = 0;
// Assign value for range
if ($results) {
    $width = (960 - count($results) * 20) / count($results);
}
$smarty->assign('ranges', $results);
$smarty->assign('devices', Device::getAll());
$smarty->assign('width', $width);
$smarty->assign('menu', 1);
$smarty->display('dashboard.tpl');
 /**
  * Returns all available presentations
  *
  * @return array<string>
  */
 public function getPresentationClass($presentation, $fieldName, $configs = null)
 {
     $event = new OW_Event('base.questions_field_get_label', array('presentation' => $presentation, 'fieldName' => $fieldName, 'configs' => $configs, 'type' => 'edit'));
     OW::getEventManager()->trigger($event);
     $label = $event->getData();
     $class = null;
     $event = new OW_Event('base.questions_field_init', array('type' => 'main', 'presentation' => $presentation, 'fieldName' => $fieldName, 'configs' => $configs));
     OW::getEventManager()->trigger($event);
     $class = $event->getData();
     if (empty($class)) {
         switch ($presentation) {
             case self::QUESTION_PRESENTATION_TEXT:
                 $class = new TextField($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_SELECT:
                 $class = new Selectbox($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_TEXTAREA:
                 $class = new Textarea($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_CHECKBOX:
                 $class = new CheckboxField($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_RADIO:
                 $class = new RadioField($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_MULTICHECKBOX:
                 $class = new CheckboxGroup($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_BIRTHDATE:
             case self::QUESTION_PRESENTATION_AGE:
             case self::QUESTION_PRESENTATION_DATE:
                 $class = new DateField($fieldName);
                 if (!empty($configs) && mb_strlen(trim($configs)) > 0) {
                     $configsList = json_decode($configs, true);
                     foreach ($configsList as $name => $value) {
                         if ($name = 'year_range' && isset($value['from']) && isset($value['to'])) {
                             $class->setMinYear($value['from']);
                             $class->setMaxYear($value['to']);
                         }
                     }
                 }
                 $class->addValidator(new DateValidator($class->getMinYear(), $class->getMaxYear()));
                 break;
             case self::QUESTION_PRESENTATION_RANGE:
                 $class = new Range($fieldName);
                 if (!empty($configs) && mb_strlen(trim($configs)) > 0) {
                     $configsList = json_decode($configs, true);
                     foreach ($configsList as $name => $value) {
                         $minMax = explode("-", $value);
                         if ($name = 'range' && isset($minMax[0]) && isset($minMax[1])) {
                             $class->setMinValue($minMax[0]);
                             $class->setMaxValue($minMax[1]);
                         }
                     }
                 }
                 $class->addValidator(new RangeValidator());
                 break;
             case self::QUESTION_PRESENTATION_URL:
                 $class = new TextField($fieldName);
                 $class->addValidator(new UrlValidator());
                 break;
             case self::QUESTION_PRESENTATION_PASSWORD:
                 $class = new PasswordField($fieldName);
                 break;
         }
     }
     if (!empty($label)) {
         $class->setLabel($label);
     }
     return $class;
 }
Ejemplo n.º 25
0
 /**
  * @dataProvider getExpectedResultsAndValues
  *
  * @param Boolean $contains
  * @param integer $value
  */
 public function testShouldDetermineIfContainsValue($contains, $value)
 {
     $range = new Range($this->start, $this->end);
     $this->assertEquals($contains, $range->contains($value));
 }
Ejemplo n.º 26
0
    public function getContent()
    {
        if (!extension_loaded('soap') || !class_exists('SoapClient')) {
            return $this->displayError($this->l('SOAP extension should be enabled on your server to use this module.'));
        }
        $output = '';
        $this->configured = Configuration::get('SEUR_Configured');
        if (Tools::isSubmit('submitToDefault')) {
            $this->setDefaultWS();
        } elseif (Tools::isSubmit('submitWebservices')) {
            $this->storeWS();
        } elseif (Tools::isSubmit('submitConfiguration')) {
            $update_seur_carriers = array();
            $delivery = Tools::getValue('seur_cod');
            if (Module::isInstalled('seurcashondelivery') == false && $delivery) {
                $output .= $this->displayError($this->l('To enable Cash on delivery you must install the module "SEUR Cash on delivery".'));
                $delivery = '0';
            }
            $sql_update_configuration_table = '
				UPDATE `' . _DB_PREFIX_ . 'seur_configuration`
				SET
					`pos` =' . (int) Tools::getValue('pos', 1) . ',
					`international_orders` =' . (int) Tools::getValue('international_orders') . ',
					`seur_cod` =' . (int) $delivery . ',
					`notification_advice_radio` =' . (int) Tools::getValue('notification_advice_radio') . ',
					`notification_distribution_radio` =' . (int) Tools::getValue('notification_distribution_radio') . ',
					`print_type` =' . (int) Tools::getValue('print_type') . ',
					`pickup` =' . (int) Tools::getValue('pickup') . ',
					`advice_checkbox` =' . (int) (Tools::getValue('advice_checkbox') == 'on' ? 1 : 0) . ',
					`distribution_checkbox` =' . (int) (Tools::getValue('distribution_checkbox') == 'on' ? 1 : 0);
            if (Context::getContext()->shop->isFeatureActive()) {
                $sql_update_configuration_table .= ', `id_shop`  =' . (int) $this->context->shop->id;
            }
            if (Tools::getValue('id_seur_carrier')) {
                $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier'), 'type' => 'SEN');
            }
            if (Tools::getValue('id_seur_carrier_canarias_m')) {
                $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier_canarias_m'), 'type' => 'SCN');
            }
            if (Tools::getValue('id_seur_carrier_canarias_48')) {
                $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier_canarias_48'), 'type' => 'SCE');
            }
            if (Tools::getValue('id_seur_carrier_pos')) {
                $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier_pos'), 'type' => 'SEP');
            }
            if (!empty($update_seur_carriers)) {
                SeurLib::updateSeurCarriers($update_seur_carriers);
            }
            $sql_update_configuration_table .= ' WHERE `id_seur_configuration` = 1';
            $this->configured = 1;
            Configuration::updateValue('SEUR_Configured', 1);
            Configuration::updateValue('SEUR_REMCAR_CARGO', (double) Tools::getValue('contra_porcentaje'));
            Configuration::updateValue('SEUR_REMCAR_CARGO_MIN', (double) Tools::getValue('contra_minimo'));
            Configuration::updateValue('SEUR_PRINTER_NAME', Tools::getValue('printer_name') ? pSQL(Tools::getValue('printer_name')) : 'Generic / Text Only');
            Configuration::updateValue('SEUR_FREE_WEIGTH', (double) Tools::getValue('peso_gratis'));
            Configuration::updateValue('SEUR_FREE_PRICE', (double) Tools::getValue('precio_gratis'));
            $seur_carriers = array();
            foreach ($update_seur_carriers as $value) {
                $seur_carriers[$value['type']] = $value['id'];
            }
            $carrier_seur = new Carrier((int) $seur_carriers['SEN']);
            $carrier_pos = new Carrier((int) $seur_carriers['SEP']);
            if (Tools::getValue('international_orders') && SeurLib::getConfigurationField('international_orders') != Tools::getValue('international_orders') && SeurLib::getConfigurationField('tarifa') && Validate::isLoadedObject($carrier_seur)) {
                if (Tools::getValue('international_orders') && Tools::getValue('international_orders') == 1) {
                    $carrier_seur->addZone((int) Zone::getIdByName('Europe'));
                    $carrier_seur->save();
                } elseif (Tools::getValue('international_orders') == 0) {
                    $carrier_seur->deleteZone((int) Zone::getIdByName('Europe'));
                    $carrier_seur->save();
                }
            }
            if (in_array(Tools::getValue('pos'), array(0, 1)) == true && Validate::isLoadedObject($carrier_pos)) {
                $carrier_pos->active = (int) Tools::getValue('pos');
                $carrier_pos->save();
            }
            if (!Db::getInstance()->Execute($sql_update_configuration_table)) {
                $output .= $this->displayError($this->l('Cannot update.'));
            } else {
                $output .= $this->displayConfirmation($this->l('Configuration updated.'));
            }
        } elseif (Tools::isSubmit('submitLogin')) {
            $sqlUpdateDataTable = 'UPDATE `' . _DB_PREFIX_ . 'seur_merchant`
				SET
					`nif_dni` ="' . pSQL(Tools::strtoupper(Tools::getValue('nif_dni'))) . '",
					`name` ="' . pSQL(Tools::strtoupper(Tools::getValue('name'))) . '",
					`first_name` ="' . pSQL(Tools::strtoupper(Tools::getValue('first_name'))) . '",
					`franchise` ="' . (Tools::getValue('franchise') ? pSQL(Tools::getValue('franchise')) : pSQL(Tools::getValue('franchise_cfg'))) . '",
					`company_name` ="' . pSQL(Tools::strtoupper(Tools::getValue('company_name'))) . '",
					`street_type` ="' . pSQL(Tools::getValue('street_type')) . '",
					`street_name` ="' . pSQL(Tools::strtoupper(Tools::getValue('street_name'))) . '",
					`street_number` ="' . pSQL(Tools::getValue('street_number')) . '",
					' . (Tools::getValue('staircase') ? '`staircase` ="' . pSQL(Tools::strtoupper(Tools::getValue('staircase'))) . '",' : ' ') . '
					`floor` ="' . pSQL(Tools::getValue('floor')) . '",
					`door` ="' . pSQL(Tools::getValue('door')) . '",
					`post_code` ="' . (Tools::getValue('post_code') ? pSQL(Tools::getValue('post_code')) : pSQL(Tools::getValue('post_code_cfg'))) . '",
					`town` ="' . (Tools::getValue('town') ? pSQL(Tools::strtoupper(Tools::getValue('town'))) : pSQL(Tools::strtoupper(Tools::getValue('town_cfg')))) . '",
					`state` ="' . (Tools::getValue('state') ? pSQL(Tools::strtoupper(Tools::getValue('state'))) : pSQL(Tools::strtoupper(Tools::getValue('state_cfg')))) . '",
					`country` ="' . (Tools::getValue('country') ? pSQL(Tools::strtoupper(Tools::getValue('country'))) : pSQL(Tools::strtoupper(Tools::getValue('country_cfg')))) . '",
					`phone` ="' . (int) Tools::getValue('phone') . '",
					`ccc` ="' . (int) Tools::getValue('ccc_cfg') . '",
					`cit` ="' . (int) Tools::getValue('ci') . '",
					' . (Tools::getValue('fax') ? '`fax` =' . (int) Tools::getValue('fax') . ',' : ' ') . '
					`email` ="' . pSQL(Tools::strtolower(Tools::getValue('email'))) . '"';
            if (Tools::getValue('user_cfg') && Tools::getValue('pass_cfg')) {
                $sqlUpdateDataTable .= ', `USER`="' . pSQL(Tools::strtolower(Tools::getValue('user_cfg'))) . '", `PASS`="' . pSQL(Tools::strtolower(Tools::getValue('pass_cfg'))) . '" ';
            }
            $sqlUpdateDataTable .= "WHERE `id_seur_datos` = 1;";
            if (Tools::getValue('user_seurcom') && Tools::getValue('pass_seurcom')) {
                Configuration::updateValue('SEUR_WS_USERNAME', Tools::getValue('user_seurcom'));
                Configuration::updateValue('SEUR_WS_PASSWORD', Tools::getValue('pass_seurcom'));
            }
            if (!Db::getInstance()->Execute($sqlUpdateDataTable)) {
                $output .= $this->displayError($this->l('Database fail.'));
            } else {
                $output .= $this->displayConfirmation($this->l('Configuration updated.'));
            }
            $this->stateConfigured = 1;
        } elseif (Tools::isSubmit('submitWithRanges')) {
            if (Range::setRanges()) {
                $output .= $this->displayConfirmation($this->l('Prices configured correctly. '));
                SeurLib::setConfigurationField('tarifa', 1);
            }
            $this->configured = 1;
            Configuration::updateValue('SEUR_Configured', 1);
            die(Tools::redirectAdmin($this->getModuleLink('AdminModules')));
        } elseif (Tools::isSubmit('submitWithoutRanges')) {
            $this->configured = 1;
            Configuration::updateValue('SEUR_Configured', 1);
        }
        return $this->displayForm();
    }
Ejemplo n.º 27
0
 public function testGetFactory()
 {
     $factory = Range::getFactory();
     $this->assertInstanceOf('Bankiru\\IPTools\\Interfaces\\RangeFactoryInterface', $factory);
 }
Ejemplo n.º 28
0
<?php

include_once 'class/range.class.php';
include_once 'class/device.class.php';
include_once 'class/payment.class.php';
$ranges = Range::getAll();
$smarty->assign('ranges', $ranges);
$smarty->assign('menu', 2);
// Report
if ($_POST['report']) {
    set_include_path(dirname(dirname(__FILE__)) . '/library/PEAR/');
    include_once 'Spreadsheet/Excel/Writer.php';
    $workbook = new Spreadsheet_Excel_Writer();
    $workbook->setVersion(8);
    $worksheet =& $workbook->addWorksheet('report');
    $worksheet->setInputEncoding('UTF-8');
    $header = $workbook->addFormat();
    $header->setFontFamily('Arial');
    $header->setSize(14);
    $header->setFgColor('blue');
    $header->setBold();
    $header->setHAlign('center');
    $header->setVAlign('center');
    $header->setColor('white');
    $common = $workbook->addFormat();
    $common->setFontFamily('Arial');
    $common->setSize(12);
    $caption = $workbook->addFormat();
    $caption->setFontFamily('Arial');
    $caption->setSize(12);
    $caption->setBorder(1);
Ejemplo n.º 29
0
 protected function getPresentationClass($presentation, $questionName, $configs = null)
 {
     $event = new OW_Event('base.questions_field_get_label', array('presentation' => $presentation, 'fieldName' => $questionName, 'configs' => $configs, 'type' => 'edit'));
     OW::getEventManager()->trigger($event);
     $label = $event->getData();
     $class = null;
     $event = new OW_Event('base.questions_field_init', array('type' => 'search', 'presentation' => $presentation, 'fieldName' => $questionName, 'configs' => $configs));
     OW::getEventManager()->trigger($event);
     $class = $event->getData();
     if (empty($class)) {
         switch ($presentation) {
             case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
             case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
                 $class = new TextField($questionName);
                 break;
             case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
                 $class = new CheckboxField($questionName);
                 break;
             case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
             case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
             case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
                 $class = new Selectbox($questionName);
                 break;
             case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
             case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
                 $class = new USEARCH_CLASS_AgeRangeField($questionName);
                 if (!empty($configs) && mb_strlen(trim($configs)) > 0) {
                     $configsList = json_decode($configs, true);
                     foreach ($configsList as $name => $value) {
                         if ($name = 'year_range' && isset($value['from']) && isset($value['to'])) {
                             $class->setMinYear($value['from']);
                             $class->setMaxYear($value['to']);
                         }
                     }
                 }
                 $class->addValidator(new USEARCH_CLASS_AgeRangeValidator($class->getMinAge(), $class->getMaxAge()));
                 break;
             case self::QUESTION_PRESENTATION_RANGE:
                 $class = new Range($fieldName);
                 if (empty($this->birthdayConfig)) {
                     $birthday = $this->findQuestionByName("birthdate");
                     if (!empty($birthday)) {
                         $this->birthdayConfig = $birthday->custom;
                     }
                 }
                 $rangeValidator = new RangeValidator();
                 if (!empty($this->birthdayConfig) && mb_strlen(trim($this->birthdayConfig)) > 0) {
                     $configsList = json_decode($this->birthdayConfig, true);
                     foreach ($configsList as $name => $value) {
                         if ($name = 'year_range' && isset($value['from']) && isset($value['to'])) {
                             $class->setMinValue(date("Y") - $value['to']);
                             $class->setMaxValue(date("Y") - $value['from']);
                             $rangeValidator->setMinValue(date("Y") - $value['to']);
                             $rangeValidator->setMaxValue(date("Y") - $value['from']);
                         }
                     }
                 }
                 $class->addValidator($rangeValidator);
                 break;
             case self::QUESTION_PRESENTATION_DATE:
                 $class = new DateRange($fieldName);
                 if (!empty($configs) && mb_strlen(trim($configs)) > 0) {
                     $configsList = json_decode($configs, true);
                     foreach ($configsList as $name => $value) {
                         if ($name = 'year_range' && isset($value['from']) && isset($value['to'])) {
                             $class->setMinYear($value['from']);
                             $class->setMaxYear($value['to']);
                         }
                     }
                 }
                 $class->addValidator(new DateValidator($class->getMinYear(), $class->getMaxYear()));
                 break;
             case BOL_QuestionService::QUESTION_PRESENTATION_URL:
                 $class = new TextField($questionName);
                 $class->addValidator(new UrlValidator());
                 break;
         }
         if (!empty($label)) {
             $class->setLabel($label);
         }
         if (empty($class)) {
             $class = BOL_QuestionService::getInstance()->getSearchPresentationClass($presentation, $questionName, $configs);
         }
     }
     return $class;
 }
Ejemplo n.º 30
0
 /**
  * get a user's active time entry
  *
  * <code>
  * $api = new HarvestReports();
  *
  * $result = $api->getUsersActiveTimer( 12345 );
  * if ( $result->isSuccess() ) {
  *     $activeTimer = $result->data;
  * }
  * </code>
  *
  * @return Result
  */
 public function getUsersActiveTimer($user_id)
 {
     $result = $this->getUserEntries($user_id, Range::today($this->_timeZone));
     if ($result->isSuccess()) {
         $data = null;
         foreach ($result->data as $entry) {
             if ($entry->timer_started_at != null || $entry->timer_started_at != "") {
                 $data = $entry;
                 break;
             }
         }
         $result->data = $data;
     }
     return $result;
 }