Пример #1
0
/**
 * Add an item to the cart 
 * @param $dbname The name of the database (e.g. instance of Omeka)
 * @param $item_id The ID of the item
 * @return false|interger Returns the number of item in the user's cart, otherwhise false
 */
function add_to_cart($dbname, $item_id)
{
    if (isset($dbname) && isset($item_id) && ($user_id = get_connected_user_id())) {
        if (!is_in_cart($dbname, $item_id)) {
            $masterdb = get_master_db();
            $table_name = $masterdb->getConfig()['prefix'] . 'carts';
            $result = $masterdb->insert($table_name, array('user_id' => $user_id, 'dbname' => $dbname, 'item_id' => $item_id));
        }
        return count(get_cart());
    }
    return false;
}
Пример #2
0
    <a target="_blank" style="outline:none;" title="Télécharger" href="<?php 
echo getenv("INSTANCE_URL");
?>
/items/print/id/<?php 
echo $item->id;
?>
"><img src="<?php 
echo WEB_THEME;
?>
/cg35/images/item-download.png"></a>

    <?php 
if (get_connected_user_id()) {
    ?>
        <?php 
    if (!is_in_cart(get_current_instance_name(), $item->id)) {
        ?>
        <a style="outline:none;" title="Mettre au panier" id="add-to-cart-2" href="#"><img src="<?php 
        echo WEB_THEME;
        ?>
/cg35/images/item-cart.png"></a>
        <?php 
    }
    ?>
    <?php 
} else {
    ?>
        <a style="outline:none;" href="<?php 
    echo MASTER_URL;
    ?>
/users/login" ><img src="<?php 
Пример #3
0
    
    <?php 
if (get_connected_user_id()) {
    ?>
        <!-- Add to cart functionality (hidden) -->
        <div id="cart-status" style="display:none;">
            <img id="added-to-cart" src="<?php 
    echo WEB_THEME;
    ?>
/cg35/images/add-to-cart-ok.png" border="0" style="display:<?php 
    echo !is_in_cart(get_current_instance_name(), $item->id) ? 'none' : 'block';
    ?>
"/>
            <span class="fa fa-cart-plus" id="picto-cart"></span>
            <a href="" id="add-to-cart" style="display:<?php 
    echo is_in_cart(get_current_instance_name(), $item->id) ? 'none' : 'block';
    ?>
"></a>
        </div>
    <?php 
}
?>


    <div id="search-container" role="search">
        <?php 
echo search_form();
?>
        <a href="<?php 
echo getenv("INSTANCE_URL");
?>
Пример #4
0
if (isset($_POST['recalc'])) {
    update_session();
} elseif (isset($_POST['delete'])) {
    update_session();
    if (isset($_POST['mark'])) {
        $marked = $_POST['mark'];
        foreach ($marked as $symb) {
            del_from_cart('cart', $symb);
        }
    }
} elseif (isset($_POST['watch'])) {
    update_session();
    if (isset($_POST['mark'])) {
        $marked = $_POST['mark'];
        foreach ($marked as $symb) {
            if (!is_in_cart('watch', $symb)) {
                if (add_to_cart('watch', $symb, $_POST["comment_{$symb}"], $_POST["volume_{$symb}"])) {
                    del_from_cart('cart', $symb);
                }
            }
        }
    }
} elseif (isset($_POST['buy'])) {
    update_session();
    if (isset($_POST['mark'])) {
        $marked = $_POST['mark'];
        foreach ($marked as $symb) {
            if (buy_stock($symb, $_POST["comment_{$symb}"], $_POST["volume_{$symb}"])) {
                del_from_cart('cart', $symb);
            }
        }
Пример #5
0
 }
 print "<tr>";
 // setup the first row of the table with the symbol details and the chance to add it to the cart or watch list
 if (!isset($row['symb'])) {
     die('<tr><td><font color="red">The Query must include the field "symb"</font></td></tr></table>');
 } else {
     $symbol = $row['symb'];
     $name = get_symb_name_coloured($symbol, $pf_exch, $pfid, $pf_working_date);
     print '<tr><td><table border="0" cellpadding="0" cellspacing="0" align="left"><tr>';
     print "<td><a href=\"/inspector.php?symb={$symbol}\" target=\"_blank\">{$symbol}</a>: {$name}</td></tr>";
     if (is_in_cart('cart', $symbol)) {
         print "<tr><td>Buying:</td></tr>\n";
     } else {
         print "<tr><td><input type=\"checkbox\" name=\"buy[]\" value=\"{$symbol}\">Buy</td></tr>\n";
     }
     if (is_in_cart('watch', $symbol)) {
         print "<tr><td>Watching:</td></tr>\n";
     } else {
         print "<tr><td><input type=\"checkbox\" name=\"watch[]\" value=\"{$symbol}\">Watch</td></tr>\n";
     }
     print '</table>';
     // print the rest of the selected rows into the table
     foreach ($headers as $index) {
         if ($index != 'symb') {
             if (isset($_SESSION['chart'])) {
                 print "<td><table><tr><td>{$index}</td></tr>";
                 print "<tr><td>{$row[$index]}</td></tr></table></td>\n";
             } else {
                 print "<td>{$row[$index]}</td>\n";
             }
         }
Пример #6
0
    }
    if (isset($_POST['chart_period'])) {
        $_SESSION['chart_period'] = $_POST['chart_period'];
    } else {
        unset($_SESSION['chart_period']);
    }
}
if (isset($_POST['recalc'])) {
    update_session();
} elseif (isset($_POST['delete'])) {
    update_session();
    if (isset($_POST['mark'])) {
        $marked = $_POST['mark'];
        foreach ($marked as $symb) {
            del_from_cart('watch', $symb);
        }
    }
} elseif (isset($_POST['cart'])) {
    update_session();
    if (isset($_POST['mark'])) {
        $marked = $_POST['mark'];
        foreach ($marked as $symb) {
            if (!is_in_cart('cart', $symb)) {
                if (add_to_cart('cart', $symb, $_POST["comment_{$symb}"], $_POST["volume_{$symb}"])) {
                    del_from_cart('watch', $symb);
                }
            }
        }
    }
}
draw_watch_table($pf_id, $pf_working_date, $pf_exch, $pf_name);
Пример #7
0
function is_in_portfolio($symb, $pfid)
{
    // lookup holdings to see if the symbol's there
    return is_in_cart('holdings', $symb);
}