Example #1
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");
    }
}
Example #2
0
 $frm->Hidden(0);
 // Выбрать клиента или показать его
 $kln_id = 0;
 $k = false;
 if (isset($_REQUEST["kln"])) {
     $k = kln_get(intval($_REQUEST["kln"]));
     // Если мы не рук-ль, то проверим филиал
     if ($k && ($k["filial_id"] == $usr["filial_id"] || $usr["group_id"] == 1 || $usr["group_id"] == 0)) {
         $kln_id = $k["id"];
     } else {
         $GUI->ERR("Неверно указан клиент");
     }
 }
 if (!$kln_id && isset($_SESSION["make_visit_tmp"]["klient"]) && intval($_SESSION["make_visit_tmp"]["klient"])) {
     $kln_id = intval($_SESSION["make_visit_tmp"]["klient"]);
     $k = kln_get($kln_id);
 }
 $selector_order = false;
 if ($k) {
     $h = $frm->Hidden($k["id"]);
     $h->linkName = "klient";
     $frm->Label("Клиент: <b>" . $k["fio"] . "</b>", 10, $ypos);
     $frm->Label("Почта: <b>" . $k["email"] . "</b>", 10, $ypos += 20);
     $frm->Label("Телефон: <b>" . $k["telnum"] . "</b>", 10, $ypos += 20);
     $b = $frm->Button("Инфо", 520, $ypos - 10, 70);
     $b->Event = 'window.open("?section=kln&subsection=2&edit=' . $k["id"] . '");';
     // Добавим поле выбора заказа
     $frm->Label("Заказ, если есть", 10, $ypos += 20);
     $o = ord_getByClient($k["id"]);
     $ords = array();
     if ($o) {
Example #3
0
<?php

use Components\Entity\Meeting;
use Components\Entity\Order;
//Редактирование встречи
//      if (!user_has_right("vis_w")) {
//        page_reloadSec();
//      }
$GUI->mmenu->selected->selected->caption = "Редактирование встречи";
$vis_id = intval($_REQUEST["visit"]);
$vis = Meeting::find($vis_id);
if (!$vis) {
    $GUI->ERR("Встреча не найдена");
    page_reloadSec();
}
$kln = kln_get($vis["client_id"]);
$ypos = 0;
$frm = $GUI->Form("Редактирование встречи №" . $vis["id"], "600", "0");
$frm->OnExecute = "editvisit_exec";
$h = $frm->Hidden($vis["id"]);
$h->linkName = "vid";
$frm->Label("Клиент: <b>" . $kln["fio"] . "</b>", 10, $ypos += 10);
$b = $frm->Button("Инфо", 520, $ypos, 70);
$b->Event = 'window.open("?section=kln&subsection=2&edit=' . $kln["id"] . '");';
$ord = false;
if ($vis["order_id"]) {
    $ord = Order::find($vis["order_id"]);
    $frm->Label("Заказ: <b>" . $ord["id"] . ". " . utils_crop_text($ord["subject"], 110) . "</b>", 10, $ypos += 30);
    $b = $frm->Button("Инфо", 520, $ypos, 70);
    $b->Event = 'window.open("?section=ord&subsection=2&p=1&order=' . $ord["id"] . '");';
}
Example #4
0
if (isset($_SESSION["repeat_order"])) {
    $defdata = $_SESSION["repeat_order"];
    unset($_SESSION["repeat_order"]);
}
$h = 800;
$frm = $GUI->Form("Добавить заказ", 650, $h);
$frm->VLine(10, $h - 80, 630);
$frm->Button("Добавить", 205, $h - 60, 100, true);
$frm->OnExecute = "addorder_exec";
$b = $frm->Button("К списку", 345, $h - 60, 100);
$b->Event = "document.location.href=\"?section=ord&subsection=2\"; return false;";
$ypos = 10;
$klient = false;
if (isset($_REQUEST["kln_id"])) {
    $id = intval($_REQUEST["kln_id"]);
    $klient = kln_get($id);
}
$s = false;
if (!$klient) {
    kln_search_modal();
    $frm->Label("Клиент", 10, $ypos);
    $ypos += 20;
    $s = $frm->Select(10, $ypos, 450, array(0 => "-выберите-") + kln_getlist(), "", $defdata["klient"]);
    //0
    $s->linkName = "klient";
    $s->AddValidator(new CGUI_VALIDATOR_NOZERO());
    $b = $frm->Button("Найти", 480, $ypos - 2, 70);
    $b->Event = 'jQuery("#' . $GUI->Vars["kln_search_modal_form"]->idname . '").modal();';
    page_AddScriptText("custom_klient_select_event = function(id){ jQuery('#" . $s->idname . "').val(id); };");
    $ypos += 30;
} else {
Example #5
0
$frm = $GUI->Form("Новое сообщение", "600", "445");
$ypos = 10;
$need_to = true;
$ansv_to = false;
if (isset($_REQUEST["_to"])) {
    $n = substr($_REQUEST["_to"], 0, 1);
    $id = intval(substr($_REQUEST["_to"], 1));
    if ($n == 'u' && isset($data_users[$id])) {
        $h = $frm->Hidden($_REQUEST["_to"]);
        $h->linkName = "to";
        $need_to = false;
        $frm->Label("Кому: " . sotr_getFullName($id), 10, $ypos);
        $ypos += 30;
    }
    if ($n == 'k') {
        $kln = kln_get($id);
        if ($kln) {
            $h = $frm->Hidden($_REQUEST["_to"]);
            $h->linkName = "to";
            $need_to = false;
            $frm->Label("Кому: " . $kln["fio"], 10, $ypos);
            $ypos += 30;
        }
    }
}
if ($need_to) {
    $t = $frm->TextArea(50, $ypos, 530, 50);
    $t->linkName = "to";
    $t->AddValidator(new CGUI_VALIDATOR_NOEMPTY());
    $t->AddJsEvent("keyup", "check_adr_field('" . $t->idname . "');");
    $frm->Label("<a href='#' style='color:black' onclick='show_adr_book(\"" . $t->idname . "\")'><b>Кому</b></a>", 10, $ypos);
Example #6
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;
        }
    }
}