Submitted by Laurent81 on
Bonjour,
savez vous si il est possible de sauvegarder un fichier csv issu d'une view jqgrid directement sur le serveur ?
sous sites/default/files/public/private/USER par exemple ?
il faut le login FTP , mot de passe et path je suppose?
Merci !
<?php
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
//$grid->debug = true;
//$grid->logtofile = false;
$grid->showError = true;
$grid->SelectCommand = 'SELECT ' . $ChaineDeCarac . ' FROM ' . $table_export1 .' INNER JOIN ' . $table_export2 . ' USING(numident)';
$grid->dataType = 'json';
// Let the grid create the model
$grid->table = $table_export1;
$grid->setPrimaryKeyId('numident');
//$grid->serialKey = false;
$grid->setColModel();
$grid->setColProperty('numident',array("editable"=>false));
// Set the url from where we obtain the data
//$grid->setUrl('/node/'.$node->vid.'/submission/'.$submission->sid.'/export/1'); // Erreur ancien code
$grid->setUrl('/node/'.$node->nid.'/submission/'.$submission->sid.'/export/1'); // Erreur ancien code
// Set grid caption using the option caption
$grid->setGridOptions(array(
"caption"=>"Data to export",
"rownumbers"=>true,
"rownumWidth"=>35,
"rowNum"=>20,
"width"=>1000,
"height"=>340,
"rowList"=>array(20,50),
"shrinkToFit"=>false,
));
$grid->navigator = true;
$grid->setNavOptions('navigator', array(
"csv" => true,
"excel"=>false,
"add"=>false,
"edit"=>false,
"del"=>false,
"view"=>true,
"search"=>true,
"refresh"=>true,
));
$grid->csvfile = $node->title . '_' . $submission->sid . '.csv';
if (arg(5) == 1) {
$output = $grid->renderGrid("#grid","#pager",true,null,null,true,true,true);
} else {
$output = $grid->renderGrid("#grid","#pager",true,null,null,true,true,false);
}
$conn = null;
return $output;
}
?>