osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> [résolu] ajout d'une fonctionalité sur une contrib, requete sql
flcflc
posté 16 Aug 2007, 07:24
Message #1


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 178
Inscrit : 19-January 05
Membre no 4435



Bonjour,

J'ai un problème avec la contrib PDF_CATALOGUE. Je voudrai modifier une requête de façon à pouvoir ajouter une id-login
dans la requête d'impression du catalogue PDF.

Le but étant de pouvoir personnaliser le catalogue en fonction du fabricant.

id_login existe bien et quand je l'appele dans la page html, elle est bien là.
Or quand je l'intègre dans la fonction, la valeur est de zéro.

Voici la requete présente dans la fonction suivante
CODE
$requete_prod="select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_model, pd.products_matiere, pd.products_style, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name, m.manufacturers_first from (" . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where m.manufacturers_id='" . $login_id . "' and (p.products_status = '1' or p.products_status = '2') and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id='".$current_category_id."' order by pd.products_name, p.products_date_added DESC";


avec cet ajout
CODE
m.manufacturers_id='" . $login_id . "'


puis l'appel de la fonction dans une boucle pour la création d'un fichier par langue
CODE
$pdf->CategoriesListing($languages[$i]['id'],$languages[$i]['code']);


donc rien de bien extraordinaire et pourtant, je sèche...



Détail de la fonction du fichier pdf_catalogue.php de l'admin

CODE
function CategoriesListing($languages_id, $languages_code)
{  
    $this->products_index_array=array();
    $this->products_index_list='';
    $this->index_lenght=0;

    //Recuperation de toutes les categories dans l'ordre
    $categoriesidarray=explode(" ",$this->categories_id);
    $categoriesnamearray=explode("\n",$this->categories_string);
    $categorieslevelsarray=explode(" ",$this->levels);
      
    //Convertion pixels -> mm
    $imagewidth=SMALL_IMAGE_WIDTH*PDF_TO_MM_FACTOR;
    $imageheight=SMALL_IMAGE_HEIGHT*PDF_TO_MM_FACTOR;

    for($i=0; $i<sizeof($categoriesidarray)-1; $i++) {
        $category_count_products = tep_products_in_category_count($categoriesidarray[$i],'false');
        if (!((!SHOW_EMPTY_CATEGORIES) and ($category_count_products < 1))) {
            $taille=0;
            $current_category_id=$categoriesidarray[$i];
            $current_category_name=$categoriesnamearray[$i];
            $current_category_level=$categorieslevelsarray[$i];
            $requete_prod="select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_model, pd.products_matiere, pd.products_style, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name, m.manufacturers_first from (" . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where m.manufacturers_id='" . $login_id . "' and (p.products_status = '1' or p.products_status = '2') and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id='".$current_category_id."' order by pd.products_name, p.products_date_added DESC";
                              
            $SHOW_catalog_query = tep_db_query($requete_prod);
            while ($print_catalog = tep_db_fetch_array($SHOW_catalog_query)) {
                $print_catalog_array[$taille++] = array(
                                  'id' => $print_catalog['products_id'],
                            'name' => $print_catalog['products_name'],                                  
                    'description' => $print_catalog['products_description'],
                          'model' => $print_catalog['products_model'],
                            'image' => $print_catalog['products_image'],
                            'price' => $print_catalog['products_price'],                        
                    'specials_price' => $print_catalog['specials_new_products_price'],
                           'tax_class_id' => $print_catalog['products_tax_class_id'],
                           'date_added' => tep_date_long($print_catalog['products_date_added']),
                               'manufacturer' => $print_catalog['manufacturers_name']);
            }

            //Forschung der Name der Vaterkategorie
            $this->parent_category_name='';
            $this->ParentsName($current_category_level,$i,$categorieslevelsarray, $categoriesnamearray);
                            
            if (($current_category_level == 1) and (CATEGORIES_PAGE_SEPARATOR)) {
                $this->AddPage();
                $this->Ln(120);
                $this->SetFont('Arial','',12);
                $titles_color_table=explode(",",CENTER_TITLES_CELL_COLOR);
                $this->SetFillColor($titles_color_table[0], $titles_color_table[1], $titles_color_table[2]);
                $this->Cell(45,5,"",0,0);
                $this->MultiCell(100,10,$current_category_name,1,'C',1);
            }
    
            if ($taille > 0) { // categorie non vide
                $this->AddPage();
                if (strlen($this->parent_category_name) > 0 ) {
                    $this->TitreChapitre($this->parent_category_name. CATEGORIES_SEPARATOR .$current_category_name);
                } else {
                    $this->TitreChapitre($current_category_name);
                }
                $this->Ln(3); // NH
                $this->SetFont('Arial','',11);

                for($j=0; $j<$taille; $j++ ) {
                    // NH si pas d'image definie, image par default
                    if (strlen($print_catalog_array[$j]['image']) > 0 && file_exists(DIR_FS_CATALOG.DIR_WS_IMAGES.$print_catalog_array[$j]['image'])) {
                        $imagepath=DIR_FS_CATALOG.DIR_WS_IMAGES.$print_catalog_array[$j]['image'];
                    } else {
                        $imagepath=DIR_FS_CATALOG.DIR_WS_IMAGES.DEFAULT_IMAGE;
                        echo 'The product "'.$print_catalog_array[$j]['name'].'" has no picture. I use the generic picture: '.DEFAULT_IMAGE.'<br>';
                    }
                    $id=$print_catalog_array[$j]['id'];
                    $name=rtrim(strip_tags($print_catalog_array[$j]['name']));
                    $model=rtrim(strip_tags($print_catalog_array[$j]['model']));
                    $description=rtrim(strip_tags($print_catalog_array[$j]['description']));
                    $manufacturer=rtrim(strip_tags($print_catalog_array[$j]['manufacturer']));
                    $price=rtrim(strip_tags($print_catalog_array[$j]['price']));
                    $specials_price=rtrim(strip_tags($print_catalog_array[$j]['specials_price']));
                    $tax_class_id=rtrim(strip_tags($print_catalog_array[$j]['tax_class_id']));
                    $date_added=rtrim(strip_tags($print_catalog_array[$j]['date_added']));
            
                    $data_array=array($imagewidth,$imageheight,$name,$model,$date_added,$manufacturer,$description,$tax_class_id,$specials_price,$price,$id,$languages_code,$imagepath);
                    $this->Ln(PRODUCTS_SEPARATOR); // NH blank space before the products description cells
                    $this->DrawCells($data_array);
                    if (SHOW_INDEX) {
                        switch (INDEX_EXTRA_FIELD) {
                            case 1 : $this->PrepareIndex($name,$manufacturer,$current_category_name);
                                    break;
                            case 2 : $this->PrepareIndex($name,$model,$current_category_name);
                                    break;
                            case 3 : $this->PrepareIndex($name,$date_added,$current_category_name);
                                    break;
                           default : $this->PrepareIndex($name,"",$current_category_name);
                        }
                    }
                }
            }
        }
    }  
}


