.
*/
include("./include/include.php");
require_once(FILESYSTEMROOTPATH."jc/include/classes/DefaultLayout.php");
require_once(FILESYSTEMROOTPATH."include/form/AbstractForm.php");
require_once(FILESYSTEMROOTPATH."jc/include/classes/DateTimeSelectField.php");
/**
* Helper classes
*/
class CandidatesDelForm extends AbstractForm {
private $election_id;
public function __construct(Layout $layout, IModel $model, $election_id) {
parent::__construct($layout, $model);
$this->election_id = $election_id;
}
public function save(IModel $model) {
$cService = $GLOBALS['ClassFactory']->getCandidatesService();
if( $cService->delete($model) ) {
$this->layout->redirect('candidates1.php?eid='.$this->election_id);
}else {
$this->layout->echoln("Error!");
}
}
}
/**
* End of helper classes
*/
$layout = new DefaultLayout("JC_MANAGE", "./jc/");
$layout->init();
$cService = $GLOBALS['ClassFactory']->getCandidatesService();
//get id if set
if (isset($_GET['id'])){
$id = $_GET['id'];
$candidate = $cService->load($id);
}
else{
$layout->redirect('elections1.php');
}
$election_id = $candidate->getElection_id();
$elections = $GLOBALS['ClassFactory']->getElectionsService()->load($election_id);
$layout->echoln('
Back
');
if (date("Y-m-d H:i:s") > $elections->getOpen()){
$layout->echoln('Elections have opened!');
$layout->echoln('
Back');
}
else
{
$layout->echoln($candidate->getName().' '.$candidate->getSurname().' (candidate for '.$elections->getPosition().'): Really delete?');
$form = new CandidatesDelForm($layout, $candidate, $election_id);
$form->setSubmitText('Delete');
$form->display();
$layout->echoln('
Cancel');
}
$layout->page_footer();
?>