Exemplo n.º 1
0
	private function compute_salary_item5_33($writ_rec) {

		//param1 : مبلغ فوق العاده تعديل سال قبل
		//param2 : ضريب

		$this_writ_year = substr(DateModules::miladi_to_shamsi($writ_rec['execute_date']), 0, 4);

		$one_year_ago = $this_writ_year - 1;
		$one_year_ago_last_day = $one_year_ago . "/12/29";
		$Gone_year_ago_last_day = DateModules::shamsi_to_miladi($one_year_ago_last_day);

		//آخرين حکم قبل از سال شخص را استخراج مي کند.
		$prior_writObj = manage_writ::get_last_writ_by_date($writ_rec['staff_id'], $Gone_year_ago_last_day);

		//مقدار قلم فوق العاده تعديل آخرين حکم سال قبل را استخراج مي کند.
		//اين قلم بر اساس بخشنامه افزايش حقوق سال 87 اضافه شد.
		$this->param1 = manage_writ_item::get_writSalaryItem_value($prior_writObj->writ_id, $prior_writObj->writ_ver, $prior_writObj->staff_id, SIT5_STAFF_EXTRA_ADJUST);
		$this->param2 = 1.5;

		$value = $this->param1 * $this->param2;

		if (!($value > 0)) {
			return false;
		}

		return $value;
	}
Exemplo n.º 2
0
function transferAction()
{
    $selected_writs = array();
    $keys = array_keys($_POST);
    for ($i = 0; $i < count($_POST); $i++) {
        if (strpos($keys[$i], "chk_") !== false) {
            $arr = preg_split('/_/', $keys[$i]);
            $selected_writs[] = array("writ_id" => $arr[1], "writ_ver" => $arr[2], "staff_id" => $arr[3], "execute_date" => $arr[4]);
        }
    }
    $new_state = $_POST["new_state"];
    $old_state = $_POST["mode"] == "return" ? $new_state + 1 : $new_state - 1;
    $return = true;
    for ($i = 0; $i < count($selected_writs); $i++) {
        if (manage_writ::change_writ_state($old_state, $new_state, $selected_writs[$i]["writ_id"], $selected_writs[$i]["writ_ver"], $selected_writs[$i]["staff_id"], $selected_writs[$i]["execute_date"]) == false) {
            $return = false;
        }
    }
    if ($return) {
        echo "true";
    } else {
        print_r(ExceptionHandler::PopAllExceptions());
    }
    die;
    /*
    	$selected_writs = "";
    	$keys = array_keys($_POST);
    	for($i=0; $i < count($_POST); $i++)
    	{
    		if(strpos($keys[$i],"chk_") !== false)
    		{
    			$arr = preg_split('/_/', $keys[$i]);
    			$selected_writs .= "'" . $arr[1] . "_" . $arr[2] . "_" . $arr[3] . "',";
    		}
    	}
    	$selected_writs = ($selected_writs != "") ? substr($selected_writs, 0, strlen($selected_writs) - 1) : "''";
    	 
    	$return = PdoDataAccess::runquery("DROP TABLE if EXISTS tmp_transfer_writs");
    	if($return === false)
    	{
    		$DB->rollBack();
    		echo "false";
    		die();
    	}
    	
    	$return = PdoDataAccess::runquery("CREATE TABLE tmp_transfer_writs TYPE=MyIsam AS
    				(SELECT w.staff_id , w.writ_id , w.writ_ver , w.execute_date
    				FROM writs w
    				WHERE (w.history_only=0 OR w.history_only IS NULL)
     			    	AND (w.dont_transfer = 0 OR w.dont_transfer IS NULL)
      			    	AND (w.correct_completed !=" . WRIT_CORRECTING . ")
      			     	AND CONCAT(writ_id,'_',writ_ver,'_',staff_id) in (" . $selected_writs . "))");
    	if($return === false)
    	{
    		$DB->rollBack();
    		echo "false";
    		die();
    	}
    	
    	$return = PdoDataAccess::runquery("UPDATE writs w
    	  		  SET state = " . $_POST["new_state"] . ($_POST["new_state"] == "2" ? ",view_flag=1" : "") . "
    			  WHERE (w.history_only=0 OR w.history_only IS NULL) 
       			    	AND (w.dont_transfer = 0 OR  w.dont_transfer IS NULL)
      			    	AND (w.correct_completed!=" . WRIT_CORRECTING . ")
      	     			AND CONCAT(writ_id,'_',writ_ver,'_',staff_id) in (" . $selected_writs . ")");
    	if($return === false)
    	{
    		$DB->rollBack();
    		echo "false";
    		die();
    	}
    	
    	if(PdoDataAccess::AffectedRows() > 0)
    	{
    		$return = PdoDataAccess::runquery("UPDATE writs w
    				INNER JOIN tmp_transfer_writs tw ON(tw.staff_id = w.staff_id AND 
    						tw.execute_date = w.execute_date AND
    						tw.staff_id = w.staff_id AND 
    						((tw.writ_id=w.writ_id AND tw.writ_ver>w.writ_ver) OR tw.writ_id>w.writ_id)	AND 
    						(w.history_only=0 OR w.history_only IS NULL))
    				SET history_only=1
    				WHERE w.state = " . $_POST["new_state"]);
    		if($return === false)
    		{
    			$DB->rollBack();
    			echo "false";
    			die();
    		}
    	}
    	
    	$DB->commit();
    	echo "true";
    	die();*/
}
Exemplo n.º 3
0
 function Next_Corrective_Writ()
 {
     $query = "  SELECT  w.writ_id,\n                            w.writ_ver,\n                            w.staff_id,\n                            w.execute_date,\n                            w.corrective ,\n                            s.person_type ,\n                            w2.writ_ver upper_ver\n\n                    FROM   staff s\n                           LEFT OUTER JOIN writs w\n                                ON (w.staff_id = s.staff_id )\n                           LEFT OUTER JOIN writs w2\n                                ON (w2.staff_id = s.staff_id AND w2.writ_id = w.writ_id AND w.writ_ver + 1 = w2.writ_ver )\n                    WHERE\n                           s.staff_id = {$this->staff_id} AND\n                            (w.execute_date > '{$this->execute_date}' OR (w.execute_date = '{$this->execute_date}' AND w.writ_id > {$this->writ_id}) ) AND\n                           ((w.history_only != " . HISTORY_ONLY . " OR w.history_only IS NULL)OR\n                            (w.writ_id={$this->corrective_writ_id} AND w.writ_ver={$this->corrective_writ_ver}))\n                            AND (w2.writ_ver IS NULL OR w.history_only != " . HISTORY_ONLY . " OR w.history_only IS NULL)\n                     ORDER BY s.staff_id , w.execute_date,w.writ_id , w.writ_ver ";
     $temp = parent::runquery($query);
     if (count($temp) > 0) {
         $state = 1;
         $next_writ_rec = $temp[0];
         for ($i = 0; $i < count($temp); $i++) {
             if ($state == 2) {
                 if ($temp[$i]['execute_date'] == $min_execute_date && $temp[$i]['corrective'] != 1) {
                     $next_writ_rec = $temp[$i];
                 } else {
                     break;
                 }
             }
             if ($state == 1) {
                 $min_execute_date = $temp[$i]['execute_date'];
                 $next_writ_rec = $temp[$i];
                 $state = 2;
             }
         }
     }
     if (!$next_writ_rec) {
         return false;
     }
     $obj = new manage_writ($next_writ_rec['writ_id'], $next_writ_rec['writ_ver'], $next_writ_rec['staff_id']);
     if ($obj->writ_id > 0) {
         if ($this->corrective_writ_id != $obj->writ_id || $this->corrective_writ_ver != $obj->writ_ver || $obj->corrective == 0) {
             $obj->history_only = 1;
             $qry3 = " select writ_id , writ_ver\n                                from writs\n                                       where writ_id = " . $obj->writ_id . " and writ_ver = " . $obj->writ_ver . " and\n                                             staff_id =" . $obj->staff_id . " and state=" . WRIT_PERSONAL;
             $tmp3 = parent::runquery($qry3);
             if (count($tmp3) > 0) {
                 $obj->EditWrit();
             }
             //............
             $qry1 = " SELECT issue_date\n    \t\t\t\t\t        FROM writs\n    \t\t\t\t\t            WHERE writ_id = " . $this->corrective_writ_id . " AND writ_ver= " . $this->corrective_writ_ver . " AND staff_id = " . $this->staff_id;
             $tmp1 = parent::runquery($qry1);
             $obj->issue_date = DateModules::shNow();
             //$tmp1[0]['issue_date'];
             if ($obj->execute_date > $obj->issue_date) {
                 $obj->pay_date = $obj->execute_date;
             } else {
                 $obj->pay_date = $obj->issue_date;
             }
             $qry2 = " select last_writ_id , last_writ_ver\n                                from staff where staff_id =" . $obj->staff_id;
             $tmp2 = parent::runquery($qry2);
             //.............
             $obj->history_only = 0;
             //end
             if (!$next_writ_rec['upper_ver']) {
                 $obj->writ_ver++;
             } else {
                 $qry4 = " SELECT MAX(writ_ver) writ_ver\n                                FROM writs\n                                        WHERE writ_id = " . $obj->writ_id;
                 $tmp4 = parent::runquery($qry4);
                 $obj->writ_ver = $tmp4[0]['writ_ver'] + 1;
             }
             $obj->state = 1;
             $obj->corrective = 0;
             $obj->corrective_date = $this->corrective_date;
             $obj->corrective_writ_id = $this->corrective_writ_id;
             $obj->corrective_writ_ver = $this->corrective_writ_ver;
             $obj->correct_completed = WRIT_CORRECTING;
             $qry5 = " select personid,staff_id from staff where staff_id =" . $obj->staff_id;
             $tmp5 = parent::runquery($qry5);
             $education_level_rec = manage_person_education::GetEducationLevelByDate($tmp5[0]['personid'], $obj->execute_date);
             $obj->education_level = $education_level_rec['max_education_level'];
             $obj->sfid = $education_level_rec['sfid'];
             $obj->sbid = $education_level_rec['sbid'];
             $where = " PersonID=" . $tmp5[0]['personid'] . "  AND\n                      (dependency = 5 or dependency = 6) AND\n\t\t\t\t       birth_date <='" . $obj->execute_date . "'";
             $obj->children_count = manage_person_dependency::CountDependency($where);
             $obj->included_children_count = manage_person_dependency::bail_count($tmp5[0]['personid'], $obj->person_type, $obj->execute_date, $obj->execute_date);
             $person_obj = new manage_person($tmp5[0]['personid']);
             $obj->marital_status = $person_obj->marital_status;
             //......
             if ($obj->person_type == HR_PROFESSOR && $obj->staff_id != '111551') {
                 $obj->writ_signature_post_owner = 'محمد کافی';
                 $obj->writ_signature_post_title = ' رئیس دانشگاه';
                 //$this->writ_signature_post_title = ' رئیس دانشگاه ';
             } else {
                 if ($obj->person_type == HR_PROFESSOR && $obj->staff_id == '111551') {
                     //$this->writ_signature_post_owner = 'محمدجواد وریدی' ;
                     $obj->writ_signature_post_owner = 'ابوالفضل باباخانی';
                     $obj->writ_signature_post_title = 'معاون اداری ومالی دانشگاه';
                 } else {
                     $obj->writ_signature_post_owner = $obj->issue_date > '2014-02-01' ? 'ابوالقاسم ساقی' : WRIT_SIGNATURE_POST_OWNER;
                 }
             }
             //.......
             //$obj->writ_signature_post_owner = ($obj->issue_date > '2014-02-01') ? 'ابوالقاسم ساقی' : WRIT_SIGNATURE_POST_OWNER ;
             $pdo = parent::getPdoObject();
             $pdo->beginTransaction();
             if (!$obj->onBeforeInsert()) {
                 $pdo->rollBack();
                 return false;
             }
             $return = parent::insert("writs", $obj);
             if (!$return) {
                 parent::PushException("ايجاد با شکست مواجه شد");
                 $pdo->rollBack();
                 return false;
             }
             if (!$obj->onAfterInsert()) {
                 parent::PushException("ايجاد با شکست مواجه شد");
                 $pdo->rollBack();
                 return false;
             }
             $pdo->commit();
             if (!manage_writ_item::compute_writ_items($obj->writ_id, $obj->writ_ver, $obj->staff_id)) {
                 return false;
             }
         } else {
             $description = "";
             $this->writ_id = $obj->writ_id;
             $this->writ_ver = $obj->writ_ver;
             $qry3 = " SELECT w.writ_id , w.writ_ver , w.execute_date , w.issue_date ,  ws.title\n                            FROM writs w\n                                INNER JOIN writ_subtypes ws ON ws.writ_type_id = w.writ_type_id\n                                    AND ws.writ_subtype_id = w.writ_subtype_id AND w.person_type = ws.person_type\n                                    AND w.staff_id = " . $obj->staff_id . "\n                                INNER JOIN\n                                (\n                                SELECT\n                                    writ_id , writ_ver - 1 writ_ver2\n                                FROM writs\n                                WHERE\n                                    corrective_writ_id = {$this->corrective_writ_id} AND corrective_writ_ver = {$this->corrective_writ_ver} AND  staff_id = " . $obj->staff_id . "\n                                )\n                                w2\n                                    ON w.writ_id = w2.writ_id AND w.writ_ver = w2.writ_ver2";
             $tmp3 = parent::runquery($qry3);
             $qry4 = " SELECT w.writ_id , w.writ_ver , w.execute_date , w.issue_date ,  ws.title\n                            FROM writs w\n                                INNER JOIN writ_subtypes ws\n                                        ON ws.writ_type_id = w.writ_type_id\n                                                AND ws.writ_subtype_id = w.writ_subtype_id AND w.person_type = ws.person_type\n                                                AND w.staff_id = {$obj->staff_id}\n                                WHERE\n                                    corrective_writ_id = {$this->corrective_writ_id} AND corrective_writ_ver = {$this->corrective_writ_ver} AND\n                                    w.writ_ver = 1 AND staff_id =" . $obj->staff_id;
             $tmp4 = parent::runquery($qry4);
             $i = 0;
             $j = 0;
             if (!empty($tmp4[0]['send_letter_no'])) {
                 $description .= 'بر اساس حکم شماره ' . $tmp4[0]['send_letter_no'] . ' مورخه ' . DateModules::miladi_to_shamsi($tmp4[0]['issue_date']) . ' احکام ذيل اصلاح مي گردد : ' . chr(13);
             } else {
                 $description .= 'ليست احکام اصلاح شده : ' . chr(13);
             }
             for ($i = 0; $i < count($tmp3); $i++) {
                 $description .= $i + 1 . '- حکم ' . $tmp3[$i]['title'] . ' شماره ' . $tmp3[$i]['send_letter_no'] . ' مورخه ' . DateModules::miladi_to_shamsi($tmp3[$i]['issue_date']) . chr(13);
             }
             parent::runquery(" UPDATE writs\n                                         SET correct_completed=" . WRIT_CORRECT_COMPLETED . "\n                                    WHERE(\n                                        (corrective_writ_id={$this->corrective_writ_id} AND corrective_writ_ver={$this->corrective_writ_ver})\n                                            OR(writ_id={$this->corrective_writ_id} AND writ_ver={$this->corrective_writ_ver} AND staff_id = {$this->staff_id} )\n                                    )");
             parent::runquery(" UPDATE writs\n                                        SET description = '" . $description . "'\n                                        WHERE  writ_id = {$this->writ_id} AND writ_ver={$this->writ_ver} AND description IS NULL AND staff_id =" . $this->staff_id);
         }
         return $obj;
     }
 }
