$result_filter = $search_filter . ' AND ' . $fltr; } elseif (!empty($fltr)) { $result_filter = $fltr; } elseif (!empty($search_filter)) { $result_filter = $search_filter; } else { $result_filter = ''; } $tbl->FilterMYSQL($result_filter); $stat_tbl = $GUI->Table("ord_stat" . $n); $stat_tbl->Width = "50%"; $column = $stat_tbl->NewColumn(); $column->Caption = ""; $column->Key = "id"; $isAuthor = is_author($_SESSION["user"]["data"]["id"]); $isDirector = is_director($_SESSION["user"]["data"]["id"]); $isManager = is_manager($_SESSION["user"]["data"]["id"]); if ($isDirector || $isManager) { $column = $stat_tbl->NewColumn(); $column->Caption = "Цена клиенту"; $column->Key = "client_price"; $column = $stat_tbl->NewColumn(); $column->Caption = "Оплачено клиентом"; $column->Key = "client_payed"; $column = $stat_tbl->NewColumn(); $column->Caption = "Долг клиента"; $column->Key = "client_debt"; } if ($isAuthor || $isDirector || $isManager) { $column = $stat_tbl->NewColumn(); $column->Caption = "Гонорар автора";
<?php use Components\Classes\Disciplines; use Components\Entity\Discipline; page_scriptNeed('select2.min.js', '/js/select2/'); page_styleNeed('select2.css', '/js/select2/'); // $GUI->Vars["page_hdr"] = "Правим содержание, управляем датами и ценой для клиента."; page_scriptNeed('jquery-ui-1.10.3.custom.min.js', '/js/jquery-ui/js/'); page_styleNeed('jquery-ui-1.10.3.custom.min.css', '/js/jquery-ui/css/ui-lightness/'); $h = 1090; $frm = $GUI->Form("Редактирование заказа №" . $order_id, 650); $showOtdelKcomment = is_otdel_K($_SESSION["user"]["data"]['id']) || is_director($_SESSION["user"]["data"]['id']) || is_manager($_SESSION["user"]["data"]['id']); if ($showOtdelKcomment) { $h = 1130; } else { $h = 930; } $frm->height = $h; $frm->VLine(10, $h - 80, 630); $frm->Button("Сохранить", 205, $h - 60, 100, true); $frm->OnExecute = "edit_order"; $b = $frm->Button("К списку", 345, $h - 60, 100); $b->Event = "document.location.href=\"?section=ord&subsection=2\"; return false;"; $t = $frm->Hidden($order_id); $t->linkName = 'id'; $ypos = 10; kln_search_modal(); $frm->Label("Клиент", 10, $ypos); $ypos += 20; $s = $frm->Select(10, $ypos, 450, array(0 => "-выберите-") + kln_getlist(), "", $order_info['klient_id']); //0
$r->Process = $column['on_execute']; $r->instantEdit = $column['instant_edit']; $i++; } $tbl->FilterMYSQL($result_filter); $totals = db::get_arrays("\n SELECT filial_id, SUM(`value`) as total_expenses\n FROM " . TBL_PREF . $Filter->DstTable . "\n WHERE " . $result_filter . "\n GROUP BY filial_id\n"); if ($totals) { $stat_tbl = $GUI->Table("expenses_stat" . $n); $stat_tbl->Width = "50%"; $column = $stat_tbl->NewColumn(); $column->Caption = "Филиал"; $column->Key = "id"; $column = $stat_tbl->NewColumn(); $column->Caption = "Общий расход"; $column->Key = "total_expenses"; if (is_director($_SESSION['user']['data']['id'])) { $column = $stat_tbl->NewColumn(); $column->Caption = "Итого расход руководителя"; $column->Key = "director_expenses"; } foreach ($totals as $row) { $res = array(); if ($row['filial_id'] == 0) { $res['id'] = 'Руководитель'; $res['director_expenses'] = ''; } else { $res['id'] = get_filial_name($row['filial_id']); $res['director_expenses'] = $row['total_expenses'] * (1 - db::get_single_value("SELECT consumption FROM " . TBL_PREF . "data_filials WHERE id = " . $row['filial_id'])); } $res['total_expenses'] = $row['total_expenses']; $stat_tbl->AddRow($res);
/** * @deprecated * @return array */ function kln_getlist() { if (is_director($_SESSION["user"]["data"]["id"])) { $clients = Client::findAll(); } else { $clients = Client::findBy(array('filial_id' => $_SESSION["user"]["data"]["filial_id"])); } $ret = array(); foreach ($clients as $v) { $ret[$v["id"]] = $v["id"] . ". " . $v["fio"] . " (тел. " . $v["telnum"] . "; email: " . $v["email"] . ")"; } return $ret; }
$script[] = "selected_users = []; selected_clients = [];"; if (isset($_REQUEST["a"]) && strlen($_REQUEST["a"])) { $a = explode(";", $_REQUEST["a"]); $u = 0; $k = 0; foreach ($a as $v) { if (strtolower(substr($v, 0, 1)) == "u") { $script[] = "selected_users[" . $u++ . "]=" . intval(substr($v, 1)) . ";"; } if (strtolower(substr($v, 0, 1)) == "k") { $script[] = "selected_clients[" . $k++ . "]=" . intval(substr($v, 1)) . ";"; } } } if ($to_kln) { if (is_director($_SESSION["user"]["data"]["id"])) { $clients = Client::findAll(); } else { $clients = Client::findBy(array('filial_id' => $_SESSION["user"]["data"]["filial_id"])); } $k = 0; foreach ($clients as $v) { $script[] = "clients_list[" . $k++ . "]={id:" . $v["id"] . ",name:'" . $v["fio"] . "'};"; } } $script[] = "</script>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
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; } } }
function deluser_exec($Frm, $Err) { if (!$Err) { if (is_director($_SESSION["user"]['data']['id'])) { $id = $Frm->GetNmValueI('id'); if (count(Order::findBy(array('manager_id' => $id)))) { $Frm->_gui->informer->ERR("У сотрудника есть назначенные заказы"); return; } if (db::get_single_value("SELECT COUNT(id) FROM " . TBL_PREF . "data_visits WHERE user_id = '" . $id . "' AND status <> 1")) { $Frm->_gui->informer->ERR("У сотрудника есть назначенные встречи"); return; } $resone = $Frm->GetNmValueH('reason'); db::query("insert into " . TABLE_USERS_BLACK . " select * from " . TABLE_USERS . " where id= " . $id); EmployeeBlack::update($id, array('comments' => $resone, 'blocked' => 1, 'black_list' => 1, 'removed_by' => $_SESSION['user']['data']['id'], 'removed_time' => time())); Employee::delete($id); $Frm->_gui->informer->OK("Сотрудник перенесен в черный список"); } else { $Frm->_gui->informer->ERR("Перемещать сотрудников в черный список может только руководитель"); } page_reloadSec(); } }