Code comment
This commit is contained in:
parent
fe103f0492
commit
8429de031f
@ -269,7 +269,7 @@ class ImportCsv extends ModeleImports
|
||||
* @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
|
||||
* @param int $maxfields Max number of fields to use
|
||||
* @param string $importid Import key
|
||||
* @param array $updatekeys Array of keys to use to try to do update
|
||||
* @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor.
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys)
|
||||
@ -588,6 +588,7 @@ class ImportCsv extends ModeleImports
|
||||
{
|
||||
$updatedone = false;
|
||||
$insertdone = false;
|
||||
|
||||
if (!empty($updatekeys)) {
|
||||
// We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields)
|
||||
if (empty($lastinsertid)) {
|
||||
|
||||
@ -136,17 +136,18 @@ class ImportXlsx extends ModeleImports
|
||||
*/
|
||||
function write_title_example($outputlangs,$headerlinefields)
|
||||
{
|
||||
global $conf;
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
|
||||
global $conf;
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
|
||||
|
||||
$col = 0;
|
||||
foreach($headerlinefields as $field) {
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field));
|
||||
// set autowidth
|
||||
//$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true);
|
||||
$col++;
|
||||
}
|
||||
|
||||
$col = 0;
|
||||
foreach($headerlinefields as $field) {
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field));
|
||||
// set autowidth
|
||||
//$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true);
|
||||
$col++;
|
||||
}
|
||||
return ''; // final output will be generated in footer
|
||||
}
|
||||
|
||||
@ -159,13 +160,14 @@ class ImportXlsx extends ModeleImports
|
||||
*/
|
||||
function write_record_example($outputlangs,$contentlinevalues)
|
||||
{
|
||||
$col = 0;
|
||||
$row = 2;
|
||||
foreach($contentlinevalues as $cell) {
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell);
|
||||
$col++;
|
||||
}
|
||||
return ''; // final output will be generated in footer
|
||||
$col = 0;
|
||||
$row = 2;
|
||||
foreach($contentlinevalues as $cell) {
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell);
|
||||
$col++;
|
||||
}
|
||||
|
||||
return ''; // final output will be generated in footer
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,15 +179,15 @@ class ImportXlsx extends ModeleImports
|
||||
function write_footer_example($outputlangs)
|
||||
{
|
||||
// return te file content as a string
|
||||
$tempfile = tempnam(sys_get_temp_dir(), 'dol');
|
||||
$objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
|
||||
$objWriter->save($tempfile);
|
||||
$this->workbook->disconnectWorksheets();
|
||||
unset($this->workbook);
|
||||
$tempfile = tempnam(sys_get_temp_dir(), 'dol');
|
||||
$objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
|
||||
$objWriter->save($tempfile);
|
||||
$this->workbook->disconnectWorksheets();
|
||||
unset($this->workbook);
|
||||
|
||||
$content = file_get_contents($tempfile);
|
||||
unlink($tempfile);
|
||||
return $content;
|
||||
$content = file_get_contents($tempfile);
|
||||
unlink($tempfile);
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@ -223,13 +225,13 @@ class ImportXlsx extends ModeleImports
|
||||
$reader = new PHPExcel_Reader_Excel2007();
|
||||
$this->workbook = $reader->load($file);
|
||||
|
||||
$rowcount = $this->workbook->getActiveSheet()->getHighestDataRow();
|
||||
$rowcount = $this->workbook->getActiveSheet()->getHighestDataRow();
|
||||
|
||||
$this->workbook->disconnectWorksheets();
|
||||
unset($this->workbook);
|
||||
$this->workbook->disconnectWorksheets();
|
||||
unset($this->workbook);
|
||||
|
||||
return $rowcount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -292,7 +294,7 @@ class ImportXlsx extends ModeleImports
|
||||
* @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
|
||||
* @param int $maxfields Max number of fields to use
|
||||
* @param string $importid Import key
|
||||
* @param array $updatekeys Array of keys to use to try to do update
|
||||
* @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor.
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
// What is this doing here ? it is common to all imports, is should be in the parent class
|
||||
|
||||
Loading…
Reference in New Issue
Block a user