Exemplo n.º 4
0
function PrintWrit($writ_rec)
{
    $sum = 0;
    $content = "";
    $emp_sal_scores = $emp_sal_vals = "";
    $salary_items = $corrective_detail = $professor_post_type = $org_sub_unit_type = $writ_title = $contact_title = $worker_salary_item1_title = $worker_salary_item1_value = $worker_salary_item2_title = $worker_salary_item2_value = $worker_other_salary_items = $worker_base_salary = $emp_sal_items = $template_file = $exe_date_title = "";
    $post_title = "";
    $os_ptitle = "";
    $sit2_annual_inc_coef = "";
    $indx = array("الف-", "ب-", "پ-", "ت-", "ث-", "ج-", "چ-", "ح-", "خ-", "د-", "ذ-", "ر-", "ز-", "س-", "ش-", "و-", "ه-", "ي-");
    global $equal_payment_system_gdate;
    // مشخص كردن template مربوط به حكم جاري
    if ($writ_rec['person_type'] == HR_EMPLOYEE) {
        if ($writ_rec['emp_state'] == EMP_STATE_PROBATIONAL_CEREMONIOUS || $writ_rec['emp_state'] == EMP_STATE_APPROVED_CEREMONIOUS) {
            if (DateModules::CompareDate($writ_rec['execute_date'], $equal_payment_system_gdate) >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') < 0 || DateModules::CompareDate($writ_rec['execute_date'], '2013-03-21') >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2014-03-21') < 0) {
                if ($writ_rec['emp_mode'] == 14) {
                    $template_file = 'employee_ceremonious_writ_print4.htm';
                } else {
                    $template_file = 'employee_ceremonious_writ_print2.htm';
                }
            } else {
                if (DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2013-03-21') < 0 || DateModules::CompareDate($writ_rec['execute_date'], '2014-03-20') > 0) {
                    $template_file = 'employee_ceremonious_writ_print3.htm';
                } else {
                    $template_file = 'employee_ceremonious_writ_print.htm';
                }
            }
        }
        if ($writ_rec['emp_state'] == EMP_STATE_CONTRACTUAL) {
            if (DateModules::CompareDate($writ_rec['execute_date'], $equal_payment_system_gdate) >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') < 0 || DateModules::CompareDate($writ_rec['execute_date'], '2013-03-21') >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2014-03-20') < 0) {
                $template_file = 'employee_contractual_writ_print_report2.htm';
            } else {
                if (DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2013-03-21') < 0 || DateModules::CompareDate($writ_rec['execute_date'], '2014-03-20') > 0) {
                    $template_file = 'employee_contractual_writ_print_report3.htm';
                } else {
                    $template_file = 'employee_contractual_writ_print_report.htm';
                }
            }
            $writ_title = "قرارداد کارمند پیمانی";
        }
    } else {
        if ($writ_rec['person_type'] == HR_PROFESSOR) {
            if ($writ_rec['emp_state'] == EMP_STATE_PROBATIONAL_CEREMONIOUS || $writ_rec['emp_state'] == EMP_STATE_APPROVED_CEREMONIOUS) {
                $template_file = 'professor_ceremonious_writ_print.htm';
                $writ_title = 'حکم استخدام رسمي اعضاي هيات علمي';
            } else {
                if ($writ_rec['emp_state'] == EMP_STATE_SOLDIER_CONTRACTUAL || $writ_rec['emp_state'] == EMP_STATE_ONUS_SOLDIER_CONTRACTUAL || $writ_rec['emp_state'] == EMP_STATE_CONTRACTUAL || $writ_rec['emp_state'] == 11) {
                    $template_file = 'professor_contractual_writ_print_report.htm';
                    if ($writ_rec['time_limited'] == 1) {
                        $writ_title = 'قرارداد استخدام پيماني اعضاي هيات علمي';
                    } else {
                        $writ_title = $writ_rec['wst_title'] . ' اعضاي هيات علمي پيماني';
                    }
                    if ($writ_rec['emp_state'] == 11) {
                        $writ_title = " قرارداد پیمانی (مشروط) اعضای هیئت علمی ";
                    }
                }
            }
            if ($writ_rec['corrective']) {
                $template_file = 'professor_ceremonious_writ_print.htm';
            }
        } else {
            if ($writ_rec['person_type'] == HR_WORKER) {
                $template_file = 'worker_writ_print.htm';
                /*if( DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') < 0)
                			$template_file = 'worker_writ_print.htm';
                		else
                			$template_file = 'worker_writ_print2.htm';*/
                if ($writ_rec['corrective']) {
                    $writ_title = 'طرح طبقه بندي مشاغل <br>حكم اصلاحي كارگزيني';
                } else {
                    $writ_title = 'طرح طبقه بندي مشاغل <br>حکم کارگزيني';
                }
            } else {
                if ($writ_rec['person_type'] == HR_CONTRACT) {
                    if (DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') < 0 || DateModules::CompareDate($writ_rec['execute_date'], '2013-03-21') >= 0 && DateModules::CompareDate($writ_rec['execute_date'], '2014-03-20') < 0) {
                        $template_file = 'contract_writ_print.htm';
                        $writ_title = "قرار داد انجام کار مشخص";
                    } else {
                        $template_file = 'contract_writ_print3.htm';
                        $writ_title = "قرارداد کارکنان قراردادی";
                    }
                }
            }
        }
    }
    echo "<div style='display:none'>" . $template_file . "</div>";
    // محل تحصيل و زمان اخذ مدرك
    $person_education_rec = manage_person_education::GetEducationLevelByDate($writ_rec['PersonID'], $writ_rec['execute_date']);
    $edu_c_ptitle = $person_education_rec['countryTitle'];
    $edu_u_ptitle = $person_education_rec['universityTitle'];
    $education_level_title = $writ_rec['education_level_title'];
    $edu_doc_date = "";
    if ($writ_rec['sfid'] != PROFESSIONAL_WITHOUT_CERTIFY) {
        $edu_doc_date = DateModules::miladi_to_shamsi($person_education_rec['doc_date']);
    } else {
        $education_level_title = "";
    }
    // سوابق خدمت
    $onduty = "";
    if ($writ_rec['onduty_year'] > 0) {
        $onduty .= $writ_rec['onduty_year'];
        $onduty .= ' سال ';
    }
    if ($writ_rec['onduty_month'] > 0) {
        if ($writ_rec['onduty_year'] > 0) {
            $onduty .= ' و ';
        }
        $onduty .= $writ_rec['onduty_month'];
        $onduty .= ' ماه ';
    }
    if ($writ_rec['onduty_day'] > 0 || $writ_rec['onduty_year'] > 0) {
        if ($writ_rec['onduty_month'] > 0) {
            $onduty .= "&nbsp;" . ' و ';
        }
        $onduty .= $writ_rec['onduty_day'];
        $onduty .= ' روز';
    }
    // وضعيت ايثارگري
    $devotion_recSet = manage_person_devotion::get_person_devotions($writ_rec['PersonID'], NULL, 'ALL');
    $devotion_type = "";
    if (is_array($devotion_recSet)) {
        foreach ($devotion_recSet as $devotion_rec) {
            $devotion_type .= " " . $devotion_rec['devotionTypeName'] . "  ";
        }
    }
    // اقلام مربوط به نظام هماهنگ پرداخت
    if (!$writ_rec['corrective'] && $writ_rec['person_type'] == HR_EMPLOYEE && DateModules::CompareDate($writ_rec['execute_date'], $equal_payment_system_gdate) >= 0 && (DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') < 0 || DateModules::CompareDate($writ_rec['execute_date'], '2013-03-20') > 0 && DateModules::CompareDate($writ_rec['execute_date'], '2014-03-21') < 0)) {
        $item_recset = manage_writ_item::GetAllWritItems("writ_id=? AND writ_ver=? AND staff_id=?", array($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec["staff_id"]));
        $emp_sal_items = array();
        $Sayer = 0;
        $Sayer_Score = 0;
        $score_sum = 0;
        foreach ($item_recset as $rec) {
            if ($writ_rec['emp_mode'] == 14) {
                $emp_sal_items['<!---item_' . $rec['salary_item_type_id'] . '-->'] = CurrencyModulesclass::toCurrency($rec['value'], 'CURRENCY');
                if ($rec['value']) {
                    $emp_sal_vals[$rec['salary_item_type_id']] = $rec['value'];
                    $sum += $rec['value'];
                }
            } else {
                if ($rec['salary_item_type_id'] != 57 && $rec['salary_item_type_id'] != 45) {
                    $emp_sal_items['<!---item_' . $rec['salary_item_type_id'] . '-->'] = CurrencyModulesclass::toCurrency($rec['value'], 'CURRENCY') . " " . ($rec['value'] < 0 ? '-' : '');
                    $emp_sal_items['<!---item_' . $rec['salary_item_type_id'] . '_score-->'] = $rec['param1'];
                    if ($rec['value']) {
                        $emp_sal_vals[$rec['salary_item_type_id']] = $rec['value'];
                        $sum += $rec['value'];
                    }
                    if ($rec['param1']) {
                        $emp_sal_scores[$rec['salary_item_type_id']] = $rec['param1'];
                        $score_sum += $rec['param1'];
                    }
                } else {
                    $rec['salary_item_type_id'] = 45;
                    $Sayer += $rec['value'];
                    $Sayer_Score += $rec['param1'];
                    $emp_sal_items['<!---item_' . $rec['salary_item_type_id'] . '-->'] = CurrencyModulesclass::toCurrency($Sayer);
                    $emp_sal_items['<!---item_' . $rec['salary_item_type_id'] . '_score-->'] = $Sayer_Score != 0 ? $Sayer_Score : "";
                    if ($rec['value']) {
                        $emp_sal_vals[$rec['salary_item_type_id']] = $Sayer;
                        $sum += $rec['value'];
                    }
                    if ($rec['param1'] > 0) {
                        $emp_sal_scores[$rec['salary_item_type_id']] = $Sayer_Score;
                        $score_sum += $rec['param1'];
                    }
                }
            }
        }
        if ($emp_sal_scores != "") {
            $emp_sal_items['<!---fix_salary_score-->'] = CurrencyModulesclass::toCurrency((isset($emp_sal_scores[34]) ? $emp_sal_scores[34] : 0) + (isset($emp_sal_scores[35]) ? $emp_sal_scores[35] : 0) + (isset($emp_sal_scores[36]) ? $emp_sal_scores[36] : 0));
        }
        if ($emp_sal_vals != "") {
            $emp_sal_items['<!---fix_salary_value-->'] = CurrencyModulesclass::toCurrency((isset($emp_sal_vals[34]) ? $emp_sal_vals[34] : 0) + (isset($emp_sal_vals[35]) ? $emp_sal_vals[35] : 0) + (isset($emp_sal_vals[36]) ? $emp_sal_vals[36] : 0));
        }
        $emp_sal_items['<!---salary_score-->'] = CurrencyModulesclass::toCurrency($score_sum);
        $emp_sal_items['<!---salary_sum-->'] = CurrencyModulesclass::toCurrency($sum);
    } else {
        if (!$writ_rec['corrective'] && $writ_rec['person_type'] == HR_EMPLOYEE && (DateModules::CompareDate($writ_rec['execute_date'], '2013-02-19') >= 0 || DateModules::CompareDate($writ_rec['execute_date'], '2014-03-20') >= 0) || $writ_rec['person_type'] == HR_CONTRACT && ($writ_rec['execute_date'] >= '2013-02-19' || DateModules::CompareDate($writ_rec['execute_date'], '2014-03-21') >= 0)) {
            $item_recset = manage_writ_item::GetAllWritItems("writ_id=? AND writ_ver=? AND staff_id=?", array($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec["staff_id"]));
            $emp_sal_items = array();
            $Sayer = 0;
            $Sayer_Score = 0;
            $score_sum = 0;
            foreach ($item_recset as $rec) {
                if ($rec['salary_item_type_id'] == 10364) {
                    $rec['salary_item_type_id'] = 10264;
                } elseif ($rec['salary_item_type_id'] == 10367) {
                    $rec['salary_item_type_id'] = 10267;
                } elseif ($rec['salary_item_type_id'] == 10366) {
                    $rec['salary_item_type_id'] = 10266;
                } elseif ($rec['salary_item_type_id'] == 10365) {
                    $rec['salary_item_type_id'] = 10265;
                } elseif ($rec['salary_item_type_id'] == 10373) {
                    $rec['salary_item_type_id'] = 10332;
                } elseif ($rec['salary_item_type_id'] == 10374) {
                    $rec['salary_item_type_id'] = 10333;
                } elseif ($rec['salary_item_type_id'] == 10328) {
                    $rec['salary_item_type_id'] = 10369;
                } elseif ($rec['salary_item_type_id'] == 10372) {
                    $rec['salary_item_type_id'] = 10331;
                } elseif ($rec['salary_item_type_id'] == 10371) {
                    $rec['salary_item_type_id'] = 10330;
                } elseif ($rec['salary_item_type_id'] == 10370) {
                    $rec['salary_item_type_id'] = 10329;
                } elseif ($rec['salary_item_type_id'] == 10368) {
                    $rec['salary_item_type_id'] = 10327;
                } elseif ($rec['salary_item_type_id'] == 10335) {
                    $rec['salary_item_type_id'] = 10376;
                } elseif ($rec['salary_item_type_id'] == 10334) {
                    $rec['salary_item_type_id'] = 10375;
                }
                $emp_sal_items['<!---item_' . $rec['salary_item_type_id'] . '-->'] = CurrencyModulesclass::toCurrency($rec['value'], 'CURRENCY');
                //$emp_sal_items['<!---item_'.$rec['salary_item_type_id'].'_score-->'] = $rec['param1'];
                if ($rec['value']) {
                    $emp_sal_vals[$rec['salary_item_type_id']] = $rec['value'];
                    $sum += $rec['value'];
                }
                /*if($rec['param1'])
                		{
                			$emp_sal_scores[$rec['salary_item_type_id']] = $rec['param1'] ;
                			$score_sum += $rec['param1'];
                		}*/
            }
            //$emp_sal_items['<!---salary_score-->'] = CurrencyModulesclass::toCurrency($score_sum);
            $emp_sal_items['<!---salary_sum-->'] = CurrencyModulesclass::toCurrency($sum);
        } else {
            if (!$writ_rec['corrective'] && ($writ_rec['person_type'] == HR_EMPLOYEE || $writ_rec['person_type'] == HR_PROFESSOR)) {
                ob_start();
                $item_recset = manage_writ_item::GetAllWritItems("writ_id=? AND writ_ver=? AND staff_id=?", array($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec["staff_id"]));
                $counter = 0;
                $sum = 0;
                foreach ($item_recset as $rec) {
                    echo "<tr>\n\t\t\t\t<td class='list-beginnormal' width='50%' style='padding-top:2; padding-bottom:2'>\n\t\t\t\t\t<span class='report_data'>" . $indx[$counter] . $rec['print_title'];
                    if ($rec['salary_item_type_id'] == SIT_PROFESSOR_FOR_BYLAW_15_3015) {
                        $content .= ' (' . $rec['param1'] . ' پايه)';
                    }
                    echo "</span>\n\t\t\t\t </td><td class='list-beginnormal' width='25%' style='padding-top:2; padding-bottom:2'>\n\t\t\t\t\t<span class='report_data'>" . CurrencyModulesclass::toCurrency($rec['value']) . "</span></td>\n\t\t\t\t\t\n\t\t\t\t<td class='list-beginnormal' width='25%' align='center' style='padding-top:2; padding-bottom:2'\n\t\t\t\t\t<span class='report_data'>ريال</span></td>\n\t\t\t</tr>";
                    $counter++;
                    $sum = $sum + $rec['value'];
                }
                if (!$item_recset && $writ_rec['person_type'] == HR_PROFESSOR) {
                    $salary_item_types_recSet = manage_writ_item::GetAllWritItems('person_type = ' . $writ_rec["person_type"] . ' AND compute_place = ' . SALARY_ITEM_COMPUTE_PLACE_WRIT . ' AND salary_compute_type = ' . SALARY_COMPUTE_TYPE_FUNCTION . ' AND user_data_entry = ' . AUTOMATIC . " AND validity_start_date <= '" . $writ_rec['execute_date'] . "' AND (validity_end_date >= '" . $writ_rec['execute_date'] . "' OR validity_end_date IS NULL)" . ' ORDER BY print_order');
                    if ($salary_item_types_recSet) {
                        foreach ($salary_item_types_recSet as $key => $salary_item_types_rec) {
                            echo "<tr>\n\t\t\t\t\t\t\t<td class='list-beginnormal' colspan='2' style='padding-top:2; padding-bottom:2'>" . $indx[$counter] . $salary_item_types_rec['print_title'];
                            if ($salary_item_types_rec['salary_item_type_id'] == SIT_PROFESSOR_FOR_BYLAW_15_3015) {
                                $content .= ' (' . $salary_item_types_rec['param1'] . ' پايه)';
                            }
                            echo "</td>\n\t\t\t\t\t\t<td class='list-beginnormal' style='padding-top:2; padding-bottom:2'> ----- </td>\n\t\t\t\t\t\t<td class='list-beginnormal' style='padding-top:2; padding-bottom:2'>ريال</td>\n\t\t\t\t\t</tr>";
                            $counter++;
                        }
                    }
                }
                for ($i = $counter; $i < 8; $i++) {
                    echo "<tr>\n\t\t\t\t<td class='list-beginnormal' width='50%' style='padding-top:2; padding-bottom:2'>&nbsp;</td>\n\t\t\t\t<td class='list-beginnormal' width='25%' style='padding-top:2; padding-bottom:2'>&nbsp;</td>\n\t\t\t\t<td class='list-beginnormal' width='25%' align='center' style='padding-top:2; padding-bottom:2'>&nbsp;</td>\n\t\t\t\t</tr>";
                }
                $salary_items = ob_get_contents();
                ob_end_clean();
            }
        }
    }
    // اقلام حقوقی کارکنان قراردادی
    if ($writ_rec["person_type"] == HR_CONTRACT && ($writ_rec["execute_date"] < '2013-02-19' || $writ_rec["execute_date"] >= '2013-03-21')) {
        $item_recset = manage_writ_item::GetAllWritItems("writ_id=? AND writ_ver=? AND staff_id=?", array($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec["staff_id"]));
        ob_start();
        $sum = 0;
        for ($i = 0; $i < count($item_recset); $i++) {
            $sum += $item_recset[$i]['value'];
            if ($i % 2 == 0 && $item_recset[$i]['value'] > 0) {
                $val1 = $item_recset[$i]['value'] > 0 ? CurrencyModulesclass::toCurrency($item_recset[$i]['value']) . " ریال" : "&nbsp;";
                $title1 = $item_recset[$i]['print_title'];
                $i++;
                if ($i < count($item_recset)) {
                    $sum += $item_recset[$i]['value'];
                    $val2 = $item_recset[$i]['value'] > 0 ? CurrencyModulesclass::toCurrency($item_recset[$i]['value']) . " ریال" : "&nbsp;";
                    $title2 = $item_recset[$i]['print_title'];
                } else {
                    $val2 = "&nbsp;";
                    $title2 = "&nbsp;";
                }
                echo "<tr>\n\t\t\t\t\t\t<td>" . $indx[$i - 1] . $title1 . "</td>\n\t\t\t\t\t\t<td align='left' class='money'>" . $val1 . "</td>\n\t\t\t\t\t\t<td> . " . $indx[$i] . $title2 . "</td>\n\t\t\t\t\t\t<td align='left' class='money'>" . $val2 . "</td></tr>";
            }
        }
        $salary_items = ob_get_contents();
        ob_end_clean();
    }
    if (!$writ_rec['corrective'] && $writ_rec['person_type'] == HR_WORKER) {
        $item_recset = manage_writ_item::GetAllWritItems("writ_id=? AND writ_ver=? AND staff_id=?", array($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec['staff_id']));
        if (count($item_recset) > 0) {
            $worker_salary_item1_title = $item_recset[0]['print_title'];
            $worker_salary_item1_value = CurrencyModulesclass::toCurrency($item_recset[0]['value']);
            $worker_salary_item2_title = $item_recset[1]['print_title'];
            $worker_salary_item2_value = CurrencyModulesclass::toCurrency($item_recset[1]['value']);
            $worker_base_salary = CurrencyModulesclass::toCurrency($sum);
        }
        ob_start();
        for ($i = 0; $i <= 9; $i++) {
            echo "<tr>\n\t\t\t\t\t<td width='80px'>" . (isset($item_recset[$i]) ? $item_recset[$i]['print_title'] : "") . "</td>\n\t\t\t\t\t<td align='left' class='money'>";
            $sum += isset($item_recset[$i]) ? $item_recset[$i]['value'] : 0;
            if (isset($item_recset[$i]) && $item_recset[$i]['value'] > 0) {
                echo CurrencyModulesclass::toCurrency($item_recset[$i]['value']);
            } else {
                echo "&nbsp;";
            }
            echo "</td>\n\t\t\t\t<td style='padding-left:4px' align='left' width='40px'>" . (isset($item_recset[$i]['value']) ? 'ريال' : "&nbsp;") . "</td></tr>";
            if ($i == 1) {
                echo "<tr>\n\t\t\t\t\t\t<td><span>جمع مزد مبنا:</span></td>\n\t\t\t\t\t\t<td class='money' style='font-size:12px' align='left'>";
                echo isset($item_recset[0]) && isset($item_recset[1]) ? CurrencyModulesclass::toCurrency($item_recset[1]['value'] + $item_recset[0]['value']) : "";
                echo "</td>\n\t\t\t\t\t\t<td style='padding-left:4px' align='left' width='40px'>ريال</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td style='background-color:#bbbbbb;font-family:titr' colspan=3>20 - مزد مزايا : </td>\n\t\t\t\t\t</tr>";
            }
        }
        $worker_other_salary_items = ob_get_contents();
        ob_end_clean();
    }
    // موارد مربوط به استخدام كشوري
    if ($writ_rec['person_type'] == HR_EMPLOYEE) {
        //  وضعيت قرارداد استخدام كشوري
        $prev_writ_obj = manage_writ::get_last_writ_by_date($writ_rec['staff_id'], $writ_rec['execute_date']);
        $contact_title = $prev_writ_obj->writ_id == "" ? 'انعقاد قرارداد' : 'تمديد قرارداد';
        // ضريب افزايش سنواتي استخدام كشوري
        $WritItemObj = new manage_writ_item($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec['staff_id'], SIT_STAFF_ANNUAL_INC);
        $sit2_annual_inc_coef = $WritItemObj->param2 * 100;
        // پست سازماني استخدام كشوري
        $specialExtraWritItemObj = new manage_writ_item($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec['staff_id'], SIT_EMPLOYEE_SPECIAL_EXTRA);
        if ($specialExtraWritItemObj->writ_id) {
            $post_title = $writ_rec['p_title'];
            if ($specialExtraWritItemObj->param1 >= 600 && $specialExtraWritItemObj->param1 < 1100) {
                $post_title .= ' (کارشناس ارشد)';
            } else {
                if ($specialExtraWritItemObj->param1 >= 1100 && $specialExtraWritItemObj->param1 < 1600) {
                    $post_title .= ' (کارشناس خبره)';
                } else {
                    if ($specialExtraWritItemObj->param1 >= 1600) {
                        $post_title .= ' (کارشناس عالي)';
                    }
                }
            }
        } else {
            $post_title = $writ_rec['p_title'];
        }
    }
    if ($writ_rec["person_type"] == HR_CONTRACT) {
        $post_title = $writ_rec["p_title"] . " - " . $writ_rec["p_post_no"];
    }
    // عنوان كامل واحد سازماني
    $org_unit_title = $full_title = manage_units::get_full_title($writ_rec['ouid']);
    $ArrayUnit = preg_split('/-/', $full_title);
    $cnt = count($ArrayUnit);
    if ($cnt == 1) {
        if ($writ_rec['emp_mode'] == 6) {
            $full_title .= "<b>مامور به </b>" . $writ_rec['MissionPlace'];
        }
        if ($writ_rec['emp_mode'] == 16) {
            $full_title .= "<b>مامور از </b>" . $writ_rec['MissionPlace'];
        }
    }
    if ($cnt > 1) {
        $full_title = '';
        for ($i = 0; $i < $cnt; $i++) {
            if ($i == $cnt - 1 && $cnt > 1 && $writ_rec['emp_mode'] != 6 && $writ_rec['emp_mode'] != 16) {
                $full_title .= "<b>شاغل در </b>" . $ArrayUnit[$i];
            } else {
                if ($i == $cnt - 1 && $cnt > 1 && ($writ_rec['emp_mode'] == 6 || $writ_rec['emp_mode'] == 16)) {
                    if ($writ_rec['emp_mode'] == 6) {
                        $full_title .= "<b>مامور به </b>" . $writ_rec['MissionPlace'];
                    }
                    if ($writ_rec['emp_mode'] == 16) {
                        $full_title .= "<b>مامور از </b>" . $writ_rec['MissionPlace'];
                    }
                } elseif ($i == $cnt - 2) {
                    $full_title .= $ArrayUnit[$i] . "&nbsp;";
                } else {
                    $full_title .= $ArrayUnit[$i] . "-";
                }
            }
        }
    }
    if ($writ_rec['emp_mode'] == EMP_MODE_ENGAGEMENT) {
        $full_title = manage_units::get_full_title($writ_rec['unitCode']);
        $full_title .= '(حالت اشتغال) ';
    } else {
        if ($writ_rec['o_ouid'] != $writ_rec['pos_ouid'] && $writ_rec['pos_ouid']) {
            $same_org_unit = $writ_rec['ou_ouid'] == $writ_rec['po_ouid'];
            $full_title = '';
            if ($writ_rec['person_type'] == HR_PROFESSOR && ($writ_rec['emp_state'] == EMP_STATE_PROBATIONAL_CEREMONIOUS || $writ_rec['emp_state'] == EMP_STATE_APPROVED_CEREMONIOUS)) {
                $full_title = 'موقت از ';
                $full_title .= $writ_rec['pos_ptitle'];
                $full_title .= ' - شاغل در ';
                $full_title .= $writ_rec['o_ptitle'];
                $os_ptitle = $full_title;
            } else {
                $full_title = '';
                if ($writ_rec['person_type'] == HR_PROFESSOR) {
                    $full_title = 'موقت از ';
                }
                $full_title .= manage_units::get_full_title($writ_rec['pouid']);
                if ($writ_rec['person_type'] == HR_PROFESSOR || $writ_rec['emp_mode'] != 6 && $writ_rec['emp_mode'] != 16) {
                    $full_title .= ' - شاغل در ';
                    if (!$same_org_unit) {
                        $full_title .= $ArrayUnit[0] . ' - ';
                    }
                    for ($i = 1; $i < $cnt; $i++) {
                        if ($i != $cnt - 1) {
                            $full_title .= $ArrayUnit[$i] . ' - ';
                        } else {
                            $full_title .= $ArrayUnit[$i];
                        }
                    }
                } else {
                    if ($writ_rec['person_type'] != HR_PROFESSOR && $writ_rec['emp_mode'] == 6) {
                        $full_title .= ' مامور به ' . $writ_rec['MissionPlace'];
                    } else {
                        if ($writ_rec['person_type'] != HR_PROFESSOR && $writ_rec['emp_mode'] == 16) {
                            $full_title .= ' مامور از  ' . $writ_rec['MissionPlace'];
                        }
                    }
                }
                $os_ptitle = $full_title;
            }
        }
    }
    if ($writ_rec['emp_mode'] == 13) {
        $full_title = $ArrayUnit[0];
    }
    //گروه آموزشي / پژوهشي هيات علمي
    // واحد سازماني فرعي
    // در صورتي كه پست فرد از يك واحدي غير از واحد سازماني فرد باشد شرح آن در واحد فرعي آمده
    if (!$os_ptitle) {
        $os_ptitle = $writ_rec['os_ptitle'];
    }
    // موارد مربوط به هيات علمي
    if ($writ_rec['person_type'] == HR_PROFESSOR) {
        // نوع پست هيات علمي
        if ($writ_rec['post_type'] == POST_PROFESSOR_RSC) {
            $professor_post_type = 'پژوهشي';
        }
        // نوع گروه هيات علمي
        if ($writ_rec['org_sub_unit_type'] == EDUCATIONAL) {
            $org_sub_unit_type = ' گروه آموزشي ';
        } else {
            if ($writ_rec['org_sub_unit_type'] == RESEARCH) {
                $org_sub_unit_type = ' گروه پژوهشي ';
            }
        }
        // عنوان حكم
        if ($writ_rec['corrective']) {
            $writ_title = 'حکم اصلاحي اعضاي هيات علمي';
        }
    }
    // موارد مربوط به حكم اصلاحي
    if ($writ_rec['corrective'] == 1) {
        // مبلغ درج شده در حكم اصلاحي
        // در صورتي که حکم اصلاحي جديد است
        if ($writ_rec['history_only']) {
            $dt = PdoDataAccess::runquery("SELECT writ_id , writ_ver, staff_id FROM writs\n\t\t\t\t\tWHERE corrective_writ_id = " . $writ_rec["writ_id"] . "\n\t\t\t\t\t\tAND corrective_writ_ver = " . $writ_rec["writ_ver"] . "\n\t\t\t\t\t\tAND staff_id = " . $writ_rec["staff_id"] . "\n\t\t\t\t\tORDER BY execute_date DESC , writ_id DESC , writ_ver DESC ");
            $corective_writ_rec = $dt[0];
            $corective_writ_items_obj = new manage_writ_item($corective_writ_rec["writ_id"], $corective_writ_rec["writ_ver"], $corective_writ_rec["staff_id"], SIT_STAFF_ANNUAL_INC);
            $sit2_annual_inc_coef = $corective_writ_items_obj->param2 * 100;
            $sum = manage_writ_item::compute_writ_items_sum($corective_writ_rec["writ_id"], $corective_writ_rec["writ_ver"], $corective_writ_rec["staff_id"]);
        } else {
            $sum = manage_writ_item::compute_writ_items_sum($writ_rec['writ_id'], $writ_rec['writ_ver'], $writ_rec["staff_id"]);
        }
    }
    if ($writ_rec['corrective'] != 1) {
        $exe_date_title = '
			<tr height=25>
				<td colspan=2>
					21-تاریخ اجرای حکم :
					<span>' . DateModules::miladi_to_shamsi($writ_rec['execute_date']) . '</span>
				</td>
		   </tr>';
    }
    /*****************************************************/
    $scores = array(1 => array(1 => 2400, 2 => 2650, 3 => 2650, 4 => 2650, 5 => 2650), 2 => array(1 => 2600, 2 => 2850, 3 => 2850, 4 => 2850, 5 => 2850), 3 => array(1 => 2800, 2 => 3050, 3 => 3050, 4 => 3050, 5 => 3050), 4 => array(1 => 3000, 2 => 3250, 3 => 3600, 4 => 4050, 5 => 4600), 5 => array(1 => 3200, 2 => 3450, 3 => 3800, 4 => 4250, 5 => 4800), 6 => array(1 => 3400, 2 => 3650, 3 => 4000, 4 => 4450, 5 => 5000), 7 => array(1 => 3600, 2 => 3850, 3 => 4200, 4 => 4650, 5 => 5200), 8 => array(1 => 3800, 2 => 4050, 3 => 4400, 4 => 4850, 5 => 5400), 9 => array(1 => 4000, 2 => 4250, 3 => 4600, 4 => 5050, 5 => 5600), 10 => array(1 => 4200, 2 => 4450, 3 => 4800, 4 => 5250, 5 => 5800), 11 => array(1 => 4400, 2 => 4650, 3 => 5000, 4 => 5450, 5 => 6000), 12 => array(1 => 4600, 2 => 4850, 3 => 5200, 4 => 5650, 5 => 6200), 13 => array(1 => 4800, 2 => 5050, 3 => 5400, 4 => 5850, 5 => 6400), 14 => array(1 => 5000, 2 => 5250, 3 => 5600, 4 => 6050, 5 => 6600), 15 => array(1 => 5200, 2 => 5450, 3 => 5800, 4 => 6250, 5 => 6800), 16 => array(1 => 5400, 2 => 5650, 3 => 6000, 4 => 6450, 5 => 7000));
    $current_group = $writ_rec['cur_group'];
    $grup = "";
    if ($writ_rec['person_type'] == HR_EMPLOYEE && DateModules::CompareDate($writ_rec['execute_date'], $equal_payment_system_gdate) >= 0) {
        $s = "";
        $indx = $current_group - 4;
        if ($emp_sal_scores != "" && $emp_sal_scores[34]) {
            $s = $emp_sal_scores[34];
        } else {
            $writ_obj = manage_writ::get_last_writ_by_date($writ_rec['staff_id'], $writ_rec['execute_date'], 34);
            if ($writ_obj->writ_id) {
                $item_obj = new manage_writ_item($writ_obj->writ_id, $writ_obj->writ_ver, $writ_obj->staff_id, 34);
                $s = $item_obj->param1;
            }
        }
        $grade = "";
        if ($scores[$indx][1] == $s) {
            $grade = 'مقدماتی';
        } else {
            if ($scores[$indx][2] == $s) {
                $grade = 'پایه';
            } else {
                if ($scores[$indx][3] == $s) {
                    $grade = 'ارشد';
                } else {
                    if ($scores[$indx][4] == $s) {
                        $grade = 'خبره';
                    } else {
                        if ($scores[$indx][5] == $s) {
                            $grade = 'عالی';
                        }
                    }
                }
            }
        }
        $current_group = $grade;
        $grup = $writ_rec['new_grup'];
    } else {
        $grup = $writ_rec['old_grup'];
    }
    $listPNO = "";
    if ($writ_rec['personel_no'] != NULL && $writ_rec['person_type'] == 1) {
        $listPNO = preg_split('/-/', $writ_rec['personel_no']);
    }
    /*****************************************************/
    $MilitaryD = "";
    if ($writ_rec['militaryID'] != 17) {
        $MilitaryD = " <militaryDate> شروع : <span><!--military_from_date--></span>\n                                                             پایان: <span><!--military_to_date--></span></militaryDate>\n\t\t";
    }
    if ($writ_rec['E_base'] == NULL && ($writ_rec['person_type'] == HR_EMPLOYEE || $writ_rec['person_type'] == HR_CONTRACT)) {
        $qry = " SELECT  w.staff_id,\n\t\t\t\t\t\t\t SUBSTRING_INDEX(SUBSTRING(max(CONCAT(w.execute_date,w.writ_id,'.',w.writ_ver)),11),'.',1) writ_id,\n\t\t\t\t\t\t\t\t\t\tSUBSTRING_INDEX(max(CONCAT(w.execute_date,w.writ_id,'.',w.writ_ver)),'.',-1) writ_ver\n\n\t\t\t\t\t FROM writs w\n\t\t\t\t\t\t\tINNER JOIN staff ls\n\t\t\t\t\t\t\t\tON(w.staff_id = ls.staff_id)\n\t\t\t\t\t\t\tINNER JOIN writ_salary_items wsi\n\t\t\t\t\t\t\t\t\t\tON w.staff_id = wsi.staff_id AND w.writ_id = wsi.writ_id AND\n\t\t\t\t\t\t\t\t\t\t\tw.writ_ver = wsi.writ_ver AND salary_item_type_id = 10364\n\n\t\t\t\t\t WHERE   w.staff_id = " . $writ_rec['staff_id'];
        $tmp2 = PdoDataAccess::runquery($qry);
        $qry = " select wsi.param8\n\t\t\t\t\t\tfrom writ_salary_items wsi\n\t\t\t\t\t\t\t\t\t\t \n                          where wsi.staff_id =" . $writ_rec['staff_id'] . " AND wsi.writ_id = " . $tmp2[0]['writ_id'] . " AND \n\t\t\t\t\t\t\t    wsi.writ_ver =" . $tmp2[0]['writ_ver'] . " AND  wsi.salary_item_type_id = 10364 ";
        $tmp = PdoDataAccess::runquery($qry);
        $writ_rec['E_base'] = !empty($tmp[0]['param8']) ? $tmp[0]['param8'] : 0;
    }
    if ($writ_rec['E_base'] == NULL || $writ_rec['E_base'] == 0) {
        if ($writ_rec["sex"] == 1 && $writ_rec["person_type"] == 2 && ($writ_rec["military_duration_day"] > 0 || $writ_rec["military_duration"] > 0)) {
            $totalDayWrt = DateModules::ymd_to_days($writ_rec["onduty_year"], $writ_rec["onduty_month"], $writ_rec["onduty_day"]);
            $totalDaySar = DateModules::ymd_to_days(0, $writ_rec["military_duration"], $writ_rec["military_duration_day"]);
            $resDay = $totalDayWrt - $totalDaySar;
            $Vyear = 0;
            $Vmonth = $Vday = 0;
            DateModules::day_to_ymd($resDay, $Vyear, $Vmonth, $Vday);
            $writ_rec['E_base'] = $Vyear;
            //echo $Vyear." ---- ".$baseRes[0]["IsarValue"]."--isa---".$otherPoint  ;  die() ;
        } else {
            $writ_rec['E_base'] = $writ_rec["onduty_year"];
        }
    }
    if ($writ_rec['ComputeGrade'] == NULL && ($writ_rec['person_type'] == HR_EMPLOYEE || $writ_rec['person_type'] == HR_CONTRACT)) {
        $qry = " select  wsi.param5 ComputeGrade\n\t\t\t\t\t\tfrom writs w inner join writ_salary_items wsi\n\t\t\t\t\t\t\t\t\t\t\ton w.staff_id = wsi.staff_id and\n\t\t\t\t\t\t\t\t\t\t\t\tw.writ_id = wsi.writ_id  and\n\t\t\t\t\t\t\t\t\t\t\t\tw.writ_ver = wsi.writ_ver and wsi.salary_item_type_id = 10364\n\n\t\t\t\t\t\t\t\t\t\twhere w.staff_id = " . $writ_rec["staff_id"] . " and \n           w.corrective_writ_id = " . $writ_rec["writ_id"] . " and\n\t\t\t\t\t\t\t\t\t\t\tw.corrective_writ_ver = " . $writ_rec["writ_ver"] . "\n\n\t\t\t\t\torder  by w.writ_id  , w.writ_id\n\n\t\t\t\t\tlimit 1";
        $tmp2 = PdoDataAccess::runquery($qry);
        $writ_rec['ComputeGrade'] = !empty($tmp2[0]['ComputeGrade']) ? $tmp2[0]['ComputeGrade'] : 0;
    }
    $GradeTitle = "";
    if ($writ_rec['ComputeGrade'] == 1) {
        $GradeTitle = "مقدماتی";
    } elseif ($writ_rec['ComputeGrade'] == 2) {
        $GradeTitle = "مهارتی";
    } elseif ($writ_rec['ComputeGrade'] == 3) {
        $GradeTitle = "3";
    } elseif ($writ_rec['ComputeGrade'] == 4) {
        $GradeTitle = "2";
    } elseif ($writ_rec['ComputeGrade'] == 5) {
        $GradeTitle = "1";
    }
    if ($writ_rec['marital_status'] == 3) {
        $writ_rec['marital_status_title'] = 'مجرد';
    } else {
        if ($writ_rec['marital_status'] == 4) {
            $writ_rec['marital_status_title'] = 'متاهل';
        }
    }
    $tags = array('<!--personel_no-->' => !empty($listPNO) && count($listPNO) > 1 ? $listPNO[1] . "-" . $listPNO[0] : $writ_rec['personel_no'], '<!--national_code-->' => $writ_rec['national_code'], '<!--ps_pfname-->' => $writ_rec['ps_pfname'], '<!--ps_plname-->' => $writ_rec['ps_plname'], '<!--ps_father_name-->' => $writ_rec['ps_father_name'], '<!--ps_idcard_no-->' => $writ_rec['ps_idcard_no'], '<!--si_ptitle-->' => $writ_rec['si_ptitle'], '<!--ci_ptitle-->' => $writ_rec['ci_ptitle'], '<!--issue_place-->' => $writ_rec['issue_place'], '<!--cb_ptitle-->' => $writ_rec['cb_ptitle'], '<!--ps_birth_place-->' => $writ_rec['ps_birth_place'], '<!--ps_birth_date-->' => DateModules::miladi_to_shamsi($writ_rec['ps_birth_date']), '<!--education_level_title-->' => $education_level_title, '<!--sf_ptitle-->' => $writ_rec['sf_ptitle'], '<!--sbs_title-->' => $writ_rec['sbs_title'], '<!--p_post_no-->' => $writ_rec['p_post_no'], '<!--jc_title-->' => $writ_rec['jc_title'], '<!--jf_title-->' => $writ_rec['jf_title'], '<!--grup-->' => $grup, '<!--E_base-->' => $writ_rec['E_base'], '<!--S_base-->' => $writ_rec['S_base'], '<!--T_base-->' => $writ_rec['T_base'], '<!--I_base-->' => $writ_rec['I_base'], '<!--Total_base-->' => $writ_rec['E_base'] + $writ_rec['S_base'] + $writ_rec['T_base'] + $writ_rec['I_base'], '<!--grade-->' => $GradeTitle, '<!--cur_group-->' => $current_group, '<!--post_title-->' => $post_title, '<!--onduty-->' => $onduty, '<!--sw_ptitle-->' => $writ_rec['sw_ptitle'], '<!--cw_ptitle-->' => $writ_rec['cw_ptitle'], '<!--sit2_annual_inc_coef-->' => $sit2_annual_inc_coef, '<!--marital_status_title-->' => $writ_rec['marital_status'] == 3 ? 'مجرد' : $writ_rec['marital_status_title'], '<!--included_children_count-->' => $writ_rec['sex'] == 1 || $writ_rec['family_responsible'] == 1 ? $writ_rec['included_children_count'] : $writ_rec['children_count'], '<!--contract_start_date-->' => DateModules::miladi_to_shamsi($writ_rec['contract_start_date']), '<!--contract_end_date-->' => DateModules::miladi_to_shamsi($writ_rec['contract_end_date']), '<!--ref_letter_no-->' => $writ_rec['ref_letter_no'], '<!--ref_letter_date-->' => DateModules::miladi_to_shamsi($writ_rec['ref_letter_date']), '<!--writ_type-->' => $writ_rec['writ_type'], '<!--description-->' => nl2br($writ_rec['description']), '<!--sum-->' => CurrencyModulesclass::toCurrency($sum), '<!--sum_str-->' => CurrencyModulesclass::CurrencyToString($sum), '<!--writ_signature_post_owner-->' => $writ_rec['writ_signature_post_owner'], '<!--writ_signature_post_title-->' => $writ_rec['writ_signature_post_title'], '<!--execute_date-->' => DateModules::miladi_to_shamsi($writ_rec['execute_date']), '<!--send_letter_no-->' => $writ_rec['send_letter_no'], '<!--issue_date-->' => DateModules::miladi_to_shamsi($writ_rec['issue_date']), '<!--ref_letter_no-->' => $writ_rec['ref_letter_no'], '<!--ref_letter_date-->' => DateModules::miladi_to_shamsi($writ_rec['ref_letter_date']), '<!--SALARY_ITEMS-->' => $salary_items, '<!--org_unit_title-->' => $org_unit_title, '<!--devotion_type-->' => $devotion_type, '<!--o_ptitle-->' => $writ_rec['ou_ptitle'], '<!--military-->' => $writ_rec['military'], '<!--MilitaryD-->' => $MilitaryD, '<!--sf_title-->' => $writ_rec['sf_title'], '<!--sbs_title-->' => $writ_rec['sbs_title'], '<!--snc_level-->' => $writ_rec['snc_level'], '<!--edu_c_ptitle-->' => $edu_c_ptitle, '<!--edu_u_ptitle-->' => $edu_u_ptitle, '<!--edu_doc_date-->' => $edu_doc_date, '<!--base-->' => $writ_rec['base'], '<!--worktime-->' => $writ_rec['worktime'], '<!--emp_st-->' => $writ_rec['person_type'] == 2 && ($writ_rec['emp_st'] == 3 || $writ_rec['emp_st'] == 4) ? str_replace('رسمی قطعی', 'رسمي', $writ_rec['emp_st']) : $writ_rec['emp_st'], '<!--org_sub_unit_type-->' => $org_sub_unit_type, '<!--os_ptitle-->' => $os_ptitle, '<!--full_title-->' => $full_title, '<!--gnd-->' => $writ_rec['gnd'] == "1" ? "مرد" : "زن", '<!--professor_post_type-->' => $professor_post_type, '<!--writ_title-->' => $writ_title, '<!--wst_title-->' => $writ_rec['wst_title'], '<!--staff_id-->' => $writ_rec['staff_id'], '<!--work_start_date-->' => DateModules::miladi_to_shamsi($writ_rec['work_start_date']), '<!--job_id-->' => $writ_rec['job_id'], '<!--j_title-->' => $writ_rec['j_title'], '<!--job_group-->' => $writ_rec['job_group'], '<!--contact_title-->' => $contact_title, '<!--worker_salary_item1_title-->' => $worker_salary_item1_title, '<!--worker_salary_item1_value-->' => $worker_salary_item1_value, '<!--worker_salary_item2_title-->' => $worker_salary_item2_title, '<!--worker_salary_item2_value-->' => $worker_salary_item2_value, '<!--WORKER_OTHER_SALARY_ITEMS-->' => $worker_other_salary_items, '<--worker_base_salary-->' => $worker_base_salary, '<!--sisIMAGEPATH-->' => "", '<!--exe_date_title-->' => $exe_date_title, '<!--notes-->' => $writ_rec["notes"], '<!--military_from_date-->' => DateModules::miladi_to_shamsi($writ_rec["military_from_date"]), '<!--military_to_date-->' => DateModules::miladi_to_shamsi($writ_rec["military_to_date"]), '<cr>' => '', '</cr>' => '', '<ncr>' => '', '</ncr>' => '', '<tlm>' => '', '</tlm>' => '', '<ntlm>' => '', '</ntlm>' => '', '<sts>' => '', '</nsts>' => '', '<cnt>' => '', '</cnt>' => '', '<ncnt>' => '', '</ncnt>' => '');
    if (is_array($emp_sal_items)) {
        $tags = array_merge($emp_sal_items, $tags);
    }
    // مشخص كردن فايل template مربوط به حكم
    $content .= file_get_contents("PrintWritTemplates/" . $template_file);
    //حذف قسمتهاي مربوط به حكم اصلاحي از حكم غير اصلاحي و برعكس
    $rgEx = "";
    $sep = "";
    if ($writ_rec['corrective']) {
        $rgEx .= $sep . "<ncr>|<\\/ncr>";
        $sep = "|";
    } else {
        $rgEx .= $sep . "<cr>|<\\/cr>";
        $sep = "|";
    }
    if (!$writ_rec['time_limited']) {
        $rgEx .= $sep . "<tlm>|<\\/tlm>";
        $sep = "|";
    } else {
        $rgEx .= $sep . "<ntlm>|<\\/ntlm>";
        $sep = "|";
    }
    if (!$writ_rec['req_staff_signature']) {
        $rgEx .= $sep . "<sts>|<\\/sts>";
        $sep = "|";
    } else {
        $rgEx .= $sep . "<nsts>|<\\/nsts>";
        $sep = "|";
    }
    if ($writ_rec["person_type"] == HR_CONTRACT) {
        /*if($writ_rec["sex"] == 2)
        		{
        			$rgEx .= $sep . "<children>|<\/children>";
        			$sep = "|";
        		}*/
        if (in_array($writ_rec['military_type'], array(2, 11, 13, 15, 16))) {
            $rgEx .= $sep . "<militaryDate>|<\\/militaryDate>";
            $sep = "|";
        }
    }
    $parts = "";
    if (preg_match("/(.{$rgEx}.)/", $content)) {
        $parts = preg_split('/(' . $rgEx . ')/', $content);
    }
    if ($parts) {
        $content = "";
        for ($i = 0; $i < count($parts); $i++) {
            if ($i % 2 == 0) {
                $content .= $parts[$i];
            }
        }
    }
    $content = str_replace(array_keys($tags), array_values($tags), $content);
    return $content;
}
Exemplo n.º 5
0
 /**
  * ط§ط·ظ„ط§ط¹ط§طھ ظ…ط±ط¨ظˆط· ط¨ظ‡ ط¢ط®ط±غŒظ† ط­ع©ظ… ظپط±ط¯ ط±ط§ ط¯ط± ط§ط·ظ„ط§ط¹ط§طھ ظپط±ط¯
  * (staff ط¬ط¯ظˆظ„) 
  * ظ‚ط±ط§ط± ظ…غŒ ط¯ظ‡ط¯
  *
  * @param string $staff_id
  * 
  */
 public static function SetStaffLastWrit($staff_id)
 {
     $lastWritObj = manage_writ::GetLastWrit($staff_id);
     /*@var $lastWritObj manage_writ*/
     $staffObj = new manage_staff();
     if (!empty($lastWritObj->writ_id)) {
         $staffObj->staff_id = $staff_id;
         $staffObj->last_writ_id = $lastWritObj->writ_id;
         $staffObj->last_writ_ver = $lastWritObj->writ_ver;
         $staffObj->post_id = $lastWritObj->post_id;
         $staffObj->ouid = $lastWritObj->ouid;
         return $staffObj->EditStaff();
     } else {
         $staffObj->staff_id = $staff_id;
         $staffObj->last_writ_id = PDONULL;
         $staffObj->last_writ_ver = PDONULL;
         $staffObj->post_id = PDONULL;
         $staffObj->ouid = PDONULL;
         $lastWritObj->cost_center_id = PDONULL;
         return $staffObj->EditStaff();
     }
 }
