Home » HTML » HTML_QuickForm » Bug #1481
Controller/Hierselect conflict
Details
| Submitted | 2004-05-24 15:09 UTC |
|---|---|
| From | mfilizzi at ssi-c dot com |
| Status | Duplicate |
| Package | HTML_QuickForm |
| PHP Version | 4.3.4 |
| OS | Debian GNU/Linux |
| Roadmaps | (Not assigned) |
Comments
[2004-05-24 15:09 UTC] mfilizzi at ssi-c dot com
Description:
------------
When using the controller and Hierselect I receive the
following error. It happens when you change pages (ie. go
to the next page or previous page).
Actual result:
--------------
Parse error: parse error, expecting `']''
in /usr/share/php/HTML/QuickForm/hierselect.php(222) :
eval()'d code on line 1
[2004-05-25 16:49 UTC] mfilizzi at ssi-c dot com
Here is one of the files in which this problem occurs. As
noted having the eval lines use ' around the items inside
the [] appears to solve the problem with no ill effects.
-- CODE
<?php
require_once ("../lib/include.php");
require_once(TEMPLATE_PATH.'EMS_Template_Default.php');
require_once 'HTML/QuickForm/Controller.php';
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/element.php';
require_once 'HTML/QuickForm/Action/Display.php';
require_once 'HTML/QuickForm/input.php';
require_once(ACTION_PATH.'QuickForm_Controller_Functions/Display.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/SF1449.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/Customer.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/Customer_Address.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/Equipment_Continuation.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/Equipment.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/Funding_Document.php');
require_once(DATA_PATH.'EMS_DB_DataObjects/Equipment_FundDoc.php');
$view = new EMS_Template_Default;
//Change ME!
$auth = $view->auth("office_groups");
$labels = $view->getLabels();
$template = $view->start();
class ActionProcess extends HTML_QuickForm_Action
{
function perform(&$page, $actionName)
{
$values =
$page->controller->exportValues('Page2');
//print_r($values);
$fundoc = $values[fundoc];
unset($values[fundoc]);
if (is_array($values[ef]))
{
foreach($values[ef] as
$key=>$value)
{
$e_fd = new
Equipment_FundDoc;
$e_fd->Funding_Document_id
= $fundoc;
$e_fd->Equipment_id =
$key;
$e_fd->find();
$e_fd->delete();
}
}
unset($_SESSION[equipmentItems]);
unset($_SESSION[_DeleteFunding_container]);
header("Location: funding.php");
}
}
//SQL 1
$contracts = new SF1449;
$contracts->find();
while ($contracts->fetch())
{
$contractList[$contracts->id] =
$contracts->contract_no;
}
$customer = new Customer;
$address = new Customer_Address;
$equipment = new Equipment;
$continuation = new Equipment_Continuation;
$sf1449 = new SF1449;
//$customer->debugLevel(5);
$equipment->joinAdd($sf1449);
$continuation->joinAdd($equipment);
$address->joinAdd($continuation);
$customer->joinAdd($address);
$customer->selectAdd();
$customer->selectAdd("DISTINCT SF1449.id as sfid,
Customer.id as cid, Customer.name as name");
$customer->find();
while ($customer->fetch())
{
$customerList[$customer->sfid][$customer->cid] =
$customer->name;
}
//EndSQL 1
$page1 = new HTML_QuickForm_Page('Page1');
$page2 = new HTML_QuickForm_Page('Page2');
$page3 = new HTML_QuickForm_Page('Page3');
$renderer =& $page3->defaultRenderer();
$renderer->setHeaderTemplate('<tr><th
style="white-space:nowrap; background:#000066;
color:white; font-weight: bold" align="left"
colspan="2">{header}</th></tr>');
$controller =& new
HTML_QuickForm_Controller('DeleteFunding');
//Page 1
$list = array($contractList, $customerList);
print_r($list);
$hier =&
$page1->addElement('hierselect','contract','Select
Contract','','</td></tr><tr><td align="right"><b>Select
Customer</b></td><td>');
$hier->setOptions($list);
$page1->addElement('submit',
$page1->getButtonName('next'),'Next >>');
$page1->setDefaultAction('next');
//End Page 1
//SQL 2
if (isset($_GET[_qf_Page2_display]))
{
$cid =
$controller->exportValue('Page1','contract');
$funding = new Funding_Document;
$e_f = new Equipment_FundDoc;
$continuation = new Equipment_Continuation;
$address = new Customer_Address;
$equipment = new Equipment;
//$equipment->debugLevel(5);
$e_f->joinAdd($funding);
$equipment->joinAdd($e_f);
$continuation->joinAdd($address);
$equipment->joinAdd($continuation);
$equipment->whereAdd("Equipment.SF1449_id = '" .
$cid[0] . "' AND Customer_Address.Customer_id = '" .
$cid[1] . "' AND (
Equipment.status = 'installed' OR Equipment.status =
'pre-uninstall'
)");
$equipment->selectAdd();
$equipment->selectAdd("Equipment.id as id,
Equipment.serial_no as sn,
Funding_Document.funding_document as funding");
if ($equipment->find() == 0)
{
$template->assign("message","There are no
Installed Equipment for this Contract");
$template->display("Form.tpl");
die();
}
while ($equipment->fetch())
{
$equipmentList[$equipment->id] ='<b>' .
$equipment->sn . '</b> - Funded - ' . $equipment->funding;
}
$e_f = new Equipment_FundDoc;
$equip = new Equipment;
$e_f->joinAdd($equip);
$e_f->whereAdd("Equipment.SF1449_id = '" .
$cid[0] . "'");
$e_f->find();
while($e_f->fetch())
{
if (!isset($equipmentList[$e_f->id]))
unset($equipmentList[$e_f->id]);
}
if (count($equipmentList) == 0)
{
$template->assign("message","There are no
Funded pieces of Equipment for this Contract");
$template->display("Form.tpl");
die();
}
$_SESSION[equipmentItems] = $equipmentList;
}
//End SQL 2
//Page 2
$page2->addElement('html','<tr><td colspan=2><b>Check all
equipment to delete Funding from</b></td></tr>');
if (is_array($_SESSION[equipmentItems]))
{
foreach($_SESSION[equipmentItems] as $key=>$value)
$equip_f[] =&
$page2->createElement('checkbox', $key,'',$value);
$page2->addGroup($equip_f, 'ef','','<br />');
}
$prevnext[] =& $page2->createElement('submit',
$page2->getButtonName('back'), '<< Previous Step');
$prevnext[] =& $page2->createElement('submit',
$page2->getButtonName('next'), 'NEXT >>');
$page2->addGroup($prevnext, 'buttons', '', ' ',
false);
$page2->setDefaultAction('next');
//End Page 2
//SQL Page 3
if (isset($_GET[_qf_Page3_display]))
{
$p2 = $controller->exportValues('Page2');
$fund = new Funding_Document;
$fund->id = $p2[fundoc];
$fund->find();
$fund->fetch();
$doc = $fund->funding_document;
$p2 = $controller->exportValue('Page2','ef');
}
//End SQL Page 3
//Page 3
$page3->addElement('header','','Please verify your
information');
$page3->addElement('static','','Funding Document',$doc);
$page3->addElement('html','<tr><td colspan=2
align=center><b>Equipment to unfunded</b></td></tr>');
if (is_array($p2))
foreach($p2 as $key=>$value)
{
$equipment = new Equipment;
$equipment->id = $key;
$equipment->find(true);
$page3->addElement('static','','',
$equipment->serial_no);
}
$pn[] =& $page3->createElement('submit',
$page3->getButtonName('back'), '<< Previous Step');
$pn[] =& $page3->createElement('submit',
$page3->getButtonName('next'), 'Finish');
$page3->addGroup($pn, 'buttons', '', ' ', false);
$page3->setDefaultAction('next');
//End Page 3
$controller->addPage($page1);
$controller->addPage($page2);
$controller->addPage($page3);
$controller->addAction('process', new ActionProcess());
$controller->addAction('display', new DisplayProcess());
$template->assign("form", $controller->run());
$template->display("Form.tpl");
?>
-- END CODE
This is the structure of "$list" as pulled from the DB.
-- $list
Array
(
[0] => Array
(
[1] => SA7007-02-A-0004
[2] => SP3100-02-A-0024
[26] => SA7007-02-A-0008
[27] => SA7007-02-A-0005
[28] => SA7007-02-A-0008
[29] => SA7007-02-A-0004
[30] => SA7007-02-A-0007
[31] => SA7007-02-A-0004
[32] => SA7007-02-A-0006
[33] => SA7007-01-A-0015
)
[1] => Array
(
[2] => Array
(
[176GB00001] => Jane's House of Stuff
)
[1] => Array
(
[176GB00001] => Jane's House of Stuff
)
[32] => Array
(
[176GB00001] => Jane's House of Stuff
)
[27] => Array
(
[176GB00001] => Jane's House of Stuff
)
[30] => Array
(
[176GB00001] => Jane's House of Stuff
)
[28] => Array
(
[176GB00001] => Jane's House of Stuff
)
[26] => Array
(
[176GB00001] => Jane's House of Stuff
)
[29] => Array
(
[176GB00001] => Jane's House of Stuff
)
[33] => Array
(
[176GB00001] => Jane's House of Stuff
)
)
)