Beispiel #1
0
function get_author($value, $row, $table, &$info)
{
    $order_status = get_status_iname($row['status_id']);
    if ($order_status == "ON_THE_DISTRIBUTION") {
        return "на распределении";
    } else {
        return sotr_getFullName($value);
    }
}
Beispiel #2
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;
        }
    }
}