private function log($type, $txt, $type = '')
    {
        if ($this->__MONTH < $this->last_month && $type != 'End') {
            return;
        }
        if ($type == 'FAIL') {
            $row = '<tr>
						<td bgcolor="#F5F5F5">' . $this->fail_counter++ . '</td>
						<td bgcolor="#F5F5F5">' . $this->cur_staff_id . '</td>                                                
						<td bgcolor="#F5F5F5">' . $this->staffRow['name'] . '</td>
						<td bgcolor="#F5F5F5">' . $txt . '</td>
					</tr>';
            fwrite($this->fail_log_file_h, $row);
        } else {
            $row = '<tr>
						<td bgcolor="#F5F5F5">' . $this->success_counter++ . '</td>
						<td bgcolor="#F5F5F5">' . $this->cur_staff_id . '</td>                                        
						<td bgcolor="#F5F5F5">' . $this->staffRow['name'] . '</td>
						<td bgcolor="#F5F5F5" >' . CurrencyModulesclass::toCurrency($txt, 'CURRENCY') . '</td>
					</tr>';
            fwrite($this->success_log_file_h, $row);
        }
    }
示例#2
0
	private function compute_salary_other_premium($writ_rec) {

		//$param1 گروه معادل استخدام كشوري افراد
		//$param2 افزايش سنواتي سال جاري
		//$param3 افزايش سنواتي سال قبل
		//$param4 ضريب فوق العاده شغل .
		//$param5 ضريب فوق العاده جذب

		$worker_salary = $this->compute_writ_items_sum($writ_rec["writ_id"], $writ_rec["writ_ver"], $writ_rec["staff_id"]
				, '( ' . SIT_WORKER_BASE_SALARY . ' , ' . SIT_WORKER_ANNUAL_INC . ')');

		// ________________________________________
		//compute_other_premium_base_salary
		$rial_coef = manage_salary_params::get_salaryParam_value("", $writ_rec["person_type"].",101", SPT_RIAL_COEF, $writ_rec['execute_date']);
		if (!$rial_coef) {
			parent::PushException(RIAL_COEF_NOT_FOUND);
			return false;
		}

		$worker_emp_base_salary = $rial_coef * manage_writ_item::Get_employee_base_number($this->param1);
		//_________________________________________

		$worker_emp_annual_inc = $this->param2;
		$worker_emp_job_extra = $this->param4 * $worker_emp_base_salary;

		//_________________________________________
		//compute_other_premium_min_salary

		$min_sal_value = manage_salary_params::get_salaryParam_value("", $writ_rec["person_type"].",101", SPT_MIN_SALARY, $writ_rec['execute_date']);
		$worker_emp_min_salary = max($min_sal_value - ($worker_emp_base_salary + $worker_emp_annual_inc + $worker_emp_job_extra), 0);
		//_________________________________________
		//compute_other_premium_absorb_extra
		$worker_emp_absorb_extra = $this->param5 *
				($worker_emp_base_salary + $worker_emp_annual_inc + $worker_emp_job_extra + $worker_emp_min_salary);
		//_________________________________________
		//compute_other_premium_bad_weather_extra
		$worker_emp_bad_wheader = 0;

		if ($writ_rec['emp_mode'] == EMP_MODE_ENGAGEMENT || $writ_rec['emp_mode'] == EMP_MODE_EDUCATIONAL_MISSION)
			$worker_emp_bad_wheader = 0;

		$this->param1 = manage_salary_params::get_salaryParam_value("", $writ_rec["person_type"].",101", SPT_WHEATHER_COEF, $writ_rec['execute_date']);
		if (!$this->param1) {
			parent::PushException('WHEATHER_COEF_NOT_FOUND');
			$worker_emp_bad_wheader = 0;
		}
		$value = $this->param1 * $worker_emp_base_salary;
		if (!($value > 0)) {
			parent::PushException('WHEATHER_ITEM_CALC_ERR');
			$worker_emp_bad_wheader = 0;
		}
		//_________________________________________
		//compute_other_premium_8_9_absorb
		//// محاسبه فوق العاده جذب بندهاي 8 و 9
		// به دست آوردن اولين روز سال قبل
		$this_writ_year = substr(DateModules::Miladi_to_Shamsi($writ_rec['execute_date']), 0, 4);
		$one_year_ago = $this_writ_year - 1;
		$one_year_ago_first_day = $one_year_ago . "/01/01";
		$Gone_year_ago_first_day = DateModules::Shamsi_to_Miladi($one_year_ago_first_day);

		// ضريب ريالي سال قبل
		$rial_coef = manage_salary_params::get_salaryParam_value("", $writ_rec["person_type"].",101", SPT_RIAL_COEF, $Gone_year_ago_first_day);
		if (!$rial_coef) {
			parent::PushException('RIAL_COEF_NOT_FOUND');
			return false;
		}

		// حقوق پايه سال قبل
		$prior_base_salary = $rial_coef * manage_writ_item::Get_employee_base_number($this->param1);

		// افزايش سنواتي سال قبل
		$prior_annual_inc = $this->param3;

		//فوق العاده شغل سال قبل
		$prior_job_extra = $prior_base_salary * $this->param4;

		// حداقل دريافتي سال قبل
		$min_sal_value = manage_salary_params::get_salaryParam_value("", $writ_rec["person_type"].",101", SPT_MIN_SALARY, $Gone_year_ago_first_day);
		$prior_min_salary = max($min_sal_value - ($prior_base_salary + $prior_annual_inc + $prior_job_extra), 0);

		// جمع اقلام مرتبط با فوق العاده تعديل
		$adjust_sal_items_sum = $prior_base_salary + $prior_annual_inc + $prior_job_extra + $prior_min_salary;

		// محاسبه فوق العاده تعديل سال قبل
		$max_value = manage_writ_item::Get_employee_base_number(1) * $rial_coef * 1.5;
		if ($adjust_sal_items_sum <= 3000000)
			$value = $max_value;
		elseif ($adjust_sal_items_sum >= 5700000)
			$value = 0;
		else
			$value = (1 - (intval(($adjust_sal_items_sum - 3000000) / 300000) + 1) * 0.1) * $max_value;

		$worker_emp_8_9_absorb = $value * 1.5;
		//_________________________________________

		$worker_emp_salary =
				$worker_emp_base_salary +
				$worker_emp_annual_inc +
				$worker_emp_job_extra +
				$worker_emp_min_salary +
				$worker_emp_absorb_extra +
				$worker_emp_bad_wheader +
				$worker_emp_8_9_absorb;

		$this->param6 = $worker_salary;

		$this->param7 = 'حقوق پايه:' . intval($worker_emp_base_salary) . '<br>' .
				'سنوات:' . intval($worker_emp_annual_inc) . '<br>' .
				'ف شغل:' . intval($worker_emp_job_extra) . '<br>' .
				'حداقل:' . intval($worker_emp_min_salary) . '<br>' .
				'ف جذب:' . intval($worker_emp_absorb_extra) . '<br>' .
				'ف بدي آب و هوا:' . intval($worker_emp_bad_wheader) . '<br>' .
				'جذب 8 و 9 ر:' . intval($worker_emp_8_9_absorb) . '<br>' .
				'جمع:' . intval($worker_emp_salary);

		$this->param2 = CurrencyModulesclass::toCurrency($this->param2);
		$value = max((11 / 12) * $worker_emp_salary - $worker_salary, 0);

		if (!($value > 0))
			return false;
		return $value;
	}
