Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82604

New Idea, Editor calls an Editor. seeking best-practices advice

$
0
0

I have lots of tables. Often when you update one table, you need to update another (or even the same, different field).

Here is an example of such an "automation"...

if DTEditor changed Housekeeping to Clean, also set Overview to Available (but only if it was previously Not Ready):

      //Now see if we need to adjust any other status
      //  Check if RoomStatus_Housekeeping was updated
      $Editor->on('process', function ($action, $id, $data, $response) 
       {if ($action === Editor::ACTION_EDIT && isset($data['RoomStatus_Housekeeping'])) 
         { $hid = $data['Hotel_ID'];
          $grid = $data['GuestRoom_ID'];
          $stat = $data['RoomStatus_Housekeeping'];
          $stid = $id;

          // Update Overview status based on Housekeeping status
          if ($stat == 'Clean') 
           {$sql = "UPDATE Hotel_GuestRoom_Status 
                    SET RoomStatus_Overview='Available'
                    WHERE Hotel_ID=:hotel 
                      AND RoomStatus_ID!=:stid
                      AND GuestRoom_ID=:room
                      AND RoomStatus_Overview='Not Ready'
                      AND RoomStatus_Maintenance IN ('No Issues', 'None', 'NONE')
                  ;";
           }
          else 

Now I want to do the following:

If a line-item price is updated, update charge total
if a charge is updated, update roomstay total
if a roomstay is updated, update booking total

Therefore... if a line-item is updated, it will cascade and update the charge, roomstay, and booking.

QUESTION: Rather than having a change to the line-item update 3 tables, my idea is to have it call a different DTEditor php to edit the Charge... and it will call a different DTEditor php to update the RoomStay, which will call the Booking. Is this possible / advisable? ...or do you think I should just update my 3 tables, 2 tables, 1 table in each editor?

If it is a good idea, I wouldn't mind being spoon fed how to have an editor call another php and pass it variables (along with what variables to pass to the 2nd editor to get it to think it was a standard datatable edit and process my update).

Would I have to / want to use the PHP output buffer to have the php call another php?

Thanks for any input on this idea.


Viewing all articles
Browse latest Browse all 82604

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>