Jump to content

cakePHP database problem


sonoton345

Recommended Posts

I have a quick question. I just started having problem with my database this morning and lost on what is actually happening. I can retrieve from the database (like when a user login or when a user wants to edit profile, the form gets populated), but I can't save to the database. If I submit a form to the database, that table doesn't get populated anymore. Any help?

Link to comment
Share on other sites

Let me make this clearer. I have the same files on different computers running apache. I could do everything on the other computer which is my office system but on my laptop I can't do any saving to the database and this wasn't so before until this morning.

Link to comment
Share on other sites

Any code relevant to the problem.  Preferably the model, and the controller function, maybe some of the view as well.  I don't know how anybody can help you without seeing something.  You say you have the same code on 2 different servers?  Why?  What are you doing to assure that you have them in sync?  Have you cleared the model cache in the tmp folder?

Link to comment
Share on other sites

I have it on the server I set up in the office and also on my laptop so I can work on the files at home. When I started having problem with the ones on my laptop I deleted them and copied the "app folder" from the office to my laptop. The database configuration are the same (username/password). Yes I did clear the cache in the tmp folder.

employer controller

<?php
class EmployersController extends AppController {

var $name = 'Employers';
var $helpers = array('Html', 'Form', 'Session');
var $uses	=	array('Employer','Postjob','Matchjob','Categorie','Admin','SteponeEmployer','SteptwoEmployer','StepthreeEmployer');
var $components	=	array('resize');

function index()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$this->redirect(array('action'=>'welcome'));	
		}
		else
		{
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome'));	
		}
	}
         $this->layout = 'mytemp2';
}


function register()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$this->Session->setFlash('You are already logged in.', 'flashMessage');
			$this->redirect(array('action'=>'welcome'));	
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('action'=>'index/'));	
		}
	}
	if (!empty($this->data)) {
	   
	   $this->data['Employer']['creation_date']=date("Y-m-d");
	   $this->data['Employer']['state'] = $_POST['state'];
	   
	   if ($this->Employer->save($this->data)) {
		   $this->Session->setFlash('Congratulations! You have signed up!','flashMessage');
		   $this->redirect(array('controller'=>'employers','action'=>'index'));
	   } else {
		   $this->Session->setFlash('There was an error signing up. Please try again.','flashMessage');
		  /* $this->data = null;*/
	   }
	}
	// set page title
	$this->pageTitle = 'iWeev - Employer Registration';
	// set layout file
	$this->layout = 'mytemp2';

}


function login()
{

	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$this->Session->setFlash('You are already logged in.', 'flashMessage');
			$this->redirect(array('action'=>'welcome'));	
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('action'=>'index/'));	
		}
	}
	elseif($this->data)
	{

	$result	=	$this->Employer->find(array('Employer.username'=>$this->data['Employer']['email'],'Employer.password'=>$this->data['Employer']['password'],'Employer.status'=>'1')); 


	if(!empty($result))
	{
		$this->Session->start();
		$this->Session->write('username',$result['Employer']['username']);
		$this->Session->write('userid',$result['Employer']['id']);
		$this->Session->write('status',$result['Employer']['status']);
		$this->Session->write('first_name',$result['Employer']['first_name']);
		$this->Session->write('last_name',$result['Employer']['last_name']);
		$this->Session->write('company_name',$result['Employer']['company_name']);
		$this->Session->write('usertype','employer');

		$this->redirect(array('action'=>'welcome'));
	}
	else
		{
			$this->Session->SetFlash('Either username or password is incorrect. Please try again.','flashMessage');
		}
	}
	// set page title
	$this->pageTitle = 'iWeev - Employer Login';
	// set layout file
	$this->layout = 'mytemp2';

}

function logout()
{
	$this->Session->destroy();
	$this->redirect(array('controller'=>'employers','action'=>'index'));
}

function welcome()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$this->Session->setFlash('You are logged in.','flashMessage');
			//$this->redirect(array('action'=>'welcome'));	
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('action'=>'index/'));	
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	// set page title
	$this->pageTitle = 'iWeev - Employer Area';
	// set layout file
	$this->layout = 'mytemp2';
}

