Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php	(revision 760)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php	(revision 761)
@@ -29,6 +29,10 @@
 
         $this->load->model('reportmodel');
+        $data['date']=1;
         $data['month'] = date("m");
         $data['year'] = date("Y");
+        $data['to_date']=31;
+        $data['to_month'] = date("m");
+        $data['to_year'] = date("Y");
         if ($this->input->post('month')) {
             $data['month'] = $this->input->post('month');
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php	(revision 760)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php	(revision 761)
@@ -30,6 +30,10 @@
 
         $this->load->model('reportmodel');
+        $data['date'] = 1;
         $data['month'] = date("m");
         $data['year'] = date("Y");
+        $data['to_date'] = 31; 
+        $data['to_month'] = date("m");
+        $data['to_year'] = date("Y");
         if ($this->input->post('month')) {
             $data['month'] = $this->input->post('month');
@@ -64,28 +68,31 @@
         $sheet->getColumnDimension('G')->setWidth(15);
         $sheet->getColumnDimension('H')->setWidth(15); 
-        $sheet->getColumnDimension('I')->setWidth(20);
+        $sheet->getColumnDimension('I')->setWidth(15);
+        $sheet->getColumnDimension('J')->setWidth(15);
         $sheet->setCellValue('A1', "BÃ¡o cÃ¡o thuÃª bao theo tá»nh");
         $sheet->setCellValue('A2', "ThÃ¡ng: " . $data['month'] . " - " . $data['year']);
-        $sheet->setCellValue('C2', "NgÃ y: ".date('d')." - ".date('m')." - ". date('Y').""); 
+        //$sheet->setCellValue('C2', "NgÃ y: ".date('d')." - ".date('m')." - ". date('Y').""); 
         $sheet->setCellValue('A4', "STT");
-        $sheet->setCellValue('B4', "MÃ£ Tá»nh/ThÃ nh Phá»");
-        $sheet->setCellValue('C4', "Tá»nh/ThÃ nh phá»");
-        $sheet->setCellValue('D4', "TB NgÃ y");
-        $sheet->setCellValue('E4', "LÅ©y káº¿ TB thÃ¡ng");
-        $sheet->setCellValue('F4', "Tá»ng TB NgÃ y");
-        $sheet->setCellValue('G4', "DT NgÃ y");
-        $sheet->setCellValue('H4', "LÅ©y káº¿ DT thÃ¡ng");
-        $sheet->setCellValue('I4', "Tá»ng DT nÄm");
+        $sheet->setCellValue('B4', "NgÃ y");
+        $sheet->setCellValue('C4', "MÃ£ Tá»nh/ThÃ nh Phá»");
+        $sheet->setCellValue('D4', "Tá»nh/ThÃ nh phá»");
+        $sheet->setCellValue('E4', "TB NgÃ y");
+        $sheet->setCellValue('F4', "LÅ©y káº¿ TB thÃ¡ng");
+        $sheet->setCellValue('G4', "Tá»ng TB NgÃ y");
+        $sheet->setCellValue('H4', "DT NgÃ y");
+        $sheet->setCellValue('I4', "LÅ©y káº¿ DT thÃ¡ng");
+        $sheet->setCellValue('J4', "Tá»ng DT nÄm");
         $dem=0;
         foreach ($data['provinces'] as $index => $provinces) {
             $sheet->setCellValue('A' . ($dem + 5), $provinces['stt']);
-            $sheet->setCellValue('B' . ($dem + 5), $index);
-            $sheet->setCellValue('C' . ($dem + 5), $provinces['province']);
-            $sheet->setCellValue('D' . ($dem + 5), $provinces['tbng']);
-            $sheet->setCellValue('E' . ($dem + 5), $provinces['tbt']);
-            $sheet->setCellValue('F' . ($dem + 5), $provinces['tbn']);
-            $sheet->setCellValue('G' . ($dem + 5), $provinces['dtng']);
-            $sheet->setCellValue('H' . ($dem + 5), $provinces['dtt']);
-            $sheet->setCellValue('I' . ($dem + 5), $provinces['dtn']);
+            $sheet->setCellValue('B' . ($dem + 5), date('d')." - ".date('m')." - ". date('Y'));
+            $sheet->setCellValue('C' . ($dem + 5), $index);
+            $sheet->setCellValue('D' . ($dem + 5), $provinces['province']);
+            $sheet->setCellValue('E' . ($dem + 5), $provinces['tbng']);
+            $sheet->setCellValue('F' . ($dem + 5), $provinces['tbt']);
+            $sheet->setCellValue('G' . ($dem + 5), $provinces['tbn']);
+            $sheet->setCellValue('H' . ($dem + 5), $provinces['dtng']);
+            $sheet->setCellValue('I' . ($dem + 5), $provinces['dtt']);
+            $sheet->setCellValue('J' . ($dem + 5), $provinces['dtn']);
             $dem++;
         }
@@ -95,3 +102,4 @@
         $writer->save('php://output');
     }
+    
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php	(revision 760)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php	(revision 761)
@@ -16,9 +16,8 @@
 
     function getProvinces($input) {
-        $ext="";
-        if (isset($input['to_month']))
-        {
-            $ext="AND tblpaidlog.paid_time <'" . $input['to_year'] . "-" . $input['to_month'] . "-01 23:59:59'";
-        }
+
+        $from="tblpaidlog.paid_time >'" . $input['year'] . "-" . $input['month'] . "-" . $input['date'] . " 00:00:00'";
+        $to="tblpaidlog.paid_time <'" . $input['to_year'] . "-" . $input['to_month'] . "-" . $input['to_date'] . " 23:59:59'";
+        
         $provinces = lang('_PROVINCES_');
         // Tinh doanh thu theo tinh theo nam
@@ -26,10 +25,11 @@
         $query = $this->db->query($sql);
         $dtns = $query->result_array();
+        
         // tinh doanh thu theo thang
-        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time >'" . $input['year'] . "-" . $input['month'] . "-01' $ext  GROUP BY tbluser.province";
+        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE $from AND $to  GROUP BY tbluser.province";
         $query = $this->db->query($sql);
         $dtts = $query->result_array();
+        
         // tinh doanh thu trong ngay hien tai
-        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time > '" . date('Y') . "-" . date('m') . "-".date('d')." 00:00:00' AND  tblpaidlog.paid_time <'" . date('Y') . "-" . date('m') . "-".date('d')." 23:59:59'  GROUP BY tbluser.province";
         if (isset($input['to_month']))
         {
@@ -45,14 +45,11 @@
 
         // tinh thue bao theo thang
-        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . $input['year'] . "-" . $input['month'] . "-01'  $ext GROUP BY tbluser.province";
+        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND  $to GROUP BY tbluser.province";
         $query = $this->db->query($sql);
         $tbts = $query->result_array();
         
          // tinh thue bao theo ngay
-        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . date('Y') . "-" . date('m') . "-".date('d')." 00:00:00' AND tbluser.created_time < '" . date('Y') . "-" . date('m') . "-".date('d')." 23:59:59'  GROUP BY tbluser.province";
-        if (isset($input['to_month']))
-        {
-            $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 00:00:00' AND tbluser.created_time < '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 23:59:59'  GROUP BY tbluser.province";
-        }
+        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 00:00:00' AND tbluser.created_time < '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 23:59:59'  GROUP BY tbluser.province";
+        
         $query = $this->db->query($sql);
         $tbng = $query->result_array(); 
@@ -104,5 +101,5 @@
         $provinces = lang('_PROVINCES_');
         // tinh thue bao theo thang
-        $sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >'" . $input['year'] . "-" . $input['month'] . "-01' AND tbluser.created_time <'" . $input['year'] . "-" . $input['month'] . "-31' AND tblservicepackage.p_period > 0 ";
+        $sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >'" . $input['year'] . "-" . $input['month'] . "-" . $input['date'] . "' AND tbluser.created_time <'" . $input['to_year'] . "-" . $input['to_month'] . "-" . $input['to_date'] . "' AND tblservicepackage.p_period > 0 ";
         $query = $this->db->query($sql);
         $users = $query->result_array();
@@ -160,5 +157,6 @@
     }
     public function exportProvince($input)
-    {
+    {   
+        //$input['date']=1;
         //$input['month']=1;
         //$input['year']=2014;
@@ -183,6 +181,10 @@
     public function exportPackage($input)
     {
+       // $input['date']=1;
         //$input['month']=1;
-        //$input['year']=2014;
+      //  $input['year']=2014;
+      // $input['to_month']=1;
+       // $input['to_year']=2015;
+       // $input['to_date']=15;
         if (isset($input['month']))
         {
