Skip to content

Commit

Permalink
Fix: Wrong count of nb of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 20, 2012
1 parent 0340403 commit 7fd27da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion htdocs/core/lib/files.lib.php
Expand Up @@ -383,7 +383,8 @@ function dol_count_nb_of_line($file)
while (!feof($fp))
{
$line=fgets($fp);
$nb++;
// We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
if (! $line === false) $nb++;
}
fclose($fp);
}
Expand Down
20 changes: 11 additions & 9 deletions htdocs/core/modules/import/import_csv.modules.php
Expand Up @@ -452,17 +452,19 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
}

// Loop on each hidden fields
foreach($objimport->array_import_fieldshidden[0] as $key => $val)
if (is_array($objimport->array_import_fieldshidden[0]))
{
if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table
if ($listfields) { $listfields.=', '; $listvalues.=', '; }
if ($val == 'user->id')
{
$listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues.=$user->id;
}
foreach($objimport->array_import_fieldshidden[0] as $key => $val)
{
if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table
if ($listfields) { $listfields.=', '; $listvalues.=', '; }
if ($val == 'user->id')
{
$listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues.=$user->id;
}
}
}

//print 'Show listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>';

if (! $errorforthistable)
Expand Down
11 changes: 7 additions & 4 deletions htdocs/core/modules/modProduct.class.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
Expand All @@ -21,10 +21,13 @@

/**
* \defgroup produit Module products
* \brief Module pour gerer le suivi de produits predefinis
* \brief Module to manage catalog of predefined products
*/

/**
* \file htdocs/core/modules/modProduct.class.php
* \ingroup produit
* \brief Fichier de description et activation du module Produit
* \brief File to describe module to manage catalog of predefined products
*/

include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
Expand Down Expand Up @@ -154,7 +157,7 @@ function modProduct($db)
$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.duration'=>"Duration",'p.weight'=>"Weight",'p.volume'=>"Volume",'p.datec'=>'DateCreation*');
$this->import_entities_array[$r]=array(); // We define here only fields that use another picto
$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]','p.tobuy'=>'^[0|1]','p.fk_product_type'=>'^[0|1]','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_examplevalues_array[$r]=array('p.ref'=>"PR123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
}

Expand Down

0 comments on commit 7fd27da

Please sign in to comment.