Exemple #1
0
		$category->save();
	}
	$stmt->close();			
}	
*/
$stmt = SqlQuery::select($cube_db, 'cubecart_inventory');
if ($stmt) {
    $result = $stmt->get_result();
    while ($row = $result->fetch_assoc()) {
        $product = new Product($db);
        $product->loadByExtId($row['productId']);
        // import new product
        if (!$product->is_loaded) {
            $product->data['product_ext_id'] = $row['productId'];
            $product->data['product_name'] = myTrim(convertEncoding($row['name']));
            $product->data['product_price'] = parseFloat($row['price']);
            $category = loadCategory($row['cat_id']);
            if (isset($category)) {
                $product->data['product_category_id'] = $category->ival('category_id');
            }
            $new++;
        } else {
            $updated++;
        }
        $product->data['product_description'] = convertEncoding($row['description']);
        $product->data['product_image'] = $row['image'];
        $product->save();
    }
    $stmt->close();
}
echo sprintf('Imported %s new, %s updated.', $new, $updated);
Exemple #2
0
 public function convert($price)
 {
     return parseFloat($price) / $this->fval('currency_value');
 }
 function parseParts($parts)
 {
     global $emptySet;
     $hasError = false;
     $borderLeft = array();
     $borderRight = array();
     $isOpenLeft = array();
     $isOpenRight = array();
     $index = array();
     // empty input
     $hasError = count($parts) == 0;
     foreach ($parts as $part) {
         // echo "-> " . $part .  "\n";
         if (preg_match('/dne/i', $part)) {
             // empty set
             // do nothing
         } else {
             $iol = preg_match("/^\\s*\\[/", $part) > 0;
             $ior = preg_match("/\\]\\s*\$/", $part) > 0;
             // list($a,$b) = preg_split("/\s*,\s*/",$part);
             preg_match('/^\\s*[\\(\\[]\\s*(?P<left>.+)\\s*,\\s*(?P<right>.+)\\s*[\\)\\]]\\s*$/', $part, $match);
             // missing colon
             if (!isset($match["left"]) || !isset($match["right"])) {
                 return array("has-error" => true);
             }
             list($bl, $v1, $e1) = parseFloat($match["left"]);
             list($br, $v2, $e2) = parseFloat($match["right"]);
             if ($e1 || $e2) {
                 return array("has-error" => true);
             }
             if ($bl == $br && (!$iol || !$ior)) {
                 // empty set
                 // do nothing
             } else {
                 $index["{$bl}"] = $v1;
                 $index["{$br}"] = $v2;
                 // swap borders if necessary
                 if ($bl < $br) {
                     $borderLeft[] = $bl;
                     $borderRight[] = $br;
                 } else {
                     $borderLeft[] = $br;
                     $borderRight[] = $bl;
                 }
                 $isOpenLeft[] = !$iol;
                 $isOpenRight[] = !$ior;
             }
         }
     }
     if (count($borderLeft) == 0) {
         return array("has-error" => false, "left-border" => array($emptySet["left-border"]), "right-border" => array($emptySet["right-border"]), "is-open-left" => array($emptySet["is-open-left"]), "is-open-right" => array($emptySet["is-open-right"]), "index" => $index);
     } else {
         return array("has-error" => false, "left-border" => $borderLeft, "right-border" => $borderRight, "is-open-left" => $isOpenLeft, "is-open-right" => $isOpenRight, "index" => $index);
     }
 }
Exemple #4
0
    ?>
% style="font-size:11px" align="center" class="corner5 text5 <?php 
    echo $classTr;
    ?>
">
	            		<span id="spanSpeed-<?php 
    echo $drVehicle["id"];
    ?>
" onmousemove="ShowPopup(event, '<span class=\'text5\'>Моментална брзина</span>')" onmouseout="HidePopup()">
	            			<?php 
    if (pg_fetch_result($dsCurrPos, 0, "speed") == "/") {
        $speed = pg_fetch_result($dsCurrPos, 0, "speed");
    } else {
        $speed = round(pg_fetch_result($dsCurrPos, 0, "speed"), 0) . ' Km/h';
        if ($metric == "mi") {
            $speed = round(round(parseFloat(pg_fetch_result($dsCurrPos, 0, "speed")) * 0.621371 * 100) / 100) . ' mph';
        }
    }
    ?>
	            			<?php 
    echo $speed;
    ?>
	            		</span>
	            		<br>max: <?php 
    $maxspeed = nnull(round(dlookup("select MAX(speed)from rMaxSpeed where  Datetime>='" . DateTimeFormat(now(), "Y-m-d 00:00:00") . "' and  Datetime<='" . DateTimeFormat(now(), "Y-m-d H:i:s") . "' and vehicleID=" . $drVehicle["id"])), "/");
    if ($maxspeed != "/") {
        $maxspeed .= " Km/h";
    }
    ?>
	            	<span id="spanMaxSpeed-<?php 
    echo $drVehicle["id"];
Exemple #5
0
 private function guessType(Token &$token)
 {
     if ($token->type == Token::T_TEXT) {
         if (is_numeric($token->value)) {
             $token->type = Token::T_NUMBER;
             $token->value = parseFloat($token->value);
         } else {
             if (preg_match("/^\\d{1,2}\\/\\d{1,2}\\/\\d{4}\$/", $token->value)) {
                 $token->type = Token::T_DATE;
                 $date = \DateTime::createFromFormat("d/m/Y", $token->value, new \DateTimeZone('Europe/Paris'));
                 $error = \DateTime::getLastErrors();
                 if ($error['error_count'] > 0) {
                     throw new \Exception($error['errors'][0]);
                 }
                 $date->setTime(0, 0, 0);
                 $token->value = $date;
             } else {
                 if ($token->value === 'true' || $token->value === 'false') {
                     $token->type = Token::T_BOOLEAN;
                     $token->value = $token->value === 'true';
                 }
             }
         }
     }
 }
function logData($db_name, $mytemp)
{
    $filename = $db_name . ".rrd";
    $temperature = parseFloat($mytemp);
    $command = "rrdtool update {$filename} N:{$temperature}";
    $output = shell_exec($command);
    print "{$command}\n";
    return true;
}
Exemple #7
0
function formatPrice($price, $selected_currency = null)
{
    if (parseFloat($price) > 0) {
        global $db, $home_dir;
        require_once $home_dir . 'models/currency.m.php';
        return Currency::formatPrice($db, $price, $selected_currency);
    } else {
        return t('Free');
    }
}