示例#3
0
function corrective_writ_detail($writ_id, $writ_ver, $staff_id, $execute_date)
{
    ob_start();
    // get corrected writs by a specfied writ
    $query = "SELECT w.* ,  wst.* , wsi.param3 \n\n        FROM   writs w\n        \t   LEFT OUTER JOIN writ_subtypes wst\n               \t\tON ((w.writ_type_id = wst.writ_type_id) AND\n                    \t(w.writ_subtype_id = wst.writ_subtype_id) AND\n                        (w.person_type = wst.person_type))\n\t\t\t   LEFT JOIN writ_salary_items wsi \n\t\t\t\t\tON w.staff_id = wsi.staff_id  AND w.writ_id = wsi.writ_id AND w.writ_ver = wsi.writ_ver AND wsi.salary_item_type_id = 10364 \n\t\t\t\t\t\n        WHERE  w.corrective_writ_id = {$writ_id}   AND\n               w.corrective_writ_ver = {$writ_ver} AND\n\t\t\t   w.staff_id = {$staff_id} AND\n               w.writ_ver > 1\n        ORDER BY execute_date";
    $corrected_writs = PdoDataAccess::runquery($query);
    $writ_count = count($corrected_writs);
    if ($writ_count == 0) {
        return;
    }
    $persent = 75 / $writ_count;
    echo "<tr>\n\t\t\t<td style='border-top:1px solid black' colspan=2>نوع حکم</td>";
    $width = round(400 / count($corrected_writs));
    for ($i = 0; $i < count($corrected_writs); $i++) {
        echo "<td style='border-top:1px solid black;width:" . $width . "px'>" . $corrected_writs[$i]["print_title"] . "</td>";
    }
    echo "</tr>";
    //----------- get all writ salary items of specified person_type -----------
    $minExecuteDate = $corrected_writs[0]["execute_date"];
    $writs = "";
    $prevwrit = "";
    for ($i = 0; $i < count($corrected_writs); $i++) {
        $writs .= "'" . $corrected_writs[$i]["staff_id"] . "-" . $corrected_writs[$i]["writ_id"] . "-" . $corrected_writs[$i]["writ_ver"] . "',";
        $prevwrit .= "'" . $corrected_writs[$i]["staff_id"] . "-" . $corrected_writs[$i]["writ_id"] . "-" . ($corrected_writs[$i]["writ_ver"] - 1) . "',";
        /*$minExecuteDate = DateModules::CompareDate($corrected_writs[$i]["execute_date"], $minExecuteDate) < 0 ?
        		$corrected_writs[$i]["execute_date"] : $minExecuteDate;*/
    }
    /*$query = "SELECT *
         FROM   salary_item_types sit
         WHERE  person_type = " . $corrected_writs[0]["person_type"] . " AND
         	   compute_place = " . SALARY_ITEM_COMPUTE_PLACE_WRIT . " AND
         	   validity_start_date <= '" . $execute_date . "' AND
         	   (validity_end_date IS NULL OR validity_end_date = '0000-00-00' OR
    		(validity_end_date >= '" . $minExecuteDate . "' AND validity_end_date >= '" . $execute_date . "'))
         ORDER BY print_order";*/
    $writs = substr($writs, 0, strlen($writs) - 1);
    $prevwrit = substr($prevwrit, 0, strlen($prevwrit) - 1);
    $query = "select distinct sit.* from writ_salary_items si join salary_item_types sit using(salary_item_type_id)\n\t\t\t\twhere concat(si.staff_id,'-',si.writ_id,'-',si.writ_ver) in (" . $writs . "," . $prevwrit . ")\n\t\t\t\t\t\t\t\tAND compute_place = " . SALARY_ITEM_COMPUTE_PLACE_WRIT . "\n\t\t\t\t\t\t\t\tAND person_type in (" . $corrected_writs[0]["person_type"] . " , 101 ) ORDER BY print_order";
    $salary_item_types = PdoDataAccess::runquery($query);
    //--------------------------------------------------------------------------
    $current_execute_date = $prior_execute_date = $current_field = $prior_field = $field_title = "";
    $current_writ_items = $prior_writ_items = array();
    $current_item_sum = $prior_item_sum = "";
    $field_title2 = "";
    for ($i = 0; $i < count($corrected_writs); $i++) {
        $current_writ = $corrected_writs[$i];
        if ($current_writ['writ_ver'] > 1) {
            $prior_writ = new manage_writ($current_writ["writ_id"], $current_writ["writ_ver"] - 1, $current_writ["staff_id"]);
            if ($current_writ["person_type"] != 1) {
                $qry = " select param3 from writ_salary_items\n\t\t\t\t\t\t\t\twhere writ_id= " . $current_writ["writ_id"] . " and \n\t\t\t\t\t\t\t\t\t\twrit_ver = " . ($current_writ["writ_ver"] - 1) . " and staff_id = " . $current_writ["staff_id"] . " and salary_item_type_id = 10364 ";
                $ResPrev = PdoDataAccess::runquery($qry);
                if (empty($ResPrev[0]['param3'])) {
                    $ResPrev[0]['param3'] = ' ';
                }
            }
            $current_execute_date .= "<td>" . DateModules::miladi_to_shamsi($current_writ["execute_date"]) . "</td>";
            $prior_execute_date .= "<td>" . DateModules::miladi_to_shamsi($prior_writ->execute_date) . "</td>";
            if ($current_writ["person_type"] == HR_EMPLOYEE || $current_writ["person_type"] == HR_PROFESSOR) {
                if ($current_writ["person_type"] == HR_EMPLOYEE && DateModules::CompareDate($execute_date, "2009-03-21") >= 0 && (DateModules::CompareDate($execute_date, "2013-02-19") < 0 || DateModules::CompareDate($execute_date, "2013-03-20") > 0 && DateModules::CompareDate($execute_date, "2014-03-20") < 0)) {
                    $field_title = 'طبقه';
                    $current_field .= "<td>" . ($current_writ["cur_group"] - 4) . "</td>";
                    $prior_field .= "<td>" . ($prior_writ->cur_group - 4) . "</td>";
                } else {
                    if ($current_writ["person_type"] == HR_EMPLOYEE && DateModules::CompareDate($execute_date, "2009-03-21") < 0) {
                        $field_title = 'گروه';
                        $current_field .= "<td>" . $current_writ["cur_group"] . "</td>";
                        $prior_field .= "<td>" . $prior_writ->cur_group . "</td>";
                    } else {
                        $field_title2 = "";
                        $field_title = 'پایه';
                        $current_writ["base"] = DateModules::CompareDate($current_writ["execute_date"], "2013-02-19") >= 0 && $current_writ["person_type"] != 1 ? substr($current_writ["param3"], 0, 2) : $current_writ["base"];
                        $prior_writ_base = DateModules::CompareDate($current_writ["execute_date"], "2013-02-19") >= 0 && $current_writ["person_type"] != 1 ? substr($ResPrev[0]['param3'], 0, 2) : $prior_writ->base;
                        $cf = DateModules::CompareDate($current_writ["execute_date"], "2013-02-19") < 0 && $current_writ["person_type"] == HR_EMPLOYEE ? "-" : $current_writ["base"];
                        $pf = DateModules::CompareDate($prior_writ->execute_date, "2013-02-19") < 0 && $current_writ["person_type"] == HR_EMPLOYEE ? "-" : $prior_writ_base;
                        $current_field .= "<td>" . $cf . "</td>";
                        $prior_field .= "<td>" . $pf . "</td>";
                        if (DateModules::CompareDate($current_writ["execute_date"], "2013-02-19") < 0 || DateModules::CompareDate($execute_date, "2013-03-20") > 0 && DateModules::CompareDate($execute_date, "2014-03-20") < 0) {
                            $field_title2 = 'طبقه';
                            $cf2 = DateModules::CompareDate($current_writ["execute_date"], "2013-02-19") < 0 || DateModules::CompareDate($execute_date, "2013-03-20") > 0 && DateModules::CompareDate($execute_date, "2014-03-20") < 0 ? $current_writ["cur_group"] - 4 : "-";
                            $pf2 = DateModules::CompareDate($prior_writ->execute_date, "2013-02-19") < 0 || DateModules::CompareDate($execute_date, "2013-03-20") > 0 && DateModules::CompareDate($execute_date, "2014-03-20") < 0 ? $prior_writ->cur_group - 4 : "-";
                            $current_field2 .= "<td>" . $cf2 . "</td>";
                            $prior_field2 .= "<td>" . $pf2 . "</td>";
                        } elseif ((DateModules::CompareDate($current_writ["execute_date"], "2013-02-19") >= 0 || DateModules::CompareDate($execute_date, "2013-03-21") < 0 || DateModules::CompareDate($execute_date, "2014-03-20") >= 0) && $field_title2 != "") {
                            $current_field2 .= "<td>" . "-" . "</td>";
                            $prior_field2 .= "<td>" . "-" . "</td>";
                        }
                    }
                }
            } else {
                $field_title = "";
                $field_title2 = "";
            }
            $sum1 = $sum2 = 0;
            $item46 = $item10374 = 0;
            $item10329 = $item10370 = $item51 = 0;
            $item10330 = $item10371 = $item50 = 0;
            foreach ($salary_item_types as $element) {
                if (in_array("46", $element)) {
                    $item46 = 1;
                }
                if (in_array("10374", $element)) {
                    $item10374 = 1;
                }
                if (in_array("10329", $element)) {
                    $item10329 = 1;
                }
                if (in_array("10370", $element)) {
                    $item10370 = 1;
                }
                if (in_array("51", $element)) {
                    $item51 = 1;
                }
                if (in_array("10330", $element)) {
                    $item10330 = 1;
                }
                if (in_array("10371", $element)) {
                    $item10371 = 1;
                }
                if (in_array("50", $element)) {
                    $item50 = 1;
                }
            }
            for ($j = 0; $j < count($salary_item_types); $j++) {
                if ($salary_item_types[$j]["salary_item_type_id"] == 10374 && $item46 == 1) {
                    continue;
                }
                if ($salary_item_types[$j]["salary_item_type_id"] == 10370 && $item51 == 1) {
                    continue;
                }
                if ($salary_item_types[$j]["salary_item_type_id"] == 10370 && $item10329 == 1) {
                    continue;
                }
                if ($salary_item_types[$j]["salary_item_type_id"] == 10371 && $item50 == 1) {
                    continue;
                }
                if ($salary_item_types[$j]["salary_item_type_id"] == 10371 && $item10330 == 1) {
                    continue;
                }
                if (!isset($current_writ_items[$j])) {
                    $current_writ_items[$j] = "";
                    $prior_writ_items[$j] = "";
                }
                $val = manage_writ_item::get_writSalaryItem_value($current_writ["writ_id"], $current_writ["writ_ver"], $current_writ["staff_id"], $salary_item_types[$j]["salary_item_type_id"]);
                if ($item46 == 1 && $item10374 == 1 && !($val > 0) && ($salary_item_types[$j]["salary_item_type_id"] == 46 || $salary_item_types[$j]["salary_item_type_id"] == 10374)) {
                    $val = manage_writ_item::get_writSalaryItem_value($current_writ["writ_id"], $current_writ["writ_ver"], $current_writ["staff_id"], 10374);
                }
                if ($item51 == 1 && $item10370 == 1 && !($val > 0) && ($salary_item_types[$j]["salary_item_type_id"] == 51 || $salary_item_types[$j]["salary_item_type_id"] == 10370)) {
                    $val = manage_writ_item::get_writSalaryItem_value($current_writ["writ_id"], $current_writ["writ_ver"], $current_writ["staff_id"], 10370);
                }
                if ($item50 == 1 && $item10371 == 1 && !($val > 0) && ($salary_item_types[$j]["salary_item_type_id"] == 50 || $salary_item_types[$j]["salary_item_type_id"] == 10371)) {
                    $val = manage_writ_item::get_writSalaryItem_value($current_writ["writ_id"], $current_writ["writ_ver"], $current_writ["staff_id"], 10371);
                }
                $current_writ_items[$j] .= "<td class='money'>" . ($val == 0 ? "-" : CurrencyModulesclass::toCurrency($val)) . "</td>";
                $sum2 += $val;
                $val = manage_writ_item::get_writSalaryItem_value($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id, $salary_item_types[$j]["salary_item_type_id"]);
                if ($item46 == 1 && $item10374 == 1 && !($val > 0) && ($salary_item_types[$j]["salary_item_type_id"] == 46 || $salary_item_types[$j]["salary_item_type_id"] == 10374)) {
                    $val = manage_writ_item::get_writSalaryItem_value($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id, 10374);
                }
                if ($item51 == 1 && $item10370 == 1 && !($val > 0) && ($salary_item_types[$j]["salary_item_type_id"] == 51 || $salary_item_types[$j]["salary_item_type_id"] == 10370)) {
                    $val = manage_writ_item::get_writSalaryItem_value($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id, 10370);
                }
                if ($item50 == 1 && $item10371 == 1 && !($val > 0) && ($salary_item_types[$j]["salary_item_type_id"] == 50 || $salary_item_types[$j]["salary_item_type_id"] == 10371)) {
                    $val = manage_writ_item::get_writSalaryItem_value($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id, 10371);
                }
                $prior_writ_items[$j] .= "<td class='money'>" . ($val == 0 ? "-" : CurrencyModulesclass::toCurrency($val)) . "</td>";
                $sum1 += $val;
            }
            $current_item_sum .= "<td class='money'>" . CurrencyModulesclass::toCurrency($sum2) . "</td>";
            $prior_item_sum .= "<td class='money'>" . CurrencyModulesclass::toCurrency($sum1) . "</td>";
        }
    }
    echo "<tr>\n\t\t\t<td style='width:80px' rowspan=2>تاريخ اجراي حکم</td>\n\t\t\t<td style='width:20px'>قبلي</td>\n\t\t\t" . $prior_execute_date . "\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>فعلی</td>\n\t\t\t" . $current_execute_date . "\n\t\t</tr>";
    if ($field_title != "") {
        echo "<tr>\n\t\t\t<td style='width:80px'  rowspan=2> " . $field_title . "</td>\n\t\t\t<td>قبلی</td>\n\t\t\t" . $prior_field . "\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>فعلی</td>\n\t\t\t" . $current_field . "\n\t\t</tr>";
    }
    if ($field_title2 != "" && $corrected_writs[0]["person_type"] != 1) {
        echo "<tr>\n\t\t\t<td style='width:80px'  rowspan=2> " . $field_title2 . "</td>\n\t\t\t<td>قبلی</td>\n\t\t\t" . $prior_field2 . "\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>فعلی</td>\n\t\t\t" . $current_field2 . "\n\t\t</tr>";
    }
    for ($i = 0; $i < count($salary_item_types); $i++) {
        if ($salary_item_types[$i]["salary_item_type_id"] == 10374 && $item46 == 1) {
            continue;
        }
        if ($salary_item_types[$i]["salary_item_type_id"] == 10370 && $item51 == 1) {
            continue;
        }
        if ($salary_item_types[$i]["salary_item_type_id"] == 10371 && $item50 == 1) {
            continue;
        }
        echo "\n\t\t<tr>\n\t\t\t<td style='width:80px'  rowspan=2>" . $salary_item_types[$i]["print_title"] . "</td>\n\t\t\t<td>قبلي</td>\n\t\t\t" . $prior_writ_items[$i] . "\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>فعلی</td>\n\t\t\t" . $current_writ_items[$i] . "\n\t\t</tr>";
    }
    echo "<tr>\n\t\t\t<td style='width:80px' rowspan=2>جمع کل</td>\n\t\t\t<td>قبلي</td>\n\t\t\t" . $prior_item_sum . "\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>فعلی</td>\n\t\t\t" . $current_item_sum . "\n\t\t</tr>";
    $ret = ob_get_contents();
    ob_end_clean();
    return $ret;
}
示例#4
0
echo CurrencyModulesclass::CurrencyToString($ReqObj->amount);
?>
 ریال )
						بعنوان <?php 
