Example #1
0
 public function print_data()
 {
     $mydata = $this->data;
     include_once PLUGIN_DIR_PATH . 'libs/Export2Excel.class.php';
     global $wpdb;
     $user_table = $this->table_prefix . 'users';
     $subject_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_SUBJECTS;
     $room_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_PHONG;
     $mydata = $this->data;
     if (!isset($mydata['id'])) {
         return $mydata;
     }
     //$where ='join('.$this->table_prefix.'users) on '.$this->table.'.soluong='.$this->table_prefix.'users.id ';
     $where = 'join(' . $subject_table . ',' . $room_table . ',' . $user_table . ') on ' . $this->table . '.magv=' . $user_table . '.id and ' . $this->table . '.maphong=' . $room_table . '.maphong   and ' . $this->table . '.mamon=' . $subject_table . '.mamon ';
     $where .= ' where  mabh=' . $mydata['id'];
     $query = "select * from {$this->table}";
     if ($where) {
         $query .= "  {$where}";
     }
     $response = $wpdb->get_results($query, ARRAY_A);
     if (empty($response)) {
         $this->throwError("Record not found");
         return false;
     }
     $record = $response[0];
     $header = ['E1' => 'Thống kê chi tiết buổi học', 'D2' => 'Giảng viên: ' . $record['display_name'], 'E2' => 'Môn học: ' . $record["tenmon"], 'D3' => 'Lớp:' . $record["lop"], 'E3' => 'Sĩ số:' . $record["siso"] . '/' . $record['sosv'], 'D4' => 'Phòng :' . $record['tenphong'], 'E4' => 'Tiết:' . $record["tiethoc"], 'F4' => 'Ngày học:' . $record["ngayhoc"]];
     $table_header = ['C6' => 'Mã Thiết Bị', 'D6' => 'Tên Thiết Bị', 'E6' => 'Số Lượng'];
     $lesson_detail = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_BUOIHOCCHITIET;
     $device_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_THIETBI;
     if (!isset($mydata['id'])) {
         return false;
     }
     $where = ' where  mabh=' . $mydata['id'];
     $query = 'select ' . $lesson_detail . '.matb,tentb,' . $lesson_detail . '.soluong from ' . $lesson_detail;
     $query .= ' join(' . $device_table . ') ON ' . $lesson_detail . '.matb=' . $device_table . '.matb';
     $query .= $where;
     $response = $wpdb->get_results($query, ARRAY_A);
     $e2e = new Export2Excel();
     $e2e->header = $header;
     $e2e->table_header = $table_header;
     $e2e->row_start = 7;
     $e2e->col_start = 2;
     $e2e->title = 'Chi tiết buổi học';
     $e2e->subject = 'Thống kê chi tiết buổi học';
     $e2e->data = $response;
     return $e2e->Writer();
 }
 public function print_data()
 {
     $mydata = $this->data;
     include_once PLUGIN_DIR_PATH . 'libs/Export2Excel.class.php';
     global $wpdb;
     $user_table = $this->table_prefix . 'users';
     $subject_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_SUBJECTS;
     $room_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_PHONG;
     $mydata = $this->data;
     if (!isset($mydata['type'])) {
         return $mydata;
     }
     $user_table = $this->table_prefix . 'users';
     $device_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_THIETBI;
     $linhkien_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_LINHKIEN;
     $status_table = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_LOAITINHTRANG;
     $query = "select " . $device_table . ".matb," . $device_table . ".tentb," . $user_table . ".display_name," . $status_table . ".tenloaitinhtrang," . $linhkien_table . ".tenlk, " . $this->table . ".soluong," . $this->table . ".soluong," . $this->table . ".ndsua," . $this->table . ".ghichu from {$this->table}";
     $query .= ' join(' . $device_table . ',' . $linhkien_table . ',' . $status_table . ',' . $user_table . ') on ' . $this->table . '.nguoisua=' . $user_table . '.id and ' . $this->table . '.lkthaythe=' . $linhkien_table . '.malk and ' . $this->table . '.tinhtrang=' . $status_table . '.loaitinhtrang and ' . $this->table . '.matb=' . $device_table . '.matb ';
     if ($mydata["type"] != 'all') {
         $query .= 'where tinhtrang="' . $mydata["type"] . '"';
     }
     $response = $wpdb->get_results($query, ARRAY_A);
     if (empty($response)) {
         $this->throwError("Record not found");
         return false;
     }
     $record = $response[0];
     if ($mydata["type"] == 'all') {
         $type = "Tất cả";
     } else {
         $type = "Theo tình trạng";
     }
     $header = ['E1' => 'Thống kê tình trạng thiết bị', 'D2' => 'Thống kê  ' . $type, 'D3' => 'Ngày thống kê:' . date('d/m/Y h:i:s')];
     $table_header = ['C5' => 'Mã Thiết Bị', 'D5' => 'Tên Thiết Bị', 'E5' => 'Người sửa', 'F5' => 'Tình trạng', 'G5' => 'Tên linh kiện', 'H5' => 'Số lượng', 'I5' => 'Nội dung sửa', 'J5' => 'Ghi chú'];
     $lesson_detail = $this->table_prefix . Global_Define::KC_MANAGEMENT_TABLE_BUOIHOCCHITIET;
     $e2e = new Export2Excel();
     $e2e->header = $header;
     $e2e->table_header = $table_header;
     $e2e->row_start = 7;
     $e2e->col_start = 2;
     $e2e->title = 'Thống kê tình trạng thiết bị';
     $e2e->subject = 'Thống kê tình trạng thiết bị';
     $e2e->data = $response;
     return $e2e->Writer();
 }