]> _ Git - cubeextranet.git/commitdiff
Spreadsheet adjustments. Wait #5051 @1.25
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 27 Jun 2022 08:40:07 +0000 (08:40 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 27 Jun 2022 08:40:07 +0000 (08:40 +0000)
inc/ws/Controlleur/class.ws.services.php

index ea6242825d6e81513601f15d89a1c869bf4c732a..62a2cb1c39e68bf7bec1cce5be3cf99133ce93a6 100644 (file)
@@ -1455,14 +1455,30 @@ class wsServices extends cubeFlashGateway
 
             // Look up the value by the column keys to ensure the correct order of values
             foreach (array_keys($column_headings) as $column_index => $column_key) {
-                $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]);
 
                 $current_cell_style = $sheet->getStyleByColumnAndRow($column_index, $current_row);
 
-                if (in_array($column_key, ['PRIX HT', 'PRIX TTC'])) {
-                    $current_cell_style->getNumberFormat()->setFormatCode($euro_currency_format);
-                } elseif (in_array($column_key, ['QTE', 'QTE MINI'])) {
-                    $current_cell_style->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
+                switch($column_key) {
+                    case 'EAN': // Ensure EAN doesn't contain commas (it's a number, not a string)
+                        $EAN = str_replace(',', '', $cart_item[$column_key]);
+                        $sheet->setCellValueByColumnAndRow($column_index, $current_row, $EAN);
+                        $current_cell_style->getNumberFormat()->setFormatCode('#,##0'); // Comma separated, no decimals
+                        break;
+                    case 'REF': // Explicitly store REF as text in order to preserve leading zeros
+                        $sheet->setCellValueExplicitByColumnAndRow($column_index, $current_row, $cart_item[$column_key], PHPExcel_Cell_DataType::TYPE_STRING);
+                        break;
+                    case 'PRIX HT':
+                    case 'PRIX TTC':
+                        $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]);
+                        $current_cell_style->getNumberFormat()->setFormatCode($euro_currency_format);
+                        break;
+                    case 'QTE':
+                    case 'QTE MINI':
+                        $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]);
+                        $current_cell_style->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
+                        break;
+                    default:
+                        $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]);
                 }
 
             }