Example #1
0
function editsotr_exec($Frm, $Err)
{
    if (!$Err) {
        $id = $Frm->GetNmValueI('user_id');
        try {
            $user = Employee::find($id);
        } catch (Exception $e) {
            $Frm->_gui->informer->ERR("Сотрудник не найден");
            return;
        }
        if ($user['group_id'] == 0) {
            $Frm->_gui->informer->ERR("Нельзя редактировать Системного администратора");
            return;
        }
        $fil = $Frm->GetNmValueI('filial');
        $grp = $Frm->GetNmValueI('group');
        $password = $Frm->GetNmValue('password');
        $email = strtolower($Frm->GetNmValueH('email'));
        $ryk_group_id = get_role_id_by_name('Руководитель');
        $author_group_id = get_role_id_by_name('Автор');
        if ($fil == 0 && $grp != $ryk_group_id && $grp != $author_group_id) {
            $Frm->_gui->informer->ERR("Для данной группы необходимо указать филиал");
            return;
        }
        if (TEST_MODE && $email != $user['email']) {
            $password = TEST_PASSWORD;
        } elseif (!TEST_MODE && strlen($password) < PASSWORD_MIN_CHARS) {
            $Frm->_gui->informer->ERR("Пароль не может быть меньше " . PASSWORD_MIN_CHARS . " символов");
            return;
        }
        Employee::update($id, array('filial_id' => $fil, 'fio' => $Frm->GetNmValueH('fio'), 'email' => $email, 'group_id' => $grp, 'telnum' => $Frm->GetNmValueH('phone'), 'cont' => $Frm->GetNmValueH('contacts'), 'comments' => $Frm->GetNmValueH('comments'), 'blocked' => $Frm->GetNmValueI('blocked'), 'payment_requisites' => $Frm->GetNmValueH('payment_requisites'), 'password' => $password, 'hpwd' => md5($password . $email)));
        if ($author_group_id == $grp) {
            Author::add_napravl($id, $Frm->GetNmValue('author_napravl'));
        }
        if (TEST_MODE) {
            $Frm->_gui->informer->OK("Сохранено. (тестовый режим - пароль не сохраняется)");
        } else {
            $Frm->_gui->informer->OK("Сохранено");
        }
        page_reloadAll();
    }
}
Example #2
0
    die("нет данных");
}
$uid = intval($_POST["uid"]);
$date = intval($_POST["date"]);
if ($uid == 0) {
    if (!isset($_POST["ml"])) {
        die("нет данных");
    }
    $_users = explode(":", $_POST["ml"]);
    if (!count($_users)) {
        die("1");
    }
    $users = array();
    // получить все встречи всех манагеров
    foreach ($_users as $u) {
        $employer = Employee::find($u);
        $users[$u] = array();
        $users[$u]['fio'] = $employer['fio'];
        $users[$u]["visits"] = array();
        $users[$u]["visits_sum"] = 0;
        foreach (db::get_arrays("SELECT tm_start, tm_finish FROM " . TABLE_VISITS . " WHERE user_id=" . $u . " AND date=" . $date) as $r) {
            $users[$u]["visits"][] = $r;
            $users[$u]["visits_sum"] += $r["tm_finish"] - $r["tm_start"];
        }
    }
    print "<div style='overflow:auto; background:white; border: 1px solid gray; height: 78px'>" . "<table cellpadding=0 cellspacing=0 style='font-size:8pt; margin-left:2px;'>" . "<tr style='color:gray'><td>Сотрудник</td><td style='width:10px' nowrap></td><td>Занятость</td></tr>";
    // Филиал сотрудника. Если нет филиала, то используем 8 часов раб день
    $worklong = 0;
    if ($_SESSION["user"]["data"]["filial_id"]) {
        $fil = fils_get($_SESSION["user"]["data"]["filial_id"]);
        $dweek = date("w", $date) - 1;
Example #3
0
<?php

use Components\Classes\db;
use Components\Entity\Employee;
$id = intval($_REQUEST["zan"]);
$order_fields = array('id', 'klient_id', 'created', 'time_kln');
$order_by = ' ORDER BY id ASC';
if (isset($_REQUEST['sort_cgui_table_id_usotr_orders2'])) {
    $order_by = ' ORDER BY ' . $order_fields[$_REQUEST['sort_cgui_table_id_usotr_orders2']] . ' ASC';
} elseif (isset($_REQUEST['sort_cgui_table_id_usotr_orders2_up'])) {
    $order_by = ' ORDER BY ' . $order_fields[$_REQUEST['sort_cgui_table_id_usotr_orders2_up']] . ' DESC';
}
if (Employee::find($id)) {
    $orders = db::get_assoc_arrays("SELECT " . join(", ", $order_fields) . " FROM " . TABLE_ORDERS . " WHERE manager_id = " . $id . " OR author_id = " . $id . $order_by);
    $tbl = $GUI->Table("sotr_orders" . $n);
    $tbl->Width = "50%";
    $tbl->RowEvent2 = "document.location.href=\"?section=ord&subsection=2&order=%var%&p=1\"";
    $r = $tbl->NewColumn();
    $r->Caption = "Номер заказа";
    $r->DoSort = true;
    $r->Key = "id";
    $r = $tbl->NewColumn();
    $r->Caption = "Клиент";
    $r->DoSort = true;
    $r->Key = "klient_id";
    $r->Align = "left";
    $r->Process = "get_client_name";
    $r = $tbl->NewColumn();
    $r->Caption = "Принят";
    $r->DoSort = true;
    $r->Key = "created";
Example #4
0
 public static function enqueue_message_to_email($message_id, $authors_ids, $notification_type = EmailNotification::TO_AUTHOR_ON_ASSIGN)
 {
     if (empty($message_id) || !is_numeric($message_id)) {
         return false;
     }
     assert(in_array($notification_type, EmailNotification::$NOTIFICATION_TYPES));
     // Если не надо уведомлять - выходим типа все ок
     if (!EmailNotificationType::isSendable($notification_type)) {
         return array();
     }
     $result = array();
     if (!is_array($authors_ids) && is_numeric($authors_ids)) {
         $authors_ids = array($authors_ids);
     }
     foreach ($authors_ids as $id) {
         if (is_numeric($id)) {
             try {
                 $author = Employee::find($id);
             } catch (Exception $e) {
                 $result['error'][] = $id;
                 continue;
             }
             $notification_id = EmailNotification::create(array('message_id' => $message_id, 'receiver_email' => $author['email'], 'type' => $notification_type));
             if ($notification_id) {
                 $result['success'][] = $id;
             }
         } else {
             $ids = explode(', ', $id);
             $temp_result = self::enqueue_message_to_email($message_id, $ids, $notification_type);
             if (count($temp_result['success'])) {
                 array_push($result['success'], $temp_result['success']);
             }
             if (count($temp_result['error'])) {
                 array_push($result['error'], $temp_result['error']);
             }
         }
     }
     return $result;
 }
Example #5
0
<?php

use Components\Exceptions\Exception;
use Components\Entity\Employee;
use Components\Classes\db;
use Components\Entity\Message;
if (!is_client_logged() || $_SESSION["frame"]["client"]["blocked"]) {
    echo 'Доступ запрещен.';
} else {
    if (!empty($_REQUEST['new']) && !empty($_REQUEST['r'])) {
        try {
            $receiver = Employee::find($_REQUEST['r']);
        } catch (Exception $e) {
            redirect("?type=cabinet&messages");
        }
        if (!empty($_REQUEST['send'])) {
            if ($receiver['id'] != $_REQUEST['receiver']) {
                redirect("?type=cabinet&messages");
            }
            $message_id = mls_Send('u' . $receiver['id'], 'k' . $_SESSION['frame']['client']['id'], $_REQUEST['subject'], $_REQUEST['text'], 1, 0);
            \Components\Classes\Author::enqueue_message_to_email($message_id, array($receiver['id']), \Components\Entity\EmailNotificationType::TO_RECEIVER_ON_MESSAGE_COMMON);
            redirect("?type=cabinet&messages");
        }
        $receiver_full_name = db::get_single_value("SELECT sname FROM " . TABLE_ROLES . " WHERE id = " . $receiver['group_id']) . ' ' . $receiver['fio'];
        $subject = '';
        if (!empty($_REQUEST['o'])) {
            $subject = 'Вопрос по заказу №' . $_REQUEST['o'];
        }
        echo "<div style='margin-bottom: 5px'><a href='?type=cabinet&messages'><< к списку сообщений</a></div>";
        echo <<<HTML
<div id="cgui_form_0" class="cgui_form_box" style="width:600px; height: 270px; margin: 0 auto;">
Example #6
0
<?php

use Components\Entity\Employee;
use Components\Entity\EmployeeBlack;
use Components\Classes\Author;
if (!user_can($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "Редактировать")) {
    $GUI->informer->ERR(PERMISSION_DENIED);
    page_ReloadSubSec();
}
$id = intval($_REQUEST["edit"]);
$employer = Employee::find($id);
if (!$employer) {
    $GUI->informer->ERR("Запись не найдена");
    page_ReloadSubSec();
}
need_data('data_napravl');
if (user_can($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "Удалить")) {
    if ($_SESSION["user"]["data"]["id"] != $id) {
        $GUI->cmdmenu->AddItem("Удалить", "?section=sotr&subsection=2&del=" . $id);
    }
}
if (user_can($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "Написать")) {
    $GUI->cmdmenu->AddItem("Написать", "?section=mls&subsection=1&_to=u" . $id);
}
if (user_can($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "История переписки")) {
    $GUI->cmdmenu->AddItem("История переписки", "?section=sotr&subsection=2&msgs=" . $id);
}
if (user_can($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "Занятость")) {
    $GUI->cmdmenu->AddItem("Занятость", "?section=sotr&subsection=2&zan=" . $id);
}
$c = text_lines_count($employer["comments"]);
Example #7
0
function tp_author_notification($value, $row, $table, &$info)
{
    global $GUI;
    try {
        $author = Employee::find($row['author_id']);
        $icon = '<div>';
        $icon .= $GUI->getIcon("?section=ord&subsection=2&order=" . $row['id'] . "&p=7&t=1", "msg", "Отправить напоминание");
        $icon .= '<span style="color:blue; position: relative; top: -2px;left:5px;">' . count(AuthorNotification::findBy(array('author_id' => $author['id'], 'order_id' => $row['id'], 'type' => 1))) . '</span>';
        $icon .= '</div>';
        $icon .= '<div>';
        $icon .= $GUI->getIcon("?section=ord&subsection=2&order=" . $row['id'] . "&p=7&t=2", "msg_red", "Отправить гневное напоминание");
        $icon .= '<span style="color:red; position: relative; top: -2px;left:5px;">' . count(AuthorNotification::findBy(array('author_id' => $author['id'], 'order_id' => $row['id'], 'type' => 2))) . '</span>';
        $icon .= '</div>';
    } catch (Exception $e) {
        $icon = '<div style="height: 20px;"></div>';
    }
    $offers_qt = '';
    if (!empty($row['manager_id']) && !empty($row['status_id'])) {
        $offers_qt = count(AuthorOffer::findBy(array('order_id' => $row['id'])));
    }
    return $icon . '<span style="color:red; position: relative; top: -26px;left:50px;">' . $offers_qt . '</span>';
}