Esempio n. 1
0
 public function insertPrice(Price $price)
 {
     $cn = new Conexao();
     $sql = "INSERT INTO prices_added (name, description, price, place_id, place_api_id) VALUES ('" . $price->getName() . "','" . $price->getDescription() . "','" . $price->getPrice() . "','" . $price->getPlaceId() . "','" . $price->getPlaceApiId() . "')";
     $result = $cn->execute($sql);
     $id = $cn->returnInsertedId();
     $cn->disconnect();
     if ($result != false) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * 
  * @param Price $price
  * @return int id of the Price inserted in base. False if it didn't work.
  */
 public static function flush($price)
 {
     $priceId = $price->getId();
     $pricevar = $price->getPrice();
     if ($priceId > 0) {
         $sql = 'UPDATE price p SET ' . 'p.price = ?, ' . 'WHERE p.id_price = ?';
         $params = array('di', &$pricevar, $priceId);
     } else {
         $sql = 'INSERT INTO price ' . '(price) ' . 'VALUES(?) ';
         $params = array('d', &$pricevar);
     }
     $idInsert = BaseSingleton::insertOrEdit($sql, $params);
     if ($idInsert !== false && $priceId > 0) {
         $idInsert = $priceId;
     }
     return $idInsert;
 }
Esempio n. 3
0
 /**
  * Acheter des objets. Si un erreur arrive, annule toutes les transactions,
  * mais ne ferme pas la session.
  * 
  * @param String $obj_ids
  * @param String $trace
  * @param int $operator_id
  * @return int $state
  */
 public function multiselect($obj_ids, $trace, $operator_id)
 {
     $obj_ids = explode(',', $obj_ids);
     $prices = array();
     // récupération des ids, du prix
     foreach ($obj_ids as $value) {
         $obj_id = trim($value);
         $object = new Object($obj_id);
         $price = Price::getPrice($this->Buyer, $this->Point, $object);
         if (is_null($price)) {
             return -1;
         }
         $prices[$obj_id] = $price;
     }
     echo "COUCOU";
     echo "<pre>";
     print_r($prices);
     echo "</pre>";
     foreach ($prices as $key => $value) {
         echo $key . " " . $value . " " . $operator_id . "\n";
         $return = $this->select($key, $value, $trace, $operator_id);
         // si erreur, on annul tout
         if ($return != 1) {
             $this->cancelCart();
             return $return;
         }
     }
     return 1;
 }
 function fix($bill_id)
 {
     $products = $this->getByBillId($bill_id);
     $product = new Product();
     $price = new Price();
     $tax = new Tax();
     $bill = new Bill();
     $tmp = $bill->get($bill_id);
     $bill_data = $tmp[0];
     $customer = new Customer();
     $tmp = $customer->get($bill_data[1]);
     $customer_data = $tmp[0];
     for ($i = 0; $i < count($products); $i++) {
         $tmp = $this->getByBillIdAndProductId($bill_id, $products[$i][2]);
         $bill_product_data = $tmp[0];
         $tmp = $product->get($products[$i][2]);
         $product_data = $tmp[0];
         $tmp = $price->getPrice($customer_data[11], $product_data[0]);
         $price_data = $tmp[0];
         $tmp = $tax->get($product_data[4]);
         $tax_data = $tmp[0];
         $this->update($bill_product_data[0], array($bill_product_data[1], $bill_product_data[2], $bill_product_data[3], $bill_product_data[4], $bill_product_data[5], $price_data[3], $tax_data[2]));
     }
 }
        if ($remote_tmp[0] == $tmp[0]) {
            $found = true;
            break;
        }
    }
    $tmp_data = $product->get($tmp[0], array("name", "details", "category_id", "tax_id", "available", "group_id", "order_number", "anmerkung"));
    if (!$found) {
        $product_net->create($tmp[0], $tmp_data[0]);
        $new_product_count++;
    } else {
        $product_net->update($tmp[0], $tmp_data[0]);
    }
}
$main_box->add(new NTKLabel("", "neue Produkte online: " . $new_product_count), 200, 0, "background-color: #dfe7f3;");
$main_box->add(new NTKLabel("", "online Produkte gel&ouml;scht: " . $del_product_count), 200, 0, "background-color: #dfe7f3;");
// check for prices on products
$local_products = $product->get('', array('product_id'), " available=1 ");
$local_pricesets = $priceset->get('');
foreach ($local_products as $tmp) {
    foreach ($local_pricesets as $tmp_priceset) {
        $tmp_price = $price->getPrice($tmp_priceset[0], $tmp[0]);
        if (count($tmp_price) <= 0) {
            continue;
        }
        if ($price_net->exists($tmp_priceset[0], $tmp[0])) {
            $price_net->update($tmp_priceset[0], $tmp[0], array_slice($tmp_price[0], 3));
        } else {
            $price_net->create($tmp_priceset[0], $tmp[0], array_slice($tmp_price[0], 3));
        }
    }
}
$customer_data = $customer->get($_SESSION['username']);
$priceset_id = 0;
if (count($customer_data) > 0) {
    $priceset_id = $customer_data[0][11];
}
$tmp_priceset = $priceset->get($priceset_id);
$netto = 0;
if (count($tmp_priceset) > 0) {
    $netto = $tmp_priceset[0][2];
}
// prepare search/filter params
$product_id = var_get_post("product_id", "");
$list = $product->get($product_id);
// $count = $product->getCountByFilter($search_product, $search_category);
for ($i = 0; $i < count($list); $i++) {
    $tmp_price = $price->getPrice($priceset_id, $list[$i][0]);
    ?>

	<tr>
		<td rowspan="3" width="200px"><img src="Bilder/<?php 
    echo $list[$i][0];
    ?>
.jpg" width="200px"></td>
		<td align="center"><b><big><?php 
    echo $list[$i][1];
    ?>
</big></b><br><br></td>
	</tr>
	<tr>
		<td><font color="#8C8C8C">Produktnummer:</font> <?php 
    echo $list[$i][0];
Esempio n. 7
0
 /**
  * Verify valid constructor parameters cause no exceptions.
  *
  * @param mixed $type  The description of the price.
  * @param mixed $price The price of the price.
  *
  * @test
  * @dataProvider constructorGoodData
  *
  * @return void
  */
 public function constructWithValidParameters($type, $price)
 {
     $entity = new Price(['type' => $type, 'price' => $price]);
     $this->assertSame($type, $entity->getType());
     $this->assertSame($price, $entity->getPrice());
 }
Esempio n. 8
0
 /**
  * Vérifie si le prix est correct.
  * 
  * @param object $User
  * @param object $Point
  * @param object $Object
  * @param int $credit
  * @return int $state
  */
 public static function checkPrice(&$User, &$Point, &$Object, $credit)
 {
     //TODO vérifier suite aux modifs sur la requere des propositions
     $creditBDD = Price::getPrice($User, $Point, $Object);
     if (!is_null($creditBDD)) {
         if (is_null($credit) or $creditBDD == $credit) {
             return 1;
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
    case "delete":
        $bill->delete(var_get("bill_id", ""));
        if ($fp_tour_id != "") {
            $onload .= "location.href = 'tour.php?action=list_tour&tour_id=" . $fp_tour_id . "&date=" . $fp_date . "';";
        }
        break;
    case "position_add":
        $bill_data = $bill->get(var_post("bill_id", ""));
        /* autoset anmerkung vom produkt, wenn nichts als anmerkung gegeben */
        $details = var_post("details", "");
        if ($details == "") {
            $product_data = $product->get(var_post("product_id", ""));
            $details = $product_data[0][8];
        }
        if ($bill_data[0][5] == -1) {
            $bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), 0, 0));
        } else {
            $customer_data = $customer->get($bill_data[0][1]);
            $price_data = $price->getPrice($customer_data[0][11], var_post("product_id", ""));
            $product_data = $product->get(var_post("product_id", ""));
            $tax_data = $tax->get($product_data[0][4]);
            $bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), $price_data[0][3], $tax_data[0][2]));
        }
        break;
    case "position_delete":
        $bill_product->delete(var_get("bill_product_id", ""));
        break;
    case "position_edit":
        $bill_product->update(var_post("bill_product_id", ""), array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), var_post("details", ""), var_post("rabatt", ""), var_post("price", ""), var_post("tax", "")));
        break;
}