Example #1
0
function find_aft_mails($id, $ret = array())
{
    try {
        $message = Message::findOneBy(array('parent_id' => $id));
    } catch (InvalidArgumentException $e) {
        $message = array();
    }
    if (!$message) {
        return $ret;
    }
    $message["sender"] = mls_getAdrName($message["creator_id"]);
    $ret[] = $message;
    $ret = find_aft_mails($message["id"], $ret);
    return $ret;
}
Example #2
0
    foreach ($ids as $id) {
        if (intval($id) > 0) {
            $message = Message::find($id);
            if ($message) {
                if ($message["addr"] == "u" . $_SESSION["user"]["data"]["id"]) {
                    mls_setreaded($message);
                    $n++;
                }
            }
        }
    }
    $GUI->OK("Отмечено писем: " . $n);
    die("" . $n);
}
if (isset($_REQUEST["ids_to_trash"])) {
    $n = 0;
    $ids = explode(";", $_REQUEST["ids_to_trash"]);
    foreach ($ids as $id) {
        if (intval($id) > 0) {
            $message = Message::find($id);
            if ($message) {
                if ($message["addr"] == "u" . $_SESSION["user"]["data"]["id"]) {
                    mls_setbasket($message, 1);
                    $n++;
                }
            }
        }
    }
    $GUI->OK("Перемещено в корзину писем: " . $n);
    die("" . $n);
}
Example #3
0
<?php

use Components\Classes\Roles;
use Components\Classes\db;
use Components\Entity\Message;
include_once "functions.php";
if (isset($_REQUEST["read"])) {
    $message = Message::find(intval($_REQUEST["read"]));
    if ($message) {
        $GUI->tmpls[] = $active_module_root . "read.tmpl.php";
        include "inc_read.php";
        return;
    } else {
        $GUI->ERR("Письмо не найдено");
        page_ReloadSubSec();
    }
}
if (isset($_REQUEST['delete'])) {
    \Components\Entity\EmailNotification::delete($_REQUEST['delete']);
}
$tbl = $GUI->Table("mls_problems", array("cur_sort_up" => true));
$tbl->Width = "100%";
$tbl->DataMYSQL('email_notifications en JOIN ' . TABLE_MESSAGES . ' m ON m.id=en.message_id', 'en.*, m.id AS mid', 'en');
$tbl->FilterMYSQL("en.attempts_to_send>0");
$tbl->Pager(CGUI_PAGER_FLAG_SEL | CGUI_PAGER_FLAG_RR | CGUI_PAGER_FLAG_R | CGUI_PAGER_FLAG_FF | CGUI_PAGER_FLAG_F, 10, array(10, 20, 50, 100, 0));
global $n;
if (Roles::isActionAllowed($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "Просмотр сообщения")) {
    $tbl->RowEvent2 = "if(window.locationLocked === undefined || window.locationLocked ==false) { document.location.href=\"?section=mls&subsection=" . MLS_SELECTED_INBOX . "&type=o&read=%var.message_id%\";} else window.locationLocked = false;";
}
$tbl->OnRowStart = "_set_row_color";
$columns_resource = Roles::getColumns($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"]);
Example #4
0
if (isset($_REQUEST["_ans"])) {
    $id = intval($_REQUEST["_ans"]);
    $m = Message::find($id);
    if ($m && mls_userMaySee($m, $_SESSION["user"]["data"]["id"]) && $m["creator_id"] == $_REQUEST["_to"]) {
        $ansv_to = $m;
        $h = $frm->Hidden($id);
        $h->linkName = "ans";
        $frm->Label("В ответ на письмо №" . $id . " от " . date("d.m.y", $m["created"]), 10, $ypos);
        $ypos += 30;
    }
}
$resend_to = false;
if (isset($_REQUEST["_rep"])) {
    $id = intval($_REQUEST["_rep"]);
    // Переслать. Получим письмо, убедимся что пользователь может его видеть
    $m = Message::find($id);
    if ($m && mls_userMaySee($m, $_SESSION["user"]["data"]["id"])) {
        $ansv_to = false;
        $need_to = false;
        $resend_to = $m;
    }
}
$frm->Label("Тема", 10, $ypos);
$s = "";
if ($ansv_to) {
    $s = "[Ответ на исх. №" . $ansv_to["id"] . " от " . date("d.m.y", $ansv_to["created"]) . "]";
}
if ($resend_to) {
    $s = $resend_to["subject"];
}
if (!empty($_REQUEST["_order"])) {
Example #5
0
 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;
     }
 }
