예제 #1
0
파일: forms.php 프로젝트: kotkotofey/eight
 function printTable($BaseDN, $Filter)
 {
     $BaseDN = iconv($GLOBALS['CHARSET_APP'], $GLOBALS['CHARSET_DATA'], $BaseDN);
     $Filter = iconv($GLOBALS['CHARSET_APP'], $GLOBALS['CHARSET_DATA'], $Filter);
     $ADAttributes = array_values($this->Attributes['name']);
     //Убрать дублирование
     foreach ($ADAttributes as $V) {
         if (strpos($V, ",")) {
             $ADAttributes = array_merge($ADAttributes, str_replace(" ", "", explode(",", $V)));
         }
     }
     @($SizeOf = sizeof($this->Attributes[name]));
     $LS = ldap_search($this->LC, $BaseDN, $Filter, $ADAttributes);
     //ldap_sort($this->LC, $LS, "name");
     if ($Entries = ldap_get_entries($this->LC, $LS)) {
         echo "<table class='sqltable' cellpadding='4'>";
         if ($Entries['count'] && $this->Head) {
             self::printHead();
         }
         //Сортировка
         //-----------------------------------------------------------------------------
         if ($this->SortColumn) {
             $SortName = self::getNameByTitle($this->SortColumn);
             $j = array_search($this->SortColumn, $this->Attributes['title']);
             $k = $this->Attributes['i'][$j];
             for ($i = 0; $i < $Entries['count']; $i++) {
                 if (strpos($SortName, ",")) {
                     $ArrSorted[$i] = "";
                     foreach (explode(",", $SortName) as $V) {
                         @($ArrSorted[$i] .= iconv($GLOBALS['CHARSET_DATA'], $GLOBALS['CHARSET_APP'], $Entries[$i][trim($V)][$k]));
                     }
                 } else {
                     //$Value=iconv($GLOBALS['CHARSET_DATA'], $GLOBALS['CHARSET_APP'], $Entries[$i][$SortName][$k]);
                     @($ArrSorted[$i] = iconv($GLOBALS['CHARSET_DATA'], $GLOBALS['CHARSET_APP'], $Entries[$i][$SortName][$k]));
                 }
                 //echo $ArrSorted[$i]."<br>";
                 switch ($this->Attributes['order_format'][$j]) {
                     case 'ad_def_full_name':
                         $ArrSorted[$i] = preg_replace("/([С‘A-zРђ-СЏ-]+[\\s]{1}[С‘A-zA-СЏ]{1}.)[\\s]{1}([С‘A-zРђ-СЏ-]+)/u", "\\2 \\1", $ArrSorted[$i]);
                         break;
                     case 'dd.mm.yyyy':
                         if (preg_match("/^[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}\$/", $ArrSorted[$i])) {
                             $e = explode(".", $ArrSorted[$i]);
                             $ArrSorted[$i] = mktime(0, 0, 0, $e[1], $e[0], $e[2]);
                             $ArrSorted[$i];
                         }
                         break;
                     case 'mm-dd':
                         if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}\$/", $ArrSorted[$i])) {
                             $e = explode("-", $ArrSorted[$i]);
                             $ArrSorted[$i] = mktime(0, 0, 0, $e[1], $e[2], 2000);
                             $ArrSorted[$i];
                         }
                         break;
                     case 'dd.mm':
                         if (preg_match("/^[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}\$/", $ArrSorted[$i])) {
                             $e = explode(".", $ArrSorted[$i]);
                             $ArrSorted[$i] = mktime(0, 0, 0, $e[1], $e[0], 2000);
                             $ArrSorted[$i];
                         }
                         break;
                 }
             }
             unset($SortName, $k);
             if (is_array(@$ArrSorted)) {
                 asort($ArrSorted);
                 $AS = array_keys($ArrSorted);
                 if ($this->SortType == "DESC") {
                     $AS = array_reverse($AS);
                 }
             }
         }
         //-----------------------------------------------------------------------------
         for ($i = 0; $i < $Entries['count']; $i++) {
             $n = $i + 1;
             if ($n % 2) {
                 $CssClass = 'even';
             } else {
                 $CssClass = 'odd';
             }
             echo "<tr class='" . $CssClass . "'>";
             if ($this->Numbering) {
                 echo "<td>" . $n . "</td>";
             }
             for ($j = 0; $j < $SizeOf; $j++) {
                 //-----------------------------------------------------------------------------
                 if ($this->SortColumn) {
                     if (strpos($this->Attributes['name'][$j], ",")) {
                         $Value = "";
                         foreach (explode(",", $this->Attributes['name'][$j]) as $V) {
                             @($Value .= self::convertValue($Entries[$AS[$i]][trim($V)][$this->Attributes['i'][array_search($ADAttributes[$j], $this->Attributes['name'])]]));
                         }
                     } else {
                         @($Value = self::convertValue($Entries[$AS[$i]][$this->Attributes['name'][$j]][$this->Attributes['i'][array_search($ADAttributes[$j], $this->Attributes['name'])]]));
                     }
                 } else {
                     if (strpos($this->Attributes['name'][$j], ",")) {
                         $Value = "";
                         foreach (explode(",", $this->Attributes['name'][$j]) as $V) {
                             $Value .= self::convertValue($Entries[$i][trim($V)][$this->Attributes['i'][array_search($ADAttributes[$j], $this->Attributes['name'])]]);
                         }
                     } else {
                         $Value = self::convertValue($Entries[$i][$this->Attributes['name'][$j]][$this->Attributes['i'][array_search($ADAttributes[$j], $this->Attributes['name'])]]);
                     }
                 }
                 //-----------------------------------------------------------------------------
                 //Проверка применимости замены на рег. выражениях
                 //-----------------------------------------------------------------------------
                 if (is_array(@$this->PregReplace[$this->Attributes[title][$j]]['conditions'])) {
                     foreach (@$this->PregReplace[$this->Attributes[title][$j]]['conditions'] as $key => $value) {
                         @($this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = true);
                         //$PreviousFlag=true;
                         foreach (@$this->PregReplace[$this->Attributes[title][$j]]['conditions'][$key] as $key1 => $value1) {
                             foreach (@$this->PregReplace[$this->Attributes[title][$j]]['conditions'][$key][$key1] as $key2 => $value2) {
                                 if ($this->SortColumn) {
                                     @($ConditionValue = self::convertValue($Entries[$AS[$i]][$key1][$this->Attributes['i'][array_search($key1, $this->Attributes['name'])]]));
                                 } else {
                                     $ConditionValue = self::convertValue($Entries[$i][$key1][$this->Attributes['i'][array_search($key1, $this->Attributes['name'])]]);
                                 }
                                 switch ($key2) {
                                     case "=":
                                         //echo $ConditionValue."--------".$value2."<br>";
                                         if ($ConditionValue == $value2) {
                                             @($this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && true);
                                         } else {
                                             @($this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && false);
                                         }
                                         break;
                                     case "!=":
                                         if ($ConditionValue != $value2) {
                                             @($this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && true);
                                         } else {
                                             @($this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && false);
                                         }
                                         break;
                                     case "in_range_date":
                                         if (preg_match("/^[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}\\s-\\s[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}\$/", $ConditionValue)) {
                                             $e = explode(" - ", $ConditionValue);
                                             if (Time::getTimeOfDMYHI($e[1]) >= $value2 && Time::getTimeOfDMYHI($e[0]) <= $value2) {
                                                 $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && true;
                                             } else {
                                                 $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && false;
                                             }
                                         } else {
                                             @($this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] && false);
                                         }
                                         break;
                                     default:
                                         $this->PregReplace[$this->Attributes[title][$j]]['apply'][$key] = true;
                                 }
                             }
                         }
                     }
                     unset($key, $key1, $key2, $value, $value1, $value2, $ConditionValue);
                 }
                 //-----------------------------------------------------------------------------
                 @($Value = self::PregReplace($this->Attributes[title][$j], $Value));
                 //$Value=self::LogicReplace($this->Attributes[title][$j], $Value);
                 if (!$this->Attributes['notshow'][$j]) {
                     echo "<td>";
                     echo $Value;
                     echo "</td>";
                 }
             }
             echo "</tr>";
             unset($Value);
         }
         echo "</table>";
     }
 }
