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] Admin/Customers.php
jame
posté 22 Sep 2003, 14:53
Message #1


Ceinture jaune+ OSC
Icône de groupe

Groupe : Membres
Messages : 97
Inscrit : 10-June 03
Lieu : Nord Est
Membre no 1226



Au secours, je crois que mes nerfs vont lacher ...

J'essaie de faire une requête sur 3 tables avec jointure et j'arrive plus. J'ai du louper un wagon ...

Dans Admin puis liste des clients, je cherche à visualiser dans le tableau principale :
la date de la dernière connexion de chaque client ainsi que le nombre de connexions.Ce serais trop simple s'il n'y avait pas la cerise sur la gateau : (classer par ordre décoissant date de dernière connexion)

Et là c'est tout autre, il faut impérativement modifier cette requete :

Dans Admin/customers.php il y a la requete suivante (vers la ligne 469)
CODE
$customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, customers_status, a.entry_country_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by c.customers_lastname, c.customers_firstname";


Je n'arrive pas à y mettre la table customers_info et y récupéré les champs customers_info_date_account_created et customers_info_number_of_logons

cry.gif


--------------------
Version 2.2 MS1 CREload5 (Delaballe) + contribs + bidouilles
Go to the top of the page
 
Gnidhal
posté 22 Sep 2003, 19:46
Message #2


5eme dan OSC
Icône de groupe

Groupe : Administrateur
Messages : 9221
Inscrit : 4-March 03
Lieu : Pau
Membre no 927



bon, pour la requête sur 3 tables, voilà, mais après faut gérer le fetch_array, car ça fout en l'air la suite du code. Mais tu as peut-être prévu ça ...
en tous cas, avec cette requête, tu récupères les valeurs demandées dans la table customers_info avec une correspondance sur l'id.
CODE
   $customers_query_raw = "select i.customers_info_date_account_created, i.customers_info_number_of_logons, c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id  from " . TABLE_CUSTOMERS_INFO . " i left join " . TABLE_CUSTOMERS . " c on i.customers_info_id = c.customers_id left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by c.customers_lastname, c.customers_firstname";



d'ailleurs tu avais un loup dans ta requête avec un customers_status qui n'est affecté à aucune table.
Mais cela fait peut-être partie de tes modifs ?


--------------------
Tout d'abord : - Ni Hotline ni Service Après Vente, ces forums sont un lieu d'échange. BIEN POSER SA QUESTION (généralités)
Les "Informations Importantes" que vous devez ABSOLUMENT avoir lues :
Règlement, Bien poser sa question dans ces forums et Bien utiliser les Forums.
Les raccourcis pour gagner du temps : la FAQ, les PDF de la Doc (MS2-fr): PDF-V1 et PDF-V2, le moteur de Recherche sur les forums , la Liste des Contributions de Corbin.