function edit($id=null)
{
	if($this->Session->check('userid'))
	{

		if($this->Session->read('usertype')=='employer')
		{
			$category	=	$this->Categorie->findAll();
			$this->set('category',$category);
		  if (!empty($this->data))
		  {
			  if($this->data['Employer']['id']=='')
			  {
				  $this->redirect(array('action'=>'welcome'));
			  }
			  $this->data['Employer']['company_type']	=	$_POST['company_type'];
			  $this->data['Employer']['company_size']	=	$_POST['company_size'];
			  $this->data['Employer']['company_category']	=	$_POST['company_category'];
			  $this->data['Employer']['recruiting_agency'] = $_POST['recruiting_agency'];
			  $this->data['Employer']['state'] = $_POST['state'];
			  $this->data['Employer']['relocate'] = $_POST['relocate'];
			  $this->data['Employer']['modify_date']=date("Y-m-d");

			  				
			  if ($this->Employer->save($this->data))
			  {
				  $this->Session->setFlash('Your user information has been saved succesfully.','flashMessage');
				  $this->redirect(array('action'=>'welcome'));
			  }
			  else
			  {
				  $this->Session->setFlash('Your user information could not be saved. Please, try again.', 'flashMessage');
			  }
		    }
		   else
		    {
		        $result	=	$this->Employer->find('id='.$id);

				if(!empty($result))
					{
						$this->set('result',$result['Employer']);
					}
					else
					{
						$this->redirect(array('action'=>'welcome'));	
					}
		     }
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('action'=>'index/'));	
		}

	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}

      $this->layout = 'mytemp2';
}

function Postjobs($id=null)
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$category	=	$this->Categorie->findAll();
			$this->set('category',$category);
			if (!empty($this->data))
			{
				$this->data['Postjob']['industry']=$_POST['industry'];

				$this->data['Postjob']['state'] = $_POST['state'];
				/*$this->data['Postjob']['price']=$_POST['price'];
				$this->data['Postjob']['relocation']=$_POST['relocation'];*/
				$this->data['Postjob']['postdate']=date("Y-m-d");
				if ($this->Postjob->save($this->data))
				{

					$this->Session->setFlash('Job posted successfully.', 'flashMessage');
					$this->data = null;

				}
				else
				{
					$this->Session->setFlash('Your job could not be saved at this time. Please try again.', 'flashMessage');
				}
			}

		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome/'));	
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	// set page title
	$this->pageTitle = 'iWeev - Employer Area';
	// set layout file
	$this->layout = 'mytemp2';
}

function jobs()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$id	=	$this->Session->read('userid');
			$result	=	$this->Postjob->findAll("employer_id='".$id."'");
			if(!empty($result))
			{
			$this->set('result',$result);
			}
			else
			{
				$this->Session->setFlash('There are no jobs posted on the system yet.', 'flashMessage');
				//$this->redirect(array('action'=>'welcome'));
			}
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome/'));	
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	// set page title
	$this->pageTitle = 'iWeev - Employer Area';
	// set layout file
	$this->layout = 'mytemp2';
}

function editjob($id=null)
{

	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
		  if (!empty($this->data))
		  {

			$this->data['Postjob']['industry']=$_POST['industry'];
			$this->data['Postjob']['postdate']=date("Y-m-d");
			$this->data['Postjob']['state'] = $_POST['state'];
			$this->data['Postjob']['employee_type']=$_POST['employee_type'];
			$this->data['Postjob']['experience_level']=$_POST['experience_level'];
			$this->data['Postjob']['education_level']=$_POST['education_level'];
			$this->data['Postjob']['relocate']=$_POST['relocate'];
			//$this->data['Postjob']['price']=$_POST['price'];

			if ($this->Postjob->save($this->data))
			{
				$last_id	=	$this->data['Postjob']['id'];
				$this->redirect(array('action'=>'jobs'));
			}
			else
			{
				$this->Session->setFlash('The job could not be saved. Please, try again.', 'flashMessage');
			}
		 }//end employer if
		 else
		 {
			$category	=	$this->Categorie->findAll();
			$this->set('category',$category);
			$result	=	$this->Postjob->find('id='.$id);

			if(!empty($result))
			{
				$this->set('id',$id);
				$this->set('result',$result['Postjob']);
			}
			else
			{
				$this->redirect(array('action'=>'jobs'));	
			}
		 }
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome/'));	
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired.', 'flashMessage');
		$this->redirect(array('action'=>'index'));
	}
	// set page title
	$this->pageTitle = 'iWeev - Employer Area';
	// set layout file
	$this->layout = 'mytemp2';
}

function viewapplicants()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$id	=	$this->Session->read('userid');
			$result	=	$this->Postjob->findAll("employer_id='".$id."'");
			if(!empty($result))
			{

			foreach($result as $result_new)
			{
				$result_n[]	=	$result_new;
			}
			$this->set('result',$result_n);
			//$this->set('result',$result);
			}
			else
			{
			$this->Session->setFlash('You have no job posted.', true);
			$this->redirect(array('action'=>'welcome'));
			}
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	// set layout file
	$this->layout = 'mytemp2';
}

function applicant($id=null)
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$result	=	$this->Employer->applicant($id);
			if(!empty($result))
			{
			//pr($job);exit;
			//$result	=	$this->JobSeeker->myjob($this->Session->read('userid'));
			foreach($result as $result_new)
			{
				$result_n	=	$result_new;
			}
			$this->set('result',$result_n);
			//$this->set('result',$result);
			}
			else
			{
			$this->Session->setFlash('There are no applicants for this job', 'flashMessage');
			$this->redirect(array('action'=>'viewapplicants'));
			}
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	// set layout file
	$this->layout = 'mytemp2';

}

