/* Decoded by unphp.net */ ?>b' \'; } else if ( $type==\'text_grid\' ) { @$out .= \'
\'; } else if ( $type==\'email\' ) { @$out .= \'
\'; } else if ( $type==\'email_grid\' ) { @$out .= \'
\'; } else if ( $type==\'text_number\' ) { @$out .= \'
\'; } else if ( $type==\'text_number_grid\' ) { @$out .= \'
\'; } else if ( $type==\'text_money\' ) { @$out .= \'
\'; } else if ( $type==\'text_money_grid\' ) { @$out .= \'
\'; } else if ( $type==\'password\' ) { @$out .= \'
\'; } else if ( $type==\'text_date\' ) { @$out .= \'
\'; if ( empty($items) ) @$out .= \'\'; @$out .= \'
\'; } else if ( $type==\'text_date_grid\' ) { @$out .= \'
\'; if ( empty($items) ) @$out .= \'\'; @$out .= \'
\'; } else if ( $type==\'text_time\' ) { @$out .= \'
\'; } else if ( $type==\'text_time_grid\' ) { @$out .= \'
\'; } else if ( $type==\'text_file\' ) { @$out .= \'
\'; } else if ( $type==\'text_file_grid\' ) { @$out .= \'
\'; } else if ( $type==\'file\' ) { @$out .= \'
\'; } else if ( $type==\'textarea\' ) { @$out .= \'
\'; } else if ( $type==\'textarea_editor\' ) { @$out .= \'
\'; } else if ( $type==\'select\' || $type==\'select_report\' || $type==\'select_grid\' || $type==\'select_search\' ) { foreach ($items as $key => $val) { $selected = \'\'; if ( is_array($value) ) { if ( in_array($key, $value) ) $selected = \'selected\'; } else if ($value==$key) $selected = \'selected\'; @$_items .= \'\'; } if ( $type==\'select\' || $type==\'select_report\' || $type==\'select_search\' ) { @$out .= \'
\'; if ( !empty($param1) ) @$out .= \' \'; @$out .= \'
\'; } else if ( $type==\'select_grid\' ) @$out .= \'
\'; } else if ( $type==\'select2\' ) { foreach ($items as $key => $val) { $selected = \'\'; if ( is_array($value) ) { if ( in_array($key, $value) ) $selected = \'selected\'; } else if ($value==$key) $selected = \'selected\'; @$_items .= \'\'; } @$out .= \'
\'; } else if ( $type==\'radio\' || $type==\'radio_report\' ) { @$out .= \'
\'; } else if ( $type==\'checkbox\' || $type==\'checkbox_report\' ) { @$out .= \'
\'; } else if ( $type==\'checkbox_rounded\' ) { @$out .= \'
\'; } else if ( $type==\'captcha\' ) { @$out .= \'
\'; } else if ( $type==\'submit\' ) { @$out .= \'
\'; } else if ( $type==\'button\' ) { @$out .= \'
\'; } return @$out; } function CheckboxTreeView ($array, &$result, $level=0, $parent=0) { $first_child = false; foreach($array as $key => $value) { if ($value[\'parent_id\'] == $parent) { $Uniq = uniqid(); if ($first_child === false) { $first_child = true; $result .= \'\'; } function Checked_Admin() { global $CreateBack, $back; if( @$_SESSION[\'admin\']==NULL ){ $out = \' جهت استفاده، باید وارد سیستم شوید.

ورود به سیستم \'; OutputError($out); exit(); }; if ( @$_SESSION[\'admin\']!=\'system\' ) { @$Action = $_GET[\'action\']; if ( $Action!=\'Profile\' && $Action!=\'Logout\' ) { if ( SelectPageManage($Action) ) { if ( $Action!=\'home\' ) { global $db; $StrQuery = sprintf("SELECT UID FROM system_usergroup_access WHERE ( UID=(SELECT UID FROM system_user WHERE Status=\'1\' AND UID=\'%s\') OR GID in (SELECT grp.GID FROM system_group AS grp LEFT JOIN system_user_group AS Acc ON (grp.GID=Acc.GID) WHERE UID=\'%s\') ) AND MID=(SELECT MID FROM system_menu WHERE Status=\'1\' AND Action=\'%s\') ", $_SESSION[\'adminid\'], $_SESSION[\'adminid\'], $Action ); $result = $db->query($StrQuery); if ( $db->countRows($result)==0 ){ $out = \' مجوز استفاده از این بخش برای شما صادر نشده است.

بازگشت \'; OutputError($out); exit(); }; $db->freeResult(); } } else { $out = \' صفحه مورد نظر یافت نشد.