----------------------------- Quelques sites de référence ---------------------------
PHP: Le site du Zéro et PHP Débutant avec la DOC en français -- HTML: Self HTML - WebProgrammation -- CSS: OpenWeb - AlsaCréations - CSS/Edge -- Autres ressources: - XajaX - highslide js
Les bons outils : EasyPHP - WAMP-5 - - Notepad++ - Firefox et son extension WebDeveloper
Le gène idéal c'est le gène original. Le génie des halles est un Génie des Alpages qui tente d'être à la page. (Merci f'murrr pour les cours de philosophie de chien)
Go to the top of the page
 
jame
posté 23 Sep 2003, 07:37
Message #3


Ceinture jaune+ OSC
Icône de groupe

Groupe : Membres
Messages : 97
Inscrit : 10-June 03
Lieu : Nord Est
Membre no 1226



Merci pour la technique de la jointure.
Mon problème est de faire un tri par la date du dernier accès.

Si je met cela à la fin de la requete:
CODE
order by i.customers_info_number_of_logons DESC

j'obtiens bien le tri descendant sur le nombre d'accès

par contre si je met :
CODE
order by i.customers_info_date_account_created DESC

Le tri est donne n'importe quoi !

Ma question est la suivante : Peut-on faire un tri sur le champ date ?
Le faite d'afficher seulement la date sous la forme jj/mm/aaaa grâce à
CODE
tep_date_short
ne change rien eu résultat de la recherche

Je n'arrive pas à trouver la logique de ce tri. Peut être est-ce au niveau des jointures qu'il faut jouer pour obtenir le résultat souhaité ? ? ?

rolleyes.gif


--------------------
Version 2.2 MS1 CREload5 (Delaballe) + contribs + bidouilles
Go to the top of the page
 
Gnidhal
posté 23 Sep 2003, 13:34
Message #4


5eme dan OSC
Icône de groupe

Groupe : Administrateur
Messages : 9221
Inscrit : 4-March 03
Lieu : Pau
Membre no 927



Bah heuuuu oui wink.gif

enfin d'après ce que j'ai compris de mysql en fonction de la doc,
- tu fais une requête SELECT de données FROM une table avec ou sans jointure LEFT JOIN autre table, ON (condition de jointure) WHERE condition externe = resultat ORDER BY pour un tri de sorti.

Le tri est réalisé après la récupération des données, donc dans la séquence de stockage du tableau de résultat.

Pour les jointures multiples il est conseillé de traiter les référence par hierarchie en considérant la table principale comme centrale (celle où on retrouve les index communs)

Le ORDER BY doit impérativement se faire en dernier.
le tri sur un champ "date" est tout à fait possible puisque l'homogénéité des données est assuré par le format du champ : timestamp, datetime...

La fonction tep_date_short n'affecte que la remise en forme du champ datetime de la table dans un ordre lisible lié à la convention de langage donc bien après l'opération de tri qui se fait dans la requête.

En bref, je ne vois pas pourquoi ça ne fonctionne pas.
Mais peut-être qu'en piochant dans la doc mysql tu trouveras ta solution confused.gif


--------------------
Tout d'abord : - Ni Hotline ni Service Après Vente, ces forums sont un lieu d'échange. BIEN POSER SA QUESTION (généralités)
Les "Informations Importantes" que vous devez ABSOLUMENT avoir lues :
Règlement, Bien poser sa question dans ces forums et Bien utiliser les Forums.
Les raccourcis pour gagner du temps : la FAQ, les PDF de la Doc (MS2-fr): PDF-V1 et PDF-V2, le moteur de Recherche sur les forums , la Liste des Contributions de Corbin.

----------------------------- Quelques sites de référence ---------------------------
PHP: Le site du Zéro et PHP Débutant avec la DOC en français -- HTML: Self HTML - WebProgrammation -- CSS: OpenWeb - AlsaCréations - CSS/Edge -- Autres ressources: - XajaX - highslide js
Les bons outils : EasyPHP - WAMP-5 - - Notepad++ - Firefox et son extension WebDeveloper
Le gène idéal c'est le gène original. Le génie des halles est un Génie des Alpages qui tente d'être à la page. (Merci f'murrr pour les cours de philosophie de chien)
Go to the top of the page
 
jame
posté 24 Sep 2003, 06:50
Message #5


Ceinture jaune+ OSC
Icône de groupe

Groupe : Membres
Messages : 97
Inscrit : 10-June 03
Lieu : Nord Est
Membre no 1226



Moi y'en a pas comprendre non plus cry.gif

Je vais me repencher sur ce problème mais je commence à perdre patiente... Je remet quand même ma requete au cas ou quelqu'un aurait un flash

admin/customers.php
CODE
$customers_query_raw = "select i.customers_info_date_account_created, i.customers_info_number_of_logons, c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id, c.customers_status  from " . TABLE_CUSTOMERS_INFO . " i left join " . TABLE_CUSTOMERS . " c on i.customers_info_id = c.customers_id left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by i.customers_info_date_account_created DESC";


--------------------
Version 2.2 MS1 CREload5 (Delaballe) + contribs + bidouilles
Go to the top of the page
 
jame
posté 24 Sep 2003, 13:09
Message #6


Ceinture jaune+ OSC
Icône de groupe

Groupe : Membres
Messages : 97
Inscrit : 10-June 03
Lieu : Nord Est
Membre no 1226



Quelqu'un aurait-il la bontée de faire un essai et de me dire ce qui cloche

Le tri par la date de dernière connexion ne fonctionne pas !

Voir le code mis en cause dans le code ci-dessous (en couleur)

Voici mon fichier admin/customers.php :
QUOTE

<?php
/*
 $Id: customers.php,v 1.3 2003/02/15 23:45:28 wilt Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright © 2002 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 if ($HTTP_GET_VARS['action']) {
   switch ($HTTP_GET_VARS['action']) {

case 'setflag':
  if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
     if ($HTTP_GET_VARS['cID']) {
   tep_set_customers_status($HTTP_GET_VARS['cID'], $HTTP_GET_VARS['flag']);
 }
    }
 
  tep_redirect(tep_href_link(FILENAME_CUSTOMERS, '', 'NONSSL'));
  break;

     case 'update':
       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
       $customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);
       $customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);
       $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
       $customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);
       $customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);
       $customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);

       $customers_gender = tep_db_prepare_input($HTTP_POST_VARS['customers_gender']);
       $customers_dob = tep_db_prepare_input($HTTP_POST_VARS['customers_dob']);

       $sql_data_array = array('customers_firstname' => $customers_firstname,
                               'customers_lastname' => $customers_lastname,
                               'customers_email_address' => $customers_email_address,
                               'customers_telephone' => $customers_telephone,
                               'customers_fax' => $customers_fax,
                               'customers_newsletter' => $customers_newsletter);

       if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;
       if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob);

       tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', \"customers_id = '\" . tep_db_input($customers_id) . \"'\");

       tep_db_query(\"update \" . TABLE_CUSTOMERS_INFO . \" set customers_info_date_account_last_modified = now() where customers_info_id = '\" . tep_db_input($customers_id) . \"'\");

       $default_address_id = tep_db_prepare_input($HTTP_POST_VARS['default_address_id']);
       $entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);
       $entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);
       $entry_postcode = tep_db_prepare_input($HTTP_POST_VARS['entry_postcode']);
       $entry_city = tep_db_prepare_input($HTTP_POST_VARS['entry_city']);
       $entry_country_id = tep_db_prepare_input($HTTP_POST_VARS['entry_country_id']);

       $entry_company = tep_db_prepare_input($HTTP_POST_VARS['entry_company']);
       $entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);
       $entry_zone_id = tep_db_prepare_input($HTTP_POST_VARS['entry_zone_id']);
       if ($entry_zone_id > 0) $entry_state = '';

       $sql_data_array = array('entry_firstname' => $customers_firstname,
                               'entry_lastname' => $customers_lastname,
                               'entry_street_address' => $entry_street_address,
                               'entry_postcode' => $entry_postcode,
                               'entry_city' => $entry_city,
                               'entry_country_id' => $entry_country_id);

       if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;
       if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;
       if (ACCOUNT_STATE == 'true') {
         $sql_data_array['entry_state'] = $entry_state;
         $sql_data_array['entry_zone_id'] = $entry_zone_id;
       }

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', \"customers_id = '\" . tep_db_input($customers_id) . \"' and address_book_id = '\" . tep_db_input($default_address_id) . \"'\");

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));
       break;
     case 'deleteconfirm':
       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

       if ($HTTP_POST_VARS['delete_reviews'] == 'on') {
         $reviews_query = tep_db_query(\"select reviews_id from \" . TABLE_REVIEWS . \" where customers_id = '\" . tep_db_input($customers_id) . \"'\");
         while ($reviews = tep_db_fetch_array($reviews_query)) {
           tep_db_query(\"delete from \" . TABLE_REVIEWS_DESCRIPTION . \" where reviews_id = '\" . $reviews['reviews_id'] . \"'\");
         }
         tep_db_query(\"delete from \" . TABLE_REVIEWS . \" where customers_id = '\" . tep_db_input($customers_id) . \"'\");
       } else {
         tep_db_query(\"update \" . TABLE_REVIEWS . \" set customers_id = null where customers_id = '\" . tep_db_input($customers_id) . \"'\");
       }

       tep_db_query(\"delete from \" . TABLE_ADDRESS_BOOK . \" where customers_id = '\" . tep_db_input($customers_id) . \"'\");
       tep_db_query(\"delete from \" . TABLE_CUSTOMERS . \" where customers_id = '\" . tep_db_input($customers_id) . \"'\");
       tep_db_query(\"delete from \" . TABLE_CUSTOMERS_INFO . \" where customers_info_id = '\" . tep_db_input($customers_id) . \"'\");
       tep_db_query(\"delete from \" . TABLE_CUSTOMERS_BASKET . \" where customers_id = '\" . tep_db_input($customers_id) . \"'\");
       tep_db_query(\"delete from \" . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . \" where customers_id = '\" . tep_db_input($customers_id) . \"'\");
       tep_db_query(\"delete from \" . TABLE_WHOS_ONLINE . \" where customer_id = '\" . tep_db_input($customers_id) . \"'\");

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))));  
       break;
   }
 }
?>
<!doctype html public \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=<?php echo CHARSET; ?>\">
<title><?php echo TITLE; ?></title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"includes/stylesheet.css\">
<script language=\"javascript\" src=\"includes/general.js\"></script>
<?php
 if ($HTTP_GET_VARS['action'] == 'edit') {
?>
<script language=\"javascript\"><!--
function resetStateText(theForm) {
 theForm.entry_state.value = '';
 if (theForm.entry_zone_id.options.length > 1) {
   theForm.entry_state.value = '<?php echo JS_STATE_SELECT; ?>';
 }
}

function resetZoneSelected(theForm) {
 if (theForm.entry_state.value != '') {
   theForm.entry_zone_id.selectedIndex = '0';
   if (theForm.entry_zone_id.options.length > 1) {
     theForm.entry_state.value = '<?php echo JS_STATE_SELECT; ?>';
   }
 }
}

function update_zone(theForm) {
 var NumState = theForm.entry_zone_id.options.length;
 var SelectedCountry = '';

 while(NumState > 0) {
   NumState--;
   theForm.entry_zone_id.options[NumState] = null;
 }

 SelectedCountry = theForm.entry_country_id.options[theForm.entry_country_id.selectedIndex].value;

<?php echo tep_js_zone_list('SelectedCountry', 'theForm', 'entry_zone_id'); ?>

 resetStateText(theForm);
}

function check_form() {
 var error = 0;
 var error_message = \"<?php echo JS_ERROR; ?>\";

 var customers_firstname = document.customers.customers_firstname.value;
 var customers_lastname = document.customers.customers_lastname.value;
<?php if (ACCOUNT_COMPANY == 'true') echo 'var entry_company = document.customers.entry_company.value;' . \"n\"; ?>
<?php if (ACCOUNT_DOB == 'true') echo 'var customers_dob = document.customers.customers_dob.value;' . \"n\"; ?>
 var customers_email_address = document.customers.customers_email_address.value;  
 var entry_street_address = document.customers.entry_street_address.value;
 var entry_postcode = document.customers.entry_postcode.value;
 var entry_city = document.customers.entry_city.value;
 var customers_telephone = document.customers.customers_telephone.value;

<?php if (ACCOUNT_GENDER == 'true') { ?>
 if (document.customers.customers_gender[0].checked || document.customers.customers_gender[1].checked) {
 } else {
   error_message = error_message + \"<?php echo JS_GENDER; ?>\";
   error = 1;
 }
<?php } ?>

 if (customers_firstname == \"\" || customers_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_FIRST_NAME; ?>\";
   error = 1;
 }

 if (customers_lastname == \"\" || customers_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_LAST_NAME; ?>\";
   error = 1;
 }

<?php if (ACCOUNT_DOB == 'true') { ?>
 if (customers_dob == \"\" || customers_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_DOB; ?>\";
   error = 1;
 }
<?php } ?>

 if (customers_email_address == \"\" || customers_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_EMAIL_ADDRESS; ?>\";
   error = 1;
 }

 if (entry_street_address == \"\" || entry_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_ADDRESS; ?>\";
   error = 1;
 }

 if (entry_postcode == \"\" || entry_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_POST_CODE; ?>\";
   error = 1;
 }

 if (entry_city == \"\" || entry_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_CITY; ?>\";
   error = 1;
 }

<?php if (ACCOUNT_STATE == 'true') { ?>
 if (document.customers.entry_zone_id.options.length <= 1) {
   if (document.customers.entry_state.value == \"\" || document.customers.entry_state.length < 4 ) {
      error_message = error_message + \"<?php echo JS_STATE; ?>\";
      error = 1;
   }
 } else {
   document.customers.entry_state.value = '';
   if (document.customers.entry_zone_id.selectedIndex == 0) {
      error_message = error_message + \"<?php echo JS_ZONE; ?>\";
      error = 1;
   }
 }
<?php } ?>

 if (document.customers.entry_country_id.value == 0) {
   error_message = error_message + \"<?php echo JS_COUNTRY; ?>\";
   error = 1;
 }

 if (customers_telephone == \"\" || customers_telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {
   error_message = error_message + \"<?php echo JS_TELEPHONE; ?>\";
   error = 1;
 }

 if (error == 1) {
   alert(error_message);
   return false;
 } else {
   return true;
 }
}
//--></script>
<?php
 }
?>
</head>
<body marginwidth=\"0\" marginheight=\"0\" topmargin=\"0\" bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bgcolor=\"#FFFFFF\" onload=\"SetFocus();\">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border=\"0\" width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">
 <tr>
   <td width=\"<?php echo BOX_WIDTH; ?>\" valign=\"top\"><table border=\"0\" width=\"<?php echo BOX_WIDTH; ?>\" cellspacing=\"1\" cellpadding=\"1\" class=\"columnLeft\">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width=\"100%\" valign=\"top\"><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
<?php
 if ($HTTP_GET_VARS['action'] == 'edit') {
   $customers_query = tep_db_query(\"select c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from \" . TABLE_CUSTOMERS . \" c left join \" . TABLE_ADDRESS_BOOK . \" a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '\" . $HTTP_GET_VARS['cID'] . \"'\");
   $customers = tep_db_fetch_array($customers_query);
   $cInfo = new objectInfo($customers);

   $newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),
                             array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));
?>
     <tr>
       <td><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
         <tr>
           <td class=\"pageHeading\"><?php echo HEADING_TITLE; ?></td>
           <td class=\"pageHeading\" align=\"right\"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr><?php echo tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('action')) . 'action=update', 'post', 'onSubmit=\"return check_form();\"') . tep_draw_hidden_field('default_address_id', $cInfo->customers_default_address_id); ?>
       <td class=\"formAreaTitle\"><?php echo CATEGORY_PERSONAL; ?></td>
     </tr>
     <tr>
       <td class=\"formArea\"><table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
<?php
   if (ACCOUNT_GENDER == 'true') {
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_GENDER; ?></td>
           <td class=\"main\"><?php echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '&&' . MALE . '&&' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '&&' . FEMALE; ?></td>
         </tr>
<?php
   }
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_FIRST_NAME; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength=\"32\"', true); ?></td>
         </tr>
         <tr>
           <td class=\"main\"><?php echo ENTRY_LAST_NAME; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength=\"32\"', true); ?></td>
         </tr>
<?php
   if (ACCOUNT_DOB == 'true') {
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength=\"10\"', true); ?></td>
         </tr>
<?php
   }
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength=\"96\"', true); ?></td>
         </tr>
       </table></td>
     </tr>
<?php
   if (ACCOUNT_COMPANY == 'true') {
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class=\"formAreaTitle\"><?php echo CATEGORY_COMPANY; ?></td>
     </tr>
     <tr>
       <td class=\"formArea\"><table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
         <tr>
           <td class=\"main\"><?php echo ENTRY_COMPANY; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength=\"32\"'); ?></td>
         </tr>
       </table></td>
     </tr>
<?php
   }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class=\"formAreaTitle\"><?php echo CATEGORY_ADDRESS; ?></td>
     </tr>
     <tr>
       <td class=\"formArea\"><table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
         <tr>
           <td class=\"main\"><?php echo ENTRY_STREET_ADDRESS; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength=\"64\"', true); ?></td>
         </tr>
<?php
   if (ACCOUNT_SUBURB == 'true') {
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_SUBURB; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('entry_suburb', $cInfo->entry_suburb, 'maxlength=\"32\"'); ?></td>
         </tr>
<?php
   }
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_POST_CODE; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength=\"8\"', true); ?></td>
         </tr>
         <tr>
           <td class=\"main\"><?php echo ENTRY_CITY; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength=\"32\"', true); ?></td>
         </tr>
         <tr>
           <td class=\"main\"><?php echo ENTRY_COUNTRY; ?></td>
           <td class=\"main\"><?php echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id, 'onChange=\"update_zone(this.form);\"'); ?></td>
         </tr>
<?php
   if (ACCOUNT_STATE == 'true') {
?>
         <tr>
           <td class=\"main\"><?php echo ENTRY_STATE; ?></td>
           <td class=\"main\"><?php echo tep_draw_pull_down_menu('entry_zone_id', tep_prepare_country_zones_pull_down($cInfo->entry_country_id), $cInfo->entry_zone_id, 'onChange=\"resetStateText(this.form);\"'); ?></td>
         </tr>
         <tr>
           <td class=\"main\">&</td>
           <td class=\"main\"><?php echo tep_draw_input_field('entry_state', $cInfo->entry_state, 'maxlength=\"32\" onChange=\"resetZoneSelected(this.form);\"'); ?></td>
         </tr>
<?php
   }
?>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class=\"formAreaTitle\"><?php echo CATEGORY_CONTACT; ?></td>
     </tr>
     <tr>
       <td class=\"formArea\"><table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
         <tr>
           <td class=\"main\"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength=\"32\"', true); ?></td>
         </tr>
         <tr>
           <td class=\"main\"><?php echo ENTRY_FAX_NUMBER; ?></td>
           <td class=\"main\"><?php echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength=\"32\"'); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class=\"formAreaTitle\"><?php echo CATEGORY_OPTIONS; ?></td>
     </tr>
     <tr>
       <td class=\"formArea\"><table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
         <tr>
           <td class=\"main\"><?php echo ENTRY_NEWSLETTER; ?></td>
           <td class=\"main\"><?php echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, $cInfo->customers_newsletter); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td align=\"right\" class=\"main\"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href=\"' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action'))) .'\">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
     </tr></form>
<?php
 } else {
?>
     <tr>
       <td><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
         <tr><?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>
           <td class=\"pageHeading\"><?php echo HEADING_TITLE; ?></td>
           <td class=\"pageHeading\" align=\"right\"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
           <td class=\"smallText\" align=\"right\"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>
         </form></tr>
       </table></td>
     </tr>
     <tr>
       <td><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
         <tr>
           <td valign=\"top\"><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
             <tr class=\"dataTableHeadingRow\">
   <td class=\"dataTableHeadingContent\"><?php echo TABLE_HEADING_LASTNAME; ?></td>
               <td class=\"dataTableHeadingContent\"><?php echo TABLE_HEADING_FIRSTNAME; ?></td>
               <td class=\"dataTableHeadingContent\" align=\"right\"><?php echo 'Dernier accès'; ?></td>
               <td class=\"dataTableHeadingContent\" align=\"center\"><?php echo 'Nb accès'; ?></td>
   <td class=\"dataTableHeadingContent\" align=\"right\"><?php echo TABLE_HEADING_CUSTOMERS_STATUS; ?></td>
               <td class=\"dataTableHeadingContent\" align=\"right\"><?php echo TABLE_HEADING_ACTION; ?>&</td>
             </tr>
<?php
   $search = '';
   if ( ($HTTP_GET_VARS['search']) && (tep_not_null($HTTP_GET_VARS['search'])) ) {
     $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));
     $search = \"where c.customers_lastname like '%\" . $keywords . \"%' or c.customers_firstname like '%\" . $keywords . \"%' or c.customers_email_address like '%\" . $keywords . \"'\";
   }
//version OSC//  

  // $customers_query_raw = \"select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, customers_status, a.entry_country_id from \" . TABLE_CUSTOMERS . \" c left join \" . TABLE_ADDRESS_BOOK . \" a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id \" . $search . \" order by c.customers_lastname, c.customers_firstname\";


//Version tri par la date de dernière connexion !Pas OK! //

$customers_query_raw = \"select i.customers_info_date_account_created, i.customers_info_number_of_logons, c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id, c.customers_status  from \" . TABLE_CUSTOMERS_INFO . \" i left join \" . TABLE_CUSTOMERS . \" c on i.customers_info_id = c.customers_id left join \" . TABLE_ADDRESS_BOOK . \" a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id \" . $search . \" order by i.customers_info_date_account_created\"; DESC

//Version tri par nb de logon desc !OK! //
 // $customers_query_raw = \"select i.customers_info_date_account_created, i.customers_info_number_of_logons, c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id, c.customers_status  from \" . TABLE_CUSTOMERS_INFO . \" i left join \" . TABLE_CUSTOMERS . \" c on i.customers_info_id = c.customers_id left join \" . TABLE_ADDRESS_BOOK . \" a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id \" . $search . \" order by i.customers_info_number_of_logons DESC\";



   $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows);
   $customers_query = tep_db_query($customers_query_raw);
   
while ($customers = tep_db_fetch_array($customers_query)) {
     $info_query = tep_db_query(\"select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from \" . TABLE_CUSTOMERS_INFO . \" where customers_info_id = '\" . $customers['customers_id'] . \"order by date_last_logon'\");
     $info = tep_db_fetch_array($info_query);

     if (((!$HTTP_GET_VARS['cID']) || (@$HTTP_GET_VARS['cID'] == $customers['customers_id'])) && (!$cInfo)) {
       $country_query = tep_db_query(\"select countries_name from \" . TABLE_COUNTRIES . \" where countries_id = '\" . $customers['entry_country_id'] . \"'\");
       $country = tep_db_fetch_array($country_query);

       $reviews_query = tep_db_query(\"select count(*) as number_of_reviews from \" . TABLE_REVIEWS . \" where customers_id = '\" . $customers['customers_id'] . \"'\");
       $reviews = tep_db_fetch_array($reviews_query);

       $customer_info = tep_array_merge($country, $info, $reviews);

       $cInfo_array = tep_array_merge($customers, $customer_info);
       $cInfo = new objectInfo($cInfo_array);
     }

     if ( (is_object($cInfo)) && ($customers['customers_id'] == $cInfo->customers_id) ) {
       echo '          <tr class=\"dataTableRowSelected\" onmouseover=\"this.style.cursor='hand'\" onclick=\"document.location.href='' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit') . ''\">' . \"n\";
     } else {
       echo '          <tr class=\"dataTableRow\" onmouseover=\"this.className='dataTableRowOver';this.style.cursor='hand'\" onmouseout=\"this.className='dataTableRow'\" onclick=\"document.location.href='' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . ''\">' . \"n\";
     }
?>
   <td class=\"dataTableContent\"><?php echo $customers['customers_lastname']; ?></td>
               <td class=\"dataTableContent\"><?php echo $customers['customers_firstname']; ?></td>
               <td class=\"dataTableContent\" align=\"right\"><?php echo tep_date_short($info['date_last_logon']); ?> </td>
               <td class=\"dataTableContent\" align=\"center\"><?php echo $info['number_of_logons']; ?></td>
   <td class=\"dataTableContent\" align=\"right\"><?php   if ($customers['customers_status'] == '1') {
     echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&&<a href=\"' . tep_href_link(FILENAME_CUSTOMERS, 'action=setflag&flag=0&cID=' . $customers['customers_id'], 'NONSSL') . '\">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
     } else {
     echo '<a href=\"' . tep_href_link(FILENAME_CUSTOMERS, 'action=setflag&flag=1&cID=' . $customers['customers_id'], 'NONSSL') . '\">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&&' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
      } ?></td>
               <td class=\"dataTableContent\" align=\"right\"><?php if ( (is_object($cInfo)) && ($customers['customers_id'] == $cInfo->customers_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href=\"' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '\">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&</td>

             </tr>
<?php
   }
?>
             <tr>
               <td colspan=\"4\"><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
                 <tr>
                   <td class=\"smallText\" valign=\"top\"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>
                   <td class=\"smallText\" align=\"right\"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>
                 </tr>
<?php
   if (tep_not_null($HTTP_GET_VARS['search'])) {
?>
                 <tr>
                   <td align=\"right\" colspan=\"2\"><?php echo '<a href=\"' . tep_href_link(FILENAME_CUSTOMERS) . '\">' . tep_image_button('button_reset.gif', IMAGE_RESET) . '</a>'; ?></td>
                 </tr>
<?php
   }
?>
               </table></td>
             </tr>
           </table></td>
<?php
 $heading = array();
 $contents = array();
 switch ($HTTP_GET_VARS['action']) {
   case 'confirm':
     $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CUSTOMER . '</b>');

     $contents = array('form' => tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=deleteconfirm'));
     $contents[] = array('text' => TEXT_DELETE_INTRO . '<br><br><b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');
     if ($cInfo->number_of_reviews > 0) $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews));
     $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href=\"' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id) . '\">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
     break;
   default:
     if (is_object($cInfo)) {
       $heading[] = array('text' => '<b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');

       $contents[] = array('align' => 'center', 'text' => '<a href=\"' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit') . '\">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href=\"' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=confirm') . '\">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href=\"' . tep_href_link(FILENAME_ORDERS, 'cID=' . $cInfo->customers_id) . '\">' . tep_image_button('button_orders.gif', IMAGE_ORDERS) . '</a> <a href=\"' . tep_href_link(FILENAME_MAIL, 'selected_box=tools&customer=' . $cInfo->customers_email_address) . '\">' . tep_image_button('button_email.gif', IMAGE_EMAIL) . '</a>');
       $contents[] = array('text' => '<br>' . TEXT_DATE_ACCOUNT_CREATED . ' ' . tep_date_short($cInfo->date_account_created));
       $contents[] = array('text' => '<br>' . TEXT_DATE_ACCOUNT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->date_account_last_modified));
       $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_LAST_LOGON . ' '  . tep_date_short($cInfo->date_last_logon));
       $contents[] = array('text' => '<br>' . TEXT_INFO_NUMBER_OF_LOGONS . ' ' . $cInfo->number_of_logons);
       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);
       $contents[] = array('text' => '<br>' . TEXT_INFO_NUMBER_OF_REVIEWS . ' ' . $cInfo->number_of_reviews);
     }
     break;
 }

 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
   echo '            <td width=\"25%\" valign=\"top\">' . \"n\";

   $box = new box;
   echo $box->infoBox($heading, $contents);

   echo '            </td>' . \"n\";
 }
?>
         </tr>
       </table></td>
     </tr>
<?php
 }
?>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


--------------------
Version 2.2 MS1 CREload5 (Delaballe) + contribs + bidouilles
Go to the top of the page
 
Gnidhal
posté 24 Sep 2003, 13:28
Message #7


5eme dan OSC
Icône de groupe

Groupe : Administrateur
Messages : 9221
Inscrit : 4-March 03
Lieu : Pau
Membre no 927



heuuu
alors là, c'est comme le nez !

Bon j'avais pas pigé ton pb la première fois mais si tu fais un tri par date, autant qua ça soit sur le bon champ non ? laugh.gif

customers_info_date_account_created n'a pas de rapport avec
customers_info_date_of_last_logon

Mais ce que j'en dis hin ? laugh.gif
sinon ça devrait marcher, car le tri est bon wink.gif


--------------------
Tout d'abord : - Ni Hotline ni Service Après Vente, ces forums sont un lieu d'échange. BIEN POSER SA QUESTION (généralités)
Les "Informations Importantes" que vous devez ABSOLUMENT avoir lues :
Règlement, Bien poser sa question dans ces forums et Bien utiliser les Forums.
Les raccourcis pour gagner du temps : la FAQ, les PDF de la Doc (MS2-fr): PDF-V1 et PDF-V2, le moteur de Recherche sur les forums , la Liste des Contributions de Corbin.

----------------------------- Quelques sites de référence ---------------------------
PHP: Le site du Zéro et PHP Débutant avec la DOC en français -- HTML: Self HTML - WebProgrammation -- CSS: OpenWeb - AlsaCréations - CSS/Edge -- Autres ressources: - XajaX - highslide js
Les bons outils : EasyPHP - WAMP-5 - - Notepad++ - Firefox et son extension WebDeveloper
Le gène idéal c'est le gène original. Le génie des halles est un Génie des Alpages qui tente d'être à la page. (Merci f'murrr pour les cours de philosophie de chien)
Go to the top of the page
 
jame
posté 24 Sep 2003, 13:59
Message #8


Ceinture jaune+ OSC
Icône de groupe

Groupe : Membres
Messages : 97
Inscrit : 10-June 03
Lieu : Nord Est
Membre no 1226



AAAAHHHHHHHHHHHHHHHHH ! ! LE C.. blush.gif
C'est pas possible ! ! !

J'ai passé des heures à essayé de faire cette requete avec jointure et j'ai du inverser le nom de la variable en faisant des essais...

C'est quand même mieux avec un oeil extérieur.

T'as raison, c'est comme le nez blush.gif

Un grand merci. C'est pour les choses les plus simple que l'on cherche le plus longtemps

C'est OK tout marche . Encore merci


--------------------
Version 2.2 MS1 CREload5 (Delaballe) + contribs + bidouilles
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 : 28th March 2024 - 19:53
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)