function candidatematch($id=null)
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{

			$candidate	=	$this->Employer->candidatematch($_SESSION['userid']);
			$count = $this->Employer->countResult($_SESSION['userid']);

			//$employer = $this->Employer->find('all');

			if(!empty($candidate))
			{
			  
			    $this->Session->setFlash('There are matches for you.', 'flashMessage');
							  //pr($this->Session->read());exit;

				$this->set('result',$candidate);
				$this->set('total',$count);
				  /*$this->redirect(array('action'=>'welcome'));*/
			    
			}
			else
			{
				$this->Session->setFlash('There are no jobs matching your profile', 'flashMessage');
							//pr($this->Session->read());exit;
				$this->redirect(array('action'=>'welcome'));
			}

		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as a jobseeker.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome/'));	
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	$this->layout = 'mytemp2';
}

function candidatematch1($id=null){
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			/*$jobs	=	$this->JobSeeker->matchjob($id);*/
			$candidate	=	$this->Employer->candidatematch($_SESSION['userid']);

			if(!empty($candidate))
			{
			  
			  //$this->Session->setFlash('There are companies matching your profile', true);
			  $this->set('result',$candidate);
				  /*$this->redirect(array('action'=>'welcome'));*/
			}
			else
			{
				//$this->Session->setFlash('There are no company matching your profile', true);
				$this->redirect(array('action'=>'welcome'));
			}
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as a candidate.', 'flashMessage');
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome/'));	
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', 'flashMessage');
		$this->redirect(array('action'=>'index/'));
	}
	$this->layout = 'mytemp2';

}
     
 function remindpassword()
 {
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', 'flashMessage');
			$this->redirect(array('action'=>'welcome'));
		}
		elseif($this->Session->read('usertype')=='employer')
		{
			$this->Session->setFlash('You are already logged in as employer.', 'flashMessage');
			$this->redirect(array('controller'=>'employers','action'=>'welcome'));
		}
	}
	elseif(!empty($this->data))
		{
		$result	=	$this->Employer->find("username='".$this->data['Employer']['username']."'");
		if(!empty($result))
		{
			$to	=	$result['Employer']['username'];
			$subject	=	"Forgot Password";	
			$message	=	"Hello ".$result['Employer']['first_name']." You had requested for your password. Your password is ".$result['Employer']['password'];
			$header		=    "Content-Type: text/html;";
			mail($to,$subject,$message,$header);
			$this->Session->setFlash('An email has been sent to your email address containing your password.', 'flashMessage');
			$this->redirect(array('controller'=>'employers','action'=>'index'));
		}
		else
		{
			$this->Session->setFlash('Username is wrong. Please fill the correct username (which should be your email address).', 'flashMessage');
			$this->redirect(array('controller'=>'employers','action'=>'index'));
		}
	}
	// set layout file
	$this->layout = 'mytemp2';

}

function employerstep1() {

	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$id	=	$this->Session->read('userid');
			if (!empty($this->data))
			 {

				if($this->data['Employer']['id']=='')
				{
					$this->redirect(array('action'=>'welcome'));
				}

				$this->data['SteponeEmployer']['employer_id'] = $id;
				$this->data['SteponeEmployer']['question1'] = $_POST['question1'];					
				$this->data['SteponeEmployer']['question2'] = $_POST['question2'];					
				$this->data['SteponeEmployer']['question3'] = $_POST['question3'];					
				$this->data['SteponeEmployer']['question4'] = $_POST['question4'];					
				$this->data['SteponeEmployer']['question5'] = $_POST['question5'];					
				$this->data['SteponeEmployer']['question6'] = $_POST['question6'];					
				$this->data['SteponeEmployer']['question7'] = $_POST['question7'];					
				$this->data['SteponeEmployer']['question8'] = $_POST['question8'];					
				$this->data['SteponeEmployer']['question9'] = $_POST['question9'];
				//test if there's an entry already  
				$test = $this->SteponeEmployer->find('first', array('conditions' => array('SteponeEmployer.employer_id' => $id)));
				if (!empty($test)){
					foreach($test as $tests)
					{
						$this->data['SteponeEmployer']['id'] =$tests['id'];
					}
				    $this->SteponeEmployer->save($this->data);
					$this->redirect(array('action'=>'employerstep2'));
				}
				else {	
				      $this->data['SteponeEmployer']['employer_id'] = $id;
					  if ($this->SteponeEmployer->save($this->data))
					  {
						  $this->Session->setFlash('Your answers have been saved succesfully.',true);
						  $this->redirect(array('action'=>'employerstep2'));
					  }
					  else
					  {
						  //echo "ssssssssss";exit;
						  $this->Session->setFlash('Your answers could not be saved. Please, try again.', true);
					  }
				}
			 }
				  
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', true);
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', true);
		$this->redirect(array('action'=>'index/'));
	}
	// set layout file
	$this->layout = 'mytemp2';
}

