Beispiel #1
0
function get_wines_list($admin = false, $formating = 'plain')
{
    global $mysql, $return;
    $sql = 'SELECT 
							v_list_vins.id_produit AS id,
							v_list_vins.prix_vente AS prix_vente,
							v_list_vins.millesime AS millesime,
							v_list_vins.producteur AS producteur,
							v_list_vins.nom AS nom,
							v_list_vins.appelation AS appelation,
							v_list_vins.id_region_du_monde AS id_region_du_monde
	 						FROM v_list_vins';
    $query = $mysql->sql_query($sql);
    while ($result = mysqli_fetch_assoc($query)) {
        $item = new Wine($result, $formating);
        switch ($result['parent']) {
            case 'sous-region':
                $id = get_id_from_result($result, 'sous_region');
                add_to_sous_region($id, $item, $result);
                break;
            case 'region':
                $id = get_id_from_result($result, 'region');
                add_to_region($id, $item, $result);
                break;
            case 'pays':
                $id = get_id_from_result($result, 'pays');
                add_to_pays($id, $item, $result);
                break;
            case 'region-monde':
                $id = get_id_from_result($result, 'region_du_monde');
                add_to_region_du_monde($id, $item, $result);
                break;
            case 'catvin':
                $id = get_id_from_result($result, 'cat_vin');
                add_to_category($id, $item, $result);
                break;
        }
    }
    echo '<pre>';
    print_r($return);
    echo '</pre>';
    return $return;
}
Beispiel #2
0
function get_wines_list($admin = false, $formating = 'plain')
{
    global $mysql, $return;
    switch ($admin) {
        case 'true':
            $admin_table = '_admin';
            $table = 't_output_vins_admin';
            break;
        case false:
            $table = 't_output_vins';
            $admin_table = '';
            break;
        case 'preview':
            $table = 't_preview';
            $admin_table = '_admin';
            break;
    }
    $sql = <<<EOS
\t      SELECT
\t        {$table}.id_produit as id,
\t        {$table}.type as type,
\t        {$table}.parent as parent,
\t        {$table}.sys_order as sys_order,
\t        {$table}.label as label,
\t        
\t        v_list_vins.id_cat_vin as cat_vin_vin,
        \tt_promotions{$admin_table}.id_cat_vin as cat_vin_promo,
        \tt_output_vins_verre{$admin_table}.id_cat_vin as cat_vin_verre,
\t\t\t\t\tt_output_demi_bouteilles{$admin_table}.id_cat_vin as cat_vin_demi,
        \t
        \tv_list_vins.id_region_du_monde as region_du_monde_vin,
        \tt_promotions{$admin_table}.id_region_du_monde as region_du_monde_promo,
        \tt_output_vins_verre{$admin_table}.id_region_du_monde as region_du_monde_verre,
\t\t\t\t\tt_output_demi_bouteilles{$admin_table}.id_region_du_monde as region_du_monde_demi,
        \t
        \tv_list_vins.id_pays as pays_vin,
        \tt_promotions{$admin_table}.id_pays as pays_promo,
        \tt_output_vins_verre{$admin_table}.id_pays as pays_verre,
\t        t_output_demi_bouteilles{$admin_table}.id_pays as pays_demi,
\t
        \tv_list_vins.id_region as region_vin,
        \tt_promotions{$admin_table}.id_region as region_promo,
        \tt_output_vins_verre{$admin_table}.id_region as region_verre,
\t\t\t\t\tt_output_demi_bouteilles{$admin_table}.id_region as region_demi,
        \t
        \tv_list_vins.id_sous_region as sous_region_vin,
        \tt_promotions{$admin_table}.id_sous_region as sous_region_promo,
        \tt_output_vins_verre{$admin_table}.id_sous_region as sous_region_verre,
        \tt_output_demi_bouteilles{$admin_table}.id_sous_region as sous_region_demi,

        \tt_promotions{$admin_table}.titre as titre,
        \t
        \tv_list_vins.prix_vente as prix_vente,
        \tv_list_vins.millesime as millesime,
        \tv_list_vins.producteur as producteur,
        \tv_list_vins.nom as nom,
        \tv_list_vins.appelation as appelation,
\t\t\t\t\tv_list_vins.demi_bouteille as demi_bouteille,
\t\t\t\t\tv_list_vins.bio as bio,
\t\t\t\t\tv_list_vins.id_cat_vin as id_cat_vin,
\t\t\t\t\tv_list_vins.id_region_du_monde as id_region_du_monde,
\t\t\t\t\tv_list_vins.id_pays as id_pays,
\t\t\t\t\tv_list_vins.id_region as id_region,
\t\t\t\t\tv_list_vins.id_sous_region as id_sous_region
          
        FROM
        \t{$table}
          
        LEFT JOIN
        \tv_list_vins ON {$table}.id_produit = v_list_vins.id_produit
        \t
        LEFT JOIN
        \tt_promotions{$admin_table} ON {$table}.id_produit = t_promotions{$admin_table}.id
        
        LEFT JOIN
          t_output_vins_verre{$admin_table} ON {$table}.id_produit = t_output_vins_verre{$admin_table}.id
          
\t\t\t\tLEFT JOIN
\t        t_output_demi_bouteilles{$admin_table} ON {$table}.id_produit = t_output_demi_bouteilles{$admin_table}.id

        ORDER BY
        \tsys_order
EOS;
    $query = $mysql->sql_query($sql);
    while ($result = mysqli_fetch_assoc($query)) {
        if ($result['type'] == "vin") {
            $item = new Wine($result, $formating);
        } else {
            if ($result['type'] == "promo") {
                $item = new Promo($result);
            } else {
                if ($result['type'] == "vins-au-verre") {
                    $item = new VinsAuVerre($result);
                } else {
                    if ($result['type'] == "vin-au-verre") {
                        $item = new Wine($result, $formating);
                    } else {
                        $item = new DemiBouteilles($result);
                    }
                }
            }
        }
        switch ($result['parent']) {
            case 'sous-region':
                $id = get_id_from_result($result, 'sous_region');
                add_to_sous_region($id, $item, $result);
                break;
            case 'region':
                $id = get_id_from_result($result, 'region');
                add_to_region($id, $item, $result);
                break;
            case 'pays':
                $id = get_id_from_result($result, 'pays');
                add_to_pays($id, $item, $result);
                break;
            case 'region-monde':
                $id = get_id_from_result($result, 'region_du_monde');
                add_to_region_du_monde($id, $item, $result);
                break;
            case 'catvin':
                $id = get_id_from_result($result, 'cat_vin');
                add_to_category($id, $item, $result);
                break;
        }
    }
    return $return;
}