hi all
i'm trying to putting a list of files in a zip to download
event: download_zip
{fn:read_selected} (my file list)
{fn:crea_zip} (a php custom code)
read_selected works ok and i have to take my filenames from documento (joining with a path in php)
filename element is "documento"[pre]Array
(
[read_selected] => Array
(
[log] => Array
(
[0] => SELECT `selected`.`aid` AS `selected.aid`, `selected`.`user_id` AS `selected.user_id`, `selected`.`created` AS `selected.created`, `selected`.`modified` AS `selected.modified`, `selected`.`cliente` AS `selected.cliente`, `selected`.`azienda` AS `selected.azienda`, `selected`.`uuidcli` AS `selected.uuidcli`, `selected`.`uuidazi` AS `selected.uuidazi`, `selected`.`uuiddip` AS `selected.uuiddip`, `selected`.`uuiddoc` AS `selected.uuiddoc`, `selected`.`idtipodoc` AS `selected.idtipodoc`, `selected`.`documento` AS `selected.documento`, `selected`.`descrizione` AS `selected.descrizione`, `selected`.`tipodoc` AS `selected.tipodoc`, `selected`.`datadoc` AS `selected.datadoc`, `selected`.`dadata` AS `selected.dadata`, `selected`.`adata` AS `selected.adata`, `selected`.`scaricato` AS `selected.scaricato`, `selected`.`data_scaricato` AS `selected.data_scaricato`, `selected`.`tstamp` AS `selected.tstamp` FROM `vuxdoccli` AS `selected` WHERE `selected`.`uuiddoc` IN ('test1', 'test2', 'test2', 'test2') GROUP BY `selected.uuiddoc`;[br] )[br][br] [var] => Array[br] ([br] [0] => Array[br] ([br] [selected] => Array[br] ([br] [aid] => 1[br] [user_id] => 0[br] [created] => 0000-00-00 00:00:00[br] [modified] => 2020-02-09 15:44:02[br] [cliente] => test1[br] [azienda] => test1AZI[br] [uuidcli] => cliente1[br] [uuidazi] => uuidtest1azi[br] [uuiddip] => [br] [uuiddoc] => test1[br] [idtipodoc] => 45[br] [documento] => test1.pdf[br] [descrizione] => Giudizio[br] [tipodoc] => CERT_EL_CLI[br] [datadoc] => 2020-01-29 00:00:00[br] [dadata] => 2020-01-01 00:00:00[br] [adata] => 2020-01-31 00:00:00[br] [scaricato] => 1[br] [data_scaricato] => 2020-02-09 15:44:02[br] [tstamp] => 2020-02-14 23:50:59[br] )[br][br] )[br][br] [1] => Array[br] ([br] [selected] => Array[br] ([br] [aid] => 2[br] [user_id] => 0[br] [created] => 0000-00-00 00:00:00[br] [modified] => 2020-02-09 15:44:11[br] [cliente] => test1[br] [azienda] => test2AZI[br] [uuidcli] => cliente1[br] [uuidazi] => [br] [uuiddip] => [br] [uuiddoc] => test2[br] [idtipodoc] => 46[br] [documento] => test2.pdf[br] [descrizione] => Registro[br] [tipodoc] => REGiSTRO_VISITE[br] [datadoc] => 2019-12-01 00:00:00[br] [dadata] => 2019-01-01 00:00:00[br] [adata] => 2019-12-31 00:00:00[br] [scaricato] => 1[br] [data_scaricato] => 2020-02-09 15:44:11[br] [tstamp] => 2020-02-14 23:51:17[br] )[br][br] )[br][br] )[br][br] )[br][br])[/pre]
now, with php, i want to take array, iterate with foreach and pass filenames ("documento") to php zip function
this is my php ({fn:crea_zip}) VAR ONLY RESULTS
i think i don't take array and i can't understand if i can use {var:read_selected} in some way inside php[br]if i activate errors, it says [br]warning: invalid argument supplied for foreach....[br][br]can you correct my code so i can understand how to iterate read_selected (every element is a record, so after i have to point them to take filenames)[br]
i need it in php
[br]thank you
edit: typo
i'm trying to putting a list of files in a zip to download
event: download_zip
{fn:read_selected} (my file list)
{fn:crea_zip} (a php custom code)
read_selected works ok and i have to take my filenames from documento (joining with a path in php)
filename element is "documento"[pre]Array
(
[read_selected] => Array
(
[log] => Array
(
[0] => SELECT `selected`.`aid` AS `selected.aid`, `selected`.`user_id` AS `selected.user_id`, `selected`.`created` AS `selected.created`, `selected`.`modified` AS `selected.modified`, `selected`.`cliente` AS `selected.cliente`, `selected`.`azienda` AS `selected.azienda`, `selected`.`uuidcli` AS `selected.uuidcli`, `selected`.`uuidazi` AS `selected.uuidazi`, `selected`.`uuiddip` AS `selected.uuiddip`, `selected`.`uuiddoc` AS `selected.uuiddoc`, `selected`.`idtipodoc` AS `selected.idtipodoc`, `selected`.`documento` AS `selected.documento`, `selected`.`descrizione` AS `selected.descrizione`, `selected`.`tipodoc` AS `selected.tipodoc`, `selected`.`datadoc` AS `selected.datadoc`, `selected`.`dadata` AS `selected.dadata`, `selected`.`adata` AS `selected.adata`, `selected`.`scaricato` AS `selected.scaricato`, `selected`.`data_scaricato` AS `selected.data_scaricato`, `selected`.`tstamp` AS `selected.tstamp` FROM `vuxdoccli` AS `selected` WHERE `selected`.`uuiddoc` IN ('test1', 'test2', 'test2', 'test2') GROUP BY `selected.uuiddoc`;[br] )[br][br] [var] => Array[br] ([br] [0] => Array[br] ([br] [selected] => Array[br] ([br] [aid] => 1[br] [user_id] => 0[br] [created] => 0000-00-00 00:00:00[br] [modified] => 2020-02-09 15:44:02[br] [cliente] => test1[br] [azienda] => test1AZI[br] [uuidcli] => cliente1[br] [uuidazi] => uuidtest1azi[br] [uuiddip] => [br] [uuiddoc] => test1[br] [idtipodoc] => 45[br] [documento] => test1.pdf[br] [descrizione] => Giudizio[br] [tipodoc] => CERT_EL_CLI[br] [datadoc] => 2020-01-29 00:00:00[br] [dadata] => 2020-01-01 00:00:00[br] [adata] => 2020-01-31 00:00:00[br] [scaricato] => 1[br] [data_scaricato] => 2020-02-09 15:44:02[br] [tstamp] => 2020-02-14 23:50:59[br] )[br][br] )[br][br] [1] => Array[br] ([br] [selected] => Array[br] ([br] [aid] => 2[br] [user_id] => 0[br] [created] => 0000-00-00 00:00:00[br] [modified] => 2020-02-09 15:44:11[br] [cliente] => test1[br] [azienda] => test2AZI[br] [uuidcli] => cliente1[br] [uuidazi] => [br] [uuiddip] => [br] [uuiddoc] => test2[br] [idtipodoc] => 46[br] [documento] => test2.pdf[br] [descrizione] => Registro[br] [tipodoc] => REGiSTRO_VISITE[br] [datadoc] => 2019-12-01 00:00:00[br] [dadata] => 2019-01-01 00:00:00[br] [adata] => 2019-12-31 00:00:00[br] [scaricato] => 1[br] [data_scaricato] => 2020-02-09 15:44:11[br] [tstamp] => 2020-02-14 23:51:17[br] )[br][br] )[br][br] )[br][br] )[br][br])[/pre]
now, with php, i want to take array, iterate with foreach and pass filenames ("documento") to php zip function
this is my php ({fn:crea_zip}) VAR ONLY RESULTS
// todo :There should be a lot of logic errors after entering foreach, i'll have to debug it but it never enter foreach loop.
// verify if files exists
// give zip file a unique name and destroy after download
// debug
// docs folder
$pathbase="/mydocs/";
// zip file to create
$pathzip=$pathbase."/zip/";
$nomezip=$pathzip."test.zip";
//THIS part, i think, doesn't wok, i can't take array
// i try a lot of combinations but i can't understand the right syntax
$array_file=array();
$this->get("read_selected","default");
$array_file=$this->data("read_selected");
$zip = new ZipArchive();
// iterate array
foreach ($array_file as $filedatrattare) {
$fileattuale=$filedatrattare["documento"];
// add files to zip
$aggiungizip=$pathbase.$fileattuale;
if($zip->open($nomezip, ZIPARCHIVE::CREATE)) {
// se esiste il file lo aggiunge
if (file_exists($aggiungizip)) {
$zip->addFile($aggiungizip);
echo "NOME FILE ".$aggiungizip;
}else{
echo 'il file NON esiste : '.$aggiungizip;
}
}
$zip->close();
unset($zip);
}
?>
i think i don't take array and i can't understand if i can use {var:read_selected} in some way inside php[br]if i activate errors, it says [br]warning: invalid argument supplied for foreach....[br][br]can you correct my code so i can understand how to iterate read_selected (every element is a record, so after i have to point them to take filenames)[br]
i need it in php
[br]thank you
edit: typo