function employerstep2() {
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$id	=	$this->Session->read('userid');
			if (!empty($this->data))
			 {

				if($this->data['Employer']['id']=='')
				{
					$this->redirect(array('action'=>'welcome'));
				}
				//retrieves answers from from
				$access=$_POST["step2"];
				  $string="";
				  for($i=0;$i<sizeof($access);$i++){
					$string .= "<>".$access[$i];
				  }
				  $this->data['SteptwoEmployer']['question'] = $string;
				//test if there's an entry already  
				$test = $this->SteptwoEmployer->find('first', array('conditions' => array('SteptwoEmployer.employer_id' => $id)));
				if (!empty($test)){
					foreach($test as $tests)
					{
						$this->data['SteptwoEmployer']['id'] =$tests['id'];
					}
				    $this->SteptwoEmployer->save($this->data);
					$this->redirect(array('action'=>'employerstep3'));
				}
				else {					

				  $this->data['SteptwoEmployer']['employer_id'] = $id;					  								  
				  
				  if ($this->SteptwoEmployer->save($this->data))
				  {
					  $this->Session->setFlash('Your answers have been saved succesfully.',true);
					  $this->redirect(array('action'=>'employerstep3'));
				  }
				  else
				  {
					  $this->Session->setFlash('Your answers could not be saved. Please, try again.', true);
				  }
			  }
			 }
				  
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', true);
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', true);
		$this->redirect(array('action'=>'index/'));
	}
	// set layout file
	$this->layout = 'mytemp2';
}

function employerstep3() {
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='employer')
		{
			$id	=	$this->Session->read('userid');
			if (!empty($this->data))
			 {

				if($this->data['Employer']['id']=='')
				{
					$this->redirect(array('action'=>'welcome'));
				}
				//retrieves answers from from
				$access=$_POST["question"];
				  $string="";
				  for($i=0;$i<sizeof($access);$i++){
					$string .= "<>".$access[$i];
				  }
				  $this->data['StepthreeEmployer']['question'] = $string;
				//test if there's an entry already  
				$test = $this->StepthreeEmployer->find('first', array('conditions' => array('StepthreeEmployer.employer_id' => $id)));
				if (!empty($test)){
					foreach($test as $tests)
					{
						$this->data['StepthreeEmployer']['id'] =$tests['id'];
					}
				    $this->StepthreeEmployer->save($this->data);
					$this->redirect(array('action'=>'candidatematch'));
				}
				else {					

				  $this->data['StepthreeEmployer']['employer_id'] = $id;					  								  
				  
				  if ($this->StepthreeEmployer->save($this->data))
				  {
					  $this->Session->setFlash('Your selections have been saved succesfully.',true);
					  $this->redirect(array('action'=>'candidatematch'));
				  }
				  else
				  {
					  $this->Session->setFlash('Your selections could not be saved. Please, try again.', true);
				  }
			  }
			 }
				  
		}
		if($this->Session->read('usertype')=='jobseeker')
		{
			$this->Session->setFlash('You are already logged in as jobseeker.', true);
			$this->redirect(array('controller'=>'jobseekers','action'=>'welcome'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', true);
		$this->redirect(array('action'=>'index/'));
	}
	// set layout file
	$this->layout = 'mytemp2';

}


function admin_employer()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			$this->layout	=	'admin';
			$result	=	$this->Employer->findAll();
			//pr($result);exit;
			if(!empty($result))
			{
			$this->set('result',$result);
			}
			else
			{
				$this->Session->setFlash('No employer registered on the site yet.',null);
				//$this->redirect(array('controller'=>'job_seekers','action'=>'welcome'));
			}
		}
	}
	else
	{
		//$this->layout	=	'admin';
		$this->Session->setFlash('You are not logged in or your session has expired.',null);
		$this->redirect(array('action'=>'index'));
	}
}


function admin_addemployer()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
		$this->layout	=	'admin';
		if (!empty($this->data))
		{
			if ($this->Employer->save($this->data))
			{
				//echo $this->Employer->save($this->data);

				$this->Session->setFlash('User has been saved successfully.', true);

				//pr($this->Session->read());exit;
				$this->redirect(array('action'=>'employer'));	
			}
			else
			{
				//echo "ssssssssss";exit;
				$this->Session->setFlash('The User could not be saved. Please, try again.', true);
				//$this->redirect(array('action'=>'/'));
			}
		}
			//$cat	=	$this->Categorie->findAll("parent='0' AND status='1'");
			//$this->set('result1',$cat);
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired.', true);
		$this->redirect(array('action'=>'index'));
	}
}

