function selectIncomeCheques() { $where = "1=1"; $param = array(); MakeWhere($where, $param); $query = "\r\n\t\tselect i.*,\r\n\t\t\tcase when i.CostID is null then group_concat(t2.TafsiliDesc SEPARATOR '<br>')\r\n\t\t\t\telse t1.TafsiliDesc end fullname,\r\n\t\t\tcase when i.CostID is null then group_concat(concat_ws('-', bb1.blockDesc, bb2.blockDesc) SEPARATOR '<br>') \r\n\t\t\t\telse concat_ws('-', b1.blockDesc, b2.blockDesc, b3.blockDesc) end CostDesc,\r\n\t\t\tb.BankDesc, \r\n\t\t\tt3.TafsiliDesc ChequeStatusDesc,\r\n\t\t\tt.docs\r\n\t\t\t\r\n\t\tfrom ACC_IncomeCheques i\r\n\t\t\tleft join ACC_tafsilis t1 using(TafsiliID)\r\n\t\t\tleft join ACC_CostCodes cc using(CostID)\r\n\t\t\tleft join ACC_blocks b1 on(cc.level1=b1.BlockID)\r\n\t\t\tleft join ACC_blocks b2 on(cc.level2=b2.BlockID)\r\n\t\t\tleft join ACC_blocks b3 on(cc.level3=b3.BlockID)\r\n\t\t\t\r\n\t\t\tleft join LON_BackPays bp using(IncomeChequeID)\r\n\t\t\tleft join LON_requests using(RequestID)\r\n\t\t\tleft join LON_loans l using(LoanID)\r\n\t\t\tleft join ACC_CostCodes cc2 on(cc2.level1=" . BLOCKID_LOAN . " AND cc2.level2=l.blockID)\r\n\t\t\tleft join ACC_blocks bb1 on(cc2.level1=bb1.BlockID)\r\n\t\t\tleft join ACC_blocks bb2 on(cc2.level2=bb2.BlockID)\r\n\t\t\tleft join ACC_tafsilis t2 on(t2.TafsiliType=" . TAFTYPE_PERSONS . " AND t2.ObjectID=LoanPersonID)\r\n\t\t\r\n\t\tleft join ACC_banks b on(ChequeBank=BankID)\r\n\t\tleft join ACC_tafsilis t3 on(t3.TafsiliType=" . TAFTYPE_ChequeStatus . " AND t3.TafsiliID=ChequeStatus)\r\n\t\tleft join (\r\n\t\t\tselect SourceID, group_concat(distinct LocalNo) docs\r\n\t\t\tfrom ACC_DocItems join ACC_docs using(DocID)\r\n\t\t\twhere SourceType='" . DOCTYPE_INCOMERCHEQUE . "' \r\n\t\t\tgroup by SourceID\r\n\t\t)t on(i.IncomeChequeID=t.SourceID)\r\n\t\t\r\n\t\twhere " . $where . " \r\n\t\tgroup by i.IncomeChequeID"; //......................................................... $query .= dataReader::makeOrder(); $temp = PdoDataAccess::runquery_fetchMode($query, $param); print_r(ExceptionHandler::PopAllExceptions()); //echo PdoDataAccess::GetLatestQueryString(); $no = $temp->rowCount(); $temp = PdoDataAccess::fetchAll($temp, $_GET["start"], $_GET["limit"]); echo dataReader::getJsonData($temp, $no, $_GET["callback"]); die; }
function GetWorkTimeExcel(){ $param = array(); MakeWhere($where, $param); $rpt = new ReportGenerator(); $rpt->mysql_resource = PrepareData(); $rpt->addColumn("شماره شناسایی", "staff_id"); $rpt->addColumn("نام خانوادگي", "plname"); $rpt->addColumn("نام", "pfname"); $rpt->addColumn("واحد اصلی محل خدمت", "unit_title"); $rpt->addColumn("واحد فرعی محل خدمت", "sub_unit_title"); $rpt->addColumn("کارکرد", "work_time"); $rpt->excel = true; $rpt->generateReport(); die(); }
//..................................... $query = "select d.*,di.DebtorAmount,CreditorAmount,\r\n\t\tconcat_ws(' - ',di.details,d.description) detail,\r\n\t\tconcat_ws(' - ' , b1.BlockCode,b2.BlockCode,b3.BlockCode) CostCode,\r\n\t\tconcat_ws(' - ' , b1.BlockDesc,b2.BlockDesc,b3.BlockDesc) CostDesc,\r\n\t\tb.InfoDesc TafsiliTypeDesc,\r\n\t\tconcat_ws(' - ',t.TafsiliDesc,t2.TafsiliDesc ) TafsiliDesc,\r\n\t\tbi2.InfoDesc TafsiliTypeDesc2\r\n\t\t\r\n\t\tfrom ACC_DocItems di join ACC_docs d using(DocID)\r\n\t\t\tjoin ACC_CostCodes cc using(CostID)\r\n\t\t\tjoin ACC_blocks b1 on(level1=b1.BlockID)\r\n\t\t\tleft join ACC_blocks b2 on(level2=b2.BlockID)\r\n\t\t\tleft join ACC_blocks b3 on(level3=b3.BlockID)\r\n\t\t\tleft join BaseInfo b on(TypeID=2 AND di.TafsiliType=InfoID)\r\n\t\t\tleft join ACC_tafsilis t using(TafsiliID)\r\n\t\t\tleft join BaseInfo bi2 on(bi2.TypeID=2 AND di.TafsiliType2=bi2.InfoID)\r\n\t\t\tleft join ACC_tafsilis t2 on(di.TafsiliID2=t2.TafsiliID)\r\n\t\twhere d.CycleID=" . $_SESSION["accounting"]["CycleID"]; $where = ""; $whereParam = array(); MakeWhere($where, $whereParam); $query .= $where; $query .= " order by d.DocDate"; $dataTable = PdoDataAccess::runquery($query, $whereParam); //-------------------------- previous remaindar ---------------------------- $BeforeRemaindar = ""; $BeforeAmount = 0; if (!empty($_REQUEST["fromDate"])) { $query = "select sum(CreditorAmount-di.DebtorAmount)\r\n\r\n\t\t\tfrom ACC_DocItems di join ACC_docs d using(DocID)\r\n\t\t\t\tjoin ACC_CostCodes cc using(CostID)\r\n\t\t\t\tjoin ACC_blocks b1 on(level1=b1.BlockID)\r\n\t\t\t\tleft join ACC_blocks b2 on(level2=b2.BlockID)\r\n\t\t\t\tleft join ACC_blocks b3 on(level3=b3.BlockID)\r\n\t\t\t\tleft join BaseInfo b on(TypeID=2 AND di.TafsiliType=InfoID)\r\n\t\t\t\tleft join ACC_tafsilis t using(TafsiliID)\r\n\t\t\t\tleft join BaseInfo bi2 on(bi2.TypeID=2 AND di.TafsiliType2=bi2.InfoID)\r\n\t\t\t\tleft join ACC_tafsilis t2 on(di.TafsiliID2=t2.TafsiliID)\r\n\t\t\twhere d.CycleID=" . $_SESSION["accounting"]["CycleID"] . " AND \r\n\t\t\t\td.DocDate < :fd"; $where = ""; $whereParam = array(":fd" => DateModules::shamsi_to_miladi($_REQUEST["fromDate"], "-")); MakeWhere($where, $whereParam, true); $query .= $where; $DT = PdoDataAccess::runquery($query, $whereParam); $BeforeAmount = $DT[0][0]; $BeforeRemaindar = "<div align=left style='font-family:nazanin;font-size:18px;font-weight:bold;" . "padding:4px;border:1px solid black'>مانده از قبل : " . number_format($DT[0][0]) . "</div>"; } //-------------------------------------------------------------------------- function moneyRender($row, $val) { return number_format($val); } $col = $rpg->addColumn("مبلغ بدهکار", "DebtorAmount", "moneyRender"); $col->EnableSummary(); $col = $rpg->addColumn("مبلغ بستانکار", "CreditorAmount", "moneyRender"); $col->EnableSummary(); function bdremainRender($row)
if (strpos($key, "From") === 0) { $where .= " AND " . $prefix . substr($key, 4) . " >= :{$key}"; } else { if (strpos($key, "To") === 0) { $where .= " AND " . $prefix . substr($key, 2) . " <= :{$key}"; } else { $where .= " AND " . $prefix . $key . " = :{$key}"; } } $whereParam[":{$key}"] = $value; } } //..................................... $where = "1=1"; $whereParam = array(); MakeWhere($where, $whereParam); $query = "select r.* , concat_ws(' ',fname,lname,CompanyName) fullname, sp.StepDesc,\r\n\t\t\t\tbf.InfoDesc TypeDesc,d.DocID, d.DocStatus \r\n\t\t\tfrom WAR_requests r \r\n\t\t\t\tleft join BSC_persons using(PersonID)\r\n\t\t\t\tleft join BaseInfo bf on(bf.TypeID=74 AND InfoID=r.TypeID)\r\n\t\t\t\tjoin WFM_FlowSteps sp on(sp.FlowID=" . FLOWID . " AND sp.StepID=r.StatusID)\r\n\t\t\t\tleft join ACC_DocItems on(SourceType='" . DOCTYPE_WARRENTY . "' \r\n\t\t\t\t\tAND SourceID=r.RequestID AND SourceID2=r.ReqVersion)\t\r\n\t\t\t\tleft join ACC_docs d using(DocID)\r\n\t\t\twhere " . $where . " group by r.RequestID"; $dataTable = PdoDataAccess::runquery($query, $whereParam); $rpg = new ReportGenerator(); $rpg->excel = !empty($_POST["excel"]); $rpg->mysql_resource = $dataTable; $rpg->addColumn("شماره تضمین", "RequestID"); $rpg->addColumn("نوع تضمین", "TypeDesc"); $rpg->addColumn("تاریخ شروع", "StartDate", "dateRender"); $rpg->addColumn("تاریخ پایان", "EndDate", "dateRender"); $rpg->addColumn("مبلغ", "amount", "moneyRender"); $rpg->addColumn("مشتری", "fullname"); $rpg->addColumn("سازمان مربوطه", "organization"); $rpg->addColumn("کارمزد", "wage"); $rpg->addColumn("شماره نامه معرفی", "LetterNo"); $rpg->addColumn("تاریخ نامه معرفی", "LetterDate");
function GetChangesExcel(){ $param = array(); $where = ""; $param[":year"] = $_POST["pay_year"]; $param[":month"] = $_POST["pay_month"]; $param[":pt"] = $_POST["PayType"]; $pre_year = $_POST["pay_year"] ; $pre_month = $_POST["pay_month"] - 1 ; if($pre_month == 0){ $pre_year--; $pre_month = 12 ; } $param[":preyear"] = $pre_year; $param[":premonth"] = $pre_month; MakeWhere($where, $param); $dataTable = PdoDataAccess::runquery_fetchMode(" select '' date, concat(plname,' ',pfname) name, s.staff_id , bi.Title emp_mode_desc, pit1.get_value val1, if( pit2.param1 - pit1.param1>0 , pit2.param1 - pit1.param1 , 0 ) normal_insure_inc, if( pit2.param8 - pit1.param8>0 , pit2.param8 - pit1.param8 , 0 ) normal2_insure_inc, if( pit2.param2 - pit1.param2>0 , pit2.param2 - pit1.param2 , 0 ) first_surplus_insure_inc, if( pit2.param3 - pit1.param3>0 , pit2.param3 - pit1.param3 , 0 ) second_surplus_insure_inc, if( pit2.param1 - pit1.param1>0 , pit2.param1 - pit1.param1 , 0 ) + if(pit2.param2 - pit1.param2>0 , pit2.param2 - pit1.param2 , 0 ) + if(pit2.param3 - pit1.param3>0 , pit2.param3 - pit1.param3 , 0 ) insure_inc_count, bi2.Title emp_mode_desc2, pit2.get_value val2, if( pit2.param1 - pit1.param1>0 , 0 , pit1.param1 - pit2.param1 ) normal_insure_dec, if( pit2.param8 - pit1.param8>0 , 0 , pit1.param8 - pit2.param8 ) normal2_insure_dec, if( pit2.param2 - pit1.param2>0 , 0 , pit1.param2 - pit2.param2 ) first_surplus_insure_dec, if( pit2.param3 - pit1.param3>0 , 0 , pit1.param3 - pit2.param3 ) second_surplus_insure_dec, if( pit2.param1 - pit1.param1>0 , 0 , pit1.param1 - pit2.param1 ) + if( pit2.param2 - pit1.param2>0 , 0 , pit1.param2 - pit2.param2 ) + if( pit2.param3 - pit1.param3>0 , 0 , pit1.param3 - pit2.param3 ) insure_dec_count from staff s INNER JOIN persons per ON (per.personID = s.personID) LEFT OUTER JOIN payments p1 ON p1.pay_year = :preyear AND p1.pay_month = :premonth AND p1.payment_type = :pt AND s.staff_id = p1.staff_id LEFT OUTER JOIN payments p2 ON p2.pay_year = :year AND p2.pay_month = :month AND p2.payment_type = :pt AND s.staff_id = p2.staff_id LEFT OUTER JOIN writs w1 ON (w1.writ_id = p1.writ_id AND w1.writ_ver = p1.writ_ver AND w1.staff_id = p1.staff_id ) LEFT OUTER JOIN writs w2 ON (w2.writ_id = p2.writ_id AND w2.writ_ver = p2.writ_ver AND w2.staff_id = p2.staff_id ) LEFT OUTER JOIN payment_items pit1 ON ((p1.staff_id = pit1.staff_id) AND (p1.pay_year = pit1.pay_year) AND (p1.pay_month = pit1.pay_month) AND (p1.payment_type = pit1.payment_type)) AND (pit1.salary_item_type_id IN (143,38) ) LEFT OUTER JOIN payment_items pit2 ON ((p2.staff_id = pit2.staff_id) AND (p2.pay_year = pit2.pay_year) AND (p2.pay_month = pit2.pay_month) AND (p2.payment_type = pit2.payment_type)) AND (pit2.salary_item_type_id IN (143,38) ) left join Basic_Info bi on(bi.TypeID=4 AND bi.InfoID=w1.emp_mode) left join Basic_Info bi2 on(bi2.TypeID=4 AND bi2.InfoID=w2.emp_mode) where (pit1.get_value > 0 OR pit2.get_value >0 ) AND (pit1.param1 != pit2.param1 OR pit1.param8 != pit2.param8 OR pit1.param2 != pit2.param2 OR pit1.param3 != pit2.param3 OR w1.emp_mode != w2.emp_mode ) $where ", $param); //echo PdoDataAccess::GetLatestQueryString();die(); $rpt = new ReportGenerator(); $rpt->mysql_resource = $dataTable; $rpt->addColumn("تاريخ", "date"); $rpt->addColumn('نام و نام خانوادگي', "name"); $rpt->addColumn("كد اصلي بيمه شده", "staff_id"); $rpt->addColumn("وضعيت استخدامي قبل", "emp_mode_desc"); $rpt->addColumn("مبلغ قبلي", "val1"); $rpt->addColumn("افزايش تبعي1", "normal_insure_inc"); $rpt->addColumn("افزايش تبعي 1 جديد", "normal2_insure_inc"); $rpt->addColumn("افزايش تبعي2", "first_surplus_insure_inc"); $rpt->addColumn("افزايش تبعي3", "second_surplus_insure_inc"); $rpt->addColumn("جمع افزايش", "insure_inc_count"); $rpt->addColumn("وضعيت استخدامي جديد", "emp_mode_desc2"); $rpt->addColumn("'مبلغ جديد", "val2"); $rpt->addColumn("كاهش تبعي1", "normal_insure_dec"); $rpt->addColumn("كاهش تبعي 1 جدید", "normal2_insure_dec"); $rpt->addColumn("كاهش تبعي2", "first_surplus_insure_dec"); $rpt->addColumn("كاهش تبعي3", "second_surplus_insure_dec"); $rpt->addColumn("جمع كاهش", "insure_dec_count"); $rpt->excel = true; $rpt->generateReport(); die(); }
function showReport(){ $levelsDescArr = array( "l1" => "کل", "l2" => "معین", "l3" => "جزء معین", "l4" => "گروه تفصیلی", "l5" => "گروه تفصیلی2", "l6" => "تفصیلی", "l7" => "تفصیلی2" ); global $level; $level = empty($_REQUEST["level"]) ? "l1" : $_REQUEST["level"]; $rpg = new ReportGenerator(); $whereParam = array(); $where = ""; $group = "cc.level1"; $select = "select sum(di.DebtorAmount) bdAmount, sum(di.CreditorAmount) bsAmount, b1.BlockDesc level1Desc, b2.BlockDesc level2Desc, b3.BlockDesc level3Desc, b.InfoDesc TafsiliTypeDesc, t.TafsiliDesc TafsiliDesc, bi2.InfoDesc TafsiliTypeDesc2, t2.TafsiliDesc TafsiliDesc2, cc.level1,cc.level2,cc.level3,di.TafsiliType,di.TafsiliType2,di.TafsiliID,di.TafsiliID2, t.StartCycleDebtor, t.StartCycleCreditor "; $from = " from ACC_DocItems di join ACC_docs d using(DocID) join ACC_CostCodes cc using(CostID) join ACC_blocks b1 on(level1=b1.BlockID) left join ACC_blocks b2 on(level2=b2.BlockID) left join ACC_blocks b3 on(level3=b3.BlockID) left join BaseInfo b on(TypeID=2 AND di.TafsiliType=InfoID) left join ACC_tafsilis t using(TafsiliID) left join BaseInfo bi2 on(bi2.TypeID=2 AND di.TafsiliType2=bi2.InfoID) left join ACC_tafsilis t2 on(t2.TafsiliID=di.TafsiliID2) left join ( select CycleID,CostID,sum(DebtorAmount) StartCycleDebtor, sum(CreditorAmount) StartCycleCreditor from ACC_DocItems join ACC_docs using(DocID) where DocType=1 group by CostID )t on(d.CycleID=t.CycleID AND di.CostID=t.CostID) "; if($level >= "l1") $rpg->addColumn("کل", "level1Desc",$level =="l1" ? "levelRender" : ""); if($level >= "l2") $rpg->addColumn("معین", "level2Desc", $level =="l2" ? "levelRender" : ""); if($level >= "l3") $rpg->addColumn("جزء معین", "level3Desc", $level =="l3" ? "levelRender" : ""); if($level == "l4" || $level == "l6") $rpg->addColumn("گروه تفصیلی", "TafsiliTypeDesc", $level =="l4" ? "levelRender" : ""); if($level == "l4" || $level == "l7") $rpg->addColumn("گروه تفصیلی2", "TafsiliTypeDesc2", $level == "l4" ? "levelRender2" : ""); if($level == "l6") $rpg->addColumn("تفصیلی", "TafsiliDesc", "showDocs"); if($level == "l7") $rpg->addColumn("تفصیلی2", "TafsiliDesc2", "showDocs2"); switch($level) { case "l2" : $group .= ",cc.level2"; break; case "l3" : $group .= ",cc.level3"; break; case "l4" : $group .= ",di.TafsiliType"; break; case "l5" : $group .= ",di.TafsiliType2"; break; case "l6" : $group .= ",di.TafsiliID"; break; case "l7" : $group .= ",di.TafsiliID2"; break; } function levelRender($row, $value){ global $level; if($value == "") $value = "-----"; return "<a onclick=changeLevel('" . $level . "','". ($level >= "l1" ? $row["level1"] : "") . "','" . ($level >= "l2" ? $row["level2"] : "") . "','" . ($level >= "l3" ? $row["level3"] : ""). "','" . ($level == "l4" ? $row["TafsiliType"] : ""). "','" . ($level == "l5" ? $row["TafsiliType2"] : ""). "') "." href='javascript:void(0);'>" . $value . "</a>"; } function levelRender2($row, $value){ global $level; return "<a onclick=changeLevel('l5','". ($level >= "l1" ? $row["level1"] : "") . "','" . ($level >= "l2" ? $row["level2"] : "") . "','" . ($level >= "l3" ? $row["level3"] : ""). "','" . ($level == "l4" ? $row["TafsiliType"] : ""). "','" . ($level == "l5" ? $row["TafsiliType2"] : ""). "') "." href='javascript:void(0);'>" . $value . "</a>"; } function showDocs($row, $value){ if($value == "") $value = "-----"; return "<a onclick=\"window.open('flow.php?show=true&taraz=true". "&level1=" . $row["level1"] . "&level2=" . $row["level2"] . "&level3=" . $row["level3"] . "&TafsiliType=" . $row["TafsiliType"] . "&TafsiliID=" . $row["TafsiliID"] . (!empty($_REQUEST["fromDate"]) ? "&fromDate=" . $_REQUEST["fromDate"] : "") . (!empty($_REQUEST["toDate"]) ? "&toDate=" . $_REQUEST["toDate"] : "") . (!empty($_REQUEST["fromLocalNo"]) ? "&fromLocalNo=" . $_REQUEST["fromLocalNo"] : "") . (!empty($_REQUEST["toLocalNo"]) ? "&toLocalNo=" . $_REQUEST["toLocalNo"] : "") . (!empty($_REQUEST["BranchID"]) ? "&BranchID=" . $_REQUEST["BranchID"] : "") . (!empty($_REQUEST["IncludeRaw"]) ? "&IncludeRaw=1" : "") . "');\" href=javascript:void(0)>" . $value . "</a>"; } function showDocs2($row, $value){ if($value == "") $value = "-----"; return "<a onclick=\"window.open('flow.php?taraz=true&show=true&taraz=true". "&level1=" . $row["level1"] . "&level2=" . $row["level2"] . "&level3=" . $row["level3"] . "&TafsiliID2=" . $row["TafsiliID2"] . (!empty($_POST["fromDate"]) ? "&fromDate=" . $_POST["fromDate"] : "") . (!empty($_POST["toDate"]) ? "&toDate=" . $_POST["toDate"] : "") . (!empty($_REQUEST["BranchID"]) ? "&BranchID=" . $_REQUEST["BranchID"] : "") . (!empty($_REQUEST["IncludeRaw"]) ? "&IncludeRaw=1" : "") . "');\" href=javascript:void(0)>" . $value . "</a>"; } function MakeWhere(&$where, &$whereParam){ if(!isset($_REQUEST["IncludeRaw"])) { $where .= " AND d.DocStatus != 'RAW'"; } if(isset($_REQUEST["level1"])) { if($_REQUEST["level1"] == "") $where .= " AND cc.level1 is null"; else { $where .= " AND cc.level1=:l1"; $whereParam[":l1"] = $_REQUEST["level1"]; } } if(isset($_REQUEST["level2"])) { if($_REQUEST["level2"] == "") $where .= " AND cc.level2 is null"; else { $where .= " AND cc.level2=:l2"; $whereParam[":l2"] = $_REQUEST["level2"]; } } if(isset($_REQUEST["level3"])) { if($_REQUEST["level3"] == "") $where .= " AND cc.level3 is null"; else { $where .= " AND cc.level3=:l3"; $whereParam[":l3"] = $_REQUEST["level3"]; } } if(isset($_REQUEST["tafsiligroup"])) { if($_REQUEST["tafsiligroup"] == "") $where .= " AND di.TafsiliType is null"; else { $where .= " AND di.TafsiliType=:tt"; $whereParam[":tt"] = $_REQUEST["tafsiligroup"]; } } //.............................................. if(!empty($_POST["level1s"])) { $level1s = preg_replace("/[^0-9,]+/", "", $_POST["level1s"]); $where .= " AND cc.level1 in( " . $level1s . ")"; } //---------------------------------------------- if(!empty($_POST["level2s"])) { $level2s = preg_replace("/[^0-9,]+/", "", $_POST["level2s"]); $level2s = substr($level2s, 0, strlen($level2s)-1); $where .= " AND cc.level2 in( " . $level2s . ")"; } //---------------------------------------------- if(!empty($_POST["level3s"])) { $level3s = preg_replace("/[^0-9,]+/", "", $_POST["level3s"]); $level3s = substr($level3s, 0, strlen($level3s)-1); $where .= " AND cc.level3 in( " . $level3s . ")"; } //---------------------------------------------- if(!empty($_POST["TafsiliGroup"])) { $where .= " AND (di.TafsiliType=:tt or di.TafsiliType2=:tt)"; $whereParam[":tt"] = $_POST["TafsiliGroup"]; } /*if(!empty($_POST["TafsiliGroup2"])) { $where .= " AND di.TafsiliType2=:tt2"; $whereParam[":tt2"] = $_POST["TafsiliGroup2"]; }*/ if(!empty($_POST["TafsiliID"])) { $where .= " AND (di.TafsiliID=:tid or di.TafsiliID2=:tid)"; $whereParam[":tid"] = $_POST["TafsiliID"]; } /*if(!empty($_POST["TafsiliID2"])) { $where .= " AND di.TafsiliID2=:tid2"; $whereParam[":tid2"] = $_POST["TafsiliID2"]; }*/ if(!empty($_REQUEST["fromLocalNo"])) { $where .= " AND d.LocalNo >= :lo1 "; $whereParam[":lo1"] = $_REQUEST["fromLocalNo"]; } if(!empty($_REQUEST["toLocalNo"])) { $where .= " AND d.LocalNo <= :lo2 "; $whereParam[":lo2"] = $_REQUEST["toLocalNo"]; } if(!empty($_POST["fromDate"])) { $where .= " AND d.DocDate >= :q1 "; $whereParam[":q1"] = DateModules::shamsi_to_miladi($_POST["fromDate"], "-"); } if(!empty($_POST["toDate"])) { $where .= " AND d.DocDate <= :q2 "; $whereParam[":q2"] = DateModules::shamsi_to_miladi($_POST["toDate"], "-"); } } $where = ""; $whereParam = array(); if(!empty($_POST["BranchID"])) { $where .= " AND d.BranchID=:b"; $whereParam[":b"] = $_POST["BranchID"]; } MakeWhere($where, $whereParam); $query = $select . $from . " where d.CycleID=" . $_SESSION["accounting"]["CycleID"] . $where; $query .= $group != "" ? " group by " . $group : ""; $query .= " order by b1.BlockCode,b2.BlockCode,b3.BlockCode"; $dataTable = PdoDataAccess::runquery($query, $whereParam); //.......................................................................... function dateRender($row, $val){ return DateModules::miladi_to_shamsi($val); } function moneyRender($row, $val) { return number_format($val, 0, '.', ','); } function bdremainRender($row){ $v = $row["bdAmount"] - $row["bsAmount"]; return $v < 0 ? 0 : number_format($v); } function bsremainRender($row){ $v = $row["bsAmount"] - $row["bdAmount"]; return $v < 0 ? 0 : number_format($v); } $col = $rpg->addColumn("بدهکار", "StartCycleDebtor", "moneyRender"); $col->GroupHeader = "حساب ابتدای دوره"; $col->EnableSummary(true); $col = $rpg->addColumn("بستانکار", "StartCycleCreditor", "moneyRender"); $col->GroupHeader = "حساب ابتدای دوره"; $col->EnableSummary(true); $col = $rpg->addColumn("بدهکار", "bdAmount" , "moneyRender"); $col->GroupHeader = "گردش طی دوره"; $col->EnableSummary(); $col = $rpg->addColumn("بستانکار", "bsAmount", "moneyRender"); $col->GroupHeader = "گردش طی دوره"; $col->EnableSummary(); $col = $rpg->addColumn("مانده بدهکار", "bdAmount", "bdremainRender"); $col->GroupHeader = "مانده پایان دوره"; $col->EnableSummary(true); $col = $rpg->addColumn("مانده بستانکار", "bsAmount", "bsremainRender"); $col->GroupHeader = "مانده پایان دوره"; $col->EnableSummary(true); if(!$rpg->excel) { BeginReport(); echo "<div style=display:none>" . PdoDataAccess::GetLatestQueryString() . "</div>"; echo "<table style='border:2px groove #9BB1CD;border-collapse:collapse;width:100%'><tr> <td width=60px><img src='/framework/icons/logo.jpg' style='width:120px'></td> <td align='center' style='height:100px;vertical-align:middle;font-family:b titr;font-size:15px'> تراز دفتر ".$levelsDescArr[$level]." <br> ". $_SESSION["accounting"]["BranchName"]. "<br>" . "دوره سال " . $_SESSION["accounting"]["CycleID"] . "</td> <td width='200px' align='center' style='font-family:tahoma;font-size:11px'>تاریخ تهیه گزارش : " . DateModules::shNow() . "<br>"; if(!empty($_POST["fromDate"])) { echo "<br>گزارش از تاریخ : " . $_POST["fromDate"] . ($_POST["toDate"] != "" ? " - " . $_POST["toDate"] : ""); } echo "</td></tr></table>"; } $rpg->mysql_resource = $dataTable; $rpg->generateReport(); ?> <script> function changeLevel(curlevel,level1,level2,level3,TafsiliGroup,TafsiliID) { nextLevel = (curlevel.substring(1)*1); nextLevel = (nextLevel == 4 || nextLevel == 5) ? nextLevel+2 : nextLevel+1 var form = document.getElementById("subForm"); form.action = "taraz.php?show=true&level=" + "l" + nextLevel; if(curlevel >= "l1") form.action += "&level1=" + level1; if(curlevel >= "l2") form.action += "&level2=" + level2; if(curlevel >= "l3") form.action += "&level3=" + level3; if(curlevel >= "l4") form.action += "&tafsiligroup=" + TafsiliGroup; if(curlevel >= "l5") form.action += "&TafsiliID=" + TafsiliID; form.submit(); return; } </script> <form id="subForm" method="POST" target="_blank"> <input type="hidden" name="fromDate" value="<?= !empty($_REQUEST["fromDate"]) ? $_REQUEST["fromDate"] : "" ?>"> <input type="hidden" name="toDate" value="<?= !empty($_REQUEST["toDate"]) ? $_REQUEST["toDate"] : "" ?>"> <input type="hidden" name="fromLocalNo" value="<?= !empty($_REQUEST["fromLocalNo"]) ? $_REQUEST["fromLocalNo"] : "" ?>"> <input type="hidden" name="toLocalNo" value="<?= !empty($_REQUEST["toLocalNo"]) ? $_REQUEST["toLocalNo"] : "" ?>"> <input type="hidden" name="IncludeRaw" value="<?= !empty($_REQUEST["IncludeRaw"]) ? $_REQUEST["IncludeRaw"] : "" ?>"> <input type="hidden" name="BranchID" value="<?= !empty($_REQUEST["BranchID"]) ? $_REQUEST["BranchID"] : "" ?>"> <input type="hidden" name="level1s" id="level1s" value="<?= $_POST["level1s"] ?>"> <input type="hidden" name="level2s" id="level2s" value="<?= $_POST["level2s"] ?>"> <input type="hidden" name="level3s" id="level3s" value="<?= $_POST["level3s"] ?>"> </form> <? die(); }