.
*/
include("./include/include.php");
require_once(FILESYSTEMROOTPATH."jc/include/classes/DefaultLayout.php");
require_once(FILESYSTEMROOTPATH."include/form/AbstractForm.php");
/**
* Helper classes
*/
class PMForm extends AbstractForm {
private $pmService;
public function __construct(Layout $layout, IModel $model, Proposals_managementService $pmService) {
parent::__construct($layout, $model);
$this->pmService = $pmService;
}
public function save(IModel $model) {
$pService = $GLOBALS['ClassFactory']->getProposalsService();
$proposal = $pService->load($model->getProposal_id());
$proposal->setStatus('Prytanium');
if($model->getResult() == 'Withdrawn'){
$proposal->setStatus('Withdrawn');
}
$pService->saveOrUpdate($proposal);
if( $this->pmService->saveOrUpdate($model) ) {
$this->layout->redirect('summary.php?pm_id='.$model->getId());
}else {
$this->layout->echoln("Failed saving.");
}
}
}
/**
* End of helper classes
*/
$layout = new DefaultLayout("JC_MANAGE", "./jc/");
$layout->init();
$proposal_id = $_GET['proposal_id'];
$layout->echoln('Back
');
//form to create/edit proposals_management object
$pmService = $GLOBALS['ClassFactory']->getProposals_managementService();
$pm = $pmService->loadByPID($proposal_id, 'Prytanium');
if ($pm == NULL){
exit(0);
}
$form = new PMForm($layout, $pm, $pmService);
$present = new TextField('bodies_present', 'Bodies present');
$favour = new TextField('votes_in_favour', 'Votes-in favour');
$against = new TextField('votes_against', 'Votes-against');
$abstention = new TextField('votes_abstention', 'Votes-abstention');
$result = new SelectField('result', 'Result', array('Positive'=>'Positive','Negative'=>'Negative','Neutral'=>'Neutral','Withdrawn'=>'Withdrawn'));
$form->addField($present->setCompulsory(true));
$form->addField($favour->setCompulsory(true));
$form->addField($against->setCompulsory(true));
$form->addField($abstention->setCompulsory(true));
$form->addField($result->setCompulsory(true));
$form->display();
$layout->echoln('
If you press save, you won\'t be able to make any changes!');
/*Do we need withdraw option here?*/
$layout->page_footer();
?>