function admin_editemployer($id=null)
{
	$this->layout	=	'admin';
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
		if (!empty($this->data))
		{
		$this->data['Employer']['company_type']	=	$_POST['company_type'];
		//pr($this->data);exit;
            if ($this->Employer->save($this->data))
            {
			$this->Session->setFlash('The User has been saved.', true);
			//pr($this->Session->read());exit;
			$this->redirect(array('action'=>'employer'));
            }
		else
		{
			//echo "ssssssssss";exit;
			$this->Session->setFlash('The User could not be saved. Please, try again.', true);
		}
		}
		else
		{
			$result	=	$this->Employer->find('id='.$id);
		//pr($result);exit;
			if(!empty($result))
			{
			$this->set('result',$result['Employer']);
			}
			else
			{
				$this->redirect(array('action'=>'employer'));	
			}
		}
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired.', true);
		$this->redirect(array('action'=>'index'));
	}
}

function admin_deleteemployer($id=null)
{

	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			if($this->Employer->delete($id))
			{
			$this->Session->setFlash('You have deleted the user successfully.', true);
			}
			else
			{
				$this->Session->setFlash("User can't be deleted. Please try again later.", true);
			}
			$this->redirect(array('action'=>'employer'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please Login again.', true);
		$this->redirect(array('action'=>'index'));
	}

}

function admin_viewemployer($id=null)
{
	$this->layout	=	'admin';
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			$result	=	$this->Employer->find('id='.$id);
			if(!empty($result))
			{
			$this->set('result', $result);
			}
			else
			{
				$this->redirect(array('action'=>'employer'));
			}
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', true);
		$this->redirect(array('action'=>'index'));
	}

}


function admin_job()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			$this->layout	=	'admin';
			$result	=	$this->Postjob->findAll();

			if(!empty($result))
			{
			$this->set('result',$result);
			}
			else
			{
				$this->Session->setFlash('No job posted on the site yet.',null);

			}
		}
	}
	else
	{
		//$this->layout	=	'admin';
		$this->Session->setFlash('You are not logged in or your session has expired.',null);
		$this->redirect(array('action'=>'index'));
	}
}


function admin_addjob()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
		$this->layout	=	'admin';
		$category	=	$this->Categorie->findAll();
			$this->set('category',$category);
			if (!empty($this->data))
			{
				//pr($this->data);exit;
				$this->data['Postjob']['category']=$_POST['category'];
				$this->data['Postjob']['postdate']=date("Y-m-d");
				if ($this->Postjob->save($this->data))
				{
					//$data	=	$this->data;
					$last_id	=	$this->Postjob->id;
					$this->redirect(array('action'=>'matchjobs/'.$last_id));

				}
				else
				{

					$this->Session->setFlash('Your job could not be saved at this time. Please try again.', true);
				}
			}
			//$cat	=	$this->Categorie->findAll("parent='0' AND status='1'");
			//$this->set('result1',$cat);
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired.', true);
		$this->redirect(array('action'=>'index'));
	}
}

function admin_editjob($id=null)
{
	$this->layout	=	'admin';
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
		if (!empty($this->data))
		{

		//pr($this->data);exit;
		$this->data['Postjob']['category']=$_POST['category'];
		$this->data['Postjob']['postdate']=date("Y-m-d");
            if ($this->Postjob->save($this->data))
            {
			//$this->Session->setFlash('The User has been saved.', true);

			$last_id	=	$this->data['Postjob']['id'];
			$this->redirect(array('action'=>'matchjobs/'.$last_id));
			//$this->redirect(array('action'=>'job'));
            }
		else
		{

			$this->Session->setFlash('The job could not be saved. Please, try again.', true);
		}
		}
		else
		{
			$category	=	$this->Categorie->findAll();
			$this->set('category',$category);
			$result	=	$this->Postjob->find('id='.$id);
		//pr($result);exit;
			if(!empty($result))
			{
			$this->set('result',$result['Postjob']);
			}
			else
			{
				$this->redirect(array('action'=>'job'));	
			}
		}
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired.', true);
		$this->redirect(array('action'=>'index'));
	}
}

function admin_deletejob($id=null)
{

	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			if($this->Postjob->delete($id))
			{
			$this->Session->setFlash('You have deleted the job successfully.', true);
			}
			else
			{
				$this->Session->setFlash("Job can't be deleted. Please try again later.", true);
			}
			$this->redirect(array('action'=>'job'));
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', true);
		$this->redirect(array('action'=>'index'));
	}

}

function admin_viewjob($id=null)
{
	$this->layout	=	'admin';
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			$result	=	$this->Postjob->find('id='.$id);
			if(!empty($result))
			{
			$this->set('result', $result);
			}
			else
			{
				$this->redirect(array('action'=>'job'));
			}
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in or your session has expired. Please login again.', true);
		$this->redirect(array('action'=>'index'));
	}

}



