move a record from table1 to table2

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.

move a record from table1 to table2

Postby Schind » Mon Jan 08, 2018 4:46 am


re: viewtopic.php?f=18&t=13361

how would i make an additional button to move the records as opposed to using the delete function, i dont want to give everyone access to the delete function and i would like to still use the delete function for the admins.
Posts: 7
Joined: Wed Jan 03, 2018 12:26 pm

Re: move a record from table1 to table2

Postby arbei » Mon Jan 08, 2018 1:47 pm

As you already implemented the logic of move the records from table1 to table2, you can add a URL parameter based on the condition to the delete button, and determine to copy or not based on this URL parameter.

To add the URL parameter to delete button based on condition.
For example:
if (<Condition>) {
$this->DeleteUrl .= "&<parm>=1";

Then check the URL parameter in Row_Deleting.
For example:
if (@$_GET["<parm>"] != "") {
// perform copy
} else {
// do not copy.
Posts: 1499
Joined: Wed Sep 09, 2015 10:13 am

Re: move a record from table1 to table2

Postby kirondedshem » Mon Jan 08, 2018 1:48 pm

I think you should use custom action, which provides an extra link for each record and when you click the link it will submit the record to custom_action event where you can do whatever you want to that record, ie run some querires. You can even use multiple select and sumit multiple records. Read (custom action) in help menu.

But in summary, draw a custom action for each record like
function ListOptions_Rendered() {
//CREATE An action named, process_lead
//check a condition before you draw it for each record
//use $this->field_name->CurrentValue to access the value of the field you want to check with
//if condition is true then draw this button for this record
$opt = &$this->ListOptions->Add("custom_action");//create the list option first
$opt->Header = "Receipts";//add a header for this column
$this->ListOptions->Items["custom_action""]->Body = "<a href=\"#\" onclick=\"return ew_SubmitAction(event, {action: 'my_action', method: 'postback', msg: 'Perform this action?', key: " . $this->KeyToJson() . "});\">Process This</a>";


NOTE:This will work by deafult, unless you have a custom list template body, in which case you have to add an extra column and put {{{list_option custom_action}}}.
NOTE:You should see an extra button next to any of the records in that list page. After this then put your implimentation in Row_CustomAction($action, $row)

Then write you code in custom action to tell it what to do after you submit a given record

function Row_CustomAction($action, $row) {
//check th action to process by
if ($action == "my_action") { // Check action name
//access whetver value of that row by using $row["filed_name"]
$id = $row["id"];
//write sql queries to do what you want here
$this->setSuccessMessage("I have processed lead of id=$id");
return TRUE; // Success
Posts: 330
Joined: Sat Jan 28, 2017 7:13 pm

Return to General Discussion (PHPMaker)