Пример #1
0
function editclient_exec($Frm, $Err)
{
    if (!$Err) {
        $client_info = Client::find($Frm->GetNmValueI("id"));
        if (!$client_info) {
            $Frm->_gui->ERR("Клиент не найден");
            page_reloadToSec(2);
        }
        $filial_id = $Frm->GetNmValueI("filial_id");
        if (empty($filial_id)) {
            $Frm->_gui->ERR("Не указан филиал");
            return;
        }
        $new_password = $client_info['hpwd'];
        $pwd = $client_info['password'];
        if ($Frm->GetNmValueH("newpwd") != "") {
            if ($Frm->GetNmValueI("genpwd")) {
                $pwd = generate_pasw(5);
            } else {
                $pwd = $Frm->GetNmValueI("newpwd");
            }
            if (strlen($pwd) < 5) {
                $Frm->_gui->ERR("Длина пароля должна быть не менее 5 символов");
                return;
            }
            if (strlen($pwd) > 20) {
                $Frm->_gui->ERR("Длина пароля должна быть не более 20 символов");
                return;
            }
            $eml = strtolower($Frm->GetNmValueH("email"));
            $new_password = md5($pwd . $eml);
        }
        db::insert(TABLE_CLIENTS_HISTORY, array('change_date' => time(), 'change_user_id' => $_SESSION['user']['data']['id'], 'client_id' => $client_info["id"], 'filial_id_new' => $filial_id, 'fio_new' => $Frm->GetNmValueH("fio"), 'hpwd_new' => $new_password, 'email_new' => $Frm->GetNmValueH("email"), 'telnum_new' => $Frm->GetNmValueH("telnum"), 'city_new' => $Frm->GetNmValueH("city"), 'icq_new' => $Frm->GetNmValueH("icq"), 'skype_new' => $Frm->GetNmValueH("skype"), 'contacts_new' => $Frm->GetNmValueH("contacts"), 'about_new' => $Frm->GetNmValueH("about"), 'filial_id_old' => $client_info['filial_id'], 'fio_old' => $client_info['fio'], 'hpwd_old' => $client_info['hpwd'], 'email_old' => $client_info['email'], 'telnum_old' => $client_info['telnum'], 'city_old' => $client_info['city'], 'icq_old' => $client_info['icq'], 'skype_old' => $client_info['skype'], 'contacts_old' => $client_info['contacts'], 'about_old' => $client_info['about']));
        Client::update($client_info['id'], array('filial_id' => $filial_id, 'fio' => $Frm->GetNmValueH("fio"), 'email' => $Frm->GetNmValueH("email"), 'telnum' => $Frm->GetNmValueH("telnum"), 'city' => $Frm->GetNmValueH("city"), 'hpwd' => $new_password, 'password' => $pwd, 'icq' => $Frm->GetNmValueH("icq"), 'skype' => $Frm->GetNmValueH("skype"), 'contacts' => $Frm->GetNmValueH("contacts"), 'about' => $Frm->GetNmValueH("about"), 'ref_id' => $Frm->GetNmValueI('ref'), 'from_id' => $Frm->GetNmValueI('client_from')));
        db::update(TABLE_ORDERS, array('filial_id' => $filial_id), 'klient_id = ' . $client_info["id"]);
        $Frm->_gui->OK("Сохранено");
        page_reloadAll();
    }
}
Пример #2
0
<?php

