function summary_doc_list() { $query = " DROP TABLE if EXISTS tmp_doc_writs "; PdoDataAccess::runquery($query); $query = " CREATE TABLE tmp_doc_writs\r\n (\r\n auto_id int(11) NOT NULL auto_increment,\r\n writ_id int(11) default NULL,\r\n writ_ver smallint(6) default NULL,\r\n staff_id int(11) default NULL,\r\n annual_effect smallint(1) default NULL,\r\n show_in_summary_doc smallint(1) default NULL,\r\n execute_date datetime NULL ,\r\n PRIMARY KEY (auto_id)\r\n )type=MYISAM AS\r\n SELECT\r\n w.writ_id ,\r\n w.writ_ver ,\r\n w.staff_id ,\r\n w.annual_effect ,\r\n wst.show_in_summary_doc ,\r\n w.execute_date\r\n FROM writs w\r\n INNER JOIN writ_subtypes wst\r\n ON w.writ_type_id = wst.writ_type_id AND\r\n w.writ_subtype_id = wst.writ_subtype_id AND\r\n w.person_type = wst.person_type\r\n WHERE\r\n (w.history_only=0 OR w.history_only IS NULL) AND\r\n w.person_type in(" . manage_access::getValidPersonTypes() . ")\r\n ORDER BY staff_id , execute_date , writ_id , writ_ver' "; PdoDataAccess::runquery($query); $query = "ALTER TABLE tmp_doc_writs ADD INDEX(writ_id,writ_ver)"; PdoDataAccess::runquery($query); $query = "ALTER TABLE tmp_doc_writs ADD INDEX(staff_id,execute_date,writ_id,writ_ver)"; PdoDataAccess::runquery($query); $query = " DELETE tmp_doc_writs sw1\r\n FROM tmp_doc_writs sw1\r\n INNER JOIN tmp_doc_writs sw2\r\n ON sw1.staff_id = sw2.staff_id AND\r\n sw1.execute_date = sw2.execute_date\r\n WHERE (sw1.writ_id > sw2.writ_id OR (sw1.writ_id = sw2.writ_id AND sw1.writ_ver > sw2.writ_ver))"; PdoDataAccess::runquery($query); $query = "DROP TABLE if EXISTS tmp_sum_doc_writs"; PdoDataAccess::runquery($query); $query = " CREATE TABLE tmp_sum_doc_writs\r\n (\r\n auto_id int(11) NOT NULL auto_increment,\r\n writ_id int(11) default NULL,\r\n writ_ver smallint(6) default NULL,\r\n staff_id int null,\r\n execute_date datetime null ,\r\n annual_effect smallint null ,\r\n show_in_summary_doc smallint null ,\r\n PRIMARY KEY (auto_id)\r\n )type=MYISAM AS\r\n SELECT w1.writ_id , w1.writ_ver , w1.staff_id , w1.execute_date execute_date , w1.annual_effect , w1.show_in_summary_doc\r\n FROM tmp_doc_writs w1\r\n LEFT OUTER JOIN tmp_doc_writs w0\r\n ON w1.auto_id - 1 = w0.auto_id AND w1.staff_id = w0.staff_id\r\n LEFT OUTER JOIN tmp_doc_writs w2\r\n ON w1.auto_id + 1 = w2.auto_id AND w1.staff_id = w2.staff_id\r\n WHERE ((w1.annual_effect <> w0.annual_effect OR w0.writ_id is null)OR(w1.show_in_summary_doc=1))\r\n ORDER by w1.staff_id "; PdoDataAccess::runquery($query); $query = "DROP TABLE IF EXISTS temp_writs"; PdoDataAccess::runquery($query); $query = " CREATE TABLE temp_writs TYPE=MyIsam AS\r\n SELECT wa.writ_type_id ,\r\n wa.writ_subtype_id ,\r\n wa.staff_id,\r\n wa.emp_mode,\r\n wa.annual_effect,\r\n wa.science_level,\r\n wa.execute_date,\r\n dw2.execute_date end_date ,\r\n wa.writ_id,\r\n wa.writ_ver\r\n FROM staff s\r\n INNER JOIN writs w\r\n ON w.writ_id = s.last_writ_id AND w.writ_ver = s.last_writ_ver AND w.staff_id = s.staff_id \r\n INNER JOIN writs wa\r\n ON wa.staff_id = s.staff_id\r\n INNER JOIN tmp_sum_doc_writs dw\r\n ON(dw.writ_id = wa.writ_id AND dw.writ_ver = wa.writ_ver)\r\n LEFT OUTER JOIN tmp_sum_doc_writs dw2\r\n ON(dw2.auto_id -1 = dw.auto_id and dw2.staff_id = dw.staff_id)\r\n WHERE (wa.history_only = 0 OR wa.history_only IS NULL) AND\r\n s.person_type in(" . manage_access::getValidPersonTypes() . ") AND\r\n (dw.annual_effect <> " . ANNUAL_NOT_CALC . " OR dw.show_in_summary_doc=1 OR dw2.auto_id IS NOT NULL) AND\r\n '.sisSession('__sisReportWhereClause') "; PdoDataAccess::runquery($query); $query = " ALTER TABLE temp_writs ADD INDEX(writ_id,writ_ver) "; PdoDataAccess::runquery($query); $query = " ALTER TABLE temp_writs ADD INDEX(staff_id,execute_date,writ_id,writ_ver) "; PdoDataAccess::runquery($query); $query = " DELETE temp_writs tw1\r\n FROM temp_writs tw1\r\n INNER JOIN temp_writs tw2\r\n ON tw1.staff_id = tw2.staff_id AND\r\n tw1.execute_date = tw2.execute_date\r\n WHERE (tw1.writ_id > tw2.writ_id OR (tw1.writ_id = tw2.writ_id AND tw1.writ_ver > tw2.writ_ver)) "; PdoDataAccess::runquery($query); $query = "DROP TABLE IF EXISTS temp_person_doc"; PdoDataAccess::runquery($query); $query = "CREATE TABLE temp_person_doc TYPE=MyIsam AS\r\n SELECT w.staff_id,\r\n w.science_level,\r\n w.execute_date first_date,\r\n CASE\r\n WHEN w.end_date IS NULL THEN NOW()\r\n ELSE w.end_date\r\n END last_date,\r\n CASE w.annual_effect\r\n WHEN " . ANNUAL_NOT_CALC . " THEN 1\r\n ELSE 2\r\n END accept_id,\r\n writ_id twrit_id ,\r\n writ_ver twrit_ver\r\n FROM temp_writs w "; PdoDataAccess::runquery($query); $query = "ALTER TABLE temp_person_doc ADD INDEX(twrit_id)"; PdoDataAccess::runquery($query); $query = "DROP TABLE IF EXISTS temp_history"; PdoDataAccess::runquery($query); $query = " CREATE TABLE temp_history TYPE=MyIsam AS\r\n (SELECT 1 AS rowno,\r\n p.PersonID,\r\n NULL AS post_title,\r\n p.military_from_date AS from_date,\r\n p.military_to_date AS to_date,\r\n (p.military_duration DIV 12) AS d_year,\r\n (p.military_duration - ((p.military_duration DIV 12) * 12)) AS d_month,\r\n 0 AS d_day,\r\n \\'قابل قبول\\' AS accept_type,\r\n \\'سربازي\\' AS org_title,\r\n \\'سربازي\\' AS emp_state_title,\r\n NULL AS writ_id,\r\n NULL AS writ_date\r\n FROM persons p\r\n WHERE p.military_duration IS NOT NULL AND\r\n p.military_from_date IS NOT NULL AND\r\n p.military_to_date IS NOT NULL)\r\n\t\t\t\tUNION\r\n (SELECT 2 AS rowno,\r\n pe.PersonID,\r\n pe.title AS post_title,\r\n pe.from_date,\r\n pe.to_date,\r\n retired_duration_year AS d_year,\r\n retired_duration_month AS d_month,\r\n retired_duration_day AS d_day,\r\n \\'قابل قبول\\' AS accept_type,\r\n pe.organization AS org_title,\r\n emps.Title emp_state_title,\r\n NULL AS writ_id,\r\n NULL AS writ_date\r\n FROM person_employments pe " . QueryHelper::makeBasicInfoJoin(BINFTYPE_emp_state, "emps", "pe.emp_state") . " )\r\n\t\t\t\tUNION\r\n (SELECT 3 AS rowno,\r\n pe.PersonID,\r\n pe.title AS post_title,\r\n pe.from_date,\r\n pe.to_date,\r\n FLOOR(((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day)) / 365.25) AS d_year,\r\n FLOOR((((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day)) -FLOOR(((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day)) / 365.25)*365.25) / 30.4375) AS d_month ,\r\n (((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day))-\r\n FLOOR(((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day)) / 365.25) *365.25\r\n -ROUND(FLOOR((((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day)) -FLOOR(((duration_year - retired_duration_year)*365.25 + (duration_month - retired_duration_month)*30.4375 + (duration_day - retired_duration_day)) / 365.25)*365.25) / 30.4375)*30.4375)) AS d_day,\r\n \\'غير قابل قبول\\' AS accept_type,\r\n pe.organization AS org_title,\r\n emps.Title emp_state_title , \r\n NULL AS writ_id,\r\n NULL AS writ_date\r\n FROM person_employments pe " . QueryHelper::makeBasicInfoJoin(BINFTYPE_emp_state, "emps", "pe.emp_state") . " )\r\n\t\t\t\tUNION\r\n (SELECT\r\n 4 AS rowno,\r\n s.PersonID,\r\n CASE\r\n WHEN w.person_type =" . HR_PROFESSOR . " THEN slvl.Title\r\n WHEN w.person_type =" . HR_WORKER . " THEN j.title\r\n ELSE p.title\r\n END post_title ,\r\n pd.first_date AS from_date,\r\n pd.last_date AS to_date,\r\n FLOOR(DATEDIFF(pd.last_date,pd.first_date) / 365.25) AS d_year,\r\n FLOOR( ( DATEDIFF(pd.last_date,pd.first_date) - FLOOR(DATEDIFF(pd.last_date,pd.first_date) / 365.25)*365.25 ) / 30.4375 ) AS d_month,\r\n DATEDIFF(pd.last_date,pd.first_date) - FLOOR(DATEDIFF(pd.last_date,pd.first_date) / 365.25)*365.25 - FLOOR( ( DATEDIFF(pd.last_date,pd.first_date) - FLOOR(DATEDIFF(pd.last_date,pd.first_date) / 365.25)*365.25 ) / 30.4375 )*30.4375 AS d_day,\r\n CASE pd.accept_id\r\n WHEN 1 THEN \\'غير قابل قبول\\'\r\n ELSE \\'قابل قبول\\'\r\n END AS accept_type,\r\n CASE pd.accept_id\r\n WHEN 1 THEN empd.Title\r\n ELSE o.ptitle\r\n END AS org_title,\r\n emps.Title emp_state_title,\r\n w.send_letter_no AS writ_id,\r\n w.execute_date AS writ_date\r\n FROM temp_person_doc pd\r\n INNER JOIN writs w\r\n ON(w.writ_id = pd.twrit_id and w.writ_ver=pd.twrit_ver)\r\n INNER JOIN staff s\r\n ON(w.staff_id = s.staff_id)\r\n LEFT OUTER JOIN org_new_units o\r\n ON(w.ouid = o.ouid)\r\n LEFT OUTER JOIN position p\r\n ON p.post_id = w.post_id\r\n LEFT OUTER JOIN jobs j\r\n ON w.job_id = j.job_id " . QueryHelper::makeBasicInfoJoin(BINFTYPE_science_level, "slvl", "w.science_level") . QueryHelper::makeBasicInfoJoin(BINFTYPE_emp_mode, "empd", "w.emp_mode") . QueryHelper::makeBasicInfoJoin(BINFTYPE_emp_state, "emps", "w.emp_state") . " WHERE w.history_only = 0) "; //.............................................................................. $query = " DROP TABLE IF EXISTS temp_exe_post "; PdoDataAccess::runquery($query); $query = " CREATE TABLE temp_exe_post Type=MyIsam AS\r\n SELECT staff_id,SUBSTRING(MAX(CONCAT(from_date , row_no)),11) max_row\r\n FROM professor_exe_posts\r\n GROUP BY staff_id"; PdoDataAccess::runquery($query); $query = " ALTER TABLE temp_exe_post ADD INDEX(staff_id,max_row) "; PdoDataAccess::runquery($query); $query = "DROP TABLE IF EXISTS temp_devotion "; PdoDataAccess::runquery($query); $query = " CREATE TABLE temp_devotion Type=MyIsam AS\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t PersonID,\r\n\t\t\t\t\t SUM(CASE devotion_type\r\n\t\t\t\t\t WHEN " . FIGHTING_DEVOTION . " THEN amount\r\n\t\t\t\t\t ELSE 0\r\n\t\t\t\t\t END) razm,\r\n\t\t\t\t\t MAX(CASE devotion_type\r\n\t\t\t\t\t WHEN " . SACRIFICE_DEVOTION . " THEN amount\r\n\t\t\t\t\t ELSE 0\r\n\t\t\t\t\t END) janbaz\r\n\t\t\t\t\tFROM person_devotions\r\n\t\t\t\t\tWHERE devotion_type IN(" . FIGHTING_DEVOTION . "," . SACRIFICE_DEVOTION . ")\r\n\t\t\t\t\tGROUP BY PersonID "; PdoDataAccess::runquery($query); $query = "ALTER TABLE temp_devotion ADD INDEX(PersonID)"; PdoDataAccess::runquery($query); $query = " SELECT s.staff_id,\r\n p.plname,\r\n p.pfname,\r\n p.father_name ,\r\n p.birth_date ,\r\n idcard_no ,\r\n national_code ,\r\n concat(st.ptitle ,'-',ct.ptitle ) birth_place ,\r\n w.base ,\r\n sf.ptitle AS field_title,\r\n sb.ptitle AS branch_title,\r\n pe.doc_date,\r\n c.ptitle AS country_title,\r\n u.ptitle AS university_title,\r\n td.razm ,\r\n td.janbaz,\r\n o.ptitle AS unit_title,\r\n o.ouid ,\r\n po.post_no,\r\n po.title AS last_post_title,\r\n po2.title AS exe_post_title,\r\n pep.from_date AS exe_post_from,\r\n slvl.Title science_level_title ,\r\n wtt.Title worktime_type_title ,\r\n mlt.Title military_type_title ,\r\n edl.Title education_level_title ,\r\n emps.Title emp_state_title \r\n\r\n FROM staff s \r\n\t\t\t\t\t INNER JOIN persons p\r\n\t\t\t\t\t ON(s.PersonID = p.PersonID)\r\n\t\t\t\t\t LEFT OUTER JOIN states st\r\n\t\t\t\t\t \t\tON (st.state_id = p.birth_state_id)\r\n\t\t\t\t\t LEFT OUTER JOIN cities ct\r\n\t\t\t\t\t \t\tON (ct.city_id = p.birth_city_id)\r\n\t\t\t\t\t LEFT OUTER JOIN writs w\r\n\t\t\t\t\t ON(s.last_writ_ver = w.writ_ver AND s.last_writ_id = w.writ_id)\r\n\t\t\t\t\t LEFT OUTER JOIN person_educations pe\r\n\t\t\t\t\t ON(s.PersonID = pe.PersonID AND w.education_level = pe.education_level AND w.sfid = pe.sfid AND (w.sbid = pe.sbid OR w.sbid IS NULL))\r\n\t\t\t\t\t LEFT OUTER JOIN study_fields sf\r\n\t\t\t\t\t ON(w.sfid = sf.sfid)\r\n\t\t\t\t\t LEFT OUTER JOIN study_branchs sb\r\n\t\t\t\t\t ON(w.sfid = sb.sfid AND w.sbid = sb.sbid)\r\n\t\t\t\t\t LEFT OUTER JOIN countries c\r\n\t\t\t\t\t ON(pe.country_id = c.country_id)\r\n\t\t\t\t\t LEFT OUTER JOIN universities u\r\n\t\t\t\t\t ON(pe.country_id = u.country_id AND pe.university_id = u.university_id)\r\n\t\t\t\t\t LEFT OUTER JOIN org_new_units o\r\n\t\t\t\t\t ON(w.ouid = o.ouid)\r\n\t\t\t\t\t LEFT OUTER JOIN position po\r\n\t\t\t\t\t ON(w.post_id = po.post_id)\r\n\t\t\t\t\t LEFT OUTER JOIN temp_exe_post tep\r\n\t\t\t\t\t ON(s.staff_id = tep.staff_id)\r\n\t\t\t\t\t LEFT OUTER JOIN professor_exe_posts pep\r\n\t\t\t\t\t ON(tep.staff_id = pep.staff_id AND tep.max_row = pep.row_no AND (pep.to_date IS NULL OR pep.to_date>=CURDATE()))\r\n\t\t\t\t\t LEFT OUTER JOIN position po2\r\n\t\t\t\t\t ON(pep.post_id = po2.post_id)\r\n\t\t\t\t\t LEFT OUTER JOIN temp_devotion td\r\n\t\t\t\t\t ON(s.PersonID = td.PersonID) " . QueryHelper::makeBasicInfoJoin(BINFTYPE_science_level, "slvl", "w.science_level") . QueryHelper::makeBasicInfoJoin(BINFTYPE_worktime_type, "wtt", "w.worktime_type") . QueryHelper::makeBasicInfoJoin(BINFTYPE_military_type, "mlt", "w.military_type") . QueryHelper::makeBasicInfoJoin(BINFTYPE_education_level, "edl", "w.education_level") . QueryHelper::makeBasicInfoJoin(BINFTYPE_emp_state, "emps", "w.emp_state") . " WHERE ((th.d_year<>0 OR th.d_month<>0 OR th.d_day<>0)OR(w.emp_mode IN(11,12,13,14) AND\r\n th.writ_date = w.execute_date)) AND\r\n s.person_type in(" . manage_access::getValidPersonTypes() . ") AND\r\n s.last_cost_center_id in(" . manage_access::getValidCostCenters() . ") "; $dt = PdoDataAccess::runquery($query, $whereParam); return $dt; }
function BindDropDown($dropdownName, $type) { $obj = new DROPDOWN(); $ptWhr = ""; if ($type == 16) { $ptWhr = " AND infoID in(" . manage_access::getValidPersonTypes() . ")"; } $obj->datasource = PdoDataAccess::runquery("select * from Basic_Info where TypeID=" . $type . $ptWhr . " order by Title"); $obj->valuefield = "%InfoID%"; $obj->textfield = "%Title%"; $obj->Style = 'style=\'width:98%\' class=\'x-form-text\''; $obj->id = $dropdownName; $obj->datasource = array_merge(array(array("InfoID" => "-1", "Title" => "---")), $obj->datasource); return $obj->bind_dropdown(); }
public static function DRP_writType_writSubType($formName, $typeFieldName, $subtypeFieldName, $typeSelectedID = "", $subtypeSelectedID = "", $typeExtraRow = "", $subtypeExraRow = "", $masterWidth = "", $person_type = "") { $obj = new MaserDetail_DROPDOWN(); $where = $person_type != "" ? $person_type : manage_access::getValidPersonTypes(); $obj->Master_datasource = PdoDataAccess::runquery("\r\n\t\t\tselect writ_type_id,title,person_type\r\n\t\t\tfrom writ_types\r\n\t\t\twhere person_type in(" . $where . ")\r\n\t\t\torder by title"); if (!empty($typeExtraRow)) { $obj->Master_datasource = array_merge(array(array("writ_type_id" => "-1", "title" => $typeExtraRow)), $obj->Master_datasource); } $obj->Master_id = $typeFieldName; $obj->Master_valuefield = "writ_type_id"; $obj->Master_valuefield2 = "person_type"; $obj->Master_textfield = "title"; $obj->Master_Width = $masterWidth; $obj->Master_formName = $formName; $obj->Detail_storeUrl = "global/domain.data.php?task=searchWritSubTypes&extraRowID=-1&extraRowText={$subtypeExraRow}"; $obj->Detail_id = $subtypeFieldName; $obj->Detail_valuefield = "writ_subtype_id"; $obj->Detail_textfield = "title"; $obj->Detail_masterfield = "writ_type_id"; $obj->Detail_masterfield2 = "person_type"; return $obj->bind_dropdown_returnObjects($typeSelectedID, $subtypeSelectedID); }
function selectArrearTransferWrits() { MakeAdvanceSearchWhere($where, $whereParam); $state; $state = isset($_REQUEST["return"]) ? "1" : "0"; $stateWhere = ""; $stateWhere = " w.arrear = " . $state . " AND "; $curYear = DateModules::GetYear(DateModules::miladi_to_shamsi(DateModules::Now())); $query = "select w.writ_id,\n w.writ_ver,\n w.staff_id,\n w.ouid,\n w.issue_date,\n w.history_only,\n w.corrective,\n w.execute_date,\n concat(wt.title,' - ', wst.title) as wt_title,\n bi_emp_state.title as emp_state_title,\n w.ref_letter_no,\n w.ref_letter_date,\n w.person_type,\n concat(p.pfname, ' ', p.plname) fullname,\n w.corrective_writ_id,\n w.correct_completed,\n\t\t\t\t\t w.view_flag\n\t\t\t\t\n\t\t\t\tfrom staff s\n \n \t\t LEFT OUTER JOIN writs w ON (w.staff_id = s.staff_id)\n LEFT OUTER JOIN writ_types wt ON ((w.writ_type_id = wt.writ_type_id) AND (w.person_type = wt.person_type))\n LEFT OUTER JOIN writ_subtypes wst ON (w.writ_subtype_id = wst.writ_subtype_id AND w.writ_type_id = wst.writ_type_id \n \t\t\t\t\t\t\t\t\t\t\tAND w.person_type = wst.person_type)\n LEFT OUTER JOIN persons p ON (s.PersonID = p.PersonID)\n LEFT OUTER JOIN org_new_units o ON (w.ouid = o.ouid)\n LEFT JOIN Basic_Info bi_emp_state on(bi_emp_state.TypeID=3 and w.emp_state=bi_emp_state.InfoID)\n LEFT JOIN payment_writs pw ON pw.writ_id = w.writ_id and pw.writ_ver = w.writ_ver and pw.staff_id = w.staff_id \n\t\t\t\t \n\t\t\twhere w.execute_date >= '" . TRANSFER_WRIT_EXE_DATE . "' AND w.state = 3 AND \n\t\t\t\t w.execute_date < '" . str_replace("/", "-", DateModules::shamsi_to_miladi($curYear . "/01/01")) . "' AND\t\t\t\t \n\t\t\t\t substr(g2j(w.execute_date),1,4) < substr(g2j(writ_recieve_date),1,4) AND \n\t\t\t\t {$stateWhere}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n s.person_type in (" . manage_access::getValidPersonTypes() . ") AND w.cost_center_id in (" . manage_access::getValidCostCenters() . ") AND\n\t\t\t\tw.emp_state <> 0 AND\n\t\t\t\t(w.history_only=0 OR w.history_only IS NULL) AND \n\t\t\t\t(w.dont_transfer = 0 OR w.dont_transfer IS NULL) AND\n ( pw.writ_id is null ) AND\n\t\t\t\t(w.correct_completed!=" . WRIT_CORRECTING . ") AND " . $where . "\n\t\t\t\n\t\t\torder by p.plname,p.pfname,s.staff_id,w.execute_date,w.writ_id,w.writ_ver"; $temp = PdoDataAccess::runquery($query, $whereParam); /*if($_SESSION['UserID'] == 'jafarkhani') { echo PdoDataAccess::GetLatestQueryString(); die(); }*/ for ($i = 0; $i < count($temp); $i++) { $temp[$i]['full_unit_title'] = manage_units::get_full_title($temp[$i]['ouid']); } echo dataReader::getJsonData($temp, count($temp), $_GET["callback"]); die; }
$QUERY_SELECT = str_replace("[0:" . $formula_columns[$i][0] . "]", $formula_columns[$i][1], $QUERY_SELECT); $QUERY_SELECT = str_replace("[1:" . $formula_columns[$i][0] . "]", $formula_columns[$i][2], $QUERY_SELECT); } $QUERY_SELECT = substr($QUERY_SELECT, 0, strlen($QUERY_SELECT) - 1); $QUERY_GROUP = $QUERY_GROUP != "" ? substr($QUERY_GROUP, 0, strlen($QUERY_GROUP) - 1) : ""; $QUERY_ORDER = $seprationOrder . $QUERY_ORDER; $QUERY_ORDER = $QUERY_ORDER != "" ? substr($QUERY_ORDER, 0, strlen($QUERY_ORDER) - 1) : ""; //------------------------------------------------------------------------------ preg_match_all('|#([^#].*)#|U', $QUERY_WHERE, $requestParams); for ($i = 0; $i < count($requestParams[0]); $i++) { $QUERY_WHERE = str_replace($requestParams[0][$i], "'" . $_REQUEST[$requestParams[1][$i]] . "'", $QUERY_WHERE); } //------------------------------------------------------------------------------ $TotalQuery = $QUERY_SELECT; $TotalQuery .= $rptobj->query; $TotalQuery .= " where " . $QUERY_WHERE . " AND persons.person_type in(" . manage_access::getValidPersonTypes() . ")"; // bahar $TotalQuery .= $QUERY_GROUP != "" ? " group by " . $QUERY_GROUP : ""; $TotalQuery .= $QUERY_ORDER != "" ? " order by " . $QUERY_ORDER : ""; if (!isset($_REQUEST["excel"])) { echo "<div style='display:none'>" . $TotalQuery . "<br>"; print_r($whereParam); echo "</div>"; } if (isset($_REQUEST["preview"])) { $TotalQuery .= " limit 10"; } $statement = PdoDataAccess::runquery_fetchMode($TotalQuery, $whereParam); if (ExceptionHandler::GetExceptionCount() != 0) { print_r(ExceptionHandler::PopAllExceptions()); }
static function GetAllWrits($where = "", $whereParam = array()) { /* $staff_group_join = ""; if(!empty($_REQUEST['staff_group_id'])) { $staff_group_join = " LEFT JOIN staff_group_members sgm ON sgm.staff_id = s.staff_id AND sgm.staff_group_id = ".$_REQUEST['staff_group_id']; } */ // PdoDataAccess::runquery("insert into temp_sum_item_writs select * from sum_items_writs i on duplicate key update sumValue=i.sumValue"); $whr = ""; /*if($_SESSION['UserID'] != 'jafarkhani' && $_SESSION['UserID'] != 'delkalaleh' && $_SESSION['UserID'] != 'nadaf' && $_SESSION['UserID'] != 'm-hakimi' && $_SESSION['UserID'] != 'shokri' ) { $whr = " AND w.execute_date < '2014-02-20' " ; } */ if (isset($_REQUEST['last_writ_view']) && (empty($_REQUEST['to_execute_date']) || $_REQUEST['to_execute_date'] == '0000-00-00')) { $query = " SELECT w.*,\n bi1.Title corrective_title ,\n\t\t bi2.Title history_only_title ,\n bi3.Title science_level_title ,\n p.pfname ,\n p.plname ,\n p.PersonID ,\n concat(p.pfname ,' ',p.plname) fullname ,\n wt.title MainWtitle,\n wst.title wst_title,\n wst.time_limited,\n concat(wt.title ,' ',wst.title) wt_title ,\n bi4.Title emp_state_title ,\n bi5.Title educTitle ,\n bi6.Title SPTitle ,\n bi7.Title AETitle ,\n o.ptitle o_ptitle,\n c.title c_title,\n c.cost_center_id ,\n sf.sfid,\n sf.ptitle sf_ptitle,\n sb.sbid,\n sb.ptitle sb_ptitle ,\n parentu.ouid ,\n parentu.ptitle parentTitle ,\n temp.sumValue\n\n\t\t FROM persons p\n JOIN staff s ON(p.personid = s.personid)\n " . $staff_group_join . "\n INNER JOIN writs w ON(s.staff_id = w.staff_id AND s.last_writ_id = w.writ_id AND s.last_writ_ver = w.writ_ver)\n LEFT JOIN sum_items_writs temp ON temp.writ_id = w.writ_id and\n temp.writ_ver = w.writ_ver and\n temp.staff_id = w.staff_id\n LEFT JOIN Basic_Info bi1 ON ( bi1.InfoID = w.corrective AND bi1.TypeID = 5)\n LEFT JOIN Basic_Info bi2 ON ( bi2.InfoID = w.history_only AND bi2.TypeID = 5)\n LEFT JOIN Basic_Info bi3 ON (bi3.InfoID = w.science_level AND bi3.TypeID = 8)\n LEFT JOIN Basic_Info bi4 ON (bi4.InfoID = w.emp_state AND bi4.TypeID = 3)\n LEFT JOIN Basic_Info bi5 ON (bi5.InfoID = w.education_level AND bi5.TypeID = 6 )\n LEFT JOIN Basic_Info bi6 ON (bi6.InfoID = w.salary_pay_proc AND bi6.TypeID = 12 )\n LEFT JOIN Basic_Info bi7 ON (bi7.InfoID = w.annual_effect AND bi7.TypeID = 13 )\n LEFT OUTER JOIN position po ON (w.post_id = po.post_id)\n LEFT OUTER JOIN writ_types wt ON (w.writ_type_id = wt.writ_type_id AND w.person_type = wt.person_type)\n LEFT OUTER JOIN writ_subtypes wst ON (w.writ_subtype_id = wst.writ_subtype_id AND\n w.writ_type_id = wst.writ_type_id AND w.person_type = wst.person_type)\n LEFT OUTER JOIN study_branchs sb ON ((w.sbid = sb.sbid) AND (w.sfid = sb.sfid))\n LEFT OUTER JOIN study_fields sf ON (w.sfid = sf.sfid)\n LEFT OUTER JOIN org_new_units o ON (o.ouid = w.ouid)\n LEFT OUTER JOIN org_new_units parentu ON (parentu.ouid = o.parent_ouid)\n LEFT OUTER JOIN cost_centers c ON (w.cost_center_id = c.cost_center_id)\n\n where (s.last_cost_center_id is null OR s.last_cost_center_id in(" . manage_access::getValidCostCenters() . "))\n\t\t\t\t\t\tAND s.person_type in(" . manage_access::getValidPersonTypes() . ") {$whr} "; } else { if (isset($_REQUEST['last_writ_view']) && (!empty($_REQUEST['to_execute_date']) && $_REQUEST['to_execute_date'] != '0000-00-00')) { $whereW = " AND w.execute_date >= '" . DateModules::shamsi_to_miladi($_REQUEST['from_execute_date']) . "'"; $whereW .= " AND w.execute_date <= '" . DateModules::shamsi_to_miladi($_REQUEST['to_execute_date']) . "'"; $query = " SELECT w.*,\n bi1.Title corrective_title ,\n\t\t bi2.Title history_only_title ,\n bi3.Title science_level_title ,\n p.pfname ,\n p.plname ,\n p.PersonID ,\n concat(p.pfname ,' ',p.plname) fullname ,\n wt.title MainWtitle,\n wst.title wst_title,\n wst.time_limited,\n concat(wt.title ,' ',wst.title) wt_title ,\n bi4.Title emp_state_title ,\n bi5.Title educTitle ,\n bi6.Title SPTitle ,\n bi7.Title AETitle ,\n o.ptitle o_ptitle,\n c.title c_title,\n c.cost_center_id ,\n sf.sfid,\n sf.ptitle sf_ptitle,\n sb.sbid,\n sb.ptitle sb_ptitle ,\n parentu.ouid ,\n parentu.ptitle parentTitle ,\n temp.sumValue\n\n\t\t FROM persons p\n JOIN staff s ON(p.personid = s.personid)\n " . $staff_group_join . "\n INNER JOIN (SELECT staff_id,\n SUBSTRING_INDEX(SUBSTRING(max_execute_date,11),'.',1) writ_id,\n SUBSTRING_INDEX(max_execute_date,'.',-1) writ_ver\n FROM (SELECT w.staff_id,\n max( CONCAT(w.execute_date,w.writ_id,'.',w.writ_ver) ) max_execute_date\n FROM writs w\n INNER JOIN staff ls\n ON(w.staff_id = ls.staff_id)\n WHERE w.history_only = 0 " . $whereW . "\n GROUP BY w.staff_id)tbl2) tbl1\n on s.staff_id = tbl1.staff_id \n INNER JOIN writs w\n on tbl1.writ_id = w.writ_id and\n tbl1.writ_ver = w.writ_ver and\n tbl1.staff_id = w.staff_id \n LEFT JOIN sum_items_writs temp ON temp.writ_id = w.writ_id and\n temp.writ_ver = w.writ_ver and\n temp.staff_id = w.staff_id\n LEFT JOIN Basic_Info bi1 ON ( bi1.InfoID = w.corrective AND bi1.TypeID = 5)\n LEFT JOIN Basic_Info bi2 ON ( bi2.InfoID = w.history_only AND bi2.TypeID = 5)\n LEFT JOIN Basic_Info bi3 ON (bi3.InfoID = w.science_level AND bi3.TypeID = 8)\n LEFT JOIN Basic_Info bi4 ON (bi4.InfoID = w.emp_state AND bi4.TypeID = 3)\n LEFT JOIN Basic_Info bi5 ON (bi5.InfoID = w.education_level AND bi5.TypeID = 6 )\n LEFT JOIN Basic_Info bi6 ON (bi6.InfoID = w.salary_pay_proc AND bi6.TypeID = 12 )\n LEFT JOIN Basic_Info bi7 ON (bi7.InfoID = w.annual_effect AND bi7.TypeID = 13 )\n LEFT OUTER JOIN position po ON (w.post_id = po.post_id)\n LEFT OUTER JOIN writ_types wt ON (w.writ_type_id = wt.writ_type_id AND w.person_type = wt.person_type)\n LEFT OUTER JOIN writ_subtypes wst ON (w.writ_subtype_id = wst.writ_subtype_id AND\n w.writ_type_id = wst.writ_type_id AND w.person_type = wst.person_type)\n LEFT OUTER JOIN study_branchs sb ON ((w.sbid = sb.sbid) AND (w.sfid = sb.sfid))\n LEFT OUTER JOIN study_fields sf ON (w.sfid = sf.sfid)\n LEFT OUTER JOIN org_new_units o ON (o.ouid = w.ouid)\n LEFT OUTER JOIN org_new_units parentu ON (parentu.ouid = o.parent_ouid)\n LEFT OUTER JOIN cost_centers c ON (w.cost_center_id = c.cost_center_id)\n\n where (s.last_cost_center_id is null OR s.last_cost_center_id in(" . manage_access::getValidCostCenters() . "))\n\t\t\t\t\t\tAND s.person_type in(" . manage_access::getValidPersonTypes() . ") {$whr} "; } else { $query = " SELECT w.*, w.ouid sub_ouid ,\n\t bi1.InfoDesc corrective_title ,\n\t\t\t bi2.InfoDesc history_only_title ,\t \n\t p.pfname ,\n\t p.plname ,\n\t p.PersonID ,\n\t concat(p.pfname ,' ',p.plname) fullname ,\n\t wt.title MainWtitle,\n\t wst.title wst_title,\n\t wst.time_limited,\n\t concat(wt.title ,' ',wst.title) wt_title ,\n\t bi4.InfoDesc emp_state_title ,\n\t bi5.InfoDesc educTitle ,\n\t bi6.InfoDesc SPTitle ,\n\t bi7.InfoDesc AETitle ,\n\t bi8.InfoDesc ModeTitle ,\n\t o.ptitle o_ptitle,\t \n\t sf.sfid,\n\t sf.ptitle sf_ptitle,\n\t sb.sbid,\n\t sb.ptitle sb_ptitle ,\n\t parentu.ouid ,\n\t parentu.ptitle parentTitle ,\n\t po.title post_title ,\n\t po.post_no ,\n\t j.title job_title ,\n\t j.job_group ,\n\t \n\t\t\t\t\t\t\t (w.cur_group - jf.start_group) + 1 job_category \n\n\t\t\t FROM HRM_persons p\n\t JOIN HRM_staff s ON(p.personid = s.personid)\t \n\t INNER JOIN HRM_writs w ON (s.staff_id = w.staff_id )\n \n\t LEFT JOIN BaseInfo bi1 ON ( bi1.InfoID = w.corrective AND bi1.TypeID = 57)\n\t LEFT JOIN BaseInfo bi2 ON ( bi2.InfoID = w.history_only AND bi2.TypeID = 57)\t \n\t LEFT JOIN BaseInfo bi4 ON (bi4.InfoID = w.emp_state AND bi4.TypeID = 58)\n\t LEFT JOIN BaseInfo bi5 ON (bi5.InfoID = w.education_level AND bi5.TypeID = 56 )\n\t LEFT JOIN BaseInfo bi6 ON (bi6.InfoID = w.salary_pay_proc AND bi6.TypeID = 59 )\n\t LEFT JOIN BaseInfo bi7 ON (bi7.InfoID = w.annual_effect AND bi7.TypeID = 60 )\n\t LEFT OUTER JOIN BaseInfo bi8 ON ( bi8.InfoID = w.emp_mode AND bi8.TypeID = 61 )\n\t LEFT OUTER JOIN HRM_position po ON (w.post_id = po.post_id)\n\t\t\t\t\t\t\tLEFT OUTER JOIN HRM_job_fields jf ON (po.jfid = jf.jfid)\n\t LEFT OUTER JOIN HRM_writ_types wt ON ((w.writ_type_id = wt.writ_type_id) AND (w.person_type = wt.person_type))\n\t LEFT OUTER JOIN HRM_writ_subtypes wst ON ((w.writ_subtype_id = wst.writ_subtype_id) AND (w.writ_type_id = wst.writ_type_id) AND (w.person_type = wst.person_type))\n\t LEFT OUTER JOIN HRM_study_branchs sb ON ((w.sbid = sb.sbid) AND (w.sfid = sb.sfid))\n\t LEFT OUTER JOIN HRM_study_fields sf ON (w.sfid = sf.sfid)\n\t LEFT OUTER JOIN HRM_org_new_units o ON (o.ouid = w.ouid)\n\t LEFT OUTER JOIN HRM_org_new_units parentu ON (parentu.ouid = o.parent_ouid)\t \n\t LEFT OUTER JOIN HRM_jobs j ON ( w.job_id = j.job_id ) \n\n\n\t\t\t\t\twhere (1=1) {$whr}\n "; } } $query .= $where != "" ? " AND " . $where : ""; $temp = parent::runquery_fetchMode($query, $whereParam); return $temp; }
static function Count($where, $whereParam) { $query = "select count(*) from persons p join staff s on(s.person_type=p.person_type and s.PersonID=p.PersonID)\n\t\t\twhhere (s.last_cost_center_id in(" . manage_access::getValidCostCenters() . ") OR s.last_cost_center_id is null)\n\t\t\t\t\t\tAND s.person_type in(" . manage_access::getValidPersonTypes() . ")"; $query .= $where != "" ? " AND " . $where : ""; $temp = parent::runquery($query, $whereParam); return $temp[0][0]; }
static function GetAll($where = "", $whereParam = array()) { $query = " select pe.*,p.title as postTitle,if(p.staff_id=pe.staff_id, 1, 0) as assign_post\r\n\t\t\t\tfrom professor_exe_posts pe\r\n\t\t\t\t\tLEFT JOIN position p using(post_id)\r\n\t\t\t\twhere p.person_type in(" . manage_access::getValidPersonTypes() . ")"; $query .= $where != "" ? " AND " . $where : ""; $temp = parent::runquery($query, $whereParam); return $temp; }
static function Count($where, $whereParam) { $query = "select count(*) from staff\n\t\t\t where (last_cost_center_id is null OR last_cost_center_id in(" . manage_access::getValidCostCenters() . "))\n\t\t\t\tAND person_type in(" . manage_access::getValidPersonTypes() . ")"; $query .= $where != "" ? " AND " . $where : ""; $temp = PdoDataAccess::runquery($query, $whereParam); return $temp[0][0]; }
LEFT JOIN writs w ON ((pa.writ_id = w.writ_id) AND (pa.writ_ver = w.writ_ver) AND (pa.staff_id = w.staff_id) ) LEFT JOIN org_new_units o ON (w.ouid = o.ouid) INNER JOIN staff s ON (pa.staff_id = s.staff_id) INNER JOIN persons ps ON (s.PersonID = ps.PersonID) INNER JOIN cost_centers c ON (pai.cost_center_id = c.cost_center_id) LEFT OUTER JOIN banks b ON (s.bank_id = b.bank_id) INNER JOIN hrmstotal.Basic_Info BI ON BI.typeid = 41 and BI.infoid = pa.pay_month where $whr AND s.person_type in(" . manage_access::getValidPersonTypes() . ") order by c.cost_center_id, pa.staff_id, pa.pay_year, pa.pay_month, pa.payment_type, ps.plname, ps.pfname, sit.print_order "; $dt = PdoDataAccess::runquery($query, $whereParam);
//--------------------------- // programmer: Mahdipour // create Date: 90.09.25 //--------------------------- require_once '../../../header.inc.php'; require_once inc_dataGrid; require_once inc_manage_unit; //----------------------------------------------- $FacilID = isset($_POST["FacilID"]) ? $_POST["FacilID"] : ""; //________________ GET ACCESS _________________ $accessObj = new ModuleAccess($FacilID, 4, Deputy, Module_writ); if (!$accessObj->UpdateAccess()) { die; } $listAcc = explode(',', manage_access::getValidPersonTypes()); $emp = 0; $worker = 0; $prof = 0; $gharardadi = 0; for ($t = 0; $t < count($listAcc); $t++) { if ($listAcc[$t] == 1) { $prof = 1; } if ($listAcc[$t] == 2) { $emp = 1; } if ($listAcc[$t] == 3) { $worker = 1; } if ($listAcc[$t] == 5) {