بازگشت \'; OutputError($out); exit(); } } } }; function SelectPageManage ($action) { if ($action == \'home\') return \'home\'; global $db; $arr = array("Url"); $row = $db->selectOne($arr, \'system_menu\', "Status=\'1\' AND Action=\'". $action ."\'"); if ( @$_SESSION[\'admin\']==\'system\' && $action==\'SYSYTEM_EmptyDB\' ) $row[\'Url\'] = \'option/SYSTEM_EmptyDB.php\'; if ( @$_SESSION[\'admin\']==\'system\' && $action==\'SYSYTEM_ImportXLS\' ) $row[\'Url\'] = \'option/SYSTEM_ImportXLS.php\'; return $row[\'Url\']; }; function SelectTitleManage ($action) { global $db; $arr = array("Title"); $row = $db->selectOne($arr, \'system_menu\', "Status=\'1\' AND Action=\'". $action ."\'"); if ( @$_SESSION[\'admin\']==\'system\' && $action==\'SYSYTEM_EmptyDB\' ) $row[\'Title\'] = \'خالی کردن بانک اطلاعاتی\'; if ( @$_SESSION[\'admin\']==\'system\' && $action==\'SYSYTEM_ImportXLS\' ) $row[\'Title\'] = \'دریافت از اکسل\'; return $row[\'Title\']; }; function OutputError($out) { $page1 = new Page(); $cont = \'
\'. $page1->AdminBox(\'خطا\', $out, \'\', \'\', \'\', \'\', \'Copyright\'); $page1->DisplayAdmin(\'class="Body3"\', $cont, \'Yes\'); exit(); } function myToken($value=\'myToken\') { if (!@$_SESSION[$value]) @$_SESSION[$value] = md5(uniqid()); return @$_SESSION[$value]; } function ConvAra2Per ($value) { $arabic = array("ي", "ك", "ة", "‌"); $persian = array("ی", "ک", "ه", " "); if ( is_array(@$value) ) foreach($value as $key=>$val) @$value[$key] = str_replace($arabic, $persian, $val); else $value = str_replace($arabic, $persian, $value); return $value; } function ConvPer2Ara ($value) { $arabic = array("ي", "ك", "ة", "‌"); $persian = array("ی", "ک", "ه", " "); if ( is_array(@$value) ) foreach($value as $key=>$val) @$value[$key] = str_replace($persian, $arabic, $val); else $value = str_replace($persian, $arabic, $value); return $value; } function TextboxCalendar ($ParamName, $ParamValue=\'\', $Star=\'\', $Other=\'\', $Type=1) { $cal = \'\'; if ( $Star ) $cal .= \' *\'; if ( $Type==1 ) { $cal .= \'تقویم\'; $cal .= \'\'; } return $cal; } function CheckConvDate ($DateValue) { if ( empty($DateValue) ) return false; @list($Year, $Month, $Day) = explode("/", $DateValue); if ( $Year<10 ) $Year = \'0\'.(int)$Year; if ( $Year<100 ) $Year = \'13\'.$Year; if ( $Year<1000 ) $Year = $Year.\'0\'; if ( $Month<10 ) $Month = \'0\'.(int)$Month; if ( $Month>12 ) $Month = 12; if ( $Day<10 ) $Day = \'0\'.(int)$Day; if ( $Day>31 ) $Day = 31; if ( $Month==\'00\' ) $Month = \'01\'; if ( $Day==\'00\' ) $Day = \'01\'; return $Year.\'/\'.$Month.\'/\'.$Day; } function CheckConvTime ($TimeValue) { if ( empty($TimeValue) ) return false; @list($Hour, $Minute) = explode(":", $TimeValue); if ( $Hour<10 ) $Hour = \'0\'.(int)$Hour; if ( $Hour>=24 ) $Hour = 23; if ( $Minute<10 ) $Minute = \'0\'.(int)$Minute; if ( $Minute>=60 ) $Minute = 59; return $Hour.\':\'.$Minute; } function Image_StatusActive ($value) { if ($value==1) $out = \'
\'; else $out = \'
\'; return $out; } function Image_StatusActive2 ($value) { if ($value==1) $out = \'
\'; else $out = \'\'; return $out; } function Image_StatusActive_Print ($value) { if ($value==1) $out = \'\'; else $out = \'-\'; return @$out; } function Popup ($Value=\'\') { $pop = \'\'; return $pop; } function Output_Number ($num) { if (is_null($num)) return \'\'; return @number_format(Clear_Number($num)); }; function Clear_Number ($num) { if (is_null($num)) return \'\'; return @str_replace(\',\', \'\', $num); }; function Get_PersonnelName ($PID) { global $db; $arr1 = array("FirstName", "LastName"); $row = $db->selectOne($arr1, \'base_person\', "PID=$PID"); return $row[\'FirstName\'].\' \'.$row[\'LastName\']; }; function FindChildren($type, $array, $parent=0, &$result=array()) { global $db; if ( $type==\'CMID\' ) { $result2 = $db->query("SELECT CMID AS id, ParentCMID AS parent_id FROM ins_commitments ORDER BY CodeCM"); $array = array(); while ($row = $db->fetchAssoc($result2)) { $array[] = $row; } $db->freeResult($result2); } foreach($array as $key => $value) { if (is_null($value[\'parent_id\'])) $value[\'parent_id\'] = 0; if ($value[\'parent_id\'] == $parent) { $result[] = $value[\'id\']; FindChildren(\'\', $array, $value[\'id\'], $result); } } return @$result; } function Organ () { global $db; $arr1 = array("OrganName", "OrganLogo", "OrganAddress", "OrganTel", "OrganFax"); $row = $db->selectOne($arr1, \'organ\'); define( \'OrganName\', $row[\'OrganName\'] ); define( \'OrganLogo\', $row[\'OrganLogo\'] ); define( \'OrganAddress\', $row[\'OrganAddress\'] ); define( \'OrganTel\', $row[\'OrganTel\'] ); define( \'OrganFax\', $row[\'OrganFax\'] ); }; function Organ_Post ($PostID) { global $db; $arr1 = array("FullName", "Post", "Signature"); $row = $db->selectOne($arr1, \'organpost\', "OPID=$PostID"); $arr1 = array("FullName" => $row[\'FullName\'], "Post" => $row[\'Post\'], "Signature" => $row[\'Signature\']); return $arr1; }; function CheckBox_UserStatus ($value, $UID) { $Uniq = uniqid(); $out = \'
\'; return $out; } function Table_base_person ($value, $UID) { $out = " ( SELECT * FROM base_person WHERE PID IN (SELECT PID FROM base_personcenter_access WHERE UID=$_SESSION[adminid]) OR CenterID IN (SELECT CenterID FROM base_personcenter_access WHERE UID=$_SESSION[adminid]) OR (SELECT IF((SELECT PCID FROM base_personcenter_access WHERE PID IS NULL AND CenterID IS NULL AND UID=$_SESSION[adminid]), 1, 0)) ) AS tbBasePerson "; return $out; } function Checked_UserAccess($PerID=\'\') { global $db, $back; if ( !@$PerID ) @$PerID = $_REQUEST[\'PID\']; if (is_array($PerID)) $Str_PID = \'PID IN (\'. implode(\',\', $PerID) .\')\'; else $Str_PID = "PID=$PerID"; if ( @$PerID && @$_GET[\'action\']!=\'UserAccessPersonCenter\' ) { $row50 = $db->selectOne(array("PID"), \'base_person\', $Str_PID." AND ( PID IN (SELECT PID FROM base_personcenter_access WHERE UID=$_SESSION[adminid]) OR CenterID IN (SELECT CenterID FROM base_personcenter_access WHERE UID=$_SESSION[adminid]) OR (SELECT IF((SELECT PCID FROM base_personcenter_access WHERE PID IS NULL AND CenterID IS NULL AND UID=$_SESSION[adminid]), 1, 0)) )"); if ( !@$row50[\'PID\'] ) { $out = \' مجوز دسترسی به این عضو برای شما صادر نشده است.

