예제 #1
0
 function AddDependency()
 {
     $this->row_no = manage_person_dependency::LastID($this->PersonID) + 1;
     if (parent::insert("HRM_person_dependents", $this) === false) {
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_add;
     $daObj->MainObjectID = $this->row_no;
     $daObj->RelatedPersonType = 5;
     $daObj->RelatedPersonID = $this->PersonID;
     $daObj->TableName = "HRM_person_dependents";
     $daObj->execute();
     return true;
 }
예제 #2
0
 static function RemovePerson($PersonID)
 {
     $pdo = PdoDataAccess::getPdoObject();
     if ($pdo->beginTransaction()) {
         $whereParam = array(":PID" => $PersonID);
         require_once 'dependent.class.php';
         if (count(manage_person_dependency::GetAllDependency("PersonID=:PID", $whereParam)) != 0) {
             return "فرد مورد نظر دارای وابستگی می باشد و قابل حذف نیست";
         }
         $return = manage_staff::remove($PersonID, "", $pdo);
         if (!$return) {
             $pdo->rollBack();
             return false;
         }
         $return = PdoDataAccess::delete("HRM_persons", "PersonID=:PID", $whereParam, $pdo);
         if (!$return) {
             $pdo->rollBack();
             return false;
         }
         $pdo->commit();
         $daObj = new DataAudit();
         $daObj->ActionType = DataAudit::Action_delete;
         $daObj->MainObjectID = $PersonID;
         $daObj->TableName = "persons";
         $daObj->execute();
         return true;
     } else {
         return false;
     }
     return true;
 }
예제 #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;
     }
 }
예제 #4
0
function DelDep()
{
    $return = manage_person_dependency::RemoveDependency($_POST['PersonID'], $_POST['row_no']);
    Response::createObjectiveResponse($return, !$return ? ExceptionHandler::popExceptionDescription() : "");
    die;
}