echo $ReqObj->_TypeDesc;
?>
						به <?php 
echo $ReqObj->_fullname;
?>
						پرداخت گردد. این صندوق متعهد است هر مبلغی را تا میزان 
						<?php 
echo number_format($ReqObj->amount);
?>
ریال 
						( <?php 
echo CurrencyModulesclass::CurrencyToString($ReqObj->amount);
?>
 ریال )
						که از طرف سازمان <?php 
echo $ReqObj->organization;
?>
						مطالبه شود به محض دریافت اولین تقاضانامه کتبی و بدون اینکه احتیاج به صدور 
						اظهارنامه یا اقدامی از مجرای اداری، قضایی ویا مقام دیگری و یا ذکر علتی داشته باشد،
						مبلغ مورد درخواست <?php 
echo $ReqObj->_fullname;
?>
						را در وجه یا حواله کرد <?php 
echo $ReqObj->organization;
?>
						بپردازد.
						<br>
function generateReport()
{
    $dt = salary_receipt_list();
    if (count($dt) == 0) {
        echo "گزارش هیچ نتیجه ایی در بر ندارد.";
        return;
    }
    $pays['value'] = array();
    $gets['value'] = array();
    $pays['diff_value'] = array();
    $gets['diff_value'] = array();
    $pays['title'] = array();
    $gets['title'] = array();
    $pays['param3'] = array();
    $gets['loan_remainder'] = array();
    $gets['frac_remainder'] = array();
    $query = " select person_type from staff where staff_id = :sid ";
    $whereParam[':sid'] = $_GET['staff_id'];
    $pt = PdoDataAccess::runquery($query, $whereParam);
    if ($pt[0]['person_type'] != HR_CONTRACT) {
        $SIT_STAFF_EXTRA_WORK = SIT_EXTRA_WORK;
        $SIT_STAFF_HORTATIVE_EXTRA_WORK = SIT_STAFF_HORTATIVE_EXTRA_WORK;
        $SIT_WORKER_EXTRA_WORK = SIT_WORKER_EXTRA_WORK;
        $SIT_WORKER_HORTATIVE_EXTRA_WORK = SIT_WORKER_HORTATIVE_EXTRA_WORK;
    } else {
        $SIT_STAFF_EXTRA_WORK = SIT5_STAFF_EXTRA_WORK;
        $SIT_STAFF_HORTATIVE_EXTRA_WORK = SIT5_STAFF_HORTATIVE_EXTRA_WORK;
        $SIT_WORKER_EXTRA_WORK = SIT5_WORKER_EXTRA_WORK;
        $SIT_WORKER_HORTATIVE_EXTRA_WORK = SIT5_WORKER_HORTATIVE_EXTRA_WORK;
    }
    //..........................
    for ($i = 0; $i < count($dt); $i++) {
        if ($dt[$i]['effect_type'] == BENEFIT && ($dt[$i]['pay_value'] != 0 || $dt[$i]['effect_type'] != 0)) {
            array_push($pays['value'], $dt[$i]['pay_value']);
            array_push($pays['diff_value'], $dt[$i]['diff_pay_value']);
            array_push($pays['title'], $dt[$i]['salary_item_title']);
            if ($dt[$i]['salary_item_type_id'] == $SIT_STAFF_EXTRA_WORK || $dt[$i]['salary_item_type_id'] == $SIT_STAFF_HORTATIVE_EXTRA_WORK) {
                array_push($pays['param3'], $dt[$i]['param3']);
            } elseif ($dt[$i]['salary_item_type_id'] == $SIT_WORKER_EXTRA_WORK || $dt[$i]['salary_item_type_id'] == $SIT_WORKER_HORTATIVE_EXTRA_WORK) {
                array_push($pays['param3'], $dt[$i]['param2']);
            } else {
                array_push($pays['param3'], NULL);
            }
        } else {
            if ($dt[$i]['get_value'] != 0 || $dt[$i]['diff_get_value'] != 0) {
                array_push($gets['value'], $dt[$i]['get_value']);
                array_push($gets['diff_value'], $dt[$i]['diff_get_value']);
                array_push($gets['title'], $dt[$i]['salary_item_title']);
                array_push($gets['loan_remainder'], $dt[$i]['loan_remainder']);
                array_push($gets['frac_remainder'], $dt[$i]['frac_remainder']);
            }
        }
    }
    $loop_limit = max(17, count($pays['title']), count($gets['title']));
    $pay_sum = 0;
    $pay_diff_sum = 0;
    $get_sum = 0;
    $get_diff_sum = 0;
    $report = "";
    for ($i = 0; $i < $loop_limit; $i++) {
        $report .= "<tr>";
        if ($i < count($pays['title'])) {
            $report .= "<td   class='payment_report_data_custom_noborder' width=5% >" . ($i + 1) . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=20% >" . $pays['title'][$i] . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . $pays['value'][$i] . "</td>";
            $pay_sum += $pays['value'][$i];
            $report .= "<td    class='payment_report_data_custom_noborder' width=10% >" . $pays['diff_value'][$i] . "</td>";
            $pay_diff_sum += $pays['diff_value'][$i];
            if ($pays['param3'][$i] != null) {
                $report .= "<td  class='payment_report_data_custom_noborder'   width=3% >" . $pays['param3'][$i] . "</td>";
            } else {
                $report .= "<td  class='payment_report_data_custom_noborder'  width=3% >" . "&nbsp;" . "</td>";
            }
        } else {
            $report .= "<td   class='payment_report_data_custom_noborder' width=5% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=20% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=3% >" . "&nbsp;" . "</td>";
        }
        if ($i < count($gets['title'])) {
            $report .= "<td   class='payment_report_data_custom_noborder' width=20% >" . $gets['title'][$i] . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . $gets['value'][$i] . "</td>";
            $get_sum += $gets['value'][$i];
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . $gets['diff_value'][$i] . "</td>";
            $get_diff_sum += $gets['diff_value'][$i];
            if ($gets['loan_remainder'][$i] != null) {
                $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . $gets['loan_remainder'][$i] . "</td>";
            } else {
                $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . "&nbsp" . "</td>";
            }
            $report .= "<td   class='payment_report_data_custom_noborder' width=7% >" . "&nbsp;" . "</td>";
        } else {
            $report .= "<td   class='payment_report_data_custom_noborder' width=20% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=10% >" . "&nbsp;" . "</td>";
            $report .= "<td   class='payment_report_data_custom_noborder' width=7% >" . "&nbsp;" . "</td>";
        }
        $report .= "</tr>";
    }
    $tags = array('<!--report-->' => $report, '<!--plname-->' => $dt[0]['plname'], '<!--account_no-->' => $dt[0]['account_no'], '<!--staff_id-->' => $dt[0]['staff_id'], '<!--pfname-->' => $dt[0]['pfname'], '<!--name-->' => $dt[0]['name'], '<!--cost_center_title-->' => $dt[0]['cost_center_title'], '<!--month_title-->' => $dt[0]['month_title'], '<!--pay_year-->' => $dt[0]['pay_year'], '<!--total_pay_diffpay-->' => CurrencyModulesclass::toCurrency($pay_sum + $pay_diff_sum), '<!--total_pay-->' => CurrencyModulesclass::toCurrency($pay_sum), '<!--total_diffpay-->' => CurrencyModulesclass::toCurrency($pay_diff_sum), '<!--total_get_diff-->' => CurrencyModulesclass::toCurrency($get_sum + $get_diff_sum), '<!--total_get-->' => CurrencyModulesclass::toCurrency($get_sum), '<!--total_diffget-->' => CurrencyModulesclass::toCurrency($get_diff_sum), '<!--total-->' => CurrencyModulesclass::toCurrency($pay_sum + $pay_diff_sum - $get_sum - $get_diff_sum), '<!--str_total-->' => CurrencyModulesclass::CurrencyToString($pay_sum + $pay_diff_sum - $get_sum - $get_diff_sum), '<!--message-->' => $dt[0]['message']);
    $content = file_get_contents("salary_receipt_print.htm");
    $content = str_replace(array_keys($tags), array_values($tags), $content);
    echo $content;
}
					'<!--plname-->' => $dt[$i-1]['plname'] ,
					'<!--account_no-->' => $dt[$i-1]['account_no'] ,
					'<!--staff_id-->' => $dt[$i-1]['staff_id'] ,
					'<!--pfname-->' => $dt[$i-1]['pfname']  ,
					'<!--name-->' => $dt[$i-1]['name'] ,
					'<!--cost_center_title-->' => $dt[$i-1]['cost_center_title'],
					'<!--month_title-->' => $dt[$i-1]['month_title'],
					'<!--pay_year-->' => $dt[$i-1]['pay_year'],
					'<!--total_pay_diffpay-->' => CurrencyModulesclass::toCurrency(($pay_sum + $pay_diff_sum)),
					'<!--total_pay-->' => CurrencyModulesclass::toCurrency($pay_sum) ,
					'<!--total_diffpay-->' =>  ($pay_diff_sum < 0 ) ? CurrencyModulesclass::toCurrency($pay_diff_sum)."-&nbsp;" : CurrencyModulesclass::toCurrency($pay_diff_sum) ,
					'<!--total_get_diff-->' => (($get_sum + $get_diff_sum) < 0 ) ? CurrencyModulesclass::toCurrency(($get_sum + $get_diff_sum))."-&nbsp;" : CurrencyModulesclass::toCurrency(($get_sum + $get_diff_sum)) ,
					'<!--total_get-->' => CurrencyModulesclass::toCurrency($get_sum) ,
					'<!--total_diffget-->' => ($get_diff_sum < 0) ? CurrencyModulesclass::toCurrency($get_diff_sum )."-&nbsp;" : CurrencyModulesclass::toCurrency($get_diff_sum )  ,					
					'<!--total-->'	=> (($pay_sum + $pay_diff_sum - $get_sum - $get_diff_sum) < 0 )  ? CurrencyModulesclass::toCurrency(($pay_sum + $pay_diff_sum - $get_sum - $get_diff_sum))."-&nbsp;" : CurrencyModulesclass::toCurrency(($pay_sum + $pay_diff_sum - $get_sum - $get_diff_sum)) ,
					'<!--str_total-->' =>	CurrencyModulesclass::CurrencyToString(($pay_sum + $pay_diff_sum - $get_sum - $get_diff_sum)),
					'<!--message-->'	=>  $dt[$i-1]['message'] );

			$content = file_get_contents("../../payment/ui/salary_receipt_print.htm");
			$content = str_replace(array_keys($tags), array_values($tags), $content);

			echo $content;	
			
			}
