This topic is locked

allow user to delete record from view

3/10/2017 12:30:55 AM
PHPRunner General questions
W
wfcentral author

I have a table called invoices and a view called my_invoices that users can only see invoices they created.
I need them to be able to delete from that view.
I understand that this code needs to be added to the events for the my_invoices list page, but I'm not clear where to put it so I don't get an error.
I put this code (below) on the "before delete" event for the list page - it does delete the record - however, I still get the warning page about how you cannot delete from the my_invoices join page...
$sql = "DELETE FROM invoices WHERE invoice_ID = '".$deleted_values['invoice_ID']."'";

CustomQuery($sql);

HJB 3/10/2017

I would recommend to use HIDE rather than DELETE, on the "my view - invoice table". Usually, once an invoice is paid,

you don't want to see it on the table when monitoring of what invoices are yet due for payment.
https://xlinesoft.com/phprunner/docs/about_sql_query_designer.htm
Screenshot inside is showing "FILTER" which means that once you place "unpaid" as additional field inside you

table, your clients would just need to enter "paid" and would only view "unpaid" ones (as the others are hidden).
Finally, any good bookkeeper needs to summarize invoice values per month / quarter / year etc pp by means of a report,

yet once the values are DELETED rather than HIDDEN, such statistical doings would be totally out of reach.

W
wfcentral author 3/10/2017



I would recommend to use HIDE rather than DELETE, on the "my view - invoice table". Usually, once an invoice is paid,

you don't want to see it on the table when monitoring of what invoices are yet due for payment.
https://xlinesoft.com/phprunner/docs/about_sql_query_designer.htm
Screenshot inside is showing "FILTER" which means that once you place "unpaid" as additional field inside you

table, your clients would just need to enter "paid" and would only view "unpaid" ones (as the others are hidden).
Finally, any good bookkeeper needs to summarize invoice values per month / quarter / year etc pp by means of a report,

yet once the values are DELETED rather than HIDDEN, such statistical doings would be totally out of reach.


thanks - I will have a look at your comment because I am using a paid checkbox as well.
I DO need the user to DELETE an invoice.
The delete invoice option is only there if they generate an invoice incorrectly and need to remove it so they can create a new one. The system pulls data from an uploaded file in order to create an invoice along with other items the user must do. If they neglect to do all those items the invoice they generate may be incorrect. Rather than building the system to check an on-going list of items I would like the user to be able to delete faulty invoices so they can create new invoices in their place.

HJB 3/10/2017

https://xlinesoft.com/marketplace/products_view.php?editid1=1
@wfcentral

To get into the arena of fool-proof invoicing incl. mail dispatch,

I want you to bless yourself by a though too timely XMAS gift of

$49 by means of the INVOICE template, or say, to sell your VW beetle

like app into the S&P market to then take a seat in a MAYBACH ;-)

lefty 3/10/2017



I appreciate you trying to help - but that invoice system would not work in the project I am building... I have just finished 40+ hours developing a system that imports data from excel spreadsheets and allows users to auto-generate invoices while assigning various percentages to developers, publishers, funding agencies, etc. On top of that it creates custom PDFs according to the clients exhaustive list of requirements. The only item I am trying to finish to ship the product is allowing lower level users the ability to delete an invoice they created by mistake.


  1. Do you have lookups that the user has no access to in the Invoice table that you copied to my_invoice table . Won't work lookup uses security also ( error message ) . Use clean my_invoices view.
  2. If so do not use in the my_invoice table lookup value uses security to check if they have access to them in the my_invoice table .
  3. Add a userid session value to your sql query - And '" . $_SESSION["Useridfieldname"] = ' " . $values["Useridfieldname"]. "' . IN Employees table also.

    3b. Start by adding $_SESSION["userid"] = $data["userid"]; in after sucessfull login event
  4. If you use import feature like import from excel,csv etc... add userid field to one of the columns with userid so each order is assigned to specific user.
  5. Advanced security feature should be set in my_invoice table for only see and edit/delete/print/export/import user records only . where is main table Invoice is set to admin . ( master admin ) can delete ,add , edit etc...
    Hope this helps.
    Just a question about your PDF's how did you implement that . Your own code, DOMPDF , FPDF or something else . I have been trying to generate pdf on the fly after add and email as attachments .

W
wfcentral author 3/10/2017



https://xlinesoft.com/marketplace/products_view.php?editid1=1
@wfcentral

To get into the arena of fool-proof invoicing incl. mail dispatch,

I want you to bless yourself by a though too timely XMAS gift of

$49 by means of the INVOICE template, or say, to sell your VW beetle

like app into the S&P market to then take a seat in a MAYBACH ;-)


I appreciate you trying to help - but that invoice system would not work in the project I am building... I have just finished 40+ hours developing a system that imports data from excel spreadsheets and allows users to auto-generate invoices while assigning various percentages to developers, publishers, funding agencies, etc. On top of that it creates custom PDFs according to the clients exhaustive list of requirements. The only item I am trying to finish to ship the product is allowing lower level users the ability to delete an invoice they created by mistake.

W
wfcentral author 3/13/2017




  1. Do you have lookups that the user has no access to in the Invoice table that you copied to my_invoice table . Won't work lookup uses security also ( error message ) . Use clean my_invoices view.
  2. If so do not use in the my_invoice table lookup value uses security to check if they have access to them in the my_invoice table .
  3. Add a userid session value to your sql query - And '" . $_SESSION["Useridfieldname"] = ' " . $values["Useridfieldname"]. "' . IN Employees table also.

    3b. Start by adding $_SESSION["userid"] = $data["userid"]; in after sucessfull login event
  4. If you use import feature like import from excel,csv etc... add userid field to one of the columns with userid so each order is assigned to specific user.
  5. Advanced security feature should be set in my_invoice table for only see and edit/delete/print/export/import user records only . where is main table Invoice is set to admin . ( master admin ) can delete ,add , edit etc...
    Hope this helps.
    Just a question about your PDF's how did you implement that . Your own code, DOMPDF , FPDF or something else . I have been trying to generate pdf on the fly after add and email as attachments .


thanks - I'll come back to this if needed - for now, the client decided they do not want lower employees to be able to delete any invoices - if they make a mistake they will need to ask an admin to delete the mistake invoice.
As for the PDFs - I am using a version of FPDF that is actually pretty old - but, it works great and I have not had a chance to work out bugs with a newer version. I modified the code that came with it so now I have three buttons in my phprunner project (web view, download PDF and email PDF). clicking those links will either show them the web version of an invoice, download the invoice as a pdf OR email the pdf as an attachment to the email address in the database record.