is this possible with model? - El Forum - 10-27-2008
[eluser]syntaxerror[/eluser]
hi,
i have an input field, my variable for it is $directory.
is it possible that 2 models will received the input data?
controller:
Code: function process()
{
$data['title'] = "DS Validator";
$data['header'] = "DS Validator";
$data['batch'] = $this->process_model->directory(); // first model to received the input
$this->process_model->export(); // 2nd model to received the input
$this->load->view('process', $data);
}
function export()
{
$data['title'] = "DS Validator Export";
$data['header'] = "DS Validator Export";
$data['excel_file'] = $this->process_model->export();
$this->load->view('export', $data);
}
model
Code: function directory()
{
$title = "DS Validator Results";
$header = "DS Validator Results";
$kebase = "//asecasianas2/DS_Keying/STATS/KE-DIR/";
$qcbase = "//asecasianas2/DS_Keying/STATS/QC-DIR/";
$dir = $this->input->post('directory');
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
return array($kebase,
$qcbase,
$dir,
$kedir,
$qcdir,
$kefiles,
$qcfiles,
$count_files,
$title,
$header);
}
function export()
{
$title = "DS Validator Results";
$header = "DS Validator Results";
$kebase = "//asecasianas2/DS_Keying/STATS/KE-DIR/";
$qcbase = "//asecasianas2/DS_Keying/STATS/QC-DIR/";
$dir = $this->input->post('directory');
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
return array($kebase,
$qcbase,
$dir,
$kedir,
$qcdir,
$kefiles,
$qcfiles,
$count_files,
$title,
$header);
}
but this script doesnt work.
please help
thanks
is this possible with model? - El Forum - 10-27-2008
[eluser]dmiden[/eluser]
Hi!
If you have a form with the input field name 'directory' and it's posted you could use:
Code: function process()
{
$directory = $this->input->post('directory', true);
$data['title'] = "DS Validator";
$data['header'] = "DS Validator";
$data['batch'] = $this->process_model->directory($directory); // first model to received the input
$this->process_model->export($directory); // 2nd model to received the input
$this->load->view('process', $data);
}
function export()
{
$directory = $this->input->post('directory', true);
$data['title'] = "DS Validator Export";
$data['header'] = "DS Validator Export";
$data['excel_file'] = $this->process_model->export($directory);
$this->load->view('export', $data);
}
model
Code: function directory($dir)
{
$title = "DS Validator Results";
$header = "DS Validator Results";
$kebase = "//asecasianas2/DS_Keying/STATS/KE-DIR/";
$qcbase = "//asecasianas2/DS_Keying/STATS/QC-DIR/";
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
return array($kebase,
$qcbase,
$dir,
$kedir,
$qcdir,
$kefiles,
$qcfiles,
$count_files,
$title,
$header);
}
function export($dir)
{
$title = "DS Validator Results";
$header = "DS Validator Results";
$kebase = "//asecasianas2/DS_Keying/STATS/KE-DIR/";
$qcbase = "//asecasianas2/DS_Keying/STATS/QC-DIR/";
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
return array($kebase,
$qcbase,
$dir,
$kedir,
$qcdir,
$kefiles,
$qcfiles,
$count_files,
$title,
$header);
}
is this possible with model? - El Forum - 10-27-2008
[eluser]xwero[/eluser]
There is no reason why the directory value would be destroyed between models but you have to check if there is actually a value and if not you should set a default value.
is this possible with model? - El Forum - 10-27-2008
[eluser]syntaxerror[/eluser]
same error....
is this possible with model? - El Forum - 10-27-2008
[eluser]syntaxerror[/eluser]
my first model works ok, and i want to export the result to excel,
so i came up an idea to duplicate the view (2nd model) and insert it with header() to trigger the
exportation. but the 2nd model doesnt even received the input data of the directory.
is this possible with model? - El Forum - 10-27-2008
[eluser]dmiden[/eluser]
When you use header() the 2nd controller won't get the data outputted by the first controller.
Why dont you just perform your code in the first controller and a single view ?
is this possible with model? - El Forum - 10-27-2008
[eluser]syntaxerror[/eluser]
actually i have successfully exported the data to excel,
but the problem is how can i trigger the exportation.
is this possible with model? - El Forum - 10-27-2008
[eluser]metaltapimenye[/eluser]
Code: function process()
{
$directory = $this->input->post('directory', true);
$data['title'] = "DS Validator";
$data['header'] = "DS Validator";
$data['batch'] = $this->process_model->directory($directory); // first model to received the input
$this->process_model->export($directory); // 2nd model to received the input
$this->load->view('process', $data);
}
models:
Code: function directory($dir)
{
$title = "DS Validator Results";
$header = "DS Validator Results";
$kebase = "//asecasianas2/DS_Keying/STATS/KE-DIR/";
$qcbase = "//asecasianas2/DS_Keying/STATS/QC-DIR/";
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
###penetrate here:untested
$this->export($dir);
return array($kebase,
$qcbase,
$dir,
$kedir,
$qcdir,
$kefiles,
$qcfiles,
$count_files,
$title,
$header);
}
function export($dir)
{
$title = "DS Validator Results";
$header = "DS Validator Results";
$kebase = "//asecasianas2/DS_Keying/STATS/KE-DIR/";
$qcbase = "//asecasianas2/DS_Keying/STATS/QC-DIR/";
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
return array($kebase,
$qcbase,
$dir,
$kedir,
$qcdir,
$kefiles,
$qcfiles,
$count_files,
$title,
$header);
}
i just giva a shoot
is this possible with model? - El Forum - 10-27-2008
[eluser]syntaxerror[/eluser]
unsuccessful... :blank:
Code: Home
export
2 files found in directory
A PHP Error was encountered
Severity: Warning
Message: file(//asecasianas2/DS_Keying/STATS/KE-DIR//SC29490) [function.file]: failed to open stream: Permission denied
Filename: views/export.php
Line Number: 43
A PHP Error was encountered
Severity: Warning
Message: file(//asecasianas2/DS_Keying/STATS/QC-DIR//SC29490) [function.file]: failed to open stream: Permission denied
Filename: views/export.php
Line Number: 44
Batch/Line Field Image Minor Error Major Error
SC29490
Total
is this possible with model? - El Forum - 10-27-2008
[eluser]xwero[/eluser]
I think the problem is the two forward slashes in the end? I don't see where it's added so i assume you add them yourself?
|