Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Inbox();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Inbox'])) {
         $model->attributes = $_POST['Inbox'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #2
0
 public function actionC()
 {
     $u =& $this->iuser;
     $model = new Inbox();
     if (isset($_POST['Inbox'])) {
         $model->attributes = $_POST['Inbox'];
         $dest_user = User::model()->findByPk($_POST['Inbox']['dest_id']);
         $model->c_time = Time::now();
         $model->source_id = $u->id;
         $model->memo = strip_tags($model->memo);
         if ($model->save()) {
             $this->redirect(array('index'));
             exit;
         }
     } else {
         $dest_user = User::model()->findByPk($_GET['dest_id']);
         if ($dest_user == null) {
             throw new CHttpException(404, 'The requested Node does not exist.');
         }
         $model->dest_id = $dest_user->id;
     }
     $this->render('create', array('dest_user' => $dest_user, 'm' => $u, 'model' => $model), false, true);
 }
Пример #3
0
 public function postLienHe()
 {
     $validator = Validator::make(Input::all(), Inbox::$rules);
     var_dump(Input::all());
     // process the login
     if ($validator->fails()) {
         return Redirect::to('users/lien-he')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         $inbox = new Inbox();
         $inbox->name = Input::get('name');
         $inbox->phone = Input::get('phone');
         $inbox->content = Input::get('content');
         $inbox->save();
         Logfile::addData('Gửi', 'Tin nhắn', $inbox->id, $inbox->name);
         // redirect
         Session::flash('message', 'Gửi Tin nhắn thành công!');
         return Redirect::to('users/lien-he');
     }
 }
Пример #4
0
 function sendReplyMsg()
 {
     $json['bool'] = 0;
     $json['err'] = "ok";
     $accid = addslashes($_POST['acc_id']);
     $inboxid = addslashes($_POST['inboxid']);
     $isi = addslashes($_POST['isi']);
     // $emai = addslashes($_POST['emai']);
     if ($accid == "") {
         $json['err'] = Lang::t('lang_id_empty');
     }
     if ($inboxid == "") {
         $json['err'] = Lang::t('lang_inbox_id_empty');
     }
     if ($isi == "") {
         $json['err'] = Lang::t('lang_isi_empty');
     }
     if ($json['err'] == "ok") {
         $in = new InboxReply();
         $tgl = date("Y-m-d H:i:s");
         $in->inbox_id = $inboxid;
         $in->inbox_to = $accid;
         $in->inbox_from = Account::getMyID();
         $in->inbox_msg = $isi;
         $in->inbox_createdate = $tgl;
         if ($in->save()) {
             //update inbox
             $inbox = new Inbox();
             $inbox->getByID($inboxid);
             $inbox->inbox_changedate = $tgl;
             $inbox->inbox_anzahlreply++;
             $inbox->load = 1;
             $inbox->addInboxNotif($accid, $inboxid, $inbox->inbox_read);
             //cek read didalamnya
             if ($inbox->inbox_read) {
                 //update Notif
                 $inbox->inbox_read = 0;
             }
             $inbox->inbox_giliran_read = $accid;
             $inbox->save();
             $json['bool'] = 1;
         } else {
             $json['err'] = Lang::t('lang_failed');
         }
     }
     echo json_encode($json);
     exit;
 }
Пример #5
0
 public function despacharProyecto()
 {
     require_once 'lib/model/base/Proyecto.class.php';
     require_once 'lib/model/base/Inbox.class.php';
     require_once 'lib/model/base/Bitacora.class.php';
     require_once 'lib/model/base/Accion.class.php';
     $idProyecto = isset($_REQUEST['id_proyecto']) ? $_REQUEST['id_proyecto'] : null;
     if ($_POST) {
         $bitacora = new Bitacora();
         $bitacora->idProyecto = $idProyecto;
         $bitacora->idAccion = $_POST['accion_usuario'];
         $bitacora->idUsuario = $_SESSION['usuario'];
         $bitacora->fechaCreacion = date('Y-m-d');
         $bitacora->observacion = $_POST['observacion'];
         $bitacora->save();
         if ($_POST['id_inbox']) {
             $bind = Inbox::find($_POST['id_inbox']);
             $inbox = new Inbox($bind);
         } else {
             $inbox = new Inbox();
         }
         $inbox->idProyecto = $idProyecto;
         $inbox->fechaDespacho = date('Y-m-d');
         $inbox->idEmisor = $_SESSION['usuario'];
         $inbox->idDestinatario = $_POST['id_destinatario'];
         if (isset($_POST['id_accion'])) {
             $inbox->idAccion = $_POST['id_accion'];
         }
         $inbox->save();
         $bind = Proyecto::find($idProyecto);
         $proyecto = new Proyecto($bind);
         $bindAccion = Accion::find($_POST['id_accion']);
         $accion = new Accion($bindAccion);
         $proyecto->idEstadoProyecto = $accion->idEstadoInicial;
         $proyecto->save();
     }
 }
 function sendMsg()
 {
     $json['bool'] = 0;
     $json['err'] = "ok";
     $accid = addslashes($_POST['acc_id']);
     $judul = addslashes($_POST['judul']);
     $isi = addslashes($_POST['isi']);
     $emai = isset($_POST['emai']) ? addslashes($_POST['emai']) : 0;
     $type = isset($_POST['type']) ? addslashes($_POST['type']) : "casual";
     if ($accid == Account::getMyID()) {
         $json['err'] = Lang::t('Receipient ID error');
     }
     if ($accid == "") {
         $json['err'] = Lang::t('Receipient ID empty');
     }
     if ($judul == "") {
         $json['err'] = Lang::t('Message Title empty');
     }
     if ($isi == "") {
         $json['err'] = Lang::t('Message Content empty');
     }
     if ($json['err'] == "ok") {
         $in = new Inbox();
         $tgl = date("Y-m-d H:i:s");
         $in->inbox_from = Account::getMyID();
         $in->inbox_to = $accid;
         $in->inbox_giliran_read = $accid;
         $in->inbox_read = 0;
         $in->inbox_createdate = $tgl;
         $in->inbox_changedate = $tgl;
         $in->inbox_judul = $judul;
         $in->inbox_msg = $isi;
         $in->inbox_type = $type;
         $inboxid = $in->save();
         if ($inboxid) {
             $json['bool'] = $in->addInboxNotif($accid, $inboxid, 1);
             // cek read didalamnya makanya dikasi val 0
             //send mail
             if ($emai) {
                 $lem = new Leapmail();
                 if (!$lem->sendByID($accid, $judul, $isi)) {
                     $json['err'] = Lang::t('Send Email Failed');
                 }
             }
         } else {
             $json['err'] = Lang::t('Saving Failed');
         }
     }
     echo json_encode($json);
 }
 public function sendMessage()
 {
     $recipient = Input::get('recipient');
     $subject = Input::get('subject');
     $message = Input::get('message');
     $submit_type = Input::get('submit_type');
     $now = new DateTime();
     $validation = Validator::make(['recipient' => Input::get('recipient'), 'subject' => Input::get('subject'), 'message' => Input::get('message')], ['recipient' => 'required', 'subject' => 'required|max:40|min:4', 'message' => 'required|max:120|min:10']);
     if ($validation->fails()) {
         return 'Error Happend';
     } else {
         try {
             if ($submit_type == "Send") {
                 $inbox = new Inbox();
                 $inbox->sender_id = Auth::id();
                 $inbox->receiver_id = $recipient;
                 $inbox->unread = 1;
                 $inbox->subject = $subject;
                 $inbox->message = $message;
                 $inbox->time = $now;
                 $inbox->save();
                 return Redirect::route('home');
             } elseif ($submit_type == "Draft") {
                 $draft = new Draft();
                 $draft->creator_id = Auth::id();
                 $draft->send_to_id = $recipient;
                 $draft->subject = $subject;
                 $draft->message = $message;
                 $draft->time = $now;
                 $draft->save();
                 return Redirect::route('home');
             }
         } catch (Exception $e) {
             echo $e;
         }
     }
 }