Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By mpmichael
#783805
Hello,

i try to generate a *.csv-File from a Grid. But it doesn't work.
pro_grid is my Grid-Variable
I used the following code...
Code: Select all
$outputdata = "AnlagenNr; Proviart; KdNr; Name;Agent; Umsatz; Volumen"; 
$file = "testfile.csv";
$gridrows = $("#pro_grid").find(".pmdynaform-grid-row");

alert("Starte Datei " + $file); // only for test

file_put_contents($file, $outputdata);

for (i=1; i <= gridrows.length; i++) 
  {
    $outputdata = "";
    $outputdata = document.getElementById("form[pro_grid]["+i+"][Uniid]").value + ";";
    $outputdata = $outputdata + document.getElementById("form[pro_grid]["+i+"][proviart]").value + ";";
    $outputdata = $outputdata + document.getElementById("form[pro_grid]["+i+"][sis_kdnr]").value + ";";
    $outputdata = $outputdata + document.getElementById("form[pro_grid]["+i+"][SISKdName]").value + ";";
    $outputdata = $outputdata + document.getElementById("form[pro_grid]["+i+"][Agent]").value + ";";
    $outputdata = $outputdata + document.getElementById("form[pro_grid]["+i+"][umsatz]").value + ";";
    $outputdata = $outputdata + document.getElementById("form[pro_grid]["+i+"][Proivalue]").value + ";";
    file_put_contents($file, $outputdata, FILE_APPEND);
  }

alert("Datei " + $file + " wurde mit " + gridrows.length +  " Zeilen erstellt"); // only for test
any clue what's wrong - I guess the grind handling, but I'm not sure...
thanks
mpm
By rundyz
#783954
Hi there,

alert() i don't think is a valid php function- perhaps take that out

it looks like you're trying to do javascript in php or vice versa-

the fputs and $ references are php, and functions like alert are javascript

try more like the following
Code: Select all
 
$tot = count(@=pro_grid);
for ($cnt = 1; $cnt <= $tot; $cnt++) {
    $outputdata = "";
    $outputdata .= @=pro_grid[$cnt]['Uniid'] . ':';
    $outputdata .= @=pro_grid[$cnt]['proviart'] . ':';
    $outputdata .= @=pro_grid[$cnt]['sis_kdnr'] . ':';
    $outputdata .= @=pro_grid[$cnt]['SISKdName'] . ':';
    $outputdata .= @=pro_grid[$cnt]['Agent'] . ':';
    $outputdata .= @=pro_grid[$cnt]['umsatz'] . ':';
    $outputdata .= @=pro_grid[$cnt]['Proivalue'] . ':';
    file_put_contents($file, $outputdata, FILE_APPEND);
it's not complete but you may want to look into a stream download for the file, but even after that not sure howto keep the case running
http://ran.ge/2009/10/27/howto-create-stream-csv-php/

In recent years, online gambling games have provid[…]

If you want to import OST files into Outlook then […]

Site officiel:- www.fitprodiet.com/cordyceps-avis[…]

Site officiel:- www.fitprodiet.com/cordyceps-avis[…]