Пример #1
0
 public static function exportSms($id)
 {
     $ids = is_array($id) ? $id : explode(",", $id);
     header("Content-Type:application/vnd.ms-excel");
     $fileName = ConvertUtil::iIconv(Ibos::lang("SMS export name", "dashboard.default", array("{date}" => date("Ymd"))), CHARSET, "gbk");
     header("Content-Disposition: attachment;filename={$fileName}.csv");
     header("Cache-Control: max-age = 0");
     $head = array("ID", Ibos::lang("Sender", "dashboard.default"), Ibos::lang("Recipient", "dashboard.default"), Ibos::lang("Membership module", "dashboard.default"), Ibos::lang("Recipient phone number", "dashboard.default"), Ibos::lang("Content", "dashboard.default"), Ibos::lang("Result", "dashboard.default"), Ibos::lang("Send time", "dashboard.default"));
     foreach ($head as &$header) {
         $header = ConvertUtil::iIconv($header, CHARSET, "gbk");
     }
     $fp = fopen("php://output", "a");
     fputcsv($fp, $head);
     $cnt = 0;
     $limit = 100;
     $system = Ibos::lang("System", "dashboard.default");
     foreach (NotifySms::model()->fetchAll(sprintf("FIND_IN_SET(id,'%s')", implode(",", $ids))) as $row) {
         if ($limit == $cnt) {
             ob_flush();
             flush();
             $cnt = 0;
         }
         $data = array($row["id"], ConvertUtil::iIconv($row["uid"] == 0 ? $system : User::model()->fetchRealnameByUid($row["uid"]), CHARSET, "gbk"), ConvertUtil::iIconv(User::model()->fetchRealnameByUid($row["touid"]), CHARSET, "gbk"), $row["module"], $row["mobile"], ConvertUtil::iIconv($row["content"], CHARSET, "gbk"), ConvertUtil::iIconv($row["return"], CHARSET, "gbk"), date("Y-m-d H:i:s", $row["ctime"]));
         fputcsv($fp, $data);
     }
     exit;
 }
Пример #2
0
 public function actionDel()
 {
     $id = EnvUtil::getRequest("id");
     $id = StringUtil::filterStr($id);
     NotifySms::model()->deleteAll("FIND_IN_SET(id,'{$id}')");
     $this->ajaxReturn(array("isSuccess" => true));
 }