Пример #1
0
	private function compute_salary_item3_47($writ_rec) {


		// should be deleted at the first of 91 ------------------------------------------
		$MONTH_DAY_COUNT = ($writ_rec["person_type"] == HR_WORKER) ? 31 : MONTH_DAY_COUNT;

		if ($writ_rec['execute_date'] >= '2012-03-20') {
			$MONTH_DAY_COUNT = 30;
		}

		$k = 0;
		$devotion_coefs = manage_person_devotion::get_devotions_last_coefs($writ_rec['staff_id'] ,"", $writ_rec["person_type"] );
		$prisoner = $devotion_coefs['prisoner'] / 30;
		$fighter = $devotion_coefs['fighter'] / 30;
                                    
		if ( ($writ_rec["person_type"] == HR_WORKER) && ($prisoner >= 9 || $fighter >= 9))
			$k = 1;
		else if ($writ_rec["person_type"] == HR_WORKER)  {

			$query = "SELECT s.staff_id,
						CASE WHEN pd.devotion_type=" . DEVOTION_TYPE_FIGHTER . "
									 THEN if(( pd.from_date <= '1988-08-20' and to_date <= '1988-08-20' ),amount ,
										  if(( pd.from_date <= '1988-08-20' and to_date >= '1988-08-20' ) ,
											   datediff('1988-08-20',pd.from_date ) ,0 )) END fighter ,
						CASE WHEN pd.devotion_type=" . DEVOTION_TYPE_PRISONER . " THEN amount ELSE 0 END prisoner

				 FROM staff s
					 INNER JOIN persons p ON (p.personID = s.personID)
					 INNER JOIN person_devotions pd ON (pd.personID = p.personID)
				 WHERE s.staff_id =" . $writ_rec['staff_id'];

			$res = parent::runquery($query);

			for ($i = 0; $i < count($res); $i++) {
				if (($res[$i]['fighter'] / 30 ) >= 6 || ($res[$i]['prisoner'] / 30 ) >= 6) {
					$k = 1;
					break;
				}
			}
		}
                else if ($devotion_coefs['prisoner'] >= 1 || $devotion_coefs['fighter'] >= 1 ) 
                    $k = 1;
          
		if ($devotion_coefs['wounded'] > 0 || $k == 1) { 
			if (!(1 <= $writ_rec['job_group'] && $writ_rec['job_group'] <= 20)) {
				parent::PushException(UNKNOWN_JOB_GROUP);
				return false;
			}

			$job_group = $writ_rec['job_group'];
			$this->param1 = $job_group;
			$cur_value = manage_salary_params::get_salaryParam_value("", $writ_rec['person_type'].",101", SPT_JOB_SALARY, $writ_rec['execute_date'], $job_group);

			if (!(0 < $cur_value)) {
				parent::PushException(UNKNOWN_JOB_SALARY);
				return false;
			}
			$this->param2 = $cur_value;

			$next_value = manage_salary_params::get_salaryParam_value("", $writ_rec['person_type'].",101", SPT_JOB_SALARY, $writ_rec['execute_date'], $job_group + 1);

			if (!(0 < $next_value)) { 
				parent::PushException(UNKNOWN_JOB_SALARY);
				return false;
			}
			$this->param3 = $next_value;
			$value = ($next_value - $cur_value) * $MONTH_DAY_COUNT;

			if ($value <= 0)
				return 0;
			else
				return $value;
		} 


		return 0;
	}
Пример #2
0
 static function get_devotion_score($staff_id, $gdate = "")
 {
     $devotion_coefs = manage_person_devotion::get_devotions_last_coefs($staff_id, $gdate);
     if ($gdate >= '2010-03-21') {
         $query = " SELECT s.staff_id,s.person_type , s.personid\n\t\t\t\t\t\t  \t FROM staff s\n\t\t\t\t\t\t\t\t WHERE s.staff_id = " . $staff_id;
         $res = parent::runquery($query);
         $person_family_shohada = manage_person_devotion::get_person_devotions($res[0]["personid"], '(' . BEHOLDER_FAMILY_DEVOTION . ')', BOY . ',' . DAUGHTER);
         if ($person_family_shohada && $devotion_coefs['wounded'] < 50 && $res[0]["person_type"] == 2) {
             $devotion_coefs['wounded'] = 50;
         }
     }
     $d1_value = $devotion_coefs['wounded'];
     $d2_value = $devotion_coefs['prisoner'] / 30;
     $d3_value = $devotion_coefs['fighter'] / 30;
     //جانبازی
     $d_array1 = array(array("start" => 4.999, "end" => 5, "score" => 400), array("start" => 5, "end" => 10, "score" => 500), array("start" => 10, "end" => 15, "score" => 600), array("start" => 15, "end" => 20, "score" => 700), array("start" => 20, "end" => 25, "score" => 800), array("start" => 25, "end" => 30, "score" => 900), array("start" => 30, "end" => 35, "score" => 1000), array("start" => 35, "end" => 40, "score" => 1100), array("start" => 40, "end" => 45, "score" => 1200), array("start" => 45, "end" => 50, "score" => 1300), array("start" => 50, "end" => 60, "score" => 1500), array("start" => 60, "end" => 200, "score" => 1550));
     $score1 = 0;
     foreach ($d_array1 as $arr) {
         if ($arr["start"] < $d1_value && $arr["end"] >= $d1_value) {
             $score1 = $arr["score"];
             break;
         }
     }
     // اسارت
     $d_array2 = array(array("start" => 2.999, "end" => 6, "score" => 400), array("start" => 6, "end" => 12, "score" => 500), array("start" => 12, "end" => 18, "score" => 600), array("start" => 18, "end" => 24, "score" => 700), array("start" => 24, "end" => 30, "score" => 800), array("start" => 30, "end" => 36, "score" => 900), array("start" => 36, "end" => 42, "score" => 1000), array("start" => 42, "end" => 48, "score" => 1100), array("start" => 48, "end" => 54, "score" => 1200), array("start" => 54, "end" => 60, "score" => 1300), array("start" => 60, "end" => 70, "score" => 1500), array("start" => 70, "end" => 300, "score" => 1550));
     $score2 = 0;
     foreach ($d_array2 as $arr) {
         if ($arr["start"] < $d2_value && $arr["end"] >= $d2_value) {
             $score2 = $arr["score"];
             break;
         }
     }
     // رزمندگی
     $d_array3 = array(array("start" => 2.999, "end" => 6, "score" => 400), array("start" => 6, "end" => 12, "score" => 500), array("start" => 12, "end" => 18, "score" => 600), array("start" => 18, "end" => 24, "score" => 700), array("start" => 24, "end" => 30, "score" => 800), array("start" => 30, "end" => 36, "score" => 900), array("start" => 36, "end" => 42, "score" => 1000), array("start" => 42, "end" => 48, "score" => 1100), array("start" => 48, "end" => 54, "score" => 1200), array("start" => 54, "end" => 60, "score" => 1300), array("start" => 60, "end" => 70, "score" => 1500), array("start" => 70, "end" => 300, "score" => 1550));
     $score3 = 0;
     foreach ($d_array3 as $arr) {
         if ($arr["start"] < $d3_value && $arr["end"] >= $d3_value) {
             $score3 = $arr["score"];
             break;
         }
     }
     // ایثارگری که بالاترین امتیاز را دارد به اضافه ی 25 درصد سایر ایثارگری ها تا سقف 1550 امتیاز
     $max = max(array($score1, $score2, $score3));
     $sum = $score1 + $score2 + $score3;
     //return min(array($max + 0.25 * ($sum - $max),1550)) ;
     return min(array($sum, 1550));
 }