Exemple #1
0
 $obj = new $classname($db, $datatoimport);
 // Load source fields in input file
 $fieldssource = array();
 $result = $obj->import_open_file($conf->import->dir_temp . '/' . $filetoimport, $langs);
 if ($result >= 0) {
     // Read first line
     $arrayrecord = $obj->import_read_record();
     // Put into array fieldssource starting with 1.
     $i = 1;
     foreach ($arrayrecord as $key => $val) {
         $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24);
         $i++;
     }
     $obj->import_close_file();
 }
 $nboflines = !empty($_GET["nboflines"]) ? $_GET["nboflines"] : dol_count_nb_of_line($conf->import->dir_temp . '/' . $filetoimport);
 $param = '&format=' . $format . '&datatoimport=' . $datatoimport . '&filetoimport=' . urlencode($filetoimport) . '&nboflines=' . $nboflines;
 if ($excludefirstline) {
     $param .= '&excludefirstline=1';
 }
 llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
 $head = import_prepare_head($param, 6);
 dol_fiche_head($head, 'step6', $langs->trans("NewImport"));
 print '<table width="100%" class="border">';
 // Module
 print '<tr><td width="25%">' . $langs->trans("Module") . '</td>';
 print '<td>';
 //print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
 print $objimport->array_import_module[0]->getName();
 print '</td></tr>';
 // Lot de donnees a importer
Exemple #2
0
   /**
    * testDolCountNbOfLine
    *
    * @return	int
    */
    public function testDolCountNbOfLine()
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$file=dirname(__FILE__).'/Example_import_company_1.csv';
		$result=dol_count_nb_of_line($file);
    	print __METHOD__." result=".$result."\n";
		$this->assertEquals(2,$result);

		return $result;
    }