public function doUpdateJobFunctionAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $ajaxRes = array('success' => 0, 'info' => null); if ($this->getRequest()->isXmlHttpRequest()) { $params = $this->getRequest()->getParams(); $JobFunctionID = null; $JobFucntion = null; $CredentialExperienceID = null; $Percentage = null; $errors = array(); // echo "tetst:<pre>";print_r($params);echo("</pre>"); if (!empty($params['data']) && sizeof($params['data'])) { foreach ($params['data'] as $key => $item) { if ($item['name'] == 'empId') { $empId = $item['value']; } if ($item['name'] == 'JobFunctionID') { $JobFunctionID = $item['value']; } if ($item['name'] == 'JobFucntion') { $JobFucntion = $item['value']; } if ($item['name'] == 'JobID') { $JobID = $item['value']; } if ($item['name'] == 'Percentage') { $Percentage = $item['value']; } } if ($Percentage == "") { $ajaxRes['success'] = 0; $ajaxRes['info'] = "Percentage not empty"; } if ($JobFucntion == "") { $ajaxRes['success'] = 0; $ajaxRes['info'] = "Job Fucntion not empty"; } if ($Percentage != "" && $JobFucntion != "") { $user = PR_Session::getSession(PR_Session::SESSION_USER); $core = new PR_Api_Core_CandidateClass(); $job = $core->getJobFunction($JobFunctionID, $empId); //db value $percent = round($job["Percentage"], 2); //total db values $totalPercentage = $core->totalPercentage($empId); $totalPercentage = round($totalPercentage["totalPercentage"], 2); //new value $Percentage = round($Percentage / 100, 2); $total = $totalPercentage - $percent + $Percentage; if ($total > 1) { $ajaxRes['success'] = 0; $ajaxRes['info'] = "Total Percentage greater than 100%"; } else { // $core->deleteJobFunction($JobID); $ajaxRes['success'] = 1; $ajaxRes['info']["JobFucntion_ID"] = $JobFucntion; $ajaxRes['info']["JobFunctionID_old"] = $JobFunctionID; $ajaxRes['info']["Percentage"] = $Percentage * 100; $ajaxRes['info']["Percentage_old"] = $percent; } } } } $response = $this->getResponse(); $response->clearAllHeaders()->clearBody(); $ajaxRes = json_encode($ajaxRes); $response->setHeader('Content-type', 'application/json'); $response->setHeader('Content-Length', strlen($ajaxRes), true)->setBody($ajaxRes); }