Example #6
0
 /**
  * @param int $order_id Номер заказа
  * @param array $authors_ids id получателей
  * @param string $sender_id id отправителя с префиксом клиент/сотрудник (н-р "u330")
  * @param string $subject тема сообщения
  * @param string $body текст сообщения
  * @param int $notification_type тип сообщения, из набора EmailNotificationType::$NOTIFICATION_TYPES
  * @see EmailNotificationType
  * @return array|bool Добавляет внутреннее сообщение и ставит его в очередь рассылки по cron<br/>Массив ассоциативных массивов с ключами 'name' и 'email' тех, для кого сообщение не было создано или не поставлено в очередь рассылки | false в случае ошибки
  */
 public static function saveMessageAndEnqueueEmail($order_id, array $authors_ids, $sender_id, $subject, $body, $notification_type)
 {
     static $order, $manager, $filial, $attachments;
     // Если не надо пихать в ядро - выходим типа все ок
     if (!EmailNotificationType::isPersistable($notification_type)) {
         return array();
     }
     if (!is_array($authors_ids)) {
         if (is_numeric($authors_ids)) {
             $authors_ids = array($authors_ids);
         } else {
             return false;
         }
     }
     if (empty($order)) {
         try {
             $order = Order::find($order_id);
         } catch (Exception $e) {
             return false;
         }
     }
     if (empty($manager)) {
         try {
             $manager = Employee::find($order['manager_id']);
         } catch (Exception $e) {
             return false;
         }
     }
     $replyTo = array('email' => $manager['email'], 'name' => $manager['fio']);
     $result = array();
     foreach ($authors_ids as $id) {
         if (is_numeric($id)) {
             try {
                 $author = Employee::find($id);
             } catch (Exception $e) {
                 continue;
             }
             $receiver = array('email' => $author['email'], 'name' => $author['fio']);
             //Сохраняем уведомление
             $message_id = Message::create(array('parent_id' => 0, 'order_id' => $order_id, 'klient_id' => $order['klient_id'], 'visit_id' => 0, 'tender_id' => 0, 'created' => time(), 'creator_id' => $sender_id, 'addr' => 'u' . $id, 'subject' => $subject, 'text' => $body, 'prior' => 1, 'uvedom' => 1, 'readed' => 0, 'needansv' => 0, 'basket' => 0));
             if (!empty($message_id)) {
                 //Ставим в очередь на отправку по cron
                 $email_notification = enqueue_message_to_email($message_id, $author['email'], $notification_type);
             }
             if (empty($email_notification)) {
                 $result[] = $receiver;
             }
         } else {
             $ids = explode(', ', $id);
             $temp_result = self::saveMessageAndEnqueueEmail($order_id, $ids, $sender_id, $subject, $body, $notification_type);
             if (count($temp_result)) {
                 array_push($result, $temp_result);
             }
         }
     }
     return $result;
 }