?>

<style>
		.reportGenerator {border-collapse: collapse;border: 1px solid black;font-family: tahoma;font-size: 8pt;
						  text-align: center;width: 50%;padding: 2px;}
		.reportGenerator .header {color: white;font-weight: bold;background-color:#3F5F96}
		.reportGenerator td {border: 1px solid #555555;height: 20px;}
示例#7
0
					$CSUM += $temp[$i]["CSUM"];
					echo "<tr>
							<td >" . "[ " . $temp[$i]["CostCode"] . " ] " . $temp[$i]["CostDesc"] . "</td>
							<td >" . $temp[$i]["details"] . "</td>	
							<td >" . $temp[$i]["TafsiliDesc"] . "</td>
							<td >" . $temp[$i]["TafsiliDesc2"] . "</td>
							<td >" . number_format($temp[$i]["DSUM"]) . "</td>
							<td >" . number_format($temp[$i]["CSUM"]) . "</td>
						</tr>";					
				}
				
				?>
			<tr class="header">
				<td colspan="4">جمع : 
				<?php 
echo $CSUM != $DSUM ? "<span style=color:red>سند تراز نمی باشد</span>" : CurrencyModulesclass::CurrencyToString($CSUM) . " ریال ";
?>
 </td>
				
				<td><?php 
echo number_format($DSUM, 0, '.', ',');
?>
</td>
				<td><?php 
echo number_format($CSUM, 0, '.', ',');
?>
</td>
			</tr>
			<tr>
				<td colspan="5">
					شرح سند : <?php 
示例#8
0
			</tr>
			<tr>
				<td colspan=3 align=center style='text-align: justify;padding: 0 5 0 5'>
				بدینوسیله گواهی می شود تعداد
				<b><u> " . $dataTable[$i]["shareCount"] . " </u></b>( " . CurrencyModulesclass::CurrencyToString($dataTable[$i]["shareCount"]) . " ) 
				سهم با نام از مجموع 
				<b><u>" . $sumRecord["shareCount"] . "</u></b> ( " . 
				CurrencyModulesclass::CurrencyToString($sumRecord["shareCount"]) . " ) 
				سهم 
				" . SoftwareName . " به ارزش اسمی هر سهم " . 
				"<b><u>" . number_format(ShareBaseAmount) . "</u></b> ریال ( " . CurrencyModulesclass::CurrencyToString(ShareBaseAmount) . " ریال ) و مجموعا به ارزش 
				<b><u>" . number_format($dataTable[$i]["amount"]) . "</u></b> ریال ( " . CurrencyModulesclass::CurrencyToString($dataTable[$i]["amount"]) . " ریال ) 
 به عنوان سهام عادی و با نام متعلق به 
				<b>" . $dataTable[$i]["TafsiliDesc"] . "</b>
				می باشد و سهام مذکور در دفتر ثبت سهام تحت شماره
				<b><u> &nbsp;&nbsp;" . $dataTable[$i]["ShareNo"] . "</u></b> &nbsp;( " . CurrencyModulesclass::CurrencyToString($dataTable[$i]["ShareNo"]) . " ) &nbsp;&nbsp; 
				ثبت گردیده است.
				<br><br>
				</td>
			</tr>
			<tr>
				<td style=padding-right:40px align=center>رسول عبدالهی<br> مدیر عامل</td>
				<td align=center>مهر صندوق</td>
				<td style=padding-left:40px align=center>دکتر جواد بهارآرا <br> رئیس هیئت مدیره</td>
			</tr>
		</table></div>";
		
		echo "<div style='width:285mm;font-family:Homa;font-size:12px'>
			<center>با صدور این برگ اوراق صادره قبلی باطل اعلام می گردد.( تاریخ صدور : " .
			DateModules::shNow(). " )</center></div>";
		
function ShowReport(){	
	
	/*
	
	$qry = " select  cpw.staff_id , cpw.writ_id ,  cpw.writ_ver , cpw.arrear_ver , w.execute_date
		
				 from corrective_payment_writs cpw inner join  writs w 
			                                         on cpw.staff_id = w.staff_id and 
														cpw.writ_id = w.writ_id and 
														cpw.writ_ver = w.writ_ver 

			 where cpw.pay_year = 1392 and cpw.staff_id = 471479 and cpw.pay_month = 12 " ; 
	
	$res1 = PdoDataAccess::runquery($qry) ; 
	
	$qry = " select   cpw.staff_id , cpw.writ_id ,  cpw.writ_ver , w.execute_date 
		
					from hrms.payment_writs cpw inner join  writs w 
			                                         on cpw.staff_id = w.staff_id and 
														cpw.writ_id = w.writ_id and 
														cpw.writ_ver = w.writ_ver
			  where cpw.pay_year = 1392 and cpw.staff_id = 471479 and cpw.pay_month = 12 " ; 
	
	// پرس و جو بالا هم بایستی union شود با ورژن های قبلی پرداخت تا احکام آنها هم دیده شود .
	
	$res2 = PdoDataAccess::runquery($qry) ; 
	
	
	for($i=0; $i<count($res1);$i++)
	{
		for($j=0;$j<count($res2);$j++)
		{
			
			if(  $res1[$i]['execute_date'] == $res2[$j]['execute_date'] && 
				($res1[$i]['writ_id'] != $res2[$j]['writ_id'] || $res1[$i]['writ_ver'] != $res2[$j]['writ_ver'] ) )
			{
				 PdoDataAccess::runquery(" insert compare_arrear_writs (staff_id ,current_execute_date , current_writ_id , current_writ_ver, 
																	 prev_execute_date , prev_writ_id , prev_writ_ver , arrear_ver , pay_year ) values 
											(".$res1[$i]['staff_id'].",'".$res1[$i]['execute_date']."',".$res1[$i]['writ_id'].",".
												$res1[$i]['writ_ver'].",'".$res2[$j]['execute_date']."',".$res2[$j]['writ_id'].",".
												$res2[$j]['writ_ver'].",".$res1[$i]['arrear_ver'].",".$_POST['year']." ) ");  
				
			}	
			elseif($res1[$i]['execute_date'] > $res2[$j]['execute_date'])
			{
				 PdoDataAccess::runquery(" insert compare_arrear_writs (staff_id ,current_execute_date , current_writ_id , 
																		current_writ_ver, prev_execute_date , prev_writ_id ,
																		prev_writ_ver , arrear_ver , pay_year  ) values 
											(".$res1[$i]['staff_id'].",'".$res1[$i]['execute_date']."',".$res1[$i]['writ_id'].",".
											   $res1[$i]['writ_ver'].",'".$res2[$j]['execute_date']."',".$res2[$j]['writ_id'].",".
											   $res2[$j]['writ_ver'].",".$res1[$i]['arrear_ver'].",".$_POST['year']." ) "); 
				
			}
			elseif ( $res1[$i]['execute_date'] < $res2[$j]['execute_date'] )
			{				
				break ;				
			}			
		}		
		
	}
	 
	*/
	
	$res = PdoDataAccess::runquery(" select * 
										from compare_arrear_writs 
											where staff_id = ".$_POST['staff_id']." and pay_year =".$_POST['pay_year']);
	
	$writsWhereClause = "" ; 
	
	for($i=0;$i<count($res);$i++)
	{
		$writsWhereClause.='(wsi.writ_id='.$res[$i]['current_writ_id'].' AND wsi.writ_ver='.$res[$i]['current_writ_ver'].' AND wsi.staff_id='.$res[$i]['staff_id'].') OR 
							(wsi.writ_id='.$res[$i]['prev_writ_id'].' AND wsi.writ_ver='.$res[$i]['prev_writ_ver'].' AND wsi.staff_id='.$res[$i]['staff_id'].' ) OR  ';		
	}
	
	$writsWhereClause = substr($writsWhereClause,0,strlen($writsWhereClause) - 4);
	
	$ResITM =  PdoDataAccess::runquery(" select distinct wsi.salary_item_type_id  , sit.print_title 
											 from writ_salary_items wsi 
																inner join salary_item_types sit 
																		on  wsi.salary_item_type_id  = sit.salary_item_type_id
													where ".$writsWhereClause);
		
	
	echo '<META http-equiv=Content-Type content="text/html; charset=UTF-8" ><body dir="rtl"><center>';
	echo "<center><table style='border:2px groove #9BB1CD;border-collapse:collapse;width:80%'>
			<tr height=200px>	
				<td align='center' style='font-family:b titr;font-size:15px'> مقایسه احکام پرداختی سال&nbsp; ".$_POST['pay_year']."  </td>				
			</tr>
		  </table></center>";      
 
	echo '<table  class="reportGenerator" style="text-align: center ;width:80%!important" cellpadding="4" cellspacing="0"> ';
	
	$prior_execute_date = $current_execute_date = $prior_writ_type = $current_writ_type = '' ; 
	$current_writ_items = $prior_writ_items = array(); 
	
	$width = round(400/count($res));
	
	for($i=0;$i<count($res);$i++) 
	{
		
		$current_writ_type .=  "<td class='money' width=".$width."px>" .	get_WrtitTypeTitle($res[$i]["current_writ_id"], $res[$i]["current_writ_ver"] , $res[$i]["staff_id"])."</td>"; 
		$prior_writ_type .= "<td class='money' >" .get_WrtitTypeTitle($res[$i]["prev_writ_id"], $res[$i]["prev_writ_ver"] , $res[$i]["staff_id"]). "</td>";
		
		$current_execute_date .= "<td class='money' >" . DateModules::miladi_to_shamsi($res[$i]['current_execute_date']) . "</td>";
		$prior_execute_date .= "<td class='money' >" . DateModules::miladi_to_shamsi($res[$i]['prev_execute_date']) . "</td>";
		
		for($j=0; $j < count($ResITM); $j++)
		{
			if(!isset($current_writ_items[$j]))
			{
				$current_writ_items[$j] = "";
				$prior_writ_items[$j] = "";
			}

			$val = get_writSalaryItem_value($res[$i]["current_writ_id"], $res[$i]["current_writ_ver"] ,
															  $res[$i]["staff_id"], $ResITM[$j]["salary_item_type_id"]);				
			$current_writ_items[$j] .= "<td class='money'>" . ($val == 0 ? "-" : CurrencyModulesclass::toCurrency($val)) . "</td>";
			

			$val = get_writSalaryItem_value($res[$i]["prev_writ_id"], $res[$i]["prev_writ_ver"] ,
															  $res[$i]["staff_id"], $ResITM[$j]["salary_item_type_id"]);
			$prior_writ_items[$j] .= "<td class='money'>" . ($val == 0 ? "-" : CurrencyModulesclass::toCurrency($val)) . "</td>";
			
		}
			
	}
	
	echo "<tr>
			<td style='width:80px' rowspan=2>عنوان حکم </td>
			<td style='width:20px'>قبلي</td>
			" . $prior_writ_type . "
		</tr>
		<tr>
			<td>فعلی</td>
			" . $current_writ_type . "
		</tr>";
	
	echo "<tr>
			<td style='width:80px' rowspan=2>تاريخ اجراي حکم</td>
			<td style='width:20px'>قبلي</td>
			" . $prior_execute_date . "
		</tr>
		<tr>
			<td>فعلی</td>
			" . $current_execute_date . "
		</tr>";
	
	for($j=0; $j<count($ResITM); $j++)
	{
		echo "
		<tr>
			<td style='width:130px'  rowspan=2>" . $ResITM[$j]["print_title"] . "</td>
			<td>قبلي</td>
			" . $prior_writ_items[$j] . "
		</tr>
		<tr>
			<td>فعلی</td>
			" . $current_writ_items[$j] . "
		</tr>";
	}
	
	echo "</table>" ; 	

	die();

}