Ce message a été modifié par flcflc - 16 Aug 2007, 09:01.


--------------------
CRE_Loaded_OSC_6.0_SP1.2 + patchs + contrib
Go to the top of the page
 
shoprun
posté 16 Aug 2007, 07:58
Message #2


2eme dan OSC
Icône de groupe

Groupe : Membres VIP
Messages : 3712
Inscrit : 11-April 07
Lieu : Ile de la Réunion
Membre no 16487



Salut

J'ai comme l'impression que function CategoriesListing() est une fonction qui ce trouve dans une classe (genre CategoriesListing), non?

Si c'est le cas, $login_id n'est pas visible dans CategoriesListing(), et c'est normal.

Toujours dans ce cas, tu as 2 solutions :
1/ Soit tu rajoute ce paramètre :
CITATION
function CategoriesListing($languages_id, $languages_code, $login_id) {
...
...
}
2/ Soit tu rend cette variable visible de manière globale :
CITATION
function CategoriesListing($languages_id, $languages_code) {
global $login_id;
...
...
}

Essai pour voir.


--------------------
Nous ne sommes pas un Service Après-Vente ni une Hot-Line !!!, et pas de "UP" et de doublon svp ...
Prenez le temps de lire les informations mises à votre dispositions avant de créer un sujet.
Démarrer du bon pied -> Bien utiliser les forums | Bien poser sa question | Règles d'usage des forums
Prés-Requis -> Les compétences requises pour réussir avec osCommerce
Docs / Infos -> LA FAQ | Rechercher | Contributions | Contribution US
Sujets épinglés -> Manuel d'utilisation MS2 | Structure OsC2.2 MS2 | ms2-fr-rc1-w3c | SSL : une obligation? | Design de la MS2 | Tutoriels CSS | Optimisez les performances de votre boutique | Taux de TVA à appliquer
Utile -> WampServer | EasyPhp | Xampp | Mamp - Ftp -> FileZilla
Apprendre -> siteduzero | alsacreations | apprendre-php | developpez.com
Go to the top of the page
 
flcflc
posté 16 Aug 2007, 09:03
Message #3


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 178
Inscrit : 19-January 05
Membre no 4435



mille sabords, un global!

shoprun la deuxième option fonctionne. Merci


--------------------
CRE_Loaded_OSC_6.0_SP1.2 + patchs + contrib
Go to the top of the page
 

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 22nd May 2013 - 10:57
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)