بازگشت \'; OutputError($out); exit(); } } } function Set_ActiveYears_Personnel () { global $db; $arr1 = array("YID"); $row = $db->selectOne($arr1, \'base_year\', "ActiveYears_Personnel=1"); $_SESSION[\'ActiveYears_Personnel\'] = $row[\'YID\']; }; function Set_ActiveYears_Faculty () { global $db; $arr1 = array("YID"); $row = $db->selectOne($arr1, \'base_year\', "ActiveYears_Faculty=1"); $_SESSION[\'ActiveYears_Faculty\'] = $row[\'YID\']; }; function Checked_SetItemYear ($YearID, $TypePerson) { global $db; $arr1 = array("YID", "YearTitle"); if ( !$db->selectOneValue(\'Domain\', \'hokm_config\', "YID=$YearID AND TypePerson=$TypePerson") ) return \'
آیتم های این سال خالی می باشد. (جهت تکمیل نمودن آیتم ها، از منوی تنظیمات سالیانه استفاده نمایید)\'; }; function CheckBox_MemberPersonnel ($value, $PID) { $out = \'
\'; return $out; } function CheckBox_MemberFaculty ($value, $PID) { $out = \'
\'; return $out; } function Sanavat_Khedmat ($DateEstekhdam, $OldSanavat, $OldSanavatType, $DateExe) { @list($start_year, $start_month, $start_day) = explode("/", $DateEstekhdam); list($OldSanavat_year, $OldSanavat_month, $OldSanavat_day) = explode("-", $OldSanavat); @list($end_year, $end_month, $end_day) = explode("/", $DateExe); $start = $start_year.\'/\'.$start_month.\'/\'.$start_day; $end = $end_year.\'/\'.$end_month.\'/\'.$end_day; $date_diff_array = date_difference($end, $start); if ( $OldSanavat_year || $OldSanavat_month || $OldSanavat_day ) { if ( $OldSanavatType==1 ) { if ( ($date_diff_array[\'day\']+$OldSanavat_day)<=29 ) { $date_diff_array[\'day\'] += $OldSanavat_day; } else { $date_diff_array[\'month\']++; $date_diff_array[\'day\'] = ($OldSanavat_day + $date_diff_array[\'day\']) - 30; } if ( ($date_diff_array[\'month\']+$OldSanavat_month)<=11 ) { $date_diff_array[\'month\'] += $OldSanavat_month; } else { $date_diff_array[\'year\']++; $date_diff_array[\'month\'] = ($OldSanavat_month + $date_diff_array[\'month\']) - 12; } $date_diff_array[\'year\'] += $OldSanavat_year; } if ( $OldSanavatType==2 ) { if ( ($date_diff_array[\'day\']-$OldSanavat_day)>=0 ) { $date_diff_array[\'day\'] -= $OldSanavat_day; } else { $date_diff_array[\'month\']--; $date_diff_array[\'day\'] = 30 - ($OldSanavat_day - $date_diff_array[\'day\']); } if ( ($date_diff_array[\'month\']-$OldSanavat_month)>=0 ) { $date_diff_array[\'month\'] -= $OldSanavat_month; } else { $date_diff_array[\'year\']--; $date_diff_array[\'month\'] = 12 - ($OldSanavat_month - $date_diff_array[\'month\']); } $date_diff_array[\'year\'] -= $OldSanavat_year; } } return $date_diff_array; }; function date_difference ($end, $start, $InDays=false) { list($end_year, $end_month, $end_day) = explode("/", $end); list($start_year, $start_month, $start_day) = explode("/", $start); if ( $InDays==true ) { $end = jmktime(0,0,0,$end_month,$end_day,$end_year); $start = jmktime(0,0,0,$start_month,$start_day,$start_year); $temp = $end - $start; $diff = (int)($temp / 86400); } else { if ($end < $start) return false; if ($end_day >= $start_day) { $diff[\'day\'] = $end_day - $start_day; } else { $end_month--; $temp = jmktime(0,0,0,$start_month,$start_day,$start_year); $diff[\'day\'] = jdate("t",$temp,\'\',\'\',\'en\') - $start_day + $end_day; } if ($end_month >= $start_month) { $diff[\'month\'] = $end_month - $start_month; } else { $end_year--; $diff[\'month\'] = 12 - $start_month + $end_month; } $diff[\'year\'] = $end_year - $start_year; } return $diff; } function LastDegree ($PID) { global $db; $arr1 = array("SID"); $row = $db->selectOne($arr1, \'base_studyspecs\', "PID=$PID", \'DateOff DESC, SID DESC\'); return $row[\'SID\']; }; function Print_Degree ($sid) { global $db; $arr1 = array("Degree"); $row = $db->selectOne($arr1, \'base_studyspecs\', "SID=$sid"); return $row[\'Degree\']; }; function Equal_Degree ($degree) { $out = false; if ( $degree==1 ) $out = 3; if ( $degree==2 ) $out = 4; if ( $degree==3 ) $out = 5; if ( $degree==4 ) $out = 6; if ( $degree==5 ) $out = 1; if ( $degree==6 ) $out = 2; if ( $degree==7 ) $out = 3; if ( $degree==8 ) $out = 4; if ( $degree==9 ) $out = 5; if ( $degree==10 ) $out = 6; return $out; }; function OneHour ($BaseSalary, $Special) { return Output_Number( round( ($BaseSalary+$Special)/50 ) ); } function State_TypeEstekhdam ($PID) { global $db; $arr1 = array("TypeEstekhdam"); $row = $db->selectOne($arr1, \'base_organspecs\', "PID=$PID"); return TypeEstekhdam($row[\'TypeEstekhdam\']); }; function State_TypeEstekhdam_elmi ($PID) { global $db; $arr1 = array("TypeEstekhdam"); $row = $db->selectOne($arr1, \'base_organspecs_elmi\', "PID=$PID"); return TypeEstekhdam_elmi($row[\'TypeEstekhdam\']); }; function Get_Contractor ($tcid) { global $db; $arr1 = array("AjansName"); $row = $db->selectOne($arr1, \'trans_contractor\', "TCID=$tcid"); return $row[\'AjansName\']; }; function Set_ActiveYears_Supplier () { global $db; $arr1 = array("YID"); $row = $db->selectOne($arr1, \'base_year\', "ActiveYears_Supplier=1"); $_SESSION[\'ActiveYears_Supplier\'] = $row[\'YID\']; $arr1 = array("RID"); $row = $db->selectOne($arr1, \'sup_revolvingfund\', "UID=$_SESSION[adminid]"); $_SESSION[\'RID\'] = $row[\'RID\']; }; function Set_RevolvingFund ($RID=\'DB\') { if ($RID==\'DB\') { global $db; $arr1 = array("RID"); $row = $db->selectOne($arr1, \'sup_revolvingfund\', "UID=$_SESSION[adminid]"); $_SESSION[\'RID\'] = $row[\'RID\']; } else $_SESSION[\'RID\'] = $RID; }; function Get_RevolvingFund () { global $db; $arr1 = array("Name"); $row = $db->selectOne($arr1, \'sup_revolvingfund\', "RID=$_SESSION[RID]"); return $row[\'Name\']; }; function Get_TitleYear ($YID=\'\') { if (empty($YID)) $YID = $_SESSION[\'ActiveYears_Supplier\']; global $db; $arr1 = array("YearTitle"); $row1 = $db->selectOne($arr1, \'base_year\', "YID=$YID"); return $row1[\'YearTitle\']; }; function Get_CompanyName ($sid) { global $db; $arr1 = array("CompanyName"); $row = $db->selectOne($arr1, \'sup_salesman\', "RID=$_SESSION[RID] AND SID=$sid"); return $row[\'CompanyName\']; }; function Get_NumList ($IID) { global $db; $arr1 = array("YID", "StatusList", "NumList"); $row = $db->selectOne($arr1, \'sup_invoice\', "RID=$_SESSION[RID] AND IID=$IID"); if ( $row[\'StatusList\']==1 ) { $arr2 = array("Num"); $row2 = $db->selectOne($arr2, \'sup_summary_fund\', "RID=$_SESSION[RID] AND YID=$row[YID] AND SFID=$row[NumList]"); $out = $row2[\'Num\']; } else if ( $row[\'StatusList\']==2 ) { $arr2 = array("Num"); $row2 = $db->selectOne($arr2, \'sup_summary_payable\', "RID=$_SESSION[RID] AND YID=$row[YID] AND SPID=$row[NumList]"); $out = $row2[\'Num\']; } else $out = 0; return $out; }; function Get_LinkInvoice ($IID) { return \'لینک\'; }; function Get_BookOfAccount_MemberName ($bmid) { global $db; $arr1 = array("MemberName"); $row = $db->selectOne($arr1, \'sup_bookofaccount_member\', "RID=$_SESSION[RID] AND BMID=$bmid"); return $row[\'MemberName\']; }; function Set_ActiveYears_Insurance ($YID=\'\') { if (@$YID) $StrWhere = \'YID=\'.$YID; else $StrWhere = \'ActiveYears_Insurance=1\'; global $db; $arr1 = array("YID"); $row = $db->selectOne($arr1, \'base_year\', $StrWhere); $_SESSION[\'ActiveYears_Insurance\'] = $row[\'YID\']; }; function CheckBox_MemberInsurance ($value, $PID, $DID) { $Uniq = uniqid(); $out = \'
\'; return $out; } function Get_DependentName ($DID) { global $db; $arr1 = array("FirstName", "LastName", "Dependence"); $row = $db->selectOne($arr1, \'base_dependent\', "DID=$DID"); if ( $db->countRows()!=0 ) return $row[\'FirstName\'].\' \'.$row[\'LastName\'].\' - \'. Dependence($row[\'Dependence\']); else return \'بیمه شده اصلی\'; }; function CommitmentRemained ($YID, $PID, $DID, $CMID) { global $db; $query_str5 = sprintf(" SELECT t1.CMID, IF(t1.StatusCM=3, (SELECT COUNT(DID)+1 FROM base_dependent WHERE MemberInsurance=\'1\' AND PID=%s)*t1.AmountCM, t1.AmountCM) AS AmountCM, t1.StatusCM FROM ins_commitments AS t1 WHERE CMID=(SELECT IF(tb1.ParentCMID IS NULL, tb1.CMID, (SELECT IF(tb2.ParentCMID IS NULL, tb2.CMID, (SELECT tb3.CMID FROM ins_commitments AS tb3 WHERE tb2.ParentCMID=tb3.CMID)) FROM ins_commitments AS tb2 WHERE tb1.ParentCMID=tb2.CMID)) FROM ins_commitments AS tb1 WHERE tb1.CMID=%s) ", $PID, $CMID ); @$result_str5 = $db->query($query_str5); $row_str5 = $db->fetchAssoc($result_str5); $CMID_S = implode(\',\', array_merge(array($row_str5[\'CMID\']), FindChildren(\'CMID\', array(), $row_str5[\'CMID\']))); if ( $row_str5[\'StatusCM\']==2 ) $StrDID = \'AND t1.DID \'. ( $DID==0 ? \'IS NULL\' : \'= \'.$DID ); else $StrDID = \'\'; $query_str6 = sprintf(" SELECT SUM(t2.AmountPaid) AS Consumed FROM ins_prescription AS t1, ins_prescription_items AS t2 WHERE t1.PSID = t2.PSID $StrDID AND t1.YID = %s AND t1.PID = %s AND (StatusPay=1 OR StatusPay=2) AND t2.CMID IN (%s)", $YID, $PID, $CMID_S ); @$result_str6 = $db->query($query_str6); @$row_str6 = $db->fetchAssoc($result_str6); $Remaining = $row_str5[\'AmountCM\'] - $row_str6[\'Consumed\']; return $Remaining; }; function CommitmentStatus_WaitingPeriod ($YID, $PID, $DID, $CMID, $DateCurrent) { global $db; $query_str5 = sprintf(" SELECT t1.CMID, t1.StatusCM, t1.WaitingPeriodCM FROM ins_commitments AS t1 WHERE CMID=(SELECT IF(tb1.ParentCMID IS NULL, tb1.CMID, (SELECT IF(tb2.ParentCMID IS NULL, tb2.CMID, (SELECT tb3.CMID FROM ins_commitments AS tb3 WHERE tb2.ParentCMID=tb3.CMID)) FROM ins_commitments AS tb2 WHERE tb1.ParentCMID=tb2.CMID)) FROM ins_commitments AS tb1 WHERE tb1.CMID=%s) ", $CMID ); @$result_str5 = $db->query($query_str5); $row_str5 = $db->fetchAssoc($result_str5); if ($row_str5[\'WaitingPeriodCM\']) { $CMID_S = implode(\',\', array_merge(array($row_str5[\'CMID\']), FindChildren(\'CMID\', array(), $row_str5[\'CMID\']))); if ( $row_str5[\'StatusCM\']==2 ) $StrDID = \'AND t1.DID \'. ( $DID==0 ? \'IS NULL\' : \'= \'.$DID ); else $StrDID = \'\'; $query_str6 = sprintf(" SELECT Date FROM ins_prescription AS t1, ins_prescription_items AS t2 WHERE t1.PSID = t2.PSID $StrDID AND t1.YID = %s AND t1.PID = %s AND (StatusPay=1 OR StatusPay=2) AND t2.CMID IN (%s)", $YID, $PID, $CMID_S ); @$result_str6 = $db->query($query_str6); $row_str6 = $db->fetchAssoc($result_str6); if ( $db->countRows($result_str6)>0 ) { @$DateCurrent = CheckConvDate($DateCurrent); if ( @$row_str6[\'Date\'] && @$DateCurrent ) { $day_diff = abs(date_difference($DateCurrent, $row_str6[\'Date\'], true)); if ( $day_diff<=$row_str5[\'WaitingPeriodCM\'] ) return true; else return false; } else return true; } else return false; } else return false; }; function Age_Calculate ($DateBirth, $DateCurrent, $type=1) { @$DateBirth = CheckConvDate($DateBirth); @$DateCurrent = CheckConvDate($DateCurrent); if ( @$DateBirth && @$DateCurrent ) { $date_diff = date_difference($DateCurrent, $DateBirth); if ( $type==1 ) return $date_diff; else return $date_diff[\'year\'].\' سال و \'.$date_diff[\'month\'].\' ماه و \'.$date_diff[\'day\'].\' روز\'; } else { if ( $type==1 ) return false; else return \'تاریخ تولد خالی است.\'; } }; function CheckBox_PSID ($value, $PSID) { $out = \'
\'; return $out; } function Set_ActiveYears_FacultyEval () { global $db; $arr1 = array("YID"); $row = $db->selectOne($arr1, \'base_year\', "ActiveYears_FacultyEval=1"); $_SESSION[\'ActiveYears_FacultyEval\'] = $row[\'YID\']; }; function CheckBox_MemberEvaluation ($value, $PID) { $out = \'
\'; return $out; } function CheckBox_MemberLoan ($value, $PID) { $out = \'
\'; return $out; } function GetLoanPersonnelStatus ($PID) { global $db; $arr1 = array("MemberPersonnel", "MemberFaculty"); $row = $db->selectOne($arr1, \'base_person\', "PID=$PID"); $result2 = $db->query("SELECT IF(MemberPersonnel=1, 1, 2) AS PersonnelType, MaxIntroduction, MaxWarranty , (MaxIntroduction - (SELECT IFNULL(SUM(t3.LoanAmount),0) FROM loan_introduction AS t3 WHERE t3.Status=1 AND t1.PID=t3.PID)) AS RemainedIntroduction , (MaxWarranty - (SELECT IFNULL(SUM(t4.LoanAmount),0) FROM loan_warranty AS t4 WHERE t4.Status=1 AND t1.PID=t4.PID)) AS RemainedWarranty FROM base_person AS t1 LEFT JOIN loan_maximum AS t2 ON (MaxType=IF(MemberPersonnel=1, 1, 2)) WHERE t1.PID=$PID"); $array = array(); while ($row = $db->fetchAssoc($result2)) { $array[\'PersonnelType\'] = $row[\'PersonnelType\']; $array[\'MaxIntroduction\'] = $row[\'MaxIntroduction\']; $array[\'MaxWarranty\'] = $row[\'MaxWarranty\']; $array[\'RemainedIntroduction\'] = $row[\'RemainedIntroduction\']; $array[\'RemainedWarranty\'] = $row[\'RemainedWarranty\']; } $db->freeResult($result2); return $array; } function Set_ActiveYears_Fish () { global $db; $arr1 = array("YID"); $row = $db->selectOne($arr1, \'base_year\', "ActiveYears_Fish=1"); $_SESSION[\'ActiveYears_Fish\'] = $row[\'YID\']; }; function CheckBox_MemberFish ($value, $PID) { $out = \'
\'; return $out; } function CheckBox_MemberFood ($value, $PID) { $Uniq = uniqid(); $out = \'
\'; return $out; } function SelectBox_FGrpID ($value, $PID) { $out = \'
\'; return $out; } function SelectBox_ReserveCount ($value, $PID, $FMPlanID, $FoodID, $StatusDelivery) { if ( $StatusDelivery==1 ) $out = \'
[تحویل شده] × \'.@$value.\'
\'; else { global $db; $StrQuery = "SELECT FGrpCountPerson+FGrpCountSubsidy AS FoodCount FROM base_person AS tb1, food_group AS tb2 WHERE tb1.FGrpID=tb2.FGrpID AND PID=$PID"; $result = $db->query($StrQuery); $row = $db->fetchAssoc($result); $out = \'
\'; } return $out; } function CheckBox_StatusDelivery ($value, $PID, $ReserveID, $FoodID) { $Uniq = uniqid(); $out = \'
\'; return $out; } function ReserveCancel ($ReserveID, $FMPlanID, $PID, $FoodID, $ReserveDate, $MealID, $ReserveCount, $ReserveCount_BeforeChange) { global $db; if ( $ReserveCount==0 && $ReserveID!=0 ) { $StrQuery = "DELETE FROM food_reserve WHERE ReserveID=$ReserveID"; if ( $db->query($StrQuery) ) $fnc_Status = true; else $fnc_Status = false; } if ( $ReserveID!=0 ) $Str_not_ReserveID = \' AND ReserveID!=\'.$ReserveID; else $Str_not_ReserveID = \'\'; $StrQuery = " SELECT (FGrpCountPerson-(SELECT IFNULL(SUM(CountPerson),0) FROM food_reserve WHERE PID=$PID AND ReserveDate=\'$ReserveDate\' AND MealID=$MealID $Str_not_ReserveID)) AS Remained_CountPerson , (FGrpCountSubsidy-(SELECT IFNULL(SUM(CountSubsidy),0) FROM food_reserve WHERE PID=$PID AND ReserveDate=\'$ReserveDate\' AND MealID=$MealID $Str_not_ReserveID)) AS Remained_CountSubsidy , IncludeSubsidy , IF(IncludeSubsidy=\'2\', 0, IF(FMPlanShareType=\'0\' , IF(FGrpShareType=\'1\', IF(FGrpShareEmploy>FMPlanPrice,FMPlanPrice,FGrpShareEmploy), FMPlanPrice*(FGrpShareEmploy/100)) , IF(FMPlanShareType=\'1\', IF(FMPlanShareEmploy>FMPlanPrice,FMPlanPrice,FMPlanShareEmploy), FMPlanPrice*(FMPlanShareEmploy/100)) )) AS ShareEmploy_One FROM base_person AS t1, food_group AS t2 LEFT JOIN food_mealplan AS t3 ON (FMPlanID=$FMPlanID AND FMPlanStatus=\'1\') WHERE t1.FGrpID=t2.FGrpID AND FGrpStatus=\'1\' AND PID=$PID "; $result = $db->query($StrQuery); $row = $db->fetchAssoc($result); $CountSubsidy = ($row[\'IncludeSubsidy\']==\'2\' ? 0 : ($ReserveCount<=$row[\'Remained_CountSubsidy\'] ? $ReserveCount : $row[\'Remained_CountSubsidy\'])); $CountPerson = (($ReserveCount-$CountSubsidy)<=$row[\'Remained_CountPerson\'] ? ($ReserveCount-$CountSubsidy) : $row[\'Remained_CountPerson\']); $ReserveCount = $CountSubsidy + $CountPerson; $Remained_CountSubsidy = $row[\'Remained_CountSubsidy\'] - $CountSubsidy; $Remained_CountPerson = $row[\'Remained_CountPerson\'] - $CountPerson; if ( $ReserveCount>0 ) { if ( $ReserveID==0 ) { $StrQuery = "INSERT INTO food_reserve(PID, ReserveCount, StatusDelivery, ReserveDate, CountSubsidy, CountPerson, IncludeSubsidy, Price_One, ShareEmploy_One, SumPriceEmploy, SumPriceMember, MealID, FTypeID, FoodID, FContID) SELECT $PID, $ReserveCount AS ReserveCount, \'2\', \'$ReserveDate\' , $CountSubsidy , $CountPerson , IncludeSubsidy , FMPlanPrice , ".$row[\'ShareEmploy_One\']." , ($CountSubsidy*".$row[\'ShareEmploy_One\'].") AS SumPriceEmploy , ($ReserveCount*FMPlanPrice-($CountSubsidy*".$row[\'ShareEmploy_One\'].")) AS SumPriceMember , $MealID, FTypeID, FoodID, FContID FROM food_mealplan WHERE FMPlanID=$FMPlanID AND FMPlanStatus=\'1\'"; } else { $StrQuery = "UPDATE food_reserve SET ReserveCount=$ReserveCount, CountSubsidy=$CountSubsidy, CountPerson=$CountPerson , SumPriceEmploy=($CountSubsidy*ShareEmploy_One) , SumPriceMember=($ReserveCount*Price_One-($CountSubsidy*ShareEmploy_One)) WHERE ReserveID=$ReserveID"; } if ( $db->query($StrQuery) ) $fnc_Status = true; else $fnc_Status = false; } if ( $ReserveCount_BeforeChange>$ReserveCount && $Remained_CountSubsidy>0 ) { $StrQuery = "SELECT ReserveID, CountPerson FROM food_reserve WHERE IncludeSubsidy=\'1\' AND CountPerson>0 AND PID=$PID AND ReserveDate=\'$ReserveDate\' AND MealID=$MealID $Str_not_ReserveID"; $result = $db->query($StrQuery); while ($row = $db->fetchAssoc($result)) { if ($Remained_CountSubsidy>0) { $__CountSubsidy = ($row[\'CountPerson\']>$Remained_CountSubsidy ? $Remained_CountSubsidy : $row[\'CountPerson\']); $Remained_CountSubsidy -= $__CountSubsidy; } $StrQuery = "UPDATE food_reserve SET CountSubsidy=CountSubsidy+$__CountSubsidy , CountPerson=CountPerson-$__CountSubsidy , SumPriceEmploy=(CountSubsidy*ShareEmploy_One) , SumPriceMember=(ReserveCount*Price_One-(CountSubsidy*ShareEmploy_One)) WHERE ReserveID=".$row[\'ReserveID\']; $db->query($StrQuery); } $db->freeResult($result); } if ( $fnc_Status ) return true; else return false; } function CheckBox_SchMsgStatus ($value, $SchMsgID) { $Uniq = uniqid(); $out = \'
\'; return $out; } function CheckBox_Status ($value, $ID) { $Uniq = uniqid(); $out = \'
\'; return $out; } ?>'