Exemplo n.º 1
0
function GroupCancelWrit()
{
    ini_set('max_execution_time', 1000);
    //300 seconds = 5 minutes
    ini_set("memory_limit", '500M');
    $where = "s.person_type=" . $_POST["person_type"];
    $whereParams = array();
    //------------------------ Make Where Clause ----------------------
    if (!empty($_REQUEST["ouid"])) {
        $where .= " AND ( o.ouid = :ouid OR o.parent_path LIKE '%,:ouid,%' OR  o.parent_path LIKE '%:ouid,%' OR o.parent_path LIKE '%,:ouid%' ) ";
        $whereParams[":ouid"] = $_REQUEST["ouid"];
    }
    if (!empty($_POST["from_PersonID"])) {
        $where .= " AND p.PersonID >= :f_personid";
        $whereParams[":f_personid"] = $_POST["from_PersonID"];
    }
    if (!empty($_POST["to_PersonID"])) {
        $where .= " AND p.PersonID <= :t_personid";
        $whereParams[":t_personid"] = $_POST["to_PersonID"];
    }
    if (!empty($_POST["from_issue_date"])) {
        $where .= " AND issue_date <= :f_issue_date";
        $whereParams[":f_issue_date"] = $_POST["from_issue_date"];
    }
    if (!empty($_POST["to_issue_date"])) {
        $where .= " AND issue_date >= :t_issue_date";
        $whereParams[":t_issue_date"] = $_POST["to_issue_date"];
    }
    if (!empty($_POST["execute_date"])) {
        $execute_date = DateModules::Shamsi_to_Miladi($_POST["execute_date"]);
        $where .= " AND execute_date = :exe_date";
        $whereParams[":exe_date"] = $execute_date;
    }
    if (!empty($_POST["writ_type_id"])) {
        $where .= " AND w.writ_type_id = :writ_type_id";
        $whereParams[":writ_type_id"] = $_POST["writ_type_id"];
    }
    if (!empty($_POST["writ_subtype_id"])) {
        $where .= " AND w.writ_subtype_id = :writ_subtype_id";
        $whereParams[":writ_subtype_id"] = $_POST["writ_subtype_id"];
    }
    //-----------------------------------------------------------------
    /*$where .= " AND bf.MasterID in (1,2) AND 
      if( tbl1.personid is not null , bf.MasterID in (1) , ( bf.MasterID in (1,2) and  tbl1.personid is null  ) )" ; */
    $query = "SELECT s.staff_id,\n\t\t    \t   w.writ_id,\n\t\t           w.writ_ver,\n\t\t           w.writ_type_id,\n\t\t           w.writ_subtype_id,\n\t\t           w.issue_date,\n\t\t           w.execute_date,\n\t\t           p.pfname,\n\t\t\t   p.plname\n\t\t\t  \n\t\n\t\t    FROM writs w\n\t\t    \tJOIN org_new_units o ON(w.ouid=o.ouid)\n\t\t\t\tJOIN staff s ON (s.staff_id=w.staff_id)\n\t\t\t\t\n                JOIN persons p ON(s.PersonID = p.PersonID and s.person_type=p.person_type)\t\t\t\t\n                \n\t\t    WHERE " . $where;
    /*inner join Basic_Info bf on(bf.TypeID=6 AND bf.InfoID=w.education_level)
    		left join (select personid
    			    from bases
    			    where BaseType in(4) AND
    
    				BaseStatus = 'NORMAL')  tbl1 
    				
    			on tbl1.personid = s.personid*/
    $staff_dt = PdoDataAccess::runquery($query, $whereParams);
    //echo PdoDataAccess::GetLatestQueryString() ; die() ;
    if (count($staff_dt) == 0) {
        echo "موارد انتخابی شما هیچ حکمی را برای ابطال شامل نمی شود.";
        die;
    }
    $log_obj = new manage_writ_group_cancel_log();
    $success_count = 0;
    $unsuccess_count = 0;
    for ($index = 0; $index < count($staff_dt); $index++) {
        /*if(manage_writ::IsUsed($staff_dt[$index]["writ_id"], $staff_dt[$index]["writ_ver"], $staff_dt[$index]["staff_id"]))
        		{
        			ExceptionHandler::PushException("از حکم در جای دیگری استفاده شده است.");
        			$log_obj->make_unsuccess_rows($staff_dt[$index], ExceptionHandler::GetExceptionsToString("<br>"));
        			$unsuccess_count++;
        		}*/
        if (manage_writ::get_writ_state($staff_dt[$index]["writ_id"], $staff_dt[$index]["writ_ver"], $staff_dt[$index]["staff_id"]) != WRIT_PERSONAL) {
            ExceptionHandler::PushException("این حکم منتقل شده است.");
            $log_obj->make_unsuccess_rows($staff_dt[$index]);
            $unsuccess_count++;
        } else {
            if (!manage_writ::RemoveWrit($staff_dt[$index]["writ_id"], $staff_dt[$index]["writ_ver"], $staff_dt[$index]["staff_id"])) {
                $log_obj->make_unsuccess_rows($staff_dt[$index]);
                $unsuccess_count++;
            } else {
                $log_obj->make_success_row($staff_dt[$index]);
                $success_count++;
            }
        }
        /*if($index == 0)
        		{
        			$log_obj->finalize();
        			echo $log_obj->make_result();
        			die();
        		}*/
    }
    $log_obj->finalize();
    echo $log_obj->make_result();
    die;
}
Exemplo n.º 2
0
 function prior_corrective_writ()
 {
     // echo $this->corrective."---"; die();
     if (!$this->corrective) {
         $query = " UPDATE writs\n                        SET history_only=0\n                             WHERE(writ_id=" . $this->writ_id . " AND  staff_id = " . $this->staff_id . " AND  writ_ver=" . ($this->writ_ver - 1) . " AND history_only = 1 ) ";
         parent::runquery($query);
         if (!manage_writ::RemoveWrit($this->writ_id, $this->writ_ver, $this->staff_id)) {
             return false;
         }
     } else {
         $this->corrective_writ_id = $this->writ_id;
         $this->corrective_writ_ver = $this->writ_ver;
         parent::runquery(" UPDATE writs\n                                    SET correct_completed=" . WRIT_CORRECTING . "\n                                        WHERE((corrective_writ_id=" . $this->corrective_writ_id . " AND corrective_writ_ver= " . $this->corrective_writ_ver . " ) OR\n                                              (writ_id= " . $this->corrective_writ_id . " AND writ_ver=" . $this->corrective_writ_ver . " ) AND staff_id = " . $this->staff_id . " )");
     }
     $query = " SELECT  writ_id ,\n                         writ_ver ,\n                         corrective ,\n                         staff_id\n                  FROM writs\n                  WHERE\n                        staff_id = {$this->staff_id} AND\n                        ((corrective_writ_id = {$this->corrective_writ_id} AND\n                          corrective_writ_ver = {$this->corrective_writ_ver} ) OR\n                        ( writ_id = {$this->corrective_writ_id} AND\n                          writ_ver = {$this->corrective_writ_ver} ) )\n                  ORDER BY corrective , execute_date DESC , writ_id DESC , writ_ver DESC ";
     $temp = parent::runquery($query);
     if (count($temp) > 0) {
         if ($temp[0]['corrective'] == 1) {
             parent::runquery("delete from writs where staff_id = " . $temp[0]['staff_id'] . " and writ_id =" . $temp[0]['writ_id'] . " and writ_ver = " . $temp[0]['writ_ver']);
             return 'Stop';
         } else {
             return $temp[0];
         }
     }
 }