Ejemplo n.º 1
0
 /**
  * Hàm khôi phục phiếu thu chi từ thùng rác
  */
 function recoveryMoneyTicket()
 {
     //check quyền recovery
     checkPermission('recovery');
     $record_id = getValue('record_id', 'int', 'POST', 0);
     if (trash_recovery($record_id, $this->bg_table) === TRUE) {
         //khôi phục thành công
         $array_return = array('success' => 1);
     } else {
         $array_return = array('error' => 'Khôi phục không thành công');
     }
     $this->add(json_encode($array_return));
 }
Ejemplo n.º 2
0
 function recoveryRecord()
 {
     // TODO: Implement recoveryRecord() method.
     //kiểm tra quyền khôi phục
     checkPermission('recovery');
     $record_id = getValue('record_id', 'int', 'POST', 0);
     //phục hồi dữ liệu
     $result = trash_recovery($record_id, $this->bg_table);
     if ($result) {
         $array_return = array('success' => 1);
     } else {
         $array_return = array('success' => 0, 'error' => 'Khôi phục không thành công');
     }
     $this->add(json_encode($array_return));
 }
Ejemplo n.º 3
0
 function recoveryRecord()
 {
     //kiểm tra quyền khôi phục
     checkPermission('recovery');
     global $bg_table;
     $record_id = getValue('record_id', 'int', 'POST', 0);
     //phục hồi dữ liệu
     $result = trash_recovery($record_id, $bg_table);
     if ($result) {
         $array_return = array('success' => 1);
     } else {
         $array_return = array('success' => 0, 'error' => 'Khôi phục không thành công');
     }
     die(json_encode($array_return));
 }
Ejemplo n.º 4
0
 /**
  * Hàm khôi phục phiếu kiểm kê từ thùng rác
  */
 function recoveryStockTransfer()
 {
     //check quyền recovery
     checkPermission('recovery');
     $record_id = getValue('record_id', 'int', 'POST', 0);
     if (trash_recovery($record_id, 'stock_transfer') === TRUE) {
         //khôi phục thành công
         $array_return = array('success' => 1, 'msg' => 'Khôi phục không thành công');
     } else {
         $array_return = array('error' => 0, 'msg' => 'Đã có lỗi vui lòng thử lại sau');
     }
     $this->add(json_encode($array_return));
 }
