예제 #1
0
파일: cg35.php 프로젝트: kyfr59/cg35
/**
 * 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
파일: item-share.php 프로젝트: kyfr59/cg35
    <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);
}