<commit_before><?php 

namespace Clinic\Controller;

use Clinic\Controller\AbstractClinicController;
use Clinic\Form\AdminLoginForm;
use Clinic\Model\Doctors;
use Clinic\Form\DoctorRegisterForm;
use Zend\View\Model\ViewModel;

class AdminController extends AbstractClinicController {

	protected $alf;
	protected $drf;

	public function indexAction()
	{
		$this->alf = new AdminLoginForm();
		return array(
			'form' => $this->alf,			
		);
	}

	public function loginAction()
	{
		//TODO: use filters
		$email = $this->getRequest()->getPost('email');
		return array(
			'email' => $email,
		);
	}

	public function registerDoctorAction()
	{
		$form = new DoctorRegisterForm();
		$form->get('submit')->setValue('Add');

		$request = $this->getRequest();
		if ($request->isPost()) {
			$doctor = new Doctors();
			$form->setInputFilter($doctor->getInputFilter());
			$form->setData($request->getPost());

			if ($form->isValid()) {
				$doctor->exchangeArray($form->getData());
				$this->getDoctorsTable()->saveDoctor($doctor);

				// Redirect to list of Doctors
				return $this->redirect()->toRoute('home');
			}
		}
		return array('form' => $form);
	}

	public function doctorsAction()
	{
		$this->checkIfLoggedIn();
		$doctors = $this->getDoctorsTable()->fetchAll();
		$doctorsView = new ViewModel(array('doctors' => $doctors));
		$loginActionView = new ViewModel($this->indexAction());
		$loginActionView->setTemplate('clinic/admin/index');

		$doctorsView->addChild($loginActionView, 'block');

		return $doctorsView;
	}

	public function editAction()
	{
		# code... 
		# read table name from param
		# fetch results
	}
	
	public function addAction()
	{
		# code... 
		# read table name from param
		# fetch results	
	}

	public function deleteAction()
	{
		# code... 
		# read table name from param
		# fetch results	
	}


	public function patientsAction()
	{
		$patients = $this->getPatientsTable()->fetchAll();
		return array('patients' => $patients);
	}

	public function deleteDoctorAction()
	{
		try {<commit_msg>fixed comments<commit_after><?php 

namespace Clinic\Controller;

use Clinic\Controller\AbstractClinicController;
use Clinic\Form\AdminLoginForm;
use Clinic\Model\Doctors;
use Clinic\Form\DoctorRegisterForm;
use Zend\View\Model\ViewModel;

class AdminController extends AbstractClinicController {

	protected $alf;
	protected $drf;

	public function indexAction()
	{
		$this->alf = new AdminLoginForm();
		return array(
			'form' => $this->alf,			
		);
	}

	public function loginAction()
	{
		//TODO: use filters
		$email = $this->getRequest()->getPost('email');
		return array(
			'email' => $email,
		);
	}

	public function registerDoctorAction()
	{
		$form = new DoctorRegisterForm();
		$form->get('submit')->setValue('Add');

		$request = $this->getRequest();
		if ($request->isPost()) {
			$doctor = new Doctors();
			$form->setInputFilter($doctor->getInputFilter());
			$form->setData($request->getPost());

			if ($form->isValid()) {
				$doctor->exchangeArray($form->getData());
				$this->getDoctorsTable()->saveDoctor($doctor);

				// Redirect to list of Doctors
				return $this->redirect()->toRoute('home');
			}
		}
		return array('form' => $form);
	}

	public function doctorsAction()
	{
		$this->checkIfLoggedIn();
		$doctors = $this->getDoctorsTable()->fetchAll();
		$doctorsView = new ViewModel(array('doctors' => $doctors));
		$loginActionView = new ViewModel($this->indexAction());
		$loginActionView->setTemplate('clinic/admin/index');

		$doctorsView->addChild($loginActionView, 'block');

		return $doctorsView;
	}

	public function editAction()
	{
		# code... 
		# read table name from param
		# read id
		# show form or update table
	}
	
	public function addAction()
	{
		# code... 
		# read table name from param
		# show form or update table
	}

	public function deleteAction()
	{
		# code... 
		# read table name from param
		# read id
		# delete from table
	}


	public function patientsAction()
	{
		$patients = $this->getPatientsTable()->fetchAll();
		return array('patients' => $patients);
	}

	public function deleteDoctorAction()
	{
		try {
{'fraction_non_alphanumeric': 0.15857526225908758, 'fraction_numerical': 0.0, 'mean_word_length': 4.067985166872682, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2492147', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1280, 'n_words': 284}