public function doUpdateJobFunctionNewAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $ajaxRes = array('success' => 0, 'info' => null); $Text = array("JobFucntion1" => "", "Percentage1" => ""); 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_Edit') { $JobFunctionID_old = $item['value']; } if ($item['name'] == 'JobFucntion_Edit') { $JobFucntion = $item['value']; } if ($item['name'] == 'pecent_edit') { $pecent_edit = $item['value']; } if ($item['name'] == 'Percentage_Edit') { $Percentage = $item['value']; } if ($item['name'] == 'Percentage1[]') { $Text["Percentage1"][] = $item['value']; } if ($item['name'] == 'JobFucntion1[]') { $Text["JobFucntion1"][] = $item['value']; } } if ($Percentage == "") { $ajaxRes['success'] = 0; $ajaxRes['info'] = "Percentage not empty"; } if ($JobFucntion == "") { $ajaxRes['success'] = 0; $ajaxRes['info'] = "Job Fucntion not empty"; } $pecent = 0; $core = new PR_Api_Core_CandidateClass(); $totalPercentage = $core->totalPercentage($empId); $totalPercentage = round($totalPercentage["totalPercentage"], 2); $Percentage1 = 0; if (!empty($Text["Percentage1"])) { for ($i = 0; $i < count($Text["Percentage1"]); $i++) { $Percentage1 = $Percentage1 + $Text["Percentage1"][$i]; } } $total = $totalPercentage + round($Percentage1 / 100, 2) + round($Percentage / 100, 2) - round($pecent_edit / 100, 2); // if($total>1){ // $ajaxRes['success'] = 0; // $ajaxRes['info'] = "Total Percentage greater than 100%"; // }else{ $ajaxRes['success'] = 1; $ajaxRes['info']["JobFunctionID_old"] = $JobFunctionID_old; $ajaxRes['info']["Percentage"] = $Percentage; $ajaxRes['info']["JobFucntion_ID"] = $JobFucntion; /* for($i=0;$i<count($Text["JobFucntion1"]);$i++) { if($Text["JobFucntion1"][$i]==$JobFunctionID_old){ $Text["JobFucntion1"][$i]=$JobFucntion; } for($j=0;$j<count($Text["Percentage1"]);$j++) { if($Text["Percentage1"][$j]==$pecent_edit && $i=$j){ $Text["Percentage1"][$j]=$Percentage; } } }*/ // } } } //} $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); }