Ejemplo n.º 5
0
                     $right_column .= '<td>' . $row['adm_note'] . '</td>';
                     $right_column .= $list->end_tr();
                 }
                 $right_column .= $list->showFooter();
                 echo $right_column;
             }
             break;
     }
     break;
     //phục hồi dữ liệu
 //phục hồi dữ liệu
 case 'recycleRow':
     $user_id = getValue('user', 'int', 'POST', 0);
     $array_return = array();
     //phục hồi dữ liệu
     $result = trash_recovery($user_id, 'admin_users');
     if ($result) {
         $array_return = array('success' => 1);
     } else {
         $array_return = array('success' => 0, 'error' => 'Khôi phục không thành công');
     }
     die(json_encode($array_return));
     break;
 case 'loadFormAddUser':
     //load form thêm mới tài khoản đăng nhập
     $form = new form();
     $html = '';
     $array_group_user = array(0 => ' - Chọn nhóm quản lý - ');
     $db_query = new db_query('SELECT * FROM admin_users_groups');
     while ($row = mysqli_fetch_assoc($db_query->result)) {
         $array_group_user[$row['adu_group_id']] = $row['adu_group_name'];
Ejemplo n.º 6
0
 function restoreBill()
 {
     checkPermission('recovery');
     $record_id = getValue('record_id', 'int', 'POST', 0);
     $table = getValue('table', 'str', 'POST', '');
     $tra_table_financies = 'financial';
     ///* kiểm tra xem hóa đơn còn tồn tại trong thùng rác hay đã bị xóa
     $db_count = new db_count('SELECT count(*) AS count FROM trash 
                                                     WHERE tra_record_id = ' . intval($record_id) . ' 
                                                     AND tra_table = \'' . $table . '\'');
     if ($db_count->total == 0) {
         $array_return['success'] = 0;
         echo json_encode($array_return);
         exit;
     }
     //
     $db_count = new db_count('SELECT count(*) AS count FROM trash 
                                                     WHERE tra_record_id = ' . intval($record_id) . ' 
                                                     AND tra_table = \'' . $table . '_detail\'');
     if ($db_count->total == 0) {
         $array_return['success'] = 0;
         echo json_encode($array_return);
         exit;
     }
     //*/
     if (trim($table) == 'bill_in') {
         $tra_option_filter = 'Phiếu thu';
         //lấy ra id kho
         // lay ra id phieu thu trong thung rac
         $sql = new db_query('SELECT * FROM trash 
                                         WHERE tra_record_id = ' . intval($record_id) . ' 
                                         AND tra_table = \'' . $table . '\'');
         $tra_data = mysqli_fetch_assoc($sql->result);
         unset($sql);
         $tra_data = json_decode(base64_decode($tra_data['tra_data']), 1);
         $store = $tra_data['bii_store_id'];
         $list_fin_id = $tra_data['arr_fin_id'];
         $list_fin_id = explode(',', $list_fin_id);
         // kiểm tra xem phiếu thu trong thùng rác tồn tại hay không
         foreach ($list_fin_id as $fin_id) {
             $db_count_financies = new db_count('SELECT count(*) AS count FROM trash 
                                                         WHERE tra_record_id = ' . intval($fin_id) . ' 
                                                         AND tra_table = \'' . trim($tra_table_financies) . '\'');
             if ($db_count_financies->total == 0) {
                 $array_return['success'] = 0;
                 echo json_encode($array_return);
                 exit;
             }
             trash_recovery($fin_id, $tra_table_financies);
         }
         //Lấy ra số lượng của các thực đơn trong hóa đơn ở trong thùng rác
         $sql = new db_query('SELECT * FROM trash 
                                         WHERE tra_record_id = ' . intval($record_id) . ' 
                                         AND tra_table = \'' . $table . '_detail\'');
         while ($row = mysqli_fetch_assoc($sql->result)) {
             $record_id_bill_detail = $row['tra_record_id'];
             $table_bill_detail = $row['tra_table'];
             $data = json_decode(base64_decode($row['tra_data']), 1);
             $db_product = new db_query('SELECT *
                                         FROM menu_products
                                         LEFT JOIN product_quantity ON product_id = mep_product_id
                                         WHERE mep_menu_id = ' . $data['bid_menu_id'] . '
                                         AND store_id = ' . $store);
             //cap nhat lai so luong khi xóa
             while ($row_pro = mysqli_fetch_assoc($db_product->result)) {
                 $sql_minus = 'UPDATE product_quantity 
                                 SET pro_quantity = pro_quantity - ' . $row_pro['mep_quantity'] * $data['bid_menu_number'] . ' 
                                 WHERE product_id = ' . $row_pro['product_id'] . ' 
                                 AND store_id = ' . $store;
                 $db_update = new db_execute($sql_minus);
                 unset($db_update);
             }
             unset($db_product);
             trash_recovery($record_id_bill_detail, $table_bill_detail);
         }
         unset($sql);
         trash_recovery($record_id, $table);
         $array_return = array('success' => 1);
     }
     if (trim($table) == 'bill_out') {
         $tra_option_filter = 'Phiếu chi';
         //l?y ra id kho
         // lấy ra id phiếu chi trong thùng rác
         $sql = new db_query('SELECT * FROM trash 
                                         WHERE tra_record_id = ' . intval($record_id) . ' 
                                         AND tra_table = "' . $table . '"');
         $tra_data = mysqli_fetch_assoc($sql->result);
         unset($sql);
         $tra_data = json_decode(base64_decode($tra_data['tra_data']), 1);
         $store = $tra_data['bio_store_id'];
         $id_fin = $tra_data['arr_fin_id'];
         $list_fin_id = explode(',', $id_fin);
         foreach ($list_fin_id as $fin_id) {
             // kiểm tra xem phiếu thu trong thùng rác tồn tại hay không
             $db_count_financies = new db_count('SELECT count(*) AS count FROM trash 
                                                         WHERE tra_record_id = ' . intval($fin_id) . ' 
                                                         AND tra_table = \'' . trim($tra_table_financies) . '\'');
             if ($db_count_financies->total == 0) {
                 $array_return['success'] = 0;
                 echo json_encode($array_return);
                 exit;
             }
             trash_recovery($fin_id, $tra_table_financies);
         }
         $sql = new db_query('SELECT * FROM trash 
                                         WHERE tra_record_id = ' . intval($record_id) . ' 
                                         AND tra_table = "' . $table . '_detail"');
         while ($row = mysqli_fetch_assoc($sql->result)) {
             $data = json_decode(base64_decode($row['tra_data']), 1);
             $record_id_bill_detail = $row['tra_record_id'];
             $table_bill_detail = $row['tra_table'];
             $db_product = new db_query('SELECT *
                                         FROM products
                                         LEFT JOIN product_quantity ON product_id = pro_id
                                         WHERE pro_id = ' . $data['bid_pro_id'] . '
                                         AND store_id = ' . $store);
             while ($row_pro = mysqli_fetch_assoc($db_product->result)) {
                 // cap nhat lai so luong sau khi khoi phuc hoa don nhap
                 $sql_minus = 'UPDATE product_quantity SET pro_quantity = pro_quantity + ' . $data['bid_pro_number'] . ' WHERE product_id = ' . $row_pro['product_id'] . ' AND store_id = ' . $store;
                 $db_update = new db_execute($sql_minus);
                 unset($db_update);
             }
             unset($db_product);
             trash_recovery($record_id_bill_detail, $table_bill_detail);
         }
         unset($sql);
         trash_recovery($record_id, $table);
         $array_return = array('success' => 1);
     }
     echo json_encode($array_return);
 }