1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
function shopping_cart_to_html($summary){
$shopping_cart=pull_shopping_cart();
if(empty($shopping_cart)) return t("h2", "le caddie est vide");
$array=array();
foreach( $shopping_cart as $row){
$row["Voir"] =img_action_product(RES."/lt_photo.jpg", ACTION_GOTO_PRODUCT, $row['ref']);
$row["Effacer"]=img_action_product(RES."/rm_cart.jpg", ACTION_REMOVE_CART, $row['ref']);
array_push($array, $row) ; }
return catalog_to_html($array, $summary); }
function pull_shopping_cart(){
init_session();
if(!isset($_SESSION['SESSION_CART'])) $_SESSION['SESSION_CART'] = array();
return $_SESSION['SESSION_CART']; }
function img_action_product($img, $action, $ref)
{
$content = t("input", "", att("type", "hidden").att("name", REQ_ACTION).att("value",$action));
$content.=t("input","",att("type", "hidden").att("name", REQ_REF).att("value", $ref));
$content.=t("input", "",att("type","image").att("name","submit").att("src",$img));
return t("form", $content, att("action", CONTROLEUR).att("method", "get"));}
function catalog_to_html($table_name, $summary)
{
connect_select_db();
$result=mysql_query("SHOW COLUMNS FROM catalogue");
$html_head="";
$class="odd";
while($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
$html_head .= t("th", $row["Field"]);
}
$html_head .= t("th", "Voir");
$html_head .= t("th","Acheter");
//$html_head .= t("thead", t("tr", $html_head));
$html_body ="";
$class="odd";
$result=mysql_query("SELECT * FROM catalogue");
while($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
$html_row=""; $class=($class=="even"?"odd":"even");
foreach($row as $att) $html_row .= t("td", $att);
$html_row .=t("td", img_action_product(RES."/lt_photo.jpg", ACTION_GOTO_PRODUCT, $row['ref']));
$html_row .=t("td", img_action_product(RES."/add_cart.jpg", ACTION_ADD_CART, $row['ref']));
$html_body .=t("tr", $html_row, att("class", $class));
}
$html_body=t("tbody", $html_body);
$html_body=t("tbody", $html_body);
$html_table=$html_head.$html_body;
$align="center";
$html_table=t("div", $html_table);
$table= t("table", $html_table, att("summary", $summary));
$table= t("div", $table,att("align", "center"));
return $table;
} |