31require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.class.php';
53 public $version =
'dolibarr';
80 public $cacheconvert = array();
82 public $cachefieldtable = array();
106 parent::__construct();
110 $this->enclosure =
'"';
114 $this->label =
'Csv';
115 $this->desc = $langs->trans(
"CSVFormatDesc", $this->separator, $this->enclosure, $this->escape);
116 $this->extension =
'csv';
117 $this->picto =
'mime/other';
118 $this->version =
'1.34';
119 $this->phpmin = array(7, 0);
121 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
123 dol_syslog(
"Module need a higher PHP version");
124 $this->error =
"Module need a higher PHP version";
129 $this->label_lib =
'Dolibarr';
130 $this->version_lib = DOL_VERSION;
132 $this->datatoimport = $datatoimport;
133 if (preg_match(
'/^societe_/', $datatoimport)) {
134 $this->thirdpartyobject =
new Societe($this->db);
163 $s = implode($this->separator, array_map(
'cleansep', $headerlinefields));
178 $s = implode($this->separator, array_map(
'cleansep', $contentlinevalues));
209 dol_syslog(get_class($this).
"::open_file file=".$file);
211 ini_set(
'auto_detect_line_endings', 1);
215 $langs->load(
"errors");
216 $this->error = $langs->trans(
"ErrorFailToOpenFile", $file);
219 $this->handle = $handle;
263 $arrayres = fgetcsv($this->handle, 100000, $this->separator, $this->enclosure, $this->escape);
266 if ($arrayres ===
false) {
272 $newarrayres = array();
275 if ($arrayres && is_array($arrayres)) {
276 foreach ($arrayres as $key => $val) {
279 $newarrayres[$key][
'val'] = $val;
280 $newarrayres[$key][
'type'] = (
dol_strlen($val) ? 1 : -1);
282 $newarrayres[$key][
'val'] = mb_convert_encoding($val,
'UTF-8',
'ISO-8859-1');
283 $newarrayres[$key][
'type'] = (
dol_strlen($val) ? 1 : -1);
287 $newarrayres[$key][
'val'] = $val;
288 $newarrayres[$key][
'type'] = (
dol_strlen($val) ? 1 : -1);
290 $newarrayres[$key][
'val'] = mb_convert_encoding($val,
'UTF-8',
'ISO-8859-1');
291 $newarrayres[$key][
'type'] = (
dol_strlen($val) ? 1 : -1);
295 $newarrayres[$key][
'val'] = trim($newarrayres[$key][
'val']);
298 $this->col = count($newarrayres);
313 fclose($this->handle);
330 public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys)
333 return $this->
commonImportInsert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys, 0);
345 return str_replace(array(
',',
';'),
'/', $value);
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Class to import CSV files.
write_header_example($outputlangs)
Output header of an example file for this format.
import_get_nb_of_lines($file)
Return nb of records.
import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys)
Insert a record into database.
__construct($db, $datatoimport)
Constructor.
import_read_record()
Return array of next record in input file.
write_record_example($outputlangs, $contentlinevalues)
Output record of an example file for this format.
write_footer_example($outputlangs)
Output footer of an example file for this format.
import_close_file()
Close file handle.
import_read_header()
Input header line from file.
write_title_example($outputlangs, $headerlinefields)
Output title line of an example file for this format.
import_open_file($file)
Open input file.
Parent class for import file readers.
commonImportInsert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys, $recordpositionbase=0)
Shared implementation of import_insert for CSV/XLSX.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_count_nb_of_line($file)
Count number of lines in a file.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
utf8_check($str)
Check if a string is in UTF8.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
cleansep($value)
Clean a string from separator.