예제 #1
0
파일: functions.php 프로젝트: yonkon/diplom
function adddiscip_exec($Frm, $Err)
{
    if (!$Err) {
        $name = trim($Frm->GetNmValueH('name'));
        $napravl = $Frm->GetNmValue('napravl');
        if (empty($napravl) || empty($name)) {
            $Frm->_gui->informer->ERR('Заполните Название и выберите Направление');
            page_reloadAll();
        }
        if (Discipline::findOneBy(array('name' => $name))) {
            $Frm->_gui->informer->ERR('Дисциплина с таким именем уже существует');
            page_reloadAll();
        }
        $id = Discipline::create(array('code' => $Frm->GetNmValueI('code'), 'name' => $name));
        Disciplines::addToNapravList($id, $napravl);
        if ($id) {
            $Frm->_gui->informer->OK("Добавлено");
        } else {
            $Frm->_gui->informer->ERR('Произошла ошибка. Запись не добавлена');
        }
        page_reloadSubSec();
    }
}
예제 #2
0
파일: makeorder.php 프로젝트: yonkon/diplom
 function add_order($client_id, &$err)
 {
     $err = "";
     try {
         $client = Client::find($client_id);
     } catch (Exception $e) {
         $err = "Ошибка - не указан клиент";
         return false;
     }
     try {
         $filial = Filial::find($client['filial_id']);
     } catch (Exception $e) {
         $filial = Filials::getDefault();
         Client::update($client['id'], array('filial_id' => $filial['id']));
         db::update(TABLE_ORDERS, array('filial_id' => $filial['id']), 'klient_id = ' . $client['id']);
     }
     $pgs = get_min_max_from_str($_SESSION["zf_work_pages"]);
     // disc id
     try {
         $discipline = Discipline::find($_SESSION["zf_work_predm"]);
         $disc_id = $discipline['id'];
     } catch (Exception $e) {
         $discipline = Discipline::findOneBy(array('name' => $_SESSION["zf_work_predm"]));
         if ($discipline) {
             $disc_id = $discipline['id'];
         } else {
             $disc_id = Discipline::create(array('name' => $_SESSION["zf_work_predm"]));
         }
     }
     $info = $_SESSION["zf_work_dopinfo"];
     $worktype_custom = '';
     $worktype = null;
     try {
         $worktype = Worktypes::find($_SESSION["zf_work_type"]);
     } catch (Exception $e) {
         $worktype = Worktypes::findOneBy(array('name' => $_SESSION["zf_work_type"]));
         if (!$worktype) {
             $worktype_custom = $_SESSION["zf_work_type"];
             $worktype['id'] = null;
         }
     }
     $id = Order::create(array("filial_id" => $filial['id'], "klient_id" => $client['id'], "type_id" => $worktype['id'], "type_user" => $worktype_custom, "disc_id" => $disc_id, "time_kln" => strtotime($_SESSION["zf_work_date"]), "subject" => $_SESSION["zf_work_tema"], "about_kln" => $info, "pages_min" => $pgs["min"], "pages_max" => $pgs["max"]));
     if ($id > 0) {
         ////////////////////////
         // Текст клиенту
         $txt = "<p>Здравствуйте, " . $client["fio"] . "!</p>";
         // Если первый раз
         if (@$_SESSION["new_klient_added"]) {
             $txt .= "<p>Мы очень рады, что Вы решили воспользоваться нашими услугами и высоко ценим Ваше доверие!</p>" . "<p>Теперь Вы можете войти в личный кабинет:<br>" . "&nbsp;Логин: " . $client["email"] . "<br>" . "&nbsp;Пароль: " . $client["password"] . "<br></p>";
         } else {
             $txt .= "<p>Спасибо, что Вы с нами! Для постоянных клиентов у нас всегда есть интересные и выгодные предложения!</p>";
         }
         $zak = "<p>Номер заказа: " . $id . "<br>" . "Дата: " . date("d.m.Y") . "<br>";
         $zak .= "Вид работы: ";
         if (!empty($worktype_custom)) {
             $zak .= $worktype_custom . "<br>";
         } else {
             $zak .= $worktype["name"] . "<br>";
         }
         $zak .= "Дисциплина: ";
         if ($discipline) {
             $zak .= $discipline['name'] . "<br>";
         } else {
             $zak .= $_SESSION["zf_work_predm"] . "<br>";
         }
         $zak .= "Тема работы: " . $_SESSION["zf_work_tema"] . "<br>" . "Требования: " . $_SESSION["zf_work_dopinfo"] . "<br>" . "Дата сдачи: " . $_SESSION["zf_work_date"] . "<br>" . "Число страниц: " . $_SESSION["zf_work_pages"] . "<br>" . ($txt .= "<p>Ваш заказ принят, и в ближайшее время наш менеджер свяжется с Вами.</p>" . "<p>Содержание заказа: <br>" . $zak . "</p>");
         $txt .= "<p><i>С уважением, компания по написанию студенческих работ.</i></p>";
         $email = new Email();
         $email->setData(array('email' => $client['email'], 'name' => $client['fio']), "Ваш заказ принят!", $txt, array(), true, array(), array('email' => $filial['email'], 'name' => $filial['name']));
         //$m->SMTPDebug = true;
         if ($email->send()) {
             $user_send_res = "Письмо клиенту отправлено";
         } else {
             $user_send_res = "Ошибки при отправке письма клиенту: " . $email->ErrorInfo;
         }
         ////////////////////////
         // Текст в приемную заказов
         $zak .= "<p>Заказчик:<br>";
         if (@$_SESSION["new_klient_added"]) {
             $zak .= "Новая регистрация<br>";
         }
         $zak .= "id: " . $client["id"] . "<br>" . "Имя: " . $client["fio"] . "<br>" . "Почта: " . $client["email"] . "<br>" . "Телефон: " . $client["telnum"] . "<br>" . "Город: " . $client["city"] . "<br>" . "Другие контакты: " . $client["contacts"] . "<br>";
         $zak .= $user_send_res;
         // Прикалываем файлы
         $files = check_user_files();
         $message_id = \Components\Entity\Message::create(array('parent_id' => 0, 'order_id' => $id, 'klient_id' => $client["id"], 'visit_id' => 0, 'tender_id' => 0, 'created' => time(), 'creator_id' => 'k' . $client["id"], 'addr' => 'u' . $filial['id'], 'subject' => "Поступил новый заказ #" . $id, 'text' => $zak, 'prior' => 1, 'uvedom' => 1, 'readed' => 0, 'needansv' => 0, 'basket' => 0));
         if (!empty($message_id)) {
             \Components\Classes\Author::enqueue_message_to_email($message_id, $filial['id'], EmailNotification::TO_MANAGER_ON_CLIENT_CREATED_ORDER);
         }
         /* ОТПРАВИТЬ В РЕАЛЬНОМ ВРЕМЕНИ
            $email = new Email();
            $email->setData(array(
              'email' => FIRM_ORD_MAIL,
              'name' => 'Приемная заказов',
            ), "Поступил новый заказ #" . $id, $zak, $files, true, array(), array(
              'email' => $filial['email'],
              'name' => $filial['name'],
            ));
            $email->send();
            ENDOF ОТПРАВИТЬ В РЕАЛЬНОМ ВРЕМЕНИ */
         // move file
         if (count($files)) {
             $path = DIR_FS_ORDER_FILES . $id;
             if (!file_exists($path)) {
                 mkdir($path);
             }
             foreach ($files as $f) {
                 $fid = OrderFile::create(array('order_id' => $id, 'creator_id' => 0, 'created' => time(), 'name' => $f["name"], 'size' => $f["size"]));
                 if ($fid > 0) {
                     $ext = substr($f["name"], strrpos($f["name"], ".") + 1);
                     $f_s = fopen($f["path"], "r");
                     $f_d = fopen($path . "/" . $fid . "." . $ext, "w");
                     fwrite($f_d, fread($f_s, $f["size"]));
                     fclose($f_s);
                     fclose($f_d);
                 }
                 unlink($f["path"]);
             }
         }
         $path = TMPFILES_PATH . session_id();
         if (file_exists($path)) {
             rmdir($path);
         }
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
파일: functions.php 프로젝트: yonkon/diplom
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;
        }
    }
}