예제 #2
0
파일: staff.php 프로젝트: smale3/eight
	public static function getVacationState($StDate, $EndDate)
		{
		if($StDate&&$EndDate)
			{
			$end_time=Time::getTimeOfDMYHI($EndDate, $GLOBALS['VAC_DATE_FORMAT']);
			$start_time=Time::getTimeOfDMYHI($StDate, $GLOBALS['VAC_DATE_FORMAT']);
			$time=time();
			if(($end_time>=$time)&&($start_time<=$time))
				return 0;	// в отпуске
			else 
				{
				if($start_time>$time)
					return 1;	// отпуск еще предстоит
				else
					return -1;	// отпуск закончился
				}

			}
		}
예제 #3
0
파일: staff.php 프로젝트: kotkotofey/eight
 public static function getVacationState($StDate, $EndDate)
 {
     if ($StDate && $EndDate) {
         $end_time = Time::getTimeOfDMYHI($EndDate, $GLOBALS['VAC_DATE_FORMAT']);
         $start_time = Time::getTimeOfDMYHI($StDate, $GLOBALS['VAC_DATE_FORMAT']);
         $time = time();
         if ($end_time >= $time && $start_time <= $time) {
             return 0;
         } else {
             if ($start_time > $time) {
                 return 1;
             } else {
                 return -1;
             }
             // отпуск закончился
         }
     }
 }
