<?php

App::import('Core');
App::import('Component');
class CancellationShell extends Shell {

	public $uses = array('Evaluation','Customer'); 
	
	public function main() 
	{
		$labelStr = array();
		$evalEmps = $this->Evaluation->listTestsToCancel();
		
		
			foreach($evalEmps as $evalEmp) {
				if ($evalEmp['Employee']['customer_id'] == 7){
				$nbDays = 0;
				$today = date('Y-m-d');	
				$statusDate = $evalEmp['Evaluation']['status_date'];
				$todaytime = date('Y-m-d H:i:s');
				$webadmin = 'webadmin';
					if ($nbDays <= floor((abs(strtotime($today)) - strtotime($statusDate))/ 86400)) {
					#Update the Evaluation_status to the next status. Cancelled in this case(#14)
					$this->Evaluation->id = $evalEmp['Evaluation']['id'];
					$this->Evaluation->saveField('status_id', 14);			
					$this->Evaluation->saveField('modifiedby', $webadmin);
					$this->Evaluation->saveField('status_date', $today);
					$this->Evaluation->saveField('modified', $todaytime);
					}
					
				}
				else {
				$nbDays = 0;
				$today = date('Y-m-d');	
				$statusDate = $evalEmp['Evaluation']['status_date'];
				$todaytime = date('Y-m-d H:i:s');
				$webadmin = 'webadmin';
					if ($nbDays <= floor((abs(strtotime($today)) - strtotime($statusDate))/ 86400)) {
					#Update the Evaluation_status to the next status. Cancelled in this case(#14)
					$this->Evaluation->id = $evalEmp['Evaluation']['id'];
					$this->Evaluation->saveField('status_id', 14);			
					$this->Evaluation->saveField('modifiedby', $webadmin);
					$this->Evaluation->saveField('status_date', $today);
					$this->Evaluation->saveField('modified', $todaytime);
					}
				}
				
			}
		

	}
}
?>