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;
 }
 public function see()
 {
     $inbox_id = isset($_GET['id']) ? addslashes($_GET['id']) : die('inbox id empty');
     $begin = isset($_GET['begin']) ? addslashes($_GET['begin']) : '0';
     $limit = 20;
     $all = 0;
     //for all
     $id = Account::getMyID();
     $inbox = new Inbox();
     $inbox->getByID($inbox_id);
     //set read utk inbox
     if ($inbox->inbox_read == 0) {
         if ($inbox->inbox_giliran_read == $id) {
             $inbox->setRead($inbox_id);
             // set read to 1
             $inbox->setOld($inbox_id);
             // set notification - 1
         }
     }
     $ir = new InboxReply();
     //ambil jumlah total
     $clause = " inbox_id = '{$inbox_id}' ";
     $return['total'] = $ir->getJumlah($clause);
     if ($begin == "all") {
         $all = 1;
         $begin = $limit;
         $limit = $return['total'] - $limit;
         // echo $return['total']. " " .$begin." ".$limit;
     }
     $whereClause = "inbox_id = '{$inbox_id}' ORDER BY inbox_createdate DESC LIMIT {$begin},{$limit}";
     $arrReply = $ir->getWhere($whereClause);
     //set read
     foreach ($arrReply as $num => $obja) {
         if ($obja->inbox_read == 0) {
             if ($inbox->inbox_giliran_read == $id) {
                 //dicomment sementara roy.
                 $obja->setReadReply($obja->inbox_reply_id);
             }
         }
     }
     //pr($inbox);
     //pr($arrReply);
     $newArr[] = $inbox;
     if ($all) {
         $merge = array_reverse($arrReply);
     } else {
         $merge = array_merge($newArr, array_reverse($arrReply));
     }
     //to
     $to = new Account();
     $to->getByID($inbox->inbox_to);
     //from
     $from = new Account();
     $from->getByID($inbox->inbox_from);
     $return['limit'] = $limit;
     $return['begin'] = $begin;
     $return['merge'] = $merge;
     $return['inbox'] = $inbox;
     $return['arrReply'] = $arrReply;
     $return['to'] = $to;
     $return['from'] = $from;
     $return['webClass'] = __CLASS__;
     $return['method'] = __FUNCTION__;
     $return['id'] = $id;
     $return['all'] = $all;
     // get all di set jadi di return tanpa chatbox dan judul, isinya aja...
     if (isset($_GET['all'])) {
         $return['all'] = $_GET['all'];
     }
     Mold::both("inbox/see", $return);
 }