function admin_matchjobs($id=null)
{

			$result	=	$this->Employer->matchjob($id);
			if(!empty($result))
			{
			foreach($result as $result_new)
			{
				foreach($result_new as $result_n)
				{
					$to	=	$result_n['name'];
					$subject	=	'Matching Job for You';
					$message	=	'A new job is matching your requirements. Please login to see the details.';
					$this->data['Matchjob']['job_id']=$id;
					$this->data['Matchjob']['user_id']=$result_n['id'];
					$this->Matchjob->save($this->data);
				}
			}
			$this->Session->setFlash('Your job has been posted successfully.', true);

				$this->redirect(array('action'=>'job'));
			}
			else
			{
				$this->Session->setFlash('Your job has been posted successfully.', true);

				$this->redirect(array('action'=>'job'));
			}
	}

function admin_changepassword()
{
	if($this->Session->check('userid'))
	{
		if($this->Session->read('usertype')=='admin')
		{
			$this->layout	=	'admin';
			if (!empty($this->data))
			{	
				$this->data['Admin']['id']=$_SESSION['id'];
				if ($this->Admin->save($this->data))
				{
					//echo $this->Employer->save($this->data);

					$this->Session->setFlash('Password has been changed.', true);


					$this->redirect(array('controller'=>'jobseekers','action'=>'welcome/'));	
				}
				else
				{

					$this->Session->setFlash('Please try again.', true);
					//$this->redirect(array('action'=>'/'));
				}
			}			
		}
	}
	else
	{
		$this->Session->setFlash('You are not logged in.', true);
			$this->redirect(array('action'=>'index/'));	
	}
}

function admin_logout()
{
	$this->Session->destroy();
	$this->redirect(array('controller'=>'jobseekers','action'=>'index'));
}

}
?>

 

Link to comment
Share on other sites

Sorry I have to do two posting bcos it exceeded the maximum text allowed

employer edit profile

<div id="bottomnew">
<div class='box'>
      <div class='boxtop'><div></div></div>
   <div class='boxcontent'>
     <!-- Content goes here -->
   <p id="contentText"><img src="http://localhost/new_iweev/img/editprofile.gif" /></p>  
  <span class="empsubnav2"><?php echo $html->link('Edit Profile','/employers/edit/'.$_SESSION['userid'], array(), false, false); ?> ¦ <?php echo $html->link('Post Jobs','/employers/postjobs/'.$_SESSION['userid'], array(), false, false); ?> ¦ <?php echo $html->link('Jobs Applied For','/employers/viewapplicants/', array(), false, false); ?> ¦ <?php echo $html->link('Matched Candidate','/employers/candidatematch/', array(), false, false); ?> ¦ <?php echo $html->link('Job Match','/employers/jobmatch/', array(), false, false); ?> ¦ <?php echo $html->link('Posted Jobs','/employers/jobs/', array(), false, false); ?> ¦ <?php echo $html->link('Logout','/employers/logout/', array(), false, false); ?></span> 
  <h5 id="subhead">Welcome <?php echo $session->read('company_name');?>  <?php //echo $session->read('last_name');?></h5>
  <!--<h3 id="titles">Employer - Edit Profile</h3>-->
  <?php e($form->create('Employer',array('url'=>'edit'))) ?>     
        <p><label>username(<span style="text-transform:lowercase">email address</span>):<span class="required">*</span></label><?php e($form->text('username', array('id'=>'txt','value'=>$result['username']))); ?></p>
        <p><label>Password:<span class="required">*</span></label><?php e($form->password('password',array('id'=>'txt','value'=>$result['password']))); ?></p>
        <p><label>First Name:<span class="required">*</span></label><?php e($form->text('first_name', array('id'=>'txt','value'=>$result['first_name']))); ?></p>
        <p><label>Last Name:<span class="required">*</span></label><?php e($form->text('last_name', array('id'=>'txt','value'=>$result['last_name']))); ?></p>
        <p><label>Company Name:<span class="required">*</span></label><?php e($form->text('company_name', array('id'=>'txt','value'=>$result['company_name']))); ?></p>
        <p><label>Address:<span class="required">*</span></label><?php e($form->text('address', array('id'=>'txt','value'=>$result['address']))); ?></p>
        <p><label>Address 2:</label><?php e($form->text('address2', array('id'=>'txt','value'=>$result['address2']))); ?></p>
        <p><label>City:<span class="required">*</span></label><?php e($form->text('city', array('id'=>'txt','value'=>$result['city']))); ?></p>
        <p><label>State:<span class="required">*</span></label>
                    <select name="state" class="txt" >

                               <option value="Alabama" <?php if($result['city_state']=="Alabama"){?> selected <?php }?>>Alabama</option>
                
                                <option value="Alaska" <?php if($result['city_state']=="Alaska"){?> selected <?php }?>>Alaska</option>
                               
                               	<option value="Arkansas" <?php if($result['city_state']=="Arkansas"){?> selected <?php }?>>Arkansas</option>
                            
                               	<option value="California" <?php if($result['city_state']=="California"){?> selected <?php }?>>California</option>
                           		<option value="Colorado" <?php if($result['city_state']=="Colorado"){?> selected <?php }?>>Colorado</option>
                               	<option value="Connecticut" <?php if($result['city_state']=="Connecticut"){?> selected <?php }?>>Connecticut</option>
                               <option value="Delaware" <?php if($result['city_state']=="Delaware"){?> selected <?php }?>>Delaware</option>
                                   
                               	<option value="Dist Of Columbia" <?php if($result['city_state']=="Dist Of Columbia"){?> selected <?php }?>>Dist Of Columbia</option>
                             <option value="Florida" <?php if($result['city_state']=="Florida"){?> selected <?php }?>>Florida</option>
                               		
                       		<option value="Georgia" <?php if($result['city_state']=="Georgia"){?> selected <?php }?>>Georgia</option>
                            <option value="Hawaii" <?php if($result['city_state']=="Hawaii"){?> selected <?php }?>>Hawaii</option>
                            <option value="Idaho" <?php if($result['city_state']=="Idaho"){?> selected <?php }?>>Idaho</option>
                          	<option value="Illinois" <?php if($result['city_state']=="Illinois"){?> selected <?php }?>>Illinois</option>
                       		<option value="Indiana" <?php if($result['city_state']=="Indiana"){?> selected <?php }?>>Indiana</option>
                        	<option value="Iowa" <?php if($result['city_state']=="Iowa"){?> selected <?php }?>>Iowa</option>
                           <option value="Kansas" <?php if($result['city_state']=="Kansas"){?> selected <?php }?>>Kansas</option>
                          	<option value="Kentucky" <?php if($result['city_state']=="Kentucky"){?> selected <?php }?>>Kentucky</option>
                            <option value="Louisiana" <?php if($result['city_state']=="Louisiana"){?> selected <?php }?>>Louisiana</option>
                           <option value="Maine" <?php if($result['city_state']=="Maine"){?> selected <?php }?>>Maine</option>
                          <option value="Maryland" <?php if($result['city_state']=="Maryland"){?> selected <?php }?>>Maryland</option>
                              <option value="Massachusetts" <?php if($result['city_state']=="Massachusetts"){?> selected <?php }?>>Massachusetts</option>
                         <option value="Michigan" <?php if($result['city_state']=="Michigan"){?> selected <?php }?>>Michigan</option>
                         <option value="Minnesota" <?php if($result['city_state']=="Minnesota"){?> selected <?php }?>>Minnesota</option>
                         <option value="Mississippi" <?php if($result['city_state']=="Mississippi"){?> selected <?php }?>>Mississippi</option>
                       	<option value="Missouri" <?php if($result['city_state']=="Missouri"){?> selected <?php }?>>Missouri</option>
                        <option value="Montana" <?php if($result['city_state']=="Montana"){?> selected <?php }?>>Montana</option>
                        <option value="Nebraska" <?php if($result['city_state']=="Nebraska"){?> selected <?php }?>>Nebraska</option>
                        <option value="Nevada" <?php if($result['city_state']=="Nevada"){?> selected <?php }?>>Nevada</option>
                        <option value="New Hampshire" <?php if($result['city_state']=="New Hampshire"){?> selected <?php }?>>New Hampshire</option>
                        <option value="New Jersey" <?php if($result['city_state']=="New Jersey"){?> selected <?php }?>>New Jersey</option>
                        <option value="New Mexico" <?php if($result['city_state']=="New Mexico"){?> selected <?php }?>>New Mexico</option>
                        <option value="New York" <?php if($result['city_state']=="New York"){?> selected <?php }?>>New York</option>
                        <option value="North Carolina" <?php if($result['city_state']=="North Carolina"){?> selected <?php }?>>North Carolina</option>
                        <option value="North Dakota" <?php if($result['city_state']=="North Dakota"){?> selected <?php }?>>North Dakota</option>
                        <option value="Ohio" <?php if($result['city_state']=="Ohio"){?> selected <?php }?>>Ohio</option>
                        <option value="Oklahoma" <?php if($result['city_state']=="Oklahoma"){?> selected <?php }?>>Oklahoma</option>
                        <option value="Oregon" <?php if($result['city_state']=="Oregon"){?> selected <?php }?>>Oregon</option>
                        <option value="Pennsylvania" <?php if($result['city_state']=="Pennsylvania"){?> selected <?php }?>>Pennsylvania</option>
                         <option value="Puerto Rico" <?php if($result['city_state']=="Puerto Rico"){?> selected <?php }?>>Puerto Rico</option>
                          <option value="Rhode Island" <?php if($result['city_state']=="Rhode Island"){?> selected <?php }?>>Rhode Island</option>
                          <option value="South Carolina" <?php if($result['city_state']=="South Carolina"){?> selected <?php }?>>South Carolina</option>
                          <option value="South Dakota" <?php if($result['city_state']=="South Dakota"){?> selected <?php }?>>South Dakota</option>
                          <option value="Tennessee" <?php if($result['city_state']=="Tennessee"){?> selected <?php }?>>Tennessee</option>
                               		
                         <option value="Texas" <?php if($result['city_state']=="Texas"){?> selected <?php }?>>Texas</option>
                         <option value="Utah" <?php if($result['city_state']=="Utah"){?> selected <?php }?>>Utah</option>									    
						<option value="Vermont" <?php if($result['city_state']=="Vermont"){?> selected <?php }?>>Vermont</option>
						<option value="Virginia" <?php if($result['city_state']=="Virginia"){?> selected <?php }?>>Virginia</option>									                            <option value="Washington" <?php if($result['city_state']=="Washington"){?> selected <?php }?>>Washington</option>							<option value="West Virginia" <?php if($result['city_state']=="West Virginia"){?> selected <?php }?>>West Virginia</option>									    
						<option value="Wisconsin" <?php if($result['city_state']=="Wisconsin"){?> selected <?php }?>>Wisconsin</option>									    						<option value="Wyoming" <?php if($result['city_state']=="Wyoming"){?> selected <?php }?>>Wyoming</option>									    
							</select>
        </p>
        <p><label>Zip Code:<span class="required">*</span></label><?php e($form->text('zip_code', array('id'=>'txt','value'=>$result['zip_code']))); ?></p>
        <p><label>Phone:<span class="required">*</span></label><?php e($form->text('phone', array('id'=>'txt','value'=>$result['phone']))); ?></p>
        
         
        <p><label>Zip Code:<span class="required">*</span></label><?php e($form->text('zip_code', array('id'=>'txt','value'=>$result['zip_code']))); ?></p>
        <p><label>Phone:<span class="required">*</span></label><?php e($form->text('phone', array('id'=>'txt','value'=>$result['phone']))); ?></p>
        <p><label>Fax:</label><?php e($form->text('fax', array('id'=>'txt','value'=>$result['fax']))); ?></p>
        <p><label>Company size:</label>
	    <select name="company_size" id="txt">
							<option value="Any">Any</option>
                                    <option value="Small" <?php if($result['company_size']=="Small"){?> selected <?php }?>>Small</option>
                                    <option value="Medium" <?php if($result['company_size']=="Medium"){?> selected <?php }?>>Medium</option>
                                    <option value="Large" <?php if($result['company_size']=="Large"){?> selected <?php }?>>Large</option>
                                    <option value="Transnational" <?php if($result['company_size']=="Transnational"){?> selected <?php }?>>Transnational</option>
							</select></p>
        <p><label>Company Type:</label><select name="company_type" id="txt">
							<option value="Any">Any</option>
                                    <option value="Private" <?php if($result['company_type']=="Private"){?> selected <?php }?>>Private</option>
                                    <option value="Public" <?php if($result['company_type']=="Public"){?> selected <?php }?>>Public</option>
							</select></p>
        <p><label>Company URL:</label><?php e($form->text('company_url', array('id'=>'txt','value'=>$result['company_url']))); ?></p>
        <p><label>Company Description:</label><?php e($form->textarea('company_desc', array('id'=>'txt','value'=>$result['company_desc']))); ?></p>
        <p><label>Industry:<span class="required">*</span></label>
                   <select name="company_category">
							<?php 
							foreach($category as $category1)
							{
								foreach($category1 as $category2)
								{
							?>
							<option value="<?php echo $category2['name']?>" <?php if($result['company_category']==$category2['name']){?> selected <?php }?>><?php echo $category2['name']?></option>
							<?php
								}
							}
							?>
							</select></p>
        
        <p><label>Recruiter's Contact:</label><?php e($form->text('recruiter_contact', array('id'=>'txt','value'=>$result['recruiter_contact']))); ?></p>
        <p><label>Recruiting Agency:</label><?php //e($form->text('fax', array('id'=>'txt'))); ?>
             <input type="radio" name="recruiting_agency" value="yes" id="recruiting_agency_0" <?php if($result['recruiting_agency']=="yes"){?> checked="checked" <?php }?> />Yes<input type="radio" name="recruiting_agency" value="yes" id="recruiting_agency_1" <?php if($result['recruiting_agency']=="yes"){?> checked="checked" <?php }?> />No
        </p>
        <p><label>Relocation covered:</label><?php //e($form->text('fax', array('id'=>'txt'))); ?>
             <input type="radio" name="relocate" value="Yes" id="relocate_0" <?php if($result['relocate']=="Yes"){?> checked="checked" <?php }?> />Yes<input type="radio" name="relocate" value="No" id="relocate_1" <?php if($result['relocate']=="No"){?> checked="checked" <?php }?> />No
        </p>
       
       
       <?php echo $form->input('id',array('type'=>'hidden','value'=>$_SESSION['userid']));?>
       
       <?php //echo $form->hidden('Employer.id');?>
        
         <p><?php e($form->submit('Update',array('div'=>false,'class' =>'submitbutton'))) ?>
     <?php e($form->end()); ?>
            
         
     </div>
<div class='boxbottom'><div></div></div>
</div>
</div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.