I need a solution, will pay $30 // SIMPLE // 20 min job

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

I need a solution, will pay $30 // SIMPLE // 20 min job

Post by D Oliveira » 2018-03-14 14:34

Ok.... tough times getting support, lets jump right to it, I will pay you $30 through paypal if you can solve this issue and give me clear directions on how to set this up.

I have 4 tables: gutter_tbl, screen_tbl, roofing_tbl and master_table

I wanna filter the invoiced field (and other fields) of the first 3 tables but appgini does not support views so I wanna clone these values inside the master_table.

scenario 1 (gutter page):

Code: Select all

gutter_tbl.id = 127
gutter_tbl.invoiced = "yes"
gutter_tbl.add = "Downspot"
scenario 1(master page):

Code: Select all

master_table.gutterid = 127
master_table.gutterinvoiced = "yes"
master_table.gutteradd = "Downspot"
master_screenid = ""
master_screeninvoiced = ""
master_table.screendogdoors = ""
master_roofingid = ""
master_rooinfinvoiced = ""
master_table.roofingtype = ""
scenario 2 (screen page):

Code: Select all

screen_tbl.id = 231
screen_tbl.invoiced = "no"
screen_tbl.dogdoors = 3
scenario 2 (master page):

Code: Select all

master_table.gutterid = ""
master_table.gutterinvoiced = ""
master_table.gutteradd = ""
master_table.screenid = 231
master_table.screeninvoiced = "no"
master_table.screendogdoors = 3
master_table.roofingid = ""
master_table.rooinfinvoiced = ""
master_table.roofingtype = ""
scenario 3 (roofing page):

Code: Select all

roofing_tbl.id = 786
roofing_tbl.invoiced = "yes"
roofing.type = "SHINGLE"
scenario 3 (master page):

Code: Select all

master_table.gutterid = 
master_table.gutterinvoiced = ""
master_table.gutteradd = ""
master_table.screenid = ""
master_table.screendogdoors = ""
master_table.screeninvoiced = ""
master_table.roofingid = 786
master_table.rooinfinvoiced = "yes"
master_table.roofingtype = "SHINGLE"
Now... if we are in the gutter section trying to create a record, first we gotta check if that record exists in the master table ( we can use the gutterid field for this ), if it exists we update and if not we create a new record. Then, if we delete a record from the gutter table (or screen or roofing) it has to be deleted from the master_table as well. Lastly, it would be awesome if the mass delete function of each table was connected to the master_table.

Whos in for the job? Thanks in advance, have a good day.

*sql statements in the hooks might be the way to do it but I couldnt build it myself*

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: I need a solution, will pay $30 // SIMPLE // 20 min job

Post by R Tammam » 2018-03-21 01:29

Hello D Oliveira ,

the solution is so simple , you shoud

1-for inserting the inserted values of (gutter_tbl, screen_tbl, roofing_tbl ) in master_ table
use after insert function of (gutter_tbl, screen_tbl, roofing_tbl ) to insert in master table
in each function write a sql to insert
for example
insert into master_table (gutterid,gutterinvoiced,gutteradd) values ($data['selectedID'] ,data['invoiced'],data['add']);
and do the same for other table

2-for updating the updated values of (gutter_tbl, screen_tbl, roofing_tbl ) in master_ table
use after update function of (gutter_tbl, screen_tbl, roofing_tbl ) to update in master table
in each function write a sql to update
for example
update master_table
set gutterinvoiced = data['invoiced'],
gutteradd = data['dd']
where gutterid = $data['selectedID']
and do the same for other table

3-for deleting the deleted values of (gutter_tbl, screen_tbl, roofing_tbl ) in master_ table
use after delete function of (gutter_tbl, screen_tbl, roofing_tbl ) to delete of master table
in each function write a sql to delete
for example
delete from master_table where gutterid = $data['selectedID']
and do the same for other table

* the mass delete function calls the after delete function so , if you handled it in after delete function , it would be handled in mass delete function

hope it would help you
Regards,
Reham

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: I need a solution, will pay $30 // SIMPLE // 20 min job

Post by D Oliveira » 2018-03-21 20:25

R Tammam wrote:
2018-03-21 01:29
Hello D Oliveira ,

the solution is so simple , you shoud

1-for inserting the inserted values of (gutter_tbl, screen_tbl, roofing_tbl ) in master_ table
use after insert function of (gutter_tbl, screen_tbl, roofing_tbl ) to insert in master table
in each function write a sql to insert
for example
insert into master_table (gutterid,gutterinvoiced,gutteradd) values ($data['selectedID'] ,data['invoiced'],data['add']);
and do the same for other table

2-for updating the updated values of (gutter_tbl, screen_tbl, roofing_tbl ) in master_ table
use after update function of (gutter_tbl, screen_tbl, roofing_tbl ) to update in master table
in each function write a sql to update
for example
update master_table
set gutterinvoiced = data['invoiced'],
gutteradd = data['dd']
where gutterid = $data['selectedID']
and do the same for other table

3-for deleting the deleted values of (gutter_tbl, screen_tbl, roofing_tbl ) in master_ table
use after delete function of (gutter_tbl, screen_tbl, roofing_tbl ) to delete of master table
in each function write a sql to delete
for example
delete from master_table where gutterid = $data['selectedID']
and do the same for other table

* the mass delete function calls the after delete function so , if you handled it in after delete function , it would be handled in mass delete function

hope it would help you
Regards,
Reham
Im getting the following error when writing the insert into sql update

Code: Select all

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\tigercontrol\hooks\gutter_tbl.php on line 80

this is what I wrote

Code: Select all

sql("insert into master_table (gutterid,gutterinvoiced,gutteradd) values ($data['selectedID'] , $data['invoiced'], $data['add'])", $eo)

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: I need a solution, will pay $30 // SIMPLE // 20 min job

Post by D Oliveira » 2018-03-21 23:30

nevermind, small syntax error, everything working great! I'll share it here for future users with the same question. Thank you

Code: Select all


function gutterwb_after_insert($data, $memberInfo, &$args){


		sql("INSERT INTO `masterwb` (`gwoid`,`gstatus`,`gplan`) VALUES ('{$data['selectedID']}','{$data['status']}','{$data['plan']}')", $eo);

		return TRUE;
	}

	function gutterwb_before_update(&$data, $memberInfo, &$args){


		return TRUE;
	}

	function gutterwb_after_update($data, $memberInfo, &$args){

		sql("UPDATE `masterwb` SET `gwoid` = '{$data['selectedID']}', `gstatus` = '{$data['status']}', `gplan` = '{$data['plan']}' WHERE `gwoid` = '{$data['selectedID']}'", $eo);

		return TRUE;
	}

	function gutterwb_before_delete($selectedID, &$skipChecks, $memberInfo, &$args){

		sql("DELETE FROM masterwb WHERE gwoid=$selectedID", $eo);


		return TRUE;
	}



R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: I need a solution, will pay $30 // SIMPLE // 20 min job

Post by R Tammam » 2018-03-27 16:45

Thanks D Oliveria for your effort and i'm happy that you could do it successfully

Post Reply