예제 #4
0
<?php

require_once "../libs/require_once.php";
if ($Valid) {
    if ($_POST['vac_from']) {
        if ($_POST['vac_to']) {
            if (Time::checkDate($_POST['vac_from'])) {
                if (Time::checkDate($_POST['vac_to'])) {
                    if (Time::getTimeOfDMYHI($_POST['vac_from']) >= time()) {
                        if (Time::getTimeOfDMYHI($_POST['vac_from']) <= Time::getTimeOfDMYHI($_POST['vac_to'])) {
                            $ldap->ldap_modify($_COOKIE['dn'], array($LDAP_ST_DATE_VACATION_FIELD => Time::modifyDateFormat($_POST['vac_from'], "dd.mm.yyyy", $VAC_DATE_FORMAT)));
                            $ldap->ldap_modify($_COOKIE['dn'], array($LDAP_END_DATE_VACATION_FIELD => Time::modifyDateFormat($_POST['vac_to'], "dd.mm.yyyy", $VAC_DATE_FORMAT)));
                            echo "{\"success\": \"true\", \"dn\": \"" . Time::getTimeOfDMYHI($_POST['vac_from']) . "\"}";
                        } else {
                            echo "{\"success\": \"false\", \"field\": \"vac_to\", \"answer\": \"Дата окончания отпуска должна быть позже даты начала.\"}";
                        }
                    } else {
                        echo "{\"success\": \"false\", \"field\": \"vac_from\", \"answer\": \"Дата начала планируемого отпуска должна быть позже текущей\"}";
                    }
                } else {
                    echo "{\"success\": \"false\", \"field\": \"vac_to\", \"answer\": \"Дата не соответствует формату\"}";
                }
            } else {
                echo "{\"success\": \"false\", \"field\": \"vac_from\", \"answer\": \"Дата не соответствует формату\"}";
            }
        } else {
            echo "{\"success\": \"false\", \"field\": \"vac_to\", \"answer\": \"Не заполнена дата окончания отпуска\"}";
        }
    } else {
        echo "{\"success\": \"false\", \"field\": \"vac_from\", \"answer\": \"Не заполнена дата начала отпуска \"}";
    }
예제 #5
0
} else {
    echo "<div class=\"photo\"><img src=\"./skins/" . $CURRENT_SKIN . "/images/ldap/user.png\"></div>";
}
echo "</td>";
echo "<td>";
if ($USE_DISPLAY_NAME) {
    $Name = $ldap->getValue($dn, $DISPLAY_NAME_FIELD);
} else {
    $Name = $ldap->getValue($dn, "name");
}
$FIO = preg_replace("/^([ёA-zА-я-]+)[\\s]{1}([ёA-zА-я-]+[\\s]{1}[ёA-zА-я-]+)\$/u", "<div class=\"surname_head\">\$1</div><div class=\"name\">\$2</div>", $Name);
$FIO = preg_replace("/^([ёA-zА-я-]+[\\s]{1}[ёA-zА-я-]{1}.)[\\s]{1}([ёA-zА-я-]+)\$/u", "<div class=\"surname_head\">\$2</div><div class=\"name\">\$1</div>", $FIO);
echo $FIO;
if ($SHOW_EVALUATION_PERIOD_MESSAGE && $LDAP_CREATED_DATE_FIELD) {
    $Created = $ldap->getValue($dn, $LDAP_CREATED_DATE_FIELD);
    $CreatedUnixTime = Time::getTimeOfDMYHI($Created, $LDAP_CREATED_DATE_FORMAT);
    $NumWorkDays = round((Time::getOnlyDatePartFromTime(time()) - Time::getOnlyDatePartFromTime($CreatedUnixTime)) / (24 * 60 * 60));
    if ($NumWorkDays <= $EVALUATION_PERIOD) {
        echo "<h6 class=\"alarm\">Новый сотрудник</h6> &mdash; <small>работает в компании <big>" . $L->ending($NumWorkDays, 'день', 'дня', 'дней') . "</big></small>";
    }
}
$Department = $ldap->getValue($dn, $LDAP_DEPARTMENT_FIELD);
$Title = $ldap->getValue($dn, $LDAP_TITLE_FIELD);
if ($Department) {
    echo "<div class=\"position\"><nobr class=\"department\">" . Staff::makeDepartment($Department) . "</nobr> <br/><span class=\"position\">" . Staff::makeTitle($Title) . "</span></div>";
}
if ($VACATION) {
    $e[0] = $ldap->getValue($dn, $LDAP_ST_DATE_VACATION_FIELD);
    $e[1] = $ldap->getValue($dn, $LDAP_END_DATE_VACATION_FIELD);
    if ($e[0] && $e[1]) {
        $VacationState = Staff::getVacationState($e[0], $e[1]);
예제 #6
0
if ($_COOKIE['dn']) {
    if ($WhoAreYou !== false) {
        echo "<fieldset class=\"whoareyou\">";
        echo "<legend>" . $WhoAreYou . "</legend>";
        echo "<ul>";
        if ($Login = $ldap->getValue($_COOKIE['dn'], "userprincipalname")) {
            if (in_array($Login, $ADMIN_LOGINS)) {
                echo "<li><a href=\"" . $_SERVER['PHP_SELF'] . "?menu_marker=si_staffedit\">" . $L->l("admin_panel") . "</a></li>";
            }
        }
        if ($vac_from = $ldap->getValue($_COOKIE['dn'], $LDAP_ST_DATE_VACATION_FIELD)) {
            $vac_from = Time::modifyDateFormat($vac_from, $VAC_DATE_FORMAT, 'dd.mm.yyyy');
        }
        if ($vac_to = $ldap->getValue($_COOKIE['dn'], $LDAP_END_DATE_VACATION_FIELD)) {
            $vac_to = Time::modifyDateFormat($vac_to, $VAC_DATE_FORMAT, 'dd.mm.yyyy');
        }
        echo "<li><a href=\"newwin.php?menu_marker=si_employeeview&dn=" . $_COOKIE['dn'] . "\" data-lightview-type=\"iframe\" data-lightview-options=\"width: '80%', height: '100%', keyboard: {esc: true}, skin: 'light'\" class=\"lightview\">" . $L->l("profile") . "</a></li>";
        if ($VACATION) {
            echo "<li><span id=\"Vac\">" . $L->l("vacation_plan") . "<big><big>&rarr;</big></big> <span class=\"\">\r\n\t\t\t<input type=\"text\" name=\"vac_from\" id=\"vac_from\" class=\"date\" value=\"" . $vac_from . "\"/>\r\n\t\t\t<em><i></i></em></span> &mdash; <span class=\"\">\r\n\t\t\t<input type=\"text\" name=\"vac_to\" id=\"vac_to\" class=\"date\" value=\"" . $vac_to . "\" />\r\n\t\t\t<em><i></i></em></span>\r\n\t\t\t<img  id=\"vac_apply\" src=\"./skins/" . $CURRENT_SKIN . "/images/true24.png\" width=\"24\" height=\"24\"/><img id=\"vac_loader\" class=\"hidden\" src=\"./skins/" . $CURRENT_SKIN . "/images/load.gif\" width=\"16\" height=\"16\"/></span>\r\n\t\t\t</li>\r\n\t\t\t<script type='text/javascript'>\r\n\t\t\tCalendar.setup({inputField:'vac_from', ifFormat:'%d.%m.%Y', button:'vac_from', firstDay:1, weekNumbers:false, showOthers:true});\r\n\t\t\tCalendar.setup({inputField: 'vac_to', ifFormat: '%d.%m.%Y', button: 'vac_to', firstDay:1, weekNumbers:false, showOthers:true});\r\n\t\t\t</script>\r\n\t\t\t";
            if ($VAC_CLAIM_ALARM && $vac_from && $vac_to) {
                if (Time::getTimeOfDMYHI($vac_from) - $VAC_CLAIM_ALARM_DAYES_FROM * 24 * 60 * 60 <= time() && Time::getTimeOfDMYHI($vac_to) - $VAC_CLAIM_ALARM_DAYES_TO * 24 * 60 * 60 >= time()) {
                    echo "<li><a href=\"newwin.php?menu_marker=si_print_vacation_claim&dn=" . $_COOKIE['dn'] . "\" title=\":: :: width: 900, height: 700\" class=\"lightview alert\">Заявление на отпуск</a></li>";
                }
            }
        }
        if (@(!$_SERVER['REMOTE_USER'])) {
            echo "<li><a href=\"" . $_SERVER['PHP_SELF'] . "?iamnot=1\" title=\"Нет! \">" . $L->l("exit") . "</a></li>";
        }
        echo "</ul></fieldset>";
    }
}