IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

import d'un fichier csv en php


Sujet :

Langage PHP

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut import d'un fichier csv en php
    Bonjour tout le monde
    voila j'ai un petit problème. Pour notre back office nous avons un fichier nommé atosboard charger de récupérer un fichier format xls enfin de récupérer les nom prénom des clients.

    Le problème c'est que récemment ma banque à changer le système et que le fichier est en format csv et maintenant il ne fonctionne plus. J'ai bien essayé de sauvegarder le fichier dans le bon format mais rien n'y fait.
    J'ai vérifié aussi les champs et ils sont identiques:

    XLS


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ENTETE	TRANSACTION_ID	MERCHANT_ID	PAYMENT_MEANS	ORIGIN_AMOUNT	AMOUNT	CURRENCY_CODE	PAYMENT_DATE	PAYMENT_TIME	CARD_VALIDITY	CARD_TYPE	CARD_NUMBER	RESPONSE_CODE	CVV_RESPONSE_CODE	COMPLEMENTARY_CODE	CERTIFICATE	AUTHORIZATION_ID	CAPTURE_DATE	TRANSACTION_STATUS	RETURN_CONTEXT	AUTORESPONSE_STATUS	ORDER_ID	CUSTOMER_ID	CUSTOMER_IP_ADDRESS	ACCOUNT_SERIAL	SESSION_ID	TRANSACTION_CONDITION	CAVV_UCAF	COMPLEMENTARY_INFO	BANK_RESPONSE_CODE	MODE_REGLEMENT	3D_LS

    CSV

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ENTETE	TRANSACTION_ID	MERCHANT_ID	PAYMENT_MEANS	ORIGIN_AMOUNT	AMOUNT	CURRENCY_CODE	PAYMENT_DATE	PAYMENT_TIME	CARD_VALIDITY	CARD_TYPE	CARD_NUMBER	RESPONSE_CODE	CVV_RESPONSE_CODE	COMPLEMENTARY_CODE	CERTIFICATE	AUTORISATION_ID	CAPTURE_DATE	TRANSACTION_STATUS	RETURN_CONTEXT	AUTORESPONSE_STATUS	ORDER_ID	CUSTOMER_ID	CUSTOMER_IP_ADDRESS	ACCOUNT_SERIAL	SESSION_ID	TRANSACTION_CONDITION	CAVV_UCAF	COMPLEMENTARY_INFO	BANK_RESPONSE_CODE	MODE_REGLEMENT	3D_LS
    voici le code


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
     
     
    <?php  /*
      $Id: atos_board.php, v 0.1 29/10/2008 Delete $
    
      This script is not included in the original version of osCommerce
    
      osCommerce, Open Source E-Commerce Solutions
      http://www.oscommerce.com
    
      Copyright (c) 2003 osCommerce
    
    */
     
    require('includes/application_top.php');
     
    // For php4 users - Merci xavkick 
    //
    if (!function_exists('file_put_contents')) {
        function file_put_contents($filename, $data) {
            $f = @fopen($filename, 'w');
            if (!$f) {
                return false;
            } else {
                $bytes = fwrite($f, $data);
                fclose($f);
                return $bytes;
            }
        }
    }
     
    ?>
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <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/stylesheet1.css">
    <script type="text/javascript" src="includes/general.js"></script>
    </head>
    <body>
    <!-- header //-->
    <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
    <!-- header_eof //-->
     
    <!-- body //-->
    <table border="0" summary="" width="150%" cellspacing="2" cellpadding="2">
      <tr>
        <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" summary="" 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="150%" valign="top"><table border="0" width="150%" cellspacing="0" cellpadding="2">
    <!-- Atos Feed Begin //-->
        <tr><td class="pageHeading"><?php echo ATOS_BOARD_PAGE_HEADING ; ?></td</tr> 
     
     
            <form  method="post" enctype="multipart/form-data" action="<?php echo tep_href_link(FILENAME_ATOS_BOARD);?>" name="atos_feed">
     
            <tr>
            <td class="dataTableContent"><?php echo ATOS_BOARD_UPLOAD_TITLE ; ?> <input type="file" name="fichier" size="60">&nbsp;<input type="submit" name="upload" action="<?php echo tep_href_link(FILENAME_ATOS_BOARD);?>" value="<?php echo ATOS_BOARD_UPLOAD ; ?>">
            </td>
        </form>
        </tr>        
        </td>
     
     
    <?php
     // Short Header  
          //
          $header = '
          <table border="0" width="150%">
          <tr>
          <td class="dataTableatos"></td>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Commande #</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Transaction</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">PRIX</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Nom client</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Status Transaction</span> </td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Heure de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Validiter Carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Type de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Numero de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Response Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Certificate</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Authorization Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Capture carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Autoresponse Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Customer Ip_address</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Transaction Condition</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Bank Response Code</span></td>
          </tr><span style="font-size: 8pt">' ;
          //
          // Format complet 
          //
          if ( ATOS_BOARD_LONG_DISPLAY )
          $header = ' </span>
          <table border="0" width="150%">
          <tr>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Commande #</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Entete</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Transaction</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Nom du client</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Merchant Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Payment Means</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Origin Amount</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">PRIX</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Transaction Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Currency Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Heure de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Validiter Carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Type de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Numero de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Response Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Cvv Response_code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Complementary Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Certificate</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Authorization Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Capture</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Return Context</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Autoresponse Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Atos Order_id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Customer Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Customer Ip_address</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Account Serial</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Session Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Transaction Condition</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Cavv Ucaf</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Complementary Info</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Bank Response Code</span></td>
          </tr><span style="font-size: 8pt">' ;
          // Ligne préformatée pour l'affichage de l'import
          //  
          $origin_line_format = '<tr class="CLASS"> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td></tr>' ;
     
          // Format complet 
          //
          if ( ATOS_BOARD_LONG_DISPLAY ) 
    	      $origin_line_format = '<tr class="CLASS"><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td></tr>' ;
     
          $displayPreviousFile = file_exists ( FILENAME_ATOS_LATEST_IMPORT ) ;
     
          if( isset($_POST['upload']) || $displayPreviousFile )
          {
    	  if ( isset($_POST['upload']) )
    	  {
    	    printf('<tr><td class="dataTableatos">%s</tr></td>', ATOS_IMPORT_TITLE) ;
                $tmp_file = $_FILES['fichier']['tmp_name'];
    	  }
    	  else
    	  //
    	  // Affichage de la date du dernier import
    	  //
      	  {
    	     printf('<tr><td class="dataTableatos">%s : <strong>%s</strong></tr></td>', ATOS_LATEST_IMPORT_TITLE, date("d F Y H:i:s", filemtime(FILENAME_ATOS_LATEST_IMPORT))) ; 
    	     $tmp_file = FILENAME_ATOS_LATEST_IMPORT ;
    	  }
     
              if( !is_uploaded_file($tmp_file) && isset($_POST['upload']) ) 
              {
                  echo "Le fichier est introuvable" ;
    	            exit() ;
              }
              $handle = fopen($tmp_file, "r"); // Fichier temporaire détruit automatique a la fin du script
              $lines  = fread($handle, filesize($tmp_file)) ;   
     
              preg_match_all('#TRANSACTION.*#', $lines, $result) ;
     
              $result = array_shift($result) ;
     
              echo $header ;
     
              foreach($result as $line)
              {
                      // Post-format
                      //
                      if ( $i++ % 2 )   $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
                      else              $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ; 
     
                      // Tout va bien !
                      //
                      $error_flag = false ; 
     
                      $val = explode("\t", $line) ;
     
                      // On saute les entêtes ...
                      //
                      if ( $val[0] != "TRANSACTION" )  continue ;
     
                      // Valeurs du journal ATOS
                      //
                      $entete                 = $val[0] ;
                      $transaction_id         = $val[1] ;
                      $merchant_id            = $val[2] ;
                      $payment_means          = $val[3] ;
                      $origin_amount          = $val[4] ;
                      $amount                 = $val[5] ;                  
                      $payment_date           = $val[18] ;
                      $payment_time           = $val[8] ;
                      $card_validity          = $val[9] ;
                      $card_type              = $val[10] ;
                      $card_number            = $val[11] ;
                      $response_code          = $val[12] ;
                      $cvv_response_code      = $val[13] ;
                      $complementary_code     = $val[14] ;
                      $certificate            = $val[15] ;
                      $authorization_id       = $val[16] ;
                      $capture_date           = $val[17] ;
                      $transaction_status     = $val[7] ;
                      $return_context         = $val[19] ;
                      $autoresponse_status    = $val[20] ;
                      $atos_order_id          = $val[21] ;
                      $atos_customer_id       = $val[22] ;
                      $customer_ip_address    = $val[23] ;
                      $account_serial         = $val[24] ;
                      $session_id             = $val[25] ;
                      $transaction_condition  = $val[26] ;
                      $cavv_ucaf              = $val[27] ;
                      $complementary_info     = $val[28] ;
                      $bank_response_code     = $val[29] ;
     
                      // Post-traitements afin d'obtenir des équivalences entre les valeurs ATOS/osC 
                      //
                      $payment_date           = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})/', '\1-\2-\3', $payment_date) ;
                      $payment_time           = preg_replace('/([0-9]{2})([0-9]{2})([0-9]{2})/', '\1:\2:\3', $payment_time) ;
                      $card_number            = preg_replace('/([0-9]{4}).([0-9]{2})/', '\1 #### #### ##\2', $card_number) ;
                      $amount                 = (float)($amount / 100) ;
     
     
     
                      // Récupération du numéro de la commande correspondante
                      // cc_owner disponible (modif de checkout_process.php)
    $query    = 'SELECT o.`orders_id` FROM ' . TABLE_ORDERS . ' o where cc_owner = "' . $transaction_id . '" and cc_number = "' . $card_number . '" ;' ;
     
                      // Obsolète : version avec cc_owner non renseigné (permets d'affecter les anciennes transaction avant modif de checkout_process.php)
                      // décommenter cette ligne pour affecter les anciennes commandes. recommenter ensuite.
                      //$query    = 'SELECT o.`orders_id`,ot.`orders_id`,o.`customers_name`,ot.`customers_name` FROM ' . TABLE_ORDERS . ' o LEFT JOIN ' . TABLE_HOLDING_ORDERS . ' ot on (o.orders_id = ot.orders_id) where o.cc_number = "' . $card_number . '" ;' ;
     
                      $order_qr = tep_db_query($query) ;
                      $order = tep_db_fetch_array($order_qr) ;
                      $orders_id = $order['orders_id'] ;
                      $name = $order['customers_name'] ; 
                      $currency_code          = $name;
                      // Montant de la commande 
                      //
                		  if ( $orders_id )
                      {
                        $query = 'SELECT ot.`value` FROM ' . TABLE_ORDERS_TOTAL . ' ot where class = "ot_total" and orders_id = "' . $orders_id . '"'  ;
                        $orders_total_qr = tep_db_query($query) ;
                        $orders_total = tep_db_fetch_array($orders_total_qr) ;
                        $orders_total_value = sprintf("%.04f", $orders_total['value']) ;  
     
     
                        // Montant de la commande différent de celui de la transaction
                        //
                        if ( $amount != $orders_total_value ) $error_flag = true ;                                  
                      } 
                      else
                      {
                        $orders_total_value = 0 ;
                      } 
     
    /////////////////////////////////////order check//////////////////////////////////////////////////////////
      // Récupération du numéro de la commande correspondante
                      // cc_owner disponible (modif de checkout_process.php)
    		              //
              $query1    = 'SELECT oc.`orders_id`,`customers_name` FROM ' . TABLE_HOLDING_ORDERS . ' oc  where customers_id = "' . $atos_customer_id . '" ;' ;
     
     
                      $order_qr1 = tep_db_query($query1) ;
                      $order1 = tep_db_fetch_array($order_qr1) ;
                      $orders_id1 = $order1['orders_id'] ;
                      $name = $order1['customers_name'] ; 
                      $currency_code          = $name;
     
     
                        if ( $orders_id1 )
                      {
                        $query_check1 = 'SELECT ot.`value` FROM ' . TABLE_HOLDING_ORDERS_TOTAL . ' ot where class = "ot_total" and orders_id = "' . $orders_id1 . '"'  ;
                        $orders_total_qr1 = tep_db_query($query_check1) ;
                        $orders_total1 = tep_db_fetch_array($orders_total_qr1) ;
                        $orders_total_value1 = sprintf("%.04f", $orders_total1['value']) ;  
                            // Montant de la commande différent de celui de la transaction
                        //
                        if ( $amount != $orders_total_value1 ) $error_flag = true ;                                  
                      } 
                      else
                      {
                        $orders_total_value1 = 0 ;
                      } 
     
    /////////////////////////////////////order check//////////////////////////////////////////////////////////
                      // Valeur atos > 0 : Commande invalide
                      //
                      if ( $response_code > 0 )     $error_flag = 1 ; 
     
                      // Si le numéro de commande est vide, commande perdue ???
                      //add ordercheck
                      if ( ! strlen(($orders_id) || ($orders_id1)) )
                      //end ordercheck
                      {
                        $status = "<STRONG>" . ATOS_BOARD_UNKNOWN . "</STRONG>" ;
                        $export = 0 ; // Commande pas trouvée on exporte pas
                      }
                      else
                      {
                        $status = ATOS_BOARD_CREATED ;
                        $export = 1 ;
                      } 
     
                      // Vérification de l'unicité de l'import
                      //
                      if ( $export )
                      {
                        $atos_query = tep_db_query('SELECT a.`orders_id` FROM '. TABLE_ATOS_BOARD . ' a where orders_id = "' . $orders_id . '" ;') ;
                        $atos_qr    = tep_db_fetch_array($atos_query) ;
     
                        if ( strlen($atos_qr['orders_id']) )
                        {
                          $status = ATOS_BOARD_EXISTS ; 
                          $export = 0 ;
                        }
                        //add ordercheck
                        if ( strlen($atos_qr['orders_id1']) )
                        {
                          $status = ATOS_BOARD_EXISTS ; 
                          $export = 0 ;
                          //end ordercheck
                        }
                      }
     
    		  // Lien hypertexte vers la commande
    		  // Add order check/////
    		  if ( $orders_id )
    		   $order_link = '<a href="' . tep_href_link(FILENAME_ORDERS, 'oID=' . $orders_id . '&action=edit') . '" >' . $orders_id . '</a>' ;
    		  else
    		  // Commande non répertoriée 
    		   $order_link = '<a href="' . tep_href_link(FILENAME_ORDERS_CHECK, 'ocID=' . $orders_id1 . '&action=edit') . '" >' . $orders_id1 . '</a>' ;
              // End order check/////
    		  // Status pour les commandes déjà importées
    		  //
    		  if ( ! isset($_POST['upload']) && $displayPreviousFile ) 
    			  $status = '<span style="color:navy;">' . ATOS_BOARD_ARCHIVE . '</span>' ;
     
     
          // Bouton vert ou rouge !
          //
          $image_status = $error_flag ? tep_image(DIR_WS_IMAGES . 'icon_status_red.gif') : tep_image(DIR_WS_IMAGES . 'icon_status_green.gif') ;
     
          // Affichage du résultat de l'importation
          //
    		  if ( ATOS_BOARD_LONG_DISPLAY ) 
    			  printf($line_format, $order_link, $status, $entete, $transaction_id, $merchant_id, $payment_means, $origin_amount, $amount, $currency_code, $payment_date, $payment_time, $card_validity, $card_type, $card_number, $response_code, $cvv_response_code, $complementary_code, $certificate, $authorization_id, $capture_date, $transaction_status, $return_context, $autoresponse_status, $atos_order_id, $customer_id, $customer_ip_address, $account_serial, $session_id, $transaction_condition, $cavv_ucaf, $complementary_info, $bank_response_code) ;
    		  else
    		    printf($line_format, $image_status, $order_link, $status, $transaction_id, $amount, $currency_code, $payment_date, $payment_time, $card_validity, $card_type, $card_number, $response_code, $certificate, $authorization_id, $capture_date, $transaction_status, $autoresponse_status, $customer_ip_address, $transaction_condition, $bank_response_code) ;
     
                      // Insertion dans la table ATOS_BOARD
                      //
                      if ( $export && isset($_POST['upload']) )
                      {
                        $query = 'INSERT into ' . TABLE_ATOS_BOARD . ' (orders_id, entete, transaction_id, merchant_id, payment_means, origin_amount, amount, currency_code, payment_date, payment_time, card_validity, card_type, card_number, response_code, cvv_response_code, complementary_code, certificate, authorization_id, capture_date, transaction_status, return_context, autoresponse_status, atos_order_id, atos_customer_id, customer_ip_address, account_serial, session_id, transaction_condition, cavv_ucaf, complementary_info, bank_response_code) values ( "' . $orders_id . '","' . $entete .  '","' . $transaction_id .  '","' . $merchant_id .  '","' . $payment_means .  '","' . $origin_amount .  '","' . $amount .  '","' . $currency_code .  '","' . $payment_date .  '","' . $payment_time .  '","' . $card_validity .  '","' . $card_type .  '","' . $card_number .  '","' . $response_code .  '","' . $cvv_response_code .  '","' . $complementary_code .  '","' . $certificate .  '","' . $authorization_id .  '","' . $capture_date .  '","' . $transaction_status .  '","' . $return_context .  '","' . $autoresponse_status .  '","' . $atos_order_id .  '","' . $customer_id .  '","' . $customer_ip_address .  '","' . $account_serial .  '","' . $session_id .  '","' . $transaction_condition .  '","' . $cavv_ucaf .  '","' . $complementary_info .  '","' . $bank_response_code . '");' ;
     
                       tep_db_query($query) ;
     
    		   // Générer un fichier backup pour la session en cours
    		   //
    		   $creating_image_file = 1 ; 
                     }  
              }
    	  //
    	  // Backup du fichier de cette session
    	  //
    	  if ( isset($_POST['upload']) && $creating_image_file )
    	    file_put_contents(FILENAME_ATOS_LATEST_IMPORT, $lines) ; 
     
    	  fclose($handle) ;
     
              echo "</table>" ; // Fin table header+lines
          }
    ?>
     
    <!-- Atos Feed End //-->
     
        </table>
    <!-- body_text_eof //-->
      </tr>
    </table>
    <style type="text/css" media="print"> 
    .menu{ 
    display:none; 
    } 
     
    .print{ 
    display:none; 
    } 
     
    <!--@page{size:landscape}--> 
    </style> 
     
     
    <!-- body_eof //-->
     
    <!-- footer //-->
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    <!-- footer_eof //-->
    <br>
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


    Merci à vous

  2. #2
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2010
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2010
    Messages : 80
    Points : 169
    Points
    169
    Par défaut
    Bonjour,

    Qu'est-ce qui ne marche plus ?

    Dans un autre registre, avez vous pensé à utiliser fputcsv voir ici qui est prévu pour traiter du CSV ?

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut
    déjà merci de la réponse.

    Malheureusement cela ne s'applique pas dans mon cas car le but et d'extraire les champ du fichier csv pour les traité puis les afficher dans un nouveau tableau php.

    merci encore

  4. #4
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2010
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2010
    Messages : 80
    Points : 169
    Points
    169
    Par défaut
    Citation Envoyé par badibad Voir le message
    déjà merci de la réponse.
    Malheureusement cela ne s'applique pas dans mon cas car le but et d'extraire les champ du fichier csv pour les traité puis les afficher dans un nouveau tableau php.
    merci encore
    au temps pour moi. Maintenant, si vous souhaitez extraire des champs du CSV, pourquoi ne pas utiliser fgetcsv dans ce cas là (http://php.net/manual/fr/function.fgetcsv.php) ? Cette fonction est faite pour ça.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut haaaa
    Merci

    J'ai essayer ce que
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    if (!function_exists('fgetcsv')) {
        function fgetcsv($filename, $data) {
            $f = @fopen($filename, 'w');
            if (!$f) {
                return false;
            } else {
                $bytes = fwrite($f, $data);
                fclose($f);
                return $bytes;
            }
        }
    }
    Mais malheureusement cale ne fonctionne toujours pas.

    merci de votre aide.

  6. #6
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    pourquoi créer la fonction ?

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut
    je pense que c'est pour récupérer les champs du csv

  8. #8
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    Citation Envoyé par badibad Voir le message
    je pense que c'est pour récupéré les champs du csv
    je sais bien ...

    mais pourquoi la créer elle existe déjà dans l'api de PHP ...
    de plus que c'est pas bon

  9. #9
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut
    d'accord
    désolé je ne savais pas qu'il étais fourni dans api de php

    mais je ne comprend toujours pas pourquoi il ne m'affiche pas mon dossier en csv

    merci

  10. #10
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    montre ton nouveau code

  11. #11
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut
    merci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
     
     
     </table></td>
    <!-- body_text //-->
        <td width="150%" valign="top"><table border="0" width="150%" cellspacing="0" cellpadding="2">
    <!-- Atos Feed Begin //-->
        <tr><td class="pageHeading"><?php echo ATOS_BOARD_PAGE_HEADING ; ?></td</tr> 
     
     
            <form  method="post" enctype="multipart/form-data" action="<?php echo tep_href_link(FILENAME_ATOS_BOARD);?>" name="atos_feed">
     
            <tr>
            <td class="dataTableContent"><?php echo ATOS_BOARD_UPLOAD_TITLE ; ?> <input type="file" name="fichier" size="60">&nbsp;<input type="submit" name="upload" action="<?php echo tep_href_link(FILENAME_ATOS_BOARD);?>" value="<?php echo ATOS_BOARD_UPLOAD ; ?>">
            </td>
        </form>
        </tr>        
        </td>
     
     
    <?php
     // Short Header  
          //
          $header = '
          <table border="0" width="150%">
          <tr>
          <td class="dataTableatos"></td>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Commande #</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Transaction</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">PRIX</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Nom client</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Status Transaction</span> </td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Heure de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Validiter Carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Type de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Numero de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Response Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Certificate</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Authorization Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Capture carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Autoresponse Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Customer Ip_address</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Transaction Condition</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Bank Response Code</span></td>
          </tr><span style="font-size: 8pt">' ;
          //
          // Format complet 
          //
          if ( ATOS_BOARD_LONG_DISPLAY )
          $header = ' </span>
          <table border="0" width="150%">
          <tr>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Commande #</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Entete</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">ID Transaction</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Nom du client</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Merchant Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Payment Means</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Origin Amount</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">PRIX</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Transaction Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Currency Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Heure de Payment</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Validiter Carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Type de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Numero de carte</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Response Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Cvv Response_code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Complementary Code</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Certificate</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Authorization Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Date de Capture</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Return Context</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Autoresponse Status</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Atos Order_id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Customer Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Customer Ip_address</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Account Serial</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Session Id</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Transaction Condition</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Cavv Ucaf</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Complementary Info</span></td>
          <td class="dataTableatos"><span style="font-size: 8pt">Bank Response Code</span></td>
          </tr><span style="font-size: 8pt">' ;
          // Ligne préformatée pour l'affichage de l'import
          //  
          $origin_line_format = '<tr class="CLASS"> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td></tr>' ;
     
          // Format complet 
          //
          if ( ATOS_BOARD_LONG_DISPLAY ) 
    	      $origin_line_format = '<tr class="CLASS"><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td></tr>' ;
     
          $displayPreviousFile = file_exists ( FILENAME_ATOS_LATEST_IMPORT ) ;
     
          if( isset($_POST['upload']) || $displayPreviousFile )
          {
    	  if ( isset($_POST['upload']) )
    	  {
    	    printf('<tr><td class="dataTableatos">%s</tr></td>', ATOS_IMPORT_TITLE) ;
                $tmp_file = $_FILES['fichier']['tmp_name'];
    	  }
    	  else
    	  //
    	  // Affichage de la date du dernier import
    	  //
      	  {
    	     printf('<tr><td class="dataTableatos">%s : <strong>%s</strong></tr></td>', ATOS_LATEST_IMPORT_TITLE, date("d F Y H:i:s", filemtime(FILENAME_ATOS_LATEST_IMPORT))) ; 
    	     $tmp_file = FILENAME_ATOS_LATEST_IMPORT ;
    	  }
     
              if( !is_uploaded_file($tmp_file) && isset($_POST['upload']) ) 
              {
                  echo "Le fichier est introuvable" ;
    	            exit() ;
              }
              $handle = fopen($tmp_file, "r"); // Fichier temporaire détruit automatique a la fin du script
              $lines  = fread($handle, filesize($tmp_file)) ;   
     
              preg_match_all('#TRANSACTION.*#', $lines, $result) ;
     
              $result = array_shift($result) ;
     
              echo $header ;
     
              foreach($result as $line)
              {
                      // Post-format
                      //
                      if ( $i++ % 2 )   $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
                      else              $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ; 
     
                      // Tout va bien !
                      //
                      $error_flag = false ; 
     
                      $val = explode("\t", $line) ;
     
                      // On saute les entêtes ...
                      //
                      if ( $val[0] != "TRANSACTION" )  continue ;
     
                      // Valeurs du journal ATOS
                      //
                      $entete                 = $val[0] ;
                      $transaction_id         = $val[1] ;
                      $merchant_id            = $val[2] ;
                      $payment_means          = $val[3] ;
                      $origin_amount          = $val[4] ;
                      $amount                 = $val[5] ;                  
                      $payment_date           = $val[18] ;
                      $payment_time           = $val[8] ;
                      $card_validity          = $val[9] ;
                      $card_type              = $val[10] ;
                      $card_number            = $val[11] ;
                      $response_code          = $val[12] ;
                      $cvv_response_code      = $val[13] ;
                      $complementary_code     = $val[14] ;
                      $certificate            = $val[15] ;
                      $authorization_id       = $val[16] ;
                      $capture_date           = $val[17] ;
                      $transaction_status     = $val[7] ;
                      $return_context         = $val[19] ;
                      $autoresponse_status    = $val[20] ;
                      $atos_order_id          = $val[21] ;
                      $atos_customer_id       = $val[22] ;
                      $customer_ip_address    = $val[23] ;
                      $account_serial         = $val[24] ;
                      $session_id             = $val[25] ;
                      $transaction_condition  = $val[26] ;
                      $cavv_ucaf              = $val[27] ;
                      $complementary_info     = $val[28] ;
                      $bank_response_code     = $val[29] ;
     
                      // Post-traitements afin d'obtenir des équivalences entre les valeurs ATOS/osC 
                      //
                      $payment_date           = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})/', '\1-\2-\3', $payment_date) ;
                      $payment_time           = preg_replace('/([0-9]{2})([0-9]{2})([0-9]{2})/', '\1:\2:\3', $payment_time) ;
                      $card_number            = preg_replace('/([0-9]{4}).([0-9]{2})/', '\1 #### #### ##\2', $card_number) ;
                      $amount                 = (float)($amount / 100) ;
     
     
     
                      // Récupération du numéro de la commande correspondante
                      // cc_owner disponible (modif de checkout_process.php)
    $query    = 'SELECT o.`orders_id` FROM ' . TABLE_ORDERS . ' o where cc_owner = "' . $transaction_id . '" and cc_number = "' . $card_number . '" ;' ;
     
                      // Obsolète : version avec cc_owner non renseigné (permets d'affecter les anciennes transaction avant modif de checkout_process.php)
                      // décommenter cette ligne pour affecter les anciennes commandes. recommenter ensuite.
                      //$query    = 'SELECT o.`orders_id`,ot.`orders_id`,o.`customers_name`,ot.`customers_name` FROM ' . TABLE_ORDERS . ' o LEFT JOIN ' . TABLE_HOLDING_ORDERS . ' ot on (o.orders_id = ot.orders_id) where o.cc_number = "' . $card_number . '" ;' ;
     
                      $order_qr = tep_db_query($query) ;
                      $order = tep_db_fetch_array($order_qr) ;
                      $orders_id = $order['orders_id'] ;
                      $name = $order['customers_name'] ; 
                      $currency_code          = $name;
                      // Montant de la commande 
                      //
                		  if ( $orders_id )
                      {
                        $query = 'SELECT ot.`value` FROM ' . TABLE_ORDERS_TOTAL . ' ot where class = "ot_total" and orders_id = "' . $orders_id . '"'  ;
                        $orders_total_qr = tep_db_query($query) ;
                        $orders_total = tep_db_fetch_array($orders_total_qr) ;
                        $orders_total_value = sprintf("%.04f", $orders_total['value']) ;  
     
     
                        // Montant de la commande différent de celui de la transaction
                        //
                        if ( $amount != $orders_total_value ) $error_flag = true ;                                  
                      } 
                      else
                      {
                        $orders_total_value = 0 ;
                      } 
     
    /////////////////////////////////////order check//////////////////////////////////////////////////////////
      // Récupération du numéro de la commande correspondante
                      // cc_owner disponible (modif de checkout_process.php)
    		              //
              $query1    = 'SELECT oc.`orders_id`,`customers_name` FROM ' . TABLE_HOLDING_ORDERS . ' oc  where customers_id = "' . $atos_customer_id . '" ;' ;
     
     
                      $order_qr1 = tep_db_query($query1) ;
                      $order1 = tep_db_fetch_array($order_qr1) ;
                      $orders_id1 = $order1['orders_id'] ;
                      $name = $order1['customers_name'] ; 
                      $currency_code          = $name;
     
     
                        if ( $orders_id1 )
                      {
                        $query_check1 = 'SELECT ot.`value` FROM ' . TABLE_HOLDING_ORDERS_TOTAL . ' ot where class = "ot_total" and orders_id = "' . $orders_id1 . '"'  ;
                        $orders_total_qr1 = tep_db_query($query_check1) ;
                        $orders_total1 = tep_db_fetch_array($orders_total_qr1) ;
                        $orders_total_value1 = sprintf("%.04f", $orders_total1['value']) ;  
                            // Montant de la commande différent de celui de la transaction
                        //
                        if ( $amount != $orders_total_value1 ) $error_flag = true ;                                  
                      } 
                      else
                      {
                        $orders_total_value1 = 0 ;
                      } 
     
    /////////////////////////////////////order check//////////////////////////////////////////////////////////
                      // Valeur atos > 0 : Commande invalide
                      //
                      if ( $response_code > 0 )     $error_flag = 1 ; 
     
                      // Si le numéro de commande est vide, commande perdue ???
                      //add ordercheck
                      if ( ! strlen(($orders_id) || ($orders_id1)) )
                      //end ordercheck
                      {
                        $status = "<STRONG>" . ATOS_BOARD_UNKNOWN . "</STRONG>" ;
                        $export = 0 ; // Commande pas trouvée on exporte pas
                      }
                      else
                      {
                        $status = ATOS_BOARD_CREATED ;
                        $export = 1 ;
                      } 
     
                      // Vérification de l'unicité de l'import
                      //
                      if ( $export )
                      {
                        $atos_query = tep_db_query('SELECT a.`orders_id` FROM '. TABLE_ATOS_BOARD . ' a where orders_id = "' . $orders_id . '" ;') ;
                        $atos_qr    = tep_db_fetch_array($atos_query) ;
     
                        if ( strlen($atos_qr['orders_id']) )
                        {
                          $status = ATOS_BOARD_EXISTS ; 
                          $export = 0 ;
                        }
                        //add ordercheck
                        if ( strlen($atos_qr['orders_id1']) )
                        {
                          $status = ATOS_BOARD_EXISTS ; 
                          $export = 0 ;
                          //end ordercheck
                        }
                      }
     
    		  // Lien hypertexte vers la commande
    		  // Add order check/////
    		  if ( $orders_id )
    		   $order_link = '<a href="' . tep_href_link(FILENAME_ORDERS, 'oID=' . $orders_id . '&action=edit') . '" >' . $orders_id . '</a>' ;
    		  else
    		  // Commande non répertoriée 
    		   $order_link = '<a href="' . tep_href_link(FILENAME_ORDERS_CHECK, 'ocID=' . $orders_id1 . '&action=edit') . '" >' . $orders_id1 . '</a>' ;
              // End order check/////
    		  // Status pour les commandes déjà importées
    		  //
    		  if ( ! isset($_POST['upload']) && $displayPreviousFile ) 
    			  $status = '<span style="color:navy;">' . ATOS_BOARD_ARCHIVE . '</span>' ;
     
     
          // Bouton vert ou rouge !
          //
          $image_status = $error_flag ? tep_image(DIR_WS_IMAGES . 'icon_status_red.gif') : tep_image(DIR_WS_IMAGES . 'icon_status_green.gif') ;
     
          // Affichage du résultat de l'importation
          //
    		  if ( ATOS_BOARD_LONG_DISPLAY ) 
    			  printf($line_format, $order_link, $status, $entete, $transaction_id, $merchant_id, $payment_means, $origin_amount, $amount, $currency_code, $payment_date, $payment_time, $card_validity, $card_type, $card_number, $response_code, $cvv_response_code, $complementary_code, $certificate, $authorization_id, $capture_date, $transaction_status, $return_context, $autoresponse_status, $atos_order_id, $customer_id, $customer_ip_address, $account_serial, $session_id, $transaction_condition, $cavv_ucaf, $complementary_info, $bank_response_code) ;
    		  else
    		    printf($line_format, $image_status, $order_link, $status, $transaction_id, $amount, $currency_code, $payment_date, $payment_time, $card_validity, $card_type, $card_number, $response_code, $certificate, $authorization_id, $capture_date, $transaction_status, $autoresponse_status, $customer_ip_address, $transaction_condition, $bank_response_code) ;
     
                      // Insertion dans la table ATOS_BOARD
                      //
                      if ( $export && isset($_POST['upload']) )
                      {
                        $query = 'INSERT into ' . TABLE_ATOS_BOARD . ' (orders_id, entete, transaction_id, merchant_id, payment_means, origin_amount, amount, currency_code, payment_date, payment_time, card_validity, card_type, card_number, response_code, cvv_response_code, complementary_code, certificate, authorization_id, capture_date, transaction_status, return_context, autoresponse_status, atos_order_id, atos_customer_id, customer_ip_address, account_serial, session_id, transaction_condition, cavv_ucaf, complementary_info, bank_response_code) values ( "' . $orders_id . '","' . $entete .  '","' . $transaction_id .  '","' . $merchant_id .  '","' . $payment_means .  '","' . $origin_amount .  '","' . $amount .  '","' . $currency_code .  '","' . $payment_date .  '","' . $payment_time .  '","' . $card_validity .  '","' . $card_type .  '","' . $card_number .  '","' . $response_code .  '","' . $cvv_response_code .  '","' . $complementary_code .  '","' . $certificate .  '","' . $authorization_id .  '","' . $capture_date .  '","' . $transaction_status .  '","' . $return_context .  '","' . $autoresponse_status .  '","' . $atos_order_id .  '","' . $customer_id .  '","' . $customer_ip_address .  '","' . $account_serial .  '","' . $session_id .  '","' . $transaction_condition .  '","' . $cavv_ucaf .  '","' . $complementary_info .  '","' . $bank_response_code . '");' ;
     
                       tep_db_query($query) ;
     
    		   // Générer un fichier backup pour la session en cours
    		   //
    		   $creating_image_file = 1 ; 
                     }  
              }
    	  //
    	  // Backup du fichier de cette session
    	  //
    	  if ( isset($_POST['upload']) && $creating_image_file )
    	    file_put_contents(FILENAME_ATOS_LATEST_IMPORT, $lines) ; 
     
    	  fclose($handle) ;
     
              echo "</table>" ; // Fin table header+lines
          }
    ?>
     
    <!-- Atos Feed End //-->
     
        </table>
    <!-- body_text_eof //-->
      </tr>
    </table>
    <style type="text/css" media="print"> 
    .menu{ 
    display:none; 
    } 
     
    .print{ 
    display:none; 
    } 
     
    <!--@page{size:landscape}--> 
    </style> 
     
     
    <!-- body_eof //-->
     
    <!-- footer //-->
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    <!-- footer_eof //-->
    <br>
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

    merci

  12. #12
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    pour lire du csv c'est avec fgetcsv, je te conseil de faire tes tests avec un autre fichier php, et ensuite l’intégrer dans ton code

  13. #13
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut
    oui en effet j'avais pas vu
    j'ai essayer ce code mais rien n'y fait

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
     
            if( !is_uploaded_file($tmp_file) && isset($_POST['upload']) ) 
              {
                  echo "Le fichier est introuvable" ;
    	            exit() ;
              }
              $handle = fopen($tmp_file, "r"); // Fichier temporaire détruit automatique a la fin du script
              $lines  = fgetcsv($handle, filesize($tmp_file)) ;   
              //$lines  = fread($handle, filesize($tmp_file)) ;   
     
              preg_match_all('#TRANSACTION.*#', $lines, $result) ;
    et j'ai les erreur suivante:

    Warning: preg_match_all() expects parameter 2 to be string, array given in (fonction pre_match)
    Warning: array_shift() [function.array-shift]: The argument should be an array in
    et
    Warning: Invalid argument supplied for foreach()

  14. #14
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    pourquoi tu veux faire un preg_match ?

    regarde bien la doc de fgetcsv (et surtout les exemples ), les paramètres sont faux

  15. #15
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut double tableau
    bonjour et merci encore.

    Il y a du progres maintenant il y a deux tableau un généré avec tous les infos et le normal qui lui est vide

    Voici le code utilisé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
     
    //$handle = fopen($tmp_file, "r"); // Fichier temporaire détruit automatique a la fin du script
             // $lines  = fread($handle, filesize($tmp_file)) ;   
     
             // preg_match_all('#TRANSACTION.*#', $lines, $result) ;
     
              $row = 1;
              $handle = fopen("$tmp_file", "r"); 
              while (($lines = fgetcsv($handle, filesize($tmp_file), 1000, ",")) !== FALSE) {    
              $num = count($lines);    
              echo "<p> $num fields in line $row: <br /></p>\n"; 
              $row++;    
              for ($c=0; $c < $num; $c++) {        echo $lines[$c] . "<br />\n";    }}
     
     
              $result = array_shift($result) ;
     
              echo $header ;
     
              foreach($result as $line)
              {
                      // Post-format
                      //
                      if ( $i++ % 2 )   $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
                      else              $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
    merci en tous cas

  16. #16
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    pas besoin de faire de count + for, pour parcourir un array utilise foreach

  17. #17
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut Warning: Invalid argument supplied for foreach() in
    merci j'ai essayer ce code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    $row = 1;
              $handle = fopen("$tmp_file", "r"); 
              while (($lines = fgetcsv($handle, filesize($tmp_file), 1000, ",")) !== FALSE) {    
              //$num = count($lines);    
              //echo "<p> $num fields in line $row: <br /></p>\n"; 
              //$row++;    
              //for ($c=0; $c < $num; $c++) {        echo $lines[$c] . "<br />\n";    }
     
     
     
              $result = array_shift($lines) ;
              }
     
              echo $header ;
     
              foreach($result as $line)

    amis très franchement je ne vois pas commet faire

    Merci de votre aide

  18. #18
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    oula, y'a je doute que tu comprennes ton propre code la, ton fgetcsv est toujours faux tu n'as pas lu la doc


    plutôt comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    $row = 1;
    $handle = fopen("$tmp_file", "rb"); 
    while (($lines = fgetcsv($handle, 0, ",")) !== FALSE) {    
        echo "<p> $num fields in line $row: <br /></p>\n";
     
        foreach($lines as $field)
        {
            echo "$field</br>\n";
        }
     
        echo "<br />";
    }

  19. #19
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut vraiment désolé
    Je suis vraiment désolé mais j'ai été obligé de le modifier pour l'implémenter dans mon tableau.

    donc j'ai fait ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    64
    65
     
     
     $row = 1;
              $handle = fopen("$tmp_file", "rb"); 
              while (($lines = fgetcsv($handle, 0, ",")) !== FALSE) {    
              echo "<p> $num fields in line $row: <br /></p>\n";
     
                echo $header ;
     
        foreach($lines as $field)
     
     
                      // Post-format
                      //
                      if ( $i++ % 2 )   $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
                      else              $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ; 
     
                      // Tout va bien !
                      //
                      $error_flag = false ; 
     
                      $val = explode("\t", $field) ;
     
                      // On saute les entêtes ...
                      //
                      if ( $val[0] != "TRANSACTION" )  continue ;
     
                      // Valeurs du journal ATOS
                      //
                      $entete                 = $val[0] ;
                      $transaction_id         = $val[1] ;
                      $merchant_id            = $val[2] ;
                      $payment_means          = $val[3] ;
                      $origin_amount          = $val[4] ;
                      $amount                 = $val[5] ;                  
                      $payment_date           = $val[18] ;
                      $payment_time           = $val[8] ;
                      $card_validity          = $val[9] ;
                      $card_type              = $val[10] ;
                      $card_number            = $val[11] ;
                      $response_code          = $val[12] ;
                      $cvv_response_code      = $val[13] ;
                      $complementary_code     = $val[14] ;
                      $certificate            = $val[15] ;
                      $authorization_id       = $val[16] ;
                      $capture_date           = $val[17] ;
                      $transaction_status     = $val[7] ;
                      $return_context         = $val[19] ;
                      $autoresponse_status    = $val[20] ;
                      $atos_order_id          = $val[21] ;
                      $atos_customer_id       = $val[22] ;
                      $customer_ip_address    = $val[23] ;
                      $account_serial         = $val[24] ;
                      $session_id             = $val[25] ;
                      $transaction_condition  = $val[26] ;
                      $cavv_ucaf              = $val[27] ;
                      $complementary_info     = $val[28] ;
                      $bank_response_code     = $val[29] ;
     
                      // Post-traitements afin d'obtenir des équivalences entre les valeurs ATOS/osC 
                      //
                      $payment_date           = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})/', '\1-\2-\3', $payment_date) ;
                      $payment_time           = preg_replace('/([0-9]{2})([0-9]{2})([0-9]{2})/', '\1:\2:\3', $payment_time) ;
                      $card_number            = preg_replace('/([0-9]{4}).([0-9]{2})/', '\1 #### #### ##\2', $card_number) ;
                      $amount                 = (float)($amount / 100) ;
    meintenant ca me donne ca
    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:

    ID Commande # Status ID Transaction PRIX Nom client Status Transaction Date de Payment Heure de Payment Date de Validiter Carte Type de carte Numero de carte Response Code Certificate Authorization Id Date de Capture carte Autoresponse Status Customer Ip_address Transaction Condition Bank Response Code
    fields in line 1:


    merci à vous

Discussions similaires

  1. [MySQL] importation fichier CSV avec php et mysql
    Par NapsterVB dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 08/10/2013, 10h01
  2. importé un fichier csv en php
    Par crush09 dans le forum Langage
    Réponses: 5
    Dernier message: 27/07/2012, 23h01
  3. Importer un fichier .csv avec php et PDO
    Par Touny dans le forum Langage
    Réponses: 6
    Dernier message: 05/03/2009, 17h45
  4. [CSV] Fichier CSV en PHP
    Par rimeh dans le forum Langage
    Réponses: 1
    Dernier message: 11/01/2007, 12h01
  5. importation d'un fichier csv
    Par bidson dans le forum XMLRAD
    Réponses: 14
    Dernier message: 22/12/2005, 13h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo