function Remove($All = "")
 {
     $query = " select * from evaluation_lists where list_id = " . $this->list_id . " and doc_state = 3 ";
     $tmp2 = parent::runquery($query);
     if (count($tmp2) > 0) {
         parent::PushException("این لیست تایید واحد مرکزی می باشد .");
         return false;
     } else {
         if ($All == "true") {
             $result = parent::delete("evaluation_list_items", "list_id=?", array($this->list_id));
         } else {
             $result = parent::delete("evaluation_list_items", "list_id =? and ListItemID=? ", array($this->list_id, $this->ListItemID));
         }
     }
     if (!$result) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $this->list_id;
     $daObj->SubObjectID = $this->ListItemID;
     $daObj->TableName = "evaluation_list_items";
     $daObj->execute();
     return true;
 }
예제 #2
0
 function Remove()
 {
     if ($this->list_type == 9) {
         $tblName = "mission_list_items";
     } else {
         $tblName = "pay_get_list_items";
     }
     $query = " select * from " . $tblName . " where list_id = " . $this->list_id;
     $tmp = parent::runquery($query);
     $query = " select * from pay_get_lists where list_id = " . $this->list_id . " and doc_state = 3 ";
     $tmp2 = parent::runquery($query);
     if (count($tmp) > 0) {
         parent::PushException("این لیست شامل مجموعه ای از افراد می باشد .");
         return false;
     } else {
         if (count($tmp2) > 0) {
             parent::PushException("این لیست تایید واحد مرکزی می باشد .");
             return false;
         } else {
             $result = parent::delete("pay_get_lists", "list_id=?", array($this->list_id));
         }
     }
     if (!$result) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $this->list_id;
     $daObj->TableName = "pay_get_lists";
     $daObj->execute();
     return true;
 }
예제 #3
0
 private function onBeforeDelete()
 {
     $res = parent::runquery(" select * from tax_table_items\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere tax_table_id = " . $this->tax_table_id);
     if (count($res) > 0) {
         parent::PushException("این رکورد دارای اطلاعات وابسته می باشد.");
         return false;
     }
     return true;
 }
예제 #4
0
function duty_year_month_day($staff_id = "", $personID = "", $toDate) {
    if ($staff_id == "" && $personID = "") {
        PdoDataAccess::PushException("يکي از دو پارامتر staff_id و PersonID بايد فرستاده شود");
        return false;                
    }
    $query = "select w.execute_date,
						w.contract_start_date ,
						w.contract_end_date ,
						w.person_type ,
						w.onduty_year ,
						w.onduty_month ,
						w.onduty_day ,
						w.annual_effect
			from writs as w";

    if ($personID != "")
        $query .= " join staff as s using(staff_id) where s.PersonID=" . $personID;

    else if ($staff_id != "")
        $query .= " where w.staff_id = $staff_id";

    $query .= " AND (w.history_only != " . HISTORY_ONLY . " OR w.history_only is null) AND w.execute_date <= '$toDate'
						order by w.execute_date DESC,w.writ_id DESC,w.writ_ver DESC
						limit 1";

    $temp = PdoDataAccess::runquery($query);

    if (count($temp) == 0)
        return array("year" => 0, "month" => 0, "day" => 0);

    $writ_rec = $temp[0];

    $temp_duration = 0;

    if (DateModules::CompareDate($toDate, $writ_rec['execute_date']) >= 0)
        $temp_duration = DateModules::GDateMinusGDate($toDate, $writ_rec['execute_date']);

    if ($writ_rec['annual_effect'] == HALF_COMPUTED)
        $temp_duration *= 0.5;
    else if ($writ_rec['annual_effect'] == DOUBLE_COMPUTED)
        $temp_duration *= 2;
    else if ($writ_rec['annual_effect'] == NOT_COMPUTED)
        $temp_duration = 0;

    $prev_writ_duration = DateModules::ymd_to_days($writ_rec['onduty_year'], $writ_rec['onduty_month'], $writ_rec['onduty_day']);

    $duration = $prev_writ_duration + $temp_duration;
    
       
    $return = array();
    DateModules::day_to_ymd($duration, $return['year'], $return['month'], $return['day']);

    return $return;
}
예제 #5
0
 private function onBeforeDelete()
 {
     $res = parent::runquery(" select * from tax_tables\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere tax_table_type_id = " . $this->tax_table_type_id);
     if (count($res) > 0) {
         parent::PushException(TAX_CAN_NOT_DELETE);
         return false;
     }
     $resstaff = parent::runquery(" select * from staff_tax_history\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere tax_table_type_id = " . $this->tax_table_type_id);
     if (count($resstaff) > 0) {
         parent::PushException(STAFF_TAX_CAN_NOT_DELETE);
         return false;
     }
     return true;
 }
예제 #6
0
 static function RemoveJobHistory($PersonID, $row_no)
 {
     $whereParams = array();
     $whereParams[":pid"] = $PersonID;
     $whereParams[":rowid"] = $row_no;
     if (PdoDataAccess::delete("PersonJobs", " PersonID=:pid and RowNO=:rowid", $whereParams) === false) {
         parent::PushException(ER_PERSON_DEP_DEL);
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->RelatedPersonID = $PersonID;
     $daObj->MainObjectID = $row_no;
     $daObj->TableName = "PersonJobs";
     $daObj->execute();
     return true;
 }
예제 #7
0
 static function Remove($pid)
 {
     $res = parent::runquery(" select count(*) cn from SubtractItemInfo where arrangement = " . $pid);
     if ($res[0]['cn'] > 0) {
         parent::PushException("حذف این رکورد امکان پذیر نمی باشد.");
         return false;
     }
     $result = parent::delete("priority", "PriorityID=:PID ", array(":PID" => $pid));
     if (!$result) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $pid;
     $daObj->TableName = "priority";
     $daObj->execute();
     return true;
 }
예제 #8
0
 static function Remove($bid)
 {
     $res = parent::runquery(" select count(*) cn from staff where bank_id = " . $bid);
     if ($res[0]['cn'] > 0) {
         parent::PushException("حذف این رکورد امکان پذیر نمی باشد.");
         return false;
     }
     $result = parent::delete("banks", "bank_id=:BID ", array(":BID" => $bid));
     if (!$result) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $bid;
     $daObj->TableName = "banks";
     $daObj->execute();
     return true;
 }
예제 #9
0
 static function Remove($sfid, $sbid)
 {
     $res = parent::runquery(" select count(*) cn from person_educations where sfid = " . $sfid . " and sbid = " . $sbid);
     if ($res[0]['cn'] > 0) {
         parent::PushException("این رشته در اطلاعات پایه افراد ثبت شده است به همین دلیل حذف امکان پذیر نمی باشد .");
         return false;
     }
     $result = parent::delete("study_branchs", "sfid=:sfid and sbid=:sbid", array(":sfid" => $sfid, ":sbid" => $sbid));
     if ($result === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $sfid;
     $daObj->SubObjectID = $sbid;
     $daObj->TableName = "study_branchs";
     $daObj->execute();
     return true;
 }
예제 #10
0
 static function Remove($uid, $cid)
 {
     $res = parent::runquery(" select count(*) cn from person_educations where university_id = " . $uid . " and country_id =" . $cid);
     if ($res[0]['cn'] > 0) {
         parent::PushException("حذف این رکورد به علت استفاده در اطلاعات پرسنل امکان پذیر نمی باشد.");
         return false;
     }
     $result = parent::delete("universities", "university_id=:UID and  country_id = :CID ", array(":UID" => $uid, ":CID" => $cid));
     if (!$result) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $uid;
     $daObj->SubObjectID = $cid;
     $daObj->TableName = "universities";
     $daObj->execute();
     return true;
 }
예제 #11
0
 static function Remove($CostID)
 {
     $query = " select count(*) cn \r\n\t\t\t\tfrom writs \r\n\t\t\t\t    where  cost_center_id = " . $CostID;
     $res = parent::runquery($query);
     if ($res[0]['cn'] > 0) {
         parent::PushException("این مرکز هزینه در احکام ثبت گردیده است لذا حذف امکان پذیر نمی باشد.");
         return false;
     }
     $result = parent::delete("cost_centers", "cost_center_id=:CID ", array(":CID" => $CostID));
     if ($result === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $CostID;
     $daObj->TableName = "cost_centers";
     $daObj->execute();
     return true;
 }
 function Add()
 {
     $query = " select * from CostCenterException where SalaryItemTypeID= " . $this->SalaryItemTypeID . " and \r\n                                                               PersonType = " . $this->PersonType . " and CostCenterID = " . $this->CostCenterID;
     $res = parent::runquery($query);
     if (count($res) > 0) {
         parent::PushException(IS_AVAILABLE);
         return false;
     }
     $return = parent::insert("CostCenterException", $this);
     if ($return === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_add;
     $daObj->MainObjectID = $this->SalaryItemTypeID;
     $daObj->SubObjectID = $this->PersonType;
     $daObj->TableName = "CostCenterException";
     $daObj->execute();
     return true;
 }
예제 #13
0
 function Add()
 {
     $query = " select * \r\n\t\t\t\t    from SubtractItemInfo \r\n\t\t\t\t\twhere SalaryItemTypeID= " . $this->SalaryItemTypeID . " and PersonType = " . $this->PersonType . " and \r\n\t\t\t\t\t    ( ToDate is  Null OR ToDate = '0000-00-00' )";
     $res = parent::runquery($query);
     if (count($res) > 0) {
         parent::PushException(strtr(IS_AVAILABLE, array("%0%" => $res[0]["arrangement"])));
         return false;
     }
     $return = parent::insert("SubtractItemInfo", $this);
     if ($return === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_add;
     $daObj->MainObjectID = $this->SalaryItemTypeID;
     $daObj->SubObjectID = $this->PersonType;
     $daObj->TableName = "SubtractItemInfo";
     $daObj->execute();
     return true;
 }
예제 #14
0
 private function date_overlap($PID)
 {
     $whereParam = array();
     $whereParam[":pid"] = $PID;
     $query = "select  count(*) cn\n\t\t\t\t\t\t\tfrom staff_tax_history sth inner join staff s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ton sth.staff_id = s.staff_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   inner join persons p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ton s.personid = p.personid\n\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\t\t  p.personid =:pid  and payed_tax_value is null  and ( sth.end_date is null or sth.end_date = '0000-00-00' )\n                                  ";
     $temp = PdoDataAccess::runquery($query, $whereParam);
     if ($temp[0][0] > 0 && $this->tax_history_id == null) {
         parent::PushException("لطفا ابتدا تاریخ انتهای رکورد قبل را پر نمایید.");
         return false;
     }
     $query = "\tselect count(*)\n\t\t\t\t\t\t\tfrom staff_tax_history sth inner join staff s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ton sth.staff_id = s.staff_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   inner join persons p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ton s.personid = p.personid\n\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\t\t((sth.start_date <=:fdate AND sth.end_date>=:fdate) OR (sth.start_date>=:fdate AND sth.start_date <=:tdate)) AND\n\t\t\t\t\t\t\t\t\t\t\t  p.personid =:pid  ";
     $whereParam[":fdate"] = str_replace('/', '-', DateModules::shamsi_to_miladi($this->start_date));
     $whereParam[":tdate"] = str_replace('/', '-', DateModules::shamsi_to_miladi($this->end_date));
     if ($this->tax_history_id) {
         $query .= " and tax_history_id  != :ihid ";
         $whereParam[":ihid"] = $this->tax_history_id;
     }
     $temp = PdoDataAccess::runquery($query, $whereParam);
     if ($temp[0][0] != 0) {
         parent::PushException(ER_DATE_RANGE_OVERLAP);
         return false;
     }
     return true;
 }
예제 #15
0
 private function date_overlap()
 {
     $query = "select count(*) from salary_params where \r\n\t\t\t((from_date<=:fdate AND to_date>=:fdate) OR (from_date>=:fdate AND from_date <=:tdate)) \r\n\t\t\tAND person_type=:hr AND param_type=:ptype";
     $whereParam = array();
     $whereParam[":fdate"] = $this->from_date;
     $whereParam[":tdate"] = $this->to_date;
     $whereParam[":hr"] = $this->person_type;
     $whereParam[":ptype"] = $this->param_type;
     if (isset($this->param_id)) {
         $query .= " AND param_id<>:pid";
         $whereParam[":pid"] = $this->param_id;
     }
     if (isset($this->dim1_id)) {
         $query .= " AND dim1_id = :d1id";
         $whereParam[":d1id"] = $this->dim1_id;
     }
     if (isset($this->dim2_id)) {
         $query .= " AND dim2_id = :d2id";
         $whereParam[":d2id"] = $this->dim2_id;
     }
     if (isset($this->dim3_id)) {
         $query .= " AND dim3_id = :d3id";
         $whereParam[":d3id"] = $this->dim3_id;
     }
     $temp = PdoDataAccess::runquery($query, $whereParam);
     if ($temp[0][0] != 0) {
         parent::PushException(ER_DATE_RANGE_OVERLAP);
         return true;
     }
     return false;
 }
예제 #16
0
function compute_salary_item1_01($writ_rec)
{
    //param1 : پايه
    //param2 : عدد مبنا
    //param3 : ضريب حقوق
    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['execute_date'] < str_replace("/", "-", DateModules::shamsi_to_miladi('1389-07-01'))) {
        $base = 1;
    } else {
        $base = $writ_rec['base'];
    }
    $professor_base_number = Get_professor_base_number($writ_rec['science_level']);
    $salary_coef = manage_salary_params::get_salaryParam_value("", HR_PROFESSOR, SPT_SALARY_COEF, $writ_rec['execute_date']);
    if (!$salary_coef) {
        PdoDataAccess::PushException(SALARY_COEF_NOT_FOUND);
        return false;
    }
    //$this->param1 = $base;
    //$this->param2 = $professor_base_number;
    //$this->param3 = $salary_coef;
    $value = $salary_coef * ($professor_base_number + 5 * $base);
    //echo  $value ." value ----<br> ";
    if (!($value > 0)) {
        parent::PushException(BASE_SALARY_CALC_ERR);
        return false;
    }
    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['execute_date'] < '2009-09-23') {
        $value *= 0.95;
    }
    //echo  $value ." value ----<br> "; die();
    return $value;
}
예제 #17
0
 static function RemoveDependency($PersonID, $row_no)
 {
     $whereParams = array();
     $whereParams[":pid"] = $PersonID;
     $whereParams[":rowid"] = $row_no;
     if (parent::delete("HRM_person_dependents", " PersonID=:pid and row_no=:rowid", $whereParams) === false) {
         $error = implode("", parent::popExceptionDescription());
         if (strpos($error, "a foreign key constraint fails") !== false) {
             if (strpos($error, "person_dependent_supports") !== false) {
                 parent::PushException("این وابسته دارای سابقه کفالت بوده و قابل حذف نمی باشد.");
             } else {
                 parent::PushException("از این وابسته در جای دیگری استفاده شده و قابل حدف نمی باشد.");
             }
         } else {
             parent::PushException($error);
         }
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $row_no;
     $daObj->RelatedPersonType = 3;
     $daObj->RelatedPersonID = $PersonID;
     $daObj->TableName = "person_dependents";
     $daObj->execute();
     return true;
 }
 function check_to_run()
 {
     if ($this->backpay_recurrence > 1) {
         return true;
     }
     $tmp_rs = parent::runquery('SELECT * FROM payment_runs WHERE time_stamp >= :expireDate', array(":expireDate" => time() - $this->expire_time));
     //هيچ اجراي فعالي وجود ندارد
     if ($tmp_rs->recordCount() == 0) {
         parent::runquery('INSERT INTO payment_runs(time_stamp,uname) VALUES(?,?)', array(time(), $_SESSION["UserID"]));
         $this->run_id = parent::InsertID();
         return true;
     }
     parent::PushException(strstr(ER_CAN_NOT_RUN_PAYMENT_CALC, array("%0%" => $temp[0]["uname"], "%1%" => $this->expire_time)));
     return false;
 }
예제 #19
0
 /**
 این تابع آخرین وضعیت تحصیلی فرد را تا تاریخ ورودی بر می گرداند
 * *اگر رکورد آخرین سطح تحصیلی را می خواهید باید پارامتر تاریخ را ارسال نکنید
 *
 * @param int $PersonID
 * @param miladi date $date
 * @return record
 */
 static function GetEducationLevelByDate($PersonID, $date = "", $is_auto = "")
 {
     $where = "";
     $whereParam = array();
     $whereParam[":pid"] = $PersonID;
     if ($date != "") {
         $where = $date != "" ? " AND doc_date <= :date" : "";
         $whereParam[":date"] = $date;
     }
     $query = "select education_level as max_education_level,\n\t   \t\t\t\t\trow_no,\n\t   \t\t\t\t\tPersonID,\n\t   \t\t\t\t\tsfid,\n\t   \t\t\t\t\tsbid,\n\t\t\t\t\t\tdoc_date,\n\t   \t\t\t\t\tu.university_id,\n\t   \t\t\t\t\tburse,\n\t\t\t\t\t\tc.ptitle as countryTitle,\n\t\t\t\t\t\tu.ptitle as universityTitle\n\t   \t\t\tfrom HRM_person_educations pe\n\t\t\t\t\tLEFT OUTER JOIN HRM_countries c ON(pe.country_id = c.country_id)\n\t\t\t\t    LEFT OUTER JOIN HRM_universities u ON(pe.university_id = u.university_id AND pe.country_id = u.country_id)\n\t   \t\t\twhere PersonID = :pid {$where}\n\t   \t\t\torder by doc_date DESC\n\t   \t\t\tlimit 1";
     $temp = parent::runquery($query, $whereParam);
     if ((count($temp) == 0 || $temp[0]["max_education_level"] == "") && $is_auto) {
         parent::PushException(ERROR_PERSON_EDUCATIONS_NOT_SET);
         return false;
     } else {
         if (count($temp) == 0 || $temp[0]["max_education_level"] == "") {
             return 101;
         }
     }
     return $temp[0];
 }
 function Remove()
 {
     $query = " select s.staff_id\n\t\t\t\t\t\t\t\tfrom HRM_staff s inner join HRM_persons p on s.personid = p.personid and s.person_type = p.person_type\n\t\t\t\t\t\t\t\t\twhere s.staff_id = " . $this->staff_id;
     $temp = PdoDataAccess::runquery($query);
     if (count($temp) == 0) {
         parent::PushException("حذف این رکورد امکان پذیر نمی باشد.");
         return false;
     }
     $result = parent::delete("HRM_staff_include_history", " staff_id = :SID and include_history_id = :ID ", array(":SID" => $this->staff_id, ":ID" => $this->include_history_id));
     if ($result === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->RelatedPersonID = $this->staff_id;
     $daObj->RelatedPersonType = 3;
     $daObj->MainObjectID = $this->include_history_id;
     $daObj->TableName = "staff_include_history";
     $daObj->execute();
     return true;
 }
예제 #21
0
 function ActiveCode()
 {
     $dt = PdoDataAccess::runquery("select c2.* from ACC_CostCodes c1 \n\t\t\tjoin ACC_CostCodes c2 on(c2.IsActive='YES' AND c1.CostID<>c2.CostID AND c1.CostCode=c2.CostCode)\n\t\t\twhere c1.CostID=?", array($this->CostID));
     if (count($dt) > 0) {
         parent::PushException("کد حساب تکراری است");
         return false;
     }
     $this->IsActive = "YES";
     if (!parent::update("ACC_CostCodes", $this, "CostID=:c", array(":c" => $this->CostID))) {
         return false;
     }
     $auditObj = new DataAudit();
     $auditObj->ActionType = DataAudit::Action_update;
     $auditObj->MainObjectID = $this->CostID;
     $auditObj->TableName = "ACC_CostCodes";
     $auditObj->execute();
 }
예제 #22
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;
     }
 }
예제 #23
0
 static function get_devotions_last_coefs($staff_id, $gdate = "", $pt = "")
 {
     if ($gdate != "") {
         $w = "and pd.from_date <= '{$gdate}' ";
     } else {
         $w = "";
     }
     if ($pt != HR_WORKER) {
         $est = " and enlisted = 1 ";
     } else {
         $est = " ";
     }
     //_________________________________________________
     // جمع اوري سوابق ايثارگري يك شخص خاص
     $query = "SELECT s.staff_id,\n\t\t\t\t\tSUM(CASE WHEN pd.devotion_type=" . DEVOTION_TYPE_FIGHTER . " {$est}\n\t                     THEN if((pd.from_date <= '1988-08-20' and to_date <= '1988-08-20'),amount ,\n\t\t\t\t\t\t\t\tif(( pd.from_date <= '1988-08-20' and to_date >= '1988-08-20'),\n\t\t\t\t\t\t\t\t\tdatediff('1988-08-20',pd.from_date ),0 )) END) fighter,\n\t\t\t\t\tSUM(CASE WHEN pd.devotion_type=" . DEVOTION_TYPE_PRISONER . " THEN amount ELSE 0 END) prisoner,\n\t\t\t\t\tMAX(CASE WHEN pd.devotion_type=" . DEVOTION_TYPE_WOUNDED . " THEN amount ELSE 0 END) wounded\n\t\t\t\t FROM staff s\n\t\t\t\t \tINNER JOIN persons p ON (p.personID = s.personID)\n\t\t\t\t \tINNER JOIN person_devotions pd ON (pd.personID = p.personID)\n\t\t\t\t WHERE s.staff_id = {$staff_id} {$w}\n\t\t\t\t GROUP BY pd.PersonID";
     $dt = parent::runquery($query);
     if (count($dt) == 0) {
         parent::PushException(WRIT_SALARY_ITEM_NOT_FOUND);
         return false;
     }
     $devotion_coefs['fighter'] = $dt[0]['fighter'];
     $devotion_coefs['prisoner'] = $dt[0]['prisoner'];
     $devotion_coefs['wounded'] = $dt[0]['wounded'];
     return $devotion_coefs;
 }
예제 #24
0
 /**
  *ع†ع© ظ…غŒ ع©ظ†ط¯ ط§غŒط§ ط§غŒظ† ط´ظ…ط§ط±ظ‡ ط´ظ†ط§ط³ط§غŒغŒ ظˆط¬ظˆط¯ ط¯ط§ط±ط¯ غŒط§ ط®غŒط±طں 
  * */
 static function check_exist_staff_id($staff_id)
 {
     $query = " SELECT   staff_id\n    \t\t\t     FROM     staff\n\t\t\t\t       WHERE    staff_id = {$staff_id} ";
     $tmp = PdoDataAccess::runquery($query);
     if (count($tmp) != 0) {
         return true;
     } else {
         parent::PushException("ط´ط®طµ ط¨ط§ ط´ظ…ط§ط±ظ‡ ط´ظ†ط§ط³ط§غŒغŒ" . $staff_id . "ظˆط¬ظˆط¯ ظ†ط¯ط§ط±ط¯.");
         return false;
     }
 }
예제 #25
0
 static function Remove($staff_id, $row_no)
 {
     $whereParams = array();
     $whereParams[":staff_id"] = $staff_id;
     $whereParams[":rowid"] = $row_no;
     if (parent::delete("professor_exe_posts", " staff_id=:staff_id and row_no=:rowid", $whereParams) === false) {
         parent::PushException(ER_PERSON_DEP_DEL);
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->RelatedPersonType = DataAudit::PersonType_staff;
     $daObj->RelatedPersonID = $staff_id;
     $daObj->MainObjectID = $staff_id;
     $daObj->SubObjectID = $row_no;
     $daObj->TableName = "professor_exe_posts";
     $daObj->execute();
     return true;
 }
예제 #26
0
 static function is_valid($post_id, $date, $staff_id)
 {
     $query = " select * from position where post_id =" . $post_id;
     $temp = PdoDataAccess::runquery($query);
     if (count($temp) == 0) {
         parent::PushException(POST_IS_NOT_VALID);
         return false;
     }
     //پست در اختيار فرد ديگري است
     if ($temp[0]["staff_id"] != $staff_id && $temp[0]["staff_id"] != NULL) {
         parent::PushException(str_replace("%0%", $temp[0]['staff_id'], POST_HAS_DETERMINED_ERR));
         return false;
     }
     // پست در تاريخ اجراي حكم معتبر است
     if (($temp[0]['validity_start'] <= $date || $temp[0]['validity_start'] == "" || $temp[0]['validity_start'] == "0000-00-00") && ($temp[0]['validity_end'] >= $date || $temp[0]['validity_end'] == "" || $temp[0]['validity_end'] == "0000-00-00")) {
         return true;
     } else {
         parent::PushException(POST_EXPIRE);
         return false;
     }
 }
예제 #27
0
	/**
	  مزد سنوات
	 */
	private function compute_salary_item5_39($writ_rec) {

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

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

		//param1 : افزايش سنواتي سال قبل
		//param2 : نرخ سنوات امسال
		//param3 : تعداد روزهاي ماه

		$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";
		$one_year_ago_last_day_writ = $one_year_ago . "-12-29";
		$Gone_year_ago_first_day = DateModules::shamsi_to_miladi($one_year_ago_first_day);
		$Gone_year_ago_last_day = DateModules::shamsi_to_miladi($one_year_ago_last_day_writ);

		if ($this_writ_year >= '1389') {
			//آخرين حکم قبل از سال شخص را استخراج مي کند.
			$prior_writ_rec = manage_writ::get_last_writ_by_date($writ_rec['staff_id'],$Gone_year_ago_last_day); //'2013-02-18'
			
			
			
			//در بدو استخدام سنوات به شخص تعلق نمي گيرد.
			if ($prior_writ_rec->writ_id == "")
				return 0;
			//end
		}
		
		$annual_rate = manage_salary_params::get_salaryParam_value("", $writ_rec['person_type'].",101", SPT_GROUP1_ANNUAL_RATE, $writ_rec['execute_date'], $writ_rec['job_group']);
		if (!(0 < $annual_rate)) {
			parent::PushException(UNKNOWN_GROUP1_ANNUAL_RATE);
			return false;
		}

		if ($this_writ_year >= '1389') {
			if ($prior_writ_rec->writ_id != "")
				$prior_annual_inc = manage_writ_item::get_writSalaryItem_value($prior_writ_rec->writ_id, $prior_writ_rec->writ_ver, $prior_writ_rec->staff_id, SIT_STAFF_DEFINED_ANNUAL_INC);

			else
				$prior_annual_inc = 0;
		}
		else {
			$prior_annual_inc = 0;
		}
		
	  

		$work_start_date = $writ_rec["work_start_date"];
		if ($this_writ_year >= '1389')
			$year_work_days = manage_writ::compute_year_work_days($Gone_year_ago_first_day, $Gone_year_ago_last_day, $writ_rec['staff_id']);
		else
			$year_work_days = manage_writ::compute_year_work_days($work_start_date, $Gone_year_ago_last_day, $writ_rec['staff_id']);

		if ($year_work_days > 365 &&
				$writ_rec['person_type'] == HR_CONTRACT) {

			$year_work_days = 360;
		}

		$Day_Year = ( $writ_rec['person_type'] == HR_CONTRACT ) ? 360 : 365;

		if ($writ_rec['person_type'] == HR_CONTRACT)
			$month_duration = 30;
		else if ($writ_rec['person_type'] == HR_WORKER)
			$month_duration = $MONTH_DAY_COUNT;

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


		$value = $prior_annual_inc + (($annual_rate * $month_duration) * $year_work_days / $Day_Year );

		return $value;
	}
예제 #28
0
 private function date_overlap()
 {
     if ($this->tax_table_id == null) {
         $W = "";
     } else {
         $W = " AND  tax_table_id != " . $this->tax_table_id;
     }
     $query = "\tselect count(*)\r\n\t\t\t\t\t\t\tfrom tax_tables\r\n\t\t\t\t\t\t\t\t\twhere\r\n\t\t\t\t\t\t\t\t\t\t\t((from_date <=:fdate AND to_date>=:fdate) OR (from_date>=:fdate AND from_date <=:tdate)) AND\r\n\t\t\t\t\t\t\t\t\t\t\t  tax_table_type_id=:ttid " . $W;
     $whereParam = array();
     $whereParam[":fdate"] = DateModules::shamsi_to_miladi($this->from_date);
     $whereParam[":tdate"] = DateModules::shamsi_to_miladi($this->to_date);
     $whereParam[":ttid"] = $this->tax_table_type_id;
     $temp = PdoDataAccess::runquery($query, $whereParam);
     if ($temp[0][0] != 0) {
         parent::PushException(ER_DATE_RANGE_OVERLAP);
         return false;
     }
     return true;
 }
예제 #29
0
 function EditPerson()
 {
     $whereParams = array();
     $whereParams[":pid"] = $this->PersonID;
     //........بررسی اعتبار کد ملی فرد .........
     if (!self::IsValidNID($this->national_code)) {
         parent::PushException("کد ملی فرد معتبر نمی باشد.");
         return false;
     }
     if (PdoDataAccess::update("HRM_persons", $this, " PersonID=:pid", $whereParams) === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_update;
     $daObj->MainObjectID = $this->PersonID;
     $daObj->TableName = "HRM_persons";
     $daObj->execute();
     return true;
 }