public static function makeDisciplinesDefault($napravl_id) { self::deleteAllDisciplines($napravl_id); foreach (self::getDisciplines($napravl_id) as $discipline_id) { Disciplines::addToNaprav($discipline_id, self::getDefaultID()); } }
public static function delete($discipline_id) { if (empty($discipline_id)) { return false; } Disciplines::deleteAllFromNaprav($discipline_id); return parent::delete($discipline_id); }
public static function addDisciplines($author_id, $disciplines_ids) { self::deleteDisciplines($author_id); foreach ($disciplines_ids as $discipline_id) { if (empty($discipline_id)) { continue; } db::insert(TABLE_AUTHOR_TO_DISCIPLINE, array('author_id' => $author_id, 'discipline_id' => $discipline_id)); $napravls_ids = Disciplines::getNapravListAsArray($discipline_id); foreach ($napravls_ids as $napravl_id) { db::replace(TABLE_AUTHOR_TO_NAPRAVL, array('author_id' => $author_id, 'napravl_id' => $napravl_id)); } } }
$ypos += 30; $s->AddJsEvent("change", " jQuery('#" . $t->idname . "').val(''); "); $t->AddJsEvent("keyup", " jQuery('#" . $s->idname . "').val(0); "); $frm->Label("Направление (факультет)", 10, $ypos); $frm->Label("Дисциплина", 190, $ypos); $ypos += 20; $s = $frm->Select(10, $ypos, 160, array(0 => array("name" => "-выберите-")) + $data_napravl, "name", $order_info["napr_id"]); //6 $s->linkName = "napr"; $t = $frm->Hidden(isset($data_discip[$order_info["disc_id"]]) ? $order_info["disc_id"] : $order_info["disc_user"]); // 8 $t->linkName = "disc_usr"; $t->class = 'discipline_select2'; $disciplines = Discipline::findAll(); foreach ($disciplines as &$discipline) { $discipline['authors_qt'] = Disciplines::getAuthorsQt($discipline['id']); } unset($discipline); page_AddScriptText('var disciplines = ' . json_encode($disciplines) . ';'); $ypos += 30; $frm->Label("Тема работы", 10, $ypos); $ypos += 20; $t = $frm->TextArea(10, $ypos, 625, 60, $order_info["subject"]); //9 $t->linkName = "subj"; $t->AddValidator(new CGUI_VALIDATOR_NOEMPTY()); $t->AddValidator(new CGUI_VALIDATOR_MAXLEN(512)); $ypos += 70; $frm->Label("Дата сдачи", 10, $ypos); $frm->Label("Практика", 110, $ypos); $frm->Label("Число страниц", 230, $ypos);
$disciplines = Napravls::getDisciplines($napravl['id']); $checked = in_array($napravl['id'], $authorNapravls); $result[] = '<tr style="background-color: #d3d3d3;">'; $result[] = '<td colspan="100">'; $result[] = '<div class="module_name"> <label for="napravl[' . $napravl['id'] . ']">' . Napravls::getName($napravl['id']) . '</label> </div>'; if (count($disciplines)) { $result[] = ' '; $result[] = '<span style="vertical-align: middle;line-height: 1.9;" data-toggle="select" data-target="napravl_' . $napravl['id'] . '">выбрать все</span>'; $result[] = ' '; $result[] = '<span style="vertical-align: middle;line-height: 1.9;" data-toggle="collapse" data-target="napravl_' . $napravl['id'] . '">' . ($checked ? 'скрыть' : 'показать') . ' дисциплины<span>'; } $result[] = '</td>'; $result[] = '</tr>'; if (count($disciplines)) { foreach ($disciplines as $discipline_id) { $result[] = '<tr class="napravl_' . $napravl['id'] . '"' . ($checked ? '' : 'style="display:none;"') . '>'; $result[] = '<td style="width: 100px;">'; $result[] = '</td>'; $result[] = '<td colspan="2">'; $result[] = '<div class="submodule_name"><label for="discipline[' . $discipline_id . ']">' . Disciplines::getName($discipline_id) . '</label></div>'; $result[] = '<input type="checkbox" ' . (in_array($discipline_id, $authorDisciplines) ? 'checked="checked"' : '') . ' name="discipline[' . $discipline_id . ']" class="submodule_checkbox" id="discipline[' . $discipline_id . ']">'; $result[] = '</tr>'; $result[] = '</td>'; } } } } $result[] = '</table>'; $GUI->Vars['table'] = join("\n", $result);
$h->linkName = "order_id"; $h = $frm->Hidden($order_info['manager_id']); $h->linkName = "old_manager_id"; $frm->VLine(10, $ypos += 40, 280); $frm->Button("Назначить", 110, $ypos += 20, 80, true); $GUI->Vars["page_top"] .= "<br><a href='#' onclick='cgui_form_modal(\"" . $frm->idname . "\");return false;'>Назначить менеджера</a>"; //отправить заказ на почту // die; $frm2 = $GUI->Form("Отправить заказ на почту", 300, 320, CGUI_FORM_FLAG_MODAL); $frm2->OnExecute = "send_order_by_email"; $ypos = 0; $frm2->Label("Выберите авторов для отправки заказа", 10, $ypos += 10); $frm2->VLine(10, $ypos += 20, 280); $discipline_id = $order_info['disc_id']; $authors = get_users_by_group_name('Автор', null, false, true); $authors = Disciplines::getAuthors($discipline_id); arsort($authors); if (count($authors) > 1) { $authors[join(", ", array_keys($authors))] = 'Отправить всем подписавшимся'; $authors = array_reverse($authors, true); } $s = $frm2->Select(10, $ypos += 20, 280, $authors, ''); $s->Multiple = true; $s->RowSize = 10; $s->linkName = 'authors'; $s->name = 'authors'; $hid = $frm2->Hidden($order_id); $hid->linkName = 'order_id'; $frm2->VLine(10, $ypos += 180, 280); $frm2->Button("Отправить", 110, $ypos += 20, 80, true); $GUI->Vars["page_top"] .= "<br><a href='#' onclick='cgui_form_modal(\"" . $frm2->idname . "\");return false;'>Отправить заказ на почту</a>";
function impdiscip_exec($Frm, $Err) { if (!$Err) { $v = $Frm->GetValue(0); if (!strpos($v["type"], "ms-excel")) { $Frm->_gui->informer->ERR("Неправильный тип файла"); page_reloadSubSec(); } else { $s = ""; if ($Frm->GetValue(1)) { db::truncate(TABLE_DISCIPLINE); db::truncate(TABLE_DISCIPLINE_TO_NAPRAVL); db::truncate(TABLE_AUTHOR_TO_DISCIPLINE); $s = "Таблица очищена. "; } require_once DIR_FS_DOCUMENT_ROOT . "/ext/PHPExcel/PHPExcel.php"; $loader = PHPExcel_IOFactory::load($v['tmp_name']); $loader->setActiveSheetIndex(0); $sheet = $loader->getActiveSheet(); $colNumber = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()); if ($colNumber < 1 or $colNumber > 2) { $Frm->_gui->informer->ERR("В таблице должно быть от 1 до 2 колонок(сейчас " . $colNumber . ")"); page_reloadSubSec(); } $rowIterator = $sheet->getRowIterator(); $addcnt = 0; foreach ($rowIterator as $row) { // Получили ячейки текущей строки и обойдем их в цикле $cellIterator = $row->getCellIterator(); foreach ($cellIterator as $cell) { $value = trim($cell->getValue()); $color = $sheet->getStyle($cell->getCoordinate())->getFill()->getEndColor()->getRGB(); if ($color == '000000') { $napravl = db::get_single_row("SELECT * FROM " . TABLE_NAPRAVL . " WHERE LOWER(name) = '" . db::input(strtolower($value)) . "'"); if ($napravl) { $napravl_id = $napravl['id']; } else { $napravl_id = Napravl::create(array('name' => $value)); } } else { if (empty($napravl_id)) { continue 2; } $discipline = db::get_single_row("SELECT * FROM " . TABLE_DISCIPLINE . " WHERE LOWER(name) = '" . db::input(strtolower($value)) . "'"); if ($discipline) { Disciplines::addToNaprav($discipline['id'], $napravl_id); continue 2; } else { $discipline_id = Discipline::create(array('name' => $value)); Disciplines::addToNaprav($discipline_id, $napravl_id); $addcnt++; } } } } $Frm->_gui->informer->OK($s . "Добавлено " . $addcnt . " строк"); page_reloadSubSec(); } } }
function get_authors_qt_for_discipline($value, $row, $table, $info) { return Disciplines::getAuthorsQt($row['id']); }
function assign_order($Frm, $Err) { if (!$Err) { $author_time = utils_cvt_date2i($Frm->GetNmValueH("time_auth")); $raspred_time = utils_cvt_date2i($Frm->GetNmValueH("raspred_srok")); if ($author_time < time() || $raspred_time < time()) { $Frm->_gui->ERR("Нельзя указывать дату прошлым числом"); page_reloadAll(); } $order_id = $Frm->GetNmValueI("order_id"); $status_id = get_status_id_by_iname("ON_THE_DISTRIBUTION"); $manager_id = $Frm->GetNmValueI("manager_id"); Order::update($order_id, array("manager_id" => $manager_id, "time_auth" => $author_time, "raspred_srok" => $raspred_time, "cost_auth" => $Frm->GetNmValueI("author_price"), "payment_comment" => $Frm->GetNmValueH("payment_comment"), "status_id" => $status_id)); Author::saveMessageAndEnqueueEmail($order_id, array($manager_id), 'u' . $_SESSION['user']['data']['id'], "Распределение заказа №" . $order_id, "Вас назначили менеджером заказа №" . $order_id, \Components\Entity\EmailNotification::TO_MANAGER_ON_FIRST_ASSIGN); $send_author_msgs = null !== $Frm->GetNmValue("send_for_authors") ? true : false; if ($send_author_msgs) { $order_info = get_order_info($order_id); $discipline_id = $order_info['disc_id']; if ($discipline_id > 0) { // Выслать уведомления авторам $authors = array_keys(Disciplines::getAuthors($discipline_id)); send_order_by_email($Frm, $Err, $authors); // само генерит сообщение } else { $Frm->_gui->OK("Заказ поставлен на распределение, уведомления не высланы - нет дисциплины"); } } else { $Frm->_gui->OK("Заказ поставлен на распределение без уведомлений"); } page_reloadAll(); } }