Exemplo n.º 6
0
<?php

//---------------------------
// programmer:	Jafarkhani
// create Date:	88.07
//---------------------------
require_once '../../../header.inc.php';
require_once '../class/writ.class.php';
require_once inc_dataReader;
manage_writ::DRP_writType_writSubType(&$writTypes, &$subwritTypes, "writ_type_id", "writ_subtype_id");
?>
<html>
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
	<?php 
jsConfig::initialExt();
jsConfig::grid(true, false, true);
jsConfig::date();
?>
	<script type="text/javascript">
	Ext.onReady(function(){
	
		var personStore = <?php 
echo dataReader::MakeStoreObject("../../persons/data/person.data.php?task=searchPerson", "'PersonID','pfname','plname','unit_name','person_type','staff_id'");
?>
;
		
		new Ext.form.ComboBox({
			id: 'PID',
			hiddenName:'staff_id',
			store: personStore,
Exemplo n.º 7
0
//---------------------------
require_once "../data/writ.data.php";
require_once '../../persons/class/person.class.php';
require_once inc_dataGrid;
require_once inc_manage_unit;
$FacilID = isset($_POST["FacilID"]) ? $_POST["FacilID"] : "";
//________________  GET ACCESS  _________________
$accessObj = new ModuleAccess($FacilID, "", Deputy, Module_writ);
$item_accessObj = new ModuleAccess($FacilID, 1, Deputy, Module_writ);
$accesscostcenterObj = new ModuleAccess($FacilID, SubModule_cost_center_id, Deputy, Module_writ);
//-----------------------------------------------
$writ_id = $_REQUEST["WID"];
$staff_id = $_REQUEST["STID"];
if (!empty($_REQUEST["WID"])) {
    $writver = isset($_REQUEST["WVER"]) ? $_REQUEST["WVER"] : "";
    $objWrt = new manage_writ($writ_id, $writver, $staff_id);
    $writver = $objWrt->writ_ver;
    $where = " w.writ_id = :WID AND w.writ_ver = :WVER AND w.staff_id = :STID";
    $whereParam = array(":WID" => $writ_id, ":WVER" => $writver, ":STID" => $staff_id);
    $FullWrt = manage_writ::GetWritInfo($where, $whereParam);
    if (count($FullWrt) == 0) {
        $FullWrt = NULL;
    }
}
//............................................
if ($objWrt->corrective && $objWrt->history_only != 0) {
    $is_new_corrective = true;
} else {
    $is_new_corrective = false;
}
//............................................