This topic is locked
[SOLVED]

 Question on how to do

12/23/2009 12:18:06 PM
PHPRunner General questions
H
htwebdev author

NOT SOLVED!
I inherited this project from a developer that is no longer here, never used PHPR before this week, and I can't figure out how to do what I'm trying to do. Been reading through the manual and this forum and haven't found it yet either. I'm using PHPR 5.1-build 2503, the db is MS SQL Server.
I have a list page that shows duplicate record of 1 table comparing to another table. It's a staging table from an Excel import. I want them the user to be able to delete duplicates before committing these records to the final table. What I need is a button (or link) that will allow the user to commit the records after they've handled the duplicates and the records are finalized. Where/how do I do that?
Bill

H
htwebdev author 12/23/2009
L
lewisekrantz 12/23/2009



I inherited this project from a developer that is no longer here, never used PHPR before this week, and I can't figure out how to do what I'm trying to do. Been reading through the manual and this forum and haven't found it yet either. I'm using PHPR 5.1-build 2503, the db is MS SQL Server.
I have a list page that shows duplicate record of 1 table comparing to another table. It's a staging table from an Excel import. I want them the user to be able to delete duplicates before committing these records to the final table. What I need is a button (or link) that will allow the user to commit the records after they've handled the duplicates and the records are finalized. Where/how do I do that?
Bill


If I understand your issue, this is one way to address it ..
Lets say your FINAL TABLE is "cars"
Set up a TABLE named "cars_preprocess"
Import from excell into "cars_preprocess"
Your user can edit and delete from "cars_preprocess"
Then you write a code snipped that is triggered by a button that ....
reads thru "cars_preprocessed" and writes records to "cars" and then deletes all of the records in "cars_preprocessed"
Lewis

H
htwebdev author 12/23/2009



If I understand your issue, this is one way to address it ..
Lets say your FINAL TABLE is "cars"
Set up a TABLE named "cars_preprocess"
Import from excell into "cars_preprocess"
Your user can edit and delete from "cars_preprocess"
Then you write a code snipped that is triggered by a button that ....
reads thru "cars_preprocessed" and writes records to "cars" and then deletes all of the records in "cars_preprocessed"
Lewis



I've got the database and everything already done and working, up to the point of creating the event. I have my query already to transfer and delete the records. I'm just not sure how to get the button/event on the page.

H
htwebdev author 12/24/2009



http://www.xlinesoft.com/phprunner/docs/update_multiple_tables.htm



here's my only question, as far as this table, I only have Import, List and Delete on it. The page will display all the records imported and then show which are possible duplicates from the main table (so they can be removed). Once they have the records as they want them, then the user can move them to the production table. Where would I put that event? so far, nothing has worked (I've tried in several spots).
I may add an edit to this table as it may be needed though.

J
Jane 12/24/2009

Sorry for my fault. Here is the correct link:

http://www.xlinesoft.com/phprunner/docs/update_multiple_records.htm
Create new button on the list page, and then move selected records to another table in the Before Delete event on the Events tab.

H
htwebdev author 12/24/2009

Nothing is happening with that either.
I have put this into the html:

<INPUT class=button id=submit2 type=submit value="Commit Stores" name=submit2>



and in the Before Record Deleted event, I have this:

if ($_REQUEST["submit2"]=="Commit Stores"){

global $conn;

$strSQLInsert = "INSERT INTO Stores (StoreNum, Address, City, State, Zip, MainPhone, Fax, CompanyID, InstallDate, ETA, SSTTechnician, CompanyName) SELECT cast(STORE as int) AS StoreNum, ADDRESS AS Address, CITY AS City, ST AS State, ZIP as Zip, PHONE as MainPhone, FAX as Fax, substring(COMPANY,1,1) as CompanyID, InstallDate, ETA, Technician as SSTTechnician, rtrim(ltrim(substring(COMPANY,4,25))) as CompanyName FROM Stores_stage";

db_exec($strSQLInsert,$conn);

$sqldelete = "DELETE FROM Stores_stage";

db_exec($sqldelete,$conn);

}



I'm not getting any of the records inserted or deleted.
Let me add a bit here. The user is sitting on the list page. They've made their edits and deletions and have these records ready to move into the production table from the stage table. They need to be able to click a button that basically does what's in the script above.

H
htwebdev author 12/24/2009

I didn't mean to mark this as solved, accidentally clicked wrong button - this is NOT solved.
I'm thinking of hijacking the export page and doing my stuff before the page is initialized and the redirecting back to the list page - since I don't need the export

J
Jane 12/25/2009

Hi,
first here is the correct button:

<INPUT class=button onclick="frmAdmin.a.value='update'; frmAdmin.submit(); return false;" value="Move selected records to production table" type=button>



You should add it on the list page on the Visual Editor tab.
Then user select records on the list page and use thi s button to insert selected records to the production table.

Here is a sample Before record deleted event:

if ($_REQUEST["a"]=="update")

{

global $conn;

$strSQLInsert = "INSERT INTO Stores (StoreNum, Address, City, State, Zip, MainPhone, Fax, CompanyID, InstallDate, ETA, SSTTechnician, CompanyName) SELECT cast(STORE as int) AS StoreNum, ADDRESS AS Address, CITY AS City, ST AS State, ZIP as Zip, PHONE as MainPhone, FAX as Fax, substring(COMPANY,1,1) as CompanyID, InstallDate, ETA, Technician as SSTTechnician, rtrim(ltrim(substring(COMPANY,4,25))) as CompanyName FROM Stores_stage where ".$where;

db_exec($strSQLInsert,$conn);

$sqldelete = "DELETE FROM Stores_stage where ".$where;

db_exec($sqldelete,$conn);

}
H
htwebdev author 12/30/2009

cool. that worked. must be the onclick event that I was missing before. Thanks.