$usr = $_SESSION["user"]["data"];
if (isset($_REQUEST["step"]) && $_REQUEST["step"] == 2) {
    if (!isset($_SESSION["make_visit_tmp"])) {
        page_reloadToSec("1");
    }
    $frm = $GUI->Form("Создать встречу. Шаг 2.", 600);
    $frm->OnExecute = "addvisit_2_exec";
    $ypos = 10;
    $dt = explode("-", $_SESSION["make_visit_tmp"]["date"]);
    $dt = mktime(0, 0, 0, $dt[1], $dt[0], $dt[2]);
    $kln = kln_get($_SESSION["make_visit_tmp"]["klient"]);
    if ($_SESSION["make_visit_tmp"]["place"] == -1) {
        $_SESSION["make_visit_tmp"]["filial_id"] = $kln["filial_id"];
        $frm->Label("Встреча с курьером - " . date("d.m.Y", $dt), 10, $ypos);
        $users = array();
        if (in_array($usr["group_id"], array(0, 1, 2, 3))) {
            foreach ($data_users as $_user) {
                if ($_user["group_id"] == 5 && $_user["blocked"] != 1 && $_user["black_list"] != 1) {
                    if (!isset($users[$_user["id"]])) {
                        $users[$_user["id"]] = sotr_getFullName($_user["id"]);
                    }
                }
            }
        }
        $ulist = array();
        foreach ($users as $k => $v) {
            $ulist[] = $k;
        }
        $frm->Label("Сотрудник", 10, $ypos += 30);
Пример #3
0
function sendmessage_exec($Frm, $Err)
{
    global $data_users;
    if (!$Err) {
        // Авторам запрещено писать клиентам
        $to_kln = $_SESSION["user"]["data"]["group_id"] != 6;
        //Декодирование адресатов
        $adrs = strtolower($Frm->GetNmValue("to"));
        $adrs = preg_replace("[^uk0-9;]", "", $adrs);
        $adrs = explode(";", $adrs);
        $adrs_k = array();
        $adrs_u = array();
        foreach ($adrs as $v) {
            $ind = intval(substr($v, 1));
            $s = substr($v, 0, 1);
            if ($to_kln && $s == 'k' && $ind) {
                $adrs_k[] = $ind;
            } else {
                if ($s == 'u' && $ind) {
                    $adrs_u[] = $ind;
                }
            }
        }
        if (!count($adrs_u) && !count($adrs_k)) {
            $Frm->_gui->informer->ERR("Неверно указан получатель");
            return;
        }
        foreach ($adrs_u as $v) {
            if (!isset($data_users[$v])) {
                $Frm->_gui->informer->ERR("Указан несуществующий получатель");
                return;
            }
        }
        $srok = 0;
        if (strlen($Frm->GetNmValue("date"))) {
            $d = explode("-", $Frm->GetNmValue("date"));
            $srok = mktime(0, 0, 0, $d[1], $d[0], $d[2]);
            if ($srok < mktime(0, 0, 0, date("n"), date("j"), date("Y"))) {
                $Frm->_gui->informer->ERR("Неверно указан срок ответа");
                return;
            }
        }
        $subj = $Frm->GetNmValueH("subj");
        $text = $Frm->GetNmValueH("txt");
        $prior = $Frm->GetNmValueI("prior");
        $parent_id = 0;
        if ($Frm->GetNmValue("ans")) {
            $parent_id = $Frm->GetNmValue("ans");
        }
        // Для каждого получателя формирутеся свой экземпляр
        foreach ($adrs_k as $a) {
            $message_id = mls_Send("k" . $a, "u" . $_SESSION["user"]["data"]["id"], $subj, $text, $prior, $srok, $parent_id, 0, $a, 0, 0);
            $client = \Components\Entity\Client::find($a);
            if (!empty($message_id) && !empty($client['email'])) {
                enqueue_message_to_email($message_id, $client['email'], EmailNotification::TO_RECEIVER_ON_MESSAGE_COMMON);
            }
        }
        foreach ($adrs_u as $a) {
            $message_id = mls_Send("u" . $a, "u" . $_SESSION["user"]["data"]["id"], $subj, $text, $prior, $srok, $parent_id, 0, 0, 0, 0);
            \Components\Classes\Author::enqueue_message_to_email($message_id, array($a), EmailNotification::TO_RECEIVER_ON_MESSAGE_COMMON);
        }
        $Frm->_gui->informer->OK("Сообщение создано");
        page_reloadToSec(3);
    }
}
Пример #4
0
<?php

use Components\Entity\Client;
$GUI->mmenu->selected->selected->caption = "Запрос на удаление";
$client = Client::find($_REQUEST["kln_id"]);
if ($client) {
    $frm = $GUI->Form("Удалить клиента?", 400, 100);
    $frm->OnExecute = "delclient_exec";
    $t = $frm->Hidden($client["id"]);
    $t->linkName = 'id';
    $frm->Label("Клиент: " . $client["fio"], 10, 10);
    $frm->Button("Удалить", 110, 40, 80, true);
    $b = $frm->Button("К списку", 210, 40, 80);
    $b->Event = "document.location.href=\"?section=kln&subsection=2\"; return false;";
} else {
    $GUI->ERR("Клиент не найден");
    page_reloadToSec("2");
}
Пример #5
0
function edit_order($Frm, $Err)
{
    if (!$Err) {
        $order_id = $Frm->GetNmValueI('id');
        $order_info = Order::find($order_id);
        $klient = kln_get($Frm->GetNmValueI("klient"));
        if (!$klient) {
            $Frm->_gui->ERR("Клиент не найден");
            return;
        }
        // Филиал клиента соотв филиалу сотрудника, если сотрудник рук то неважно
        if ($_SESSION["user"]["data"]["group_id"] == 1 || $_SESSION["user"]["data"]["group_id"] == 0 || $_SESSION["user"]["data"]["filial_id"] == $klient["filial_id"]) {
        } else {
            $Frm->_gui->ERR("Филиал клиента и сотрудника не совпадают");
            return;
        }
        if ($Frm->GetNmValue("work") == 0 && !strlen($Frm->GetNmValue("work_usr"))) {
            $Frm->_gui->ERR("Не указан вид работы");
            return;
        }
        $disciplina = trim($Frm->GetNmValue("disc_usr"));
        if (!strlen($disciplina)) {
            $Frm->_gui->ERR("Не указана дисциплина");
            return;
        }
        $pmin = $Frm->GetNmValueI("pgmin");
        $pmax = $Frm->GetNmValueI("pgmax");
        //    if ($pmax && ($pmax < $pmin)) {
        //      $Frm->_gui->ERR("Неверно указано макс. число страниц");
        //      return;
        //    }
        $pmin = $Frm->GetNmValueI("srcmin");
        $pmax = $Frm->GetNmValueI("srcmax");
        //    if ($pmax && ($pmax < $pmin)) {
        //      $Frm->_gui->ERR("Неверно указано макс. число источников");
        //      return;
        //    }
        if (!$Frm->GetNmValueI("pole_t") || !$Frm->GetNmValueI("pole_b") || !$Frm->GetNmValueI("pole_l") || !$Frm->GetNmValueI("pole_r")) {
            $Frm->_gui->ERR("Не указаны размеры полей в оформлении");
            return;
        }
        $changes = array();
        $kln_date = utils_cvt_date2i($Frm->GetNmValueH("date"));
        $rel_date = utils_cvt_date2i($Frm->GetNmValueH("next_rel_date"));
        $showOtdelKcomment = is_otdel_K($_SESSION["user"]["data"]['id']) || is_director($_SESSION["user"]["data"]['id']) || is_manager($_SESSION["user"]["data"]['id']);
        if ($showOtdelKcomment) {
            $ok_comment = $Frm->GetNmValueH("ok_comment");
        } else {
            $ok_comment = $order_info['ok_comment'];
        }
        if ($ok_comment != $order_info['ok_comment']) {
            $changes[] = "'комментарий ОК' с " . $order_info['ok_comment'] . " на " . $ok_comment;
            $ok_comment_date = time();
        } else {
            $ok_comment_date = $order_info['ok_comment_date'];
        }
        $oform = array();
        $oform[] = $Frm->GetNmValueI("fontnm");
        $oform[] = $Frm->GetNmValueI("fontsz");
        $oform[] = $Frm->GetNmValueI("interval");
        $oform[] = $Frm->GetNmValueI("links");
        $oform[] = $Frm->GetNmValueI("pole_t");
        $oform[] = $Frm->GetNmValueI("pole_b");
        $oform[] = $Frm->GetNmValueI("pole_l");
        $oform[] = $Frm->GetNmValueI("pole_r");
        $oform[] = $Frm->GetNmValueI("pagenums");
        $oform = serialize($oform);
        try {
            $discipline = Discipline::find($disciplina);
        } catch (Exception $e) {
            $discipline = Discipline::findOneBy(array('name' => $disciplina));
        }
        if (!$discipline) {
            $disc_id = Discipline::create(array('name' => $disciplina, 'code' => ''));
            Disciplines::addToDefaultNaprav($disc_id);
        } else {
            $disc_id = $discipline['id'];
        }
        $order_status_id = $Frm->GetNmValueI("status_id");
        db::insert("orders_changes_history", array('change_date' => time(), 'change_user_id' => $_SESSION['user']['data']['id'], 'order_id' => $order_id, 'filial_id_new' => $klient["filial_id"], 'klient_id_new' => $klient["id"], 'vuz_id_new' => $Frm->GetNmValueI("vuz"), 'vuz_user_new' => $Frm->GetNmValueH("vuz_usr"), 'type_id_new' => $Frm->GetNmValueI("work"), 'type_user_new' => $Frm->GetNmValueH("work_usr"), 'napr_id_new' => $Frm->GetNmValueI("napr"), 'disc_id_new' => $disc_id, 'disc_user_new' => $Frm->GetNmValueH("disc_usr"), 'time_kln_new' => $kln_date, 'cost_kln_new' => $Frm->GetNmValueI("cost"), 'payment_id_new' => $Frm->GetNmValueI("opl"), 'subject_new' => $Frm->GetNmValueH("subj"), 'about_kln_new' => $Frm->GetNmValueH("treb"), 'about_mng_new' => $Frm->GetNmValueH("rem"), 'kurs_new' => $Frm->GetNmValueI("kurs"), 'prakt_pc_new' => $Frm->GetNmValueI("prakt"), 'pages_min_new' => $Frm->GetNmValueI("pgmin"), 'pages_max_new' => $Frm->GetNmValueI("pgmax"), 'src_min_new' => $Frm->GetNmValueI("srcmin"), 'src_max_new' => $Frm->GetNmValueI("srcmax"), 'from_id_new' => $Frm->GetNmValueI("take"), 'oform_new' => $oform, 'next_rel_date_new' => $rel_date, 'status_id_new' => $order_status_id, 'ok_comment_new' => $ok_comment, 'ok_comment_date_new' => $ok_comment_date, 'payment_comment_new' => $Frm->GetNmValueH("payment_comment"), 'cost_auth_new' => $Frm->GetNmValueI("cost_auth"), 'time_auth_new' => $kln_date, 'oplata_kln_new' => $Frm->GetNmValueI("oplata_kln"), 'author_paid_new' => $Frm->GetNmValueI("author_paid"), 'company_paid_new' => $order_info['company_paid'], 'filial_id_old' => $order_info['filial_id'], 'klient_id_old' => $order_info['klient_id'], 'vuz_id_old' => $order_info['vuz_id'], 'vuz_user_old' => $order_info['vuz_user'], 'type_id_old' => $order_info['type_id'], 'type_user_old' => $order_info['type_user'], 'napr_id_old' => $order_info['napr_id'], 'disc_id_old' => $order_info['disc_id'], 'disc_user_old' => $order_info['disc_user'], 'time_kln_old' => $order_info['time_kln'], 'cost_kln_old' => $order_info['cost_kln'], 'payment_id_old' => $order_info['payment_id'], 'subject_old' => $order_info['subject'], 'about_kln_old' => $order_info['about_kln'], 'about_mng_old' => $order_info['about_mng'], 'kurs_old' => $order_info['kurs'], 'prakt_pc_old' => $order_info['prakt_pc'], 'pages_min_old' => $order_info['pages_min'], 'pages_max_old' => $order_info['pages_max'], 'src_min_old' => $order_info['src_min'], 'src_max_old' => $order_info['src_max'], 'from_id_old' => $order_info['from_id'], 'oform_old' => $order_info['oform'], 'next_rel_date_old' => $order_info['next_rel_date'], 'status_id_old' => $order_info['status_id'], 'ok_comment_old' => $order_info['ok_comment'], 'ok_comment_date_old' => $order_info['ok_comment_date'], 'payment_comment_old' => $order_info['payment_comment'], 'cost_auth_old' => $order_info['cost_auth'], 'time_auth_old' => $order_info['time_auth'], 'oplata_kln_old' => $order_info['oplata_kln'], 'author_paid_old' => $order_info['author_paid'], 'company_paid_old' => $order_info['company_paid']));
        $time_kln_r = 0;
        if (get_status_iname($order_status_id) == 'ORDER_GIVEN') {
            $time_kln_r = time();
        }
        if (get_order_status($order_id) == 'ORDER_GIVEN') {
            $time_kln_r = $order_info['time_kln_r'];
        }
        Order::update($order_id, array("filial_id" => $klient["filial_id"], "manager_id" => $order_info['manager_id'], "author_id" => $order_info['author_id'], "klient_id" => $klient["id"], "parent_id" => 0, "vuz_id" => $Frm->GetNmValueI("vuz"), "vuz_user" => $Frm->GetNmValueH("vuz_usr"), "type_id" => $Frm->GetNmValueI("work"), "type_user" => $Frm->GetNmValueH("work_usr"), "napr_id" => $Frm->GetNmValueI("napr"), "disc_id" => $disc_id, "disc_user" => '', "time_kln" => $kln_date, "time_kln_r" => $time_kln_r, "cost_kln" => $Frm->GetNmValueI("cost"), "cost_auth" => $Frm->GetNmValueI("cost_auth"), "oplata_kln" => $Frm->GetNmValueI("oplata_kln"), "payment_id" => $Frm->GetNmValueI("opl"), "raspred_srok" => 0, "raspred_auth" => "", "subject" => $Frm->GetNmValueH("subj"), "about_kln" => $Frm->GetNmValueH("treb"), "about_mng" => $Frm->GetNmValueH("rem"), "kurs" => $Frm->GetNmValueI("kurs"), "prakt_pc" => $Frm->GetNmValueI("prakt"), "pages_min" => $Frm->GetNmValueI("pgmin"), "pages_max" => $Frm->GetNmValueI("pgmax"), "src_min" => $Frm->GetNmValueI("srcmin"), "src_max" => $Frm->GetNmValueI("srcmax"), "from_id" => $Frm->GetNmValueI("take"), "oform" => $oform, "next_rel_date" => $rel_date, 'status_id' => $order_status_id, 'ok_comment' => $ok_comment, 'ok_comment_date' => $ok_comment_date, 'author_paid' => $Frm->GetNmValueI("author_paid")));
        $Frm->_gui->OK("Заказ обновлен");
        switch ($Frm->GetNmValueI("next")) {
            case 1:
                unset($_SESSION["repeat_order"]);
                header("location: /index.php?section=ord&subsection=2&p=2&order=" . $order_id);
                die;
                break;
            case 2:
                $_SESSION["repeat_order"] = $Frm->GetAllNmValues();
                page_reloadToSec(1);
                break;
            case 0:
            default:
                unset($_SESSION["repeat_order"]);
                header("location: /index.php?section=ord&subsection=2");
                die;
                break;
        }
    }
}
Пример #6
0
function addvisit_2_exec($Frm, $Err)
{
    if (!$Err) {
        if (!isset($_SESSION["make_visit_tmp"]["klient"])) {
            $Frm->_gui->ERR("Клиент не определен");
            return;
        }
        $kln = kln_get($_SESSION["make_visit_tmp"]["klient"]);
        if (!$kln) {
            $Frm->_gui->ERR("Клиент не определен");
            return;
        }
        $ord_id = 0;
        if (isset($_SESSION["make_visit_tmp"]["order"]) && intval($_SESSION["make_visit_tmp"]["order"])) {
            $ord_id = intval($_SESSION["make_visit_tmp"]["order"]);
            if (!Order::find($ord_id)) {
                $Frm->_gui->ERR("Заказ не найден");
                return;
            }
        }
        // Проверить время
        $t1 = $Frm->GetNmValue("start");
        $t2 = $Frm->GetNmValue("finish");
        if ($t2 <= $t1) {
            $Frm->_gui->ERR("Некорректно задано время");
            return;
        }
        $dt = explode("-", $_SESSION["make_visit_tmp"]["date"]);
        $dt = mktime(0, 0, 0, $dt[1], $dt[0], $dt[2]);
        $fil = intval($_SESSION["make_visit_tmp"]["filial_id"]);
        if ($fil <= 0) {
            $Frm->_gui->ERR("Некорректный филиал");
            return false;
        }
        $courier_id = $Frm->GetNmValueI("user");
        $visits = db::get_single_value("SELECT COUNT(*) FROM " . TABLE_VISITS . " WHERE user_id = " . db::input($courier_id) . " AND tm_start <= " . db::input($t1) . " AND tm_finish > " . db::input($t1) . " AND date = " . db::input($dt));
        if ($visits) {
            $Frm->_gui->ERR("На это время уже назначена встреча");
            return false;
        }
        $vis_id = Meeting::create(array("user_id" => $courier_id, "date" => $dt, "status" => 0, "tm_start" => $t1, "tm_finish" => $t2, "client_id" => $kln["id"], "order_id" => $ord_id, "filial_id" => $fil, "created" => time(), "creator_id" => $_SESSION["user"]["data"]["id"], "summa" => $_SESSION["make_visit_tmp"]["summa1"], "about" => $_SESSION["make_visit_tmp"]["about"], "opisanie_klienta" => $Frm->GetNmValueH("opisanie_klienta"), "opisanie_pyti" => $Frm->GetNmValueH("opisanie_pyti"), "station_id" => $Frm->GetNmValueI("station")));
        $Frm->_gui->OK("Встреча создана");
        // Создаем сообщение при необходимости
        if ($courier_id != $_SESSION["user"]["data"]["id"]) {
            $prior = 1;
            $msg_id = mls_Send("u" . $courier_id, "u" . $_SESSION["user"]["data"]["id"], "Новая встреча №" . $vis_id, "Вы проводите встречу " . date("d.m.Y", $dt) . " c " . utils_cvt_i2times($t1) . " по " . utils_cvt_i2times($t2) . "." . " <a href='?section=vis&subsection=2&visit=" . $vis_id . "'>Подробнее...</a><br>Внимание! Ответ на данное сообщение обязателен!", $prior, 0, 0, 0, 0, $vis_id, 0);
            if ($msg_id) {
                \Components\Classes\Author::enqueue_message_to_email($msg_id, array($courier_id), \Components\Entity\EmailNotificationType::TO_CLIENT_ON_ORDER_CHANGE);
                Meeting::update($vis_id, array('uved_umsg' => $msg_id));
            }
        }
        page_reloadToSec("2");
    }
}