Example #7
0
function _get_prior_name($v, $k)
{
    $out = "";
    $pr = array(0 => "низкий", 1 => "нормальный", 2 => "высокий");
    $pr_c = array(0 => "<font color=blue>низкий</font>", 1 => "<font color=green>нормальный</font>", 2 => "<font color=red>высокий</font>");
    if ($k["readed"]) {
        $out = $pr[$v];
    } else {
        $out = $pr_c[$v];
    }
    if ($k["needansv"]) {
        if (Message::findBy(array('parent_id' => $k["id"]))) {
            $out .= ", <font color=gray>ответ отправлен</font>";
        } else {
            $out .= ", <font color=red>ответ до " . date("d.m.y", $k["needansv"]) . "</font>";
        }
    }
    return $out;
}
function cron_sendEmailNotifications()
{
    $execution_time = ini_get('max_execution_time');
    if (empty($execution_time)) {
        $execution_time = DEF_EXEC_TIME;
    } else {
        if ($execution_time > MAX_EXEC_TIME * 2) {
            $execution_time = MAX_EXEC_TIME * 2;
        }
    }
    $execution_time_start = time();
    $execution_time_end = $execution_time_start + $execution_time / 2;
    $notifications = \Components\Entity\EmailNotification::findBy(array(), array('attempts_to_send' => 'ASC'), EMAIL_NOTIFICATION_LIMIT, 0);
    $notification_index = 0;
    $good_cnt = 0;
    $notification_count = count($notifications);
    while (time() <= $execution_time_end && $notification_index < $notification_count) {
        $notification = $notifications[$notification_index];
        $message = \Components\Entity\Message::find($notification['message_id']);
        if (!empty($message)) {
            //Прочитано, или не шлем - надо его сразу убить, чтобы потом когда включим не повалил шквал старых писем
            if ($message['readed'] || !\Components\Entity\EmailNotificationType::isSendable($notification['type'])) {
                \Components\Entity\EmailNotification::delete($notification['id']);
            } else {
                $attachments = array();
                // надо только для писем типа \Components\Entity\EmailNotification::TO_SUBSCRIBED_AUTHORS_ON_DISTRIBUTION
                $all_added_size = 0;
                $fna = 0;
                if ($notification['type'] == \Components\Entity\EmailNotification::TO_SUBSCRIBED_AUTHORS_ON_DISTRIBUTION && !empty($message['order_id'])) {
                    $files = get_order_files($message['order_id']);
                    foreach ($files as $file) {
                        $all_added_size += $file['size'];
                        if ($all_added_size > 16000000) {
                            // write to body, but not add file
                            $fna++;
                        } else {
                            $attachments[] = array('path' => get_file_path($message['order_id'], $file), 'name' => $file['name']);
                        }
                    }
                }
                $subtext = "";
                if ($fna) {
                    $subtext = "<br><br>-----------------------------------<br>" . "Еще " . $fna . " файла(ов) не были добавлены к письму из-за ограничения размеров";
                }
                // Это условие проверено выше
                //if ( \Components\Entity\EmailNotificationType::isSendable($notification['type']) )
                //{
                $email = new \Components\Classes\Email();
                $email->IsHTML(true);
                $email->setData(array('email' => $notification['receiver_email'], 'name' => ''), $message['subject'], $message['text'] . $subtext, $attachments, true, Message::getReceiverEmailAndName($message['creator_id']), Message::getReceiverEmailAndName($message['creator_id']));
                try {
                    $send_result = $email->send();
                    if ($send_result) {
                        \Components\Entity\EmailNotification::delete($notification['id']);
                        $good_cnt++;
                    } else {
                        \Components\Entity\EmailNotification::update($notification['id'], array('attempts_to_send' => $notification['attempts_to_send'] + 1, 'last_attempt' => time(), 'last_error' => $email->ErrorInfo));
                    }
                } catch (\Components\Exceptions\Exception $e) {
                    \Components\Entity\EmailNotification::update($notification['id'], array('attempts_to_send' => $notification['attempts_to_send'] + 1, 'last_attempt' => time()));
                }
                unset($email);
                //}
            }
        }
        $notification_index++;
    }
    db::query("update ofc_sys_log set p_value=" . $execution_time_start . " where p_name='email_notify_last_tm_start'");
    db::query("update ofc_sys_log set p_value=" . (time() - $execution_time_start) . " where p_name='email_notify_last_tm_work'");
    db::query("update ofc_sys_log set p_value=" . $notification_index . " where p_name='email_notify_last_all_cnt'");
    db::query("update ofc_sys_log set p_value=" . $good_cnt . " where p_name='email_notify_last_good_cnt'");
}
Example #9
0
             $h = 180;
         }
         print "<div style='height: " . $h . "px; overflow: auto;'>" . $out . "<div style='border-top: 1px solid silver;'></div></div>";
     }
 }
 if (isset($messages[intval($_REQUEST["messages"])])) {
     $m = $messages[intval($_REQUEST["messages"])];
     if (!$m["readed"]) {
         Message::update($m["id"], array('readed' => 1));
     }
     if (isset($_REQUEST["cab_msg_answer"])) {
         $t = clearText($_REQUEST["cab_msg_answer"]);
         if (strlen($t)) {
             $t = substr($t, 0, 1000);
             $sbj = "[Re] " . $m["subject"];
             $message_id = Message::create(array("parent_id" => $m["id"], "klient_id" => $m["klient_id"], "created" => time(), "creator_id" => $m["addr"], "addr" => $m["creator_id"], "subject" => $sbj, "text" => $t, "prior" => 1));
             if ($message_id) {
                 enqueue_message_to_email($message_id, message_reciever_to_email($m['creator_id']), \Components\Entity\EmailNotificationType::TO_RECEIVER_ON_MESSAGE_COMMON);
                 $_SESSION["cab_msg_answer_info"] = "<span style='color:green'>Сообщение отправлено</span>";
             } else {
                 $_SESSION["cab_msg_answer_info"] = "<span style='color:red'>Не удалось отправить сообщение</span>";
             }
             header("location: ?type=cabinet&messages=" . $m["id"]);
             print $_SESSION["cab_msg_answer_info"];
             die;
         } else {
             $_SESSION["cab_msg_answer_info"] = "Введите текст сообщения";
         }
     }
     ?>
 <script>
Example #10
0
 public static function create_order($order_parameters)
 {
     $result = array('status' => false, 'msg' => '');
     $message = array();
     if (empty($order_parameters['client_id'])) {
         $result['msg'] = "Id клиента не указан";
         return $result;
     }
     if ($order_parameters['work'] == 0 && !strlen($order_parameters['work_usr'])) {
         $order_parameters['work_usr'] = "******";
         //            $message[] = "Не указан вид работы";
     }
     if ($order_parameters['disc'] == 0 && !strlen($order_parameters['disc_usr'])) {
         $order_parameters['disc_usr'] = "******";
         //          $message[] = "Не указана дисциплина";
     }
     if ($order_parameters['pgmax'] && $order_parameters['pgmax'] < $order_parameters['pgmin']) {
         $message[] = "Неверно указано макс. число страниц";
     }
     if ($order_parameters['srcmax'] && $order_parameters['srcmax'] < $order_parameters['srcmin']) {
         $message[] = "Неверно указано макс. число источников";
     }
     if (count($message)) {
         $result['msg'] = join("\n", $message);
         return $result;
     }
     $date = mktime();
     $filial_id = db::get_single_value("SELECT filial_id FROM " . TBL_PREF . "clients WHERE id = " . db::input($order_parameters['client_id']) . "");
     if (!$filial_id) {
         $filial_id = $order_parameters['filial_id'];
     }
     if (!$filial_id) {
         $query = "SELECT ftc.filial_id FROM " . TBL_PREF . "clients c  JOIN " . TBL_PREF . "data_city dc ON dc.name = c.city JOIN " . TBL_PREF . "filial_to_city ftc ON ftc.city_id = dc.id" . " WHERE c.id = " . db::input($order_parameters['client_id']) . "";
         $filial_id = db::get_single_value($query);
     }
     $order_id = Order::create(array("filial_id" => $filial_id, "klient_id" => $order_parameters['client_id'], "vuz_id" => $order_parameters['vuz'], "vuz_user" => $order_parameters['vuz_usr'], "type_id" => $order_parameters['work'], "type_user" => $order_parameters['work_usr'], "napr_id" => $order_parameters['napr'], "disc_id" => $order_parameters['disc'], "disc_user" => $order_parameters['disc_usr'], "time_kln" => $order_parameters['time_kln'], "payment_id" => $order_parameters['opl'], "subject" => $order_parameters['subj'], "about_kln" => $order_parameters['treb'], "kurs" => $order_parameters['kurs'], "prakt_pc" => $order_parameters['prakt'], "pages_min" => $order_parameters['pgmin'], "pages_max" => $order_parameters['pgmax'], "src_min" => $order_parameters['srcmin'], "src_max" => $order_parameters['srcmax'], "from_id" => 4));
     //        foreach ($_FILES as $file) {
     //            if (is_uploaded_file($file["tmp_name"])) {
     //                $extension = pathinfo($file['name']);
     //                $extension = strtolower($extension['extension']);
     //
     //                $file_id = \Components\Entity\OrderFile::create() ::attachFile($order_id, 0, $file["name"], $file["size"]);
     //
     //                if (!$file_id) {
     //                    $result['msg'] = "Ошибка при загрузке файла";
     //                    return $result;
     //                } else {
     //                    $dir = DIR_FS_ORDER_FILES . $order_id . '/';
     //                    if (!is_dir(DIR_FS_ORDER_FILES)) {
     //                        create_path('order_files', DIR_FS_DOCUMENT_ROOT);
     //                    }
     //                    if (!is_dir($dir)) {
     //                        create_path($order_id, DIR_FS_ORDER_FILES);
     //                    }
     //
     //                    $file_name = $file_id . '.' . $extension;
     //
     //                    if (!move_uploaded_file($file['tmp_name'], $dir . $file_name)) {
     //                        Order::deleteAttachedFile($file_id);
     //                        $result['msg'] = "Ошибка при сохранении файла";
     //                        return $result;
     //                    }
     //                }
     //            }
     //        }
     if ($order_id) {
         ////////////////////////
         // Текст клиенту
         $client = Client::find($order_parameters['client_id']);
         $filial = \Components\Entity\Filial::find($filial_id);
         $txt = "<p>Здравствуйте" . (empty($client["fio"]) ? "" : ", " . $client["fio"]) . "!</p>";
         // Если первый раз
         if (@$_SESSION["new_klient_added"]) {
             $txt .= "<p>Мы очень рады, что Вы решили воспользоваться нашими услугами и высоко ценим Ваше доверие!</p>";
         } else {
             $txt .= "<p>Спасибо, что Вы с нами! Для постоянных клиентов у нас всегда есть интересные и выгодные предложения!</p>";
         }
         $zak = "<p>Номер заказа: " . $order_id . "<br>" . "Дата: " . date("d.m.Y") . "<br>";
         $zak .= "Вид работы: ";
         if (!empty($order_parameters['work_usr'])) {
             $zak .= $order_parameters['work_usr'] . "<br>";
         } else {
             $worktype = \Components\Entity\Worktypes::find($order_parameters['work']);
             $zak .= $worktype['name'] . "<br>";
         }
         $zak .= "Дисциплина: ";
         if ($order_parameters['disc_usr']) {
             $zak .= $order_parameters['disc_usr'] . "<br>";
         } else {
             $discipline = \Components\Entity\Discipline::find($order_parameters['disc']);
             $zak .= $discipline['name'] . "<br>";
             //                $zak .= $_SESSION["zf_work_predm"] . "<br>";
         }
         if ($order_parameters['subj']) {
             $zak .= "Тема работы: " . $order_parameters['subj'] . "<br>";
         }
         if ($order_parameters['treb']) {
             $zak .= "Требования: " . $order_parameters['treb'] . "<br>";
         }
         if ($order_parameters['time_kln']) {
             $zak .= "Дата сдачи: " . $order_parameters['time_kln'] . "<br>";
         }
         if ($order_parameters['pgmin'] && $order_parameters['pgmax']) {
             $zak .= "Число страниц: " . $order_parameters['pgmin'] . "-" . $order_parameters['pgmax'] . "<br>";
         }
         $txt .= "<p>Ваш заказ принят, и в ближайшее время наш менеджер свяжется с Вами.</p>" . "<p>Содержание заказа: <br>" . $zak . "</p>";
         $txt .= "<p><i>С уважением, компания по написанию студенческих работ.</i></p>";
         $email = new \Components\Classes\Email();
         $email->setData(array('email' => $client['email'], 'name' => $client['fio']), "Ваш заказ принят!", $txt, array(), true, array(), array('email' => $filial['email'], 'name' => $filial['name']));
         //$m->SMTPDebug = true;
         $mailErrors = array();
         if (!$email->send()) {
             $mailErrors[] = "Ошибки при отправке письма клиенту: " . $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>";
         if (!empty($mailErrors)) {
             $zak .= join('<br>', $mailErrors);
         }
         $message_id = \Components\Entity\Message::create(array('parent_id' => 0, 'order_id' => $order_id, 'klient_id' => $client["id"], 'visit_id' => 0, 'tender_id' => 0, 'created' => time(), 'creator_id' => 'k' . $client["id"], 'addr' => 'u' . $filial['user_id'], 'subject' => "Поступил новый заказ #" . $order_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['user_id'], \Components\Entity\EmailNotification::TO_MANAGER_ON_CLIENT_CREATED_ORDER);
         }
         // Прикалываем файлы
         $files = $_FILES;
         // move file
         if (count($files)) {
             $path = DIR_FS_ORDER_FILES . $order_id;
             if (!file_exists($path)) {
                 mkdir($path);
             }
             foreach ($files as $f) {
                 $fid = \Components\Entity\OrderFile::create(array('order_id' => $order_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["tmp_name"], "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"]);
             }
         }
     }
     return self::generate_response(true, "OK", array('id' => $order_id, 'date' => $date));
 }
Example #11
0
<?php

use Components\Classes\Roles;
use Components\Classes\db;
use Components\Entity\Message;
if (isset($_REQUEST["_add"])) {
    $message = Message::find(intval($_REQUEST["_add"]));
    if ($message && $message["addr"] == "u" . $_SESSION["user"]["data"]["id"]) {
        mls_setbasket($message, 1);
        if ($message["basket"]) {
            $GUI->OK("Перемещено в корзину");
        } else {
            $GUI->ERR("Не удалось переместить в корзину");
        }
    } else {
        $GUI->ERR("Нельзя переместить в корзину");
    }
    page_reloadToSec("2");
}
$tbl = $GUI->Table("mls_in", array("cur_sort_up" => true));
$tbl->Width = "100%";
$tbl->DataMYSQL("messages");
$tbl->FilterMYSQL("addr='u" . $_SESSION["user"]["data"]["id"] . "' AND basket=1");
$tbl->Pager(CGUI_PAGER_FLAG_SEL | CGUI_PAGER_FLAG_RR | CGUI_PAGER_FLAG_R | CGUI_PAGER_FLAG_FF | CGUI_PAGER_FLAG_F, 10, array(10, 20, 50, 100, 0));
global $n;
if (Roles::isActionAllowed($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"], "Просмотр сообщения")) {
    $tbl->RowEvent2 = "document.location.href=\"?section=mls&subsection=2&type=b&read=%var%\"";
}
$tbl->OnRowStart = "_set_row_color";
$columns_resource = Roles::getColumns($GUI->mmenu->selected->id, $GUI->mmenu->selected->selected->id, $_SESSION["user"]["data"]["group_id"]);
if (!is_resource($columns_resource)) {
Example #12
0
    <input type="hidden" name="add_file">
		<div style="height:50px; margin-bottom: 20px;margin-top: 20px; width: 580px;">
			<div>Если имеются методические указания и материалы прикрепите файл (макс. размер 1го файла = ' . ini_get("upload_max_filesize") . ')</div>
			<div id="add_file_field" style="margin-top: 5px">
           		<input type=file name="zf_work_file" value="Выбрать" onchange="mkorder_add_file_change(this)">
			</div>
		</div>
		</form>';
        if ($order["manager_id"]) {
            if (isset($_REQUEST["cab_msg_answer"])) {
                $t = clearText($_REQUEST["cab_msg_answer"]);
                $t = substr($t, 0, 1000);
                if (strlen($t)) {
                    $cid = $_SESSION["frame"]["client"]["id"];
                    $sbj = "Сообщение от клиента по заказу " . $order["id"];
                    $message_id = Message::create(array("klient_id" => $cid, "order_id" => $order["id"], "created" => time(), "addr" => "u" . $order["manager_id"], "creator_id" => "k" . $cid, "subject" => $sbj, "text" => $t, "prior" => 1));
                    if ($message_id) {
                        \Components\Classes\Author::enqueue_message_to_email($message_id, $order['manager_id'], \Components\Entity\EmailNotificationType::TO_MANAGER_ON_ORDER_CHANGE);
                        $_SESSION["cab_ord_answer_info"] = "<span style='color:green'>Сообщение отправлено</span>";
                    } else {
                        $_SESSION["cab_ord_answer_info"] = "<span style='color:red'>Не удалось отправить сообщение</span>";
                    }
                    header("location: ?type=cabinet&order=" . $order["id"]);
                    die;
                } else {
                    $_SESSION["cab_ord_answer_info"] = "<span style='color:red;'>Введите текст сообщения</span>";
                }
            }
            print "<script>\n\tjQuery(function(){\n\tjQuery('#cab_msg_answer').bind('focus', function(){\n\t\tjQuery('#cab_msg_answer_btn').removeAttr('disabled');\n\t\tjQuery('#cab_msg_answer').css('color', 'black');\n\t\tjQuery('#cab_msg_answer').text('');\n\t\tjQuery('#cab_msg_answer').unbind('focus');\n\t});\n});\n</script>\n<div style='margin-top: 10px'>";
            if (strlen(@$_SESSION["cab_ord_answer_info"])) {
                print "<div style='margin-bottom: 5px;'>" . $_SESSION["cab_ord_answer_info"] . "</div>";
Example #13
0
<?php

use Components\Classes\db;
use Components\Entity\Employee;
use Components\Entity\Message;
$id = intval($_REQUEST["msgs"]);
if (Employee::find($id)) {
    // Показать с какого по какое есть письма, выбрать дату и получить текстовый файл с перепиской
    // фильтр по адресату
    $messages = Message::findBy(array('creator_id' => 'u' . $id));
    $date_min = 0;
    $date_max = 0;
    $rcps = array();
    foreach ($messages as $v) {
        if ($v["created"] > $date_max) {
            $date_max = $v["created"];
        }
        if ($v["created"] < $date_min || $date_min == 0) {
            $date_min = $v["created"];
        }
    }
    $ypos = 10;
    $frm = $GUI->Form("История переписки сотрудника", 500, 480);
    $t = $frm->Hidden($id);
    $t->linkName = 'employer_id';
    $frm->Label("Сотрудник: " . sotr_getFullName($id), 10, $ypos);
    $frm->Label("Сообщений: " . count($messages) . "; с " . date("d.m.y", $date_min) . " по " . date("d.m.y", $date_max), 10, $ypos += 20);
    $t = $frm->Checkbox(10, $ypos += 20, true, 1);
    $t->linkName = 'with_employers';
    $frm->Label("Переписка с сотрудниками:", 30, $ypos);
    $frm->Label("Дата:", 330, $ypos);